use of org.broadleafcommerce.openadmin.server.service.persistence.module.PersistenceModule in project BroadleafCommerce by BroadleafCommerce.
the class PersistenceManagerImpl method fetch.
@Override
public PersistenceResponse fetch(PersistencePackage persistencePackage, CriteriaTransferObject cto) throws ServiceException {
for (PersistenceManagerEventHandler handler : persistenceManagerEventHandlers) {
PersistenceManagerEventHandlerResponse response = handler.preFetch(this, persistencePackage, cto);
if (PersistenceManagerEventHandlerResponse.PersistenceManagerEventHandlerResponseStatus.HANDLED_BREAK == response.getStatus()) {
break;
}
}
// check to see if there is a custom handler registered
for (CustomPersistenceHandler handler : getCustomPersistenceHandlers()) {
if (handler.canHandleFetch(persistencePackage)) {
if (!handler.willHandleSecurity(persistencePackage)) {
adminRemoteSecurityService.securityCheck(persistencePackage, EntityOperationType.FETCH);
}
DynamicResultSet results = handler.fetch(persistencePackage, cto, dynamicEntityDao, (RecordHelper) getCompatibleModule(OperationType.BASIC));
return executePostFetchHandlers(persistencePackage, cto, new PersistenceResponse().withDynamicResultSet(results));
}
}
adminRemoteSecurityService.securityCheck(persistencePackage, EntityOperationType.FETCH);
PersistenceModule myModule = getCompatibleModule(persistencePackage.getPersistencePerspective().getOperationTypes().getFetchType());
try {
DynamicResultSet results = myModule.fetch(persistencePackage, cto);
return executePostFetchHandlers(persistencePackage, cto, new PersistenceResponse().withDynamicResultSet(results));
} catch (ServiceException e) {
if (e.getCause() instanceof NoPossibleResultsException) {
DynamicResultSet drs = new DynamicResultSet(null, new Entity[] {}, 0);
return executePostFetchHandlers(persistencePackage, cto, new PersistenceResponse().withDynamicResultSet(drs));
}
throw e;
}
}
use of org.broadleafcommerce.openadmin.server.service.persistence.module.PersistenceModule 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));
}
use of org.broadleafcommerce.openadmin.server.service.persistence.module.PersistenceModule in project BroadleafCommerce by BroadleafCommerce.
the class PersistenceManagerImpl method postConstruct.
@PostConstruct
public void postConstruct() {
for (PersistenceModule module : modules) {
module.setPersistenceManager(this);
}
Collections.sort(persistenceManagerEventHandlers, new Comparator<PersistenceManagerEventHandler>() {
@Override
public int compare(PersistenceManagerEventHandler o1, PersistenceManagerEventHandler o2) {
return Integer.valueOf(o1.getOrder()).compareTo(Integer.valueOf(o2.getOrder()));
}
});
honorExplicitPersistenceHandlerSorting();
}
use of org.broadleafcommerce.openadmin.server.service.persistence.module.PersistenceModule in project BroadleafCommerce by BroadleafCommerce.
the class PersistenceManagerImpl method processMergedProperties.
public Property[] processMergedProperties(Class<?>[] entities, Map<MergedPropertyType, Map<String, FieldMetadata>> mergedProperties) {
List<Property> propertiesList = new ArrayList<>();
for (PersistenceModule module : modules) {
module.extractProperties(entities, mergedProperties, propertiesList);
}
Property[] properties = new Property[propertiesList.size()];
properties = propertiesList.toArray(properties);
Arrays.sort(properties, new Comparator<Property>() {
@Override
public int compare(Property o1, Property o2) {
Integer tabOrder1 = o1.getMetadata().getTabOrder() == null ? 99999 : o1.getMetadata().getTabOrder();
Integer tabOrder2 = o2.getMetadata().getTabOrder() == null ? 99999 : o2.getMetadata().getTabOrder();
Integer groupOrder1 = null;
Integer groupOrder2 = null;
if (o1.getMetadata() instanceof BasicFieldMetadata) {
BasicFieldMetadata b1 = (BasicFieldMetadata) o1.getMetadata();
groupOrder1 = b1.getGroupOrder();
}
groupOrder1 = groupOrder1 == null ? 99999 : groupOrder1;
if (o2.getMetadata() instanceof BasicFieldMetadata) {
BasicFieldMetadata b2 = (BasicFieldMetadata) o2.getMetadata();
groupOrder2 = b2.getGroupOrder();
}
groupOrder2 = groupOrder2 == null ? 99999 : groupOrder2;
Integer fieldOrder1 = o1.getMetadata().getOrder() == null ? 99999 : o1.getMetadata().getOrder();
Integer fieldOrder2 = o2.getMetadata().getOrder() == null ? 99999 : o2.getMetadata().getOrder();
String friendlyName1 = o1.getMetadata().getFriendlyName() == null ? "zzzz" : o1.getMetadata().getFriendlyName();
String friendlyName2 = o2.getMetadata().getFriendlyName() == null ? "zzzz" : o2.getMetadata().getFriendlyName();
String name1 = o1.getName() == null ? "zzzzz" : o1.getName();
String name2 = o2.getName() == null ? "zzzzz" : o2.getName();
return new CompareToBuilder().append(tabOrder1, tabOrder2).append(groupOrder1, groupOrder2).append(fieldOrder1, fieldOrder2).append(friendlyName1, friendlyName2).append(name1, name2).toComparison();
}
});
return properties;
}
use of org.broadleafcommerce.openadmin.server.service.persistence.module.PersistenceModule in project BroadleafCommerce by BroadleafCommerce.
the class CustomerPaymentCustomPersistenceHandler method fetch.
@Override
public DynamicResultSet fetch(PersistencePackage persistencePackage, CriteriaTransferObject cto, DynamicEntityDao dynamicEntityDao, RecordHelper helper) throws ServiceException {
OperationType fetchType = persistencePackage.getPersistencePerspective().getOperationTypes().getFetchType();
PersistenceModule persistenceModule = helper.getCompatibleModule(fetchType);
DynamicResultSet drs = persistenceModule.fetch(persistencePackage, cto);
for (Entity entity : drs.getRecords()) {
Property customerPaymentId = entity.findProperty("id");
if (customerPaymentId != null) {
CustomerPayment customerPayment = customerPaymentService.readCustomerPaymentById(Long.parseLong(customerPaymentId.getValue()));
if (customerPayment != null) {
String savedPaymentDisplayValue = buildSavedPaymentDisplayValue(customerPayment);
Property derivedLabel = new Property();
derivedLabel.setName(SAVED_PAYMENT_INFO);
derivedLabel.setValue(savedPaymentDisplayValue);
entity.addProperty(derivedLabel);
}
}
}
return drs;
}
Aggregations