List of usage examples for org.dom4j Element setQName
void setQName(QName qname);
QName
of this element which represents the local name, the qualified name and the Namespace
. From source file:com.flaptor.util.parser.HtmlParser.java
License:Apache License
private void removeNamespace(Element elem) { if (null != elem) { elem.remove(elem.getNamespace()); elem.setQName(QName.get(elem.getName(), Namespace.NO_NAMESPACE)); removeNamespace(elem.content()); }//from ww w . ja v a 2 s .co m }
From source file:de.innovationgate.wga.common.WGAXML.java
License:Apache License
/** * Performs normalization on the wga.xml by creating mandatory elements and attributes and doing some * additional validations, like converting obsolete structures, defining yet undefined domains etc. * @param doc The wga.xml/*from ww w . j a va2s.com*/ */ public static void normalize(Document doc) { // Remove obsolete namespace String ns = "urn:de.innovationgate.webgate.api.query.domino.WGDatabaseImpl"; Iterator nodes = doc.selectNodes("//*[namespace-uri(.)='" + ns + "']").iterator(); Element element; while (nodes.hasNext()) { element = (Element) nodes.next(); element.setQName(QName.get(element.getName())); } // Build necessary elements Element wga = (Element) doc.selectSingleNode("wga"); // Licenses Element licenses = WGUtils.getOrCreateElement(wga, "licenses"); Iterator licenseTags = licenses.elements("authorlicense").iterator(); while (licenseTags.hasNext()) { Element licenseTag = (Element) licenseTags.next(); //WGUtils.getOrCreateAttribute(licenseTag, "type", "WGA.Client"); // B0000486E licenseTag.addAttribute("type", "WGA.Client"); } // administrators WGUtils.getOrCreateElement(wga, "administrators"); // configuration Element configuration = WGUtils.getOrCreateElement(wga, "configuration"); Element defaultdb = WGUtils.getOrCreateElement(configuration, "defaultdb"); WGUtils.getOrCreateAttribute(defaultdb, "key", ""); WGUtils.getOrCreateAttribute(defaultdb, "favicon", ""); WGUtils.getOrCreateAttribute(defaultdb, "datacache", "10000"); WGUtils.getOrCreateAttribute(defaultdb, "staticexpiration", "10"); Element features = WGUtils.getOrCreateElement(configuration, "features"); WGUtils.getOrCreateAttribute(features, "bi", "true"); WGUtils.getOrCreateAttribute(features, "adminpage", "true"); WGUtils.getOrCreateAttribute(features, "manager", "true"); WGUtils.getOrCreateAttribute(features, "startpage", "true"); WGUtils.getOrCreateAttribute(features, "webdav", "true"); WGUtils.getOrCreateAttribute(features, "webservice", "true"); WGUtils.getOrCreateAttribute(features, "adminport", ""); WGUtils.getOrCreateAttribute(features, "authoringport", ""); WGUtils.getOrCreateAttribute(features, "clusterport", ""); Element warnings = WGUtils.getOrCreateElement(configuration, "warnings"); WGUtils.getOrCreateAttribute(warnings, "enabled", "true"); WGUtils.getOrCreateAttribute(warnings, "consoleOutput", "false"); WGUtils.getOrCreateAttribute(warnings, "pageOutput", "true"); Element tml = WGUtils.getOrCreateElement(configuration, "tml"); WGUtils.getOrCreateAttribute(tml, "characterEncoding", ""); WGUtils.getOrCreateAttribute(tml, "linkEncoding", "UTF-8"); Element tmlheader = WGUtils.getOrCreateElement(tml, "tmlheader"); WGUtils.getOrCreateAttribute(tmlheader, "buffer", "8kb"); Element authoringconfig = WGUtils.getOrCreateElement(configuration, "authoringconfig"); WGUtils.getOrCreateAttribute(authoringconfig, "dbfile", ""); Element applog = WGUtils.getOrCreateElement(configuration, "applog"); WGUtils.getOrCreateAttribute(applog, "level", "INFO"); WGUtils.getOrCreateAttribute(applog, "logserver", "false"); Element compression = WGUtils.getOrCreateElement(configuration, "compression"); WGUtils.getOrCreateAttribute(compression, "enabled", "false"); Element listeners = WGUtils.getOrCreateElement(configuration, "listeners"); Element lucene = WGUtils.getOrCreateElement(configuration, "lucene"); WGUtils.getOrCreateAttribute(lucene, "dir", ""); WGUtils.getOrCreateAttribute(lucene, "enabled", "false"); WGUtils.getOrCreateAttribute(lucene, "booleanQueryMaxClauseCount", "1024"); WGUtils.getOrCreateAttribute(lucene, "maxDocsPerDBSession", "50"); // read old lucene enabled dbs Attribute dbs = WGUtils.getOrCreateAttribute(lucene, "dbs", ""); List oldLuceneEnabledDBKeys = WGUtils.deserializeCollection(dbs.getText(), ","); // remove old attribute for lucene enabled dbs lucene.remove(dbs); Element persoconfig = WGUtils.getOrCreateElement(configuration, "personalisation"); // Element for TestCore - config Element testcore = WGUtils.getOrCreateElement(configuration, "testcore"); WGUtils.getOrCreateAttribute(testcore, "dir", ""); WGUtils.getOrCreateAttribute(testcore, "enabled", "false"); Element design = WGUtils.getOrCreateElement(configuration, "designsync"); WGUtils.getOrCreateAttribute(design, "fileEncoding", ""); WGUtils.getOrCreateAttribute(design, "interval", "1"); WGUtils.getOrCreateAttribute(design, "throttling", "false"); WGUtils.getOrCreateAttribute(design, "throttlingactivation", "10"); Element jdbcDrivers = WGUtils.getOrCreateElement(configuration, "jdbcdrivers"); WGUtils.getOrCreateElement(configuration, "defaultdboptions"); WGUtils.getOrCreateElement(configuration, "defaultpublisheroptions"); Element mailConfig = WGUtils.getOrCreateElement(configuration, "mailconfig"); WGUtils.getOrCreateAttribute(mailConfig, "mailHost", ""); WGUtils.getOrCreateAttribute(mailConfig, "mailUser", ""); WGUtils.getOrCreateAttribute(mailConfig, "mailPassword", ""); WGUtils.getOrCreateAttribute(mailConfig, "mailFrom", ""); WGUtils.getOrCreateAttribute(mailConfig, "mailTo", ""); WGUtils.getOrCreateAttribute(mailConfig, "mailWGARootURL", ""); WGUtils.getOrCreateAttribute(mailConfig, "useAsDefaultForWF", "false"); WGUtils.getOrCreateAttribute(mailConfig, "enableAdminNotifications", "true"); // Mappings Element mappings = WGUtils.getOrCreateElement(wga, "mappings"); Attribute mappingLibraries = WGUtils.getOrCreateAttribute(mappings, "libraries", ""); Element elementmappings = WGUtils.getOrCreateElement(mappings, "elementmappings"); if (elementmappings.attribute("libraries") != null && mappingLibraries.getText().equals("")) { mappingLibraries.setText(elementmappings.attributeValue("libraries", "")); elementmappings.remove(elementmappings.attribute("libraries")); } List elementsToRemove = new ArrayList(); Iterator elementmappingTags = elementmappings.selectNodes("elementmapping").iterator(); while (elementmappingTags.hasNext()) { Element elementmapping = (Element) elementmappingTags.next(); if (elementmapping.attribute("binary") != null) { elementmapping.remove(elementmapping.attribute("binary")); } // remove old FOP implementation reference (F000040EE) String implClass = elementmapping.attributeValue("class", null); if (implClass != null && implClass.equals("de.innovationgate.wgpublisher.webtml.elements.FOP")) { elementsToRemove.add(elementmapping); } } Iterator toRemove = elementsToRemove.iterator(); while (toRemove.hasNext()) { Element elementmapping = (Element) toRemove.next(); elementmappings.remove(elementmapping); } Element mediamappings = WGUtils.getOrCreateElement(mappings, "mediamappings"); Iterator mediamappingTags = mediamappings.selectNodes("mediamapping").iterator(); while (mediamappingTags.hasNext()) { Element mediamapping = (Element) mediamappingTags.next(); WGUtils.getOrCreateAttribute(mediamapping, "binary", "false"); WGUtils.getOrCreateAttribute(mediamapping, "httplogin", "false"); } WGUtils.getOrCreateElement(mappings, "encodermappings"); WGUtils.getOrCreateElement(mappings, "syncmappings"); Element analyzermappings = WGUtils.getOrCreateElement(mappings, "analyzermappings"); WGUtils.getOrCreateAttribute(analyzermappings, "defaultAnalyzerClass", "de.innovationgate.wgpublisher.lucene.analysis.StandardAnalyzer"); removeDefaultFileHandlerMappings(WGUtils.getOrCreateElement(mappings, "filehandlermappings")); WGUtils.getOrCreateElement(mappings, "filtermappings"); Element scheduler = WGUtils.getOrCreateElement(wga, "scheduler"); WGUtils.getOrCreateAttribute(scheduler, "loggingdir", ""); // Domains Element domains = WGUtils.getOrCreateElement(wga, "domains"); Iterator domainsIt = domains.elementIterator("domain"); while (domainsIt.hasNext()) { Element domain = (Element) domainsIt.next(); WGUtils.getOrCreateAttribute(domain, "name", ""); WGUtils.getOrCreateAttribute(domain, "loginattempts", "5"); WGUtils.getOrCreateAttribute(domain, "defaultmanager", ""); Element login = WGUtils.getOrCreateElement(domain, "login"); WGUtils.getOrCreateAttribute(login, "mode", "user"); WGUtils.getOrCreateAttribute(login, "username", ""); WGUtils.getOrCreateAttribute(login, "password", ""); Element errorpage = WGUtils.getOrCreateElement(domain, "errorpage"); WGUtils.getOrCreateAttribute(errorpage, "enabled", "false"); WGUtils.getOrCreateElement(domain, "defaultdboptions"); WGUtils.getOrCreateElement(domain, "defaultpublisheroptions"); } // content dbs Element contentdbs = WGUtils.getOrCreateElement(wga, "contentdbs"); Iterator contentdbTags = contentdbs.selectNodes("contentdb").iterator(); Set usedDomains = new HashSet(); while (contentdbTags.hasNext()) { Element contentdb = (Element) contentdbTags.next(); WGUtils.getOrCreateAttribute(contentdb, "enabled", "true"); WGUtils.getOrCreateAttribute(contentdb, "lazyconnect", "false"); Element type = WGUtils.getOrCreateElement(contentdb, "type"); String typeName = type.getStringValue(); if (typeName.equals("de.innovationgate.webgate.api.domino.local.WGDatabaseImpl")) { type.setText("de.innovationgate.webgate.api.domino.WGDatabaseImpl"); } boolean isFullContentStore = false; DbType dbType = DbType.getByImplClass(DbType.GENTYPE_CONTENT, typeName); if (dbType != null) { isFullContentStore = dbType.isFullContentStore(); } //lowercase dbkey Element dbkey = WGUtils.getOrCreateElement(contentdb, "dbkey"); dbkey.setText(dbkey.getText().trim().toLowerCase()); WGUtils.getOrCreateElement(contentdb, "title"); Element domain = WGUtils.getOrCreateElement(contentdb, "domain"); String domainStr = domain.getTextTrim(); if (domainStr.equals("")) { domainStr = "masterloginonly"; domain.setText("masterloginonly"); } usedDomains.add(domainStr); WGUtils.getOrCreateElement(contentdb, "login"); Element dboptions = WGUtils.getOrCreateElement(contentdb, "dboptions"); Iterator options = dboptions.selectNodes("option").iterator(); Element option; String optionName; while (options.hasNext()) { option = (Element) options.next(); optionName = option.attributeValue("name"); if (optionName.indexOf(":") != -1) { option.addAttribute("name", optionName.substring(optionName.indexOf(":") + 1)); } } WGUtils.getOrCreateElement(contentdb, "publisheroptions"); WGUtils.getOrCreateElement(contentdb, "storedqueries"); WGUtils.getOrCreateElement(contentdb, "fieldmappings"); if (isFullContentStore) { WGUtils.getOrCreateElement(contentdb, "shares"); } else { if (contentdb.element("shares") != null) { contentdb.remove(contentdb.element("shares")); } } Element cache = WGUtils.getOrCreateElement(contentdb, "cache"); WGUtils.getOrCreateAttribute(cache, "type", "de.innovationgate.wgpublisher.cache.WGACacheHSQLDB"); WGUtils.getOrCreateAttribute(cache, "path", ""); WGUtils.getOrCreateAttribute(cache, "maxpages", "5000"); // Design - Migrate old designsync element Element designsync = contentdb.element("designsync"); design = contentdb.element("design"); if (designsync != null && design == null) { design = contentdb.addElement("design"); if (designsync.attributeValue("enabled", "false").equals("true")) { design.addAttribute("provider", "sync"); } else { design.addAttribute("provider", "none"); } design.addAttribute("mode", designsync.attributeValue("mode", "")); design.addAttribute("key", designsync.attributeValue("key", "")); design.setText(designsync.getText()); } else { design = WGUtils.getOrCreateElement(contentdb, "design"); WGUtils.getOrCreateAttribute(design, "provider", "none"); WGUtils.getOrCreateAttribute(design, "mode", ""); WGUtils.getOrCreateAttribute(design, "key", ""); } // create default lucene config for old enabled dbs if (oldLuceneEnabledDBKeys.contains(dbkey.getText().toLowerCase())) { Element luceneDBConfig = WGUtils.getOrCreateElement(contentdb, "lucene"); WGUtils.getOrCreateAttribute(luceneDBConfig, "enabled", "true"); WGUtils.getOrCreateElement(luceneDBConfig, "itemrules"); // create defaultrule LuceneIndexItemRule.addDefaultRule(luceneDBConfig); } //lucene config per db Element luceneDBConfig = WGUtils.getOrCreateElement(contentdb, "lucene"); WGUtils.getOrCreateAttribute(luceneDBConfig, "enabled", "false"); WGUtils.getOrCreateElement(luceneDBConfig, "itemrules"); //check for default rule ArrayList rules = (ArrayList) LuceneIndexItemRule.getRules(luceneDBConfig); if (rules.size() > 0) { //check if last rule is defaultrule LuceneIndexItemRule checkDefaultRule = (LuceneIndexItemRule) rules.get(rules.size() - 1); if (!checkDefaultRule.getItemExpression().equals(LuceneIndexItemRule.EXPRESSION_WILDCARD)) { //last rule is no defaultRule, create defaultRule LuceneIndexItemRule.addDefaultRule(luceneDBConfig); } } else { //no rules present, create defaultRule LuceneIndexItemRule.addDefaultRule(luceneDBConfig); } // lucene file rules WGUtils.getOrCreateElement(luceneDBConfig, "filerules"); //check for default filerule rules = (ArrayList) LuceneIndexFileRule.getRules(luceneDBConfig); if (rules.size() > 0) { //check if last rule is defaultrule LuceneIndexFileRule checkDefaultRule = (LuceneIndexFileRule) rules.get(rules.size() - 1); if (!checkDefaultRule.isDefaultRule()) { //last rule is no defaultRule, create defaultRule LuceneIndexFileRule.addDefaultRule(luceneDBConfig); } } else { //no rules present, create defaultRule LuceneIndexFileRule.addDefaultRule(luceneDBConfig); } // client restrictions Element clientRestrictions = WGUtils.getOrCreateElement(contentdb, "clientrestrictions"); WGUtils.getOrCreateAttribute(clientRestrictions, "enabled", "false"); WGUtils.getOrCreateElement(clientRestrictions, "restrictions"); } // Personalisation dbs Element persodbs = WGUtils.getOrCreateElement(wga, "personalisationdbs"); Iterator persodbTags = persodbs.selectNodes("personalisationdb").iterator(); while (persodbTags.hasNext()) { Element persodb = (Element) persodbTags.next(); WGUtils.getOrCreateAttribute(persodb, "enabled", "true"); WGUtils.getOrCreateAttribute(persodb, "lazyconnect", "false"); Element type = WGUtils.getOrCreateElement(persodb, "type"); if (type.getStringValue().equals("de.innovationgate.webgate.api.domino.local.WGDatabaseImpl")) { type.setText("de.innovationgate.webgate.api.domino.WGDatabaseImpl"); } Element domain = WGUtils.getOrCreateElement(persodb, "domain"); String domainStr = domain.getTextTrim(); if (domainStr.equals("")) { domainStr = "masterloginonly"; domain.setText("masterloginonly"); } usedDomains.add(domainStr); WGUtils.getOrCreateElement(persodb, "login"); Element persConfig = WGUtils.getOrCreateElement(persodb, "persconfig"); WGUtils.getOrCreateAttribute(persConfig, "mode", "auto"); WGUtils.getOrCreateAttribute(persConfig, "statistics", "off"); Element dboptions = WGUtils.getOrCreateElement(persodb, "dboptions"); Iterator options = dboptions.selectNodes("option").iterator(); Element option; String optionName; while (options.hasNext()) { option = (Element) options.next(); optionName = option.attributeValue("name"); if (optionName.indexOf(":") != -1) { option.addAttribute("name", optionName.substring(optionName.indexOf(":") + 1)); } } WGUtils.getOrCreateElement(persodb, "publisheroptions"); } // **** Post-Processings **** // Turn stored queries into CDATA-Sections List queries = doc.selectNodes("/wga/contentdbs/contentdb/storedqueries/storedquery/query"); for (Iterator iter = queries.iterator(); iter.hasNext();) { Element query = (Element) iter.next(); Node text = query.selectSingleNode("text()"); if (text != null && text instanceof Text) { query.addCDATA(text.getText()); query.remove(text); } } // Create domains from database definitions Iterator usedDomainsIt = usedDomains.iterator(); String usedDomain; while (usedDomainsIt.hasNext()) { usedDomain = (String) usedDomainsIt.next(); Element domain = (Element) domains.selectSingleNode("domain[@name='" + usedDomain + "']"); if (domain == null) { domain = domains.addElement("domain"); domain.addAttribute("name", usedDomain); Element login = domain.addElement("login"); if (usedDomain.equals("masterloginonly")) { login.addAttribute("mode", "master"); } else { login.addAttribute("mode", "user"); } login.addAttribute("username", ""); login.addAttribute("password", ""); Element errorPage = domain.addElement("errorpage"); errorPage.addAttribute("enabled", "false"); Element defDBOptions = domain.addElement("defaultdboptions"); Element defPublisherOptions = domain.addElement("defaultpublisheroptions"); } } // Reorder content dbs, so design providers are first pullupDesignProviders(doc); }
From source file:edu.ucsd.library.dams.jhove.MyJhoveBase.java
License:Open Source License
public static void removeNS(Element elem) { elem.remove(elem.getNamespace());/*from w ww . ja va 2 s . co m*/ elem.setQName(new QName(elem.getQName().getName(), Namespace.NO_NAMESPACE)); // fix children List children = elem.elements(); for (int i = 0; i < children.size(); i++) { Element child = (Element) children.get(i); removeNS(child); } }
From source file:edu.vt.middleware.ldap.dsml.AbstractDsml.java
License:Open Source License
/** * This will take an attribute name and it's values and return a DSML * attribute element.//from www. jav a 2 s .c o m * * @param attrName <code>String</code> * @param attrValues <code>Set</code> * @param ns <code>Namespace</code> of DSML * @param elementName <code>String</code> of the attribute element * @param elementAttrName <code>String</code> of the attribute element * @param elementValueName <code>String</code> of the value element * * @return <code>Element</code> */ protected Element createDsmlAttribute(final String attrName, final Set<?> attrValues, final Namespace ns, final String elementName, final String elementAttrName, final String elementValueName) { final Element attrElement = DocumentHelper.createElement(""); if (attrName != null) { attrElement.setQName(new QName(elementName, ns)); if (elementAttrName != null) { attrElement.addAttribute(elementAttrName, attrName); } if (attrValues != null) { final Iterator<?> i = attrValues.iterator(); while (i.hasNext()) { final Object rawValue = i.next(); String value = null; boolean isBase64 = false; if (rawValue instanceof String) { value = (String) rawValue; } else if (rawValue instanceof byte[]) { value = LdapUtil.base64Encode((byte[]) rawValue); isBase64 = true; } else { if (this.logger.isWarnEnabled()) { this.logger.warn("Could not cast attribute value as a byte[]" + " or a String"); } } if (value != null) { final Element valueElement = attrElement.addElement(new QName(elementValueName, ns)); valueElement.addText(value); if (isBase64) { valueElement.addAttribute("encoding", "base64"); } } } } } return attrElement; }
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 w w w . j av a 2 s . co 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:fr.gouv.culture.vitam.utils.XmlDom.java
License:Open Source License
private final static void setNamespace(Element elem, Namespace ns) { elem.setQName(QName.get(elem.getName(), ns, elem.getQualifiedName())); }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private String serializeLearningObjectInstanceUserReportToXML(LearningObjectInstanceUserReport userReport) { Document document = DocumentHelper.createDocument(); Element root = document.addElement("LearningObjectInstanceUserReport"); root.setQName(new QName("LearningObjectInstanceUserReport", new Namespace("", EntityConstants.NAMESPACE_ENTITIES))); root.add(new Namespace("i", "http://www.w3.org/2001/XMLSchema-instance")); fillLearningObjectInstanceUserReportXmlElement(root, userReport); return root.asXML(); }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private String serializeLearningObjectInstanceUserReportCommentOnCommentToXML( LearningObjectInstanceUserReportCommentOnComment reportComment) { Document document = DocumentHelper.createDocument(); Element root = document.addElement("LearningObjectInstanceUserReportCommentOnComment"); root.setQName(new QName("LearningObjectInstanceUserReportCommentOnComment", new Namespace("", EntityConstants.NAMESPACE_ENTITIES))); root.add(new Namespace("i", "http://www.w3.org/2001/XMLSchema-instance")); if (reportComment.getUserId() != null) { root.addElement("UserId").addText(reportComment.getUserId().toString()); }/*from ww w .ja v a 2 s. c o m*/ if (reportComment.getCommentText() != null) { root.addElement("CommentText").addText(reportComment.getCommentText()); } if (reportComment.getCommentSyncKey() != null) { root.addElement("CommentSyncKey").addText(reportComment.getCommentSyncKey()); } if (reportComment.getModifiedUtc() != null) { root.addElement("ModifiedUtc").addText(sdf.format(reportComment.getModifiedUtc())); } return root.asXML(); }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private String serializeNotificationToXML(Notification notification) { Document document = DocumentHelper.createDocument(); Element root = document.addElement("Notification"); root.setQName(new QName("Notification", new Namespace("", EntityConstants.NAMESPACE_ENTITIES))); root.add(new Namespace("i", "http://www.w3.org/2001/XMLSchema-instance")); if (notification.getLaunchParameter() != null) { root.addElement("LaunchParameter").addText(notification.getLaunchParameter().toString()); }/* w w w .j a v a 2s. c o m*/ if (notification.getLocalizedMessages() != null) { Element n = root.addElement("LocalizedMessages"); n.add(new Namespace("a", EntityConstants.NAMESPACE_ARRAYS)); HashMap<String, String> messages = notification.getLocalizedMessages(); for (String lang : messages.keySet()) { Element messageKeyValuePair = n.addElement("a:KeyValueOfstringstring"); messageKeyValuePair.addElement("a:Key").addText(lang); messageKeyValuePair.addElement("a:Value").addText(messages.get(lang)); } } if (notification.getMessage() != null) { root.addElement("Message").addText(notification.getMessage()); } if (notification.getReciverPermission() != null) { root.addElement("ReciverPermission").addText(notification.getReciverPermission().toString()); } return root.asXML(); }
From source file:itslearning.platform.restapi.sdk.learningtoolapp.LearningObjectServicetRestClient.java
private String serializeLearningObjectInstanceUserReportsToXML( List<LearningObjectInstanceUserReport> userReports) { Document document = DocumentHelper.createDocument(); Element root = document.addElement("ArrayOfLearningObjectInstanceUserReport"); root.setQName(new QName("ArrayOfLearningObjectInstanceUserReport", new Namespace("", EntityConstants.NAMESPACE_ENTITIES))); root.add(new Namespace("i", "http://www.w3.org/2001/XMLSchema-instance")); for (LearningObjectInstanceUserReport userReport : userReports) { Element n = root.addElement("LearningObjectInstanceUserReport"); fillLearningObjectInstanceUserReportXmlElement(n, userReport); }//from w ww . ja va 2 s . c o m return root.asXML(); }