List of usage examples for org.jdom2 Element getChildText
public String getChildText(final String cname, final Namespace ns)
From source file:org.yawlfoundation.yawl.resourcing.interactions.OfferInteraction.java
License:Open Source License
private void parseDynParams(Element e, Namespace nsYawl) { // ... and input parameters for (Element eParam : e.getChildren("param", nsYawl)) { String name = eParam.getChildText("name", nsYawl); String refers = eParam.getChildText("refers", nsYawl); int pType = refers.equals("role") ? ROLE_PARAM : USER_PARAM; addInputParam(name, pType);//from w ww.jav a 2 s . c o m } }
From source file:org.yawlfoundation.yawl.resourcing.interactions.OfferInteraction.java
License:Open Source License
private void parseFilters(Element e, Namespace nsYawl) throws ResourceParseException { // get the Filters Element eFilters = e.getChild("filters", nsYawl); if (eFilters != null) { List<Element> filters = eFilters.getChildren("filter", nsYawl); if (filters == null) throw new ResourceParseException("No filter elements found in filters element"); for (Element eFilter : filters) { String filterClassName = eFilter.getChildText("name", nsYawl); if (filterClassName != null) { AbstractFilter filter = PluginFactory.newFilterInstance(filterClassName); if (filter != null) { filter.setParams(parseParams(eFilter, nsYawl)); _filters.add(filter); } else throw new ResourceParseException("Unknown filter name: " + filterClassName); } else throw new ResourceParseException("Missing filter element: name"); }/*from w ww .j a va2s . co m*/ } }
From source file:org.yawlfoundation.yawl.resourcing.interactions.OfferInteraction.java
License:Open Source License
private void parseConstraints(Element e, Namespace nsYawl) throws ResourceParseException { // get the Constraints Element eConstraints = e.getChild("constraints", nsYawl); if (eConstraints != null) { List<Element> constraints = eConstraints.getChildren("constraint", nsYawl); if (constraints == null) throw new ResourceParseException("No constraint elements found in constraints element"); for (Element eConstraint : constraints) { String constraintClassName = eConstraint.getChildText("name", nsYawl); if (constraintClassName != null) { AbstractConstraint constraint = PluginFactory.newConstraintInstance(constraintClassName); if (constraint != null) { constraint.setParams(parseParams(eConstraint, nsYawl)); _constraints.add(constraint); } else throw new ResourceParseException("Unknown constraint name: " + constraintClassName); } else throw new ResourceParseException("Missing constraint element: name"); }//from ww w . j a v a 2 s . c om } }
From source file:org.yawlfoundation.yawl.resourcing.TaskPrivileges.java
License:Open Source License
/** * Parses the xml element passed into a set of privileges and who has them * * @param e the element containing the privileges from the spec xml *//*from ww w. j a va2s .c o m*/ public void parse(Element e, Namespace nsYawl) { if (e != null) { List<Element> ePrivileges = e.getChildren("privilege", nsYawl); // if no privileges element to deal with, we're done if (ePrivileges == null) return; for (Element ePrivilege : ePrivileges) { // get the privilege set we're referring to String privName = ePrivilege.getChildText("name", nsYawl); int priv = getPrivilegeType(privName); HashSet<Participant> privSet = getPrivSet(privName); // are all allowed? String allowall = ePrivilege.getChildText("allowall", nsYawl); if (allowall != null) { if (allowall.equalsIgnoreCase("true")) allowAll(priv); else disallowAll(priv); } // get the set of participant and/or role tags for this privilege Element eSet = ePrivilege.getChild("set", nsYawl); if (eSet == null) continue; for (Element eResource : eSet.getChildren()) { // if it's a 'role' child, unpack it to a set of participants ... if (eResource.getName().equals("role")) { String rid = eResource.getText(); Set<Participant> pSet = ResourceManager.getInstance().getOrgDataSet() .getRoleParticipants(rid); addSet(privSet, pSet); // remember that this set was added as a role addRoleToPrivilegeUnchecked(rid, priv); } // ... otherwise add the participant to the privilege else add(privSet, eResource.getText()); } } } }
From source file:org.yawlfoundation.yawl.unmarshal.YDecompositionParser.java
License:Open Source License
private void parseDecompositionRoles(YDecomposition decomposition, Element decompElem) { String name = decompElem.getChildText("name", _yawlNS); if (name != null) { decomposition.setName(name);// w w w. ja v a 2 s . c o m } String documentation = decompElem.getChildText("documentation", _yawlNS); if (documentation != null) { decomposition.setDocumentation(documentation); } List<Element> inputParamElems = decompElem.getChildren("inputParam", _yawlNS); for (int i = 0; i < inputParamElems.size(); i++) { YParameter yparameter = new YParameter(_decomposition, YParameter._INPUT_PARAM_TYPE); yparameter.setOrdering(i); parseParameter(inputParamElems.get(i), yparameter, _yawlNS, isBeta2Version()); decomposition.addInputParameter(yparameter); } List<Element> outputParamElems = decompElem.getChildren("outputParam", _yawlNS); for (int i = 0; i < outputParamElems.size(); i++) { YParameter yparameter = new YParameter(_decomposition, YParameter._OUTPUT_PARAM_TYPE); yparameter.setOrdering(i); parseParameter(outputParamElems.get(i), yparameter, _yawlNS, isBeta2Version()); decomposition.addOutputParameter(yparameter); } for (Element outputExpressionElem : decompElem.getChildren("outputExpression", _yawlNS)) { String outputExpressionText = outputExpressionElem.getAttributeValue("query"); decomposition.setOutputExpression(outputExpressionText); } markEmptyComplexTypeVariables(decomposition); }
From source file:org.yawlfoundation.yawl.unmarshal.YDecompositionParser.java
License:Open Source License
private void parseExternalTaskRoles(Element externalTaskElem, YTask externalTask) { _removeSetIDs.put(externalTask, parseRemoveSet(externalTaskElem)); _removeSetForFlows.put(externalTask, parseRemoveSetFromFlow(externalTaskElem)); _postsetIDs.add(externalTask.getID(), parsePostset(externalTaskElem)); Element startingMappings = externalTaskElem.getChild("startingMappings", _yawlNS); if (startingMappings != null) { externalTask.setDataMappingsForTaskStarting(parseMappings(startingMappings, true)); }/*from w ww . ja v a 2s. c o m*/ Element completedMappings = externalTaskElem.getChild("completedMappings", _yawlNS); if (completedMappings != null) { externalTask.setDataMappingsForTaskCompletion(parseMappings(completedMappings, false)); } Element enablementMappings = externalTaskElem.getChild("enablementMappings", _yawlNS); if (enablementMappings != null && externalTask instanceof YAtomicTask) { ((YAtomicTask) externalTask).setDataMappingsForEnablement(parseMappings(enablementMappings, true)); } String taskType = externalTaskElem.getAttributeValue("type", externalTaskElem.getNamespace("xsi")); if ("MultipleInstanceExternalTaskFactsType".equals(taskType)) { externalTask.setUpMultipleInstanceAttributes(externalTaskElem.getChildText("minimum", _yawlNS), externalTaskElem.getChildText("maximum", _yawlNS), externalTaskElem.getChildText("threshold", _yawlNS), externalTaskElem.getChild("creationMode", _yawlNS).getAttributeValue("code")); String expression = externalTaskElem.getChild("miDataInput", _yawlNS).getChild("expression", _yawlNS) .getAttributeValue("query"); String processingExpressionForInput = externalTaskElem.getChild("miDataInput", _yawlNS) .getChild("splittingExpression", _yawlNS).getAttributeValue("query"); String remoteVarName = externalTaskElem.getChild("miDataInput", _yawlNS) .getChildText("formalInputParam", _yawlNS); externalTask.setDataBindingForInputParam(expression, remoteVarName); externalTask.setMultiInstanceInputDataMappings(remoteVarName, processingExpressionForInput); Element miDataOutputElem = externalTaskElem.getChild("miDataOutput", _yawlNS); if (miDataOutputElem != null) { String remoteExpressionName = miDataOutputElem.getChild("formalOutputExpression", _yawlNS) .getAttributeValue("query"); String aggregationQuery = miDataOutputElem.getChild("outputJoiningExpression", _yawlNS) .getAttributeValue("query"); String localVarName = miDataOutputElem.getChildText("resultAppliedToLocalVariable", _yawlNS); externalTask.setDataBindingForOutputExpression(remoteExpressionName, localVarName); externalTask.setMultiInstanceOutputDataMappings(remoteExpressionName, aggregationQuery); } } }
From source file:org.yawlfoundation.yawl.unmarshal.YDecompositionParser.java
License:Open Source License
private Map<String, String> parseMappings(Element mappingsElem, boolean isStartMappings) { Map<String, String> map = new TreeMap<String, String>(); for (Element mapping : mappingsElem.getChildren()) { String expression = mapping.getChild("expression", _yawlNS).getAttributeValue("query"); String varOrParam = mapping.getChildText("mapsTo", _yawlNS); if (isStartMappings) { map.put(varOrParam, expression); } else {// w w w. j a v a 2 s . co m map.put(expression, varOrParam); } } return map; }
From source file:org.yawlfoundation.yawl.unmarshal.YDecompositionParser.java
License:Open Source License
private void parseNameAndDocumentation(YExternalNetElement element, Element netElementElem) { String name = netElementElem.getChildText("name", _yawlNS); if (name == null && (element instanceof YTask)) { String id = netElementElem.getAttributeValue("id"); name = stripEngineID(id);/*from w w w.j a va2s . c om*/ } element.setName(name); String documentation = netElementElem.getChildText("documentation", _yawlNS); element.setDocumentation(documentation); }
From source file:org.yawlfoundation.yawl.unmarshal.YDecompositionParser.java
License:Open Source License
private void parseCustomFormURL(YTask task, Element taskElem) { String formStr = taskElem.getChildText("customForm", _yawlNS); if (formStr != null) { try {/*from ww w . j a v a2 s. co m*/ URL formURI = new URL(formStr); task.setCustomFormURI(formURI); } catch (MalformedURLException use) { LogManager.getLogger(this.getClass()) .error("Invalid custom form URL in specification for task {}: {}" + ". Custom form URL will be ignored.", task.getID(), formStr); } } }
From source file:org.yawlfoundation.yawl.unmarshal.YDecompositionParser.java
License:Open Source License
private void parseTimerParameters(YTask task, Element taskElem) { Element timerElem = taskElem.getChild("timer", _yawlNS); if (timerElem != null) { YTimerParameters timerParameters = new YTimerParameters(); String netParam = timerElem.getChildText("netparam", _yawlNS); // net-level param holds values at runtime if (netParam != null) { timerParameters.set(netParam); } else {//w ww . ja v a 2 s . co m // get the triggering event String triggerStr = timerElem.getChildText("trigger", _yawlNS); YWorkItemTimer.Trigger trigger = YWorkItemTimer.Trigger.valueOf(triggerStr); // expiry is a stringified long value representing a specific datetime String expiry = timerElem.getChildText("expiry", _yawlNS); if (expiry != null) timerParameters.set(trigger, new Date(new Long(expiry))); else { // duration type - specified as a Duration? String durationStr = timerElem.getChildText("duration", _yawlNS); if (durationStr != null) { Duration duration = StringUtil.strToDuration(durationStr); if (duration != null) { timerParameters.set(trigger, duration); } } else { // ticks / interval durationparams type Element durationElem = timerElem.getChild("durationparams", _yawlNS); String tickStr = durationElem.getChildText("ticks", _yawlNS); String intervalStr = durationElem.getChildText("interval", _yawlNS); YTimer.TimeUnit interval = YTimer.TimeUnit.valueOf(intervalStr); timerParameters.set(trigger, new Long(tickStr), interval); } } } task.setTimerParameters(timerParameters); } }