List of usage examples for org.dom4j Element elementIterator
Iterator<Element> elementIterator(QName qName);
From source file:au.gov.ansto.bragg.process.parse.Parse.java
License:Open Source License
public static FrameworkConfiguration parseFile(Element rootElement) throws NullConfigurationPointerException, DocumentException { String frameworkName = rootElement.attributeValue("name"); FrameworkConfiguration framework = new FrameworkConfiguration_(frameworkName); // List<?> list = rootElement.selectNodes("*"); // String groupName; // int numberOfAttribute; for (Iterator<?> iter = rootElement.elementIterator("source"); iter.hasNext();) { // for (Iterator<?> iter = list.iterator(); iter.hasNext();){ Element item = (Element) iter.next(); // System.out.println(item.toString()); // groupName = item.getName().toString(); SourceConfiguration sourceConfiguration = getSourceConfiguration(item, frameworkName); framework.addSourceConfiguration(sourceConfiguration); }/* w w w . ja va 2 s. c o m*/ for (Iterator<?> iter = rootElement.elementIterator("sink"); iter.hasNext();) { Element item = (Element) iter.next(); SinkConfiguration sinkConfiguration = getSinkConfiguration(item, frameworkName); framework.addSinkConfiguration(sinkConfiguration); } for (Iterator<?> iter = rootElement.elementIterator("processor"); iter.hasNext();) { Element item = (Element) iter.next(); ProcessorConfiguration processorConfiguration = getProcessorConfiguration(item, frameworkName); framework.addProcessorConfiguration(processorConfiguration); } for (Iterator<?> iter = rootElement.elementIterator("composite_processor"); iter.hasNext();) { Element item = (Element) iter.next(); CompositeProcessorConfiguration processorConfiguration = getCompositeProcessorConfiguration(item, frameworkName); framework.addProcessorConfiguration(processorConfiguration); } for (Iterator<?> iter = rootElement.elementIterator("ins"); iter.hasNext();) { Element item = (Element) iter.next(); framework.setInConfigurationList(getInConfigurationList(item, frameworkName)); } for (Iterator<?> iter = rootElement.elementIterator("outs"); iter.hasNext();) { Element item = (Element) iter.next(); framework.setOutConfigurationList(getOutConfigurationList(item, frameworkName)); } for (Iterator<?> iter = rootElement.elementIterator("vars"); iter.hasNext();) { Element item = (Element) iter.next(); framework.setVarConfigurationList(getVarConfigurationList(item, frameworkName)); } for (Iterator<?> iter = rootElement.elementIterator("connectors"); iter.hasNext();) { Element item = (Element) iter.next(); framework.setConnectorConfigurationList(getConnectorConfigurationList(item, frameworkName)); } for (Iterator<?> iter = rootElement.elementIterator("agents"); iter.hasNext();) { Element item = (Element) iter.next(); framework.setAgentConfigurationList(getAgentConfigurationList(item)); } return framework; }
From source file:au.gov.ansto.bragg.process.parse.Parse.java
License:Open Source License
protected static CompositeProcessorConfiguration getCompositeProcessorConfiguration(final Element item, final String frameworkName) throws NullConfigurationPointerException, DocumentException { // int id = Integer.parseInt(item.attributeValue("id")); String name = item.attributeValue("name"); String classType = item.attributeValue("class"); CompositeProcessorConfiguration_ compositeProcessorConfiguration = new CompositeProcessorConfiguration_( name, frameworkName, classType); String version = item.attributeValue("version"); if (version != null) compositeProcessorConfiguration.setVersionNumber(version); else// ww w. j a v a2 s.c om compositeProcessorConfiguration.setVersionNumber("0.0.0"); // List<?> list = item.selectNodes("*"); // String groupName; // for (Iterator<?> iter = list.iterator(); iter.hasNext();){ for (Iterator<?> iter = item.elementIterator("processor"); iter.hasNext();) { Element subItem = (Element) iter.next(); // System.out.println(subItem.toString()); // if (groupName == "processor"){ ProcessorConfiguration processorConfiguration = getProcessorConfiguration(subItem, name); compositeProcessorConfiguration.addProcessorConfiguration(processorConfiguration); } for (Iterator<?> iter = item.elementIterator("composite_processor"); iter.hasNext();) { Element subItem = (Element) iter.next(); CompositeProcessorConfiguration processorConfiguration = getCompositeProcessorConfiguration(subItem, name); compositeProcessorConfiguration.addProcessorConfiguration(processorConfiguration); } for (Iterator<?> iter = item.elementIterator("ins"); iter.hasNext();) { Element subItem = (Element) iter.next(); compositeProcessorConfiguration.setInConfigurationList(getInConfigurationList(subItem, name)); } for (Iterator<?> iter = item.elementIterator("outs"); iter.hasNext();) { Element subItem = (Element) iter.next(); compositeProcessorConfiguration.setOutConfigurationList(getOutConfigurationList(subItem, name)); } for (Iterator<?> iter = item.elementIterator("vars"); iter.hasNext();) { Element subItem = (Element) iter.next(); compositeProcessorConfiguration.setVarConfigurationList(getVarConfigurationList(subItem, name)); } for (Iterator<?> iter = item.elementIterator("connectors"); iter.hasNext();) { Element subItem = (Element) iter.next(); compositeProcessorConfiguration .setConnectorConfigurationList(getConnectorConfigurationList(subItem, name)); } return compositeProcessorConfiguration; }
From source file:au.gov.ansto.bragg.process.parse.Parse.java
License:Open Source License
protected static SourceConfiguration getSourceConfiguration(final Element item, final String parentName) throws DocumentException { SourceConfiguration configuration = new SourceConfiguration_(item.attributeValue("name"), parentName, item.attributeValue("class"), item.attributeValue("method")); // List<?> subList = item.selectNodes("*"); // String portsName = null; List<InConfiguration> inConfigurationList = new LinkedList<InConfiguration>(); List<OutConfiguration> outConfigurationList = new LinkedList<OutConfiguration>(); List<VarConfiguration> varConfigurationList = new LinkedList<VarConfiguration>(); // for (Iterator<?> subIter = subList.iterator(); subIter.hasNext();){ for (Iterator<?> iter = item.elementIterator("ins"); iter.hasNext();) { Element subItem = (Element) iter.next(); // portsName = subItem.getName().toString(); inConfigurationList = getInConfigurationList(subItem, configuration.getName()); }// www.j a v a 2s . c o m for (Iterator<?> iter = item.elementIterator("outs"); iter.hasNext();) { Element subItem = (Element) iter.next(); outConfigurationList = getOutConfigurationList(subItem, configuration.getName()); } for (Iterator<?> iter = item.elementIterator("vars"); iter.hasNext();) { Element subItem = (Element) iter.next(); varConfigurationList = getVarConfigurationList(subItem, configuration.getName()); } configuration.setInConfigurationList(inConfigurationList); configuration.setOutConfigurationList(outConfigurationList); configuration.setVarConfigurationList(varConfigurationList); // System.out.println(configuration.toString()); return configuration; }
From source file:au.gov.ansto.bragg.process.parse.Parse.java
License:Open Source License
protected static SinkConfiguration getSinkConfiguration(final Element item, final String parentName) throws DocumentException { String name = item.attributeValue("name"); String autoPlot = item.attributeValue("autoplot"); String isDefaultSink = item.attributeValue("defaultsink"); SinkConfiguration configuration = new SinkConfiguration_(name, parentName, autoPlot, isDefaultSink); // List<?> subList = item.selectNodes("*"); // String portsName = null; List<InConfiguration> inConfigurationList = new LinkedList<InConfiguration>(); List<OutConfiguration> outConfigurationList = new LinkedList<OutConfiguration>(); List<VarConfiguration> varConfigurationList = new LinkedList<VarConfiguration>(); // for (Iterator<?> subIter = subList.iterator(); subIter.hasNext();){ for (Iterator<?> iter = item.elementIterator("ins"); iter.hasNext();) { Element subItem = (Element) iter.next(); // portsName = subItem.getName().toString(); inConfigurationList = getInConfigurationList(subItem, name); }/*from w w w. ja va2 s . c o m*/ for (Iterator<?> iter = item.elementIterator("outs"); iter.hasNext();) { Element subItem = (Element) iter.next(); outConfigurationList = getOutConfigurationList(subItem, name); } for (Iterator<?> iter = item.elementIterator("vars"); iter.hasNext();) { Element subItem = (Element) iter.next(); varConfigurationList = getVarConfigurationList(subItem, name); } configuration.setInConfigurationList(inConfigurationList); configuration.setOutConfigurationList(outConfigurationList); configuration.setVarConfigurationList(varConfigurationList); // System.out.println(configuration.toString()); return configuration; }
From source file:au.gov.ansto.bragg.process.parse.Parse.java
License:Open Source License
protected static ProcessorConfiguration getProcessorConfiguration(final Element item, final String parentName) throws DocumentException { String name = item.attributeValue("name"); ProcessorConfiguration configuration = new ProcessorConfiguration_(name, parentName, item.attributeValue("class"), item.attributeValue("method")); String version = item.attributeValue("version"); if (version != null) configuration.setVersionNumber(version); else//from w ww . j av a2s . c om configuration.setVersionNumber("0.0.0"); // List<?> subList = item.selectNodes("*"); // String portsName = null; List<InConfiguration> inConfigurationList = new LinkedList<InConfiguration>(); List<OutConfiguration> outConfigurationList = new LinkedList<OutConfiguration>(); List<VarConfiguration> varConfigurationList = new LinkedList<VarConfiguration>(); // for (Iterator<?> subIter = subList.iterator(); subIter.hasNext();){ for (Iterator<?> iter = item.elementIterator("ins"); iter.hasNext();) { Element subItem = (Element) iter.next(); // portsName = subItem.getName().toString(); inConfigurationList = getInConfigurationList(subItem, name); } for (Iterator<?> iter = item.elementIterator("outs"); iter.hasNext();) { Element subItem = (Element) iter.next(); outConfigurationList = getOutConfigurationList(subItem, name); } for (Iterator<?> iter = item.elementIterator("vars"); iter.hasNext();) { Element subItem = (Element) iter.next(); varConfigurationList = getVarConfigurationList(subItem, name); } configuration.setInConfigurationList(inConfigurationList); configuration.setOutConfigurationList(outConfigurationList); configuration.setVarConfigurationList(varConfigurationList); // System.out.println(configuration.toString()); return configuration; }
From source file:batch.core.om.Instance.java
License:Open Source License
/** Creates a test instance from a spec meta file. */ public Instance(URL baseUrl, Element instance) throws IOException { this(new URL(baseUrl, instance.attributeValue("href"))); Iterator itr = instance.elementIterator("property"); while (itr.hasNext()) { Element p = (Element) itr.next(); properties.put(p.attributeValue("name"), p.elementText("value")); }// ww w .ja v a 2s . c o m }
From source file:batch.performance.PerformanceTestDescriptor.java
License:Open Source License
/** * @param metaFile/*from w ww . java2s . c o m*/ * @throws Exception */ public PerformanceTestDescriptor(File metaFile) throws Exception { super(metaFile); Element testSpec = Util.loadXML(metaFile).getRootElement(); List configs = new ArrayList(); for (Iterator itr = testSpec.elementIterator("performance"); itr.hasNext();) { Element performance = (Element) itr.next(); // load scenario Scenario scenario = createScenario(metaFile, performance); // load profiler Profiler profiler; if (performance.attributeValue("profiler").equals("memory")) profiler = Profiler.MEMORY; else profiler = Profiler.SPEED; // associated with instance? if (performance.attributeValue("run", "---").equals("once")) { // no configs.add(new Config(scenario, profiler, null)); } else { // yes for (int i = 0; i < instances.length; i++) configs.add(new Config(scenario, profiler, instances[i])); } } this.configs = (Config[]) configs.toArray(new Config[configs.size()]); }
From source file:batch.qa.QATestDescriptor.java
License:Open Source License
public QATestDescriptor(File metaFile) throws Exception { super(metaFile); Document doc = Util.loadXML(metaFile); Element testSpec = doc.getRootElement(); List runOnce = new ArrayList(); List normal = new ArrayList(); {// run sciprts with "run='once'" attribute. Iterator jtr = testSpec.elementIterator("script"); while (jtr.hasNext()) { Element script = (Element) jtr.next(); URL url = new URL(testSpecUrl, script.attributeValue("href")); Script s = new Script(url); if ("once".equals(script.attributeValue("run"))) { runOnce.add(s);/* ww w.j a va 2 s . c o m*/ } else { normal.add(s); } } } this.runOnceScripts = (Script[]) runOnce.toArray(new Script[runOnce.size()]); this.perInstanceScripts = (Script[]) normal.toArray(new Script[normal.size()]); if (perInstanceScripts.length != 0 && instances.length == 0) throw new IllegalArgumentException(metaFile + " has per-instance scripts but no instance"); // this might simply mean that the test is written for something other than QA. // if( perInstanceScripts.length==0 && instances.length!=0 ) // throw new IllegalArgumentException(metaFile+" has instances but no per-instance script"); }
From source file:be.mxs.common.util.pdf.general.dossierCreators.StaffDossierPDFCreator.java
private void addSalaryDetails(PdfPTable table, Salary salary) { PdfPTable detailsTable = new PdfPTable(10); detailsTable.setWidthPercentage(100); //*** XML 1 - benefits (multi-add) ************************** if (salary.benefits.length() > 0) { detailsTable.addCell(createSubtitleCell(getTran("web.hr", "benefits"), 10)); // header detailsTable.addCell(createHeaderCell(getTran("web.hr", "beginDate"), 1)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "endDate"), 1)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "period"), 2)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "type"), 3)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "amount"), 3)); try {/*from www . j a v a 2 s. co m*/ // parse benefits from xml SAXReader reader = new SAXReader(false); org.dom4j.Document document = reader.read(new StringReader(salary.benefits)); org.dom4j.Element benefitsElem = document.getRootElement(); if (benefitsElem != null) { String sTmpBegin, sTmpEnd, sTmpPeriod, sTmpType, sTmpAmount; org.dom4j.Element benefitElem; Iterator benefitsIter = benefitsElem.elementIterator("Benefit"); while (benefitsIter.hasNext()) { benefitElem = (org.dom4j.Element) benefitsIter.next(); sTmpBegin = checkString(benefitElem.elementText("Begin")); sTmpEnd = checkString(benefitElem.elementText("End")); sTmpPeriod = checkString(benefitElem.elementText("Period")); sTmpType = checkString(benefitElem.elementText("Type")); sTmpAmount = checkString(benefitElem.elementText("Amount")); // one benefit detailsTable.addCell(createValueCell(sTmpBegin, 1)); detailsTable.addCell(createValueCell(sTmpEnd, 1)); detailsTable.addCell(createValueCell(getTran("hr.salary.period", sTmpPeriod), 2)); detailsTable.addCell(createValueCell(getTran("hr.salary.benefit.type", sTmpType), 3)); cell = createValueCell( sTmpAmount + " " + MedwanQuery.getInstance().getConfigParam("currency", ""), 3); cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); detailsTable.addCell(cell); } } } catch (Exception e) { Debug.printStackTrace(e); } } //*** XML 2 - bonuses (multi-add) ************************** if (salary.bonuses.length() > 0) { table.addCell(createSubtitleCell(getTran("web.hr", "bonuses"), 10)); // header detailsTable.addCell(createHeaderCell(getTran("web.hr", "beginDate"), 1)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "endDate"), 1)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "period"), 2)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "type"), 2)); detailsTable.addCell(createHeaderCell(getTran("web", "percentage"), 2)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "amount"), 2)); try { // parse bonuses from xml SAXReader reader = new SAXReader(false); org.dom4j.Document document = reader.read(new StringReader(salary.bonuses)); org.dom4j.Element bonusesElem = document.getRootElement(); if (bonusesElem != null) { String sTmpBegin, sTmpEnd, sTmpPeriod, sTmpType, sTmpPercentage, sTmpAmount; org.dom4j.Element bonusElem; Iterator bonusesIter = bonusesElem.elementIterator("Bonus"); while (bonusesIter.hasNext()) { bonusElem = (org.dom4j.Element) bonusesIter.next(); sTmpBegin = checkString(bonusElem.elementText("Begin")); sTmpEnd = checkString(bonusElem.elementText("End")); sTmpPeriod = checkString(bonusElem.elementText("Period")); sTmpType = checkString(bonusElem.elementText("Type")); sTmpPercentage = checkString(bonusElem.elementText("Percentage")); sTmpAmount = checkString(bonusElem.elementText("Amount")); // one record detailsTable.addCell(createValueCell(sTmpBegin, 1)); detailsTable.addCell(createValueCell(sTmpEnd, 1)); detailsTable.addCell(createValueCell(sTmpPeriod, 2)); detailsTable.addCell(createValueCell(sTmpType, 2)); detailsTable.addCell(createValueCell(sTmpPercentage + "%", 2)); cell = createValueCell( sTmpAmount + " " + MedwanQuery.getInstance().getConfigParam("currency", ""), 2); cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); detailsTable.addCell(cell); } } } catch (Exception e) { Debug.printStackTrace(e); } } //*** XML 3 - otherIncome (multi-add) *********************** if (salary.otherIncome.length() > 0) { table.addCell(createSubtitleCell(getTran("web.hr", "otherIncome"), 10)); // header detailsTable.addCell(createHeaderCell(getTran("web.hr", "beginDate"), 1)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "endDate"), 1)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "period"), 2)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "type"), 3)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "amount"), 3)); try { // parse otherIncome from xml SAXReader reader = new SAXReader(false); org.dom4j.Document document = reader.read(new StringReader(salary.otherIncome)); org.dom4j.Element benefitsElem = document.getRootElement(); if (benefitsElem != null) { String sTmpBegin, sTmpEnd, sTmpPeriod, sTmpType, sTmpAmount; org.dom4j.Element otherIncomeElem; Iterator otherIncomesIter = benefitsElem.elementIterator("OtherIncome"); while (otherIncomesIter.hasNext()) { otherIncomeElem = (org.dom4j.Element) otherIncomesIter.next(); sTmpBegin = checkString(otherIncomeElem.elementText("Begin")); sTmpEnd = checkString(otherIncomeElem.elementText("End")); sTmpPeriod = checkString(otherIncomeElem.elementText("Period")); sTmpType = checkString(otherIncomeElem.elementText("Type")); sTmpAmount = checkString(otherIncomeElem.elementText("Amount")); // one record detailsTable.addCell(createValueCell(sTmpBegin, 1)); detailsTable.addCell(createValueCell(sTmpEnd, 1)); detailsTable.addCell(createValueCell(sTmpPeriod, 2)); detailsTable.addCell(createValueCell(sTmpType, 3)); cell = createValueCell( sTmpAmount + " " + MedwanQuery.getInstance().getConfigParam("currency", ""), 3); cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); detailsTable.addCell(cell); } } } catch (Exception e) { Debug.printStackTrace(e); } } //*** XML 4 - deductions (multi-add) ************************ if (salary.deductions.length() > 0) { detailsTable.addCell(createSubtitleCell(getTran("web.hr", "deductions"), 10)); // header detailsTable.addCell(createHeaderCell(getTran("web.hr", "beginDate"), 1)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "endDate"), 1)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "period"), 2)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "type"), 3)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "amount"), 3)); try { // parse deductions from xml SAXReader reader = new SAXReader(false); org.dom4j.Document document = reader.read(new StringReader(salary.deductions)); org.dom4j.Element deductionsElem = document.getRootElement(); if (deductionsElem != null) { String sTmpBegin, sTmpEnd, sTmpPeriod, sTmpType, sTmpAmount; org.dom4j.Element deductionElem; Iterator deductionsIter = deductionsElem.elementIterator("Deduction"); while (deductionsIter.hasNext()) { deductionElem = (org.dom4j.Element) deductionsIter.next(); sTmpBegin = checkString(deductionElem.elementText("Begin")); sTmpEnd = checkString(deductionElem.elementText("End")); sTmpPeriod = checkString(deductionElem.elementText("Period")); sTmpType = checkString(deductionElem.elementText("Type")); sTmpAmount = checkString(deductionElem.elementText("Amount")); // one record detailsTable.addCell(createValueCell(sTmpBegin, 1)); detailsTable.addCell(createValueCell(sTmpEnd, 1)); detailsTable.addCell(createValueCell(sTmpPeriod, 2)); detailsTable.addCell(createValueCell(sTmpType, 3)); cell = createValueCell( sTmpAmount + " " + MedwanQuery.getInstance().getConfigParam("currency", ""), 3); cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); detailsTable.addCell(cell); } } } catch (Exception e) { Debug.printStackTrace(e); } } if (detailsTable.size() > 0) { table.addCell(emptyCell(3)); cell = createCell(new PdfPCell(detailsTable), table.getNumberOfColumns() - 3, PdfPCell.ALIGN_CENTER, PdfPCell.BOX); cell.setPadding(2); table.addCell(cell); } }
From source file:be.mxs.common.util.pdf.general.dossierCreators.StaffDossierPDFCreator.java
private String parseWeekschedule(org.dom4j.Element weekSchedule) { String sConcatValue = ""; if (weekSchedule != null) { org.dom4j.Element timeBlocks = weekSchedule.element("TimeBlocks"); if (timeBlocks != null) { Iterator timeBlockIter = timeBlocks.elementIterator("TimeBlock"); String sTmpDayIdx, sTmpBeginHour, sTmpEndHour, sTmpDuration; org.dom4j.Element timeBlock; while (timeBlockIter.hasNext()) { timeBlock = (org.dom4j.Element) timeBlockIter.next(); sTmpDayIdx = checkString(timeBlock.elementText("DayIdx")); sTmpBeginHour = checkString(timeBlock.elementText("BeginHour")); sTmpEndHour = checkString(timeBlock.elementText("EndHour")); sTmpDuration = checkString(timeBlock.elementText("Duration")); sConcatValue += sTmpDayIdx + "|" + sTmpBeginHour + "|" + sTmpEndHour + "|" + sTmpDuration + "$"; }// w ww . jav a2 s. c o m } } return sConcatValue; }