Interface RecordHelper
- All Superinterfaces:
DataFormatProvider
- All Known Implementing Classes:
AdornedTargetListPersistenceModule,BasicPersistenceModule,MapStructurePersistenceModule
Helper interface for serializing/deserializing the generic
Entity DTO to/from its actual domain object
representation.- Author:
- jfischer
-
Method Summary
Modifier and TypeMethodDescriptionadd(PersistencePackage persistencePackage, boolean includeRealEntityObject) createPopulatedInstance(Serializable instance, Entity entity, Map<String, FieldMetadata> unfilteredProperties, Boolean setId) Delegates to the overloaded method with validateUnsubmittedProperties set to true.createPopulatedInstance(Serializable instance, Entity entity, Map<String, FieldMetadata> mergedProperties, 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.getCompatibleModule(org.broadleafcommerce.common.presentation.client.OperationType operationType) getFieldManager(boolean cleanFieldManger) getFilterMappings(PersistencePerspective persistencePerspective, CriteriaTransferObject cto, String ceilingEntityFullyQualifiedClassname, Map<String, FieldMetadata> mergedProperties) getFilterMappings(PersistencePerspective persistencePerspective, CriteriaTransferObject cto, String ceilingEntityFullyQualifiedClassname, Map<String, FieldMetadata> mergedUnfilteredProperties, RestrictionFactory customRestrictionFactory) getIdPropertyName(String entityClass) For the fully qualified entity class name, find the primary key property name.getMaxValue(String ceilingEntity, List<FilterMapping> filterMappings, String maxField) getPersistentRecords(String ceilingEntity, List<FilterMapping> filterMappings, Integer firstResult, Integer maxResults) Deprecated.getPersistentRecords(FetchRequest fetchRequest) Retrieve a paged list of persistent entity instances given some basic metadata and restrictions.getPrimaryKey(Entity entity, Map<String, FieldMetadata> mergedProperties) getRecord(Class<?> ceilingEntityClass, PersistencePerspective persistencePerspective, Serializable record) 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) Deprecated.usegetRecords(FetchExtractionRequest)instead.Entity[]getRecords(Map<String, FieldMetadata> primaryMergedProperties, List<? extends Serializable> records, Map<String, FieldMetadata> alternateMergedProperties, String pathToTargetObject) Deprecated.usegetRecords(FetchExtractionRequest)insteadEntity[]getRecords(Map<String, FieldMetadata> primaryMergedProperties, List<? extends Serializable> records, Map<String, FieldMetadata> alternateMergedProperties, String pathToTargetObject, String[] customCriteria) Deprecated.usegetRecords(FetchExtractionRequest)insteadEntity[]getRecords(FetchExtractionRequest fetchExtractionRequest) Based on retrieved persistent entities and entity metadata, construct data transfer object instances to represent these records to the caller.getSimpleMergedProperties(String entityName, PersistencePerspective persistencePerspective) getStringValueFromGetter(Serializable instance, String propertyName) Returns a string representation of the field on the given instance specified by the property name.getTotalRecords(String ceilingEntity, List<FilterMapping> filterMappings) Deprecated.usegetTotalRecords(FetchRequest)insteadgetTotalRecords(FetchRequest fetchRequest) Retrieve a total count of persistent entities given some basic metadata and restrictionsupdate(PersistencePackage persistencePackage, boolean includeRealEntityObject) booleanvalidate(Entity entity, Serializable populatedInstance, Map<String, FieldMetadata> mergedProperties) Delegates to the overloaded method with validateUnsubmittedProperties set to true.booleanvalidate(Entity entity, Serializable populatedInstance, Map<String, FieldMetadata> mergedProperties, boolean validateUnsubmittedProperties) Validates theEntitybased on the validators associated with each propertyMethods inherited from interface org.broadleafcommerce.openadmin.server.service.persistence.module.DataFormatProvider
formatValue, getDecimalFormatter, getSimpleDateFormatter
-
Method Details
-
getFilterMappings
List<FilterMapping> getFilterMappings(PersistencePerspective persistencePerspective, CriteriaTransferObject cto, String ceilingEntityFullyQualifiedClassname, Map<String, FieldMetadata> mergedProperties) -
getFilterMappings
List<FilterMapping> getFilterMappings(PersistencePerspective persistencePerspective, CriteriaTransferObject cto, String ceilingEntityFullyQualifiedClassname, Map<String, FieldMetadata> mergedUnfilteredProperties, RestrictionFactory customRestrictionFactory) -
getRecords
Based on retrieved persistent entities and entity metadata, construct data transfer object instances to represent these records to the caller.- Parameters:
fetchExtractionRequest-- Returns:
-
getRecords
@Deprecated Entity[] getRecords(Map<String, FieldMetadata> primaryMergedProperties, List<? extends Serializable> records, Map<String, FieldMetadata> alternateMergedProperties, String pathToTargetObject, String[] customCriteria) Deprecated.usegetRecords(FetchExtractionRequest)instead- Parameters:
primaryMergedProperties-records-alternateMergedProperties-pathToTargetObject-customCriteria-- Returns:
-
getRecords
@Deprecated Entity[] getRecords(Map<String, FieldMetadata> primaryMergedProperties, List<? extends Serializable> records, Map<String, FieldMetadata> alternateMergedProperties, String pathToTargetObject) Deprecated.usegetRecords(FetchExtractionRequest)instead- Parameters:
primaryMergedProperties-records-alternateMergedProperties-pathToTargetObject-- Returns:
-
getRecords
@Deprecated Entity[] getRecords(Map<String, FieldMetadata> primaryMergedProperties, List<? extends Serializable> records) Deprecated.usegetRecords(FetchExtractionRequest)instead.- Parameters:
primaryMergedProperties-records-- Returns:
-
getRecords
Entity[] getRecords(Class<?> ceilingEntityClass, PersistencePerspective persistencePerspective, List<? extends Serializable> records) -
getRecord
Entity getRecord(Map<String, FieldMetadata> primaryMergedProperties, Serializable record, Map<String, FieldMetadata> alternateMergedProperties, String pathToTargetObject) -
getRecord
Entity getRecord(Class<?> ceilingEntityClass, PersistencePerspective persistencePerspective, Serializable record) -
createPopulatedInstance
Serializable createPopulatedInstance(Serializable instance, Entity entity, Map<String, FieldMetadata> mergedProperties, Boolean setId, Boolean validateUnsubmittedProperties) throws ValidationExceptionPopulates 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 aValidationExceptionis thrown. In the common case, this exception bubbles up to theDynamicRemoteServicewhich catches the exception and communicates appropriately to the invoker- Parameters:
instance-entity-mergedProperties-setId-validateUnsubmittedProperties- if set to true, will ignore validation for properties that weren't submitted along with the entity- Returns:
- instance populated with the property values from entity according to the metadata specified in mergedProperties
- Throws:
ValidationException- if after populating instance via the values in entity thenEntityValidatorService#validate(Entity, Serializable, Map)returns false
-
createPopulatedInstance
Serializable createPopulatedInstance(Serializable instance, Entity entity, Map<String, FieldMetadata> unfilteredProperties, Boolean setId) throws ValidationExceptionDelegates to the overloaded method with validateUnsubmittedProperties set to true. -
getPrimaryKey
-
getIdPropertyName
For the fully qualified entity class name, find the primary key property name.- Parameters:
entityClass-- Returns:
-
getSimpleMergedProperties
Map<String,FieldMetadata> getSimpleMergedProperties(String entityName, PersistencePerspective persistencePerspective) -
getFieldManager
FieldManager getFieldManager() -
getFieldManager
-
getCompatibleModule
PersistenceModule getCompatibleModule(org.broadleafcommerce.common.presentation.client.OperationType operationType) -
validate
boolean validate(Entity entity, Serializable populatedInstance, Map<String, FieldMetadata> mergedProperties, boolean validateUnsubmittedProperties) Validates theEntitybased on the validators associated with each property- Parameters:
entity- the instance that is attempted to be saved from. Implementers should setEntity.isValidationFailure()accordingly as a result of the validationpopulatedInstance-mergedProperties-validateUnsubmittedProperties- if set to true, will ignore validation for properties that weren't submitted along with the entity- Returns:
- whether or not the entity passed validation. This yields the same result as calling !
Entity.isValidationFailure()after invoking this method
-
validate
boolean validate(Entity entity, Serializable populatedInstance, Map<String, FieldMetadata> mergedProperties) Delegates to the overloaded method with validateUnsubmittedProperties set to true. -
getTotalRecords
Deprecated.usegetTotalRecords(FetchRequest)insteadRetrieve a total count of persistent entities given some basic metadata and restrictions- Parameters:
ceilingEntity-filterMappings-- Returns:
-
getTotalRecords
Retrieve a total count of persistent entities given some basic metadata and restrictions- Parameters:
fetchRequest-- Returns:
-
getMaxValue
-
getPersistentRecords
@Deprecated List<Serializable> getPersistentRecords(String ceilingEntity, List<FilterMapping> filterMappings, Integer firstResult, Integer maxResults) Deprecated.usegetPersistentRecords(FetchRequest)insteadRetrieve a paged list of persistent entity instances given some basic metadata and restrictions.- Parameters:
ceilingEntity-filterMappings-firstResult-maxResults-- Returns:
-
getPersistentRecords
Retrieve a paged list of persistent entity instances given some basic metadata and restrictions.- Parameters:
fetchRequest-- Returns:
-
update
EntityResult update(PersistencePackage persistencePackage, boolean includeRealEntityObject) throws org.broadleafcommerce.common.exception.ServiceException - Throws:
org.broadleafcommerce.common.exception.ServiceException
-
add
EntityResult add(PersistencePackage persistencePackage, boolean includeRealEntityObject) throws org.broadleafcommerce.common.exception.ServiceException - Throws:
org.broadleafcommerce.common.exception.ServiceException
-
getStringValueFromGetter
String getStringValueFromGetter(Serializable instance, String propertyName) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException Returns a string representation of the field on the given instance specified by the property name. The propertyName should start from the root of the given instance- Parameters:
instance-propertyName-- Returns:
- Throws:
IllegalAccessExceptionInvocationTargetExceptionNoSuchMethodException
-
getPersistentRecords(FetchRequest)instead