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);
}
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());
}
}
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;
}
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);
}
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;
}
Aggregations