List of usage examples for org.jdom2 Element getChild
public Element getChild(final String cname, final Namespace ns)
From source file:cz.muni.fi.pb138.scxml2voicexmlj.voicexml.XsltStateStackConverter.java
/** * Return the {@code <filled>} element of {@code field}. * If it didnt exists, create it first//from ww w .j a va 2 s . co m */ public Element getFilledElementAppendLazyly(Element field) { if (field.getChild("filled", NS_VXML) == null) { Element filled = new Element("filled", NS_VXML); field.addContent(filled); } return field.getChild("filled", NS_VXML); }
From source file:de.hbrs.oryx.yawl.converter.handler.oryx.OryxTaskHandler.java
License:Open Source License
/** * Code copied from YDecompositionParser.java licensed under LGPL: * //from w w w. j av a 2 s . c o m * Copyright (c) 2004-2012 The YAWL Foundation. All rights reserved. The YAWL Foundation is a collaboration of individuals and organisations who * are committed to improving workflow technology. * * @param task * @param taskElem * @param _yawlNS */ private void parseTimerParameters(final YTask task, final Element taskElem, final Namespace _yawlNS) { Element timerElem = taskElem.getChild("timer", _yawlNS); if (timerElem != null) { String netParam = timerElem.getChildText("netparam", _yawlNS); // net-level param holds values at runtime if (netParam != null) { task.setTimerParameters(netParam); } else { // 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) { task.setTimerParameters(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) { task.setTimerParameters(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); task.setTimerParameters(trigger, new Long(tickStr), interval); } } } } }
From source file:de.hbrs.oryx.yawl.converter.handler.yawl.element.AtomicTaskHandler.java
License:Open Source License
private HashMap<String, String> convertResourcing(final Element resourcingSpecs) { HashMap<String, String> properties = new HashMap<String, String>(); if (resourcingSpecs == null) { getContext().addConversionWarnings("No resourcing specification " + getNetElement().getID(), null); return properties; }//from w w w . ja v a2 s . c o m Element offer = resourcingSpecs.getChild("offer", resourcingSpecs.getNamespace()); if (offer != null) { properties.put("offerinitiator", offer.getAttributeValue("initiator")); properties.put("offerinteraction", YAWLUtils.elementToString(offer.getChildren())); } Element allocate = resourcingSpecs.getChild("allocate", resourcingSpecs.getNamespace()); if (allocate != null) { properties.put("allocateinitiator", allocate.getAttributeValue("initiator")); properties.put("allocateinteraction", YAWLUtils.elementToString(allocate.getChildren())); } Element start = resourcingSpecs.getChild("start", resourcingSpecs.getNamespace()); if (start != null) { properties.put("startinitiator", start.getAttributeValue("initiator")); properties.put("startinteraction", YAWLUtils.elementToString(start.getChildren())); } Element privileges = resourcingSpecs.getChild("privileges", resourcingSpecs.getNamespace()); if (privileges != null) { properties.put("privileges", YAWLUtils.elementToString(privileges.getChildren())); } return properties; }
From source file:de.hbrs.oryx.yawl.converter.handler.yawl.element.TaskHandler.java
License:Open Source License
/** * Converting the properties of a net.<br/> * CONTRACT: Sub-Classes have to call this method first, adding their properties afterwards. * * @param layout/*from www . ja v a2 s .c o m*/ * of the YAWL task read from layout XML * @return Oryx Property HashMap */ protected HashMap<String, String> convertTaskProperties(final NetElementLayout layout) { HashMap<String, String> properties = new HashMap<String, String>(); properties.put("yawlid", getTask().getID()); if (layout.hasJoinDecorator()) { properties.put("join", convertConnectorType(getTask().getJoinType(), layout.getJoinDecorator())); } if (layout.hasSplitDecorator()) { properties.put("split", convertConnectorType(getTask().getSplitType(), layout.getSplitDecorator())); } properties.put("name", getTask().getName()); if (getTask().getDocumentation() != null && !getTask().getDocumentation().isEmpty()) { properties.put("documentation", getTask().getDocumentation()); } try { properties.put("cancelationset", convertCancelationSet(getTask())); } catch (JSONException e) { getContext().addConversionWarnings("Could not convert Cancelation Set " + getTask().getID(), e); } try { properties.put("flowsinto", convertFlowsInto(getTask())); } catch (JSONException e) { getContext().addConversionWarnings("Could not convert Flows Into " + getTask().getID(), e); } String iconPath = layout.getIconPath(); if (iconPath != null && !iconPath.isEmpty()) { String[] splitPath = iconPath.split("/"); String filename = splitPath[splitPath.length - 1]; properties.put("icon", filename.substring(0, filename.length() - 4)); } if (getTask().getCustomFormURL() != null) { properties.put("customform", getTask().getCustomFormURL().toString()); } // The name ConfigurationElement is misleading, it contains the whole // Task XML Element configurationElement = getTask().getConfigurationElement(); if (configurationElement != null) { Element realConfigurationElement = configurationElement.getChild("configuration", configurationElement.getNamespace()); if (realConfigurationElement != null) { properties.put("configuration", YAWLUtils.elementToString(realConfigurationElement)); } } if (getTask().getTimeParameters() != null) { properties.put("timer", getTask().timerParamsToXML()); } if (hasDecomposition()) { // Only needs decomposition as lookup, does not really convert // information of the decomposition try { properties.put("inputparameters", convertInputParamMappings()); } catch (JSONException e) { getContext().addConversionWarnings("Could not convert Input Parameters " + getTask().getID(), e); } try { properties.put("outputparameters", convertOutputParamMappings()); } catch (JSONException e) { getContext().addConversionWarnings("Could not convert Output Parameters " + getTask().getID(), e); } } return properties; }
From source file:de.hbrs.oryx.yawl.converter.layout.YAWLLayoutArranger.java
License:Open Source License
private void createNet(Element yawlDecomposition) { String isRootNet = yawlDecomposition.getAttributeValue("isRootNet"); if (Boolean.parseBoolean(isRootNet)) { String id = yawlDecomposition.getAttributeValue("id"); sb.append("<net id=\"" + id + "\">"); createFakeXYWH();/*from ww w .j a v a 2 s . co m*/ Element yawlProcessControlElements = yawlDecomposition.getChild("processControlElements", yawlDecomposition.getNamespace()); if (yawlProcessControlElements != null) { createVertexesAndFlows(yawlProcessControlElements); } sb.append("</net>"); } }
From source file:de.hbrs.oryx.yawl.converter.layout.YAWLLayoutConverter.java
License:Open Source License
private void initXMLReader() throws JDOMException, IOException { SAXBuilder builder = new SAXBuilder(); Document document = builder.build(new StringReader(specificationString)); Element root = document.getRootElement(); layout = root.getChild("layout", root.getNamespace()); if (layout == null) layout = yawlLayoutArranger.arrangeLayout(root); yawlNamespace = layout.getNamespace(); setYAWLLocale(layout);//from w w w. j av a 2s. c o m }
From source file:de.hbrs.oryx.yawl.converter.layout.YAWLLayoutConverter.java
License:Open Source License
private void setYAWLLocale(final Element e) { Element eLocale = e.getChild("locale", yawlNamespace); if (eLocale != null) { String language = eLocale.getAttributeValue("language"); String country = eLocale.getAttributeValue("country"); yawlLocale = new Locale(language, country); } else {/*from w ww .j ava 2 s. c om*/ yawlLocale = Locale.getDefault(); } numberFormatter = NumberFormat.getInstance(yawlLocale); }
From source file:de.hbrs.oryx.yawl.converter.layout.YAWLLayoutConverter.java
License:Open Source License
/** * Converts the YAWL net layout bounds/* ww w .j a v a 2 s.co m*/ * * <pre> * <net id=""> * <bounds x="" y="" w="" h="" /> * <frame x="" y="" w="" h="" /> * <viewport x="" y="0" w="" h="" /> * <vertex> .. </vertex> * ... * </net> * </pre> * * @param yawlNet * @return */ private NetLayout convertNetLayout(final Element yawlNet) { String yawlId = yawlNet.getAttributeValue("id"); Element yawlBounds = yawlNet.getChild("bounds", yawlNamespace); Bounds bounds = convertToOryxBounds(fixNetBoundsElement(yawlBounds), 0.0, 0.0); NetLayout netLayout = new NetLayout(bounds); context.putNetLayout(yawlId, netLayout); return netLayout; }
From source file:de.hbrs.oryx.yawl.converter.layout.YAWLLayoutConverter.java
License:Open Source License
/** * Converts a YAWL Container, which may be a condition or a task. * // ww w . j a va2s. c o m * <pre> * <container id="XY"> * <vertex> * </vertex> * <decorator type="XYJoin"> * </decorator> * <decorator type="XYSplit"> * </decorator> * </container> * </pre> * * @param netLayout * @param yawlContainer */ private void convertContainerLayout(final NetLayout netLayout, final Element yawlContainer) { Element yawlVertex = yawlContainer.getChild("vertex", yawlNamespace); if (yawlVertex != null) { if (isCondition(yawlContainer.getAttributeValue("id"))) { convertConditionLayout(netLayout, yawlContainer, yawlVertex); } else { convertTaskLayout(netLayout, yawlContainer, yawlVertex); } } else { // Should not happen. TODO: Log warning } }
From source file:de.hbrs.oryx.yawl.converter.layout.YAWLLayoutConverter.java
License:Open Source License
/** * Converts the layout of a YAWL condition from a vertex or container element * /*from ww w . ja v a 2 s.c o m*/ * @param netLayout * @param yawlContainer * may be NULL if the condition has no label * @param yawlVertex * containing the bounds of the condition */ private void convertConditionLayout(final NetLayout netLayout, final Element yawlContainer, final Element yawlVertex) { Element yawlVertexBounds = yawlVertex.getChild("attributes", yawlNamespace).getChild("bounds", yawlNamespace); NetElementLayout layoutInformation = new NetElementLayout(true); layoutInformation.setBounds(convertToOryxBounds(yawlVertexBounds, 0.0, 0.0)); if (yawlContainer != null) { netLayout.putVertexLayout(yawlContainer.getAttributeValue("id"), layoutInformation); } else { netLayout.putVertexLayout(yawlVertex.getAttributeValue("id"), layoutInformation); } }