org.broadleafcommerce.openadmin.server.service.persistence.module
Class BasicPersistenceModule

java.lang.Object
  extended by org.broadleafcommerce.openadmin.server.service.persistence.module.BasicPersistenceModule
All Implemented Interfaces:
PersistenceModule, RecordHelper, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware
Direct Known Subclasses:
AdornedTargetListPersistenceModule, MapStructurePersistenceModule

@Component(value="blBasicPersistenceModule")
@Scope(value="prototype")
public class BasicPersistenceModule
extends Object
implements PersistenceModule, RecordHelper, org.springframework.context.ApplicationContextAware

Author:
jfischer

Field Summary
protected  org.springframework.context.ApplicationContext applicationContext
           
protected  SimpleDateFormat dateFormat
           
protected  DecimalFormat decimalFormat
           
protected  EntityValidatorService entityValidatorService
           
static String MAIN_ENTITY_NAME_PROPERTY
           
protected  PersistenceManager persistenceManager
           
 
Constructor Summary
BasicPersistenceModule()
           
 
Method Summary
 Entity add(PersistencePackage persistencePackage)
           
protected  void buildProperty(PersistencePerspective persistencePerspective, com.anasoft.os.daofusion.cto.client.CriteriaTransferObject cto, String ceilingEntityFullyQualifiedClassname, Map<String,FieldMetadata> mergedProperties, BaseCtoConverter ctoConverter, String propertyName)
           
 Serializable createPopulatedInstance(Serializable instance, Entity entity, Map<String,FieldMetadata> unfilteredProperties, Boolean setId)
           
 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, com.anasoft.os.daofusion.cto.client.CriteriaTransferObject cto)
           
protected  Map<String,FieldMetadata> filterOutCollectionMetadata(Map<String,FieldMetadata> metadata)
           
protected  Class<?> getBasicBroadleafType(SupportedFieldType fieldType)
           
 PersistenceModule getCompatibleModule(OperationType operationType)
           
 com.anasoft.os.daofusion.criteria.PersistentEntityCriteria getCountCriteria(PersistencePackage persistencePackage, com.anasoft.os.daofusion.cto.client.CriteriaTransferObject cto, BaseCtoConverter ctoConverter)
          Returns the count criteria representation that should be used to count the result set.
 BaseCtoConverter getCtoConverter(PersistencePerspective persistencePerspective, com.anasoft.os.daofusion.cto.client.CriteriaTransferObject cto, String ceilingEntityFullyQualifiedClassname, Map<String,FieldMetadata> mergedUnfilteredProperties)
           
 BaseCtoConverter getCtoConverter(PersistencePerspective persistencePerspective, com.anasoft.os.daofusion.cto.client.CriteriaTransferObject cto, String ceilingEntityFullyQualifiedClassname, Map<String,FieldMetadata> mergedUnfilteredProperties, FilterCriterionProviders criterionProviders)
           
 DecimalFormat getDecimalFormatter()
           
 FieldManager getFieldManager()
           
 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)
           
 Map<String,FieldMetadata> getSimpleMergedProperties(String entityName, PersistencePerspective persistencePerspective)
           
 int getTotalRecords(PersistencePackage persistencePackage, com.anasoft.os.daofusion.cto.client.CriteriaTransferObject cto, BaseCtoConverter ctoConverter)
           
 boolean isCompatible(OperationType operationType)
           
protected  Date parseDate(String value)
           
 void remove(PersistencePackage persistencePackage)
           
 void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
           
 void setPersistenceManager(PersistenceManager persistenceManager)
           
 Entity update(PersistencePackage persistencePackage)
           
protected  Entity update(PersistencePackage persistencePackage, Object primaryKey)
           
 void updateMergedProperties(PersistencePackage persistencePackage, Map<MergedPropertyType,Map<String,FieldMetadata>> allMergedProperties)
           
 boolean validate(Entity entity, Serializable populatedInstance, Map<String,FieldMetadata> mergedProperties)
          Validates the Entity based on the validators associated with each property
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAIN_ENTITY_NAME_PROPERTY

public static final String MAIN_ENTITY_NAME_PROPERTY
See Also:
Constant Field Values

dateFormat

protected SimpleDateFormat dateFormat

decimalFormat

protected DecimalFormat decimalFormat

applicationContext

protected org.springframework.context.ApplicationContext applicationContext

persistenceManager

protected PersistenceManager persistenceManager

entityValidatorService

protected EntityValidatorService entityValidatorService
Constructor Detail

BasicPersistenceModule

public BasicPersistenceModule()
Method Detail

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
                           throws org.springframework.beans.BeansException
Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware
Throws:
org.springframework.beans.BeansException

isCompatible

public boolean isCompatible(OperationType operationType)
Specified by:
isCompatible in interface PersistenceModule

getFieldManager

public FieldManager getFieldManager()
Specified by:
getFieldManager in interface RecordHelper

parseDate

protected Date parseDate(String value)
                  throws ParseException
Throws:
ParseException

getDecimalFormatter

public DecimalFormat getDecimalFormatter()
Specified by:
getDecimalFormatter in interface RecordHelper

filterOutCollectionMetadata

protected Map<String,FieldMetadata> filterOutCollectionMetadata(Map<String,FieldMetadata> metadata)

getBasicBroadleafType

protected Class<?> getBasicBroadleafType(SupportedFieldType fieldType)

createPopulatedInstance

public Serializable createPopulatedInstance(Serializable instance,
                                            Entity entity,
                                            Map<String,FieldMetadata> unfilteredProperties,
                                            Boolean setId)
                                     throws IllegalAccessException,
                                            InvocationTargetException,
                                            NoSuchMethodException,
                                            ParseException,
                                            NumberFormatException,
                                            InstantiationException,
                                            ClassNotFoundException
Specified by:
createPopulatedInstance in interface RecordHelper
Throws:
IllegalAccessException
InvocationTargetException
NoSuchMethodException
ParseException
NumberFormatException
InstantiationException
ClassNotFoundException

getRecord

public Entity getRecord(Map<String,FieldMetadata> primaryMergedProperties,
                        Serializable record,
                        Map<String,FieldMetadata> alternateMergedProperties,
                        String pathToTargetObject)
                 throws ParserConfigurationException,
                        DOMException,
                        IllegalAccessException,
                        InvocationTargetException,
                        NoSuchMethodException,
                        TransformerFactoryConfigurationError,
                        IllegalArgumentException,
                        TransformerException,
                        SecurityException,
                        ClassNotFoundException
Specified by:
getRecord in interface RecordHelper
Throws:
ParserConfigurationException
DOMException
IllegalAccessException
InvocationTargetException
NoSuchMethodException
TransformerFactoryConfigurationError
IllegalArgumentException
TransformerException
SecurityException
ClassNotFoundException

getRecord

public Entity getRecord(Class<?> ceilingEntityClass,
                        PersistencePerspective persistencePerspective,
                        Serializable record)
                 throws SecurityException,
                        IllegalArgumentException,
                        ClassNotFoundException,
                        NoSuchMethodException,
                        IllegalAccessException,
                        InvocationTargetException,
                        DOMException,
                        ParserConfigurationException,
                        TransformerFactoryConfigurationError,
                        TransformerException,
                        NoSuchFieldException
Specified by:
getRecord in interface RecordHelper
Throws:
SecurityException
IllegalArgumentException
ClassNotFoundException
NoSuchMethodException
IllegalAccessException
InvocationTargetException
DOMException
ParserConfigurationException
TransformerFactoryConfigurationError
TransformerException
NoSuchFieldException

getRecords

public Entity[] getRecords(Class<?> ceilingEntityClass,
                           PersistencePerspective persistencePerspective,
                           List<? extends Serializable> records)
                    throws SecurityException,
                           IllegalArgumentException,
                           ClassNotFoundException,
                           NoSuchMethodException,
                           IllegalAccessException,
                           InvocationTargetException,
                           DOMException,
                           ParserConfigurationException,
                           TransformerFactoryConfigurationError,
                           TransformerException,
                           NoSuchFieldException
Specified by:
getRecords in interface RecordHelper
Throws:
SecurityException
IllegalArgumentException
ClassNotFoundException
NoSuchMethodException
IllegalAccessException
InvocationTargetException
DOMException
ParserConfigurationException
TransformerFactoryConfigurationError
TransformerException
NoSuchFieldException

getSimpleMergedProperties

public Map<String,FieldMetadata> getSimpleMergedProperties(String entityName,
                                                           PersistencePerspective persistencePerspective)
                                                    throws ClassNotFoundException,
                                                           SecurityException,
                                                           IllegalArgumentException,
                                                           NoSuchMethodException,
                                                           IllegalAccessException,
                                                           InvocationTargetException,
                                                           NoSuchFieldException
Specified by:
getSimpleMergedProperties in interface RecordHelper
Throws:
ClassNotFoundException
SecurityException
IllegalArgumentException
NoSuchMethodException
IllegalAccessException
InvocationTargetException
NoSuchFieldException

getRecords

public Entity[] getRecords(Map<String,FieldMetadata> primaryMergedProperties,
                           List<? extends Serializable> records)
                    throws ParserConfigurationException,
                           DOMException,
                           IllegalAccessException,
                           InvocationTargetException,
                           NoSuchMethodException,
                           TransformerFactoryConfigurationError,
                           IllegalArgumentException,
                           TransformerException,
                           SecurityException,
                           ClassNotFoundException
Specified by:
getRecords in interface RecordHelper
Throws:
ParserConfigurationException
DOMException
IllegalAccessException
InvocationTargetException
NoSuchMethodException
TransformerFactoryConfigurationError
IllegalArgumentException
TransformerException
SecurityException
ClassNotFoundException

getRecords

public Entity[] getRecords(Map<String,FieldMetadata> primaryUnfilteredMergedProperties,
                           List<? extends Serializable> records,
                           Map<String,FieldMetadata> alternateUnfilteredMergedProperties,
                           String pathToTargetObject)
                    throws ParserConfigurationException,
                           DOMException,
                           IllegalAccessException,
                           InvocationTargetException,
                           NoSuchMethodException,
                           TransformerFactoryConfigurationError,
                           IllegalArgumentException,
                           TransformerException,
                           SecurityException,
                           ClassNotFoundException
Specified by:
getRecords in interface RecordHelper
Throws:
ParserConfigurationException
DOMException
IllegalAccessException
InvocationTargetException
NoSuchMethodException
TransformerFactoryConfigurationError
IllegalArgumentException
TransformerException
SecurityException
ClassNotFoundException

extractPropertiesFromPersistentEntity

protected void extractPropertiesFromPersistentEntity(Map<String,FieldMetadata> mergedProperties,
                                                     Serializable entity,
                                                     List<Property> props)
                                              throws IllegalAccessException,
                                                     InvocationTargetException,
                                                     NoSuchMethodException,
                                                     SecurityException,
                                                     IllegalArgumentException,
                                                     ClassNotFoundException
Throws:
IllegalAccessException
InvocationTargetException
NoSuchMethodException
SecurityException
IllegalArgumentException
ClassNotFoundException

update

protected Entity update(PersistencePackage persistencePackage,
                        Object primaryKey)
                 throws ServiceException
Throws:
ServiceException

getPrimaryKey

public Object getPrimaryKey(Entity entity,
                            Map<String,FieldMetadata> mergedUnfilteredProperties)
                     throws RuntimeException
Specified by:
getPrimaryKey in interface RecordHelper
Throws:
RuntimeException

getCtoConverter

public BaseCtoConverter getCtoConverter(PersistencePerspective persistencePerspective,
                                        com.anasoft.os.daofusion.cto.client.CriteriaTransferObject cto,
                                        String ceilingEntityFullyQualifiedClassname,
                                        Map<String,FieldMetadata> mergedUnfilteredProperties)
                                 throws ClassNotFoundException
Specified by:
getCtoConverter in interface RecordHelper
Throws:
ClassNotFoundException

getCtoConverter

public BaseCtoConverter getCtoConverter(PersistencePerspective persistencePerspective,
                                        com.anasoft.os.daofusion.cto.client.CriteriaTransferObject cto,
                                        String ceilingEntityFullyQualifiedClassname,
                                        Map<String,FieldMetadata> mergedUnfilteredProperties,
                                        FilterCriterionProviders criterionProviders)
                                 throws ClassNotFoundException
Specified by:
getCtoConverter in interface RecordHelper
Throws:
ClassNotFoundException

buildProperty

protected void buildProperty(PersistencePerspective persistencePerspective,
                             com.anasoft.os.daofusion.cto.client.CriteriaTransferObject cto,
                             String ceilingEntityFullyQualifiedClassname,
                             Map<String,FieldMetadata> mergedProperties,
                             BaseCtoConverter ctoConverter,
                             String propertyName)
                      throws ClassNotFoundException
Throws:
ClassNotFoundException

getTotalRecords

public int getTotalRecords(PersistencePackage persistencePackage,
                           com.anasoft.os.daofusion.cto.client.CriteriaTransferObject cto,
                           BaseCtoConverter ctoConverter)
                    throws ClassNotFoundException
Specified by:
getTotalRecords in interface RecordHelper
Throws:
ClassNotFoundException

getCountCriteria

public com.anasoft.os.daofusion.criteria.PersistentEntityCriteria getCountCriteria(PersistencePackage persistencePackage,
                                                                                   com.anasoft.os.daofusion.cto.client.CriteriaTransferObject cto,
                                                                                   BaseCtoConverter ctoConverter)
                                                                            throws ClassNotFoundException
Description copied from interface: RecordHelper
Returns the count criteria representation that should be used to count the result set. This is an advanced use case and should only be used when you need to have explicit control over the Hibernate criteria that can be created from the result of this method (like if you are using table aliases in the BaseCtoConverter.getFilterCriterionProviders()).

Specified by:
getCountCriteria in interface RecordHelper
Returns:
Throws:
ClassNotFoundException

extractProperties

public void extractProperties(Class<?>[] inheritanceLine,
                              Map<MergedPropertyType,Map<String,FieldMetadata>> mergedProperties,
                              List<Property> properties)
                       throws NumberFormatException
Specified by:
extractProperties in interface PersistenceModule
Throws:
NumberFormatException

extractPropertiesFromMetadata

protected void extractPropertiesFromMetadata(Class<?>[] inheritanceLine,
                                             Map<String,FieldMetadata> mergedProperties,
                                             List<Property> properties,
                                             Boolean isHiddenOverride,
                                             MergedPropertyType type)
                                      throws NumberFormatException
Throws:
NumberFormatException

updateMergedProperties

public void updateMergedProperties(PersistencePackage persistencePackage,
                                   Map<MergedPropertyType,Map<String,FieldMetadata>> allMergedProperties)
                            throws ServiceException
Specified by:
updateMergedProperties in interface PersistenceModule
Throws:
ServiceException

update

public Entity update(PersistencePackage persistencePackage)
              throws ServiceException
Specified by:
update in interface PersistenceModule
Throws:
ServiceException

add

public Entity add(PersistencePackage persistencePackage)
           throws ServiceException
Specified by:
add in interface PersistenceModule
Throws:
ServiceException

remove

public void remove(PersistencePackage persistencePackage)
            throws ServiceException
Specified by:
remove in interface PersistenceModule
Throws:
ServiceException

fetch

public DynamicResultSet fetch(PersistencePackage persistencePackage,
                              com.anasoft.os.daofusion.cto.client.CriteriaTransferObject cto)
                       throws ServiceException
Specified by:
fetch in interface PersistenceModule
Throws:
ServiceException

validate

public boolean validate(Entity entity,
                        Serializable populatedInstance,
                        Map<String,FieldMetadata> mergedProperties)
                 throws InstantiationException,
                        IllegalAccessException,
                        ClassNotFoundException
Description copied from interface: RecordHelper
Validates the Entity based on the validators associated with each property

Specified by:
validate in interface RecordHelper
Parameters:
entity - the instance that is attempted to be saved from. Implementers should set Entity.isValidationFailure() accordingly as a result of the validation
mergedProperties - TODO
Returns:
whether or not the entity passed validation. This yields the same result as calling !Entity.isValidationFailure() after invoking this method
Throws:
InstantiationException
IllegalAccessException
ClassNotFoundException

setPersistenceManager

public void setPersistenceManager(PersistenceManager persistenceManager)
Specified by:
setPersistenceManager in interface PersistenceModule

getCompatibleModule

public PersistenceModule getCompatibleModule(OperationType operationType)
Specified by:
getCompatibleModule in interface RecordHelper


Copyright © 2013. All Rights Reserved.