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.resourcing.datastore.orgdata.DataBackupEngine.java

License:Open Source License

/************************************************************************/

private String importCapabilities(Element capElem) {
    String result = "Capabilities: 0 in imported file.";
    if (capElem != null) {
        if (orgDataSet.isDataEditable("Capability")) {
            int added = 0;
            List<Element> capList = capElem.getChildren();
            for (Element cap : capList) {
                String id = cap.getAttributeValue("id");
                Capability c = orgDataSet.getCapability(id);
                if ((c == null) && (!orgDataSet.isKnownCapabilityName(cap.getChildText("name")))) {
                    c = new Capability();
                    c.reconstitute(cap);
                    orgDataSet.importCapability(c);
                    added++;/*  w w  w  .  j av a 2 s.  c  o  m*/
                }
            }
            result = String.format("Capabilities: %d/%d imported.", added, capList.size());
        } else {
            result = "Capabilities: could not import, external dataset is read-only.";
        }
    }
    return result;
}

From source file:org.yawlfoundation.yawl.resourcing.datastore.orgdata.DataBackupEngine.java

License:Open Source License

private String importNonHumanCategories(Element nhcElem) {
    String result = "NonHumanCategories: 0 in imported file.";
    if (nhcElem != null) {
        if (orgDataSet.isDataEditable("NonHumanCategory")) {
            int added = 0;
            List<Element> children = nhcElem.getChildren();
            for (Element nhc : children) {
                String id = nhc.getAttributeValue("id");
                String name = nhc.getChildText("name");
                NonHumanCategory c = orgDataSet.getNonHumanCategory(id);
                if ((c == null) && (!orgDataSet.isKnownNonHumanCategoryName(name))) {
                    c = new NonHumanCategory(name);
                    c.setID(id);/* w  ww  .  j  a  v  a 2  s.c  o  m*/
                    c.setDescription(nhc.getChildText("description"));
                    c.setNotes(nhc.getChildText("notes"));
                    for (Element eSubCat : nhc.getChild("subcategories").getChildren()) {
                        String subcat = eSubCat.getText();
                        if (!StringUtil.isNullOrEmpty(subcat)) {
                            c.addSubCategory(subcat);
                        }
                    }
                    orgDataSet.importNonHumanCategory(c);
                    added++;
                }
            }
            result = String.format("NonHumanCategories: %d/%d imported.", added, children.size());
        } else {
            result = "NonHumanCategories: could not import, external dataset is read-only.";
        }
    }
    return result;
}

From source file:org.yawlfoundation.yawl.resourcing.datastore.orgdata.DataBackupEngine.java

License:Open Source License

private String importNonHumanResources(Element nhrElem) {
    String result = "NonHumanResources: 0 in imported file.";
    if (nhrElem != null) {
        if (orgDataSet.isDataEditable("NonHumanResource")) {
            int added = 0;
            List<Element> children = nhrElem.getChildren();
            for (Element nhr : children) {
                String id = nhr.getAttributeValue("id");
                NonHumanResource r = orgDataSet.getNonHumanResource(id);
                if ((r == null) && (!orgDataSet.isKnownNonHumanResourceName(nhr.getChildText("name")))) {
                    r = new NonHumanResource(nhr);
                    String catID = nhr.getChild("category").getAttributeValue("id");
                    NonHumanCategory category = orgDataSet.getNonHumanCategory(catID);
                    if (category != null) {
                        r.setCategory(category);
                        String subcat = nhr.getChildText("subcategory");
                        if (!StringUtil.isNullOrEmpty(subcat)) {
                            r.setSubCategory(subcat);
                        }/* w ww.  j a v a2 s .  c o  m*/
                    }
                    orgDataSet.importNonHumanResource(r);
                    added++;
                }
            }
            result = String.format("NonHumanResources: %d/%d imported.", added, children.size());
        } else {
            result = "NonHumanResources: could not import, external dataset is read-only.";
        }
    }
    return result;
}

From source file:org.yawlfoundation.yawl.resourcing.datastore.orgdata.DataBackupEngine.java

License:Open Source License

private String importRoles(Element roleElem) {
    String result = "Roles: 0 in imported file.";
    if (roleElem != null) {
        if (orgDataSet.isDataEditable("Role")) {
            Hashtable<String, Role> cyclics = new Hashtable<String, Role>();
            int added = 0;
            List<Element> children = roleElem.getChildren();
            for (Element role : children) {
                String id = role.getAttributeValue("id");
                Role r = orgDataSet.getRole(id);
                if ((r == null) && (!orgDataSet.isKnownRoleName(role.getChildText("name")))) {
                    r = new Role();

                    // ensure all roles created before cyclic refs are added
                    Element belongsTo = role.getChild("belongsToID");
                    if (belongsTo != null) {
                        cyclics.put(belongsTo.getText(), r);
                    }//w ww .  j  a  v a2  s  . c o m
                    r.reconstitute(role);
                    orgDataSet.importRole(r);
                    added++;
                }
            }
            for (String id : cyclics.keySet()) {
                Role r = cyclics.get(id);
                r.setOwnerRole(orgDataSet.getRole(id));
                orgDataSet.updateRole(r);
            }
            result = String.format("Roles: %d/%d imported.", added, children.size());
        } else {
            result = "Roles: could not import, external dataset is read-only.";
        }
    }
    return result;
}

From source file:org.yawlfoundation.yawl.resourcing.datastore.orgdata.DataBackupEngine.java

License:Open Source License

private String importOrgGroups(Element ogElem) {
    String result = "OrgGroup: 0 in imported file.";
    if (ogElem != null) {
        if (orgDataSet.isDataEditable("OrgGroup")) {
            Hashtable<String, OrgGroup> cyclics = new Hashtable<String, OrgGroup>();
            int added = 0;
            List<Element> children = ogElem.getChildren();
            for (Element group : children) {
                String id = group.getAttributeValue("id");
                OrgGroup og = orgDataSet.getOrgGroup(id);
                if ((og == null) && (!orgDataSet.isKnownOrgGroupName(group.getChildText("groupName")))) {
                    og = new OrgGroup();

                    // ensure all OrgGroups created before cyclic refs are added
                    Element belongsTo = group.getChild("belongsToID");
                    if (belongsTo != null) {
                        cyclics.put(belongsTo.getText(), og);
                    }// ww  w. java  2 s. c om
                    og.reconstitute(group);
                    orgDataSet.importOrgGroup(og);
                    added++;
                }
            }
            for (String id : cyclics.keySet()) {
                OrgGroup og = cyclics.get(id);
                og.setBelongsTo(orgDataSet.getOrgGroup(id));
                orgDataSet.updateOrgGroup(og);
            }
            result = String.format("OrgGroups: %d/%d imported.", added, children.size());
        } else {
            result = "OrgGroups: could not import, external dataset is read-only.";
        }
    }
    return result;
}

From source file:org.yawlfoundation.yawl.resourcing.datastore.orgdata.DataBackupEngine.java

License:Open Source License

private String importPositions(Element posElem) {
    String result = "Positions: 0 in imported file.";
    if (posElem != null) {
        if (orgDataSet.isDataEditable("OrgGroup")) {
            Hashtable<String, Position> cyclics = new Hashtable<String, Position>();
            int added = 0;
            List<Element> children = posElem.getChildren();
            for (Element pos : children) {
                String id = pos.getAttributeValue("id");
                Position p = orgDataSet.getPosition(id);
                if ((p == null) && (!orgDataSet.isKnownPositionName(pos.getChildText("title")))) {
                    p = new Position();

                    // ensure all Positions created before cyclic refs are added
                    Element reportsTo = pos.getChild("reportstoid");
                    if (reportsTo != null) {
                        cyclics.put(reportsTo.getText(), p);
                    }//from w ww. j  a va2s.  c  o  m
                    p.reconstitute(pos);

                    Element ogElem = pos.getChild("orggroupid");
                    if (ogElem != null) {
                        p.setOrgGroup(orgDataSet.getOrgGroup(ogElem.getText()));
                    }
                    orgDataSet.importPosition(p);
                    added++;
                }
            }
            for (String id : cyclics.keySet()) {
                Position p = cyclics.get(id);
                p.setReportsTo(orgDataSet.getPosition(id));
                orgDataSet.updatePosition(p);
            }
            result = String.format("Positions: %d/%d imported.", added, children.size());
        } else {
            result = "Positions: could not import, external dataset is read-only.";
        }
    }
    return result;
}

From source file:org.yawlfoundation.yawl.resourcing.datastore.orgdata.DataBackupEngine.java

License:Open Source License

private String importParticipants(Element pElem) {
    String result = "Participants: 0 in imported file.";
    int added = 0;
    if (pElem != null) {
        if (orgDataSet.isDataEditable("Participant")) {
            List<Element> children = pElem.getChildren();
            for (Element part : children) {
                String id = part.getAttributeValue("id");
                Participant p = orgDataSet.getParticipant(id);
                if ((p == null) && (!_rm.isKnownUserID(part.getChildText("userid")))) {
                    p = new Participant();
                    p.reconstitute(part);
                    p.setPassword(part.getChildText("password"));
                    p.setDescription(part.getChildText("description"));
                    p.setNotes(part.getChildText("notes"));
                    addParticipantToResourceGroup(p, part, "roles");
                    addParticipantToResourceGroup(p, part, "positions");
                    addParticipantToResourceGroup(p, part, "capabilities");
                    p.getUserPrivileges().setPrivilegesFromBits(part.getChildText("privileges"));
                    _rm.importParticipant(p);
                    added++;//from  w  ww .j av a  2s.com
                }
            }
            result = String.format("Participants: %d/%d imported.", added, children.size());
        } else {
            result = "Positions: could not import, external dataset is read-only.";
        }
    }
    return result;
}

From source file:org.yawlfoundation.yawl.resourcing.jsf.dynform.DynFormFieldAssembler.java

License:Open Source License

private DynFormField addField(String name, String type, Element data, String minOccurs, String maxOccurs,
        int level) {
    String value = (data != null) ? data.getChildText(name) : "";
    DynFormField input = new DynFormField(name, type, value);
    populateField(input, name, minOccurs, maxOccurs, level);
    return input;
}

From source file:org.yawlfoundation.yawl.resourcing.jsf.FormViewer.java

License:Open Source License

private void adjustSessionTimeout(WorkItemRecord wir) {

    // get new timeout value (if any)
    String rawValue = null;/*from ww w .j  ava2  s  .c om*/
    Element data = wir.getDataList();
    if (data != null) {
        rawValue = data.getChildText("ySessionTimeout");
    }

    // convert to int, remember current timeout, set new timeout (as secs)
    if (rawValue != null) {
        try {
            int minutes = new Integer(rawValue);
            HttpSession session = _sb.getExternalSession();
            _sb.setDefaultSessionTimeoutValue(session.getMaxInactiveInterval());
            session.setMaxInactiveInterval(minutes * 60);
            _sb.setSessionTimeoutValueChanged(true);
        } catch (NumberFormatException nfe) {
            // bad timeout value supplied - nothing further to do
        }
    }
}

From source file:org.yawlfoundation.yawl.resourcing.resource.AbstractResourceAttribute.java

License:Open Source License

public void reconstitute(Element e) {
    setID(e.getAttributeValue("id"));
    setDescription(JDOMUtil.decodeEscapes(e.getChildText("description")));
    setNotes(JDOMUtil.decodeEscapes(e.getChildText("notes")));
}