use of com.google.cloud.servicedirectory.v1.Namespace in project scylla by bptlab.
the class CommonProcessElementsParser method parse.
@Override
public CommonProcessElements parse(Element rootElement) throws ScyllaValidationException {
String definitionsId = rootElement.getAttributeValue("id");
Namespace bpmnNamespace = rootElement.getNamespace();
Map<String, GlobalTaskType> globalTasks = new HashMap<String, GlobalTaskType>();
Map<String, Element> globalTaskElements = new HashMap<String, Element>();
Map<String, Map<String, String>> resources = new HashMap<String, Map<String, String>>();
Map<String, Map<String, String>> messages = new HashMap<String, Map<String, String>>();
Map<String, Map<String, String>> errors = new HashMap<String, Map<String, String>>();
Map<String, Map<String, String>> escalations = new HashMap<String, Map<String, String>>();
// global tasks called by call activities
for (GlobalTaskType gtt : GlobalTaskType.values()) {
List<Element> gte = rootElement.getChildren(gtt.toString(), bpmnNamespace);
for (Element el : gte) {
String elementId = el.getAttributeValue("id");
globalTasks.put(elementId, gtt);
globalTaskElements.put(elementId, el);
}
}
// common elements: chapter 8.4 in BPMN 2.0.2 definition
List<Element> resourceElements = rootElement.getChildren("resource", bpmnNamespace);
for (Element el : resourceElements) {
Map<String, String> resource = new HashMap<String, String>();
String elementId = el.getAttributeValue("id");
String name = el.getAttributeValue("name");
if (name != null) {
resource.put("name", name);
}
resources.put(elementId, resource);
}
List<Element> messageElements = rootElement.getChildren("message", bpmnNamespace);
for (Element el : messageElements) {
Map<String, String> message = new HashMap<String, String>();
String elementId = el.getAttributeValue("id");
String name = el.getAttributeValue("name");
if (name != null) {
message.put("name", name);
}
messages.put(elementId, message);
}
List<Element> errorElements = rootElement.getChildren("error", bpmnNamespace);
for (Element el : errorElements) {
Map<String, String> error = new HashMap<String, String>();
String elementId = el.getAttributeValue("id");
String name = el.getAttributeValue("name");
if (name != null) {
error.put("name", name);
}
String errorCode = el.getAttributeValue("errorCode");
if (errorCode != null) {
error.put("errorCode", errorCode);
}
errors.put(elementId, error);
}
List<Element> escalationElements = rootElement.getChildren("escalation", bpmnNamespace);
for (Element el : escalationElements) {
Map<String, String> escalation = new HashMap<String, String>();
String elementId = el.getAttributeValue("id");
String name = el.getAttributeValue("name");
if (name != null) {
escalation.put("name", name);
}
String escalationCode = el.getAttributeValue("escalationCode");
if (escalationCode != null) {
escalation.put("escalationCode", escalationCode);
}
escalations.put(elementId, escalation);
}
CommonProcessElements commonProcessElements = new CommonProcessElements(definitionsId, globalTasks, globalTaskElements, resources, messages, errors, escalations);
return commonProcessElements;
}
use of com.google.cloud.servicedirectory.v1.Namespace in project scylla by bptlab.
the class ProcessModelParser method parse.
@Override
public ProcessModel parse(Element rootElement) throws ScyllaValidationException {
Namespace bpmnNamespace = rootElement.getNamespace();
List<Element> processElements = rootElement.getChildren("process", bpmnNamespace);
if (processElements.isEmpty()) {
throw new ScyllaValidationException("No process in file.");
}
// pool references to process models
Map<String, String> processIdToPoolName = new HashMap<String, String>();
Map<String, MessageFlow> messageFlows = new HashMap<String, MessageFlow>();
Element collaboration = rootElement.getChild("collaboration", bpmnNamespace);
if (collaboration != null) {
for (Element el : collaboration.getChildren()) {
String elementName = el.getName();
if (elementName.equals("participant")) {
if (el.getAttributeValue("processRef") != null) {
String participantName = el.getAttributeValue("name");
String processId = el.getAttributeValue("processRef");
processIdToPoolName.put(processId, participantName);
}
} else if (elementName.equals("messageFlow")) {
String id = el.getAttributeValue("id");
String sourceRef = el.getAttributeValue("sourceRef");
String targetRef = el.getAttributeValue("targetRef");
MessageFlow messageFlow = new MessageFlow(id, sourceRef, targetRef);
messageFlows.put(id, messageFlow);
} else {
DebugLogger.log("Element " + el.getName() + " of collaboration not supported.");
}
}
}
Map<String, ProcessModel> processModels = new HashMap<String, ProcessModel>();
for (Element process : processElements) {
ProcessModel processModel = parseProcess(process, bpmnNamespace, false, commonProcessElements);
String processId = processModel.getId();
if (processIdToPoolName.containsKey(processId)) {
String participant = processIdToPoolName.get(processId);
processModel.setParticipant(participant);
}
processModels.put(processId, processModel);
}
if (processModels.size() == 1) {
return processModels.values().iterator().next();
} else {
try {
Set<ProcessModel> processModelsTriggeredInCollaboration = new HashSet<ProcessModel>();
ProcessModel processModelTriggeredExternally = null;
for (String processId : processModels.keySet()) {
ProcessModel pm = processModels.get(processId);
int startNodeId = pm.getStartNode();
String identifierOfStartNode = pm.getIdentifiers().get(startNodeId);
boolean isTriggeredInCollaboration = false;
for (MessageFlow mf : messageFlows.values()) {
if (mf.getTargetRef().equals(identifierOfStartNode)) {
isTriggeredInCollaboration = true;
break;
}
}
if (isTriggeredInCollaboration) {
processModelsTriggeredInCollaboration.add(pm);
} else {
if (processModelTriggeredExternally != null) {
throw new ScyllaValidationException("BPMN file contains multiple process models that are triggered externally.");
}
processModelTriggeredExternally = pm;
}
}
processModelTriggeredExternally.setProcessModelsInCollaboration(processModelsTriggeredInCollaboration);
return processModelTriggeredExternally;
} catch (NodeNotFoundException | MultipleStartNodesException | NoStartNodeException e) {
e.printStackTrace();
throw new ScyllaValidationException(e.getMessage());
}
}
}
use of com.google.cloud.servicedirectory.v1.Namespace in project wildfly-camel by wildfly-extras.
the class WildFlyCamelConfigPlugin method updateExtension.
private static void updateExtension(ConfigContext context, boolean enable) {
Element extensions = ConfigSupport.findChildElement(context.getDocument().getRootElement(), "extensions", NS_DOMAINS);
ConfigSupport.assertExists(extensions, "Did not find the <extensions> element");
Namespace namespace = extensions.getNamespace();
Element element = ConfigSupport.findElementWithAttributeValue(extensions, "extension", "module", "org.wildfly.extension.camel", NS_DOMAINS);
if (enable && element == null) {
extensions.addContent(new Text(" "));
extensions.addContent(new Element("extension", namespace).setAttribute("module", "org.wildfly.extension.camel"));
extensions.addContent(new Text("\n "));
}
if (!enable && element != null) {
element.getParentElement().removeContent(element);
}
}
use of com.google.cloud.servicedirectory.v1.Namespace in project wildfly-camel by wildfly-extras.
the class WildFlyCamelConfigPlugin method updateSystemProperties.
@SuppressWarnings("unchecked")
private static void updateSystemProperties(ConfigContext context, boolean enable) {
Element rootElement = context.getDocument().getRootElement();
Element extensions = ConfigSupport.findChildElement(rootElement, "extensions", NS_DOMAINS);
ConfigSupport.assertExists(extensions, "Did not find the <extensions> element");
Namespace namespace = extensions.getNamespace();
Element element = ConfigSupport.findChildElement(rootElement, "system-properties", NS_DOMAINS);
if (element == null) {
element = new Element("system-properties", namespace);
element.addContent(new Text("\n "));
int pos = rootElement.indexOf(extensions);
rootElement.addContent(pos + 1, new Text(" "));
rootElement.addContent(pos + 1, element);
rootElement.addContent(pos + 1, new Text("\n "));
}
Map<String, Element> propertiesByName = ConfigSupport.mapByAttributeName(element.getChildren(), "name");
if (enable) {
addProperty(element, propertiesByName, "hawtio.authenticationEnabled", "true");
addProperty(element, propertiesByName, "hawtio.realm", "hawtio-domain");
addProperty(element, propertiesByName, "org.apache.xml.dtm.DTMManager", "org.apache.xml.dtm.ref.DTMManagerDefault");
} else {
removeProperty(propertiesByName, "hawtio.authenticationEnabled");
removeProperty(propertiesByName, "hawtio.realm");
/* Do not remove org.apache.xml.dtm.DTMManager because we do not know whether it was added by us or by the
* user. Leaving it there should be harmless or even beneficial for the perf of XPath.evaluate() */
}
}
use of com.google.cloud.servicedirectory.v1.Namespace in project wildfly-camel by wildfly-extras.
the class ConfigSupport method findProfileElements.
@SuppressWarnings("unchecked")
public static List<Element> findProfileElements(Document doc, Namespace... supportedNamespaces) {
List<Element> result = new ArrayList<>();
for (Namespace ns : supportedNamespaces) {
Element profile = doc.getRootElement().getChild("profile", ns);
if (profile != null) {
result.add(profile);
}
Element profiles = doc.getRootElement().getChild("profiles", ns);
if (profiles != null) {
result.addAll(profiles.getChildren("profile", ns));
}
}
return result;
}
Aggregations