Search in sources :

Example 11 with Namespace

use of org.osate.aadl2.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());
        }
    }
}
Also used : ProcessModel(de.hpi.bpt.scylla.model.process.ProcessModel) HashMap(java.util.HashMap) Element(org.jdom2.Element) MessageFlow(de.hpi.bpt.scylla.model.process.node.MessageFlow) MultipleStartNodesException(de.hpi.bpt.scylla.model.process.graph.exception.MultipleStartNodesException) Namespace(org.jdom2.Namespace) ScyllaValidationException(de.hpi.bpt.scylla.exception.ScyllaValidationException) NodeNotFoundException(de.hpi.bpt.scylla.model.process.graph.exception.NodeNotFoundException) NoStartNodeException(de.hpi.bpt.scylla.model.process.graph.exception.NoStartNodeException) HashSet(java.util.HashSet)

Example 12 with Namespace

use of org.osate.aadl2.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;
}
Also used : ApplicationMetadata(com.google.android.gms.cast.ApplicationMetadata) WebImage(com.google.android.gms.common.images.WebImage) Namespace(su.litvak.chromecast.api.v2.Namespace)

Example 13 with Namespace

use of org.osate.aadl2.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);
    }
}
Also used : Element(org.jdom2.Element) Text(org.jdom2.Text) Namespace(org.jdom2.Namespace)

Example 14 with Namespace

use of org.osate.aadl2.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() */
    }
}
Also used : Element(org.jdom2.Element) Text(org.jdom2.Text) Namespace(org.jdom2.Namespace)

Example 15 with Namespace

use of org.osate.aadl2.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;
}
Also used : Element(org.jdom2.Element) ArrayList(java.util.ArrayList) Namespace(org.jdom2.Namespace)

Aggregations

Namespace (org.jdom2.Namespace)158 Element (org.jdom2.Element)129 IOException (java.io.IOException)37 Document (org.jdom2.Document)26 ArrayList (java.util.ArrayList)25 Attribute (org.jdom2.Attribute)22 HashMap (java.util.HashMap)21 List (java.util.List)21 XConfiguration (org.apache.oozie.util.XConfiguration)19 Configuration (org.apache.hadoop.conf.Configuration)15 StringReader (java.io.StringReader)14 ActionExecutorException (org.apache.oozie.action.ActionExecutorException)14 JDOMException (org.jdom2.JDOMException)14 Namespace.getNamespace (org.jdom2.Namespace.getNamespace)14 MigrationReport (com.mulesoft.tools.migration.step.category.MigrationReport)13 Map (java.util.Map)12 Path (org.apache.hadoop.fs.Path)12 File (java.io.File)11 SAXBuilder (org.jdom2.input.SAXBuilder)11 Path (java.nio.file.Path)10