use of io.kubernetes.client.proto.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 io.kubernetes.client.proto.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;
}
use of io.kubernetes.client.proto.V1.Namespace in project JMRI by JMRI.
the class LocaleSelectorTest method testFindPartialCodeNoAttribute.
public void testFindPartialCodeNoAttribute() {
LocaleSelector.suffixes = new String[] { "kl_KL", "kl" };
Namespace xml = Namespace.XML_NAMESPACE;
Element el = new Element("foo").addContent(new Element("temp").setAttribute("lang", "aa_BB", xml).addContent("b")).addContent(new Element("temp").setAttribute("lang", "kl", xml).addContent("c")).addContent(new Element("temp").setAttribute("lang", "kl_AA", xml).addContent("d"));
String result = LocaleSelector.getAttribute(el, "temp");
Assert.assertEquals("find default", "c", result);
}
use of io.kubernetes.client.proto.V1.Namespace in project JMRI by JMRI.
the class LocaleSelectorTest method testFindFullCodeNoAttribute.
public void testFindFullCodeNoAttribute() {
LocaleSelector.suffixes = new String[] { "kl_KL", "kl" };
Namespace xml = Namespace.XML_NAMESPACE;
Element el = new Element("foo").addContent(new Element("temp").setAttribute("lang", "aa_BB", xml).addContent("b")).addContent(new Element("temp").setAttribute("lang", "kl", xml).addContent("b")).addContent(new Element("temp").setAttribute("lang", "kl_KL", xml).addContent("c"));
String result = LocaleSelector.getAttribute(el, "temp");
Assert.assertEquals("find default", "c", result);
}
use of io.kubernetes.client.proto.V1.Namespace in project JMRI by JMRI.
the class LocaleSelectorTest method testFindDefault.
public void testFindDefault() {
LocaleSelector.suffixes = new String[] { "kl_KL", "kl" };
Namespace xml = Namespace.XML_NAMESPACE;
Element el = new Element("foo").setAttribute("temp", "a").addContent(new Element("temp").setAttribute("lang", "hh", xml).addContent("b"));
String result = LocaleSelector.getAttribute(el, "temp");
Assert.assertEquals("find default", "a", result);
}
Aggregations