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 android_packages_apps_GmsCore by microg.
the class CastDeviceControllerImpl method createMetadataFromApplication.
protected ApplicationMetadata createMetadataFromApplication(Application app) {
if (app == null) {
return null;
}
ApplicationMetadata metadata = new ApplicationMetadata();
metadata.applicationId = app.id;
metadata.name = app.name;
Log.d(TAG, "unimplemented: ApplicationMetadata.images");
Log.d(TAG, "unimplemented: ApplicationMetadata.senderAppLaunchUri");
metadata.images = new ArrayList<WebImage>();
metadata.namespaces = new ArrayList<String>();
for (Namespace namespace : app.namespaces) {
metadata.namespaces.add(namespace.name);
}
metadata.senderAppIdentifier = this.context.getPackageName();
return metadata;
}
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