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;
}
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;
}
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);
}
}
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;
}
}
}
}
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);
}
Aggregations