@Primary @Component(value="blBasicPersistenceModule") @Scope(value="prototype") public class BasicPersistenceModule extends Object implements PersistenceModule, RecordHelper, org.springframework.context.ApplicationContextAware
| Modifier and Type | Field and Description |
|---|---|
static String |
ALTERNATE_ID_PROPERTY |
protected org.springframework.context.ApplicationContext |
applicationContext |
protected CriteriaTranslator |
criteriaTranslator |
protected FieldPersistenceProvider |
defaultFieldPersistenceProvider |
protected EntityValidatorService |
entityValidatorService |
protected BasicPersistenceModuleExtensionManager |
extensionManager |
protected List<FieldPersistenceProvider> |
fieldPersistenceProviders |
static String |
MAIN_ENTITY_NAME_PROPERTY |
protected PersistenceManager |
persistenceManager |
protected List<PopulateValueRequestValidator> |
populateValidators |
protected RestrictionFactory |
restrictionFactory |
| Constructor and Description |
|---|
BasicPersistenceModule() |
| Modifier and Type | Method and Description |
|---|---|
Entity |
add(PersistencePackage persistencePackage) |
EntityResult |
add(PersistencePackage persistencePackage,
boolean includeRealEntityObject) |
protected List<TQRestriction> |
buildSpecialRestrictions(String specialExpression,
List<FilterMapping> filterMappings)
Generate EQUALS restrictions for any filter property specified on the entity member of the collection field in the @Embeddable object
|
protected List<TQRestriction> |
buildStandardRestrictions(FieldPath embeddedCollectionPath,
List<FilterMapping> filterMappings)
Generate LIKE or EQUALS restrictions for any filter property specified on the root entity (not the collection field in the @Embeddable object)
|
protected void |
cleanupFailedPersistenceAttempt(Serializable instance) |
Serializable |
createPopulatedInstance(Serializable instance,
Entity entity,
Map<String,FieldMetadata> unfilteredProperties,
Boolean setId)
Delegates to the overloaded method with validateUnsubmittedProperties set to true.
|
Serializable |
createPopulatedInstance(Serializable instance,
Entity entity,
Map<String,FieldMetadata> unfilteredProperties,
Boolean setId,
Boolean validateUnsubmittedProperties)
Populates a Hibernate entity instance based on the values from entity (the DTO representation of
instance) and the metadata from mergedProperties.
|
void |
extractProperties(Class<?>[] inheritanceLine,
Map<MergedPropertyType,Map<String,FieldMetadata>> mergedProperties,
List<Property> properties) |
protected void |
extractPropertiesFromMetadata(Class<?>[] inheritanceLine,
Map<String,FieldMetadata> mergedProperties,
List<Property> properties,
Boolean isHiddenOverride,
MergedPropertyType type) |
protected void |
extractPropertiesFromPersistentEntity(Map<String,FieldMetadata> mergedProperties,
Serializable entity,
List<Property> props) |
DynamicResultSet |
fetch(PersistencePackage persistencePackage,
CriteriaTransferObject cto) |
protected Map<String,FieldMetadata> |
filterOutCollectionMetadata(Map<String,FieldMetadata> metadata) |
String |
formatValue(Object value)
Formats a aw value from an entity into its string representation used by the system.
|
protected Class<?> |
getBasicBroadleafType(SupportedFieldType fieldType) |
PersistenceModule |
getCompatibleModule(OperationType operationType) |
CriteriaTranslator |
getCriteriaTranslator() |
DecimalFormat |
getDecimalFormatter() |
FieldPersistenceProvider |
getDefaultFieldPersistenceProvider() |
EntityValidatorService |
getEntityValidatorService() |
FieldManager |
getFieldManager() |
List<FieldPersistenceProvider> |
getFieldPersistenceProviders() |
List<FilterMapping> |
getFilterMappings(PersistencePerspective persistencePerspective,
CriteriaTransferObject cto,
String ceilingEntityFullyQualifiedClassname,
Map<String,FieldMetadata> mergedUnfilteredProperties) |
List<FilterMapping> |
getFilterMappings(PersistencePerspective persistencePerspective,
CriteriaTransferObject cto,
String ceilingEntityFullyQualifiedClassname,
Map<String,FieldMetadata> mergedUnfilteredProperties,
RestrictionFactory customRestrictionFactory) |
String |
getIdPropertyName(Map<String,FieldMetadata> mergedUnfilteredProperties) |
protected Class<?> |
getMapFieldType(Serializable instance,
FieldManager fieldManager,
Property property) |
Serializable |
getMaxValue(String ceilingEntity,
List<FilterMapping> filterMappings,
String maxField) |
Map<String,FieldMetadata> |
getMergedProperties(PersistencePackage persistencePackage,
CriteriaTransferObject cto) |
PersistenceManager |
getPersistenceManager() |
List<Serializable> |
getPersistentRecords(String ceilingEntity,
List<FilterMapping> filterMappings,
Integer firstResult,
Integer maxResults) |
Object |
getPrimaryKey(Entity entity,
Map<String,FieldMetadata> mergedUnfilteredProperties) |
Entity |
getRecord(Class<?> ceilingEntityClass,
PersistencePerspective persistencePerspective,
Serializable record) |
Entity |
getRecord(Map<String,FieldMetadata> primaryMergedProperties,
Serializable record,
Map<String,FieldMetadata> alternateMergedProperties,
String pathToTargetObject) |
Entity[] |
getRecords(Class<?> ceilingEntityClass,
PersistencePerspective persistencePerspective,
List<? extends Serializable> records) |
Entity[] |
getRecords(Map<String,FieldMetadata> primaryMergedProperties,
List<? extends Serializable> records) |
Entity[] |
getRecords(Map<String,FieldMetadata> primaryUnfilteredMergedProperties,
List<? extends Serializable> records,
Map<String,FieldMetadata> alternateUnfilteredMergedProperties,
String pathToTargetObject) |
RestrictionFactory |
getRestrictionFactory() |
SimpleDateFormat |
getSimpleDateFormatter() |
Map<String,FieldMetadata> |
getSimpleMergedProperties(String entityName,
PersistencePerspective persistencePerspective) |
protected TypedQueryBuilder |
getSpecialCaseQueryBuilder(FieldPath embeddedCollectionPath,
List<FilterMapping> filterMappings,
String collectionClass)
Use an alternate approach to generating a fetch query for a collection located inside of an @Embeddable object.
|
String |
getStringValueFromGetter(Serializable instance,
String propertyName)
Returns a string representation of the field on the given instance specified by the property name.
|
Integer |
getTotalRecords(String ceilingEntity,
List<FilterMapping> filterMappings) |
void |
init() |
boolean |
isCompatible(OperationType operationType) |
void |
remove(PersistencePackage persistencePackage) |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setCriteriaTranslator(CriteriaTranslator criteriaTranslator) |
void |
setDefaultFieldPersistenceProvider(FieldPersistenceProvider defaultFieldPersistenceProvider) |
void |
setEntityValidatorService(EntityValidatorService entityValidatorService) |
void |
setFieldPersistenceProviders(List<FieldPersistenceProvider> fieldPersistenceProviders) |
void |
setPersistenceManager(PersistenceManager persistenceManager) |
void |
setRestrictionFactory(RestrictionFactory restrictionFactory) |
Entity |
update(PersistencePackage persistencePackage) |
EntityResult |
update(PersistencePackage persistencePackage,
boolean includeRealEntityObject) |
protected EntityResult |
update(PersistencePackage persistencePackage,
Object primaryKey,
boolean includeRealEntity) |
void |
updateMergedProperties(PersistencePackage persistencePackage,
Map<MergedPropertyType,Map<String,FieldMetadata>> allMergedProperties) |
boolean |
validate(Entity entity,
Serializable populatedInstance,
Map<String,FieldMetadata> mergedProperties)
Delegates to the overloaded method with validateUnsubmittedProperties set to true.
|
boolean |
validate(Entity entity,
Serializable populatedInstance,
Map<String,FieldMetadata> mergedProperties,
boolean validateUnsubmittedProperties)
Validates the
Entity based on the validators associated with each property |
public static final String MAIN_ENTITY_NAME_PROPERTY
public static final String ALTERNATE_ID_PROPERTY
protected org.springframework.context.ApplicationContext applicationContext
protected PersistenceManager persistenceManager
protected EntityValidatorService entityValidatorService
protected List<FieldPersistenceProvider> fieldPersistenceProviders
protected List<PopulateValueRequestValidator> populateValidators
protected FieldPersistenceProvider defaultFieldPersistenceProvider
protected CriteriaTranslator criteriaTranslator
protected RestrictionFactory restrictionFactory
protected BasicPersistenceModuleExtensionManager extensionManager
@PostConstruct public void init()
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
throws org.springframework.beans.BeansException
setApplicationContext in interface org.springframework.context.ApplicationContextAwareorg.springframework.beans.BeansExceptionpublic boolean isCompatible(OperationType operationType)
isCompatible in interface PersistenceModulepublic FieldManager getFieldManager()
getFieldManager in interface RecordHelperpublic DecimalFormat getDecimalFormatter()
getDecimalFormatter in interface DataFormatProviderpublic SimpleDateFormat getSimpleDateFormatter()
getSimpleDateFormatter in interface DataFormatProviderprotected Map<String,FieldMetadata> filterOutCollectionMetadata(Map<String,FieldMetadata> metadata)
protected Class<?> getBasicBroadleafType(SupportedFieldType fieldType)
public Serializable createPopulatedInstance(Serializable instance, Entity entity, Map<String,FieldMetadata> unfilteredProperties, Boolean setId) throws ValidationException
RecordHelpercreatePopulatedInstance in interface RecordHelperValidationExceptionRecordHelper.createPopulatedInstance(Serializable, Entity, Map, Boolean, Boolean)public Serializable createPopulatedInstance(Serializable instance, Entity entity, Map<String,FieldMetadata> unfilteredProperties, Boolean setId, Boolean validateUnsubmittedProperties) throws ValidationException
RecordHelperPopulates a Hibernate entity instance based on the values from entity (the DTO representation of instance) and the metadata from mergedProperties.
While populating instance, validation is also performed using the EntityValidatorService. If this
validation fails, then the instance is left unchanged and a ValidationExcpetion is thrown. In the common
case, this exception bubbles up to the DynamicRemoteService which catches the exception and communicates
appropriately to the invoker
createPopulatedInstance in interface RecordHelpervalidateUnsubmittedProperties - if set to true, will ignore validation for properties that weren't submitted
along with the entityValidationException - if after populating instance via the values in entity then
EntityValidatorService#validate(Entity, Serializable, Map) returns falseEntityValidatorService}public Entity getRecord(Map<String,FieldMetadata> primaryMergedProperties, Serializable record, Map<String,FieldMetadata> alternateMergedProperties, String pathToTargetObject)
getRecord in interface RecordHelperpublic Entity getRecord(Class<?> ceilingEntityClass, PersistencePerspective persistencePerspective, Serializable record)
getRecord in interface RecordHelperpublic Entity[] getRecords(Class<?> ceilingEntityClass, PersistencePerspective persistencePerspective, List<? extends Serializable> records)
getRecords in interface RecordHelperpublic Map<String,FieldMetadata> getSimpleMergedProperties(String entityName, PersistencePerspective persistencePerspective)
getSimpleMergedProperties in interface RecordHelperpublic Entity[] getRecords(Map<String,FieldMetadata> primaryMergedProperties, List<? extends Serializable> records)
getRecords in interface RecordHelperpublic Entity[] getRecords(Map<String,FieldMetadata> primaryUnfilteredMergedProperties, List<? extends Serializable> records, Map<String,FieldMetadata> alternateUnfilteredMergedProperties, String pathToTargetObject)
getRecords in interface RecordHelperprotected void extractPropertiesFromPersistentEntity(Map<String,FieldMetadata> mergedProperties, Serializable entity, List<Property> props)
public String getStringValueFromGetter(Serializable instance, String propertyName) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
RecordHelpergetStringValueFromGetter in interface RecordHelperIllegalAccessExceptionInvocationTargetExceptionNoSuchMethodExceptionpublic String formatValue(Object value)
DataFormatProviderDataFormatProvider.getDecimalFormatter() to ensure that BigDecimals only show 2 decimal places or dates are formatted
a certain way.formatValue in interface DataFormatProviderprotected EntityResult update(PersistencePackage persistencePackage, Object primaryKey, boolean includeRealEntity) throws ServiceException
ServiceExceptionpublic String getIdPropertyName(Map<String,FieldMetadata> mergedUnfilteredProperties)
public Object getPrimaryKey(Entity entity, Map<String,FieldMetadata> mergedUnfilteredProperties)
getPrimaryKey in interface RecordHelperpublic List<FilterMapping> getFilterMappings(PersistencePerspective persistencePerspective, CriteriaTransferObject cto, String ceilingEntityFullyQualifiedClassname, Map<String,FieldMetadata> mergedUnfilteredProperties, RestrictionFactory customRestrictionFactory)
getFilterMappings in interface RecordHelperpublic List<FilterMapping> getFilterMappings(PersistencePerspective persistencePerspective, CriteriaTransferObject cto, String ceilingEntityFullyQualifiedClassname, Map<String,FieldMetadata> mergedUnfilteredProperties)
getFilterMappings in interface RecordHelperpublic void extractProperties(Class<?>[] inheritanceLine, Map<MergedPropertyType,Map<String,FieldMetadata>> mergedProperties, List<Property> properties)
extractProperties in interface PersistenceModuleprotected void extractPropertiesFromMetadata(Class<?>[] inheritanceLine, Map<String,FieldMetadata> mergedProperties, List<Property> properties, Boolean isHiddenOverride, MergedPropertyType type)
public void updateMergedProperties(PersistencePackage persistencePackage, Map<MergedPropertyType,Map<String,FieldMetadata>> allMergedProperties) throws ServiceException
updateMergedProperties in interface PersistenceModuleServiceExceptionpublic EntityResult update(PersistencePackage persistencePackage, boolean includeRealEntityObject) throws ServiceException
update in interface RecordHelperServiceExceptionpublic Entity update(PersistencePackage persistencePackage) throws ServiceException
update in interface PersistenceModuleServiceExceptionpublic Entity add(PersistencePackage persistencePackage) throws ServiceException
add in interface PersistenceModuleServiceExceptionpublic EntityResult add(PersistencePackage persistencePackage, boolean includeRealEntityObject) throws ServiceException
add in interface RecordHelperServiceExceptionpublic void remove(PersistencePackage persistencePackage) throws ServiceException
remove in interface PersistenceModuleServiceExceptionpublic Map<String,FieldMetadata> getMergedProperties(PersistencePackage persistencePackage, CriteriaTransferObject cto) throws ServiceException
ServiceExceptionpublic DynamicResultSet fetch(PersistencePackage persistencePackage, CriteriaTransferObject cto) throws ServiceException
fetch in interface PersistenceModuleServiceExceptionpublic Integer getTotalRecords(String ceilingEntity, List<FilterMapping> filterMappings)
getTotalRecords in interface RecordHelperpublic Serializable getMaxValue(String ceilingEntity, List<FilterMapping> filterMappings, String maxField)
getMaxValue in interface RecordHelperpublic List<Serializable> getPersistentRecords(String ceilingEntity, List<FilterMapping> filterMappings, Integer firstResult, Integer maxResults)
getPersistentRecords in interface RecordHelperpublic boolean validate(Entity entity, Serializable populatedInstance, Map<String,FieldMetadata> mergedProperties)
RecordHelpervalidate in interface RecordHelperRecordHelper.validate(Entity, Serializable, Map, boolean)public boolean validate(Entity entity, Serializable populatedInstance, Map<String,FieldMetadata> mergedProperties, boolean validateUnsubmittedProperties)
RecordHelperEntity based on the validators associated with each propertyvalidate in interface RecordHelperentity - the instance that is attempted to be saved from. Implementers should set Entity.isValidationFailure()
accordingly as a result of the validationmergedProperties - TODOvalidateUnsubmittedProperties - if set to true, will ignore validation for properties that weren't submitted
along with the entityEntity.isValidationFailure()
after invoking this methodpublic void setPersistenceManager(PersistenceManager persistenceManager)
setPersistenceManager in interface PersistenceModulepublic PersistenceModule getCompatibleModule(OperationType operationType)
getCompatibleModule in interface RecordHelperpublic FieldPersistenceProvider getDefaultFieldPersistenceProvider()
public void setDefaultFieldPersistenceProvider(FieldPersistenceProvider defaultFieldPersistenceProvider)
public List<FieldPersistenceProvider> getFieldPersistenceProviders()
public void setFieldPersistenceProviders(List<FieldPersistenceProvider> fieldPersistenceProviders)
public CriteriaTranslator getCriteriaTranslator()
public void setCriteriaTranslator(CriteriaTranslator criteriaTranslator)
public EntityValidatorService getEntityValidatorService()
public void setEntityValidatorService(EntityValidatorService entityValidatorService)
public RestrictionFactory getRestrictionFactory()
public void setRestrictionFactory(RestrictionFactory restrictionFactory)
public PersistenceManager getPersistenceManager()
protected TypedQueryBuilder getSpecialCaseQueryBuilder(FieldPath embeddedCollectionPath, List<FilterMapping> filterMappings, String collectionClass)
embeddedCollectionPath - the path to the collection field itselffilterMappings - all the fetch restrictions for this requestcollectionClass - the type of the collection membersprotected List<TQRestriction> buildStandardRestrictions(FieldPath embeddedCollectionPath, List<FilterMapping> filterMappings)
embeddedCollectionPath - the path for the collection field in the @Embeddable object - this is what caused the whole thingfilterMappings - all the fetch restrictions for this requestgetSpecialCaseQueryBuilder(org.broadleafcommerce.openadmin.server.service.persistence.module.criteria.FieldPath, java.util.List, String)protected List<TQRestriction> buildSpecialRestrictions(String specialExpression, List<FilterMapping> filterMappings)
specialExpression - the String representation of the path for the collection field in the @Embeddable objectfilterMappings - all the fetch restrictions for this requestgetSpecialCaseQueryBuilder(org.broadleafcommerce.openadmin.server.service.persistence.module.criteria.FieldPath, java.util.List, String)protected void cleanupFailedPersistenceAttempt(Serializable instance) throws IllegalAccessException
IllegalAccessExceptionprotected Class<?> getMapFieldType(Serializable instance, FieldManager fieldManager, Property property)
Copyright © 2017. All rights reserved.