Example usage for org.jdom2 Element getChildText

List of usage examples for org.jdom2 Element getChildText

Introduction

In this page you can find the example usage for org.jdom2 Element getChildText.

Prototype

public String getChildText(final String cname) 

Source Link

Document

Returns the textual content of the named child element, or null if there's no such child.

Usage

From source file:org.yawlfoundation.yawl.worklet.rdrutil.RdrConditionFunctions.java

License:Open Source License

private static String isNotCompleted(String itemInfo) {
    Element eItem = JDOMUtil.stringToElement(itemInfo);
    String status = eItem.getChildText("status");
    return String.valueOf(!isFinishedStatus(status));
}

From source file:org.yawlfoundation.yawl.worklet.rdrutil.RdrConditionFunctions.java

License:Open Source License

private static String hasTimerExpired(String itemInfo) {
    Element eItem = JDOMUtil.stringToElement(itemInfo);
    return String.valueOf((eItem.getChildText("timerexpiry") != null));
}

From source file:org.yawlfoundation.yawl.worklet.support.RdrConversionTools.java

License:Open Source License

/**
 * Builds an RdrNode from its JDOM Element representation
 * @param e - the Element represerntation of the RdrNode
 * @param tree - the tree that this node will become a member of
 * @return - the reconstructed RdrNode/*from  w  w  w.j  a v  a2s.  c om*/
 */
public static RdrNode xmlStringToNode(Element e, RdrTree tree) {
    int id = Integer.parseInt(e.getChildText("id"));
    int parent = Integer.parseInt(e.getChildText("parent"));
    int tID = Integer.parseInt(e.getChildText("trueChild"));
    int fID = Integer.parseInt(e.getChildText("falseChild"));
    String condition = e.getChildText("condition");
    Element conclusion = e.getChild("conclusion");
    Element cornerstone = e.getChild("cornerstone");

    RdrNode pNode = tree.getNode(parent);
    RdrNode tNode = tree.getNode(tID);
    RdrNode fNode = tree.getNode(fID);

    return new RdrNode(id, pNode, tNode, fNode, condition, conclusion, cornerstone);
}

From source file:org.yawlfoundation.yawl.worklet.support.RdrConversionTools.java

License:Open Source License

/** returns the String value of a child of the xml string passed */
public static String getChildValue(String xmlStr, String child) {
    Element e = JDOMUtil.stringToElement(xmlStr); // reform as Element
    if (e != null)
        return e.getChildText(child);
    else//from  w ww.  j  a v a 2s  . com
        return "null";
}

From source file:org.yawlfoundation.yawl.worklet.WorkletService.java

License:Open Source License

/**
 * writes a summary of substitution outcomes for MI tasks to log
 *///w ww .  j a  v  a2 s  .  c  o  m
private void logSelectionForMISummary(WorkItemRecord wir, int itemCount, int workletCount) {
    Element taskInfo = JDOMUtil.stringToElement(getMITaskInfo(wir));
    if (taskInfo != null) {
        String min = taskInfo.getChildText("minimum");
        String max = taskInfo.getChildText("maximum");
        String threshold = taskInfo.getChildText("threshold");

        _log.info("Summary result of worklet selections for multi-instance task {}:", wir.getTaskID());
        _log.info("   Task attributes: Minimum - {}, Maximum - {}, Threshold - {}", min, max, threshold);
        _log.info("   WorkItems created by engine: {}", itemCount);
        _log.info("   Worklets launched: {}", workletCount);
    }
}

From source file:org.yawlfoundation.yawl.wsif.WSIFController.java

License:Open Source License

/**
 * Implements InterfaceBWebsideController.  It receives messages from the engine
 * notifying an enabled task and acts accordingly.  In this case it takes the message,
 * tries to check out the work item, and if successful it begins to start up a web service
 * invocation.//from   w w w.j a va 2  s  .  c om
 * @param enabledWorkItem
 */
public void handleEnabledWorkItemEvent(WorkItemRecord enabledWorkItem) {
    try {
        if (!checkConnection(_sessionHandle)) {
            _sessionHandle = connect(engineLogonName, engineLogonPassword);
        }
        if (successful(_sessionHandle)) {
            List<WorkItemRecord> executingChildren = checkOutAllInstancesOfThisTask(enabledWorkItem,
                    _sessionHandle);
            for (WorkItemRecord itemRecord : executingChildren) {
                Element inputData = itemRecord.getDataList();
                String wsdlLocation = inputData.getChildText(WSDL_LOCATION_PARAMNAME);
                String portName = inputData.getChildText(WSDL_PORTNAME_PARAMNAME);
                String operationName = inputData.getChildText(WSDL_OPERATIONNAME_PARAMNAME);

                Element webServiceArgsData = inputData.clone();
                webServiceArgsData.removeChild(WSDL_LOCATION_PARAMNAME);
                webServiceArgsData.removeChild(WSDL_PORTNAME_PARAMNAME);
                webServiceArgsData.removeChild(WSDL_OPERATIONNAME_PARAMNAME);

                Map replyFromWebServiceBeingInvoked = WSIFInvoker.invokeMethod(wsdlLocation, portName,
                        operationName, webServiceArgsData, getAuthenticationConfig());

                _log.warn("\n\nReply from Web service being invoked is : {}", replyFromWebServiceBeingInvoked);

                Element caseDataBoundForEngine = prepareReplyRootElement(enabledWorkItem, _sessionHandle);
                Map<String, String> outputDataTypes = getOutputDataTypes(enabledWorkItem);

                for (Object o : replyFromWebServiceBeingInvoked.keySet()) {
                    String varName = (String) o;
                    Object replyMsg = replyFromWebServiceBeingInvoked.get(varName);
                    System.out.println("replyMsg class = " + replyMsg.getClass().getName());
                    String varVal = replyMsg.toString();
                    String varType = outputDataTypes.get(varName);
                    if ((varType != null) && (!varType.endsWith("string"))) {
                        varVal = validateValue(varType, varVal);
                    }
                    Element content = new Element(varName);
                    content.setText(varVal);
                    caseDataBoundForEngine.addContent(content);
                }

                _logger.debug("\nResult of item [" + itemRecord.getID() + "] checkin is : " + checkInWorkItem(
                        itemRecord.getID(), inputData, caseDataBoundForEngine, null, _sessionHandle));
            }
        }

    } catch (Throwable e) {
        _logger.error(e.getMessage(), e);
    }
}

From source file:OSFFMIDM.SimpleIDM.java

License:Apache License

private void init(String file) {
    Element params;
    try {//w  w  w .j a va2 s.com
        parser = new ParserXML(new File(file));
        params = parser.getRootElement().getChild("SimpleIDMParams");
        mdbIp = params.getChildText("serverip");
        //dbName= params.getChildText("dbname"); Removed 
        identityDBname = params.getChildText("IdentityDBname");
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:parcelhub.utilities.ParcelXMLFileReader.java

License:Open Source License

/**
 * Reads the XML file `this.filePath` and creates an ArrayList of String
 * arrays, each containing the complete information of a Parcel.
 *//*w ww.  ja va2 s .  c om*/
private void readFile() {
    try {
        File database = new File(this.filePath);

        SAXBuilder builder = new SAXBuilder();

        Document document = builder.build(database);
        Element parcelsElement = document.getRootElement();
        List<Element> parcelList = parcelsElement.getChildren();
        for (int i = 0; i < parcelList.size(); i++) {
            Element parcel = parcelList.get(i);
            String[] info = new String[] { parcel.getChildText("parcelID"), parcel.getChildText("name"),
                    parcel.getChildText("address"), parcel.getChildText("city"), parcel.getChildText("state"),
                    parcel.getChildText("zip"), parcel.getChildText("date") };
            this.parcelInfo.add(info);
        }
    } catch (JDOMException | IOException e) {
        e.printStackTrace();
    }
}

From source file:persistence.xml.ImportarBandasOperadorasXML.java

private void importar1() throws JDOMException, IOException {
    Document d = new SAXBuilder().build(arquivo1);
    Element root = d.getRootElement();
    elementosXml1 = root.getChildren();/*  www .  j av  a 2s.  c  om*/
    for (Element e : elementosXml1) {
        String nome = e.getChildText("operadora");
        String[] ddd = e.getChildText("ddd").split(" ");
        String[] banda = e.getChildText("banda").split(" ");
        this.operadoras.add(new Operadora(nome, ddd, banda));
    }
}

From source file:persistence.xml.ImportarBandasOperadorasXML.java

private void importar2() throws JDOMException, IOException {
    Document d = new SAXBuilder().build(arquivo2);
    Element root = d.getRootElement();
    elementosXml2 = root.getChildren();/*from  ww w.j  a  va2s .  c  o m*/
    for (Element e : elementosXml2) {
        String nome = e.getChildText("operadora");
        String[] ddd = e.getChildText("ddd").split(" ");
        int inicio = Integer.valueOf(e.getChildText("bandaInicial"));
        int fim = Integer.valueOf(e.getChildText("bandaFinal"));
        String[] banda = gerarBanda(inicio, fim);
        this.operadoras.add(new Operadora(nome, ddd, banda));
    }
}