List of usage examples for org.dom4j Document clearContent
void clearContent();
Node
instances this branch may contain. From source file:com.beetle.framework.web.cache.imp.CacheConfig.java
License:Apache License
public synchronized void readCacheURLs(InputStream xmlIs) { url_cacheAttr.clear();//from w w w . jav a2 s .co m if (xmlIs == null) { return; } SAXReader reader = new SAXReader(); Document doc = null; try { doc = reader.read(xmlIs); Node node = doc.selectSingleNode(convertPath("mappings.caches")); if (node != null) { config.setDiskStorePath(node.valueOf("@diskStorePath")); config.setMaxElementsInMemory(toInt(node.valueOf("@maxElementsInMemory"))); config.setMemoryStoreEvictionPolicy(node.valueOf("memoryStoreEvictionPolicy")); Iterator<?> it = node.selectNodes("cItem").iterator(); while (it.hasNext()) { CacheAttr attr = new CacheAttr(); Element e = (Element) it.next(); attr.setUrl(e.valueOf("@name")); attr.setScope(e.valueOf("@scope")); attr.setTime(toInt(e.valueOf("@time"))); url_cacheAttr.put(attr.getUrl(), attr); } } } catch (Exception de) { de.printStackTrace(); } finally { if (doc != null) { doc.clearContent(); } reader = null; } }
From source file:com.ewcms.content.particular.util.XmlConvert.java
License:Open Source License
@SuppressWarnings("unchecked") public static List<Map<String, Object>> importXML(File xmlFile, String fileType) { if (xmlFile != null) { List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); try {//from www. j a v a 2s .com List<InputStream> inputStreams = new ArrayList<InputStream>(); //FileType fileType = FileTypeJudge.getType(xmlFile); if (fileType.toLowerCase().equals("application/zip")) { inputStreams = parseXmlZIPFile(xmlFile); } else if (fileType.toLowerCase().equals("text/xml")) { InputStream in = new FileInputStream(xmlFile); inputStreams.add(in); } else { return null; } if (!inputStreams.isEmpty()) { SAXReader reader = new SAXReader(); Document doc = null; for (InputStream inputStream : inputStreams) { try { doc = reader.read(inputStream); if (doc != null) { Element root = doc.getRootElement(); Element metaViewData; Element projecties; for (Iterator<?> metaViewDataIterator = root .elementIterator("MetaViewData"); metaViewDataIterator.hasNext();) { metaViewData = (Element) metaViewDataIterator.next(); for (Iterator<?> projectiesIterator = metaViewData .elementIterator("PROPERTIES"); projectiesIterator.hasNext();) { projecties = (Element) projectiesIterator.next(); List<Element> elements = projecties.elements(); if (!elements.isEmpty()) { Map<String, Object> map = new HashMap<String, Object>(); for (Element element : elements) { map.put(element.getName(), element.getData()); } list.add(map); } } } } } catch (DocumentException e) { } finally { if (doc != null) { doc.clearContent(); doc = null; } } } } } catch (IOException e) { return null; } return list; } return null; }
From source file:com.globalsight.everest.webapp.pagehandler.administration.config.xmldtd.XmlDtdManager.java
License:Apache License
/** * Validates xml files with specified dtd file. * // www . j ava2s . c o m * @param id * The xml dtd id. * @param file * The xml file need to validate. * @throws DtdException */ public static void validateXmlFile(long id, File file) throws DtdException { Assert.assertFileExist(file); if (file.getName().endsWith(".xml")) { logger.debug("File: " + file.getPath()); File dtdFile = DtdFileManager.getDtdFile(id, file); if (dtdFile != null && dtdFile.exists()) { logger.debug("DTD: " + dtdFile.getPath()); SAXReader reader = new SAXReader(); DtdEntityResolver resolver = new DtdEntityResolver(dtdFile); reader.setEntityResolver(resolver); reader.setValidation(true); Document document; try { document = reader.read(file); document.clearContent(); logger.debug("Successful"); } catch (Exception e) { logger.info("DTD validation failed: " + e.getMessage()); throw new DtdException(e); } } } }
From source file:com.thinkberg.webdav.data.DavResource.java
License:Apache License
/** * Add the value for a given property to the result document. If the value * is missing or can not be added for some reason it will return false to * indicate a missing property./*from w ww . j av a 2s . c om*/ * * @param root the root element for the result document fragment * @param propertyName the property name to query * @return true for successful addition and false for missing data */ protected boolean getPropertyValue(Element root, String propertyName, boolean ignoreValue) { LogFactory.getLog(getClass()).debug(String.format("[%s].get('%s')", object.getName(), propertyName)); if (PROP_CREATION_DATE.equals(propertyName)) { return addCreationDateProperty(root, ignoreValue); } else if (PROP_DISPLAY_NAME.equals(propertyName)) { return addGetDisplayNameProperty(root, ignoreValue); } else if (PROP_GET_CONTENT_LANGUAGE.equals(propertyName)) { return addGetContentLanguageProperty(root, ignoreValue); } else if (PROP_GET_CONTENT_LENGTH.equals(propertyName)) { return addGetContentLengthProperty(root, ignoreValue); } else if (PROP_GET_CONTENT_TYPE.equals(propertyName)) { return addGetContentTypeProperty(root, ignoreValue); } else if (PROP_GET_ETAG.equals(propertyName)) { return addGetETagProperty(root, ignoreValue); } else if (PROP_GET_LAST_MODIFIED.equals(propertyName)) { return addGetLastModifiedProperty(root, ignoreValue); } else if (PROP_LOCK_DISCOVERY.equals(propertyName)) { return addLockDiscoveryProperty(root, ignoreValue); } else if (PROP_RESOURCETYPE.equals(propertyName)) { return addResourceTypeProperty(root, ignoreValue); } else if (PROP_SOURCE.equals(propertyName)) { return addSourceProperty(root, ignoreValue); } else if (PROP_SUPPORTED_LOCK.equals(propertyName)) { return addSupportedLockProperty(root, ignoreValue); } else { // handle non-standard properties (keep a little separate) if (PROP_QUOTA.equals(propertyName)) { return addQuotaProperty(root, ignoreValue); } else if (PROP_QUOTA_USED.equals(propertyName)) { return addQuotaUsedProperty(root, ignoreValue); } else if (PROP_QUOTA_AVAILABLE_BYTES.equals(propertyName)) { return addQuotaAvailableBytesProperty(root, ignoreValue); } else if (PROP_QUOTA_USED_BYTES.equals(propertyName)) { return addQuotaUsedBytesProperty(root, ignoreValue); } else { try { Object propertyValue = object.getContent().getAttribute(propertyName); if (null != propertyValue) { if (((String) propertyValue).startsWith("<")) { try { Document property = DocumentHelper.parseText((String) propertyValue); if (ignoreValue) { property.clearContent(); } root.add(property.getRootElement().detach()); return true; } catch (DocumentException e) { LogFactory.getLog(getClass()).error("property value unparsable", e); return false; } } else { Element el = root.addElement(propertyName); if (!ignoreValue) { el.addText((String) propertyValue); } return true; } } } catch (FileSystemException e) { LogFactory.getLog(this.getClass()) .error(String.format("property '%s' is not supported", propertyName), e); } } } return false; }
From source file:de.ingrid.server.opensearch.servlet.OpensearchServerServlet.java
License:EUPL
/** * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) *///from w w w . j a va 2s . c o m @Override protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { IngridHits hits = null; long overallStartTime = 0; if (log.isDebugEnabled()) { overallStartTime = System.currentTimeMillis(); } final RequestWrapper reqWrapper = new RequestWrapper(request); // set content Type request.setCharacterEncoding("UTF-8"); response.setContentType("text/xml"); response.setCharacterEncoding("UTF-8"); OSSearcher osSearcher = OSSearcher.getInstance(); if (osSearcher == null) { // redirect or show error page or empty result final PrintWriter pout = response.getWriter(); pout.write("Error: no index file found"); return; } int page = reqWrapper.getRequestedPage(); final int hitsPerPage = reqWrapper.getHitsPerPage(); if (page <= 0) { page = 1; } final int startHit = (page - 1) * hitsPerPage; try { // Hits also need Details which has title and summary!!! hits = osSearcher.searchAndDetails(reqWrapper.getQuery(), startHit, reqWrapper.getHitsPerPage()); } catch (final Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } // transform hits into target format final OpensearchMapper mapper = (new SpringUtil("spring/spring.xml")).getBean("mapper", OpensearchMapper.class); final HashMap<String, Object> parameter = new HashMap<String, Object>(); parameter.put(OpensearchMapper.REQUEST_WRAPPER, reqWrapper); final Document doc = mapper.mapToXML(hits, parameter); // write target format final PrintWriter pout = response.getWriter(); pout.write(doc.asXML()); pout.close(); request.getInputStream().close(); doc.clearContent(); if (log.isDebugEnabled()) { log.debug("Time for complete search: " + (System.currentTimeMillis() - overallStartTime) + " ms"); } }
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 {//w ww . jav a 2 s. c om 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:org.apache.taglibs.xtags.xpath.ReplaceTag.java
License:Apache License
public int doEndTag() throws JspException { Object context = TagHelper.getInputNodes(pageContext, this, false); if (context == null) { logInfo("No current node to replace"); return EVAL_PAGE; }/*from w ww. ja v a 2s . c o m*/ try { String xmlFragment = null; if (bodyContent != null) { xmlFragment = bodyContent.getString(); } if (context instanceof List) { List els = (List) context; if (els.size() > 1) { throw new JspException("Current context contains more than one node"); } if (els.size() == 1) { context = els.get(0); } } if (context instanceof Document) { if (xmlFragment == null) { throw new JspException("Cannot replace document with empty body"); } Document sourceDoc = (Document) context; Document newDoc = DocumentHelper.parseText(xmlFragment); // clear source doc contents sourceDoc.clearContent(); for (int i = 0, size = newDoc.nodeCount(); i < size; i++) { Node node = newDoc.node(i); // detach from new doc node.detach(); // add to source sourceDoc.add(node); } } else { if (!(context instanceof Element)) { throw new JspException("Current node is not an Element: " + context.getClass().getName()); } Element element = (Element) context; SAXReader reader = new SAXReader(); if (element.isRootElement()) { if (xmlFragment == null) { throw new JspException("Cannot replace root element with empty body"); } Document newDoc = DocumentHelper.parseText(xmlFragment); Document sourceDoc = element.getDocument(); Element newRoot = newDoc.getRootElement(); newRoot.detach(); sourceDoc.setRootElement(newRoot); } else { Element parent = element.getParent(); List parentContent = parent.content(); int index = parentContent.indexOf(element); parentContent.remove(index); if (xmlFragment != null) { Document newDoc = DocumentHelper.parseText("<dummy>" + xmlFragment + "</dummy>"); parentContent.addAll(index, newDoc.getRootElement().content()); } } } } catch (DocumentException e) { handleException(e); } return EVAL_PAGE; }
From source file:org.efaps.webdav4vfs.data.DavResource.java
License:Apache License
/** * Add the value for a given property to the result document. If the value * is missing or can not be added for some reason it will return false to * indicate a missing property./* w w w . jav a 2 s . co m*/ * * @param _root root element for the result document fragment * @param _propertyName property name to query * @param _ignoreValue <i>true</i> if values must be ignored * @return true for successful addition and false for missing data */ @Override() protected boolean getPropertyValue(final Element _root, final String _propertyName, final boolean ignoreValue) { LogFactory.getLog(getClass()).debug(String.format("[%s].get('%s')", object.getName(), _propertyName)); if (PROP_CREATION_DATE.equals(_propertyName)) { return addCreationDateProperty(_root, ignoreValue); } else if (PROP_DISPLAY_NAME.equals(_propertyName)) { return addGetDisplayNameProperty(_root, ignoreValue); } else if (PROP_GET_CONTENT_LANGUAGE.equals(_propertyName)) { return addGetContentLanguageProperty(_root, ignoreValue); } else if (PROP_GET_CONTENT_LENGTH.equals(_propertyName)) { return addGetContentLengthProperty(_root, ignoreValue); } else if (PROP_GET_CONTENT_TYPE.equals(_propertyName)) { return addGetContentTypeProperty(_root, ignoreValue); } else if (PROP_GET_ETAG.equals(_propertyName)) { return addGetETagProperty(_root, ignoreValue); } else if (PROP_GET_LAST_MODIFIED.equals(_propertyName)) { return addGetLastModifiedProperty(_root, ignoreValue); } else if (PROP_LOCK_DISCOVERY.equals(_propertyName)) { return addLockDiscoveryProperty(_root, ignoreValue); } else if (PROP_RESOURCETYPE.equals(_propertyName)) { return addResourceTypeProperty(_root, ignoreValue); } else if (PROP_SOURCE.equals(_propertyName)) { return addSourceProperty(_root, ignoreValue); } else if (PROP_SUPPORTED_LOCK.equals(_propertyName)) { return addSupportedLockProperty(_root, ignoreValue); } else { // handle non-standard properties (keep a little separate) if (PROP_QUOTA.equals(_propertyName)) { return addQuotaProperty(_root, ignoreValue); } else if (PROP_QUOTA_USED.equals(_propertyName)) { return addQuotaUsedProperty(_root, ignoreValue); } else if (PROP_QUOTA_AVAILABLE_BYTES.equals(_propertyName)) { return addQuotaAvailableBytesProperty(_root, ignoreValue); } else if (PROP_QUOTA_USED_BYTES.equals(_propertyName)) { return addQuotaUsedBytesProperty(_root, ignoreValue); } else { try { Object propertyValue = object.getContent().getAttribute(_propertyName); if (null != propertyValue) { if (((String) propertyValue).startsWith("<")) { try { Document property = DocumentHelper.parseText((String) propertyValue); if (ignoreValue) { property.clearContent(); } _root.add(property.getRootElement().detach()); return true; } catch (DocumentException e) { LogFactory.getLog(getClass()).error("property value unparsable", e); return false; } } else { Element el = _root.addElement(_propertyName); if (!ignoreValue) { el.addText((String) propertyValue); } return true; } } } catch (FileSystemException e) { LogFactory.getLog(this.getClass()) .error(String.format("property '%s' is not supported", _propertyName), e); } } } return false; }
From source file:org.firesoa.common.jxpath.model.dom4j.Dom4JNodePointer.java
License:Open Source License
@Override public void setValue(Object value) { if (value == null) value = "";//null?? if ((node instanceof org.dom4j.CharacterData || node instanceof Attribute || node instanceof DocumentType || node instanceof Entity || node instanceof ProcessingInstruction)) { String string = (String) TypeUtils.convert(value, String.class); if (string != null && !string.equals("")) { ((Node) node).setText(string); } else {/*from ww w .j a v a2 s . co m*/ ((Node) node).getParent().remove((Node) node); } } else if (node instanceof Document) { Document theOriginalDoc = (Document) node; Element theOrigialRoot = theOriginalDoc.getRootElement(); if (value instanceof Document) {//?document Document valueDoc = (Document) value; Element valueRoot = valueDoc.getRootElement(); if (theOrigialRoot == null || valueRoot == null || theOrigialRoot.getQName().equals(valueRoot.getQName())) { theOriginalDoc.clearContent(); List content = valueDoc.content(); if (content != null) { for (int i = 0; i < content.size(); i++) { Node dom4jNode = (Node) content.get(i); Node newDom4jNode = (Node) dom4jNode.clone(); theOriginalDoc.add(newDom4jNode); } } } else { throw new RuntimeException( "Can NOT assign " + valueRoot.getQName() + " to " + theOrigialRoot.getQName()); } } else if (value instanceof Element) { Element valueElem = (Element) value; if (valueElem.getQName().equals(theOrigialRoot.getQName())) { theOriginalDoc.clearContent(); Element newValueElem = (Element) valueElem.clone(); theOriginalDoc.setRootElement(newValueElem); } else { throw new RuntimeException( "Can NOT assign " + valueElem.getQName() + " to " + theOrigialRoot.getQName()); } } else { throw new RuntimeException("Can NOT assign " + value + " to " + theOrigialRoot.getQName()); } // else if (value instanceof Comment){ // Comment cmmt = (Comment)((Comment)value).clone(); // theOriginalDoc.add(cmmt); // // }else if (value instanceof ProcessingInstruction){ // ProcessingInstruction instru = (ProcessingInstruction)((ProcessingInstruction)value).clone(); // theOriginalDoc.add(instru); // } } else if (node instanceof Element) { Element originalElem = ((Element) node); if (value != null && value instanceof Element) { Element valueElm = (Element) value; if (originalElem.getQName().equals(valueElm.getQName())) { originalElem.clearContent(); List content = valueElm.content(); if (content != null) { for (int i = 0; i < content.size(); i++) { Node dom4jNode = (Node) content.get(i); Node newDom4jNode = (Node) dom4jNode.clone(); originalElem.add(newDom4jNode); } } } else { throw new RuntimeException( "Can NOT assign " + valueElm.getQName() + " to " + originalElem.getQName()); } } else if (value != null && value instanceof Text) { originalElem.clearContent(); Text txt = (Text) ((Text) value).clone(); originalElem.add(txt); } else if (value != null && value instanceof CDATA) { originalElem.clearContent(); CDATA cdata = (CDATA) ((CDATA) value).clone(); originalElem.add(cdata); } else if (value != null && value instanceof java.util.Date) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String dateStr = format.format((java.util.Date) value); originalElem.clearContent(); originalElem.addText(dateStr); } else { String string = (String) TypeUtils.convert(value, String.class); originalElem.clearContent(); originalElem.addText(string); } } }
From source file:org.lnicholls.galleon.apps.internetSlideshows.InternetSlideshows.java
License:Open Source License
public static List getPhotoDescriptions(String url) { List photoDescriptions = new ArrayList(); PersistentValue persistentValue = PersistentValueManager .loadPersistentValue(InternetSlideshows.class.getName() + "." + url);//w w w .ja v a2 s . c om String content = persistentValue == null ? null : persistentValue.getValue(); if (PersistentValueManager.isAged(persistentValue)) { try { String page = Tools.getPage(new URL(url)); if (page != null && page.length() > 0) content = page; } catch (Exception ex) { Tools.logException(InternetSlideshows.class, ex, "Could not cache listing: " + url); } } if (content != null) { try { SAXReader saxReader = new SAXReader(); StringReader stringReader = new StringReader(content); // Document document = saxReader.read(new // File("d:/galleon/itunes2.rss.xml")); Document document = saxReader.read(stringReader); stringReader.close(); stringReader = null; Element root = document.getRootElement(); // check for errors if (root != null && root.getName().equals("rss")) { Element channel = root.element("channel"); if (channel != null) { for (Iterator i = channel.elementIterator("item"); i.hasNext();) { Element item = (Element) i.next(); String value = null; String title = null; String link = null; if ((value = Tools.getAttribute(item, "title")) != null) { title = value; } if ((value = Tools.getAttribute(item, "description")) != null) { title = Tools.cleanHTML(value); } Element contentElement = item.element("content"); if (contentElement != null) { if ((value = contentElement.attributeValue("url")) != null) { link = value; if (url.startsWith("http://rss.news.yahoo.com")) { URL location = new URL(link); photoDescriptions.add(new PhotoDescription(location.getProtocol() + "://" + location.getHost() + location.getPath(), title)); } else photoDescriptions.add(new PhotoDescription(link, title)); } } Element enclosureElement = item.element("enclosure"); if (enclosureElement != null) { if ((value = enclosureElement.attributeValue("url")) != null) { link = value; if (url.startsWith("http://rss.news.yahoo.com")) { URL location = new URL(link); photoDescriptions.add(new PhotoDescription(location.getProtocol() + "://" + location.getHost() + location.getPath(), title)); } else photoDescriptions.add(new PhotoDescription(link, title)); } } } } } document.clearContent(); document = null; if (PersistentValueManager.isAged(persistentValue)) { PersistentValueManager.savePersistentValue(InternetSlideshows.class.getName() + "." + url, content, 60); } } catch (Exception ex) { Tools.logException(InternetSlideshows.class, ex, "Could not download listing: " + url); return null; } } return photoDescriptions; }