List of usage examples for org.jdom2 Element removeContent
@Override public Content removeContent(final int index)
From source file:org.yawlfoundation.yawl.scheduling.resource.ResourceServiceInterface.java
License:Open Source License
public Map<String, List<Element>> removeReservations(Document rup, String statusToBe) throws JDOMException { Map<String, List<Element>> res = new HashMap<String, List<Element>>(); String where = statusToBe == null ? "" : "[" + XML_STATUSTOBE + "='" + statusToBe + "']"; String xpath = XMLUtils.getXPATH_ActivityElement(null, XML_RESERVATION + where, null); List<Element> reservations = XMLUtils.getXMLObjects(rup, xpath); for (Element reservation : reservations) { Element activity = reservation.getParentElement(); activity.removeContent(reservation); List<Element> l = res.get(activity.getChildText(XML_ACTIVITYNAME)); if (l == null) l = new ArrayList<Element>(); Element reservationId = reservation.getChild(XML_RESERVATIONID); if (reservationId == null) { reservation.addContent(new Element(XML_RESERVATIONID)); } else {//from w w w .j a v a 2 s. c o m reservationId.setText(""); } l.add(reservation); res.put(activity.getChildText(XML_ACTIVITYNAME), l); } return res; }
From source file:scrum.server.ScrumEntityfilePreparator.java
License:Open Source License
private void prepareSprint(File file) throws IOException { boolean modified = false; Document doc;/*from w w w . java 2s. co m*/ try { doc = new SAXBuilder().build(file); } catch (JDOMException ex) { throw new RuntimeException(ex); } Element eSprint = doc.getRootElement(); Element eCompletedRequirementLabels = eSprint.getChild("completedRequirementLabels"); if (eCompletedRequirementLabels != null) { eSprint.removeContent(eCompletedRequirementLabels); modified = true; } if (modified) save(doc, file); }
From source file:scrum.server.ScrumEntityfilePreparator.java
License:Open Source License
private void prepareProjectUserConfig(File file) throws IOException { boolean modified = false; Document doc;// w w w . j av a2s . c o m try { doc = new SAXBuilder().build(file); } catch (JDOMException ex) { throw new RuntimeException(ex); } Element root = doc.getRootElement(); Element ids = root.getChild("selectedEntitysIds"); if (ids != null) { root.removeContent(ids); modified = true; } if (modified) save(doc, file); }
From source file:scrum.server.ScrumEntityfilePreparator.java
License:Open Source License
/** * use as template, don't modify//from www .j a va 2 s. c o m */ private void prepare_template_(File file) throws IOException { if (true) throw new RuntimeException("remove this line"); boolean modified = false; Document doc; try { doc = new SAXBuilder().build(file); } catch (JDOMException ex) { throw new RuntimeException(ex); } Element root = doc.getRootElement(); Element principalDescription = root.getChild("principalDescription"); if (principalDescription != null) { root.removeContent(principalDescription); modified = true; } if (modified) save(doc, file); }
From source file:se.miun.itm.input.model.design.Design.java
License:Open Source License
private Value<?> createElement(Element obsoleteE, Element root) throws InPUTException { Param<?> param;// w w w . j a v a2s. c o m String id; // retrieve param id id = obsoleteE.getAttributeValue(Q.ID_ATTR); // retrieve meta information about the parameter param = ps.getParam(id); // create the new entry if (param == null) { throw new InPUTException( "There is no parameter with id '" + id + "' in design space '" + ps.getId() + "'."); } Value<?> newE = ValueFactory.constructElementByElement(obsoleteE, param, param.getDimensions(), elementCache); // reset the obsolete entry { root.removeContent(obsoleteE); root.addContent(newE); } return newE; }
From source file:se.miun.itm.input.model.design.Design.java
License:Open Source License
void addElement(String paramId, Value<?> valueE) throws InPUTException { Element parent = retrieveParent(paramId); // remove old element parent.removeContent(elementCache.get(paramId)); if (valueE != null) { valueE.getParam().checkIfParameterSettable(paramId); // add new element parent.addContent(valueE);//from w w w . j a va 2s . c o m valueE.renewId(); } // update index updateElementCache(paramId, valueE); }
From source file:se.miun.itm.input.model.param.Param.java
License:Open Source License
private void initFromOriginal(Element original) { // init attributes setNamespace(original.getNamespace()); setName(original.getName());/* w ww . j ava 2 s. com*/ Attribute attr; for (Object content : original.getAttributes()) { attr = (Attribute) content; setAttribute(attr.getName(), attr.getValue()); } // move children Element childE; Object[] children = original.getChildren().toArray(); for (Object child : children) { childE = (Element) child; original.removeContent(childE); addContent(childE); } // attach to parent Element parent = original.getParentElement(); parent.removeContent(original); parent.addContent(this); }
From source file:se.miun.itm.input.model.param.ParamStore.java
License:Open Source License
private void preprocessTreeForTypes() throws InPUTException { Element root = spaceTree.getRootElement(); List<Element> params = root.getChildren(); String typeId;//ww w.j av a 2 s . co m Element param; while (params.size() > 0) { param = params.get(0); if (!param.getName().equals(Q.SCHOICE_TYPE)) break; typeId = param.getAttributeValue(Q.ID_ATTR); initTypeChoices(root, param, typeId); initTypeParams(root, param, typeId); root.removeContent(params.get(0)); } }
From source file:se.miun.itm.input.model.param.ParamStore.java
License:Open Source License
private void initElementByType(String referentType, Element referent, Element type) { Element newChoice = type.clone(); String localId = referent.getAttributeValue(Q.ID_ATTR); addAlias(referent, type);/*w w w . ja v a 2s. c om*/ newChoice.setAttribute(Q.ID_ATTR, localId); newChoice.setName(referentType); overrideSubElementsIfExist(referent, newChoice); Element parent = referent.getParentElement(); parent.removeContent(referent); parent.addContent(newChoice); }
From source file:se.miun.itm.input.model.param.ParamStore.java
License:Open Source License
private void overrideSubElementsIfExist(Element referent, Element typeElement) { Element overriden;/*w w w. ja v a 2 s . c om*/ Element[] children = referent.getChildren().toArray(new Element[] {}); for (Element introduced : children) { overriden = getIfHasSuchChild(typeElement, introduced); if (overriden != null) typeElement.removeContent(overriden); referent.removeContent(introduced); typeElement.addContent(introduced); } }