Search in sources :

Example 36 with Namespace

use of com.google.cloud.servicedirectory.v1.Namespace in project qpp-conversion-tool by CMSgov.

the class AciMeasurePerformedRnRDecoderTest method internalDecodeReturnsTreeContinue.

@Test
void internalDecodeReturnsTreeContinue() {
    // set-up
    AciMeasurePerformedRnRDecoder objectUnderTest = new AciMeasurePerformedRnRDecoder(new Context());
    Namespace rootns = Namespace.getNamespace("urn:hl7-org:v3");
    Namespace ns = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
    Element element = new Element("organizer", rootns);
    Element templateIdElement = new Element("templateId", rootns).setAttribute("root", "2.16.840.1.113883.10.20.27.3.28");
    Element referenceElement = new Element("reference", rootns);
    Element externalDocumentElement = new Element("externalDocument", rootns);
    Element idElement = new Element("id", rootns).setAttribute("extension", MEASURE_ID);
    externalDocumentElement.addContent(idElement);
    referenceElement.addContent(externalDocumentElement);
    element.addContent(templateIdElement);
    element.addContent(referenceElement);
    element.addNamespaceDeclaration(ns);
    Node aciMeasurePerformedNode = new Node();
    objectUnderTest.setNamespace(element.getNamespace());
    // execute
    DecodeResult decodeResult = objectUnderTest.decode(element, aciMeasurePerformedNode);
    // assert
    assertThat(decodeResult).isEqualTo(DecodeResult.TREE_CONTINUE);
    String actualMeasureId = aciMeasurePerformedNode.getValue("measureId");
    assertThat(actualMeasureId).isEqualTo(MEASURE_ID);
}
Also used : Context(gov.cms.qpp.conversion.Context) Element(org.jdom2.Element) Node(gov.cms.qpp.conversion.model.Node) Namespace(org.jdom2.Namespace) Test(org.junit.jupiter.api.Test)

Example 37 with Namespace

use of com.google.cloud.servicedirectory.v1.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 38 with Namespace

use of com.google.cloud.servicedirectory.v1.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 39 with Namespace

use of com.google.cloud.servicedirectory.v1.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 40 with Namespace

use of com.google.cloud.servicedirectory.v1.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)

Aggregations

Namespace (org.jdom2.Namespace)176 Element (org.jdom2.Element)145 IOException (java.io.IOException)45 Document (org.jdom2.Document)36 ArrayList (java.util.ArrayList)30 Attribute (org.jdom2.Attribute)25 HashMap (java.util.HashMap)23 List (java.util.List)21 XConfiguration (org.apache.oozie.util.XConfiguration)19 StringReader (java.io.StringReader)18 JDOMException (org.jdom2.JDOMException)18 Configuration (org.apache.hadoop.conf.Configuration)15 SAXBuilder (org.jdom2.input.SAXBuilder)15 Map (java.util.Map)14 ActionExecutorException (org.apache.oozie.action.ActionExecutorException)14 Namespace.getNamespace (org.jdom2.Namespace.getNamespace)14 MigrationReport (com.mulesoft.tools.migration.step.category.MigrationReport)13 File (java.io.File)13 Path (org.apache.hadoop.fs.Path)12 Path (java.nio.file.Path)11