List of usage examples for org.dom4j Document 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:edu.ku.brc.specify.tasks.services.CollectingEventLocalityKMLGenerator.java
License:Open Source License
/** * Write the KML out to a file./*w w w. ja va 2 s. c o m*/ * * @param filename the name of the output file * @throws IOException a file I/O exception occurred */ public void outputToFile(final String filename) throws IOException { Document document = DocumentHelper.createDocument(); Element root = document.addElement("kml").addAttribute("xmlns", KML_NAMESPACE_DECL); Element kmlDocument = root.addElement("Document"); if (StringUtils.isNotEmpty(description)) { kmlDocument.addElement("description").addText(description); } GenericKMLGenerator.generateStyle(kmlDocument, placemarkIconURL, balloonStyleBgColor, balloonStyleTextColor, balloonStyleText); boolean isDoingCollectingEvents = false; DataProviderSessionIFace session = null; try { session = DataProviderFactory.getInstance().createSession(); for (int i = 0; i < dataObjs.size(); ++i) { String label = labels.get(i); FormDataObjIFace dataObj = dataObjs.get(i); session.attach(dataObj); if (dataObj instanceof CollectingEvent) { generatePlacemark(kmlDocument, (CollectingEvent) dataObj, label); isDoingCollectingEvents = true; } else if (dataObj instanceof Locality) { generatePlacemark(kmlDocument, (Locality) dataObj, label); } else if (dataObj instanceof CollectionObject) { generatePlacemark(kmlDocument, (CollectionObject) dataObj, label); } } } catch (Exception ex) { ex.printStackTrace(); } finally { if (session != null) { session.close(); } } if (isDoingCollectingEvents) { /*String kmlStr = generatePathForLocalities(); if (kmlStr != null) { writer.write(kmlStr); }*/ } FileWriter out = new FileWriter(filename); OutputFormat format = OutputFormat.createPrettyPrint(); XMLWriter writer = new XMLWriter(out, format); writer.write(document); writer.close(); out.close(); }
From source file:edu.ku.brc.util.services.GenericKMLGenerator.java
License:Open Source License
/** * Generates KML output based on the current points, names and descriptions given to the generator. * /*w ww .j ava 2s.c om*/ * @return a String containing the generated KML */ public Document generateKML() { Document document = DocumentHelper.createDocument(); Element root = document.addElement("kml").addAttribute("xmlns", KML_NAMESPACE_DECL); Element kmlDocument = root.addElement("Document"); if (StringUtils.isNotEmpty(description)) { kmlDocument.addElement("description").addText(description); } // setup the custom style, if any of these are non-null generateStyle(kmlDocument, placemarkIconURL, balloonStyleBgColor, balloonStyleTextColor, balloonStyleText); // generate a placemark for each point for (Pair<Double, Double> point : points) { String name = pointNameMap.get(point); String htmlDesc = pointDescMap.get(point); buildPlacemark(kmlDocument, point, name, balloonStyleTextColor, htmlDesc, placemarkIconURL); } return document; }
From source file:edu.ucsd.library.dams.api.DAMSAPIServlet.java
public static Document toXML(Map m) { Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("response"); doc.setRootElement(root);// w w w .j av a 2s . co m Iterator keys = m.keySet().iterator(); while (keys.hasNext()) { String key = (String) keys.next(); Object val = m.get(key); Element e = root.addElement(key); if (val instanceof String) { e.setText(val.toString()); } else if (val instanceof Collection) { Collection col = (Collection) val; for (Iterator it = col.iterator(); it.hasNext();) { Object o = it.next(); Element sub = e.addElement("value"); if (o instanceof Map) { Map valmap = (Map) o; Iterator fields = valmap.keySet().iterator(); while (fields.hasNext()) { String field = (String) fields.next(); Element sub2 = sub.addElement(field); sub2.setText(valmap.get(field).toString()); } } else { sub.setText(o.toString()); } } } else if (val instanceof Map) { Map m2 = (Map) val; for (Iterator it = m2.keySet().iterator(); it.hasNext();) { String k2 = (String) it.next(); String v2 = (String) m2.get(k2); Element sub = e.addElement("value"); sub.addAttribute("key", k2); sub.setText(v2); } } else if (val instanceof Exception) { Exception ex = (Exception) val; e.addElement("p").setText(ex.toString()); StackTraceElement[] elem = ex.getStackTrace(); for (int i = 0; i < elem.length; i++) { e.addElement("p").setText(elem[i].toString()); } } else { e.setText(String.valueOf(val)); } } return doc; }
From source file:edu.ucsd.library.dams.api.DAMSAPIServlet.java
public static String toHTML(Map m) { Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("html"); doc.setRootElement(root);//from w w w . j a va 2 s . c o m Element body = root.addElement("body"); Element table = body.addElement("table"); Iterator keys = m.keySet().iterator(); while (keys.hasNext()) { String key = (String) keys.next(); Object val = m.get(key); Element row = table.addElement("tr"); Element keyCell = row.addElement("td"); keyCell.setText(key); Element valCell = row.addElement("td"); if (val instanceof String) { valCell.setText(val.toString()); } else if (val instanceof Collection) { Collection col = (Collection) val; for (Iterator it = col.iterator(); it.hasNext();) { Element p = valCell.addElement("p"); Object o = it.next(); if (o instanceof Map) { Map valmap = (Map) o; Iterator fields = valmap.keySet().iterator(); while (fields.hasNext()) { String field = (String) fields.next(); String value = (String) valmap.get(field); p.addText(field + ": " + value); if (fields.hasNext()) { p.addElement("br"); } } } else { p.setText(o.toString()); } } } else if (val instanceof Map) { Map m2 = (Map) val; for (Iterator it = m2.keySet().iterator(); it.hasNext();) { String k2 = (String) it.next(); String v2 = (String) m2.get(k2); Element div = valCell.addElement("div"); div.setText(k2 + ": " + v2); } } else if (val instanceof Exception) { Exception ex = (Exception) val; valCell.addElement("p").setText(ex.toString()); StackTraceElement[] elem = ex.getStackTrace(); for (int i = 0; i < elem.length; i++) { valCell.addText(elem[i].toString()); valCell.addElement("br"); } } } return doc.asXML(); }
From source file:edu.upenn.cis.orchestra.workloadgenerator.GeneratorJournal.java
License:Apache License
/** * Serializes the journal in the format below. The peer and maping elements * are as in the Orchestra schema file./*w w w . j a va 2 s . c om*/ * * <pre> * <?xml version="1.0" encoding="UTF-8"?> * <!--00:50:07 06/12/08 EDT * {integers=1, inout=true, oracle=0, skip=0, cutoff=1024, password=password, addBypasses=1, deletions=1, * username=xyz, relsize=15, tukwila=0, fanout=2, olivier=1, schemas=3, dbalias=BIOTBS, insertions=2, * iterations=2, seed=0, mappingsServer=jdbc:db2://localhost:50000, bidir=0, updateAlias=null, addPeers=1, * coverage=1.0, deleteBypasses=1, maxcycles=-1, peers=3, filename=prot, mincycles=-1, deletePeers=1}--> * <deltas> * <iteration idx="0"> * <operation type="addPeer" name="P0"/> * <operation type="addPeer" name="P1"> * <mapping name="M0"/> * <mapping name="M2"/> * </operation> * <operation type="addPeer" name="P2"> * <mapping name="M1"/> * </operation> * </iteration> * <iteration idx="1"> * <operation type="addPeer" name="P3"> * <mapping name="M3"/> * </operation> * <operation type="deletePeer" name="P0"/> * </iteration> * <iteration idx="2"> * <operation type="addPeer" name="P4"> * <mapping name="M4"/> * <mapping name="M5"/> * <mapping name="M6"/> * </operation> * <operation type="deletePeer" name="P2"/> * <operation type="addBypass" name="M23"/> * <operation type="deleteBypass" name="M2"/> * </iteration> * <peer name="P0" address="localhost"> * </peer> * <mapping name="M0" materialized="true"> * </mapping> * </deltas> * * </pre> * * @param params * run parameters, see <code>Generator</code>. * @return serialzed <code>GeneratorJournal</code>. */ @SuppressWarnings("unchecked") public Document serialize(Map<String, Object> params) { // TODO: this method copies code from MetadataXml, needs refactoring. Document deltasDoc = DocumentHelper.createDocument(); deltasDoc.addComment(WorkloadGeneratorUtils.stamp() + "\n" + params); Element deltas = deltasDoc.addElement("deltas"); List<Integer> indexes = new LinkedList<Integer>(_operations.keySet()); Collections.sort(indexes); for (Integer idx : indexes) { Element iteration = deltas.addElement("iteration").addAttribute("idx", idx.toString()); List<List<String>> operations = _operations.get(idx); for (List<String> operation : operations) { Element opElement = iteration.addElement("operation").addAttribute("type", operation.get(0)) .addAttribute("name", operation.get(1)); if ("addPeer".equals(operation.get(0))) { if (null == _peersToMaps.get(operation.get(1))) { continue; } for (String mapping : _peersToMaps.get(operation.get(1))) { opElement.addElement("mapping").addAttribute("name", mapping); } } } } for (int i = 0; i < _peers.size(); i++) { Element peer = deltas.addElement("peer").addAttribute("name", "P" + i).addAttribute("address", "localhost"); int j = _peers.get(i); Element schema = peer.addElement("schema").addAttribute("name", "S" + j); for (int k = 0; k < _logicalSchemas.get(j).size(); k++) { for (String var : iovariations((Boolean) params.get("inout"))) { Element relation = schema.addElement("relation") .addAttribute("name", WorkloadGeneratorUtils.relname(i, j, k) + var) .addAttribute("materialized", "true"); if ((Double) params.get("coverage") == 1) { relation.addAttribute("noNulls", "true"); } String hasLocalData; if (Generator.peerHasLocalData(i, (Integer) params.get("topology"), (Integer) params.get("modlocal"), (Integer) params.get("peers"), (Integer) params.get("fanout"))) { hasLocalData = "true"; } else { hasLocalData = "false"; } relation.addAttribute("hasLocalData", hasLocalData); relation.addElement("dbinfo").addAttribute("schema", (String) params.get("username")) .addAttribute("table", WorkloadGeneratorUtils.relname(i, j, k) + var); relation.addElement("field").addAttribute("name", "KID").addAttribute("type", "integer") .addAttribute("key", "true"); for (String att : _logicalSchemas.get(j).get(k)) { relation.addElement("field").addAttribute("name", att).addAttribute("type", MetadataXml.universalType(att, params)); } } } } for (int k = 0; k < _mappings.size(); k++) { int i = (Integer) _mappings.get(k).get(1); int j = (Integer) _mappings.get(k).get(2); List<String> x = (List<String>) _mappings.get(k).get(3); List<String> source = MetadataXml.selectAtoms(i, "KID", x, "_", _logicalSchemas, _peers, (Boolean) params.get("addValueAttr"), true); // _ means don't care List<String> target = MetadataXml.selectAtoms(j, "KID", x, "-", _logicalSchemas, _peers, (Boolean) params.get("addValueAttr"), false); // - means null Element mapping = deltas.addElement("mapping").addAttribute("name", "M" + k) .addAttribute("materialized", "true"); if (1 == (Integer) params.get("bidir")) { mapping.addAttribute("bidirectional", "true"); } Element head = mapping.addElement("head"); for (String atom : target) { Element atomElem = head.addElement("atom"); if (1 == (Integer) params.get("bidir")) { atomElem.addAttribute("del", "true"); } atomElem.addText(atom); } Element body = mapping.addElement("body"); for (String atom : source) { Element atomElem = body.addElement("atom"); if (1 == (Integer) params.get("bidir")) { atomElem.addAttribute("del", "true"); } atomElem.addText(atom); } } return deltasDoc; }
From source file:edu.upenn.cis.orchestra.workloadgenerator.MetadataXml.java
License:Apache License
@SuppressWarnings("unchecked") public void metadataXml(List<List<List<String>>> schemas, List<Integer> peers, List<List<Object>> mappings, String extension) {/*from ww w .j a v a 2 s.c o m*/ Writer writer = null; if (null == _params.get("filename")) { writer = new PrintWriter(System.out); } else { try { if (!"".equals(extension)) { extension = "." + extension; } writer = new FileWriter((String) _params.get("filename") + extension + ".schema"); // + ".schema.new"); } catch (IOException e) { throw new IllegalStateException("Unable to create schema file.", e); } } Document document = DocumentHelper.createDocument(); document.addComment(WorkloadGeneratorUtils.stamp() + "\n" + _params); Element catalog = document.addElement("catalog").addAttribute("recMode", "false").addAttribute("name", (String) _params.get("filename")); catalog.addElement("migrated").setText("true"); for (int i = 0; i < peers.size(); i++) { if (null == peers.get(i)) { continue; } Element peer = catalog.addElement("peer").addAttribute("name", "P" + i).addAttribute("address", "localhost"); int j = peers.get(i); Element schema = peer.addElement("schema").addAttribute("name", "S" + j); for (int k = 0; k < schemas.get(j).size(); k++) { for (String var : iovariations()) { Element relation = schema.addElement("relation") .addAttribute("name", WorkloadGeneratorUtils.relname(i, j, k) + var) .addAttribute("materialized", "true"); if ((Double) _params.get("coverage") == 1) { relation.addAttribute("noNulls", "true"); } String hasLocalData; if (Generator.peerHasLocalData(i, (Integer) _params.get("topology"), (Integer) _params.get("modlocal"), (Integer) _params.get("peers"), (Integer) _params.get("fanout"))) { hasLocalData = "true"; } else { hasLocalData = "false"; } relation.addAttribute("hasLocalData", hasLocalData); relation.addElement("dbinfo").addAttribute("schema", (String) _params.get("username")) .addAttribute("table", WorkloadGeneratorUtils.relname(i, j, k) + var); relation.addElement("field").addAttribute("name", "KID").addAttribute("type", "integer") .addAttribute("key", "true"); for (String att : schemas.get(j).get(k)) { if ((Boolean) _params.get("addValueAttr") && att.equals(Relation.valueAttrName)) { relation.addElement("field").addAttribute("name", att).addAttribute("type", "integer") .addAttribute("key", "true"); } else { relation.addElement("field").addAttribute("name", att).addAttribute("type", universalType(att, _params)); } } } } } for (int k = 0; k < mappings.size(); k++) { if (null == mappings.get(k)) { continue; } int i = (Integer) mappings.get(k).get(0); int j = (Integer) mappings.get(k).get(1); List<String> x = (List<String>) mappings.get(k).get(2); List<String> source = selectAtoms(i, "KID", x, "_", schemas, peers, (Boolean) _params.get("addValueAttr"), true); // _ means don't care List<String> target = selectAtoms(j, "KID", x, "-", schemas, peers, (Boolean) _params.get("addValueAttr"), false); // - means null Element mapping = catalog.addElement("mapping").addAttribute("name", "M" + k) .addAttribute("materialized", "true"); if (1 == (Integer) _params.get("bidir")) { mapping.addAttribute("bidirectional", "true"); } Element head = mapping.addElement("head"); for (String atom : target) { Element atomElem = head.addElement("atom"); if (1 == (Integer) _params.get("bidir")) { atomElem.addAttribute("del", "true"); } atomElem.addText(atom); } Element body = mapping.addElement("body"); for (String atom : source) { Element atomElem = body.addElement("atom"); if (1 == (Integer) _params.get("bidir")) { atomElem.addAttribute("del", "true"); } atomElem.addText(atom); } } Element mappingsElem = catalog.addElement("engine").addElement("mappings"); if (1 == (Integer) _params.get("tukwila")) { mappingsElem.addAttribute("type", "tukwila").addAttribute("host", "localhost").addAttribute("port", "7777"); } else { mappingsElem.addAttribute("type", "sql") .addAttribute("server", (String) _params.get("mappingsServer") + "/" // "jdbc:db2://localhost:50000/" + _params.get("dbalias")) .addAttribute("username", (String) _params.get("username")) .addAttribute("password", (String) _params.get("password")); } if (null != _params.get("updateAlias")) { catalog.addElement("updates") .addAttribute("server", "jdbc:db2://localhost:50000/" + _params.get("updateAlias")) .addAttribute("username", (String) _params.get("username")) .addAttribute("password", (String) _params.get("password")); } // Output some default (dummy) reconciliation store info Element store = catalog.addElement("store"); store.addElement("update").addAttribute("type", "bdb").addAttribute("hostname", "localhost") .addAttribute("port", "777"); store.addElement("state").addAttribute("type", "hash"); // Output trust conditions saying that everyone trusts everyone for (int i = 0; i < peers.size(); i++) { if (null == peers.get(i)) { continue; } int j = peers.get(i); Element trustConditions = catalog.addElement("trustConditions").addAttribute("peer", "P" + i) .addAttribute("schema", "S" + j); for (int i2 = 0; i2 < peers.size(); i2++) { if (null == peers.get(i2)) { continue; } int j2 = peers.get(i2); if (i != i2) { for (int k2 = 0; k2 < schemas.get(j2).size(); k2++) { trustConditions.addElement("trusts").addAttribute("pid", "P" + i2) .addAttribute("pidType", "STRING").addAttribute("pidType", "STRING") .addAttribute("priority", "5") .addAttribute("relation", WorkloadGeneratorUtils.relname(i2, j2, k2)); } } } } try { OutputFormat format = OutputFormat.createPrettyPrint(); XMLWriter xmlWriter = new XMLWriter(writer, format); xmlWriter.write(document); writer.flush(); writer.close(); } catch (IOException e) { throw new IllegalStateException("Problem writing schema file.", e); } }
From source file:edu.vt.middleware.ldap.dsml.Dsmlv1.java
License:Open Source License
/** * This will take the results of a prior LDAP query and convert it to a DSML * <code>Document</code>./* w ww . j a v a 2s . com*/ * * @param result <code>LdapResult</code> * * @return <code>Document</code> */ public Document createDsml(final LdapResult result) { final Namespace ns = new Namespace("dsml", "http://www.dsml.org/DSML"); final Document doc = DocumentHelper.createDocument(); final Element dsmlElement = doc.addElement(new QName("dsml", ns)); final Element entriesElement = dsmlElement.addElement(new QName("directory-entries", ns)); // build document object from result if (result != null) { for (LdapEntry le : result.getEntries()) { final Element entryElement = this.createDsmlEntry(new QName("entry", ns), le, ns); entriesElement.add(entryElement); } } return doc; }
From source file:edu.vt.middleware.ldap.dsml.Dsmlv2.java
License:Open Source License
/** * This will take the results of a prior LDAP query and convert it to a DSML * <code>Document</code>./* ww w. java 2 s . com*/ * * @param result <code>LdapResult</code> * * @return <code>Document</code> */ public Document createDsml(final LdapResult result) { final Namespace ns = new Namespace("", "urn:oasis:names:tc:DSML:2:0:core"); final Document doc = DocumentHelper.createDocument(); final Element dsmlElement = doc.addElement(new QName("batchResponse", ns)); final Element entriesElement = dsmlElement.addElement(new QName("searchResponse", ns)); // build document object from results if (result != null) { for (LdapEntry le : result.getEntries()) { final Element entryElement = this.createDsmlEntry(new QName("searchResultEntry", ns), le, ns); entriesElement.add(entryElement); } } final Element doneElement = entriesElement.addElement(new QName("searchResultDone", ns)); final Element codeElement = doneElement.addElement(new QName("resultCode", ns)); codeElement.addAttribute("code", "0"); return doc; }
From source file:epa_eds.epa_prototype_0_1.EPA_Prototype.java
License:Apache License
public void tFileInputExcel_2Process(final java.util.Map<String, Object> globalMap) throws TalendException { globalMap.put("tFileInputExcel_2_SUBPROCESS_STATE", 0); final boolean execStat = this.execStat; String currentVirtualComponent = null; String iterateId = ""; String currentComponent = ""; java.util.Map<String, Object> resourceMap = new java.util.HashMap<String, Object>(); try {//from ww w. ja v a 2 s . c o m String currentMethodName = new java.lang.Exception().getStackTrace()[0].getMethodName(); boolean resumeIt = currentMethodName.equals(resumeEntryMethodName); if (resumeEntryMethodName == null || resumeIt || globalResumeTicket) {// start // the // resume globalResumeTicket = true; tFileInputExcel_1Process(globalMap); tFileInputExcel_3Process(globalMap); tFileInputExcel_4Process(globalMap); tFileInputExcel_5Process(globalMap); row1Struct row1 = new row1Struct(); row7Struct row7 = new row7Struct(); FLIGHT_OutStruct FLIGHT_Out = new FLIGHT_OutStruct(); final_outputStruct final_output = new final_outputStruct(); row11Struct row11 = new row11Struct(); /** * [tAggregateRow_2_AGGOUT begin ] start */ ok_Hash.put("tAggregateRow_2_AGGOUT", false); start_Hash.put("tAggregateRow_2_AGGOUT", System.currentTimeMillis()); currentVirtualComponent = "tAggregateRow_2"; currentComponent = "tAggregateRow_2_AGGOUT"; int tos_count_tAggregateRow_2_AGGOUT = 0; // ------------ java.util.Map hashAggreg_tAggregateRow_2 = new java.util.HashMap(); // ------------ class UtilClass_tAggregateRow_2 { // G_OutBegin_AggR_144 public double sd(Double[] data) { final int n = data.length; if (n < 2) { return Double.NaN; } double d1 = 0d; double d2 = 0d; for (int i = 0; i < data.length; i++) { d1 += (data[i] * data[i]); d2 += data[i]; } return Math.sqrt((n * d1 - d2 * d2) / n / (n - 1)); } public void checkedIADD(byte a, byte b, boolean checkTypeOverFlow, boolean checkUlp) { byte r = (byte) (a + b); if (checkTypeOverFlow && ((a ^ r) & (b ^ r)) < 0) { throw new RuntimeException(buildOverflowMessage(String.valueOf(a), String.valueOf(b), "'short/Short'", "'int/Integer'")); } } public void checkedIADD(short a, short b, boolean checkTypeOverFlow, boolean checkUlp) { short r = (short) (a + b); if (checkTypeOverFlow && ((a ^ r) & (b ^ r)) < 0) { throw new RuntimeException(buildOverflowMessage(String.valueOf(a), String.valueOf(b), "'int/Integer'", "'short/Short'")); } } public void checkedIADD(int a, int b, boolean checkTypeOverFlow, boolean checkUlp) { int r = a + b; if (checkTypeOverFlow && ((a ^ r) & (b ^ r)) < 0) { throw new RuntimeException(buildOverflowMessage(String.valueOf(a), String.valueOf(b), "'long/Long'", "'int/Integer'")); } } public void checkedIADD(long a, long b, boolean checkTypeOverFlow, boolean checkUlp) { long r = a + b; if (checkTypeOverFlow && ((a ^ r) & (b ^ r)) < 0) { throw new RuntimeException(buildOverflowMessage(String.valueOf(a), String.valueOf(b), "'BigDecimal'", "'long/Long'")); } } public void checkedIADD(float a, float b, boolean checkTypeOverFlow, boolean checkUlp) { if (checkUlp) { float minAddedValue = Math.ulp(a); if (minAddedValue > Math.abs(b)) { throw new RuntimeException(buildPrecisionMessage(String.valueOf(a), String.valueOf(b), "'double' or 'BigDecimal'", "'float/Float'")); } } if (checkTypeOverFlow && ((double) a + (double) b > (double) Float.MAX_VALUE) || ((double) a + (double) b < (double) -Float.MAX_VALUE)) { throw new RuntimeException(buildOverflowMessage(String.valueOf(a), String.valueOf(b), "'double' or 'BigDecimal'", "'float/Float'")); } } public void checkedIADD(double a, double b, boolean checkTypeOverFlow, boolean checkUlp) { if (checkUlp) { double minAddedValue = Math.ulp(a); if (minAddedValue > Math.abs(b)) { throw new RuntimeException(buildPrecisionMessage(String.valueOf(a), String.valueOf(a), "'BigDecimal'", "'double/Double'")); } } if (checkTypeOverFlow && (a + b > (double) Double.MAX_VALUE) || (a + b < -Double.MAX_VALUE)) { throw new RuntimeException(buildOverflowMessage(String.valueOf(a), String.valueOf(b), "'BigDecimal'", "'double/Double'")); } } public void checkedIADD(double a, byte b, boolean checkTypeOverFlow, boolean checkUlp) { if (checkTypeOverFlow && (a + b > (double) Double.MAX_VALUE) || (a + b < -Double.MAX_VALUE)) { throw new RuntimeException(buildOverflowMessage(String.valueOf(a), String.valueOf(b), "'BigDecimal'", "'double/Double'")); } } public void checkedIADD(double a, short b, boolean checkTypeOverFlow, boolean checkUlp) { if (checkTypeOverFlow && (a + b > (double) Double.MAX_VALUE) || (a + b < -Double.MAX_VALUE)) { throw new RuntimeException(buildOverflowMessage(String.valueOf(a), String.valueOf(b), "'BigDecimal'", "'double/Double'")); } } public void checkedIADD(double a, int b, boolean checkTypeOverFlow, boolean checkUlp) { if (checkTypeOverFlow && (a + b > (double) Double.MAX_VALUE) || (a + b < -Double.MAX_VALUE)) { throw new RuntimeException(buildOverflowMessage(String.valueOf(a), String.valueOf(b), "'BigDecimal'", "'double/Double'")); } } public void checkedIADD(double a, float b, boolean checkTypeOverFlow, boolean checkUlp) { if (checkUlp) { double minAddedValue = Math.ulp(a); if (minAddedValue > Math.abs(b)) { throw new RuntimeException(buildPrecisionMessage(String.valueOf(a), String.valueOf(a), "'BigDecimal'", "'double/Double'")); } } if (checkTypeOverFlow && (a + b > (double) Double.MAX_VALUE) || (a + b < -Double.MAX_VALUE)) { throw new RuntimeException(buildOverflowMessage(String.valueOf(a), String.valueOf(b), "'BigDecimal'", "'double/Double'")); } } private String buildOverflowMessage(String a, String b, String advicedTypes, String originalType) { return "Type overflow when adding " + b + " to " + a + ", to resolve this problem, increase the precision by using " + advicedTypes + " type in place of " + originalType + "."; } private String buildPrecisionMessage(String a, String b, String advicedTypes, String originalType) { return "The double precision is unsufficient to add the value " + b + " to " + a + ", to resolve this problem, increase the precision by using " + advicedTypes + " type in place of " + originalType + "."; } } // G_OutBegin_AggR_144 UtilClass_tAggregateRow_2 utilClass_tAggregateRow_2 = new UtilClass_tAggregateRow_2(); class AggOperationStruct_tAggregateRow_2 { // G_OutBegin_AggR_100 private static final int DEFAULT_HASHCODE = 1; private static final int PRIME = 31; private int hashCode = DEFAULT_HASHCODE; public boolean hashCodeDirty = true; Integer reporting_year; String state; BigDecimal ghg_quantity_sum; @Override public int hashCode() { if (this.hashCodeDirty) { final int prime = PRIME; int result = DEFAULT_HASHCODE; result = prime * result + ((this.reporting_year == null) ? 0 : this.reporting_year.hashCode()); result = prime * result + ((this.state == null) ? 0 : this.state.hashCode()); this.hashCode = result; this.hashCodeDirty = false; } return this.hashCode; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final AggOperationStruct_tAggregateRow_2 other = (AggOperationStruct_tAggregateRow_2) obj; if (this.reporting_year == null) { if (other.reporting_year != null) return false; } else if (!this.reporting_year.equals(other.reporting_year)) return false; if (this.state == null) { if (other.state != null) return false; } else if (!this.state.equals(other.state)) return false; return true; } } // G_OutBegin_AggR_100 AggOperationStruct_tAggregateRow_2 operation_result_tAggregateRow_2 = null; AggOperationStruct_tAggregateRow_2 operation_finder_tAggregateRow_2 = new AggOperationStruct_tAggregateRow_2(); java.util.Map<AggOperationStruct_tAggregateRow_2, AggOperationStruct_tAggregateRow_2> hash_tAggregateRow_2 = new java.util.HashMap<AggOperationStruct_tAggregateRow_2, AggOperationStruct_tAggregateRow_2>(); /** * [tAggregateRow_2_AGGOUT begin ] stop */ /** * [tFileInputExcel_2 begin ] start */ ok_Hash.put("tFileInputExcel_2", false); start_Hash.put("tFileInputExcel_2", System.currentTimeMillis()); currentComponent = "tFileInputExcel_2"; int tos_count_tFileInputExcel_2 = 0; class RegexUtil_tFileInputExcel_2 { public java.util.List<jxl.Sheet> getSheets(jxl.Workbook workbook, String oneSheetName, boolean useRegex) { java.util.List<jxl.Sheet> list = new java.util.ArrayList<jxl.Sheet>(); if (useRegex) {// this part process the regex issue jxl.Sheet[] sheets = workbook.getSheets(); java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(oneSheetName); for (int i = 0; i < sheets.length; i++) { String sheetName = sheets[i].getName(); java.util.regex.Matcher matcher = pattern.matcher(sheetName); if (matcher.matches()) { jxl.Sheet sheet = workbook.getSheet(sheetName); if (sheet != null) { list.add(sheet); } } } } else { jxl.Sheet sheet = workbook.getSheet(oneSheetName); if (sheet != null) { list.add(sheet); } } return list; } public java.util.List<jxl.Sheet> getSheets(jxl.Workbook workbook, int index, boolean useRegex) { java.util.List<jxl.Sheet> list = new java.util.ArrayList<jxl.Sheet>(); jxl.Sheet sheet = workbook.getSheet(index); if (sheet != null) { list.add(sheet); } return list; } } RegexUtil_tFileInputExcel_2 regexUtil_tFileInputExcel_2 = new RegexUtil_tFileInputExcel_2(); final jxl.WorkbookSettings workbookSettings_tFileInputExcel_2 = new jxl.WorkbookSettings(); workbookSettings_tFileInputExcel_2.setDrawingsDisabled(true); workbookSettings_tFileInputExcel_2.setEncoding("ISO-8859-15"); Object source_tFileInputExcel_2 = context.recv_dir + "/FLIGHT 2011 Power Plant Extract.xls"; final jxl.Workbook workbook_tFileInputExcel_2; java.io.InputStream toClose_tFileInputExcel_2 = null; java.io.BufferedInputStream buffIStreamtFileInputExcel_2 = null; try { if (source_tFileInputExcel_2 instanceof java.io.InputStream) { toClose_tFileInputExcel_2 = (java.io.InputStream) source_tFileInputExcel_2; buffIStreamtFileInputExcel_2 = new java.io.BufferedInputStream(toClose_tFileInputExcel_2); workbook_tFileInputExcel_2 = jxl.Workbook.getWorkbook(buffIStreamtFileInputExcel_2, workbookSettings_tFileInputExcel_2); } else if (source_tFileInputExcel_2 instanceof String) { toClose_tFileInputExcel_2 = new java.io.FileInputStream( source_tFileInputExcel_2.toString()); buffIStreamtFileInputExcel_2 = new java.io.BufferedInputStream(toClose_tFileInputExcel_2); workbook_tFileInputExcel_2 = jxl.Workbook.getWorkbook(buffIStreamtFileInputExcel_2, workbookSettings_tFileInputExcel_2); } else { workbook_tFileInputExcel_2 = null; throw new java.lang.Exception( "The data source should be specified as Inputstream or File Path!"); } } finally { try { if (buffIStreamtFileInputExcel_2 != null) { buffIStreamtFileInputExcel_2.close(); } } catch (Exception e) { } } try { java.util.List<jxl.Sheet> sheetList_tFileInputExcel_2 = new java.util.ArrayList<jxl.Sheet>(); sheetList_tFileInputExcel_2.addAll(regexUtil_tFileInputExcel_2 .getSheets(workbook_tFileInputExcel_2, "FLIGHT Facilities and GHG Quant", false)); if (sheetList_tFileInputExcel_2.size() <= 0) { throw new RuntimeException("Special sheets not exist!"); } java.util.List<jxl.Sheet> sheet_FilterNullList_tFileInputExcel_2 = new java.util.ArrayList<jxl.Sheet>(); for (jxl.Sheet sheet_FilterNull_tFileInputExcel_2 : sheetList_tFileInputExcel_2) { if (sheet_FilterNull_tFileInputExcel_2.getRows() > 0) { sheet_FilterNullList_tFileInputExcel_2.add(sheet_FilterNull_tFileInputExcel_2); } } sheetList_tFileInputExcel_2 = sheet_FilterNullList_tFileInputExcel_2; if (sheetList_tFileInputExcel_2.size() > 0) { int nb_line_tFileInputExcel_2 = 0; int begin_line_tFileInputExcel_2 = 6; int footer_input_tFileInputExcel_2 = 0; int end_line_tFileInputExcel_2 = 0; for (jxl.Sheet sheet_tFileInputExcel_2 : sheetList_tFileInputExcel_2) { end_line_tFileInputExcel_2 += sheet_tFileInputExcel_2.getRows(); } end_line_tFileInputExcel_2 -= footer_input_tFileInputExcel_2; int limit_tFileInputExcel_2 = -1; int start_column_tFileInputExcel_2 = 1 - 1; int end_column_tFileInputExcel_2 = sheetList_tFileInputExcel_2.get(0).getColumns(); jxl.Cell[] row_tFileInputExcel_2 = null; jxl.Sheet sheet_tFileInputExcel_2 = sheetList_tFileInputExcel_2.get(0); int rowCount_tFileInputExcel_2 = 0; int sheetIndex_tFileInputExcel_2 = 0; int currentRows_tFileInputExcel_2 = sheetList_tFileInputExcel_2.get(0).getRows(); // for the number format java.text.DecimalFormat df_tFileInputExcel_2 = new java.text.DecimalFormat( "#.####################################"); char separatorChar_tFileInputExcel_2 = df_tFileInputExcel_2.getDecimalFormatSymbols() .getDecimalSeparator(); for (int i_tFileInputExcel_2 = begin_line_tFileInputExcel_2; i_tFileInputExcel_2 < end_line_tFileInputExcel_2; i_tFileInputExcel_2++) { int emptyColumnCount_tFileInputExcel_2 = 0; if (limit_tFileInputExcel_2 != -1 && nb_line_tFileInputExcel_2 >= limit_tFileInputExcel_2) { break; } while (i_tFileInputExcel_2 >= rowCount_tFileInputExcel_2 + currentRows_tFileInputExcel_2) { rowCount_tFileInputExcel_2 += currentRows_tFileInputExcel_2; sheet_tFileInputExcel_2 = sheetList_tFileInputExcel_2 .get(++sheetIndex_tFileInputExcel_2); currentRows_tFileInputExcel_2 = sheet_tFileInputExcel_2.getRows(); } if (rowCount_tFileInputExcel_2 <= i_tFileInputExcel_2) { row_tFileInputExcel_2 = sheet_tFileInputExcel_2 .getRow(i_tFileInputExcel_2 - rowCount_tFileInputExcel_2); } globalMap.put("tFileInputExcel_2_CURRENT_SHEET", sheet_tFileInputExcel_2.getName()); row1 = null; int tempRowLength_tFileInputExcel_2 = 13; int columnIndex_tFileInputExcel_2 = 0; // // end%> String[] temp_row_tFileInputExcel_2 = new String[tempRowLength_tFileInputExcel_2]; int actual_end_column_tFileInputExcel_2 = end_column_tFileInputExcel_2 > row_tFileInputExcel_2.length ? row_tFileInputExcel_2.length : end_column_tFileInputExcel_2; for (int i = 0; i < tempRowLength_tFileInputExcel_2; i++) { if (i + start_column_tFileInputExcel_2 < actual_end_column_tFileInputExcel_2) { jxl.Cell cell_tFileInputExcel_2 = row_tFileInputExcel_2[i + start_column_tFileInputExcel_2]; temp_row_tFileInputExcel_2[i] = cell_tFileInputExcel_2.getContents(); } else { temp_row_tFileInputExcel_2[i] = ""; } } boolean whetherReject_tFileInputExcel_2 = false; row1 = new row1Struct(); int curColNum_tFileInputExcel_2 = -1; String curColName_tFileInputExcel_2 = ""; try { columnIndex_tFileInputExcel_2 = 0; if (temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2].length() > 0) { curColNum_tFileInputExcel_2 = columnIndex_tFileInputExcel_2 + start_column_tFileInputExcel_2 + 1; curColName_tFileInputExcel_2 = "reporting_year"; row1.reporting_year = ParserUtils.parseTo_Integer( temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2]); } else { row1.reporting_year = null; emptyColumnCount_tFileInputExcel_2++; } columnIndex_tFileInputExcel_2 = 1; if (temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2].length() > 0) { curColNum_tFileInputExcel_2 = columnIndex_tFileInputExcel_2 + start_column_tFileInputExcel_2 + 1; curColName_tFileInputExcel_2 = "facility_name"; row1.facility_name = temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2]; } else { row1.facility_name = null; emptyColumnCount_tFileInputExcel_2++; } columnIndex_tFileInputExcel_2 = 2; if (temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2].length() > 0) { curColNum_tFileInputExcel_2 = columnIndex_tFileInputExcel_2 + start_column_tFileInputExcel_2 + 1; curColName_tFileInputExcel_2 = "ghgrp_id"; row1.ghgrp_id = ParserUtils.parseTo_Integer( temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2]); } else { row1.ghgrp_id = null; emptyColumnCount_tFileInputExcel_2++; } columnIndex_tFileInputExcel_2 = 3; if (temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2].length() > 0) { curColNum_tFileInputExcel_2 = columnIndex_tFileInputExcel_2 + start_column_tFileInputExcel_2 + 1; curColName_tFileInputExcel_2 = "reported_address"; row1.reported_address = temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2]; } else { row1.reported_address = null; emptyColumnCount_tFileInputExcel_2++; } columnIndex_tFileInputExcel_2 = 4; if (temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2].length() > 0) { curColNum_tFileInputExcel_2 = columnIndex_tFileInputExcel_2 + start_column_tFileInputExcel_2 + 1; curColName_tFileInputExcel_2 = "latitude"; row1.latitude = ParserUtils.parseTo_Float( temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2]); } else { row1.latitude = null; emptyColumnCount_tFileInputExcel_2++; } columnIndex_tFileInputExcel_2 = 5; if (temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2].length() > 0) { curColNum_tFileInputExcel_2 = columnIndex_tFileInputExcel_2 + start_column_tFileInputExcel_2 + 1; curColName_tFileInputExcel_2 = "longitude"; row1.longitude = ParserUtils.parseTo_Float( temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2]); } else { row1.longitude = null; emptyColumnCount_tFileInputExcel_2++; } columnIndex_tFileInputExcel_2 = 6; if (temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2].length() > 0) { curColNum_tFileInputExcel_2 = columnIndex_tFileInputExcel_2 + start_column_tFileInputExcel_2 + 1; curColName_tFileInputExcel_2 = "city_name"; row1.city_name = temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2]; } else { row1.city_name = null; emptyColumnCount_tFileInputExcel_2++; } columnIndex_tFileInputExcel_2 = 7; if (temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2].length() > 0) { curColNum_tFileInputExcel_2 = columnIndex_tFileInputExcel_2 + start_column_tFileInputExcel_2 + 1; curColName_tFileInputExcel_2 = "county_name"; row1.county_name = temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2]; } else { row1.county_name = null; emptyColumnCount_tFileInputExcel_2++; } columnIndex_tFileInputExcel_2 = 8; if (temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2].length() > 0) { curColNum_tFileInputExcel_2 = columnIndex_tFileInputExcel_2 + start_column_tFileInputExcel_2 + 1; curColName_tFileInputExcel_2 = "state"; row1.state = temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2]; } else { row1.state = null; emptyColumnCount_tFileInputExcel_2++; } columnIndex_tFileInputExcel_2 = 9; if (temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2].length() > 0) { curColNum_tFileInputExcel_2 = columnIndex_tFileInputExcel_2 + start_column_tFileInputExcel_2 + 1; curColName_tFileInputExcel_2 = "zip"; row1.zip = temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2]; } else { row1.zip = null; emptyColumnCount_tFileInputExcel_2++; } columnIndex_tFileInputExcel_2 = 10; if (temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2].length() > 0) { curColNum_tFileInputExcel_2 = columnIndex_tFileInputExcel_2 + start_column_tFileInputExcel_2 + 1; curColName_tFileInputExcel_2 = "parent_companies"; row1.parent_companies = temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2]; } else { row1.parent_companies = null; emptyColumnCount_tFileInputExcel_2++; } columnIndex_tFileInputExcel_2 = 11; if (temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2].length() > 0) { curColNum_tFileInputExcel_2 = columnIndex_tFileInputExcel_2 + start_column_tFileInputExcel_2 + 1; curColName_tFileInputExcel_2 = "ghg_quantity"; row1.ghg_quantity = ParserUtils.parseTo_BigDecimal( temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2]); } else { row1.ghg_quantity = null; emptyColumnCount_tFileInputExcel_2++; } columnIndex_tFileInputExcel_2 = 12; if (temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2].length() > 0) { curColNum_tFileInputExcel_2 = columnIndex_tFileInputExcel_2 + start_column_tFileInputExcel_2 + 1; curColName_tFileInputExcel_2 = "sub_parts"; row1.sub_parts = temp_row_tFileInputExcel_2[columnIndex_tFileInputExcel_2]; } else { row1.sub_parts = null; emptyColumnCount_tFileInputExcel_2++; } nb_line_tFileInputExcel_2++; } catch (java.lang.Exception e) { whetherReject_tFileInputExcel_2 = true; System.err.println(e.getMessage()); row1 = null; } /** * [tFileInputExcel_2 begin ] stop */ /** * [tFileInputExcel_2 main ] start */ currentComponent = "tFileInputExcel_2"; tos_count_tFileInputExcel_2++; /** * [tFileInputExcel_2 main ] stop */ // Start of branch "row1" if (row1 != null) { /** * [tAggregateRow_2_AGGOUT main ] start */ currentVirtualComponent = "tAggregateRow_2"; currentComponent = "tAggregateRow_2_AGGOUT"; operation_finder_tAggregateRow_2.reporting_year = row1.reporting_year; operation_finder_tAggregateRow_2.state = row1.state; operation_finder_tAggregateRow_2.hashCodeDirty = true; operation_result_tAggregateRow_2 = hash_tAggregateRow_2 .get(operation_finder_tAggregateRow_2); if (operation_result_tAggregateRow_2 == null) { // G_OutMain_AggR_001 operation_result_tAggregateRow_2 = new AggOperationStruct_tAggregateRow_2(); operation_result_tAggregateRow_2.reporting_year = operation_finder_tAggregateRow_2.reporting_year; operation_result_tAggregateRow_2.state = operation_finder_tAggregateRow_2.state; hash_tAggregateRow_2.put(operation_result_tAggregateRow_2, operation_result_tAggregateRow_2); } // G_OutMain_AggR_001 if (operation_result_tAggregateRow_2.ghg_quantity_sum == null) { operation_result_tAggregateRow_2.ghg_quantity_sum = new BigDecimal(0); } operation_result_tAggregateRow_2.ghg_quantity_sum = operation_result_tAggregateRow_2.ghg_quantity_sum .add(new BigDecimal(String.valueOf(row1.ghg_quantity))); tos_count_tAggregateRow_2_AGGOUT++; /** * [tAggregateRow_2_AGGOUT main ] stop */ } // End of branch "row1" /** * [tFileInputExcel_2 end ] start */ currentComponent = "tFileInputExcel_2"; } globalMap.put("tFileInputExcel_2_NB_LINE", nb_line_tFileInputExcel_2); } } finally { if (!(source_tFileInputExcel_2 instanceof java.io.InputStream)) { workbook_tFileInputExcel_2.close(); } } ok_Hash.put("tFileInputExcel_2", true); end_Hash.put("tFileInputExcel_2", System.currentTimeMillis()); /** * [tFileInputExcel_2 end ] stop */ /** * [tAggregateRow_2_AGGOUT end ] start */ currentVirtualComponent = "tAggregateRow_2"; currentComponent = "tAggregateRow_2_AGGOUT"; ok_Hash.put("tAggregateRow_2_AGGOUT", true); end_Hash.put("tAggregateRow_2_AGGOUT", System.currentTimeMillis()); /** * [tAggregateRow_2_AGGOUT end ] stop */ /** * [tSortRow_1_SortOut begin ] start */ ok_Hash.put("tSortRow_1_SortOut", false); start_Hash.put("tSortRow_1_SortOut", System.currentTimeMillis()); currentVirtualComponent = "tSortRow_1"; currentComponent = "tSortRow_1_SortOut"; int tos_count_tSortRow_1_SortOut = 0; class Comparablefinal_outputStruct extends final_outputStruct implements Comparable<Comparablefinal_outputStruct> { public int compareTo(Comparablefinal_outputStruct other) { if (this.state == null && other.state != null) { return -1; } else if (this.state != null && other.state == null) { return 1; } else if (this.state != null && other.state != null) { if (!this.state.equals(other.state)) { return this.state.compareTo(other.state); } } return 0; } } java.util.List<Comparablefinal_outputStruct> list_tSortRow_1_SortOut = new java.util.ArrayList<Comparablefinal_outputStruct>(); /** * [tSortRow_1_SortOut begin ] stop */ /** * [tMap_2 begin ] start */ ok_Hash.put("tMap_2", false); start_Hash.put("tMap_2", System.currentTimeMillis()); currentComponent = "tMap_2"; int tos_count_tMap_2 = 0; // ############################### // # Lookup's keys initialization org.talend.designer.components.lookup.memory.AdvancedMemoryLookup<row2Struct> tHash_Lookup_row2 = (org.talend.designer.components.lookup.memory.AdvancedMemoryLookup<row2Struct>) ((org.talend.designer.components.lookup.memory.AdvancedMemoryLookup<row2Struct>) globalMap .get("tHash_Lookup_row2")); row2Struct row2HashKey = new row2Struct(); row2Struct row2Default = new row2Struct(); // ############################### // ############################### // # Vars initialization class Var__tMap_2__Struct { } Var__tMap_2__Struct Var__tMap_2 = new Var__tMap_2__Struct(); // ############################### // ############################### // # Outputs initialization final_outputStruct final_output_tmp = new final_outputStruct(); // ############################### /** * [tMap_2 begin ] stop */ /** * [tMap_1 begin ] start */ ok_Hash.put("tMap_1", false); start_Hash.put("tMap_1", System.currentTimeMillis()); currentComponent = "tMap_1"; int tos_count_tMap_1 = 0; // ############################### // # Lookup's keys initialization org.talend.designer.components.lookup.memory.AdvancedMemoryLookup<row8Struct> tHash_Lookup_row8 = (org.talend.designer.components.lookup.memory.AdvancedMemoryLookup<row8Struct>) ((org.talend.designer.components.lookup.memory.AdvancedMemoryLookup<row8Struct>) globalMap .get("tHash_Lookup_row8")); row8Struct row8HashKey = new row8Struct(); row8Struct row8Default = new row8Struct(); org.talend.designer.components.lookup.memory.AdvancedMemoryLookup<row9Struct> tHash_Lookup_row9 = (org.talend.designer.components.lookup.memory.AdvancedMemoryLookup<row9Struct>) ((org.talend.designer.components.lookup.memory.AdvancedMemoryLookup<row9Struct>) globalMap .get("tHash_Lookup_row9")); row9Struct row9HashKey = new row9Struct(); row9Struct row9Default = new row9Struct(); org.talend.designer.components.lookup.memory.AdvancedMemoryLookup<row10Struct> tHash_Lookup_row10 = (org.talend.designer.components.lookup.memory.AdvancedMemoryLookup<row10Struct>) ((org.talend.designer.components.lookup.memory.AdvancedMemoryLookup<row10Struct>) globalMap .get("tHash_Lookup_row10")); row10Struct row10HashKey = new row10Struct(); row10Struct row10Default = new row10Struct(); // ############################### // ############################### // # Vars initialization class Var__tMap_1__Struct { } Var__tMap_1__Struct Var__tMap_1 = new Var__tMap_1__Struct(); // ############################### // ############################### // # Outputs initialization FLIGHT_OutStruct FLIGHT_Out_tmp = new FLIGHT_OutStruct(); // ############################### /** * [tMap_1 begin ] stop */ /** * [tAggregateRow_2_AGGIN begin ] start */ ok_Hash.put("tAggregateRow_2_AGGIN", false); start_Hash.put("tAggregateRow_2_AGGIN", System.currentTimeMillis()); currentVirtualComponent = "tAggregateRow_2"; currentComponent = "tAggregateRow_2_AGGIN"; int tos_count_tAggregateRow_2_AGGIN = 0; java.util.Collection<AggOperationStruct_tAggregateRow_2> values_tAggregateRow_2 = hash_tAggregateRow_2 .values(); globalMap.put("tAggregateRow_2_NB_LINE", values_tAggregateRow_2.size()); for (AggOperationStruct_tAggregateRow_2 aggregated_row_tAggregateRow_2 : values_tAggregateRow_2) { // G_AggR_600 /** * [tAggregateRow_2_AGGIN begin ] stop */ /** * [tAggregateRow_2_AGGIN main ] start */ currentVirtualComponent = "tAggregateRow_2"; currentComponent = "tAggregateRow_2_AGGIN"; row7.reporting_year = aggregated_row_tAggregateRow_2.reporting_year; row7.state = aggregated_row_tAggregateRow_2.state; row7.ghg_quantity = aggregated_row_tAggregateRow_2.ghg_quantity_sum; tos_count_tAggregateRow_2_AGGIN++; /** * [tAggregateRow_2_AGGIN main ] stop */ /** * [tMap_1 main ] start */ currentComponent = "tMap_1"; boolean hasCasePrimitiveKeyWithNull_tMap_1 = false; // ############################### // # Input tables (lookups) boolean rejectedInnerJoin_tMap_1 = false; boolean mainRowRejected_tMap_1 = false; // ///////////////////////////////////////////// // Starting Lookup Table "row8" // ///////////////////////////////////////////// boolean forceLooprow8 = false; row8Struct row8ObjectFromLookup = null; if (!rejectedInnerJoin_tMap_1) { // G_TM_M_020 hasCasePrimitiveKeyWithNull_tMap_1 = false; row8HashKey.state = row7.state; row8HashKey.hashCodeDirty = true; tHash_Lookup_row8.lookup(row8HashKey); } // G_TM_M_020 if (tHash_Lookup_row8 != null && tHash_Lookup_row8.getCount(row8HashKey) > 1) { // G // 071 // System.out.println("WARNING: UNIQUE MATCH is configured for the lookup 'row8' and it contains more one result from keys : row8.state = '" // + row8HashKey.state + "'"); } // G 071 row8Struct row8 = null; row8Struct fromLookup_row8 = null; row8 = row8Default; if (tHash_Lookup_row8 != null && tHash_Lookup_row8.hasNext()) { // G 099 fromLookup_row8 = tHash_Lookup_row8.next(); } // G 099 if (fromLookup_row8 != null) { row8 = fromLookup_row8; } // ///////////////////////////////////////////// // Starting Lookup Table "row9" // ///////////////////////////////////////////// boolean forceLooprow9 = false; row9Struct row9ObjectFromLookup = null; if (!rejectedInnerJoin_tMap_1) { // G_TM_M_020 hasCasePrimitiveKeyWithNull_tMap_1 = false; row9HashKey.state = row7.state; row9HashKey.hashCodeDirty = true; tHash_Lookup_row9.lookup(row9HashKey); } // G_TM_M_020 if (tHash_Lookup_row9 != null && tHash_Lookup_row9.getCount(row9HashKey) > 1) { // G // 071 // System.out.println("WARNING: UNIQUE MATCH is configured for the lookup 'row9' and it contains more one result from keys : row9.state = '" // + row9HashKey.state + "'"); } // G 071 row9Struct row9 = null; row9Struct fromLookup_row9 = null; row9 = row9Default; if (tHash_Lookup_row9 != null && tHash_Lookup_row9.hasNext()) { // G 099 fromLookup_row9 = tHash_Lookup_row9.next(); } // G 099 if (fromLookup_row9 != null) { row9 = fromLookup_row9; } // ///////////////////////////////////////////// // Starting Lookup Table "row10" // ///////////////////////////////////////////// boolean forceLooprow10 = false; row10Struct row10ObjectFromLookup = null; if (!rejectedInnerJoin_tMap_1) { // G_TM_M_020 hasCasePrimitiveKeyWithNull_tMap_1 = false; row10HashKey.state = row7.state; row10HashKey.hashCodeDirty = true; tHash_Lookup_row10.lookup(row10HashKey); } // G_TM_M_020 if (tHash_Lookup_row10 != null && tHash_Lookup_row10.getCount(row10HashKey) > 1) { // G // 071 // System.out.println("WARNING: UNIQUE MATCH is configured for the lookup 'row10' and it contains more one result from keys : row10.state = '" // + row10HashKey.state + "'"); } // G 071 row10Struct row10 = null; row10Struct fromLookup_row10 = null; row10 = row10Default; if (tHash_Lookup_row10 != null && tHash_Lookup_row10.hasNext()) { // G 099 fromLookup_row10 = tHash_Lookup_row10.next(); } // G 099 if (fromLookup_row10 != null) { row10 = fromLookup_row10; } // ############################### { // start of Var scope // ############################### // # Vars tables Var__tMap_1__Struct Var = Var__tMap_1;// ############################### // ############################### // # Output tables FLIGHT_Out = null; // # Output table : 'FLIGHT_Out' FLIGHT_Out_tmp.state = row7.state; FLIGHT_Out_tmp.ghg_quantity_2011 = row7.ghg_quantity; FLIGHT_Out_tmp.ghg_quantity_2012 = row8.ghg_quantity; FLIGHT_Out_tmp.ghg_quantity_2013 = row9.ghg_quantity; FLIGHT_Out_tmp.ghg_quantity_2014 = row10.ghg_quantity; FLIGHT_Out = FLIGHT_Out_tmp; // ############################### } // end of Var scope rejectedInnerJoin_tMap_1 = false; tos_count_tMap_1++; /** * [tMap_1 main ] stop */ // Start of branch "FLIGHT_Out" if (FLIGHT_Out != null) { /** * [tMap_2 main ] start */ currentComponent = "tMap_2"; boolean hasCasePrimitiveKeyWithNull_tMap_2 = false; // ############################### // # Input tables (lookups) boolean rejectedInnerJoin_tMap_2 = false; boolean mainRowRejected_tMap_2 = false; // ///////////////////////////////////////////// // Starting Lookup Table "row2" // ///////////////////////////////////////////// boolean forceLooprow2 = false; row2Struct row2ObjectFromLookup = null; if (!rejectedInnerJoin_tMap_2) { // G_TM_M_020 hasCasePrimitiveKeyWithNull_tMap_2 = false; row2HashKey.state = FLIGHT_Out.state; row2HashKey.hashCodeDirty = true; tHash_Lookup_row2.lookup(row2HashKey); } // G_TM_M_020 if (tHash_Lookup_row2 != null && tHash_Lookup_row2.getCount(row2HashKey) > 1) { // G // 071 // System.out.println("WARNING: UNIQUE MATCH is configured for the lookup 'row2' and it contains more one result from keys : row2.state = '" // + row2HashKey.state + "'"); } // G 071 row2Struct row2 = null; row2Struct fromLookup_row2 = null; row2 = row2Default; if (tHash_Lookup_row2 != null && tHash_Lookup_row2.hasNext()) { // G 099 fromLookup_row2 = tHash_Lookup_row2.next(); } // G 099 if (fromLookup_row2 != null) { row2 = fromLookup_row2; } // ############################### { // start of Var scope // ############################### // # Vars tables Var__tMap_2__Struct Var = Var__tMap_2;// ############################### // ############################### // # Output tables final_output = null; // # Output table : 'final_output' final_output_tmp.state = FLIGHT_Out.state; final_output_tmp.ghg_quantity_2011 = FLIGHT_Out.ghg_quantity_2011; final_output_tmp.ghg_quantity_2012 = FLIGHT_Out.ghg_quantity_2012; final_output_tmp.ghg_quantity_2013 = FLIGHT_Out.ghg_quantity_2013; final_output_tmp.ghg_quantity_2014 = FLIGHT_Out.ghg_quantity_2014; final_output_tmp.ghg_goal_2022 = row2.ghg_goal_2022; final_output_tmp.ghg_goal_2023 = row2.ghg_goal_2023; final_output_tmp.ghg_goal_2024 = row2.ghg_goal_2024; final_output_tmp.ghg_goal_2025 = row2.ghg_goal_2025; final_output_tmp.ghg_goal_2026 = row2.ghg_goal_2026; final_output_tmp.ghg_goal_2027 = row2.ghg_goal_2027; final_output_tmp.ghg_goal_2028 = row2.ghg_goal_2028; final_output_tmp.ghg_goal_2029 = row2.ghg_goal_2029; final_output_tmp.ghg_goal_2030 = row2.ghg_goal_2030; final_output_tmp.state_fullname = row2.state_name; final_output = final_output_tmp; // ############################### } // end of Var scope rejectedInnerJoin_tMap_2 = false; tos_count_tMap_2++; /** * [tMap_2 main ] stop */ // Start of branch "final_output" if (final_output != null) { /** * [tSortRow_1_SortOut main ] start */ currentVirtualComponent = "tSortRow_1"; currentComponent = "tSortRow_1_SortOut"; Comparablefinal_outputStruct arrayRowtSortRow_1_SortOut = new Comparablefinal_outputStruct(); arrayRowtSortRow_1_SortOut.state = final_output.state; arrayRowtSortRow_1_SortOut.ghg_quantity_2011 = final_output.ghg_quantity_2011; arrayRowtSortRow_1_SortOut.ghg_quantity_2012 = final_output.ghg_quantity_2012; arrayRowtSortRow_1_SortOut.ghg_quantity_2013 = final_output.ghg_quantity_2013; arrayRowtSortRow_1_SortOut.ghg_quantity_2014 = final_output.ghg_quantity_2014; arrayRowtSortRow_1_SortOut.ghg_goal_2022 = final_output.ghg_goal_2022; arrayRowtSortRow_1_SortOut.ghg_goal_2023 = final_output.ghg_goal_2023; arrayRowtSortRow_1_SortOut.ghg_goal_2024 = final_output.ghg_goal_2024; arrayRowtSortRow_1_SortOut.ghg_goal_2025 = final_output.ghg_goal_2025; arrayRowtSortRow_1_SortOut.ghg_goal_2026 = final_output.ghg_goal_2026; arrayRowtSortRow_1_SortOut.ghg_goal_2027 = final_output.ghg_goal_2027; arrayRowtSortRow_1_SortOut.ghg_goal_2028 = final_output.ghg_goal_2028; arrayRowtSortRow_1_SortOut.ghg_goal_2029 = final_output.ghg_goal_2029; arrayRowtSortRow_1_SortOut.ghg_goal_2030 = final_output.ghg_goal_2030; arrayRowtSortRow_1_SortOut.state_fullname = final_output.state_fullname; list_tSortRow_1_SortOut.add(arrayRowtSortRow_1_SortOut); tos_count_tSortRow_1_SortOut++; /** * [tSortRow_1_SortOut main ] stop */ } // End of branch "final_output" } // End of branch "FLIGHT_Out" /** * [tAggregateRow_2_AGGIN end ] start */ currentVirtualComponent = "tAggregateRow_2"; currentComponent = "tAggregateRow_2_AGGIN"; } // G_AggR_600 ok_Hash.put("tAggregateRow_2_AGGIN", true); end_Hash.put("tAggregateRow_2_AGGIN", System.currentTimeMillis()); /** * [tAggregateRow_2_AGGIN end ] stop */ /** * [tMap_1 end ] start */ currentComponent = "tMap_1"; // ############################### // # Lookup hashes releasing if (tHash_Lookup_row8 != null) { tHash_Lookup_row8.endGet(); } globalMap.remove("tHash_Lookup_row8"); if (tHash_Lookup_row9 != null) { tHash_Lookup_row9.endGet(); } globalMap.remove("tHash_Lookup_row9"); if (tHash_Lookup_row10 != null) { tHash_Lookup_row10.endGet(); } globalMap.remove("tHash_Lookup_row10"); // ############################### ok_Hash.put("tMap_1", true); end_Hash.put("tMap_1", System.currentTimeMillis()); /** * [tMap_1 end ] stop */ /** * [tMap_2 end ] start */ currentComponent = "tMap_2"; // ############################### // # Lookup hashes releasing if (tHash_Lookup_row2 != null) { tHash_Lookup_row2.endGet(); } globalMap.remove("tHash_Lookup_row2"); // ############################### ok_Hash.put("tMap_2", true); end_Hash.put("tMap_2", System.currentTimeMillis()); /** * [tMap_2 end ] stop */ /** * [tSortRow_1_SortOut end ] start */ currentVirtualComponent = "tSortRow_1"; currentComponent = "tSortRow_1_SortOut"; final_outputStruct[] array_tSortRow_1_SortOut = list_tSortRow_1_SortOut .toArray(new Comparablefinal_outputStruct[0]); java.util.Arrays.sort(array_tSortRow_1_SortOut); globalMap.put("tSortRow_1", array_tSortRow_1_SortOut); ok_Hash.put("tSortRow_1_SortOut", true); end_Hash.put("tSortRow_1_SortOut", System.currentTimeMillis()); /** * [tSortRow_1_SortOut end ] stop */ /** * [tWriteJSONField_1_Out begin ] start */ ok_Hash.put("tWriteJSONField_1_Out", false); start_Hash.put("tWriteJSONField_1_Out", System.currentTimeMillis()); currentVirtualComponent = "tWriteJSONField_1"; currentComponent = "tWriteJSONField_1_Out"; int tos_count_tWriteJSONField_1_Out = 0; // tWriteXMLFieldOut_begin int nb_line_tWriteJSONField_1_Out = 0; boolean needRoot_tWriteJSONField_1_Out = true; String strCompCache_tWriteJSONField_1_Out = null; java.util.Queue<row3Struct> listGroupby_tWriteJSONField_1_Out = new java.util.concurrent.ConcurrentLinkedQueue<row3Struct>(); class ThreadXMLField_tWriteJSONField_1_Out extends Thread { java.util.Queue<row3Struct> queue; java.util.List<java.util.Map<String, String>> flows; java.lang.Exception lastException; String currentComponent; ThreadXMLField_tWriteJSONField_1_Out(java.util.Queue q) { this.queue = q; globalMap.put("queue_tWriteJSONField_1_In", queue); lastException = null; } ThreadXMLField_tWriteJSONField_1_Out(java.util.Queue q, java.util.List<java.util.Map<String, String>> l) { this.queue = q; this.flows = l; lastException = null; globalMap.put("queue_tWriteJSONField_1_In", queue); globalMap.put("flows_tWriteJSONField_1_In", flows); } public java.lang.Exception getLastException() { return this.lastException; } public String getCurrentComponent() { return this.currentComponent; } @Override public void run() { try { tWriteJSONField_1_InProcess(globalMap); } catch (TalendException te) { this.lastException = te.getException(); this.currentComponent = te.getCurrentComponent(); } } } ThreadXMLField_tWriteJSONField_1_Out txf_tWriteJSONField_1_Out = new ThreadXMLField_tWriteJSONField_1_Out( listGroupby_tWriteJSONField_1_Out); txf_tWriteJSONField_1_Out.start(); java.util.List<java.util.List<String>> groupbyList_tWriteJSONField_1_Out = new java.util.ArrayList<java.util.List<String>>(); java.util.Map<String, String> valueMap_tWriteJSONField_1_Out = new java.util.HashMap<String, String>(); class NestXMLTool_tWriteJSONField_1_Out { public void parseAndAdd(org.dom4j.Element nestRoot, String value) { try { org.dom4j.Document doc4Str = org.dom4j.DocumentHelper .parseText("<root>" + value + "</root>"); nestRoot.setContent(doc4Str.getRootElement().content()); } catch (java.lang.Exception e) { e.printStackTrace(); nestRoot.setText(value); } } public void setText(org.dom4j.Element element, String value) { if (value.startsWith("<![CDATA[") && value.endsWith("]]>")) { String text = value.substring(9, value.length() - 3); element.addCDATA(text); } else { element.setText(value); } } public void replaceDefaultNameSpace(org.dom4j.Element nestRoot) { if (nestRoot != null) { for (org.dom4j.Element tmp : (java.util.List<org.dom4j.Element>) nestRoot.elements()) { if (("").equals(tmp.getQName().getNamespace().getURI()) && ("").equals(tmp.getQName().getNamespace().getPrefix())) { tmp.setQName(org.dom4j.DocumentHelper.createQName(tmp.getName(), nestRoot.getQName().getNamespace())); } replaceDefaultNameSpace(tmp); } } } public void removeEmptyElement(org.dom4j.Element root) { if (root != null) { for (org.dom4j.Element tmp : (java.util.List<org.dom4j.Element>) root.elements()) { removeEmptyElement(tmp); } if (root.content().size() == 0 && root.attributes().size() == 0 && root.declaredNamespaces().size() == 0) { if (root.getParent() != null) { root.getParent().remove(root); } } } } } NestXMLTool_tWriteJSONField_1_Out nestXMLTool_tWriteJSONField_1_Out = new NestXMLTool_tWriteJSONField_1_Out(); row11Struct rowStructOutput_tWriteJSONField_1_Out = null; // sort group root element for judgement of group java.util.List<org.dom4j.Element> groupElementList_tWriteJSONField_1_Out = new java.util.ArrayList<org.dom4j.Element>(); org.dom4j.Element root4Group_tWriteJSONField_1_Out = null; org.dom4j.Document doc_tWriteJSONField_1_Out = org.dom4j.DocumentHelper.createDocument(); org.dom4j.io.OutputFormat format_tWriteJSONField_1_Out = org.dom4j.io.OutputFormat .createCompactFormat(); format_tWriteJSONField_1_Out.setNewLineAfterDeclaration(false); format_tWriteJSONField_1_Out.setTrimText(false); format_tWriteJSONField_1_Out.setEncoding("ISO-8859-15"); int[] orders_tWriteJSONField_1_Out = new int[1]; /** * [tWriteJSONField_1_Out begin ] stop */ /** * [tSortRow_1_SortIn begin ] start */ ok_Hash.put("tSortRow_1_SortIn", false); start_Hash.put("tSortRow_1_SortIn", System.currentTimeMillis()); currentVirtualComponent = "tSortRow_1"; currentComponent = "tSortRow_1_SortIn"; int tos_count_tSortRow_1_SortIn = 0; final_outputStruct[] array_tSortRow_1_SortIn = (final_outputStruct[]) globalMap.get("tSortRow_1"); int nb_line_tSortRow_1_SortIn = 0; final_outputStruct current_tSortRow_1_SortIn = null; for (int i_tSortRow_1_SortIn = 0; i_tSortRow_1_SortIn < array_tSortRow_1_SortIn.length; i_tSortRow_1_SortIn++) { current_tSortRow_1_SortIn = array_tSortRow_1_SortIn[i_tSortRow_1_SortIn]; row11.state = current_tSortRow_1_SortIn.state; row11.ghg_quantity_2011 = current_tSortRow_1_SortIn.ghg_quantity_2011; row11.ghg_quantity_2012 = current_tSortRow_1_SortIn.ghg_quantity_2012; row11.ghg_quantity_2013 = current_tSortRow_1_SortIn.ghg_quantity_2013; row11.ghg_quantity_2014 = current_tSortRow_1_SortIn.ghg_quantity_2014; row11.ghg_goal_2022 = current_tSortRow_1_SortIn.ghg_goal_2022; row11.ghg_goal_2023 = current_tSortRow_1_SortIn.ghg_goal_2023; row11.ghg_goal_2024 = current_tSortRow_1_SortIn.ghg_goal_2024; row11.ghg_goal_2025 = current_tSortRow_1_SortIn.ghg_goal_2025; row11.ghg_goal_2026 = current_tSortRow_1_SortIn.ghg_goal_2026; row11.ghg_goal_2027 = current_tSortRow_1_SortIn.ghg_goal_2027; row11.ghg_goal_2028 = current_tSortRow_1_SortIn.ghg_goal_2028; row11.ghg_goal_2029 = current_tSortRow_1_SortIn.ghg_goal_2029; row11.ghg_goal_2030 = current_tSortRow_1_SortIn.ghg_goal_2030; row11.state_fullname = current_tSortRow_1_SortIn.state_fullname; // increase number of line sorted nb_line_tSortRow_1_SortIn++; /** * [tSortRow_1_SortIn begin ] stop */ /** * [tSortRow_1_SortIn main ] start */ currentVirtualComponent = "tSortRow_1"; currentComponent = "tSortRow_1_SortIn"; tos_count_tSortRow_1_SortIn++; /** * [tSortRow_1_SortIn main ] stop */ /** * [tWriteJSONField_1_Out main ] start */ currentVirtualComponent = "tWriteJSONField_1"; currentComponent = "tWriteJSONField_1_Out"; if (txf_tWriteJSONField_1_Out.getLastException() != null) { currentComponent = txf_tWriteJSONField_1_Out.getCurrentComponent(); throw txf_tWriteJSONField_1_Out.getLastException(); } nb_line_tWriteJSONField_1_Out++; valueMap_tWriteJSONField_1_Out.clear(); valueMap_tWriteJSONField_1_Out.put("state", (row11.state != null ? row11.state.toString() : null)); valueMap_tWriteJSONField_1_Out.put("ghg_quantity_2011", (row11.ghg_quantity_2011 != null ? row11.ghg_quantity_2011.toPlainString() : null)); valueMap_tWriteJSONField_1_Out.put("ghg_quantity_2012", (row11.ghg_quantity_2012 != null ? row11.ghg_quantity_2012.toPlainString() : null)); valueMap_tWriteJSONField_1_Out.put("ghg_quantity_2013", (row11.ghg_quantity_2013 != null ? row11.ghg_quantity_2013.toPlainString() : null)); valueMap_tWriteJSONField_1_Out.put("ghg_quantity_2014", (row11.ghg_quantity_2014 != null ? row11.ghg_quantity_2014.toPlainString() : null)); valueMap_tWriteJSONField_1_Out.put("ghg_goal_2022", (row11.ghg_goal_2022 != null ? row11.ghg_goal_2022.toPlainString() : null)); valueMap_tWriteJSONField_1_Out.put("ghg_goal_2023", (row11.ghg_goal_2023 != null ? row11.ghg_goal_2023.toPlainString() : null)); valueMap_tWriteJSONField_1_Out.put("ghg_goal_2024", (row11.ghg_goal_2024 != null ? row11.ghg_goal_2024.toPlainString() : null)); valueMap_tWriteJSONField_1_Out.put("ghg_goal_2025", (row11.ghg_goal_2025 != null ? row11.ghg_goal_2025.toPlainString() : null)); valueMap_tWriteJSONField_1_Out.put("ghg_goal_2026", (row11.ghg_goal_2026 != null ? row11.ghg_goal_2026.toPlainString() : null)); valueMap_tWriteJSONField_1_Out.put("ghg_goal_2027", (row11.ghg_goal_2027 != null ? row11.ghg_goal_2027.toPlainString() : null)); valueMap_tWriteJSONField_1_Out.put("ghg_goal_2028", (row11.ghg_goal_2028 != null ? row11.ghg_goal_2028.toPlainString() : null)); valueMap_tWriteJSONField_1_Out.put("ghg_goal_2029", (row11.ghg_goal_2029 != null ? row11.ghg_goal_2029.toPlainString() : null)); valueMap_tWriteJSONField_1_Out.put("ghg_goal_2030", (row11.ghg_goal_2030 != null ? row11.ghg_goal_2030.toPlainString() : null)); valueMap_tWriteJSONField_1_Out.put("state_fullname", (row11.state_fullname != null ? row11.state_fullname.toString() : null)); String strTemp_tWriteJSONField_1_Out = ""; if (strCompCache_tWriteJSONField_1_Out == null) { strCompCache_tWriteJSONField_1_Out = strTemp_tWriteJSONField_1_Out; rowStructOutput_tWriteJSONField_1_Out = row11; } else { nestXMLTool_tWriteJSONField_1_Out .replaceDefaultNameSpace(doc_tWriteJSONField_1_Out.getRootElement()); java.io.StringWriter strWriter_tWriteJSONField_1_Out = new java.io.StringWriter(); org.dom4j.io.XMLWriter output_tWriteJSONField_1_Out = new org.dom4j.io.XMLWriter( strWriter_tWriteJSONField_1_Out, format_tWriteJSONField_1_Out); output_tWriteJSONField_1_Out.write(doc_tWriteJSONField_1_Out); output_tWriteJSONField_1_Out.close(); row3Struct row_tWriteJSONField_1_Out = new row3Struct(); row_tWriteJSONField_1_Out.state = strWriter_tWriteJSONField_1_Out.toString(); listGroupby_tWriteJSONField_1_Out.add(row_tWriteJSONField_1_Out); doc_tWriteJSONField_1_Out.clearContent(); needRoot_tWriteJSONField_1_Out = true; for (int i_tWriteJSONField_1_Out = 0; i_tWriteJSONField_1_Out < orders_tWriteJSONField_1_Out.length; i_tWriteJSONField_1_Out++) { orders_tWriteJSONField_1_Out[i_tWriteJSONField_1_Out] = 0; } if (groupbyList_tWriteJSONField_1_Out != null && groupbyList_tWriteJSONField_1_Out.size() >= 0) { groupbyList_tWriteJSONField_1_Out.clear(); } strCompCache_tWriteJSONField_1_Out = strTemp_tWriteJSONField_1_Out; rowStructOutput_tWriteJSONField_1_Out = row11; } org.dom4j.Element subTreeRootParent_tWriteJSONField_1_Out = null; // build root xml tree if (needRoot_tWriteJSONField_1_Out) { needRoot_tWriteJSONField_1_Out = false; org.dom4j.Element root_tWriteJSONField_1_Out = doc_tWriteJSONField_1_Out .addElement("state_group"); subTreeRootParent_tWriteJSONField_1_Out = root_tWriteJSONField_1_Out; org.dom4j.Element root_0_tWriteJSONField_1_Out = root_tWriteJSONField_1_Out .addElement("acronymn"); if (valueMap_tWriteJSONField_1_Out.get("state") != null) { nestXMLTool_tWriteJSONField_1_Out.setText(root_0_tWriteJSONField_1_Out, valueMap_tWriteJSONField_1_Out.get("state")); } org.dom4j.Element root_1_tWriteJSONField_1_Out = root_tWriteJSONField_1_Out .addElement("ghg_emissions"); org.dom4j.Element root_1_0_tWriteJSONField_1_Out = root_1_tWriteJSONField_1_Out .addElement("emissions_2011"); if (valueMap_tWriteJSONField_1_Out.get("ghg_quantity_2011") != null) { nestXMLTool_tWriteJSONField_1_Out.setText(root_1_0_tWriteJSONField_1_Out, valueMap_tWriteJSONField_1_Out.get("ghg_quantity_2011")); } org.dom4j.Element root_1_1_tWriteJSONField_1_Out = root_1_tWriteJSONField_1_Out .addElement("emissions_2012"); if (valueMap_tWriteJSONField_1_Out.get("ghg_quantity_2012") != null) { nestXMLTool_tWriteJSONField_1_Out.setText(root_1_1_tWriteJSONField_1_Out, valueMap_tWriteJSONField_1_Out.get("ghg_quantity_2012")); } org.dom4j.Element root_1_2_tWriteJSONField_1_Out = root_1_tWriteJSONField_1_Out .addElement("emissions_2013"); if (valueMap_tWriteJSONField_1_Out.get("ghg_quantity_2013") != null) { nestXMLTool_tWriteJSONField_1_Out.setText(root_1_2_tWriteJSONField_1_Out, valueMap_tWriteJSONField_1_Out.get("ghg_quantity_2013")); } org.dom4j.Element root_1_3_tWriteJSONField_1_Out = root_1_tWriteJSONField_1_Out .addElement("emissions_2014"); if (valueMap_tWriteJSONField_1_Out.get("ghg_quantity_2014") != null) { nestXMLTool_tWriteJSONField_1_Out.setText(root_1_3_tWriteJSONField_1_Out, valueMap_tWriteJSONField_1_Out.get("ghg_quantity_2014")); } org.dom4j.Element root_2_tWriteJSONField_1_Out = root_tWriteJSONField_1_Out .addElement("ghg_goals"); org.dom4j.Element root_2_0_tWriteJSONField_1_Out = root_2_tWriteJSONField_1_Out .addElement("goals_2022"); if (valueMap_tWriteJSONField_1_Out.get("ghg_goal_2022") != null) { nestXMLTool_tWriteJSONField_1_Out.setText(root_2_0_tWriteJSONField_1_Out, valueMap_tWriteJSONField_1_Out.get("ghg_goal_2022")); } org.dom4j.Element root_2_1_tWriteJSONField_1_Out = root_2_tWriteJSONField_1_Out .addElement("goals_2023"); if (valueMap_tWriteJSONField_1_Out.get("ghg_goal_2023") != null) { nestXMLTool_tWriteJSONField_1_Out.setText(root_2_1_tWriteJSONField_1_Out, valueMap_tWriteJSONField_1_Out.get("ghg_goal_2023")); } org.dom4j.Element root_2_2_tWriteJSONField_1_Out = root_2_tWriteJSONField_1_Out .addElement("goals_2024"); if (valueMap_tWriteJSONField_1_Out.get("ghg_goal_2024") != null) { nestXMLTool_tWriteJSONField_1_Out.setText(root_2_2_tWriteJSONField_1_Out, valueMap_tWriteJSONField_1_Out.get("ghg_goal_2024")); } org.dom4j.Element root_2_3_tWriteJSONField_1_Out = root_2_tWriteJSONField_1_Out .addElement("goals_2025"); if (valueMap_tWriteJSONField_1_Out.get("ghg_goal_2025") != null) { nestXMLTool_tWriteJSONField_1_Out.setText(root_2_3_tWriteJSONField_1_Out, valueMap_tWriteJSONField_1_Out.get("ghg_goal_2025")); } org.dom4j.Element root_2_4_tWriteJSONField_1_Out = root_2_tWriteJSONField_1_Out .addElement("goals_2026"); if (valueMap_tWriteJSONField_1_Out.get("ghg_goal_2026") != null) { nestXMLTool_tWriteJSONField_1_Out.setText(root_2_4_tWriteJSONField_1_Out, valueMap_tWriteJSONField_1_Out.get("ghg_goal_2026")); } org.dom4j.Element root_2_5_tWriteJSONField_1_Out = root_2_tWriteJSONField_1_Out .addElement("goals_2027"); if (valueMap_tWriteJSONField_1_Out.get("ghg_goal_2027") != null) { nestXMLTool_tWriteJSONField_1_Out.setText(root_2_5_tWriteJSONField_1_Out, valueMap_tWriteJSONField_1_Out.get("ghg_goal_2027")); } org.dom4j.Element root_2_6_tWriteJSONField_1_Out = root_2_tWriteJSONField_1_Out .addElement("goals_2028"); if (valueMap_tWriteJSONField_1_Out.get("ghg_goal_2028") != null) { nestXMLTool_tWriteJSONField_1_Out.setText(root_2_6_tWriteJSONField_1_Out, valueMap_tWriteJSONField_1_Out.get("ghg_goal_2028")); } org.dom4j.Element root_2_7_tWriteJSONField_1_Out = root_2_tWriteJSONField_1_Out .addElement("goals_2029"); if (valueMap_tWriteJSONField_1_Out.get("ghg_goal_2029") != null) { nestXMLTool_tWriteJSONField_1_Out.setText(root_2_7_tWriteJSONField_1_Out, valueMap_tWriteJSONField_1_Out.get("ghg_goal_2029")); } org.dom4j.Element root_2_8_tWriteJSONField_1_Out = root_2_tWriteJSONField_1_Out .addElement("goals_2030"); if (valueMap_tWriteJSONField_1_Out.get("ghg_goal_2030") != null) { nestXMLTool_tWriteJSONField_1_Out.setText(root_2_8_tWriteJSONField_1_Out, valueMap_tWriteJSONField_1_Out.get("ghg_goal_2030")); } root4Group_tWriteJSONField_1_Out = subTreeRootParent_tWriteJSONField_1_Out; } else { subTreeRootParent_tWriteJSONField_1_Out = root4Group_tWriteJSONField_1_Out; } // build group xml tree // build loop xml tree org.dom4j.Element loop_tWriteJSONField_1_Out = org.dom4j.DocumentHelper.createElement("name"); if (orders_tWriteJSONField_1_Out[0] == 0) { orders_tWriteJSONField_1_Out[0] = 0; } if (1 < orders_tWriteJSONField_1_Out.length) { orders_tWriteJSONField_1_Out[1] = 0; } subTreeRootParent_tWriteJSONField_1_Out.elements().add(orders_tWriteJSONField_1_Out[0]++, loop_tWriteJSONField_1_Out); if (valueMap_tWriteJSONField_1_Out.get("state_fullname") != null) { nestXMLTool_tWriteJSONField_1_Out.setText(loop_tWriteJSONField_1_Out, valueMap_tWriteJSONField_1_Out.get("state_fullname")); } tos_count_tWriteJSONField_1_Out++; /** * [tWriteJSONField_1_Out main ] stop */ /** * [tSortRow_1_SortIn end ] start */ currentVirtualComponent = "tSortRow_1"; currentComponent = "tSortRow_1_SortIn"; } globalMap.put("tSortRow_1_SortIn_NB_LINE", nb_line_tSortRow_1_SortIn); ok_Hash.put("tSortRow_1_SortIn", true); end_Hash.put("tSortRow_1_SortIn", System.currentTimeMillis()); /** * [tSortRow_1_SortIn end ] stop */ /** * [tWriteJSONField_1_Out end ] start */ currentVirtualComponent = "tWriteJSONField_1"; currentComponent = "tWriteJSONField_1_Out"; if (nb_line_tWriteJSONField_1_Out > 0) { nestXMLTool_tWriteJSONField_1_Out .replaceDefaultNameSpace(doc_tWriteJSONField_1_Out.getRootElement()); java.io.StringWriter strWriter_tWriteJSONField_1_Out = new java.io.StringWriter(); org.dom4j.io.XMLWriter output_tWriteJSONField_1_Out = new org.dom4j.io.XMLWriter( strWriter_tWriteJSONField_1_Out, format_tWriteJSONField_1_Out); output_tWriteJSONField_1_Out.write(doc_tWriteJSONField_1_Out); output_tWriteJSONField_1_Out.close(); row3Struct row_tWriteJSONField_1_Out = new row3Struct(); row_tWriteJSONField_1_Out.state = strWriter_tWriteJSONField_1_Out.toString(); listGroupby_tWriteJSONField_1_Out.add(row_tWriteJSONField_1_Out); } globalMap.put("tWriteJSONField_1_Out_NB_LINE", nb_line_tWriteJSONField_1_Out); globalMap.put("tWriteJSONField_1_In_FINISH" + (listGroupby_tWriteJSONField_1_Out == null ? "" : listGroupby_tWriteJSONField_1_Out.hashCode()), "true"); txf_tWriteJSONField_1_Out.join(); if (txf_tWriteJSONField_1_Out.getLastException() != null) { currentComponent = txf_tWriteJSONField_1_Out.getCurrentComponent(); throw txf_tWriteJSONField_1_Out.getLastException(); } resourceMap.put("finish_tWriteJSONField_1_Out", true); ok_Hash.put("tWriteJSONField_1_Out", true); end_Hash.put("tWriteJSONField_1_Out", System.currentTimeMillis()); /** * [tWriteJSONField_1_Out end ] stop */ } // end the resume } catch (java.lang.Exception e) { TalendException te = new TalendException(e, currentComponent, globalMap); te.setVirtualComponentName(currentVirtualComponent); throw te; } catch (java.lang.Error error) { throw error; } finally { // free memory for "tSortRow_1_SortIn" globalMap.remove("tSortRow_1"); // free memory for "tMap_2" globalMap.remove("tHash_Lookup_row2"); // free memory for "tMap_1" globalMap.remove("tHash_Lookup_row8"); // free memory for "tMap_1" globalMap.remove("tHash_Lookup_row9"); // free memory for "tMap_1" globalMap.remove("tHash_Lookup_row10"); // free memory for "tAggregateRow_2_AGGIN" globalMap.remove("tAggregateRow_2"); try { /** * [tFileInputExcel_2 finally ] start */ currentComponent = "tFileInputExcel_2"; /** * [tFileInputExcel_2 finally ] stop */ /** * [tAggregateRow_2_AGGOUT finally ] start */ currentVirtualComponent = "tAggregateRow_2"; currentComponent = "tAggregateRow_2_AGGOUT"; /** * [tAggregateRow_2_AGGOUT finally ] stop */ /** * [tAggregateRow_2_AGGIN finally ] start */ currentVirtualComponent = "tAggregateRow_2"; currentComponent = "tAggregateRow_2_AGGIN"; /** * [tAggregateRow_2_AGGIN finally ] stop */ /** * [tMap_1 finally ] start */ currentComponent = "tMap_1"; /** * [tMap_1 finally ] stop */ /** * [tMap_2 finally ] start */ currentComponent = "tMap_2"; /** * [tMap_2 finally ] stop */ /** * [tSortRow_1_SortOut finally ] start */ currentVirtualComponent = "tSortRow_1"; currentComponent = "tSortRow_1_SortOut"; /** * [tSortRow_1_SortOut finally ] stop */ /** * [tSortRow_1_SortIn finally ] start */ currentVirtualComponent = "tSortRow_1"; currentComponent = "tSortRow_1_SortIn"; /** * [tSortRow_1_SortIn finally ] stop */ /** * [tWriteJSONField_1_Out finally ] start */ currentVirtualComponent = "tWriteJSONField_1"; currentComponent = "tWriteJSONField_1_Out"; java.util.Queue listGroupby_tWriteJSONField_1_Out = (java.util.Queue) globalMap .get("queue_tWriteJSONField_1_In"); if (resourceMap.get("finish_tWriteJSONField_1_Out") == null) { globalMap.put("tWriteJSONField_1_In_FINISH_WITH_EXCEPTION" + (listGroupby_tWriteJSONField_1_Out == null ? "" : listGroupby_tWriteJSONField_1_Out.hashCode()), "true"); } if (listGroupby_tWriteJSONField_1_Out != null) { globalMap.put("tWriteJSONField_1_In_FINISH" + (listGroupby_tWriteJSONField_1_Out == null ? "" : listGroupby_tWriteJSONField_1_Out.hashCode()), "true"); } /** * [tWriteJSONField_1_Out finally ] stop */ } catch (java.lang.Exception e) { // ignore } catch (java.lang.Error error) { // ignore } resourceMap = null; } globalMap.put("tFileInputExcel_2_SUBPROCESS_STATE", 1); }
From source file:eu.planets_project.pp.plato.action.ProjectExportAction.java
License:Open Source License
/** * Dumps binary data to provided file/*from w w w. j a v a2 s . co m*/ * It results in an XML file with a single element: data, * @param id * @param data * @param f * @param encoder * @throws IOException */ private static void writeBinaryData(int id, ByteStream data, File f, BASE64Encoder encoder) throws IOException { Document streamDoc = DocumentHelper.createDocument(); Element d = streamDoc.addElement("data"); d.addAttribute("id", "" + id); d.setText(encoder.encode(data.getData())); XMLWriter writer = new XMLWriter(new BufferedWriter(new FileWriter(f)), ProjectExporter.prettyFormat); writer.write(streamDoc); writer.flush(); writer.close(); }