List of usage examples for java.lang Exception getStackTrace
public StackTraceElement[] getStackTrace()
From source file:com.ibm.bi.dml.test.integration.AutomatedTestBase.java
/** * Runs an R script in the old or the new way */// ww w . j a v a 2 s . com protected void runRScript(boolean newWay) { String executionFile = sourceDirectory + selectedTest + ".R"; // *** HACK ALERT *** HACK ALERT *** HACK ALERT *** // Some of the R scripts will fail if the "expected" directory doesn't exist. // Make sure the directory exists. File expectedDir = new File(baseDirectory, "expected" + "/" + cacheDir); expectedDir.mkdirs(); // *** END HACK *** String cmd; if (!newWay) { executionFile = executionFile + "t"; cmd = "R -f " + executionFile; } else { // *** HACK ALERT *** HACK ALERT *** HACK ALERT *** // Rscript does *not* load the "methods" package by default // to save on start time. The "Matrix" package used in the // tests requires the "methods" package and should still // load and attach it, but in R 3.2 with the latest version // of the "Matrix" package, "methods" is loaded *but not // attached* when run with Rscript. Therefore, we need to // explicitly load it with Rscript. cmd = rCmd.replaceFirst("Rscript", "Rscript --default-packages=methods,datasets,graphics,grDevices,stats,utils"); // *** END HACK *** } if (System.getProperty("os.name").contains("Windows")) { cmd = cmd.replace('/', '\\'); executionFile = executionFile.replace('/', '\\'); } if (DEBUG) { if (!newWay) { // not sure why have this condition TestUtils.printRScript(executionFile); } } if (!newWay) { ParameterBuilder.setVariablesInScript(sourceDirectory, selectedTest + ".R", testVariables); } if (cacheDir.length() > 0) { File expectedFile = null; String[] outputFiles = null; TestConfiguration testConfig = getTestConfiguration(selectedTest); if (testConfig != null) { outputFiles = testConfig.getOutputFiles(); } if (outputFiles != null && outputFiles.length > 0) { expectedFile = new File(expectedDir.getPath() + "/" + outputFiles[0]); if (expectedFile.canRead()) { System.out.println("Skipping R script cmd: " + cmd); return; } } } try { long t0 = System.nanoTime(); System.out.println("starting R script"); System.out.println("cmd: " + cmd); Process child = Runtime.getRuntime().exec(cmd); String outputR = IOUtils.toString(child.getInputStream()); System.out.println("Standard Output from R:" + outputR); String errorString = IOUtils.toString(child.getErrorStream()); System.err.println("Standard Error from R:" + errorString); // // To give any stream enough time to print all data, otherwise there // are situations where the test case fails, even before everything // has been printed // child.waitFor(); // Thread.sleep(30000); try { if (child.exitValue() != 0) { throw new Exception( "ERROR: R has ended irregularly\n" + outputR + "\nscript file: " + executionFile); } } catch (IllegalThreadStateException ie) { // // In UNIX JVM does not seem to be able to close threads // correctly. However, give it a try, since R processed the // script, therefore we can terminate the process. // child.destroy(); } long t1 = System.nanoTime(); System.out.println("R is finished (in " + ((double) t1 - t0) / 1000000000 + " sec)"); } catch (Exception e) { e.printStackTrace(); StringBuilder errorMessage = new StringBuilder(); errorMessage.append("failed to run script " + executionFile); errorMessage.append("\nexception: " + e.toString()); errorMessage.append("\nmessage: " + e.getMessage()); errorMessage.append("\nstack trace:"); for (StackTraceElement ste : e.getStackTrace()) { errorMessage.append("\n>" + ste); } fail(errorMessage.toString()); } }
From source file:base.BasePlayer.BedTable.java
void drawScreen2(Graphics g) { buf.setColor(Color.black);//from w w w.ja va 2 s . co m buf.fillRect(0, 0, this.getWidth(), this.getHeight()); //Header Draw if (aminoarray.size() > 0) { samplecount = 0; genemutcount = 0; for (int i = 0; i < aminoarray.size(); i++) { if ((i + 1) * rowHeight < tablescroll.getVerticalScrollBar().getValue()) { continue; } if (i * rowHeight > tablescroll.getVerticalScrollBar().getValue() + this.getHeight()) { break; } /*if(mouseY >= (rowHeight*(i+samplecount+1)) && mouseY < (rowHeight*(i+samplecount+2))) { hoverNode = aminoarray.get(i).getNode(); hoverString = aminoarray.get(i).getRow(); }*/ for (int j = 0; j < aminoarray.get(i).getRow().length; j++) { try { // buf.setColor(Color.gray); // buf.drawLine(this.getWidth()/header.length*(j+1), rowHeight, this.getWidth()/header.length*(j+1), this.getHeight()); if (selectedNode != null && selectedNode.equals(aminoarray.get(i).getNode())) { // samplecount = selectedNode.getSamples().size(); /* buf.setColor(Color.black); buf.fillRect(this.getWidth()/header.length*j, ((rowHeight)*((i+1)+samplecount))+2-tablescroll.getVerticalScrollBar().getValue(), this.getWidth()/header.length, rowHeight); buf.setColor(Color.darkGray); buf.drawRect(this.getWidth()/header.length*j, ((rowHeight)*((i+1)+samplecount))+2-tablescroll.getVerticalScrollBar().getValue(), this.getWidth()/header.length, rowHeight); */ buf.setColor(Color.yellow); if (j < 2) { buf.drawString(aminoarray.get(i).getRow()[j], 10 + this.getWidth() / header.length * j, (rowHeight * (i + 1)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else { buf.setColor(Color.yellow); for (int s = 0; s < samplecount; s++) { if (j == 2) { buf.setColor(Color.yellow); // buf.drawString(selectedNode.getSamples().get(s).getSample().getName(), 10, (rowHeight*(i+s+2))-tablescroll.getVerticalScrollBar().getValue()+rowHeight); } buf.setColor(Color.black); buf.fillRect(this.getWidth() / header.length * j, ((rowHeight) * ((i + s + 2))) + 2 - tablescroll.getVerticalScrollBar().getValue(), this.getWidth() / header.length + 1, rowHeight); buf.setColor(Color.yellow); buf.drawString(aminoarray.get(i).getRow()[j], 10 + this.getWidth() / header.length * j, (rowHeight * ((i + s + 2))) + 2 - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } } /* for(int s = 0; s<samplecount; s++) { buf.setColor(Color.black); buf.fillRect(this.getWidth()/header.length*j, ((rowHeight)*((i+1)+samplecount))+2-tablescroll.getVerticalScrollBar().getValue(), this.getWidth()/header.length+1, rowHeight); buf.setColor(Color.yellow); buf.drawString(aminoarray.get(i).getRow()[j], 10+this.getWidth()/header.length*j, (rowHeight*((i+1)+samplecount))-tablescroll.getVerticalScrollBar().getValue()+rowHeight); buf.drawString(selectedNode.getSamples().get(s).getSample().getName(), 10, (rowHeight*(i+s+2))-tablescroll.getVerticalScrollBar().getValue()+rowHeight); } */ } else { buf.setColor(Color.black); buf.fillRect(this.getWidth() / header.length * j, ((rowHeight) * ((i + 1) + samplecount)) + 2 - tablescroll.getVerticalScrollBar().getValue(), this.getWidth() / header.length, rowHeight); buf.setColor(Color.darkGray); buf.drawRect(this.getWidth() / header.length * j, ((rowHeight) * ((i + 1) + samplecount)) + 2 - tablescroll.getVerticalScrollBar().getValue(), this.getWidth() / header.length, rowHeight); if (hoverNode != null && hoverNode.equals(aminoarray.get(i).getNode())) { buf.setColor(Color.yellow); } else { buf.setColor(Color.white); } buf.drawString(aminoarray.get(i).getRow()[j], 10 + this.getWidth() / header.length * j, (rowHeight * ((i + 1) + samplecount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } } catch (Exception e) { e.printStackTrace(); ErrorLog.addError(e.getStackTrace()); } } } } for (int i = 0; i < header.length; i++) { buf.setColor(Color.darkGray); buf.fillRect(i * this.getWidth() / header.length, 0, this.getWidth() / header.length + 1, rowHeight); buf.setColor(Color.white); buf.drawString(header[i], i * this.getWidth() / header.length + 4, rowHeight - 2); buf.setColor(Color.black); buf.drawLine(i * this.getWidth() / header.length, 0, i * this.getWidth() / header.length, rowHeight); } g.drawImage(bufImage, 0, tablescroll.getVerticalScrollBar().getValue(), null); }
From source file:eu.brokeratcloud.fpr.model.DivaRoot.java
public List<String> getRecommQuery_old(String consumer, List<String> srvs) { List<String> result = new ArrayList<String>(); Set<String> requirements = new HashSet<String>(); ServiceDependencySparql dc = new ServiceDependencySparql(); for (Dimension dim : root.getDimension()) { if (!"FC".equals(dim.getId())) { // boolean found = false; // dim.setUpper(1); // for(String s : srvs){ // if(dim.getId().startsWith(s)) // dim.setUpper(1); // }// ww w . j a v a 2 s. co m continue; } for (Variant v : dim.getVariant()) { String fc = v.getId(); for (String dep : dc.getDependency(fc)) { for (String input : srvs) { if (input.equals(dep)) requirements.addAll(dc.getRequirement(fc)); } } } } Context ctx = root.getSimulation().getScenario().get(0).getContext().get(0); ctx.getVariable().clear(); for (Variable var : root.getContext()) { if (var instanceof BooleanVariable) { BoolVariableValue varval = DivaFactory.eINSTANCE.createBoolVariableValue(); ctx.getVariable().add(varval); varval.setVariable(var); String id = var.getId(); if (id.startsWith("RFC")) { if (requirements.contains(var.getId())) varval.setBool(true); else varval.setBool(false); } else if (id.startsWith("For")) { if (var.getId().equals("ForCustomer")) varval.setBool(true); else varval.setBool(false); } else if (id.endsWith("Avail")) { varval.setBool(false); for (String s : srvs) { if (id.startsWith(s.substring(0, s.length() - 2))) { varval.setBool(true); } } for (String s : requirements) { if (id.startsWith(s.substring(1))) varval.setBool(true); } } } } List<Dimension> notToRemove = new ArrayList<Dimension>(); for (Dimension dim : root.getDimension()) { boolean remitted = false; for (Variant v : dim.getVariant()) { for (String srv : srvs) { if (srv.equals(v.getId())) { dim.setLower(1); remitted = true; break; } } } if (remitted) notToRemove.add(dim); } for (Dimension dim : root.getDimension()) { for (Dimension dim2 : root.getDimension()) { boolean remitted = false; for (Dimension dim3 : root.getDimension()) { if (notToRemove.contains(dim3)) { for (Variant v2 : dim3.getVariant()) { try { if (v2.getDependency().getText().contains(dim2.getId())) remitted = true; } catch (Exception e) { } if (remitted) break; } } } if (remitted) notToRemove.add(dim2); } } List<Dimension> toRemove = new ArrayList<Dimension>(); for (Dimension dim : root.getDimension()) { if (!notToRemove.contains(dim)) { toRemove.add(dim); } } root.getDimension().removeAll(toRemove); saveModel(consumer + "-before"); this.fileNamePrefix = consumer; _runSimulation(); try { Configuration config = root.getSimulation().getScenario().get(0).getContext().get(0).getConfiguration() .get(0); for (ConfigVariant v : config.getVariant()) { result.add(v.getVariant().getId()); } } catch (Exception e) { e.printStackTrace(); result.add(e.getStackTrace().toString()); } return result; }
From source file:base.BasePlayer.AminoTable.java
public void paint(Graphics g) { try {/* w w w . j a v a 2s.c o m*/ drawScreen(g); } catch (Exception e) { ErrorLog.addError(e.getStackTrace()); e.printStackTrace(); } }
From source file:it.imtech.metadata.MetaUtility.java
/** * Metodo che costruisce l'albero delle classificazione e setta il nodo * selezionato se esistente/*from www . java 2 s . c o m*/ * * @param nodes Il nodo nel quale aggiungere i nuovi nodi (Nodo Padre) * @param taxons La lista di nodi per livello */ private void recursiveOefosTreeviewBuild(DefaultMutableTreeNode nodes, TreeMap<Object, Taxon> taxons, String sequence, String panelname) throws Exception { try { for (Map.Entry<Object, Taxon> kv : taxons.entrySet()) { ClassNode iNode = new ClassNode("" + kv.getKey(), kv.getValue().upstream_identifier + ": " + kv.getValue().description); ClassMutableNode inner = new ClassMutableNode(iNode); nodes.add(inner); String oefosname = panelname + "----" + sequence; if (this.oefos_path.get(oefosname) != null) { if (this.oefos_path.get(oefosname).containsValue(kv.getValue().TID)) { selected = inner; } } recursiveOefosTreeviewBuild(inner, kv.getValue().subtaxons, sequence, panelname); } // Utility.sortTreeChildren(nodes); } catch (Exception ex) { throw new Exception("Exception in recursiveOefosTreeviewBuild: " + ex.getStackTrace() + "\n"); } }
From source file:it.imtech.metadata.MetaUtility.java
/** * Metodo che setta il TreeMap oefos_path con i valori del nodo selezionato * e aggiorna il label che descrive il path dei nodi selezionati * * @param e L'albero sul quale ricercare il path selezionato *///from w w w . ja v a 2s.co m private void setOEFOS(JTree e, String sequence, String panelname) throws Exception { try { DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getLastSelectedPathComponent(); String completePath = ""; //OefosPaths path = new OefosPaths(panelname, sequence); BookImporter.getInstance() .createComponentMap(BookImporter.getInstance().metadatapanels.get(panelname).getPanel()); Component controls = BookImporter.getInstance().getComponentByName("classification_path---" + sequence); //Se e' una foglia aggiorna il path nell'interfaccia e oefos_path if (node != null) { TreePath selpath = new TreePath(node.getPath()); e.setSelectionPath(selpath); Object[] nodes = selpath.getPath(); TreeMap<Integer, Integer> single_path = new TreeMap<Integer, Integer>(); for (int i = 1; i < nodes.length; i++) { Object nodeInfo = nodes[i]; DefaultMutableTreeNode nodeC = (DefaultMutableTreeNode) nodeInfo; ClassNode c = (ClassNode) nodeC.getUserObject(); single_path.put(i, Integer.parseInt(c.getKey().toString())); completePath += nodes[i].toString(); completePath += (i != nodes.length - 1) ? "/" : ""; } this.oefos_path.put(panelname + "----" + sequence, single_path); } else { this.oefos_path.put(panelname + "----" + sequence, null); } JLabel label = (JLabel) controls; if (completePath.length() > 120) { label.setText(completePath.substring(0, 120)); } else { label.setText(completePath); } label.revalidate(); } catch (Exception ex) { throw new Exception("Exception in setOEFOS: " + ex.getStackTrace() + "\n"); } }
From source file:com.ibm.bi.dml.test.integration.AutomatedTestBase.java
/** * <p>/* www . j av a2 s. c o m*/ * Runs a test for which the exception expectation can be specified as well * as the specific expectation which is expected. If SystemML executes more * MR jobs than specified in maxMRJobs this test will fail. * </p> * @param newWay * in the new way if it is set to true * @param exceptionExpected * exception expected * @param expectedException * expected exception * @param maxMRJobs * specifies a maximum limit for the number of MR jobs. If set to * -1 there is no limit. */ protected void runTest(boolean newWay, boolean exceptionExpected, Class<?> expectedException, int maxMRJobs) { String executionFile = sourceDirectory + selectedTest + ".dml"; if (!newWay) { executionFile = executionFile + "t"; ParameterBuilder.setVariablesInScript(sourceDirectory, selectedTest + ".dml", testVariables); } //cleanup scratch folder (prevent side effect between tests) cleanupScratchSpace(); ArrayList<String> args = new ArrayList<String>(); // setup arguments to SystemML if (DEBUG) { args.add("-Dsystemml.logging=trace"); } if (scriptType != null) { // DML/PYDML tests have newWay==true and a non-null scriptType switch (scriptType) { case DML: // Need a null pointer check because some tests read DML from a string. if (null != fullDMLScriptName) { args.add("-f"); args.add(fullDMLScriptName); } break; case PYDML: if (null != fullDMLScriptName) { args.add("-f"); args.add(fullDMLScriptName); } break; } } else if (newWay) { // Need a null pointer check because some tests read DML from a string. if (null != fullDMLScriptName) { args.add("-f"); args.add(fullDMLScriptName); } } else { if (null != executionFile) { args.add("-f"); args.add(executionFile); } } // program-independent parameters if (VISUALIZE) args.add("-v"); args.add("-exec"); if (rtplatform == RUNTIME_PLATFORM.HADOOP) args.add("hadoop"); else if (rtplatform == RUNTIME_PLATFORM.HYBRID) args.add("hybrid"); else if (rtplatform == RUNTIME_PLATFORM.SINGLE_NODE) args.add("singlenode"); else if (rtplatform == RUNTIME_PLATFORM.SPARK) args.add("spark"); else if (rtplatform == RUNTIME_PLATFORM.HYBRID_SPARK) args.add("hybrid_spark"); else { throw new RuntimeException("Unknown runtime platform: " + rtplatform); } //use optional config file since default under SystemML/DML args.add("-config=" + getCurConfigFile().getPath()); // program-specific parameters if (newWay) { for (int i = 0; i < programArgs.length; i++) args.add(programArgs[i]); } if (DEBUG) { if (!newWay) TestUtils.printDMLScript(executionFile); else { if (scriptType == null) { TestUtils.printDMLScript(fullDMLScriptName); } else if (scriptType == ScriptType.DML) { TestUtils.printDMLScript(fullDMLScriptName); } else if (scriptType == ScriptType.PYDML) { TestUtils.printPYDMLScript(fullDMLScriptName); } } } try { String[] dmlScriptArgs = args.toArray(new String[args.size()]); System.out.println("arguments to DMLScript: " + Arrays.toString(dmlScriptArgs)); DMLScript.main(dmlScriptArgs); /** check number of MR jobs */ if (maxMRJobs > -1 && maxMRJobs < Statistics.getNoOfCompiledMRJobs()) fail("Limit of MR jobs is exceeded: expected: " + maxMRJobs + ", occurred: " + Statistics.getNoOfCompiledMRJobs()); if (exceptionExpected) fail("expected exception which has not been raised: " + expectedException); } catch (Exception e) { if (!exceptionExpected || (expectedException != null && !(e.getClass().equals(expectedException)))) { e.printStackTrace(); StringBuilder errorMessage = new StringBuilder(); errorMessage.append("failed to run script " + executionFile); errorMessage.append("\nexception: " + e.toString()); errorMessage.append("\nmessage: " + e.getMessage()); errorMessage.append("\nstack trace:"); for (StackTraceElement ste : e.getStackTrace()) { errorMessage.append("\n>" + ste); } fail(errorMessage.toString()); } } }
From source file:edu.ku.brc.specify.conversion.BasicSQLUtils.java
/** * Executes an SQL Update command/*from ww w .j av a 2s . co m*/ * @param stmt Statement object to execute the SQL * @param cmdStr the SQL string to execute * @return the return code from the executeUpdate call */ public static int exeUpdateCmd(Statement stmt, String cmdStr) { try { //log.debug("---- exeUpdateCmd" + cmdStr); stmt.setEscapeProcessing(true); return stmt.executeUpdate(cmdStr); } catch (Exception ex) { //TODO: Problem encountered with the CUPaleo database when converting the AccessionAgent //We (Rod?) need to go in an create a hashtable that if ((ex instanceof MySQLIntegrityConstraintViolationException) && (cmdStr.contains("INSERT INTO accessionagent"))) { log.error("ignoring a record because it makes a MySQLIntegrityConstraintViolation: " + ex.getStackTrace().toString()); log.error(cmdStr + "\n"); ex.printStackTrace(); return 0; } else if (cmdStr.contains("INSERT INTO accessionagent")) { log.error("ignoring a record because it makes a uncatchable SQL Exception: " + ex.getMessage()); log.error(" " + cmdStr + "\n"); //ex.printStackTrace(); return 0; } else { //e.printStackTrace(); log.error(ex.getMessage()); log.error(cmdStr + "\n"); ex.printStackTrace(); //ex.getStackTrace(). throw new RuntimeException(ex); } } //return -1; }
From source file:jp.furplag.util.commons.NumberUtilsTest.java
/** * {@link jp.furplag.util.commons.NumberUtils#round(Object, Class)}. *///from www . j a va2 s . c o m @SuppressWarnings("unchecked") @Test public void testRoundObjectClassOfT() { try { for (Class<?> type : NUMBERS) { Object expected = null; if (ClassUtils.isPrimitiveOrWrapper(type)) { expected = ClassUtils.primitiveToWrapper(type).getMethod("valueOf", String.class).invoke(null, "3"); } else { Constructor<?> c = type.getDeclaredConstructor(String.class); expected = c.newInstance("3"); } assertEquals("PI: " + type.getSimpleName(), expected, round(Math.PI, (Class<? extends Number>) type)); } } catch (Exception e) { e.printStackTrace(); fail(e.getMessage() + "\n" + Arrays.toString(e.getStackTrace())); } }
From source file:jp.furplag.util.commons.NumberUtilsTest.java
/** * {@link jp.furplag.util.commons.NumberUtils#round(Number)}. *//*from w ww. j a v a 2 s .c o m*/ @Test public void testRoundT() { try { for (Class<?> type : NUMBERS) { Object o = null; Object expected = null; if (ObjectUtils.isAny(ClassUtils.primitiveToWrapper(type), Float.class, Double.class)) { o = ClassUtils.primitiveToWrapper(type).getMethod("valueOf", String.class).invoke(null, Double.toString(Math.PI)); expected = ClassUtils.primitiveToWrapper(type).getMethod("valueOf", String.class).invoke(null, "3"); } else if (BigDecimal.class.equals(type)) { o = new BigDecimal(Math.PI); expected = new BigDecimal("3"); } else if (BigInteger.class.equals(type)) { o = new BigDecimal(Math.PI).toBigInteger(); expected = new BigDecimal("3").toBigInteger(); } else { o = ClassUtils.primitiveToWrapper(type).getMethod("valueOf", String.class).invoke(null, "3"); expected = ClassUtils.primitiveToWrapper(type).getMethod("valueOf", String.class).invoke(null, "3"); } assertEquals(o + "(" + o.getClass() + "): " + type.getSimpleName(), expected, round((Number) o)); } } catch (Exception e) { e.printStackTrace(); fail(e.getMessage() + "\n" + Arrays.toString(e.getStackTrace())); } }