use of com.centurylink.mdw.bpm.MDWProcess in project mdw-designer by CenturyLinkCloud.
the class GraphFragment method toString.
@Override
public String toString() {
ProcessDefinitionDocument defnDoc = ProcessDefinitionDocument.Factory.newInstance();
MDWProcessDefinition procDefn = defnDoc.addNewProcessDefinition();
MDWProcess process = procDefn.addNewProcess();
process.setId(sourceProcessId.toString());
for (Node node : nodes) {
exportActivity(node.nodet, process.addNewActivity());
}
for (Link link : links) {
exportTransition(link.conn, process.addNewTransition());
}
for (SubGraph subgraph : subgraphs) {
MDWProcess subproc = process.addNewSubProcess();
subproc.setId(subgraph.getId().toString());
subproc.setName(subgraph.getName());
for (Node node : subgraph.nodes) {
exportActivity(node.nodet, subproc.addNewActivity());
}
for (Link link : subgraph.links) {
exportTransition(link.conn, subproc.addNewTransition());
}
}
return defnDoc.xmlText(new XmlOptions().setSavePrettyPrint());
}
use of com.centurylink.mdw.bpm.MDWProcess in project mdw-designer by CenturyLinkCloud.
the class Importer method importAttributes.
public void importAttributes(final WorkflowElement element, final String xml, final ProgressMonitor progressMonitor, String attrPrefix) throws DataAccessException, XmlException {
progressMonitor.subTask(PARSING_XML);
int schemaVersion = dataAccess.getSchemaVersion();
ProcessImporter importer = DataAccess.getProcessImporter(schemaVersion);
progressMonitor.progress(40);
progressMonitor.subTask("Saving attributes");
ProcessDefinitionDocument procdef = ProcessDefinitionDocument.Factory.parse(xml, Compatibility.namespaceOptions());
if (element instanceof WorkflowPackage && !((WorkflowPackage) element).getName().equals(procdef.getProcessDefinition().getPackageName()))
throw new DataAccessException("Expected package: " + ((WorkflowPackage) element).getName() + " in attributes XML but found: " + procdef.getProcessDefinition().getPackageName());
for (MDWProcess process : procdef.getProcessDefinition().getProcessList()) {
ProcessDefinitionDocument oneProcDef = ProcessDefinitionDocument.Factory.newInstance();
MDWProcessDefinition oneProc = oneProcDef.addNewProcessDefinition();
oneProc.getProcessList().add(process);
ProcessVO importedProc = importer.importProcess(oneProcDef.xmlText());
if (element instanceof WorkflowProcess && !((WorkflowProcess) element).getName().equals(importedProc.getProcessName()))
throw new DataAccessException("Expected process: " + ((WorkflowProcess) element).getName() + " in attributes XML but found: " + importedProc.getName());
ProcessVO proc = dataAccess.getLatestProcess(importedProc.getName());
if (proc == null)
throw new DataAccessException("Process not found: " + importedProc.getName());
Map<String, String> existAttrs = dataAccess.getDesignerDataAccess().getAttributes(OwnerType.PROCESS, proc.getId());
Map<String, String> importedAttrs = importedProc.getOverrideAttributes();
Map<String, String> setAttrs = new HashMap<>();
if (existAttrs != null) {
// retain existing attrs not related to this prefix
for (Map.Entry<String, String> attrs : existAttrs.entrySet()) {
if (!WorkAttributeConstant.isAttrNameFor(attrs.getKey(), attrPrefix))
setAttrs.put(attrs.getKey(), attrs.getValue());
}
}
if (importedAttrs != null) {
for (Map.Entry<String, String> attrs : importedAttrs.entrySet()) {
if (!WorkAttributeConstant.isAttrNameFor(attrs.getKey(), attrPrefix))
throw new DataAccessException("Expected attribute prefix: " + attrPrefix + " in attributes XML but found attribute: " + attrs.getKey());
else
setAttrs.put(attrs.getKey(), attrs.getValue());
}
}
dataAccess.getDesignerDataAccess().setOverrideAttributes(attrPrefix, OwnerType.PROCESS, proc.getId(), setAttrs);
}
}
Aggregations