Search in sources :

Example 6 with Namespace

use of org.osate.aadl2.Namespace in project scylla by bptlab.

the class SimulationTest method setGlobalSeed.

protected void setGlobalSeed(Long seed) {
    if (seed == null)
        return;
    if (globalConfigRoot == null)
        beforeParsingGlobal.add(() -> setGlobalSeed(seed));
    else {
        Namespace nsp = globalConfigRoot.getNamespace();
        if (globalConfigRoot.getChild("randomSeed", nsp) == null)
            globalConfigRoot.addContent(new Element("randomSeed", nsp));
        globalConfigRoot.getChild("randomSeed", nsp).setText(seed.toString());
    }
}
Also used : Element(org.jdom2.Element) Namespace(org.jdom2.Namespace)

Example 7 with Namespace

use of org.osate.aadl2.Namespace in project scylla by bptlab.

the class BatchProcessModelParserPlugin method parse.

@Override
public Map<String, Object> parse(ProcessModel processModel, Element process) throws ScyllaValidationException {
    Namespace bpmnNamespace = process.getNamespace();
    Map<Integer, BatchActivity> batchActivities = new HashMap<Integer, BatchActivity>();
    for (Element element : process.getChildren()) {
        String elementName = element.getName();
        if (elementName.equals("subProcess") || elementName.equals("task") || elementName.endsWith("Task")) {
            String elementId = element.getAttributeValue("id");
            int nodeId = processModel.getIdentifiersToNodeIds().get(elementId);
            try {
                parseElement(element, bpmnNamespace, nodeId).ifPresent(batchActivity -> batchActivities.put(nodeId, batchActivity));
            } catch (ScyllaValidationException e) {
                throw new ScyllaValidationException("Error at parsing batch region with id " + elementId + ": " + e.getMessage(), e);
            }
        }
    }
    // Not needed batchActivities.forEach((key, value) -> value.setProcessModel(processModel));
    Map<String, Object> extensionAttributes = new HashMap<String, Object>();
    extensionAttributes.put(BatchPluginUtils.ACTIVITIES_KEY, batchActivities);
    return extensionAttributes;
}
Also used : ScyllaValidationException(de.hpi.bpt.scylla.exception.ScyllaValidationException) HashMap(java.util.HashMap) Element(org.jdom2.Element) Namespace(org.jdom2.Namespace)

Example 8 with Namespace

use of org.osate.aadl2.Namespace in project scylla by bptlab.

the class BatchProcessModelParserPlugin method parseElement.

private Optional<BatchActivity> parseElement(Element element, Namespace bpmnNamespace, Integer nodeId) throws ScyllaValidationException {
    Element extensions = element.getChild("extensionElements", bpmnNamespace);
    // Check that only elements with extensions get parsed
    if (extensions == null)
        return Optional.empty();
    String id = element.getAttributeValue("id");
    Namespace camundaNamespace = Namespace.getNamespace("camunda", "http://camunda.org/schema/1.0/bpmn");
    List<Namespace> possibleNamespaces = Arrays.asList(camundaNamespace, bpmnNamespace);
    List<Element> propertyList = possibleNamespaces.stream().map(namespace -> extensions.getChild("properties", namespace)).filter(Objects::nonNull).map(propertiesElement -> propertiesElement.getChildren("property", propertiesElement.getNamespace())).flatMap(List::stream).collect(Collectors.toList());
    if (propertyList.isEmpty())
        return Optional.empty();
    Integer maxBatchSize = null;
    BatchClusterExecutionType executionType = defaultExecutionType();
    ActivationRule activationRule = null;
    List<BatchGroupingCharacteristic> groupingCharacteristic = new ArrayList<BatchGroupingCharacteristic>();
    for (Element property : propertyList) {
        // maximum batch size
        switch(property.getAttributeValue("name")) {
            case "maxBatchSize":
                maxBatchSize = Integer.parseInt(property.getAttributeValue("value"));
                break;
            // execution type. if none is defined, take parallel as default
            case "executionType":
                executionType = parseExecutionType(property);
                break;
            // grouping characteristic
            case "groupingCharacteristic":
                groupingCharacteristic.addAll(parseGroupingCharacteristic(property));
                break;
            // threshold capacity (minimum batch size) & timeout of activation rule
            case "activationRule":
                activationRule = parseActivationRule(property);
                break;
        }
    }
    if (maxBatchSize == null) {
        throw new ScyllaValidationException("You have to specify a maxBatchSize at " + id + " .");
    }
    /*if (groupingCharacteristic.isEmpty()){
                        throw new ScyllaValidationException("You have to specify at least one groupingCharacteristic at "+ id +" .");
                    }*/
    BatchActivity ba = new BatchActivity(nodeId, maxBatchSize, executionType, activationRule, groupingCharacteristic);
    return Optional.of(ba);
}
Also used : Element(org.jdom2.Element) ArrayList(java.util.ArrayList) Namespace(org.jdom2.Namespace) ScyllaValidationException(de.hpi.bpt.scylla.exception.ScyllaValidationException)

Example 9 with Namespace

use of org.osate.aadl2.Namespace in project scylla by bptlab.

the class EventArrivalRateSCParserPlugin method parse.

/**
 * Parses all occurences of event arrival rates to be stored as extension attribute.
 */
@Override
public Map<String, Object> parse(SimulationConfiguration simulationInput, Element sim) throws ScyllaValidationException {
    Map<Integer, TimeDistributionWrapper> arrivalRates = new HashMap<Integer, TimeDistributionWrapper>();
    Namespace simNamespace = sim.getNamespace();
    ProcessModel processModel = simulationInput.getProcessModel();
    for (Element el : sim.getChildren()) {
        String elementName = el.getName();
        if (elementName.equals(EventArrivalRatePluginUtils.ELEMENT_NAME)) {
            String identifier = el.getAttributeValue("id");
            if (identifier == null) {
                DebugLogger.log("Warning: Simulation configuration definition catch event element '" + elementName + "' does not have an identifier, skip.");
                continue;
            }
            Integer nodeId = processModel.getIdentifiersToNodeIds().get(identifier);
            if (nodeId == null) {
                DebugLogger.log("Warning: There is no matching catch event in the process model for " + "simulation configuration definition '" + identifier + ", skip.");
                continue;
            }
            Element elem = el.getChild("arrivalRate", simNamespace);
            if (elem != null) {
                TimeDistributionWrapper distribution = SimulationConfigurationParser.getTimeDistributionWrapper(elem, simNamespace);
                arrivalRates.put(nodeId, distribution);
            }
        }
    }
    Map<String, Object> extensionAttributes = new HashMap<String, Object>();
    extensionAttributes.put(EventArrivalRatePluginUtils.ARRIVALRATES_KEY, arrivalRates);
    return extensionAttributes;
}
Also used : ProcessModel(de.hpi.bpt.scylla.model.process.ProcessModel) HashMap(java.util.HashMap) Element(org.jdom2.Element) TimeDistributionWrapper(de.hpi.bpt.scylla.model.configuration.distribution.TimeDistributionWrapper) Namespace(org.jdom2.Namespace)

Example 10 with Namespace

use of org.osate.aadl2.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;
}
Also used : CommonProcessElements(de.hpi.bpt.scylla.model.process.CommonProcessElements) GlobalTaskType(de.hpi.bpt.scylla.model.process.node.GlobalTaskType) HashMap(java.util.HashMap) Element(org.jdom2.Element) Map(java.util.Map) HashMap(java.util.HashMap) Namespace(org.jdom2.Namespace)

Aggregations

Namespace (org.jdom2.Namespace)150 Element (org.jdom2.Element)122 IOException (java.io.IOException)28 ArrayList (java.util.ArrayList)23 HashMap (java.util.HashMap)21 List (java.util.List)21 Document (org.jdom2.Document)20 XConfiguration (org.apache.oozie.util.XConfiguration)19 Attribute (org.jdom2.Attribute)17 Configuration (org.apache.hadoop.conf.Configuration)15 StringReader (java.io.StringReader)14 ActionExecutorException (org.apache.oozie.action.ActionExecutorException)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 JDOMException (org.jdom2.JDOMException)12 SAXBuilder (org.jdom2.input.SAXBuilder)10 AbstractApplicationModelMigrationStep (com.mulesoft.tools.migration.step.AbstractApplicationModelMigrationStep)9 ScyllaValidationException (de.hpi.bpt.scylla.exception.ScyllaValidationException)9