Search in sources :

Example 6 with CustomPersistenceHandler

use of org.broadleafcommerce.openadmin.server.service.handler.CustomPersistenceHandler in project BroadleafCommerce by BroadleafCommerce.

the class PersistenceManagerImpl method inspect.

@Override
public PersistenceResponse inspect(PersistencePackage persistencePackage) throws ServiceException, ClassNotFoundException {
    for (PersistenceManagerEventHandler handler : persistenceManagerEventHandlers) {
        PersistenceManagerEventHandlerResponse response = handler.preInspect(this, persistencePackage);
        if (PersistenceManagerEventHandlerResponse.PersistenceManagerEventHandlerResponseStatus.HANDLED_BREAK == response.getStatus()) {
            break;
        }
    }
    // check to see if there is a custom handler registered
    for (CustomPersistenceHandler handler : getCustomPersistenceHandlers()) {
        if (handler.canHandleInspect(persistencePackage)) {
            if (!handler.willHandleSecurity(persistencePackage)) {
                adminRemoteSecurityService.securityCheck(persistencePackage, EntityOperationType.INSPECT);
            }
            DynamicResultSet results = handler.inspect(persistencePackage, dynamicEntityDao, this);
            return executePostInspectHandlers(persistencePackage, new PersistenceResponse().withDynamicResultSet(results));
        }
    }
    adminRemoteSecurityService.securityCheck(persistencePackage, EntityOperationType.INSPECT);
    Class<?>[] entities = getPolymorphicEntities(persistencePackage.getCeilingEntityFullyQualifiedClassname());
    Map<MergedPropertyType, Map<String, FieldMetadata>> allMergedProperties = new HashMap<>();
    for (PersistenceModule module : modules) {
        module.updateMergedProperties(persistencePackage, allMergedProperties);
    }
    ClassMetadata classMetadata = buildClassMetadata(entities, persistencePackage, allMergedProperties);
    DynamicResultSet results = new DynamicResultSet(classMetadata);
    return executePostInspectHandlers(persistencePackage, new PersistenceResponse().withDynamicResultSet(results));
}
Also used : ClassMetadata(org.broadleafcommerce.openadmin.dto.ClassMetadata) HashMap(java.util.HashMap) CustomPersistenceHandler(org.broadleafcommerce.openadmin.server.service.handler.CustomPersistenceHandler) PersistenceModule(org.broadleafcommerce.openadmin.server.service.persistence.module.PersistenceModule) MergedPropertyType(org.broadleafcommerce.openadmin.dto.MergedPropertyType) DynamicResultSet(org.broadleafcommerce.openadmin.dto.DynamicResultSet) Map(java.util.Map) HashMap(java.util.HashMap)

Example 7 with CustomPersistenceHandler

use of org.broadleafcommerce.openadmin.server.service.handler.CustomPersistenceHandler in project BroadleafCommerce by BroadleafCommerce.

the class PersistenceManagerImpl method getCustomPersistenceHandlers.

@Override
public List<CustomPersistenceHandler> getCustomPersistenceHandlers() {
    List<CustomPersistenceHandler> cloned = new ArrayList<>();
    cloned.addAll(customPersistenceHandlers);
    if (getCustomPersistenceHandlerFilters() != null) {
        for (CustomPersistenceHandlerFilter filter : getCustomPersistenceHandlerFilters()) {
            Iterator<CustomPersistenceHandler> itr = cloned.iterator();
            while (itr.hasNext()) {
                CustomPersistenceHandler handler = itr.next();
                if (!filter.shouldUseHandler(handler.getClass().getName())) {
                    itr.remove();
                }
            }
        }
    }
    Collections.sort(cloned, new Comparator<CustomPersistenceHandler>() {

        @Override
        public int compare(CustomPersistenceHandler o1, CustomPersistenceHandler o2) {
            return new Integer(o1.getOrder()).compareTo(new Integer(o2.getOrder()));
        }
    });
    return cloned;
}
Also used : CustomPersistenceHandler(org.broadleafcommerce.openadmin.server.service.handler.CustomPersistenceHandler) ArrayList(java.util.ArrayList) CustomPersistenceHandlerFilter(org.broadleafcommerce.openadmin.server.service.handler.CustomPersistenceHandlerFilter)

Aggregations

CustomPersistenceHandler (org.broadleafcommerce.openadmin.server.service.handler.CustomPersistenceHandler)7 PersistenceModule (org.broadleafcommerce.openadmin.server.service.persistence.module.PersistenceModule)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 List (java.util.List)3 AdminMainEntity (org.broadleafcommerce.common.admin.domain.AdminMainEntity)3 ServiceException (org.broadleafcommerce.common.exception.ServiceException)3 Entity (org.broadleafcommerce.openadmin.dto.Entity)3 DynamicResultSet (org.broadleafcommerce.openadmin.dto.DynamicResultSet)2 PersistencePackage (org.broadleafcommerce.openadmin.dto.PersistencePackage)2 ValidationException (org.broadleafcommerce.openadmin.server.service.ValidationException)2 RecordHelper (org.broadleafcommerce.openadmin.server.service.persistence.module.RecordHelper)2 NoPossibleResultsException (org.broadleafcommerce.common.exception.NoPossibleResultsException)1 ClassMetadata (org.broadleafcommerce.openadmin.dto.ClassMetadata)1 CriteriaTransferObject (org.broadleafcommerce.openadmin.dto.CriteriaTransferObject)1 MergedPropertyType (org.broadleafcommerce.openadmin.dto.MergedPropertyType)1 CustomPersistenceHandlerFilter (org.broadleafcommerce.openadmin.server.service.handler.CustomPersistenceHandlerFilter)1