public void oneTimeConfig() { // Tell JNDI config to not expect JNDI props System.setProperty( "gov.usgs.cida.config.DynamicReadOnlyProperties.EXPECT_NON_JNDI_ENVIRONMENT", "true"); System.setProperty(LoadModelMetadata.SKIP_LOADING_PREDEFINED_THEMES, "true"); // Production Properties System.setProperty( SharedApplication.READONLY_DB_URL_KEY, "jdbc:oracle:thin:@130.11.165.152:1521:widw"); System.setProperty(SharedApplication.READONLY_DB_USER_KEY, "sparrow_dss"); System.setProperty(SharedApplication.READONLY_DB_USER_KEY, dbPwd); // Turns on detailed logging - very verbose on the tests // log.setLevel(Level.DEBUG); // Generically turn on logging for Actions // log.getLogger(Action.class).setLevel(Level.DEBUG); // Turn off logging for the lifecycle Logger.getLogger(LifecycleListener.class).setLevel(Level.ERROR); lifecycle.contextInitialized(null, true); }
public static String prompt(String prompt) { // prompt the user to enter their name System.out.print(prompt); // open up standard input BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String val = null; // read the username from the command-line; need to use try/catch with the // readLine() method try { val = br.readLine(); } catch (IOException ioe) { System.out.println("IO error trying to read input!"); System.exit(1); } finally { // br.close(); } return val; }
public static DataTable readAsDouble(InputStream source, boolean hasHeadings) throws Exception { int indexCol; InputStreamReader isr = new InputStreamReader(source); BufferedReader br = new BufferedReader(isr); try { int[] remappedColumns = null; // indexes to map the columns to int mappedColumnCount = 0; // Number of columns in the output String[] headings = (hasHeadings) ? TabDelimFileUtil.readHeadings(br) : null; indexCol = findIdColumn(headings); if (indexCol < 0) { throw new Exception("Could not find an ID Column"); } List<double[]> rows = readDataBodyAsDouble(br, remappedColumns, mappedColumnCount); // copy the array list to a double[][] array DataTableWritable builder = new SimpleDataTableWritable(); // Configure the columns int numColumns = (headings != null) ? headings.length : rows.get(0).length; numColumns = (mappedColumnCount > 0) ? mappedColumnCount : numColumns; for (int i = 0; i < numColumns; i++) { // no units in this test String heading = (headings != null) ? headings[i] : null; ColumnDataWritable column = new StandardNumberColumnDataWritable<Double>(heading, null); builder.addColumn(column); } // Add the data boolean debug = false; for (int i = 0; i < rows.size(); i++) { double[] row = rows.get(i); int offset = 0; for (int j = 0; j < numColumns; j++) { builder.setValue(Double.valueOf(row[j + offset]), i, j); } } // builder.buildIndex(indexCol); builder.setProperty(ID_COL_KEY, Integer.toString(indexCol)); // return builder; ColumnData[] cols = new ColumnData[builder.getColumns().length]; System.arraycopy(builder.getColumns(), 0, cols, 0, builder.getColumns().length); ColumnData oldCol = cols[indexCol]; StandardLongColumnData newCol = new StandardLongColumnData(oldCol, true, 0L); cols[indexCol] = newCol; SimpleDataTable table = new SimpleDataTable( cols, builder.getName(), builder.getDescription(), builder.getProperties()); return table; } finally { try { br.close(); } catch (IOException e) { e.printStackTrace(); // At this point we ignore. } br = null; } }