Search in sources :

Example 1 with CallMethod

use of com.axelor.meta.CallMethod in project axelor-open-suite by axelor.

the class AccountManagementServiceAccountImpl method getProductAccount.

/**
 * Get the product tax
 *
 * @param product
 * @param company
 * @param isPurchase
 * @param fixedAsset Specify if we should get the purchase account for fixed asset or not. Used
 *     only if isPurchase param is true.
 * @param configObject Specify if we want get the tax from the product or its product family
 *     <li>1 : product
 *     <li>2 : product family
 * @return
 * @throws AxelorException
 */
@CallMethod
protected Account getProductAccount(Product product, Company company, boolean isPurchase, boolean fixedAsset, int configObject) {
    AccountManagement accountManagement = this.getAccountManagement(product, company, configObject);
    Account account = null;
    if (accountManagement != null) {
        if (isPurchase) {
            if (fixedAsset) {
                account = accountManagement.getPurchFixedAssetsAccount();
            } else {
                account = accountManagement.getPurchaseAccount();
            }
        } else {
            account = accountManagement.getSaleAccount();
        }
    }
    if (account == null && configObject == CONFIG_OBJECT_PRODUCT) {
        return getProductAccount(product, company, isPurchase, fixedAsset, CONFIG_OBJECT_PRODUCT_FAMILY);
    }
    return account;
}
Also used : Account(com.axelor.apps.account.db.Account) AccountManagement(com.axelor.apps.account.db.AccountManagement) CallMethod(com.axelor.meta.CallMethod)

Example 2 with CallMethod

use of com.axelor.meta.CallMethod in project axelor-open-suite by axelor.

the class AppBaseServiceImpl method getCustomStyle.

@CallMethod
@Override
public String getCustomStyle() {
    AppBase appBase = Beans.get(AppBaseRepository.class).all().fetchOne();
    String style = appBase.getCustomAppStyle();
    if (StringUtils.isBlank(style)) {
        return null;
    }
    return style;
}
Also used : AppBase(com.axelor.apps.base.db.AppBase) CallMethod(com.axelor.meta.CallMethod)

Example 3 with CallMethod

use of com.axelor.meta.CallMethod in project axelor-open-suite by axelor.

the class ActionEmailBuilderService method sendEmail.

@CallMethod
public ActionResponse sendEmail(Long objectId, String model, String tag, Long templateId, int sendOption) throws ClassNotFoundException, InstantiationException, IllegalAccessException, AxelorException, IOException, MessagingException {
    Template template = templateRepo.find(templateId);
    Message message = templateMessageService.generateMessage(objectId, model, tag, template);
    ActionResponse response = new ActionResponse();
    if (sendOption == 0) {
        messageService.sendByEmail(message);
    } else {
        response.setView(ActionView.define(I18n.get(IExceptionMessage.MESSAGE_3)).model(Message.class.getName()).add("form", "message-form").param("forceEdit", "true").context("_showRecord", message.getId().toString()).map());
    }
    return response;
}
Also used : Message(com.axelor.apps.message.db.Message) IExceptionMessage(com.axelor.apps.message.exception.IExceptionMessage) ActionResponse(com.axelor.rpc.ActionResponse) Template(com.axelor.apps.message.db.Template) CallMethod(com.axelor.meta.CallMethod)

Example 4 with CallMethod

use of com.axelor.meta.CallMethod in project axelor-open-suite by axelor.

the class WkfDisplayServiceImpl method getWkfNodeCountUrl.

@Override
@CallMethod
public String getWkfNodeCountUrl(WkfModel wkfModel) {
    try {
        Map<String, Integer> activityCountMap = new HashMap<>();
        List<WkfInstance> instances = Beans.get(WkfInstanceRepository.class).all().filter("self.wkfProcess.wkfModel.id = ?1", wkfModel.getId()).fetch();
        log.trace("Total process instances: {}", instances.size());
        for (WkfInstance instance : instances) {
            getActivityPassCount(instance.getInstanceId(), activityCountMap);
        }
        log.trace("Count map: {}", activityCountMap);
        String activityCount = activityCountMap.keySet().stream().map(it -> it + ":" + activityCountMap.get(it)).collect(Collectors.joining(","));
        String url = String.format(engineService.getWkfViewerUrl(), "id=" + wkfModel.getId(), null, activityCount);
        log.trace("Url created: {}", url);
        return url;
    } catch (Exception e) {
    }
    return null;
}
Also used : HistoryService(org.camunda.bpm.engine.HistoryService) CallMethod(com.axelor.meta.CallMethod) Inject(com.google.inject.Inject) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessEngineService(com.axelor.apps.bpm.service.init.ProcessEngineService) WkfInstanceRepository(com.axelor.apps.bpm.db.repo.WkfInstanceRepository) WkfInstanceService(com.axelor.apps.bpm.service.execution.WkfInstanceService) WkfInstance(com.axelor.apps.bpm.db.WkfInstance) Map(java.util.Map) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) HistoricVariableInstanceQuery(org.camunda.bpm.engine.history.HistoricVariableInstanceQuery) WkfTaskConfigRepository(com.axelor.apps.bpm.db.repo.WkfTaskConfigRepository) WkfModel(com.axelor.apps.bpm.db.WkfModel) JPA(com.axelor.db.JPA) Logger(org.slf4j.Logger) Model(com.axelor.db.Model) Iterator(java.util.Iterator) ActivityTypes(org.camunda.bpm.engine.ActivityTypes) Set(java.util.Set) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) WkfProcess(com.axelor.apps.bpm.db.WkfProcess) Collectors(java.util.stream.Collectors) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) List(java.util.List) Beans(com.axelor.inject.Beans) WkfTaskConfig(com.axelor.apps.bpm.db.WkfTaskConfig) Process(org.camunda.bpm.model.bpmn.instance.Process) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) RuntimeService(org.camunda.bpm.engine.RuntimeService) AuthUtils(com.axelor.auth.AuthUtils) User(com.axelor.auth.db.User) MetaJsonRecord(com.axelor.meta.db.MetaJsonRecord) Joiner(com.google.common.base.Joiner) HashMap(java.util.HashMap) WkfInstance(com.axelor.apps.bpm.db.WkfInstance) WkfInstanceRepository(com.axelor.apps.bpm.db.repo.WkfInstanceRepository) CallMethod(com.axelor.meta.CallMethod)

Example 5 with CallMethod

use of com.axelor.meta.CallMethod in project axelor-open-suite by axelor.

the class WkfInstanceServiceImpl method findProcessInstanceByNode.

@Override
@CallMethod
public List<String> findProcessInstanceByNode(String nodeKey, String processId, String type, boolean permanent) {
    HistoricProcessInstanceQuery processInstanceQuery = engineService.getEngine().getHistoryService().createHistoricProcessInstanceQuery();
    List<String> processInstanceIds = processInstanceQuery.processDefinitionId(processId).activeActivityIdIn(nodeKey).unfinished().list().stream().map(it -> it.getId()).collect(Collectors.toList());
    if (permanent) {
        processInstanceQuery = engineService.getEngine().getHistoryService().createHistoricProcessInstanceQuery();
        processInstanceQuery.processDefinitionId(processId).executedActivityIdIn(nodeKey).list().stream().forEach(it -> processInstanceIds.add(it.getId()));
    }
    if (type != null && type.equals(BpmnModelConstants.BPMN_ELEMENT_END_EVENT)) {
        engineService.getEngine().getHistoryService().createHistoricProcessInstanceQuery().executedActivityIdIn(nodeKey).completed().or().finished().endOr().processDefinitionKey(processId.substring(0, processId.indexOf(":"))).list().forEach(it -> processInstanceIds.add(it.getId()));
    }
    processInstanceIds.add("0");
    return processInstanceIds;
}
Also used : HistoryService(org.camunda.bpm.engine.HistoryService) CallMethod(com.axelor.meta.CallMethod) FullContextHelper(com.axelor.apps.tool.context.FullContextHelper) Variables(org.camunda.bpm.engine.variable.Variables) EntityHelper(com.axelor.db.EntityHelper) WkfProcessConfig(com.axelor.apps.bpm.db.WkfProcessConfig) Inject(com.google.inject.Inject) LoggerFactory(org.slf4j.LoggerFactory) MessagingException(javax.mail.MessagingException) HashMap(java.util.HashMap) FullContext(com.axelor.apps.tool.context.FullContext) Transactional(com.google.inject.persist.Transactional) ArrayList(java.util.ArrayList) Strings(com.google.common.base.Strings) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessEngineService(com.axelor.apps.bpm.service.init.ProcessEngineService) AxelorException(com.axelor.exception.AxelorException) WkfInstanceRepository(com.axelor.apps.bpm.db.repo.WkfInstanceRepository) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) WkfInstance(com.axelor.apps.bpm.db.WkfInstance) Map(java.util.Map) WkfContextHelper(com.axelor.apps.bpm.context.WkfContextHelper) WkfCommonService(com.axelor.apps.bpm.service.WkfCommonService) MetaFiles(com.axelor.meta.MetaFiles) WkfTaskConfigRepository(com.axelor.apps.bpm.db.repo.WkfTaskConfigRepository) Logger(org.slf4j.Logger) Model(com.axelor.db.Model) ImmutableMap(com.google.common.collect.ImmutableMap) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) IOException(java.io.IOException) WkfProcess(com.axelor.apps.bpm.db.WkfProcess) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) IOUtils(org.apache.commons.io.IOUtils) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) List(java.util.List) Beans(com.axelor.inject.Beans) WkfTaskConfig(com.axelor.apps.bpm.db.WkfTaskConfig) BpmnModelConstants(org.camunda.bpm.model.bpmn.impl.BpmnModelConstants) HistoricActivityInstanceQuery(org.camunda.bpm.engine.history.HistoricActivityInstanceQuery) ProcessInstantiationBuilder(org.camunda.bpm.engine.runtime.ProcessInstantiationBuilder) RuntimeService(org.camunda.bpm.engine.RuntimeService) MetaJsonRecord(com.axelor.meta.db.MetaJsonRecord) InputStream(java.io.InputStream) SerializationDataFormats(org.camunda.bpm.engine.variable.Variables.SerializationDataFormats) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) CallMethod(com.axelor.meta.CallMethod)

Aggregations

CallMethod (com.axelor.meta.CallMethod)9 WkfInstance (com.axelor.apps.bpm.db.WkfInstance)3 WkfProcess (com.axelor.apps.bpm.db.WkfProcess)3 WkfTaskConfig (com.axelor.apps.bpm.db.WkfTaskConfig)3 WkfInstanceRepository (com.axelor.apps.bpm.db.repo.WkfInstanceRepository)3 WkfTaskConfigRepository (com.axelor.apps.bpm.db.repo.WkfTaskConfigRepository)3 ProcessEngineService (com.axelor.apps.bpm.service.init.ProcessEngineService)3 Model (com.axelor.db.Model)3 Beans (com.axelor.inject.Beans)3 MetaJsonRecord (com.axelor.meta.db.MetaJsonRecord)3 Inject (com.google.inject.Inject)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3 HistoryService (org.camunda.bpm.engine.HistoryService)3 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)3 RuntimeService (org.camunda.bpm.engine.RuntimeService)3 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)3