Search in sources :

Example 1 with ConfiguratorCreatorService

use of com.axelor.apps.sale.service.configurator.ConfiguratorCreatorService in project axelor-open-suite by axelor.

the class ConfiguratorCreatorController method updateAndActivate.

/**
 * Called from the configurator creator form on formula changes
 *
 * @param request
 * @param response
 */
public void updateAndActivate(ActionRequest request, ActionResponse response) {
    try {
        ConfiguratorCreator creator = request.getContext().asType(ConfiguratorCreator.class);
        ConfiguratorCreatorService configuratorCreatorService = Beans.get(ConfiguratorCreatorService.class);
        creator = Beans.get(ConfiguratorCreatorRepository.class).find(creator.getId());
        configuratorCreatorService.updateIndicators(creator);
        configuratorCreatorService.activate(creator);
        response.setSignal("refresh-app", true);
    } catch (Exception e) {
        TraceBackService.trace(e);
    }
}
Also used : ConfiguratorCreator(com.axelor.apps.sale.db.ConfiguratorCreator) ConfiguratorCreatorService(com.axelor.apps.sale.service.configurator.ConfiguratorCreatorService)

Example 2 with ConfiguratorCreatorService

use of com.axelor.apps.sale.service.configurator.ConfiguratorCreatorService in project axelor-open-suite by axelor.

the class ConfiguratorCreatorSaleRepository method save.

@Override
public ConfiguratorCreator save(ConfiguratorCreator entity) {
    try {
        if (entity.getCopyNeedingUpdate()) {
            entity = super.save(entity);
            entity.setCopyNeedingUpdate(false);
            Beans.get(ConfiguratorCreatorImportService.class).fixAttributesName(entity);
            ConfiguratorCreatorService configuratorCreatorService = Beans.get(ConfiguratorCreatorService.class);
            configuratorCreatorService.updateAttributes(entity);
            configuratorCreatorService.updateIndicators(entity);
            return entity;
        } else {
            return super.save(entity);
        }
    } catch (Exception e) {
        TraceBackService.traceExceptionFromSaveMethod(e);
        throw new PersistenceException(e.getMessage(), e);
    }
}
Also used : ConfiguratorCreatorImportService(com.axelor.apps.sale.service.configurator.ConfiguratorCreatorImportService) PersistenceException(javax.persistence.PersistenceException) ConfiguratorCreatorService(com.axelor.apps.sale.service.configurator.ConfiguratorCreatorService) PersistenceException(javax.persistence.PersistenceException)

Aggregations

ConfiguratorCreatorService (com.axelor.apps.sale.service.configurator.ConfiguratorCreatorService)2 ConfiguratorCreator (com.axelor.apps.sale.db.ConfiguratorCreator)1 ConfiguratorCreatorImportService (com.axelor.apps.sale.service.configurator.ConfiguratorCreatorImportService)1 PersistenceException (javax.persistence.PersistenceException)1