Search in sources :

Example 11 with WkfProcess

use of com.axelor.apps.bpm.db.WkfProcess in project axelor-open-suite by axelor.

the class WkfModelController method setModelsDomain.

public void setModelsDomain(ActionRequest request, ActionResponse response) {
    try {
        WkfModel wkfModel = null;
        List<Long> jsonModelIds = new ArrayList<>();
        List<Long> metaModelIds = new ArrayList<>();
        if (request.getContext().get("wkfId") != null) {
            wkfModel = wkfModelRepository.find(Long.parseLong(request.getContext().get("wkfId").toString()));
        }
        String process = (String) request.getContext().get("_process");
        if (wkfModel != null) {
            for (WkfProcess wkfProcess : wkfModel.getWkfProcessList()) {
                if (CollectionUtils.isEmpty(wkfProcess.getWkfProcessConfigList()) || !wkfProcess.getName().equals(process)) {
                    continue;
                }
                for (WkfProcessConfig processConfig : wkfProcess.getWkfProcessConfigList()) {
                    if (processConfig.getMetaModel() != null) {
                        metaModelIds.add(processConfig.getMetaModel().getId());
                    }
                    if (processConfig.getMetaJsonModel() != null) {
                        jsonModelIds.add(processConfig.getMetaJsonModel().getId());
                    }
                }
            }
        }
        response.setAttr("metaJsonModel", "domain", !jsonModelIds.isEmpty() ? "self.id IN (" + StringUtils.join(jsonModelIds, ',') + ")" : "self.id IN (0)");
        response.setAttr("metaModel", "domain", !metaModelIds.isEmpty() ? "self.id IN (" + StringUtils.join(metaModelIds, ',') + ")" : "self.id IN (0)");
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : WkfProcess(com.axelor.apps.bpm.db.WkfProcess) WkfProcessConfig(com.axelor.apps.bpm.db.WkfProcessConfig) WkfModel(com.axelor.apps.bpm.db.WkfModel) ArrayList(java.util.ArrayList) AxelorException(com.axelor.exception.AxelorException)

Aggregations

WkfProcess (com.axelor.apps.bpm.db.WkfProcess)11 HashMap (java.util.HashMap)8 WkfProcessConfig (com.axelor.apps.bpm.db.WkfProcessConfig)6 ArrayList (java.util.ArrayList)6 WkfModel (com.axelor.apps.bpm.db.WkfModel)4 User (com.axelor.auth.db.User)4 List (java.util.List)4 Map (java.util.Map)4 WkfInstance (com.axelor.apps.bpm.db.WkfInstance)3 WkfTaskConfig (com.axelor.apps.bpm.db.WkfTaskConfig)2 FullContext (com.axelor.apps.tool.context.FullContext)2 Model (com.axelor.db.Model)2 AxelorException (com.axelor.exception.AxelorException)2 MetaJsonRecord (com.axelor.meta.db.MetaJsonRecord)2 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)2 RuntimeService (org.camunda.bpm.engine.RuntimeService)2 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)2 NodeList (org.w3c.dom.NodeList)2 WkfInstanceRepository (com.axelor.apps.bpm.db.repo.WkfInstanceRepository)1 WkfProcessRepository (com.axelor.apps.bpm.db.repo.WkfProcessRepository)1