use of org.broadleafcommerce.common.presentation.client.OperationType in project BroadleafCommerce by BroadleafCommerce.
the class AdminUserCustomPersistenceHandler method remove.
@Override
public void remove(PersistencePackage persistencePackage, DynamicEntityDao dynamicEntityDao, RecordHelper helper) throws ServiceException {
Entity entity = persistencePackage.getEntity();
String idValue = entity.findProperty("id").getValue();
String userLoginToRemove = entity.findProperty("login") == null ? null : entity.findProperty("login").getValue();
AdminUser persistentAdminUser = adminRemoteSecurityService.getPersistentAdminUser();
if (persistentAdminUser != null && persistentAdminUser.getLogin() != null && userLoginToRemove != null) {
if (persistentAdminUser.getLogin().equals(userLoginToRemove)) {
throw new ValidationException(entity, "admin.cantDeleteCurrentUserError");
}
}
if (idValue != null) {
Long id = Long.parseLong(idValue);
AdminUser adminInstance = adminSecurityService.readAdminUserById(id);
// Check if Status was Weaved in
if (Status.class.isAssignableFrom(adminInstance.getClass())) {
((Status) adminInstance).setArchived('Y');
adminSecurityService.saveAdminUser(adminInstance);
return;
}
}
OperationType removeType = persistencePackage.getPersistencePerspective().getOperationTypes().getRemoveType();
helper.getCompatibleModule(removeType).remove(persistencePackage);
}
use of org.broadleafcommerce.common.presentation.client.OperationType in project BroadleafCommerce by BroadleafCommerce.
the class OfferCustomPersistenceHandler method update.
@Override
public Entity update(PersistencePackage persistencePackage, DynamicEntityDao dynamicEntityDao, RecordHelper helper) throws ServiceException {
Entity entity = persistencePackage.getEntity();
// This can't be on a validator since the field is dynamically added with JavaScript
Property isMultiTierOffer = entity.findProperty(IS_TIERED_OFFER);
if (isMultiTierOffer != null) {
String multiTierValue = isMultiTierOffer.getValue();
if ("false".equalsIgnoreCase(multiTierValue)) {
Property offerValue = entity.findProperty(OFFER_VALUE);
if (offerValue != null) {
String value = offerValue.getValue();
if (value == null || "null".equalsIgnoreCase(value)) {
entity.addValidationError(OFFER_VALUE, "requiredFieldMessage");
}
}
}
}
Property qualifiersCanBeQualifiers = entity.findProperty(QUALIFIERS_CAN_BE_QUALIFIERS);
if (qualifiersCanBeQualifiers != null) {
qualifiersCanBeQualifiers.setIsDirty(true);
}
Property qualifiersCanBeTargets = entity.findProperty(QUALIFIERS_CAN_BE_TARGETS);
if (qualifiersCanBeTargets != null) {
qualifiersCanBeTargets.setIsDirty(true);
}
Property offerItemQualifierRuleType = buildOfferItemQualifierRuleTypeProperty(qualifiersCanBeQualifiers, qualifiersCanBeTargets);
entity.addProperty(offerItemQualifierRuleType);
Property stackable = entity.findProperty(STACKABLE);
if (stackable != null) {
stackable.setIsDirty(true);
}
Property offerItemTargetRuleType = buildOfferItemTargetRuleTypeProperty(stackable);
entity.addProperty(offerItemTargetRuleType);
OperationType updateType = persistencePackage.getPersistencePerspective().getOperationTypes().getUpdateType();
return helper.getCompatibleModule(updateType).update(persistencePackage);
}
use of org.broadleafcommerce.common.presentation.client.OperationType 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