use of com.axelor.meta.db.MetaAttrs in project axelor-open-suite by axelor.
the class BpmDeploymentServiceImpl method deploy.
@Override
@Transactional
public void deploy(WkfModel wkfModel, Map<String, Map<String, String>> migrationMap) {
if (wkfModel.getDiagramXml() == null) {
return;
}
this.wkfModel = wkfModel;
this.migrationMap = migrationMap;
ProcessEngine engine = Beans.get(ProcessEngineService.class).getEngine();
String key = wkfModel.getId() + ".bpmn";
BpmnModelInstance bpmInstance = Bpmn.readModelFromStream(new ByteArrayInputStream(wkfModel.getDiagramXml().getBytes()));
DeploymentBuilder deploymentBuilder = engine.getRepositoryService().createDeployment().addModelInstance(key, bpmInstance).source(key);
Set<MetaFile> dmnFiles = wkfModel.getDmnFileSet();
if (dmnFiles != null) {
addDmn(deploymentBuilder, dmnFiles);
}
Map<String, String> processMap = deployProcess(engine, deploymentBuilder, bpmInstance);
List<MetaAttrs> metaAttrsList = Beans.get(WkfNodeService.class).extractNodes(wkfModel, bpmInstance, processMap);
Beans.get(WkfModelRepository.class).save(wkfModel);
metaAttrsService.saveMetaAttrs(metaAttrsList, wkfModel.getId());
}
use of com.axelor.meta.db.MetaAttrs in project axelor-open-suite by axelor.
the class MetaAttrsServiceImpl method saveMetaAttrs.
@Override
@Transactional
public void saveMetaAttrs(List<MetaAttrs> metaAttrsList, Long wkfModelId) {
List<Long> metaAttrsIds = new ArrayList<Long>();
metaAttrsIds.add(0L);
for (MetaAttrs metaAttrs : metaAttrsList) {
MetaAttrs saved = findMetaAttrs(metaAttrs, wkfModelId);
log.debug("Creating meta attrs: {}", saved);
saved.setValue(metaAttrs.getValue());
saved.setRoles(metaAttrs.getRoles());
metaAttrsRepository.save(saved);
metaAttrsIds.add(saved.getId());
}
long attrsRemoved = Query.of(MetaAttrs.class).filter("self.id not in ?1 and self.wkfModelId = ?2", metaAttrsIds, wkfModelId.toString()).remove();
log.debug("Total meta attrs removed: {}", attrsRemoved);
}
use of com.axelor.meta.db.MetaAttrs 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.meta.db.MetaAttrs in project axelor-open-suite by axelor.
the class MetaAttrsServiceImpl method createMetaAttrs.
@Override
public List<MetaAttrs> createMetaAttrs(String taskName, ModelElementInstance modelElementInstance, WkfTaskConfig config, String wkfModelId) {
List<MetaAttrs> metaAttrsList = new ArrayList<MetaAttrs>();
Collection<CamundaProperty> properties = modelElementInstance.getChildElementsByType(CamundaProperty.class);
log.debug("Extension elements: {}", properties.size());
String model = null;
String view = null;
String item = null;
String roles = null;
String permanent = null;
for (CamundaProperty property : properties) {
String name = property.getCamundaName();
String value = property.getCamundaValue();
if (name == null) {
continue;
}
log.debug("Processing property: {}, value: {}", name, value);
switch(name) {
case "model":
model = getModel(value);
view = null;
item = null;
roles = null;
break;
case "view":
view = value;
break;
case "item":
item = value;
break;
case "roles":
roles = value;
break;
case "modelName":
break;
case "modelType":
break;
case "itemLabel":
break;
case "permanent":
permanent = value;
break;
default:
if (model != null && item != null) {
MetaAttrs metaAttrs = new MetaAttrs();
metaAttrs.setModel(model);
metaAttrs.setView(view);
metaAttrs.setField(item);
metaAttrs.setRoles(findRoles(roles));
if (permanent != null && permanent.equals("true")) {
metaAttrs.setCondition(String.format(META_ATTRS_CONDITION_PERMANENT, taskName));
} else {
metaAttrs.setCondition(String.format(META_ATTRS_CONDITION, taskName));
}
metaAttrs.setValue(value);
metaAttrs.setName(name);
metaAttrs.setWkfModelId(wkfModelId);
metaAttrsList.add(metaAttrs);
}
break;
}
}
return metaAttrsList;
}
Aggregations