use of org.jdom2.Namespace.getNamespace 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 org.jdom2.Namespace.getNamespace 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 org.jdom2.Namespace.getNamespace in project scylla by bptlab.
the class JDomTestClass method createEmpty.
public static void createEmpty() {
FileWriter writer;
// Namespace nsp = Namespace.getNamespace("bsim","http://bsim.hpi.uni-potsdam.de/scylla/simModel");
//
// Element root = new Element("globalConfiguration",nsp);
// Document d = new Document(root);
// root.setAttribute("targetNamespace", "http://www.hpi.de");
// Element rAO = new Element("resourceAssignmentOrder",nsp);
// rAO.setText("priority,simulationTime,");
// root.addContent(rAO);
GlobalConfigurationCreator c = new GlobalConfigurationCreator();
c.setId("This is an ID");
c.addReferencedResourceAssignmentOrder("priority");
c.addReferencedResourceAssignmentOrder("simulationTime");
c.removeReferencedResourceAssignmentOrder("simulationTime");
c.setSeed(1337);
c.setTimeOffset(ZoneOffset.ofHoursMinutesSeconds(13, 37, 42));
c.createTimetable("Hero");
Timetable lazy = c.createTimetable("Lazy");
c.deleteTimetable("Hero");
c.deleteTimetable("Hero");
TimetableItem item = lazy.addItem(DayOfWeek.MONDAY, DayOfWeek.FRIDAY, LocalTime.parse("13:37"), LocalTime.parse("20:35:37"));
item.setFrom(DayOfWeek.THURSDAY);
c.addResourceType("Student");
c.addResourceType("Professor");
// Nothing should happen
c.addResourceType("Student");
c.removeResourceType("Student");
ResourceType student = c.addResourceType("Student");
student.setName("True Hero");
student.setDefaultTimeUnit(TimeUnit.MINUTES);
student.setDefaultQuantity(100);
student.setDefaultCost(12.50);
student.addInstance("Anton");
student.addInstance("Bert");
student.getInstance("Anton").setCost(50);
student.removeInstance("Bert");
ResourceType prof = c.getResourceType("Professor");
prof.setDefaultQuantity(1);
prof.setDefaultCost(41.14);
prof.setDefaultTimeUnit(TimeUnit.HOURS);
c.validate();
//
try {
writer = new FileWriter("testFile.xml");
XMLOutputter outputter = new XMLOutputter();
outputter.setFormat(Format.getPrettyFormat());
outputter.output(c.getDoc(), writer);
outputter.output(c.getDoc(), System.out);
// writer.close();
} catch (IOException e) {
e.printStackTrace();
}
Element r = null;
try {
Document doc;
SAXBuilder builder = new SAXBuilder();
doc = builder.build("./samples/p2_normal.bpmn");
r = doc.getRootElement();
} catch (JDOMException | IOException e1) {
e1.printStackTrace();
}
SimulationConfigurationCreator s = new SimulationConfigurationCreator();
s.setId("This is the id");
// s.setProcessRef("Process_2");
s.setProcessInstances(10);
s.setStartDateTime(ZonedDateTime.parse("2017-07-06T09:00:00.000+02:00"));
s.setEndDateTime(ZonedDateTime.parse("2017-07-12T09:00:00.000+02:00"));
s.setRandomSeed(1337);
try {
s.setModel(r, false);
} catch (NoProcessSpecifiedException | NotAuthorizedToOverrideException e1) {
e1.printStackTrace();
}
Distribution testDistribution = Distribution.create(DistributionType.BINOMIAL);
testDistribution.setAttribute("amount", 5);
testDistribution.setAttribute(0, 0.2);
s.getStartEvent().setArrivalRateDistribution(testDistribution);
Task t = (Task) s.getElement("Task_1tvvo6w");
t.setDurationDistribution(Distribution.create(DistributionType.CONSTANT));
t.getDurationDistribution().setAttribute("constantValue", 100);
t.assignResource(student).setAmount(5);
t.assignResource(prof).setAmount(5);
t.getResource("Student").setAmount(13);
t.deassignResource(prof.getId());
t.getResource(student.getId()).setAssignmentPriority(5);
t.assignResource(prof).setAmount(5);
t.getResource("Professor").setAssignmentPriority(0);
t.getResource(prof.getId()).removeAssignmentDefinition();
t.deassignResource(prof.getId());
for (ElementLink element : s.getElements()) {
if (!(element instanceof Task))
continue;
Task task = (Task) element;
Distribution d = Distribution.create(DistributionType.TRIANGULAR);
d.setAttribute(0, 11);
d.setAttribute(2, 33);
d.setAttribute("peak", 22);
task.setDurationDistribution(d);
task.assignResource(prof).setAmount(3);
}
ExclusiveGateway g = null;
for (ElementLink element : s.getElements()) {
if (element instanceof ExclusiveGateway) {
g = (ExclusiveGateway) element;
break;
}
}
g.setBranchingProbability("SequenceFlow_1237oxj", 1);
for (String branch : g.getBranches()) {
System.err.println(s.getFlowTarget(branch).el.getAttributeValue("name"));
}
try {
writer = new FileWriter("testFile2.xml");
XMLOutputter outputter = new XMLOutputter();
outputter.setFormat(Format.getPrettyFormat());
outputter.output(s.getDoc(), writer);
outputter.output(s.getDoc(), System.out);
// writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.jdom2.Namespace.getNamespace in project jspwiki by apache.
the class WebContainerAuthorizer method initialize.
/**
* Initializes the authorizer for.
* @param engine the current wiki engine
* @param props the wiki engine initialization properties
*/
public void initialize(WikiEngine engine, Properties props) {
m_engine = engine;
m_containerAuthorized = false;
// FIXME: Error handling here is not very verbose
try {
m_webxml = getWebXml();
if (m_webxml != null) {
// Add the J2EE 2.4 schema namespace
m_webxml.getRootElement().setNamespace(Namespace.getNamespace(J2EE_SCHEMA_25_NAMESPACE));
m_containerAuthorized = isConstrained("/Delete.jsp", Role.ALL) && isConstrained("/Login.jsp", Role.ALL);
}
if (m_containerAuthorized) {
m_containerRoles = getRoles(m_webxml);
log.info("JSPWiki is using container-managed authentication.");
} else {
log.info("JSPWiki is using custom authentication.");
}
} catch (IOException e) {
log.error("Initialization failed: ", e);
throw new InternalWikiException(e.getClass().getName() + ": " + e.getMessage(), e);
} catch (JDOMException e) {
log.error("Malformed XML in web.xml", e);
throw new InternalWikiException(e.getClass().getName() + ": " + e.getMessage(), e);
}
if (m_containerRoles.length > 0) {
String roles = "";
for (Role containerRole : m_containerRoles) {
roles = roles + containerRole + " ";
}
log.info(" JSPWiki determined the web container manages these roles: " + roles);
}
log.info("Authorizer WebContainerAuthorizer initialized successfully.");
}
use of org.jdom2.Namespace.getNamespace in project wildfly-camel by wildfly-extras.
the class StandaloneConfigTest method testUnsupportedNamespaceVersion.
@Test
public void testUnsupportedNamespaceVersion() throws Exception {
URL resurl = StandaloneConfigTest.class.getResource("/standalone.xml");
SAXBuilder jdom = new SAXBuilder();
Document doc = jdom.build(resurl);
doc.getRootElement().getChild("extensions", NS_DOMAIN_130).setNamespace(Namespace.getNamespace("urn:jboss:domain:99.99"));
File modifiedConfig = new File("target/standalone-modified.xml");
outputDocumentContent(doc, new FileOutputStream(modifiedConfig));
jdom = new SAXBuilder();
doc = jdom.build(modifiedConfig);
ConfigContext context = ConfigSupport.createContext(null, modifiedConfig.toPath(), doc);
ConfigPlugin plugin = new WildFlyCamelConfigPlugin();
expectedException.expect(ConfigException.class);
plugin.applyStandaloneConfigChange(context, true);
}
Aggregations