Search in sources :

Example 1 with WkfTaskConfig

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

the class WkfNodeService method extractNodes.

public List<MetaAttrs> extractNodes(WkfModel wkfModel, BpmnModelInstance bpmInstance, Map<String, String> processMap) {
    Map<String, WkfTaskConfig> configMap = new HashMap<>();
    if (wkfModel.getWkfTaskConfigList() != null) {
        for (WkfTaskConfig config : wkfModel.getWkfTaskConfigList()) {
            configMap.put(config.getName(), config);
        }
    }
    List<MetaAttrs> metaAttrsList = new ArrayList<MetaAttrs>();
    Collection<FlowNode> activities = new ArrayList<FlowNode>();
    activities.addAll(bpmInstance.getModelElementsByType(Activity.class));
    activities.addAll(bpmInstance.getModelElementsByType(CatchEvent.class));
    activities.addAll(bpmInstance.getModelElementsByType(EndEvent.class));
    if (activities != null) {
        for (FlowNode activity : activities) {
            WkfTaskConfig config = updateTaskConfig(wkfModel, configMap, metaAttrsList, activity);
            Process process = findProcess(activity);
            if (process != null) {
                config.setProcessId(processMap.get(process.getId()));
            }
            updateMenus(config, false);
            wkfModel.addWkfTaskConfigListItem(config);
        }
    }
    for (String name : configMap.keySet()) {
        updateMenus(configMap.get(name), true);
        wkfModel.removeWkfTaskConfigListItem(configMap.get(name));
    }
    return metaAttrsList;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Activity(org.camunda.bpm.model.bpmn.instance.Activity) Process(org.camunda.bpm.model.bpmn.instance.Process) CatchEvent(org.camunda.bpm.model.bpmn.instance.CatchEvent) WkfTaskConfig(com.axelor.apps.bpm.db.WkfTaskConfig) MetaAttrs(com.axelor.meta.db.MetaAttrs) EndEvent(org.camunda.bpm.model.bpmn.instance.EndEvent) FlowNode(org.camunda.bpm.model.bpmn.instance.FlowNode)

Example 2 with WkfTaskConfig

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

the class WkfNodeService method updateTaskConfig.

public WkfTaskConfig updateTaskConfig(WkfModel wkfModel, Map<String, WkfTaskConfig> configMap, List<MetaAttrs> metaAttrsList, FlowNode activity) {
    WkfTaskConfig config;
    if (configMap.containsKey(activity.getId())) {
        config = configMap.get(activity.getId());
        configMap.remove(activity.getId());
    } else {
        config = new WkfTaskConfig();
        config.setName(activity.getId());
        wkfConfigRepository.save(config);
    }
    config.setDescription(activity.getName());
    config.setType(activity.getElementType().getTypeName());
    config.setButton(null);
    config.setExpression(null);
    config = (WkfTaskConfig) Beans.get(WkfCommonService.class).addProperties(WkfPropertyMapper.FIELD_MAP, config, activity);
    ExtensionElements extensionElements = activity.getExtensionElements();
    if (extensionElements != null) {
        for (ModelElementInstance modelElementInstance : extensionElements.getElements()) {
            metaAttrsList.addAll(metaAttrsService.createMetaAttrs(activity.getId(), modelElementInstance, config, wkfModel.getId().toString()));
        }
    }
    return config;
}
Also used : ExtensionElements(org.camunda.bpm.model.bpmn.instance.ExtensionElements) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) WkfTaskConfig(com.axelor.apps.bpm.db.WkfTaskConfig) WkfCommonService(com.axelor.apps.bpm.service.WkfCommonService)

Example 3 with WkfTaskConfig

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

the class WkfExecutionListener method onNodeActivation.

private void onNodeActivation(DelegateExecution execution) {
    WkfTaskConfig wkfTaskConfig = Beans.get(WkfTaskConfigRepository.class).all().filter("self.name = ? and self.wkfModel.id = (select wkfModel.id from WkfProcess where processId = ?)", execution.getCurrentActivityId(), execution.getProcessDefinitionId()).fetchOne();
    log.debug("Task config searched with taskId: {}, processInstanceId: {}, found:{}", execution.getCurrentActivityId(), execution.getProcessInstanceId(), wkfTaskConfig);
    if (wkfTaskConfig != null) {
        Beans.get(WkfInstanceService.class).onNodeActivation(wkfTaskConfig, execution);
    }
}
Also used : WkfInstanceService(com.axelor.apps.bpm.service.execution.WkfInstanceService) WkfTaskConfig(com.axelor.apps.bpm.db.WkfTaskConfig) WkfTaskConfigRepository(com.axelor.apps.bpm.db.repo.WkfTaskConfigRepository)

Example 4 with WkfTaskConfig

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

the class WkfInstanceServiceImpl method checkSubProcess.

protected void checkSubProcess(Model model) {
    String chldModel = model instanceof MetaJsonRecord ? ((MetaJsonRecord) model).getJsonModel() : model.getClass().getSimpleName();
    List<WkfTaskConfig> taskConfigs = wkfTaskConfigRepository.all().filter("self.callModel = ?1 AND self.callLink IS NOT NULL", chldModel).fetch();
    if (taskConfigs.isEmpty()) {
        return;
    }
    FullContext modelCtx = WkfContextHelper.create(model);
    Map<String, Object> ctxMap = ImmutableMap.of(wkfService.getVarName(model), modelCtx);
    for (WkfTaskConfig taskConfig : taskConfigs) {
        if (!evalCondition(ctxMap, taskConfig.getCallLinkCondition())) {
            continue;
        }
        Object parentModel = modelCtx.get(taskConfig.getCallLink());
        if (parentModel != null && parentModel instanceof FullContext) {
            Model parent = (Model) ((FullContext) parentModel).getTarget();
            if (parent.getProcessInstanceId() != null) {
                addChildProcessInstanceId(parent.getProcessInstanceId(), modelCtx, ctxMap);
                break;
            }
        }
    }
}
Also used : FullContext(com.axelor.apps.tool.context.FullContext) Model(com.axelor.db.Model) WkfTaskConfig(com.axelor.apps.bpm.db.WkfTaskConfig) MetaJsonRecord(com.axelor.meta.db.MetaJsonRecord)

Example 5 with WkfTaskConfig

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

the class WkfCache method initWkfButttonCache.

public static void initWkfButttonCache() {
    List<WkfTaskConfig> wkfTaskConfigs = JPA.all(WkfTaskConfig.class).fetch();
    MultiMap multiMap = new MultiValueMap();
    multiMap.put(0L, null);
    for (WkfTaskConfig config : wkfTaskConfigs) {
        if (config.getButton() != null) {
            for (String btnName : config.getButton().split(",")) {
                multiMap.put(config.getId(), btnName);
            }
        }
    }
    WKF_BUTTON_CACHE.put(BpmTools.getCurentTenant(), multiMap);
}
Also used : MultiMap(org.apache.commons.collections.MultiMap) WkfTaskConfig(com.axelor.apps.bpm.db.WkfTaskConfig) MultiValueMap(org.apache.commons.collections.map.MultiValueMap)

Aggregations

WkfTaskConfig (com.axelor.apps.bpm.db.WkfTaskConfig)7 HashMap (java.util.HashMap)3 User (com.axelor.auth.db.User)2 WkfProcess (com.axelor.apps.bpm.db.WkfProcess)1 WkfTaskConfigRepository (com.axelor.apps.bpm.db.repo.WkfTaskConfigRepository)1 WkfCommonService (com.axelor.apps.bpm.service.WkfCommonService)1 WkfInstanceService (com.axelor.apps.bpm.service.execution.WkfInstanceService)1 FullContext (com.axelor.apps.tool.context.FullContext)1 Model (com.axelor.db.Model)1 AxelorException (com.axelor.exception.AxelorException)1 MetaAttrs (com.axelor.meta.db.MetaAttrs)1 MetaJsonRecord (com.axelor.meta.db.MetaJsonRecord)1 ArrayList (java.util.ArrayList)1 MultiMap (org.apache.commons.collections.MultiMap)1 MultiValueMap (org.apache.commons.collections.map.MultiValueMap)1 HistoryService (org.camunda.bpm.engine.HistoryService)1 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)1 Execution (org.camunda.bpm.engine.runtime.Execution)1 Task (org.camunda.bpm.engine.task.Task)1 Activity (org.camunda.bpm.model.bpmn.instance.Activity)1