List of usage examples for org.dom4j Element addElement
Element addElement(String name);
Element
node with the given name to this branch and returns a reference to the new node. From source file:com.nokia.helium.internaldata.ant.listener.XMLRenderer.java
License:Open Source License
/** * Generating target only for TargetNode type of node * @param node/* w ww. j ava 2 s. c om*/ * @param targets */ protected void createTarget(DataNode node, Element targets) { if (node instanceof TargetNode) { TargetNode targetNode = (TargetNode) node; if (!targetList.contains(targetNode.getName() + targetNode.getFilename())) { targetList.add(targetNode.getName() + targetNode.getFilename()); Element target = targets.addElement("target"); target.addAttribute("id", "target@" + targetList.indexOf(targetNode.getName() + targetNode.getFilename())); target.addAttribute("name", targetNode.getName()); target.addAttribute("file", targetNode.getFilename()); target.addAttribute("line", "" + targetNode.getLine()); } } for (Iterator<DataNode> i = node.iterator(); i.hasNext();) { createTarget(i.next(), targets); } }
From source file:com.nokia.helium.internaldata.ant.listener.XMLRenderer.java
License:Open Source License
/** * Creating the targets section.// w ww. jav a 2s. c om * @param statistics */ protected void createTargets(Element statistics) { Element targets = statistics.addElement("targets"); if (root != null) { createTarget(root, targets); } }
From source file:com.nokia.helium.internaldata.ant.listener.XMLRenderer.java
License:Open Source License
/** * Creating the assert section.//from w w w. j av a 2 s . co m * @param statistics */ protected void createAsserts(Element statistics) { Element asserts = statistics.addElement("asserts"); if (root != null) { createAssert(root, asserts); } }
From source file:com.nokia.helium.internaldata.ant.listener.XMLRenderer.java
License:Open Source License
/** * Generating assert only for TargetNode type of node * @param node//from w ww .j ava 2s . co m * @param targets */ protected void createAssert(DataNode node, Element targets) { if (node instanceof AssertNode) { AssertNode assertNode = (AssertNode) node; if (assertNode.getAssertName() != null) { assertList.add(assertNode.getAssertName()); Element target = targets.addElement("assert"); target.addAttribute("id", "assert@" + assertList.indexOf(assertNode.getAssertName())); target.addAttribute("name", assertNode.getAssertName()); target.addAttribute("file", assertNode.getFilename()); target.addAttribute("line", "" + assertNode.getLine()); target.addAttribute("message", "" + assertNode.getMessage()); } } for (Iterator<DataNode> i = node.iterator(); i.hasNext();) { createAssert(i.next(), targets); } }
From source file:com.nokia.helium.internaldata.ant.listener.XMLRenderer.java
License:Open Source License
/** * Creating execution tree recursively, visiting the DataNodes. * @param node//from w ww. jav a 2 s . co m * @param tree */ protected void createTree(DataNode node, Element tree) { Element elt = null; if (node instanceof BuildNode) { BuildNode buildNode = (BuildNode) node; elt = tree.addElement("build"); elt.addAttribute("name", buildNode.getName()); elt.addAttribute("startTime", "" + buildNode.getStartTime().getTime()); elt.addAttribute("endTime", "" + buildNode.getEndTime().getTime()); elt.addAttribute("status", buildNode.getSuccessful() ? "successful" : "failed"); elt.addAttribute("thread", "" + buildNode.getThreadId()); } else if (node instanceof TargetNode) { TargetNode targetNode = (TargetNode) node; elt = tree.addElement("targetRef"); elt.addAttribute("reference", "target@" + targetList.indexOf(targetNode.getName() + targetNode.getFilename())); elt.addAttribute("startTime", "" + targetNode.getStartTime().getTime()); elt.addAttribute("endTime", "" + targetNode.getEndTime().getTime()); elt.addAttribute("thread", "" + targetNode.getThreadId()); elt.addAttribute("startUsedHeap", "" + targetNode.getStartUsedHeap()); elt.addAttribute("startCommittedHeap", "" + targetNode.getStartCommittedHeap()); elt.addAttribute("endUsedHeap", "" + targetNode.getEndUsedHeap()); elt.addAttribute("endCommittedHeap", "" + targetNode.getEndCommittedHeap()); } else if (node instanceof AssertNode) { AssertNode assertNode = (AssertNode) node; if (assertNode.getAssertName() != null) { elt = tree.addElement("assertRef"); elt.addAttribute("reference", "assert@" + assertList.indexOf(assertNode.getAssertName())); elt.addAttribute("startTime", "" + assertNode.getStartTime().getTime()); elt.addAttribute("endTime", "" + assertNode.getEndTime().getTime()); elt.addAttribute("thread", "" + assertNode.getThreadId()); } } if (elt != null) { for (Iterator<DataNode> i = node.iterator(); i.hasNext();) { createTree(i.next(), elt); } } }
From source file:com.nokia.helium.internaldata.ant.listener.XMLRenderer.java
License:Open Source License
/** * Creating the execution tree section./* w w w . j a v a 2 s.c o m*/ * @param statistics */ protected void createExecutionTree(Element statistics) { Element executionTree = statistics.addElement("executionTree"); if (root != null) { createTree(root, executionTree); } }
From source file:com.nokia.helium.internaldata.ant.listener.XMLRenderer.java
License:Open Source License
/** * Creating the property section.//from ww w.ja va2 s . c o m * @param statistics */ protected void createProperties(Element statistics) { Element propertiesElt = statistics.addElement("properties"); if (properties != null) { for (Enumeration<String> propertyEnum = properties.keys(); propertyEnum.hasMoreElements();) { String key = propertyEnum.nextElement(); Element propertyElt = propertiesElt.addElement("property"); propertyElt.addAttribute("name", key); propertyElt.addAttribute("value", properties.get(key)); } } }
From source file:com.nokia.helium.internaldata.ant.listener.XMLRenderer.java
License:Open Source License
protected void insertDatabase(Element statistics) { if (database != null) { Element databaseElt = statistics.addElement("database"); databaseElt.add(database.getRootElement().detach()); }//from ww w . j av a2s . c om }
From source file:com.noterik.bart.fs.action.CollectionIndexAction.java
License:Open Source License
private void makeTypeFromCollection(Map<String, Object> collectionDetails) { typeDocument.clearContent();//from w w w. ja v a2 s .co m Element fsxml = typeDocument.addElement("fsxml"); Element type = fsxml.addElement(indexSaveType); //add refer to original collection Element referCollectionPresentation = type.addElement("collectionrefer"); referCollectionPresentation.addAttribute("id", "1"); referCollectionPresentation.addAttribute("referid", (String) collectionDetails.get("collectionUri")); Element properties = type.addElement("properties"); //add standard properties properties.addElement("collection").addText((String) collectionDetails.get("collectionUri")); //add user configured properties Map<String, String> items = userConfigMemory.get(domainid + ":" + userid); for (String item : items.keySet()) { if (item.equals("collectiontitle") || item.equals("collectiondescription") || item.equals("collectionstatus")) { properties.addElement(item).addText((String) collectionDetails.get(item)); } } long timestamp = new Date().getTime(); type.addAttribute("id", String.valueOf(timestamp)); // Add directly to fs so maggie get's updated with first content faster FSXMLRequestHandler.instance().saveFsXml(indexUri, typeDocument.asXML(), "PUT", true); }
From source file:com.noterik.bart.fs.action.CollectionIndexAction.java
License:Open Source License
private void makeType(Element typeContent, Map<String, Object> collectionDetails) { // create new type typeDocument.clearContent();//from ww w .j ava 2 s. c o m Element fsxml = typeDocument.addElement("fsxml"); Element type = fsxml.addElement(indexSaveType); // add refer to original collection Element referCollectionPresentation = type.addElement("collectionrefer"); referCollectionPresentation.addAttribute("id", "1"); referCollectionPresentation.addAttribute("referid", (String) collectionDetails.get("collectionUri")); Element properties = type.addElement("properties"); //add standard properties properties.addElement("collection").addText((String) collectionDetails.get("collectionUri")); //add user configured properties Map<String, String> items = userConfigMemory.get(domainid + ":" + userid); for (String item : items.keySet()) { if (item.equals("collectiontitle") || item.equals("collectiondescription") || item.equals("collectionstatus")) { properties.addElement(item).addText((String) collectionDetails.get(item)); } } long timestamp = new Date().getTime(); type.addAttribute("id", String.valueOf(timestamp)); logger.debug("about to PUT to uri " + indexUri + " this xml: " + typeDocument.asXML()); // Add directly to fs so maggie get's updated with first content faster FSXMLRequestHandler.instance().saveFsXml(indexUri, typeDocument.asXML(), "PUT", true); }