List of usage examples for java.io PrintStream flush
public void flush()
From source file:org.alfresco.repo.tenant.TenantInterpreter.java
/** * Execute a single command using the BufferedReader passed in for any data needed. * * TODO: Use decent parser!// www .j a v a 2 s . co m * * @param line The unparsed command * @return The textual output of the command. */ public String executeCommand(String line) throws IOException { String[] command = line.split(" "); if (command.length == 0) { command = new String[1]; command[0] = line; } ByteArrayOutputStream bout = new ByteArrayOutputStream(); PrintStream out = new PrintStream(bout); // repeat last command? if (command[0].equals("r")) { if (lastCommand == null) { return "No command entered yet."; } return "repeating command " + lastCommand + "\n\n" + executeCommand(lastCommand); } // remember last command lastCommand = line; // execute command if (command[0].equals("help")) { String helpFile = I18NUtil.getMessage("tenant_console.help"); ClassPathResource helpResource = new ClassPathResource(helpFile); byte[] helpBytes = new byte[500]; InputStream helpStream = helpResource.getInputStream(); try { int read = helpStream.read(helpBytes); while (read != -1) { bout.write(helpBytes, 0, read); read = helpStream.read(helpBytes); } } finally { helpStream.close(); } } else if (command[0].equals("show")) { if (command.length < 2) { return "Syntax Error, try 'help'.\n"; } else if (command[1].equals("tenants")) { List<Tenant> tenants = tenantAdminService.getAllTenants(); for (Tenant tenant : tenants) { if (tenant.isEnabled()) { String contentRoot = tenant.getRootContentStoreDir(); out.println("Enabled - Tenant: " + tenant.getTenantDomain() + " (" + contentRoot + ")"); } } out.println(""); for (Tenant tenant : tenants) { if (!tenant.isEnabled()) { String contentRoot = tenant.getRootContentStoreDir(); out.println("Disabled - Tenant: " + tenant.getTenantDomain() + " (" + contentRoot + ")"); } } } else if (command[1].equals("tenant")) { if (command.length != 3) { return "Syntax Error, try 'help'.\n"; } String tenantDomain = new String(command[2]).toLowerCase(); Tenant tenant = tenantAdminService.getTenant(tenantDomain); String contentRoot = tenant.getRootContentStoreDir(); if (tenant.isEnabled()) { out.println("Enabled - Tenant: " + tenant.getTenantDomain() + " (" + contentRoot + ")"); } else { out.println("Disabled - Tenant: " + tenant.getTenantDomain() + " (" + contentRoot + ")"); } } else { return "No such sub-command, try 'help'.\n"; } } else if (command[0].equals("create")) { if ((command.length < 3) || (command.length > 5)) { return "Syntax Error, try 'help'.\n"; } String newTenant = new String(command[1]).toLowerCase(); char[] tenantAdminRawPassword = new String(command[2]).toCharArray(); String contentRoot = null; if (command.length >= 4) { contentRoot = new String(command[3]); if ("null".equals(contentRoot)) { contentRoot = null; } } String dbUrl = null; if (command.length >= 5) { // experimental (unsupported) dbUrl = new String(command[4]); if ("null".equals(dbUrl)) { dbUrl = null; } } tenantAdminService.createTenant(newTenant, tenantAdminRawPassword, contentRoot, dbUrl); out.println("created tenant: " + newTenant); } else if (command[0].equals("import")) { if ((command.length != 3) && (command.length != 4)) { return "Syntax Error, try 'help'.\n"; } String newTenant = new String(command[1]).toLowerCase(); File directorySource = new File(command[2]); String contentRoot = null; if (command.length == 4) { contentRoot = new String(command[3]); } tenantAdminService.importTenant(newTenant, directorySource, contentRoot); out.println("imported tenant: " + newTenant); } else if (command[0].equals("export")) { if (command.length != 3) { return "Syntax Error, try 'help'.\n"; } String tenant = new String(command[1]).toLowerCase(); File directoryDestination = new File(command[2]); tenantAdminService.exportTenant(tenant, directoryDestination); out.println("exported tenant: " + tenant); } // TODO - not fully working yet else if (command[0].equals("delete")) { if (command.length != 2) { return "Syntax Error, try 'help'.\n"; } String tenantDomain = new String(command[1]).toLowerCase(); tenantAdminService.deleteTenant(tenantDomain); out.println("Deleted tenant: " + tenantDomain); } else if (command[0].equals("enable")) { if (command.length != 2) { return "Syntax Error, try 'help'.\n"; } String tenantDomain = new String(command[1]).toLowerCase(); tenantAdminService.enableTenant(tenantDomain); out.println("Enabled tenant: " + tenantDomain); } else if (command[0].equals("disable")) { if (command.length != 2) { return "Syntax Error, try 'help'.\n"; } String tenantDomain = new String(command[1]).toLowerCase(); tenantAdminService.disableTenant(tenantDomain); out.println("Disabled tenant: " + tenantDomain); } else if (command[0].equals("changeAdminPassword")) { if (command.length != 3) { return "Syntax Error, try 'help'.\n"; } String tenantDomain = new String(command[1]).toLowerCase(); final String newPassword = new String(command[2]); final String tenantAdminUsername = tenantService.getDomainUser(getBaseAdminUsername(), tenantDomain); AuthenticationUtil.runAs(new RunAsWork<Object>() { public Object doWork() throws Exception { authenticationService.setAuthentication(tenantAdminUsername, newPassword.toCharArray()); return null; } }, tenantAdminUsername); } else { return "No such command, try 'help'.\n"; } out.flush(); String retVal = new String(bout.toByteArray()); out.close(); return retVal; }
From source file:org.proteomecommons.tranche.cacheupdater.CacheUpdater.java
public void execute() { // first and foremost, make sure the proteomecommons tranche configuration is loaded ProteomeCommonsTrancheConfig.load(); // set up directories if (!workingDirectory.exists()) { workingDirectory.mkdirs();/*from w w w . j av a 2s . c o m*/ } if (!publishDirectory.exists()) { publishDirectory.mkdirs(); } PrintStream detailsLog = null, errorLog = null, generalLog = null, stdOutLog = null, stdErrLog = null; try { // create the log files File detailsLogFile = new File(workingDirectory, "details.log"); if (!detailsLogFile.createNewFile()) { throw new RuntimeException("There was a problem creating the detailed log file."); } detailsLog = new PrintStream(new FileOutputStream(detailsLogFile)); File errorLogFile = new File(workingDirectory, "errors.log"); if (!errorLogFile.createNewFile()) { throw new RuntimeException("There was a problem creating the error log file."); } errorLog = new PrintStream(new FileOutputStream(errorLogFile)); File generalLogFile = new File(workingDirectory, "general.log"); if (!generalLogFile.createNewFile()) { throw new RuntimeException("There was a problem creating the general log file."); } generalLog = new PrintStream(new FileOutputStream(generalLogFile)); File changesLogFile = new File(workingDirectory, "changes.log"); if (!changesLogFile.createNewFile()) { throw new RuntimeException("There was a problem creating the changes log file."); } changesLog = new PrintStream(new FileOutputStream(changesLogFile)); File missingLogFile = new File(workingDirectory, "missing.log"); if (!missingLogFile.createNewFile()) { throw new RuntimeException("There was a problem creating the missing log file."); } missingLog = new PrintStream(new FileOutputStream(missingLogFile)); File invalidLogFile = new File(workingDirectory, "invalid.log"); if (!invalidLogFile.createNewFile()) { throw new RuntimeException("There was a problem creating the invalid log file."); } invalidLog = new PrintStream(new FileOutputStream(invalidLogFile)); File stdOutFile = new File(workingDirectory, "stdout.log"); if (!stdOutFile.createNewFile()) { throw new RuntimeException("There was a problem creating the standard out log file."); } stdOutLog = new PrintStream(new FileOutputStream(stdOutFile)); File stdErrFile = new File(workingDirectory, "stderr.log"); if (!stdErrFile.createNewFile()) { throw new RuntimeException("There was a problem creating the standard error log file."); } stdErrLog = new PrintStream(new FileOutputStream(stdErrFile)); // change standard out and err System.setOut(stdOutLog); System.setErr(stdErrLog); // set output to the detailed log log = detailsLog; err = errorLog; // run the cache updater start = System.currentTimeMillis(); if (updateTagsDatabase || makeNewCache) { populateHashesSet(); } if (updateTagsDatabase) { updateTagsDatabase(); } if (makeNewCache) { createCacheFile(); if (makeChanges) { publishCacheFile(); } } if (indexTagsDatabase) { indexTagsDatabase(); } } catch (Exception e) { log.println("ERROR: Fatal error. Program terminating."); err.println(e.getMessage()); Thread t = new Thread() { public void run() { try { EmailUtil.sendEmail("FATAL ERROR: Cache Updater", new String[] { "augman85@gmail.com", "jfalkner@umich.edu", "bryanesmith@gmail.com" }, "A fatal error occurred on the cache updater. Check the logs on the proteomecommons.org server under \"" + workingDirectory.getAbsolutePath() + "\" for more information."); } catch (Exception e) { } } }; t.start(); } finally { stop = System.currentTimeMillis(); detailsLog.flush(); detailsLog.close(); printFileTypeLog(); log = generalLog; printReportOfAction(); generalLog.flush(); generalLog.close(); changesLog.flush(); changesLog.close(); missingLog.flush(); missingLog.close(); invalidLog.flush(); invalidLog.close(); errorLog.flush(); errorLog.close(); stdOutLog.flush(); stdOutLog.close(); stdErrLog.flush(); stdErrLog.close(); System.out .println("*** FINISHED BUILDING " + Text.getFormattedDate(System.currentTimeMillis()) + " ***"); } }
From source file:org.kuali.kfs.module.tem.batch.service.impl.AgencyDataImportServiceImpl.java
/** * @see org.kuali.kfs.module.tem.batch.service.AgencyDataImportService#validateAgencyData(org.kuali.kfs.module.tem.businessobject.AgencyImportData, java.lang.String) *///w w w.java 2 s . c o m @Override public List<AgencyStagingData> validateAgencyData(AgencyImportData agencyImportData, String dataFileName) { PrintStream reportDataStream = dataReportService.getReportPrintStream(getAgencyDataReportDirectory(), getAgencyDataReportFilePrefix()); BusinessObjectReportHelper reportHelper = getReportHelper( ExpenseImport.getExpenseImportByCode(agencyImportData.getImportBy())); HashMap<String, AgencyStagingData> validAgencyStagingDataMap = new HashMap<String, AgencyStagingData>(); try { dataReportService.writeReportHeader(reportDataStream, dataFileName, TemKeyConstants.MESSAGE_AGENCY_DATA_REPORT_HEADER, reportHelper); int count = 1; List<AgencyStagingData> importedAgencyStagingDataList = agencyImportData.getAgencyStagingData(); int listSize = importedAgencyStagingDataList.size(); LOG.info("Validating agency import by traveler: importing " + listSize + " records"); NextAgencyStagingDataIdFinder idFinder = new NextAgencyStagingDataIdFinder(); for (AgencyStagingData importedAgencyStagingData : importedAgencyStagingDataList) { String key = null; importedAgencyStagingData.setId(Integer.valueOf(idFinder.getValue())); importedAgencyStagingData.setImportBy(agencyImportData.getImportBy()); importedAgencyStagingData .setStagingFileName(StringUtils.substringAfterLast(dataFileName, File.separator)); importedAgencyStagingData.setCreationTimestamp(getDateTimeService().getCurrentTimestamp()); String itineraryData = importedAgencyStagingData.getItineraryDataString(); AgencyStagingData validAgencyStagingData = null; List<ErrorMessage> errorMessages = new ArrayList<ErrorMessage>(); // validate by Traveler ID if (importedAgencyStagingData.getExpenseImport() == ExpenseImport.traveler) { key = importedAgencyStagingData.getTravelerId() + "~" + itineraryData + "~" + importedAgencyStagingData.getCreditCardOrAgencyCode() + "~" + importedAgencyStagingData.getTransactionPostingDate() + "~" + importedAgencyStagingData.getTripExpenseAmount() + "~" + importedAgencyStagingData.getTripInvoiceNumber(); LOG.info("Validating agency import by traveler. Record# " + count + " of " + listSize); if (!validAgencyStagingDataMap.containsKey(key)) { errorMessages.addAll( expenseImportByTravelerService.validateAgencyData(importedAgencyStagingData)); //no errors- load the data if (errorMessages.isEmpty()) { validAgencyStagingDataMap.put(key, importedAgencyStagingData); } else { //if there are errors check for required fields missing or duplicate data- load anything else String errorCode = importedAgencyStagingData.getErrorCode(); if (ObjectUtils.isNotNull(errorCode) && !StringUtils.equals( TemConstants.AgencyStagingDataErrorCodes.AGENCY_DUPLICATE_DATA, errorCode)) { validAgencyStagingDataMap.put(key, importedAgencyStagingData); } } } else { // duplicate record found in the file ErrorMessage error = new ErrorMessage( TemKeyConstants.MESSAGE_AGENCY_DATA_TRAVELER_DUPLICATE_RECORD, importedAgencyStagingData.getTravelerId(), itineraryData, importedAgencyStagingData.getCreditCardOrAgencyCode(), importedAgencyStagingData.getTransactionPostingDate().toString(), importedAgencyStagingData.getTripExpenseAmount().toString(), importedAgencyStagingData.getTripInvoiceNumber()); errorMessages.add(error); } } // validate by Trip ID else if (importedAgencyStagingData.getExpenseImport() == ExpenseImport.trip) { key = importedAgencyStagingData.getTravelerId() + "~" + importedAgencyStagingData.getTripId() + "~" + importedAgencyStagingData.getCreditCardOrAgencyCode() + "~" + importedAgencyStagingData.getTransactionPostingDate() + "~" + importedAgencyStagingData.getTripExpenseAmount(); LOG.info("Validating agency import by trip. Record# " + count + " of " + listSize); if (!validAgencyStagingDataMap.containsKey(key)) { errorMessages .addAll(expenseImportByTripService.validateAgencyData(importedAgencyStagingData)); //no errors- load the data if (errorMessages.isEmpty()) { validAgencyStagingDataMap.put(key, importedAgencyStagingData); } else { //if there are errors check for required fields missing or duplicate data- load anything else String errorCode = importedAgencyStagingData.getErrorCode(); if (ObjectUtils.isNotNull(errorCode) && !StringUtils.equals( TemConstants.AgencyStagingDataErrorCodes.AGENCY_DUPLICATE_DATA, errorCode)) { validAgencyStagingDataMap.put(key, importedAgencyStagingData); } } } else { // duplicate record found in the file. ErrorMessage error = new ErrorMessage( TemKeyConstants.MESSAGE_AGENCY_DATA_TRIP_DUPLICATE_RECORD, importedAgencyStagingData.getTripId(), importedAgencyStagingData.getCreditCardOrAgencyCode(), importedAgencyStagingData.getTransactionPostingDate().toString(), importedAgencyStagingData.getTripExpenseAmount().toString(), itineraryData); errorMessages.add(error); } } //writer to error report if (!errorMessages.isEmpty()) { dataReportService.writeToReport(reportDataStream, importedAgencyStagingData, errorMessages, reportHelper); } count++; } } finally { if (reportDataStream != null) { reportDataStream.flush(); reportDataStream.close(); } } ArrayList<AgencyStagingData> validAgencyRecords = new ArrayList<AgencyStagingData>(); for (Map.Entry<String, AgencyStagingData> entry : validAgencyStagingDataMap.entrySet()) { validAgencyRecords.add(entry.getValue()); } return validAgencyRecords; }
From source file:fr.inrialpes.exmo.align.cli.ExtGroupEval.java
public void printHTML(Vector<Vector<Object>> result, PrintStream writer) { // variables for computing iterative harmonic means int expected = 0; // expected so far int foundVect[]; // found so far double symVect[]; // symmetric similarity double effVect[]; // effort-based similarity double precOrVect[]; // precision-oriented similarity double recOrVect[]; // recall-oriented similarity fsize = format.length();/*from ww w .j a v a 2 s .c om*/ try { Formatter formatter = new Formatter(writer); // Print the header writer.println("<html><head></head><body>"); writer.println("<table border='2' frame='sides' rules='groups'>"); writer.println("<colgroup align='center' />"); // for each algo <td spancol='2'>name</td> for (String m : listAlgo) { writer.println("<colgroup align='center' span='" + 2 * fsize + "' />"); } // For each file do a writer.println("<thead valign='top'><tr><th>algo</th>"); // for each algo <td spancol='2'>name</td> for (String m : listAlgo) { writer.println("<th colspan='" + ((2 * fsize)) + "'>" + m + "</th>"); } writer.println("</tr></thead><tbody><tr><td>test</td>"); // for each algo <td>Prec.</td><td>Rec.</td> for (String m : listAlgo) { for (int i = 0; i < fsize; i++) { if (format.charAt(i) == 's') { writer.println("<td colspan='2'><center>Symmetric</center></td>"); } else if (format.charAt(i) == 'e') { writer.println("<td colspan='2'><center>Effort</center></td>"); } else if (format.charAt(i) == 'p') { writer.println("<td colspan='2'><center>Prec. orient.</center></td>"); } else if (format.charAt(i) == 'r') { writer.println("<td colspan='2'><center>Rec. orient.</center></td>"); } } //writer.println("<td>Prec.</td><td>Rec.</td>"); } writer.println("</tr></tbody><tbody>"); foundVect = new int[size]; symVect = new double[size]; effVect = new double[size]; precOrVect = new double[size]; recOrVect = new double[size]; for (int k = size - 1; k >= 0; k--) { foundVect[k] = 0; symVect[k] = 0.; effVect[k] = 0.; precOrVect[k] = 0.; recOrVect[k] = 0.; } // </tr> // For each directory <tr> boolean colored = false; for (Vector<Object> test : result) { int nexpected = -1; if (colored == true && color != null) { colored = false; writer.println("<tr bgcolor=\"" + color + "\">"); } else { colored = true; writer.println("<tr>"); } ; // Print the directory <td>bla</td> writer.println("<td>" + (String) test.get(0) + "</td>"); // For each record print the values <td>bla</td> Enumeration<Object> f = test.elements(); f.nextElement(); for (int k = 0; f.hasMoreElements(); k++) { ExtPREvaluator eval = (ExtPREvaluator) f.nextElement(); if (eval != null) { // iterative H-means computation if (nexpected == -1) { nexpected = eval.getExpected(); expected += nexpected; } // If foundVect is -1 then results are invalid if (foundVect[k] != -1) foundVect[k] += eval.getFound(); for (int i = 0; i < fsize; i++) { writer.print("<td>"); if (format.charAt(i) == 's') { formatter.format("%1.2f", eval.getSymPrecision()); writer.print("</td><td>"); formatter.format("%1.2f", eval.getSymRecall()); symVect[k] += eval.getSymSimilarity(); } else if (format.charAt(i) == 'e') { formatter.format("%1.2f", eval.getEffPrecision()); writer.print("</td><td>"); formatter.format("%1.2f", eval.getEffRecall()); effVect[k] += eval.getEffSimilarity(); } else if (format.charAt(i) == 'p') { formatter.format("%1.2f", eval.getPrecisionOrientedPrecision()); writer.print("</td><td>"); formatter.format("%1.2f", eval.getPrecisionOrientedRecall()); precOrVect[k] += eval.getPrecisionOrientedSimilarity(); } else if (format.charAt(i) == 'r') { formatter.format("%1.2f", eval.getRecallOrientedPrecision()); writer.print("</td><td>"); formatter.format("%1.2f", eval.getRecallOrientedRecall()); recOrVect[k] += eval.getRecallOrientedSimilarity(); } writer.print("</td>"); } } else { for (int i = 0; i < fsize; i++) writer.print("<td>n/a</td>"); } } writer.println("</tr>"); } writer.print("<tr bgcolor=\"yellow\"><td>H-mean</td>"); int k = 0; for (String m : listAlgo) { if (foundVect[k] != -1) { for (int i = 0; i < fsize; i++) { writer.print("<td>"); if (format.charAt(i) == 's') { formatter.format("%1.2f", symVect[k] / foundVect[k]); writer.print("</td><td>"); formatter.format("%1.2f", symVect[k] / expected); } else if (format.charAt(i) == 'e') { formatter.format("%1.2f", effVect[k] / foundVect[k]); writer.print("</td><td>"); formatter.format("%1.2f", effVect[k] / expected); } else if (format.charAt(i) == 'p') { formatter.format("%1.2f", precOrVect[k] / foundVect[k]); writer.print("</td><td>"); formatter.format("%1.2f", precOrVect[k] / expected); } else if (format.charAt(i) == 'r') { formatter.format("%1.2f", recOrVect[k] / foundVect[k]); writer.print("</td><td>"); formatter.format("%1.2f", recOrVect[k] / expected); } writer.println("</td>"); } } else { writer.println("<td colspan='2'><center>Error</center></td>"); } //}; k++; } writer.println("</tr>"); writer.println("</tbody></table>"); writer.println("<p><small>n/a: result alignment not provided or not readable<br />"); writer.println("NaN: division per zero, likely due to empty alignent.</small></p>"); writer.println("</body></html>"); } catch (Exception ex) { logger.debug("IGNORED Exception", ex); } finally { writer.flush(); writer.close(); } }
From source file:com.github.lindenb.jvarkit.tools.vcfcmp.VcfCompareCallers.java
@Override public Collection<Throwable> call() throws Exception { htsjdk.samtools.util.IntervalTreeMap<Boolean> capture = null; PrintWriter exampleWriter = null; XMLStreamWriter exampleOut = null; PrintStream pw = null; VcfIterator vcfInputs[] = new VcfIterator[] { null, null }; VCFHeader headers[] = new VCFHeader[] { null, null }; final List<String> args = getInputFiles(); try {// w ww .j av a2s . c o m if (args.size() == 1) { LOG.info("Reading from stdin and " + args.get(0)); vcfInputs[0] = VCFUtils.createVcfIteratorStdin(); vcfInputs[1] = VCFUtils.createVcfIterator(args.get(0)); } else if (args.size() == 2) { LOG.info("Reading from stdin and " + args.get(0) + " and " + args.get(1)); vcfInputs[0] = VCFUtils.createVcfIterator(args.get(0)); vcfInputs[1] = VCFUtils.createVcfIterator(args.get(1)); } else { return wrapException(getMessageBundle("illegal.number.of.arguments")); } if (super.captureFile != null) { LOG.info("Reading " + super.captureFile); capture = super.readBedFileAsBooleanIntervalTreeMap(super.captureFile); } for (int i = 0; i < vcfInputs.length; ++i) { headers[i] = vcfInputs[i].getHeader(); } /* dicts */ final SAMSequenceDictionary dict0 = headers[0].getSequenceDictionary(); final SAMSequenceDictionary dict1 = headers[1].getSequenceDictionary(); final Comparator<VariantContext> ctxComparator; if (dict0 == null && dict1 == null) { ctxComparator = VCFUtils.createChromPosRefComparator(); } else if (dict0 != null && dict1 != null) { if (!SequenceUtil.areSequenceDictionariesEqual(dict0, dict1)) { return wrapException(getMessageBundle("not.the.same.sequence.dictionaries")); } ctxComparator = VCFUtils.createTidPosRefComparator(dict0); } else { return wrapException(getMessageBundle("not.the.same.sequence.dictionaries")); } /* samples */ Set<String> samples0 = new HashSet<>(headers[0].getSampleNamesInOrder()); Set<String> samples1 = new HashSet<>(headers[1].getSampleNamesInOrder()); Set<String> samples = new TreeSet<>(samples0); samples.retainAll(samples1); if (samples.size() != samples0.size() || samples.size() != samples1.size()) { LOG.warn("Warning: Not the same samples set. Using intersection of both lists."); } if (samples.isEmpty()) { return wrapException("No common samples"); } Map<String, Counter<Category>> sample2info = new HashMap<String, Counter<Category>>(samples.size()); for (String sampleName : samples) { sample2info.put(sampleName, new Counter<Category>()); } if (super.exampleFile != null) { exampleWriter = new PrintWriter(exampleFile, "UTF-8"); XMLOutputFactory xof = XMLOutputFactory.newFactory(); exampleOut = xof.createXMLStreamWriter(exampleWriter); exampleOut.writeStartDocument("UTF-8", "1.0"); exampleOut.writeStartElement("compare-callers"); } SAMSequenceDictionaryProgress progress = new SAMSequenceDictionaryProgress(dict0); VariantContext buffer[] = new VariantContext[vcfInputs.length]; VariantContext prev[] = new VariantContext[vcfInputs.length]; for (;;) { VariantContext smallest = null; //refill buffer for (int i = 0; i < vcfInputs.length; ++i) { if (buffer[i] == null && vcfInputs[i] != null) { if (vcfInputs[i].hasNext()) { buffer[i] = vcfInputs[i].peek(); /* check data are sorted */ if (prev[i] != null && ctxComparator.compare(prev[i], buffer[i]) > 0) { return wrapException("Input " + (i + 1) + "/2 is not sorted" + (((i == 0 && dict0 == null) || (i == 1 && dict1 == null)) ? "on chrom/pos/ref" : "on sequence dictionary") + ". got\n" + buffer[i] + "\nafter\n" + prev[i]); } } else { vcfInputs[i].close(); vcfInputs[i] = null; } } if (buffer[i] != null) { if (smallest == null || ctxComparator.compare(buffer[i], smallest) < 0) { smallest = buffer[i]; } } } if (smallest == null) break; VariantContext ctx0 = null; VariantContext ctx1 = null; Interval interval = null; if (buffer[0] != null && ctxComparator.compare(buffer[0], smallest) == 0) { prev[0] = progress.watch(vcfInputs[0].next()); ctx0 = prev[0]; buffer[0] = null; interval = new Interval(ctx0.getContig(), ctx0.getStart(), ctx0.getEnd()); } if (buffer[1] != null && ctxComparator.compare(buffer[1], smallest) == 0) { prev[1] = progress.watch(vcfInputs[1].next()); ctx1 = prev[1]; buffer[1] = null; interval = new Interval(ctx1.getContig(), ctx1.getStart(), ctx1.getEnd()); } boolean in_capture = true; if (capture != null && interval != null) { in_capture = capture.containsOverlapping(interval); } for (final String sampleName : sample2info.keySet()) { final Counter<Category> sampleInfo = sample2info.get(sampleName); Genotype g0 = (ctx0 == null ? null : ctx0.getGenotype(sampleName)); Genotype g1 = (ctx1 == null ? null : ctx1.getGenotype(sampleName)); if (g0 != null && (g0.isNoCall() || !g0.isAvailable())) g0 = null; if (g1 != null && (g1.isNoCall() || !g1.isAvailable())) g1 = null; if (g0 == null && g1 == null) { watch(exampleOut, ctx0, ctx1, g0, g1, sampleName, sampleInfo, Category.both_missing); continue; } else if (g0 != null && g1 == null) { if (!in_capture) { watch(exampleOut, ctx0, ctx1, g0, g1, sampleName, sampleInfo, Category.off_target_only_1); continue; } watch(exampleOut, ctx0, ctx1, g0, g1, sampleName, sampleInfo, Category.unique_to_file_1); if (ctx0.isIndel()) { watch(exampleOut, ctx0, ctx1, g0, g1, sampleName, sampleInfo, Category.unique_to_file_1_indel); } else if (ctx0.isSNP()) { watch(exampleOut, ctx0, ctx1, g0, g1, sampleName, sampleInfo, Category.unique_to_file_1_snp); } continue; } else if (g0 == null && g1 != null) { if (!in_capture) { watch(exampleOut, ctx0, ctx1, g0, g1, sampleName, sampleInfo, Category.off_target_only_2); continue; } watch(exampleOut, ctx0, ctx1, g0, g1, sampleName, sampleInfo, Category.unique_to_file_2); if (ctx1.isIndel()) { watch(exampleOut, ctx0, ctx1, g0, g1, sampleName, sampleInfo, Category.unique_to_file_2_indel); } else if (ctx1.isSNP()) { watch(exampleOut, ctx0, ctx1, g0, g1, sampleName, sampleInfo, Category.unique_to_file_2_snp); } continue; } else { if (!in_capture) { watch(exampleOut, ctx0, ctx1, g0, g1, sampleName, sampleInfo, Category.off_target_both); continue; } watch(exampleOut, ctx0, ctx1, g0, g1, sampleName, sampleInfo, Category.common_context); if (ctx0.isIndel() && ctx1.isIndel()) { watch(exampleOut, ctx0, ctx1, g0, g1, sampleName, sampleInfo, Category.common_context_indel); } else if (ctx0.isSNP() && ctx1.isSNP()) { watch(exampleOut, ctx0, ctx1, g0, g1, sampleName, sampleInfo, Category.common_context_snp); } if ((ctx0.hasID() && !ctx1.hasID()) || (!ctx0.hasID() && ctx1.hasID()) || (ctx0.hasID() && ctx1.hasID() && !ctx0.getID().equals(ctx1.getID()))) { watch(exampleOut, ctx0, ctx1, g0, g1, sampleName, sampleInfo, Category.common_context_discordant_id); } if (g0.sameGenotype(g1)) { watch(exampleOut, ctx0, ctx1, g0, g1, sampleName, sampleInfo, Category.called_and_same); if (g0.isHomRef()) { watch(exampleOut, ctx0, ctx1, g0, g1, sampleName, sampleInfo, Category.called_and_same_hom_ref); } if (g0.isHomVar()) { watch(exampleOut, ctx0, ctx1, g0, g1, sampleName, sampleInfo, Category.called_and_same_hom_var); } else if (g0.isHet()) { watch(exampleOut, ctx0, ctx1, g0, g1, sampleName, sampleInfo, Category.called_and_same_het); } } else { watch(exampleOut, ctx0, ctx1, g0, g1, sampleName, sampleInfo, Category.called_but_discordant); if (g0.isHom() && g1.isHet()) { watch(exampleOut, ctx0, ctx1, g0, g1, sampleName, sampleInfo, Category.called_but_discordant_hom1_het2); } else if (g0.isHet() && g1.isHom()) { watch(exampleOut, ctx0, ctx1, g0, g1, sampleName, sampleInfo, Category.called_but_discordant_het1_hom2); } else if (g0.isHom() && g1.isHom()) { watch(exampleOut, ctx0, ctx1, g0, g1, sampleName, sampleInfo, Category.called_but_discordant_hom1_hom2); } else if (g0.isHet() && g1.isHet()) { watch(exampleOut, ctx0, ctx1, g0, g1, sampleName, sampleInfo, Category.called_but_discordant_het1_het2); } else { watch(exampleOut, ctx0, ctx1, g0, g1, sampleName, sampleInfo, Category.called_but_discordant_others); } } } } } progress.finish(); pw = openFileOrStdoutAsPrintStream(); pw.print("#Sample"); for (Category c : Category.values()) { pw.print('\t'); pw.print(c.name()); } pw.println(); for (String sample : sample2info.keySet()) { Counter<Category> count = sample2info.get(sample); pw.print(sample); for (Category c : Category.values()) { pw.print('\t'); pw.print(count.count(c)); } pw.println(); if (pw.checkError()) break; } pw.flush(); if (exampleOut != null) { exampleOut.writeEndElement(); exampleOut.writeEndDocument(); exampleOut.flush(); exampleOut.close(); } return RETURN_OK; } catch (Exception err) { return wrapException(err); } finally { if (getOutputFile() != null) CloserUtil.close(pw); CloserUtil.close(exampleWriter); } }
From source file:org.openmrs.module.sync.api.db.hibernate.HibernateSyncDAO.java
public void exportChildDB(String uuidForChild, OutputStream os) throws DAOException { PrintStream out = new PrintStream(os); Set<String> tablesToSkip = new HashSet<String>(); {/*w w w. j a v a 2 s . c o m*/ tablesToSkip.add("hl7_in_archive"); tablesToSkip.add("hl7_in_queue"); tablesToSkip.add("hl7_in_error"); tablesToSkip.add("formentry_archive"); tablesToSkip.add("formentry_queue"); tablesToSkip.add("formentry_error"); tablesToSkip.add("sync_class"); tablesToSkip.add("sync_import"); tablesToSkip.add("sync_record"); tablesToSkip.add("sync_server"); tablesToSkip.add("sync_server_class"); tablesToSkip.add("sync_server_record"); // TODO: figure out which other tables to skip // tablesToSkip.add("obs"); // tablesToSkip.add("concept"); // tablesToSkip.add("patient"); } List<String> tablesToDump = new ArrayList<String>(); Session session = sessionFactory.getCurrentSession(); String schema = (String) session.createSQLQuery("SELECT schema()").uniqueResult(); log.warn("schema: " + schema); // Get all tables that we'll need to dump { Query query = session.createSQLQuery( "SELECT tabs.table_name FROM INFORMATION_SCHEMA.TABLES tabs WHERE tabs.table_schema = '" + schema + "'"); for (Object tn : query.list()) { String tableName = (String) tn; if (!tablesToSkip.contains(tableName.toLowerCase())) tablesToDump.add(tableName); } } log.warn("tables to dump: " + tablesToDump); String thisServerGuid = getGlobalProperty(SyncConstants.PROPERTY_SERVER_UUID); // Write the DDL Header as mysqldump does { out.println("-- ------------------------------------------------------"); out.println("-- Database dump to create an openmrs child server"); out.println("-- Schema: " + schema); out.println("-- Parent GUID: " + thisServerGuid); out.println("-- Parent version: " + OpenmrsConstants.OPENMRS_VERSION); out.println("-- ------------------------------------------------------"); out.println(""); out.println("/*!40101 SET CHARACTER_SET_CLIENT=utf8 */;"); out.println("/*!40101 SET NAMES utf8 */;"); out.println("/*!40103 SET TIME_ZONE='+00:00' */;"); out.println("/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;"); out.println("/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;"); out.println("/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;"); out.println("/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;"); out.println("/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;"); out.println("/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;"); out.println("/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;"); out.println("/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;"); out.println(""); } try { // JDBC way of doing this // Connection conn = // DriverManager.getConnection("jdbc:mysql://localhost/" + schema, // "test", "test"); Connection conn = sessionFactory.getCurrentSession().connection(); try { Statement st = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); // Get the create database statement ResultSet rs = st.executeQuery("SHOW CREATE DATABASE " + schema); for (String tableName : tablesToDump) { out.println(); out.println("--"); out.println("-- Table structure for table `" + tableName + "`"); out.println("--"); out.println("DROP TABLE IF EXISTS `" + tableName + "`;"); out.println("SET @saved_cs_client = @@character_set_client;"); out.println("SET character_set_client = utf8;"); rs = st.executeQuery("SHOW CREATE TABLE " + tableName); while (rs.next()) { out.println(rs.getString("Create Table") + ";"); } out.println("SET character_set_client = @saved_cs_client;"); out.println(); { out.println("-- Dumping data for table `" + tableName + "`"); out.println("LOCK TABLES `" + tableName + "` WRITE;"); out.println("/*!40000 ALTER TABLE `" + tableName + "` DISABLE KEYS */;"); boolean first = true; rs = st.executeQuery("select * from " + tableName); ResultSetMetaData md = rs.getMetaData(); int numColumns = md.getColumnCount(); int rowNum = 0; boolean insert = false; while (rs.next()) { if (rowNum == 0) { insert = true; out.print("INSERT INTO `" + tableName + "` VALUES "); } ++rowNum; if (first) { first = false; } else { out.print(", "); } if (rowNum % 20 == 0) { out.println(); } out.print("("); for (int i = 1; i <= numColumns; ++i) { if (i != 1) { out.print(","); } if (rs.getObject(i) == null) { out.print("NULL"); } else { switch (md.getColumnType(i)) { case Types.VARCHAR: case Types.CHAR: case Types.LONGVARCHAR: out.print("'"); out.print( rs.getString(i).replaceAll("\n", "\\\\n").replaceAll("'", "\\\\'")); out.print("'"); break; case Types.BIGINT: case Types.DECIMAL: case Types.NUMERIC: out.print(rs.getBigDecimal(i)); break; case Types.BIT: out.print(rs.getBoolean(i)); break; case Types.INTEGER: case Types.SMALLINT: case Types.TINYINT: out.print(rs.getInt(i)); break; case Types.REAL: case Types.FLOAT: case Types.DOUBLE: out.print(rs.getDouble(i)); break; case Types.BLOB: case Types.VARBINARY: case Types.LONGVARBINARY: Blob blob = rs.getBlob(i); out.print("'"); InputStream in = blob.getBinaryStream(); while (true) { int b = in.read(); if (b < 0) { break; } char c = (char) b; if (c == '\'') { out.print("\'"); } else { out.print(c); } } out.print("'"); break; case Types.CLOB: out.print("'"); out.print( rs.getString(i).replaceAll("\n", "\\\\n").replaceAll("'", "\\\\'")); out.print("'"); break; case Types.DATE: out.print("'" + rs.getDate(i) + "'"); break; case Types.TIMESTAMP: out.print("'" + rs.getTimestamp(i) + "'"); break; default: throw new RuntimeException("TODO: handle type code " + md.getColumnType(i) + " (name " + md.getColumnTypeName(i) + ")"); } } } out.print(")"); } if (insert) { out.println(";"); insert = false; } out.println("/*!40000 ALTER TABLE `" + tableName + "` ENABLE KEYS */;"); out.println("UNLOCK TABLES;"); out.println(); } } } finally { conn.close(); } // Now we mark this as a child out.println("-- Now mark this as a child database"); if (uuidForChild == null) uuidForChild = SyncUtil.generateUuid(); out.println("update global_property set property_value = '" + uuidForChild + "' where property = '" + SyncConstants.PROPERTY_SERVER_UUID + "';"); // Write the footer of the DDL script { out.println("/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;"); out.println("/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;"); out.println("/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;"); out.println("/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;"); out.println("/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;"); out.println("/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;"); out.println("/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;"); out.println("/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;"); } out.flush(); out.close(); } catch (IOException ex) { log.error("IOException", ex); } catch (SQLException ex) { log.error("SQLException", ex); } }
From source file:org.talend.esb.job.api.test.TestConsumerJob.java
public void tFixedFlowInput_1Process(final java.util.Map<String, Object> globalMap) throws TalendException { globalMap.put("tFixedFlowInput_1_SUBPROCESS_STATE", 0); final boolean execStat = this.execStat; String iterateId = ""; String currentComponent = ""; try {//from w w w. j a v a 2 s .c om String currentMethodName = new Exception().getStackTrace()[0].getMethodName(); boolean resumeIt = currentMethodName.equals(resumeEntryMethodName); if (resumeEntryMethodName == null || resumeIt || globalResumeTicket) {// start // the // resume globalResumeTicket = true; row1Struct row1 = new row1Struct(); row2Struct row2 = new row2Struct(); row3Struct row3 = new row3Struct(); row5Struct row5 = new row5Struct(); row4Struct row4 = new row4Struct(); row6Struct row6 = new row6Struct(); /** * [tLogRow_1 begin ] start */ ok_Hash.put("tLogRow_1", false); start_Hash.put("tLogRow_1", System.currentTimeMillis()); currentComponent = "tLogRow_1"; int tos_count_tLogRow_1 = 0; // ///////////////////// final String OUTPUT_FIELD_SEPARATOR_tLogRow_1 = "|"; java.io.PrintStream consoleOut_tLogRow_1 = null; int nb_line_tLogRow_1 = 0; // ///////////////////// /** * [tLogRow_1 begin ] stop */ /** * [tJavaFlex_2 begin ] start */ ok_Hash.put("tJavaFlex_2", false); start_Hash.put("tJavaFlex_2", System.currentTimeMillis()); currentComponent = "tJavaFlex_2"; int tos_count_tJavaFlex_2 = 0; // start part of your Java code /** * [tJavaFlex_2 begin ] stop */ /** * [tLogRow_2 begin ] start */ ok_Hash.put("tLogRow_2", false); start_Hash.put("tLogRow_2", System.currentTimeMillis()); currentComponent = "tLogRow_2"; int tos_count_tLogRow_2 = 0; // ///////////////////// final String OUTPUT_FIELD_SEPARATOR_tLogRow_2 = "|"; java.io.PrintStream consoleOut_tLogRow_2 = null; int nb_line_tLogRow_2 = 0; // ///////////////////// /** * [tLogRow_2 begin ] stop */ /** * [tJavaFlex_3 begin ] start */ ok_Hash.put("tJavaFlex_3", false); start_Hash.put("tJavaFlex_3", System.currentTimeMillis()); currentComponent = "tJavaFlex_3"; int tos_count_tJavaFlex_3 = 0; // start part of your Java code /** * [tJavaFlex_3 begin ] stop */ /** * [tESBConsumer_1 begin ] start */ ok_Hash.put("tESBConsumer_1", false); start_Hash.put("tESBConsumer_1", System.currentTimeMillis()); currentComponent = "tESBConsumer_1"; int tos_count_tESBConsumer_1 = 0; javax.xml.namespace.QName serviceName_tESBConsumer_1 = null; javax.xml.namespace.QName portName_tESBConsumer_1 = null; // [TA] commented run in TOS part due to external dependencies :: begin // org.talend.ws.helper.ServiceInvokerHelper serviceInvokerHelper_tESBConsumer_1 = null; // [TA] commented run in TOS part due to external dependencies :: end ESBConsumer consumer_tESBConsumer_1 = null; if (registry != null) { consumer_tESBConsumer_1 = registry.createConsumer(new ESBEndpointInfo() { @SuppressWarnings("serial") private java.util.Map<String, Object> props = new java.util.HashMap<String, Object>() { { put("wsdlURL", "http://www.deeptraining.com/webservices/weather.asmx?WSDL"); put("dataFormat", "PAYLOAD"); put("portName", "{}"); put("serviceName", "{}"); put("defaultOperationName", ""); put("defaultOperationNameSpace", ""); } }; public String getEndpointUri() { // projectName + "_" + processName + "_" + // componentName return "TEST_FakeESBJob_tESBConsumer_1"; } public java.util.Map<String, Object> getEndpointProperties() { return props; } public String getEndpointKey() { return "cxf"; } }); } else { System.out.println(""); System.out.println(""); System.out.println("|"); class Util_tESBConsumer_1 { public final String LIST_SIZE_SYMBOL = ".size"; public final String LEFT_SQUARE_BRACKET = "["; public final String RIGHT_SQUARE_BRACKET = "]"; public final String ALL_LIST_SYMBOL = "[*]"; public Object getValue(java.util.Map<String, Object> map, String path) { if (path == null || "".equals(path)) { return null; } if (map == null || map.isEmpty()) { return null; } java.util.List<String> paths = new java.util.ArrayList<String>(); resolvePath(map, path, paths); if (paths.size() > 0) { if (path.indexOf(ALL_LIST_SYMBOL) == -1) { return map.get(paths.get(0)); } else { int size = paths.size(); java.util.List<Object> out = new java.util.ArrayList<Object>(size); for (int i = 0; i < size; i++) { out.add(map.get(paths.get(i))); } return out; } } else { return null; } } public void resolveInputPath(java.util.Map<String, Object> inputMap) { java.util.Map<String, Object> tempStoreMap = new java.util.HashMap<String, Object>(); java.util.List<String> tempRemovePath = new java.util.ArrayList<String>(); for (String key : inputMap.keySet()) { if (key.indexOf(ALL_LIST_SYMBOL) != -1) { String listHeadPath = key.substring(0, key.indexOf(ALL_LIST_SYMBOL)); String listFootPath = key .substring(key.indexOf(ALL_LIST_SYMBOL) + ALL_LIST_SYMBOL.length()); java.util.List listElement = (java.util.List) inputMap.get(key); for (int i = 0; i < listElement.size(); i++) { tempStoreMap.put(listHeadPath + LEFT_SQUARE_BRACKET + i + RIGHT_SQUARE_BRACKET + listFootPath, listElement.get(i)); } tempRemovePath.add(key); } } inputMap.putAll(tempStoreMap); for (String removePath : tempRemovePath) { inputMap.remove(removePath); } } public void resolvePath(java.util.Map<String, Object> map, String path, java.util.List<String> paths) { String listHeadPath = ""; String listFootPath = ""; int size = 0; String tempPath = ""; if (path.indexOf(ALL_LIST_SYMBOL) != -1) { listHeadPath = path.substring(0, path.indexOf(ALL_LIST_SYMBOL)); listFootPath = path .substring(path.indexOf(ALL_LIST_SYMBOL) + ALL_LIST_SYMBOL.length()); if (map.get(listHeadPath) == null && map.get(listHeadPath + LIST_SIZE_SYMBOL) != null) { size = Integer.parseInt(map.get(listHeadPath + LIST_SIZE_SYMBOL).toString()); for (int i = 0; i < size; i++) { tempPath = listHeadPath + LEFT_SQUARE_BRACKET + i + RIGHT_SQUARE_BRACKET + listFootPath; if (tempPath.indexOf(ALL_LIST_SYMBOL) != -1) { resolvePath(map, tempPath, paths); } else { paths.add(tempPath); } } } } else { paths.add(path); } } public java.util.List<Object> normalize(String inputValue, String delimiter) { if (inputValue == null || "".equals(inputValue)) { return null; } Object[] inputValues = inputValue.split(delimiter); return java.util.Arrays.asList(inputValues); } public String denormalize(java.util.List inputValues, String delimiter) { if (inputValues == null || inputValues.isEmpty()) { return null; } StringBuffer sb = new StringBuffer(); for (Object o : inputValues) { sb.append(String.valueOf(o)); sb.append(delimiter); } if (sb.length() > 0) { sb.delete(sb.length() - delimiter.length(), sb.length()); } return sb.toString(); } } // [TA] commented run in TOS part due to external dependencies :: begin // System.setProperty("org.apache.commons.logging.Log", // "org.apache.commons.logging.impl.NoOpLog"); // // shade the log level for DynamicClientFactory.class // java.util.logging.Logger LOG_tESBConsumer_1 = org.apache.cxf.common.logging.LogUtils // .getL7dLogger(org.apache.cxf.endpoint.dynamic.DynamicClientFactory.class); // LOG_tESBConsumer_1 // .setLevel(java.util.logging.Level.WARNING); // // Util_tESBConsumer_1 util_tESBConsumer_1 = new Util_tESBConsumer_1(); // // org.talend.ws.helper.conf.ServiceHelperConfiguration config_tESBConsumer_1 = // new org.talend.ws.helper.conf.ServiceHelperConfiguration(); // // config_tESBConsumer_1.setConnectionTimeout(Long // .valueOf(20000)); // config_tESBConsumer_1 // .setReceiveTimeout(Long.valueOf(20000)); // // config_tESBConsumer_1.setKeyStoreFile(System // .getProperty("javax.net.ssl.keyStore")); // config_tESBConsumer_1.setKeyStoreType(System // .getProperty("javax.net.ssl.keyStoreType")); // config_tESBConsumer_1.setKeyStorePwd(System // .getProperty("javax.net.ssl.keyStorePassword")); // org.talend.ws.helper.ServiceDiscoveryHelper serviceDiscoveryHelper_tESBConsumer_1 = null; // // java.net.URI uri_tESBConsumer_1 = new java.net.URI( // "http://www.deeptraining.com/webservices/weather.asmx?WSDL"); // if ("http".equals(uri_tESBConsumer_1.getScheme()) // || "https".equals(uri_tESBConsumer_1.getScheme())) { // serviceInvokerHelper_tESBConsumer_1 = new org.talend.ws.helper.ServiceInvokerHelper( // "http://www.deeptraining.com/webservices/weather.asmx?WSDL", // config_tESBConsumer_1, ""); // } else { // serviceDiscoveryHelper_tESBConsumer_1 = new org.talend.ws.helper.ServiceDiscoveryHelper( // "http://www.deeptraining.com/webservices/weather.asmx?WSDL", // ""); // serviceInvokerHelper_tESBConsumer_1 = new org.talend.ws.helper.ServiceInvokerHelper( // serviceDiscoveryHelper_tESBConsumer_1, // config_tESBConsumer_1); // } // // serviceName_tESBConsumer_1 = new javax.xml.namespace.QName( // "", ""); // portName_tESBConsumer_1 = new javax.xml.namespace.QName("", // ""); // // java.util.Map<String, Object> inMap_tESBConsumer_1 = null; // [TA] commented run in TOS part due to external dependencies :: end } /** * [tESBConsumer_1 begin ] stop */ /** * [tJavaFlex_1 begin ] start */ ok_Hash.put("tJavaFlex_1", false); start_Hash.put("tJavaFlex_1", System.currentTimeMillis()); currentComponent = "tJavaFlex_1"; int tos_count_tJavaFlex_1 = 0; // start part of your Java code /** * [tJavaFlex_1 begin ] stop */ /** * [tFixedFlowInput_1 begin ] start */ ok_Hash.put("tFixedFlowInput_1", false); start_Hash.put("tFixedFlowInput_1", System.currentTimeMillis()); currentComponent = "tFixedFlowInput_1"; int tos_count_tFixedFlowInput_1 = 0; globalMap.put("NB_LINE", 1); for (int i_tFixedFlowInput_1 = 0; i_tFixedFlowInput_1 < 1; i_tFixedFlowInput_1++) { // row1.payloadString = "<request>hi</request>"; row1.payloadString = "<GetWeather xmlns='http://litwinconsulting.com/webservices/'><City>bonn</City></GetWeather>"; /** * [tFixedFlowInput_1 begin ] stop */ /** * [tFixedFlowInput_1 main ] start */ currentComponent = "tFixedFlowInput_1"; tos_count_tFixedFlowInput_1++; /** * [tFixedFlowInput_1 main ] stop */ /** * [tJavaFlex_1 main ] start */ currentComponent = "tJavaFlex_1"; // here is the main part of the component, // a piece of code executed in the row // loop org.dom4j.Document doc = org.dom4j.DocumentHelper.parseText(row1.payloadString); Document talendDoc = new Document(); talendDoc.setDocument(doc); row2.payload = talendDoc; tos_count_tJavaFlex_1++; /** * [tJavaFlex_1 main ] stop */ /** * [tESBConsumer_1 main ] start */ currentComponent = "tESBConsumer_1"; row3 = null; row4 = null; org.dom4j.Document responseDoc_tESBConsumer_1 = null; try { Document requestTalendDoc = row2.payload; if (consumer_tESBConsumer_1 == null) { // [TA] commented run in TOS part due to external dependencies :: begin // try { // responseDoc_tESBConsumer_1 = serviceInvokerHelper_tESBConsumer_1 // .invoke(serviceName_tESBConsumer_1, // portName_tESBConsumer_1, "", // requestTalendDoc.getDocument()); // } catch (javax.xml.ws.soap.SOAPFaultException e) { // String faultString = e.getFault() // .getFaultString(); // Document faultTalendDoc = null; // if (null != e.getFault().getDetail() // && null != e.getFault().getDetail() // .getFirstChild()) { // try { // javax.xml.transform.Source faultSource = new javax.xml.transform.dom.DOMSource( // e.getFault().getDetail() // .getFirstChild()); // // org.dom4j.io.DocumentResult result = new org.dom4j.io.DocumentResult(); // javax.xml.transform.TransformerFactory // .newInstance().newTransformer() // .transform(faultSource, result); // org.dom4j.Document faultDoc = result // .getDocument(); // // faultTalendDoc = new Document(); // faultTalendDoc.setDocument(faultDoc); // } catch (Exception e1) { // e1.printStackTrace(); // } // } // if (row4 == null) { // row4 = new row4Struct(); // } // row4.faultString = faultString; // row4.faultDetail = faultTalendDoc; // } // [TA] commented run in TOS part due to external dependencies :: end } else { try { responseDoc_tESBConsumer_1 = (org.dom4j.Document) consumer_tESBConsumer_1 .invoke(requestTalendDoc.getDocument()); } catch (Exception e) { String faultMessage = e.getMessage(); if (row4 == null) { row4 = new row4Struct(); } row4.faultString = faultMessage; row4.faultDetail = null; } } } catch (Exception e) { throw (e); } if (null != responseDoc_tESBConsumer_1) { if (row3 == null) { row3 = new row3Struct(); } Document responseTalendDoc_tESBConsumer_1 = new Document(); responseTalendDoc_tESBConsumer_1.setDocument(responseDoc_tESBConsumer_1); row3.payload = responseTalendDoc_tESBConsumer_1; } tos_count_tESBConsumer_1++; /** * [tESBConsumer_1 main ] stop */ // Start of branch "row3" if (row3 != null) { /** * [tJavaFlex_2 main ] start */ currentComponent = "tJavaFlex_2"; // here is the main part of the component, // a piece of code executed in the row // loop row5.payloadString = row3.payload.getDocument().asXML(); tos_count_tJavaFlex_2++; /** * [tJavaFlex_2 main ] stop */ /** * [tLogRow_1 main ] start */ currentComponent = "tLogRow_1"; // ///////////////////// StringBuilder strBuffer_tLogRow_1 = new StringBuilder(); strBuffer_tLogRow_1.append("[tLogRow_1] "); if (row5.payloadString != null) { // strBuffer_tLogRow_1.append(String.valueOf(row5.payloadString)); } // if (globalMap.get("tLogRow_CONSOLE") != null) { consoleOut_tLogRow_1 = (java.io.PrintStream) globalMap.get("tLogRow_CONSOLE"); } else { consoleOut_tLogRow_1 = new java.io.PrintStream( new java.io.BufferedOutputStream(System.out)); globalMap.put("tLogRow_CONSOLE", consoleOut_tLogRow_1); } consoleOut_tLogRow_1.println(strBuffer_tLogRow_1.toString()); consoleOut_tLogRow_1.flush(); nb_line_tLogRow_1++; // //// // //// // ///////////////////// tos_count_tLogRow_1++; /** * [tLogRow_1 main ] stop */ } // End of branch "row3" // Start of branch "row4" if (row4 != null) { /** * [tJavaFlex_3 main ] start */ currentComponent = "tJavaFlex_3"; row6.faultString = row4.faultString; // here is the main part of the component, // a piece of code executed in the row // loop // row6.faultString = row4.faultString; if (null != row4.faultDetail) { row6.faultDetailString = row4.faultDetail.getDocument().asXML(); } tos_count_tJavaFlex_3++; /** * [tJavaFlex_3 main ] stop */ /** * [tLogRow_2 main ] start */ currentComponent = "tLogRow_2"; // ///////////////////// StringBuilder strBuffer_tLogRow_2 = new StringBuilder(); strBuffer_tLogRow_2.append("[tLogRow_2] "); if (row6.faultString != null) { // strBuffer_tLogRow_2.append(String.valueOf(row6.faultString)); } // strBuffer_tLogRow_2.append("|"); if (row6.faultDetailString != null) { // strBuffer_tLogRow_2.append(String.valueOf(row6.faultDetailString)); } // if (globalMap.get("tLogRow_CONSOLE") != null) { consoleOut_tLogRow_2 = (java.io.PrintStream) globalMap.get("tLogRow_CONSOLE"); } else { consoleOut_tLogRow_2 = new java.io.PrintStream( new java.io.BufferedOutputStream(System.out)); globalMap.put("tLogRow_CONSOLE", consoleOut_tLogRow_2); } consoleOut_tLogRow_2.println(strBuffer_tLogRow_2.toString()); consoleOut_tLogRow_2.flush(); nb_line_tLogRow_2++; // //// // //// // ///////////////////// tos_count_tLogRow_2++; /** * [tLogRow_2 main ] stop */ } // End of branch "row4" /** * [tFixedFlowInput_1 end ] start */ currentComponent = "tFixedFlowInput_1"; } ok_Hash.put("tFixedFlowInput_1", true); end_Hash.put("tFixedFlowInput_1", System.currentTimeMillis()); /** * [tFixedFlowInput_1 end ] stop */ /** * [tJavaFlex_1 end ] start */ currentComponent = "tJavaFlex_1"; // end of the component, outside/closing the loop ok_Hash.put("tJavaFlex_1", true); end_Hash.put("tJavaFlex_1", System.currentTimeMillis()); /** * [tJavaFlex_1 end ] stop */ /** * [tESBConsumer_1 end ] start */ currentComponent = "tESBConsumer_1"; ok_Hash.put("tESBConsumer_1", true); end_Hash.put("tESBConsumer_1", System.currentTimeMillis()); /** * [tESBConsumer_1 end ] stop */ /** * [tJavaFlex_2 end ] start */ currentComponent = "tJavaFlex_2"; // end of the component, outside/closing the loop ok_Hash.put("tJavaFlex_2", true); end_Hash.put("tJavaFlex_2", System.currentTimeMillis()); /** * [tJavaFlex_2 end ] stop */ /** * [tLogRow_1 end ] start */ currentComponent = "tLogRow_1"; // //// // //// globalMap.put("tLogRow_1_NB_LINE", nb_line_tLogRow_1); // ///////////////////// ok_Hash.put("tLogRow_1", true); end_Hash.put("tLogRow_1", System.currentTimeMillis()); /** * [tLogRow_1 end ] stop */ /** * [tJavaFlex_3 end ] start */ currentComponent = "tJavaFlex_3"; // end of the component, outside/closing the loop ok_Hash.put("tJavaFlex_3", true); end_Hash.put("tJavaFlex_3", System.currentTimeMillis()); /** * [tJavaFlex_3 end ] stop */ /** * [tLogRow_2 end ] start */ currentComponent = "tLogRow_2"; // //// // //// globalMap.put("tLogRow_2_NB_LINE", nb_line_tLogRow_2); // ///////////////////// ok_Hash.put("tLogRow_2", true); end_Hash.put("tLogRow_2", System.currentTimeMillis()); /** * [tLogRow_2 end ] stop */ } // end the resume } catch (Exception e) { throw new TalendException(e, currentComponent, globalMap); } catch (Error error) { throw new Error(error); } globalMap.put("tFixedFlowInput_1_SUBPROCESS_STATE", 1); }