org.broadleafcommerce.openadmin.server.service
Class AdminEntityServiceImpl

java.lang.Object
  extended by org.broadleafcommerce.openadmin.server.service.AdminEntityServiceImpl
All Implemented Interfaces:
AdminEntityService

@Service(value="blAdminEntityService")
public class AdminEntityServiceImpl
extends Object
implements AdminEntityService

Author:
Andre Azzolini (apazzolini)

Field Summary
protected  DynamicDaoHelper dynamicDaoHelper
           
protected  javax.persistence.EntityManager em
           
protected  EntityConfiguration entityConfiguration
           
protected  PersistencePackageFactory persistencePackageFactory
           
protected  DynamicEntityService service
           
 
Constructor Summary
AdminEntityServiceImpl()
           
 
Method Summary
protected  PersistenceResponse add(PersistencePackageRequest request)
           
 PersistenceResponse addEntity(EntityForm entityForm, String[] customCriteria, List<SectionCrumb> sectionCrumb)
          Persists the given entity
 PersistenceResponse addSubCollectionEntity(EntityForm entityForm, ClassMetadata mainMetadata, Property field, Entity parentEntity, List<SectionCrumb> sectionCrumbs)
          Adds an item into the specified collection
protected  PersistenceResponse fetch(PersistencePackageRequest request)
           
 PersistenceResponse getAdvancedCollectionRecord(ClassMetadata containingClassMetadata, Entity containingEntity, Property collectionProperty, String collectionItemId, List<SectionCrumb> sectionCrumbs)
          Gets an Entity representing a specific collection item
 PersistenceResponse getClassMetadata(PersistencePackageRequest request)
          Returns class metadata for the given request object
 String getContextSpecificRelationshipId(ClassMetadata cmd, Entity entity, String propertyName)
          Returns the appropriate id to use for the given entity/metadata and prefix when dealing with collections.
protected  CriteriaTransferObject getDefaultCto()
           
 String getIdProperty(ClassMetadata cmd)
          Returns the name of the property in this ClassMetadata that has field type set to SupportedFieldType.ID
protected  List<Property> getPropertiesFromEntityForm(EntityForm entityForm)
           
 PersistenceResponse getRecord(PersistencePackageRequest request, String id, ClassMetadata cmd, boolean isCollectionRequest)
          Returns a specific record for the given request and primary key id/property
 PersistenceResponse getRecords(PersistencePackageRequest request)
          Returns the DynamicResultSet containing the total records for the query and the currently fetched Entity[]
 Map<String,DynamicResultSet> getRecordsForAllSubCollections(PersistencePackageRequest ppr, Entity containingEntity, List<SectionCrumb> sectionCrumb)
          Returns all records for all subcollections of the specified request and its primary key
 PersistenceResponse getRecordsForCollection(ClassMetadata containingClassMetadata, Entity containingEntity, Property collectionProperty, FilterAndSortCriteria[] fascs, Integer startIndex, Integer maxIndex, List<SectionCrumb> sectionCrumb)
          Returns the DynamicResultSet representing the records that belong to the specified collectionProperty for the given containingClass and the primary key for the containingClass
 PersistenceResponse getRecordsForCollection(ClassMetadata containingClassMetadata, Entity containingEntity, Property collectionProperty, FilterAndSortCriteria[] fascs, Integer startIndex, Integer maxIndex, String idValueOverride, List<SectionCrumb> sectionCrumbs)
          The same as the other getRecordsForCollection method, except that this one expects allow the caller to explicitly set the id value that will be used in the fetch instead of delegating to #getContextSpecificRelationshipId()
protected  PersistencePackageRequest getRequestForEntityForm(EntityForm entityForm, String[] customCriteria, List<SectionCrumb> sectionCrumbs)
           
protected  PersistenceResponse inspect(PersistencePackageRequest request)
           
protected  PersistenceResponse remove(PersistencePackageRequest request)
           
 PersistenceResponse removeEntity(EntityForm entityForm, String[] customCriteria, List<SectionCrumb> sectionCrumb)
          Removes the given entity
 PersistenceResponse removeSubCollectionEntity(ClassMetadata mainMetadata, Property field, Entity parentEntity, String itemId, String priorKey, List<SectionCrumb> sectionCrumbs)
          Removes the given item from the specified collection.
protected  PersistenceResponse update(PersistencePackageRequest request)
           
 PersistenceResponse updateEntity(EntityForm entityForm, String[] customCriteria, List<SectionCrumb> sectionCrumb)
          Updates the given entity
 PersistenceResponse updateSubCollectionEntity(EntityForm entityForm, ClassMetadata mainMetadata, Property field, Entity parentEntity, String collectionItemId, List<SectionCrumb> sectionCrumbs)
          Updates the specified collection item
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

service

protected DynamicEntityService service

persistencePackageFactory

protected PersistencePackageFactory persistencePackageFactory

em

protected javax.persistence.EntityManager em

entityConfiguration

protected EntityConfiguration entityConfiguration

dynamicDaoHelper

protected DynamicDaoHelper dynamicDaoHelper
Constructor Detail

AdminEntityServiceImpl

public AdminEntityServiceImpl()
Method Detail

getClassMetadata

public PersistenceResponse getClassMetadata(PersistencePackageRequest request)
                                     throws ServiceException
Description copied from interface: AdminEntityService
Returns class metadata for the given request object

Specified by:
getClassMetadata in interface AdminEntityService
Returns:
ClassMetadata for the given request
Throws:
ServiceException

getRecords

public PersistenceResponse getRecords(PersistencePackageRequest request)
                               throws ServiceException
Description copied from interface: AdminEntityService
Returns the DynamicResultSet containing the total records for the query and the currently fetched Entity[]

Specified by:
getRecords in interface AdminEntityService
Returns:
DynamicResultSet
Throws:
ServiceException

getRecord

public PersistenceResponse getRecord(PersistencePackageRequest request,
                                     String id,
                                     ClassMetadata cmd,
                                     boolean isCollectionRequest)
                              throws ServiceException
Description copied from interface: AdminEntityService
Returns a specific record for the given request and primary key id/property

Specified by:
getRecord in interface AdminEntityService
isCollectionRequest - whether or not this record request was initiated from a collection on a parent entity
Returns:
the Entity
Throws:
ServiceException

addEntity

public PersistenceResponse addEntity(EntityForm entityForm,
                                     String[] customCriteria,
                                     List<SectionCrumb> sectionCrumb)
                              throws ServiceException
Description copied from interface: AdminEntityService
Persists the given entity

Specified by:
addEntity in interface AdminEntityService
Returns:
the persisted Entity
Throws:
ServiceException

updateEntity

public PersistenceResponse updateEntity(EntityForm entityForm,
                                        String[] customCriteria,
                                        List<SectionCrumb> sectionCrumb)
                                 throws ServiceException
Description copied from interface: AdminEntityService
Updates the given entity

Specified by:
updateEntity in interface AdminEntityService
Returns:
the persisted Entity
Throws:
ServiceException

removeEntity

public PersistenceResponse removeEntity(EntityForm entityForm,
                                        String[] customCriteria,
                                        List<SectionCrumb> sectionCrumb)
                                 throws ServiceException
Description copied from interface: AdminEntityService
Removes the given entity

Specified by:
removeEntity in interface AdminEntityService
Throws:
ServiceException

getPropertiesFromEntityForm

protected List<Property> getPropertiesFromEntityForm(EntityForm entityForm)

getRequestForEntityForm

protected PersistencePackageRequest getRequestForEntityForm(EntityForm entityForm,
                                                            String[] customCriteria,
                                                            List<SectionCrumb> sectionCrumbs)

getAdvancedCollectionRecord

public PersistenceResponse getAdvancedCollectionRecord(ClassMetadata containingClassMetadata,
                                                       Entity containingEntity,
                                                       Property collectionProperty,
                                                       String collectionItemId,
                                                       List<SectionCrumb> sectionCrumbs)
                                                throws ServiceException
Description copied from interface: AdminEntityService
Gets an Entity representing a specific collection item

Specified by:
getAdvancedCollectionRecord in interface AdminEntityService
Returns:
the Entity
Throws:
ServiceException

getRecordsForCollection

public PersistenceResponse getRecordsForCollection(ClassMetadata containingClassMetadata,
                                                   Entity containingEntity,
                                                   Property collectionProperty,
                                                   FilterAndSortCriteria[] fascs,
                                                   Integer startIndex,
                                                   Integer maxIndex,
                                                   List<SectionCrumb> sectionCrumb)
                                            throws ServiceException
Description copied from interface: AdminEntityService
Returns the DynamicResultSet representing the records that belong to the specified collectionProperty for the given containingClass and the primary key for the containingClass

Specified by:
getRecordsForCollection in interface AdminEntityService
Returns:
the DynamicResultSet
Throws:
ServiceException

getRecordsForCollection

public PersistenceResponse getRecordsForCollection(ClassMetadata containingClassMetadata,
                                                   Entity containingEntity,
                                                   Property collectionProperty,
                                                   FilterAndSortCriteria[] fascs,
                                                   Integer startIndex,
                                                   Integer maxIndex,
                                                   String idValueOverride,
                                                   List<SectionCrumb> sectionCrumbs)
                                            throws ServiceException
Description copied from interface: AdminEntityService
The same as the other getRecordsForCollection method, except that this one expects allow the caller to explicitly set the id value that will be used in the fetch instead of delegating to #getContextSpecificRelationshipId()

Specified by:
getRecordsForCollection in interface AdminEntityService
Returns:
the PersistenceResponse
Throws:
ServiceException

getRecordsForAllSubCollections

public Map<String,DynamicResultSet> getRecordsForAllSubCollections(PersistencePackageRequest ppr,
                                                                   Entity containingEntity,
                                                                   List<SectionCrumb> sectionCrumb)
                                                            throws ServiceException
Description copied from interface: AdminEntityService
Returns all records for all subcollections of the specified request and its primary key

Specified by:
getRecordsForAllSubCollections in interface AdminEntityService
Returns:
all Entity[] for all collections for the specified containingClass
Throws:
ServiceException
See Also:
#getRecordsForCollection(ClassMetadata, String, Property)

addSubCollectionEntity

public PersistenceResponse addSubCollectionEntity(EntityForm entityForm,
                                                  ClassMetadata mainMetadata,
                                                  Property field,
                                                  Entity parentEntity,
                                                  List<SectionCrumb> sectionCrumbs)
                                           throws ServiceException,
                                                  ClassNotFoundException
Description copied from interface: AdminEntityService
Adds an item into the specified collection

Specified by:
addSubCollectionEntity in interface AdminEntityService
Returns:
the persisted Entity
Throws:
ServiceException
ClassNotFoundException

updateSubCollectionEntity

public PersistenceResponse updateSubCollectionEntity(EntityForm entityForm,
                                                     ClassMetadata mainMetadata,
                                                     Property field,
                                                     Entity parentEntity,
                                                     String collectionItemId,
                                                     List<SectionCrumb> sectionCrumbs)
                                              throws ServiceException,
                                                     ClassNotFoundException
Description copied from interface: AdminEntityService
Updates the specified collection item

Specified by:
updateSubCollectionEntity in interface AdminEntityService
Returns:
the persisted Entity
Throws:
ServiceException
ClassNotFoundException

removeSubCollectionEntity

public PersistenceResponse removeSubCollectionEntity(ClassMetadata mainMetadata,
                                                     Property field,
                                                     Entity parentEntity,
                                                     String itemId,
                                                     String priorKey,
                                                     List<SectionCrumb> sectionCrumbs)
                                              throws ServiceException
Description copied from interface: AdminEntityService
Removes the given item from the specified collection.

Specified by:
removeSubCollectionEntity in interface AdminEntityService
priorKey - - only needed for Map type collections
Throws:
ServiceException

getContextSpecificRelationshipId

public String getContextSpecificRelationshipId(ClassMetadata cmd,
                                               Entity entity,
                                               String propertyName)
Description copied from interface: AdminEntityService
Returns the appropriate id to use for the given entity/metadata and prefix when dealing with collections. For example, on the Product screen, we display associated media. However, this media is actually owned by the Sku entity, which means its property name is "defaultSku.skuMedia". In this case, when wanting to look up media for this product, we cannot use the id of the product. Instead, we need to use the id of the sku.

Specified by:
getContextSpecificRelationshipId in interface AdminEntityService
Returns:
the id to be used for this relationship

getIdProperty

public String getIdProperty(ClassMetadata cmd)
                     throws ServiceException
Description copied from interface: AdminEntityService
Returns the name of the property in this ClassMetadata that has field type set to SupportedFieldType.ID

Specified by:
getIdProperty in interface AdminEntityService
Returns:
the id property name
Throws:
ServiceException

add

protected PersistenceResponse add(PersistencePackageRequest request)
                           throws ServiceException
Throws:
ServiceException

update

protected PersistenceResponse update(PersistencePackageRequest request)
                              throws ServiceException
Throws:
ServiceException

inspect

protected PersistenceResponse inspect(PersistencePackageRequest request)
                               throws ServiceException
Throws:
ServiceException

remove

protected PersistenceResponse remove(PersistencePackageRequest request)
                              throws ServiceException
Throws:
ServiceException

fetch

protected PersistenceResponse fetch(PersistencePackageRequest request)
                             throws ServiceException
Throws:
ServiceException

getDefaultCto

protected CriteriaTransferObject getDefaultCto()


Copyright © 2013. All Rights Reserved.