List of usage examples for java.util Vector get
public synchronized E get(int index)
From source file:fr.sanofi.fcl4transmart.controllers.listeners.snpData.SetPlatformListener.java
@Override public void handleEvent(Event event) { Vector<String> values = this.ui.getValues(); Vector<String> samples = this.ui.getSamples(); File file = new File(this.dataType.getPath().toString() + File.separator + this.dataType.getStudy().toString() + ".subject_mapping.tmp"); File mappingFile = ((SnpData) this.dataType).getMappingFile(); if (mappingFile == null) { this.ui.displayMessage("Error: no subject to sample mapping file"); }//from w w w . j ava 2 s . com try { FileWriter fw = new FileWriter(file); BufferedWriter out = new BufferedWriter(fw); try { BufferedReader br = new BufferedReader(new FileReader(mappingFile)); String line; while ((line = br.readLine()) != null) { String[] fields = line.split("\t", -1); String sample = fields[3]; String platform; if (samples.contains(sample)) { platform = values.get(samples.indexOf(sample)); } else { br.close(); return; } out.write(fields[0] + "\t" + fields[1] + "\t" + fields[2] + "\t" + sample + "\t" + platform + "\t" + fields[5] + "\t" + fields[6] + "\t" + fields[7] + "\t" + fields[8] + "\n"); } br.close(); } catch (Exception e) { this.ui.displayMessage("Error: " + e.getLocalizedMessage()); out.close(); e.printStackTrace(); } out.close(); try { File fileDest; if (mappingFile != null) { String fileName = mappingFile.getName(); mappingFile.delete(); fileDest = new File(this.dataType.getPath() + File.separator + fileName); } else { fileDest = new File(this.dataType.getPath() + File.separator + this.dataType.getStudy().toString() + ".subject_mapping"); } FileUtils.moveFile(file, fileDest); ((SnpData) this.dataType).setMappingFile(fileDest); } catch (IOException ioe) { this.ui.displayMessage("File error: " + ioe.getLocalizedMessage()); return; } } catch (Exception e) { this.ui.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } this.ui.displayMessage("Subject to sample mapping file updated"); WorkPart.updateSteps(); WorkPart.updateFiles(); }
From source file:edu.ku.brc.specify.datamodel.CollectingEventAttribute.java
@Override @Transient/*from ww w. j a v a 2s .co m*/ public Integer getParentId() { Vector<Object> ids = BasicSQLUtils .querySingleCol("SELECT CollectingEventID FROM collectingevent WHERE CollectingEventAttributeID = " + collectingEventAttributeId); if (ids.size() == 1) { return (Integer) ids.get(0); } return null; }
From source file:edu.ku.brc.specify.ui.db.ResultSetTableModel.java
/** * Gets the value of the row col.//from www . j av a 2 s . c o m * @param rowArg the row of the cell to be gotten * @param colArg the column of the cell to be gotten */ public Object getValueAt(final int row, final int column) { if (row > -1 && row < cache.size()) { Vector<Object> rowArray = cache.get(row); if (column > -1 && column < rowArray.size()) { Object obj = rowArray.get(column); Class<?> dataClassObj = getColumnClass2(column); //see comment for getColumnClass(). if (obj == null && (dataClassObj == null || dataClassObj == String.class)) { return ""; } if (obj instanceof Calendar) { return scrDateFormat.format((Calendar) obj); } else if (obj instanceof Timestamp) { return scrDateFormat.format((Date) obj); } else if (obj instanceof java.sql.Date || obj instanceof Date) { return scrDateFormat.format((Date) obj); } else if (obj instanceof Boolean) { if (getColumnClass2(column) == Boolean.class) { return obj; } return UIRegistry.getResourceString(obj.toString()); } //System.out.println(row+" "+column+" ["+obj+"] "+getColumnClass(column).getSimpleName() + " " + useColOffset); UIFieldFormatterIFace formatter = captionInfo != null ? captionInfo.get(column).getUiFieldFormatter() : null; if (formatter != null && formatter.isInBoundFormatter()) { return formatter.formatToUI(obj); } return obj; } } return "No Data"; }
From source file:com.mysql.stresstool.RunnableQueryInsert.java
public void run() { BufferedReader d = null;/*from ww w . ja va 2 s . c om*/ Connection conn = null; try { if (jdbcUrlMap.get("dbType") != null && !((String) jdbcUrlMap.get("dbType")).equals("MySQL")) { conn = DriverManager.getConnection((String) jdbcUrlMap.get("dbType"), "test", "test"); } else conn = DriverManager.getConnection((String) jdbcUrlMap.get("jdbcUrl")); } catch (SQLException ex) { ex.printStackTrace(); } if (conn != null) { try { Statement stmt = null; // ResultSet rs = null; // ResultSet rs2 = null; conn.setAutoCommit(false); stmt = conn.createStatement(); stmt.execute("SET AUTOCOMMIT=0"); long execTime = 0; int pkStart = 0; int pkEnds = 0; int intDeleteInterval = 0; int intBlobInterval = 0; int intBlobIntervalLimit = StressTool.getNumberFromRandom(4).intValue(); ThreadInfo thInfo; long threadTimeStart = System.currentTimeMillis(); active = true; thInfo = new ThreadInfo(); thInfo.setId(this.ID); thInfo.setType("insert"); thInfo.setStatusActive(this.isActive()); StressTool.setInfo(this.ID, thInfo); boolean lazy = false; int lazyInterval = 0; for (int repeat = 0; repeat <= repeatNumber; repeat++) { String query = null; ArrayList insert1 = null; ArrayList insert2 = null; int pk = 0; if (repeat > 0 && lazyInterval < 500) { lazy = true; ++lazyInterval; } else { lazy = false; lazyInterval = 0; } intBlobInterval++; //IMPLEMENTING lazy Vector v = this.getTablesValues(lazy); insert1 = (ArrayList<String>) v.get(0); insert2 = (ArrayList<String>) v.get(1); // System.out.println(insert1); // System.out.println(insert2); // pk = ((Integer) v.get(2)).intValue(); int[] iLine = { 0, 0 }; // pkStart = StressTool.getNumberFromRandom(2147483647).intValue(); // pkEnds = StressTool.getNumberFromRandom(2147483647).intValue(); try { long timeStart = System.currentTimeMillis(); if (this.ignoreBinlog) stmt.execute("SET sql_log_bin=0"); stmt.execute("SET GLOBAL max_allowed_packet=1073741824"); if (dbType.equals("MySQL") && !engine.toUpperCase().equals("BRIGHTHOUSE")) stmt.execute("BEGIN"); else stmt.execute("COMMIT"); // stmt.execute("SET TRANSACTION NAME 'TEST'"); { Iterator<String> it = insert1.iterator(); while (it.hasNext()) { stmt.addBatch(it.next()); } } if (!this.doSimplePk) { if (intBlobInterval > intBlobIntervalLimit) { Iterator<String> it = insert2.iterator(); while (it.hasNext()) { stmt.addBatch(it.next()); } intBlobInterval = 0; } } iLine = stmt.executeBatch(); stmt.clearBatch(); // System.out.println("Query1 = " + insert1); // System.out.println("Query2 = " + insert2); // stmt.execute("START TRANSACTION"); // stmt.execute(insert1); // iLine = stmt.executeBatch(); // conn.commit(); long timeEnds = System.currentTimeMillis(); execTime = (timeEnds - timeStart); } catch (Exception sqle) { conn.rollback(); System.out.println("FAILED QUERY1==" + insert1); System.out.println("FAILED QUERY2==" + insert2); sqle.printStackTrace(); System.exit(1); //conn.close(); //this.setJdbcUrl(jdbcUrl); //System.out.println("Query Insert TH RE-INIZIALIZING"); } finally { // conn.commit(); stmt.execute("COMMIT"); // intDeleteInterval++; if (doLog) { System.out.println("Query Insert TH = " + this.getID() + " Loop N = " + repeat + " " + iLine[0] + "|" + ((iLine.length > 1) ? iLine[1] : 0) + " Exec Time(ms) =" + execTime + " Running = " + repeat + " of " + repeatNumber + " to go =" + (repeatNumber - repeat) + " Using Lazy=" + lazy); } } thInfo.setExecutedLoops(repeat); if (sleepFor > 0 || this.getSleepWrite() > 0) { if (this.getSleepWrite() > 0) { Thread.sleep(getSleepWrite()); } else Thread.sleep(sleepFor); } } long threadTimeEnd = System.currentTimeMillis(); this.executionTime = (threadTimeEnd - threadTimeStart); // this.setExecutionTime(executionTime); active = false; // System.out.println("Query Insert TH = " + this.getID() + " COMPLETED! TOTAL TIME = " + execTime + "(ms) Sec =" + (execTime/1000)); thInfo.setExecutionTime(executionTime); thInfo.setStatusActive(false); StressTool.setInfo(this.ID, thInfo); return; } catch (Exception ex) { ex.printStackTrace(); try { conn.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }
From source file:bboss.org.apache.velocity.runtime.resource.loader.JarResourceLoader.java
/** * Called by Velocity to initialize the loader * @param configuration/* w ww . j av a2s. c o m*/ */ public void init(ExtendedProperties configuration) { log.trace("JarResourceLoader : initialization starting."); // rest of Velocity engine still use legacy Vector // and Hashtable classes. Classes are implicitly // synchronized even if we don't need it. Vector paths = configuration.getVector("path"); StringUtils.trimStrings(paths); /* * support the old version but deprecate with a log message */ if (paths == null || paths.size() == 0) { paths = configuration.getVector("resource.path"); StringUtils.trimStrings(paths); if (paths != null && paths.size() > 0) { log.debug("JarResourceLoader : you are using a deprecated configuration" + " property for the JarResourceLoader -> '<name>.resource.loader.resource.path'." + " Please change to the conventional '<name>.resource.loader.path'."); } } if (paths != null) { log.debug("JarResourceLoader # of paths : " + paths.size()); for (int i = 0; i < paths.size(); i++) { loadJar((String) paths.get(i)); } } log.trace("JarResourceLoader : initialization complete."); }
From source file:de.fhg.fokus.odp.middleware.ckan.CKANGatewayUtil.java
/** * The function receives a vector with details for a set of revisions and * returns the details for the packages affected by these revisions. * // ww w . j av a2s . c o m * @param revisionsDetails * a vector of strings containing the JSON details for the * revisions. * @return a vector of maps with the details for each affected package. */ @SuppressWarnings({ "rawtypes", "unchecked" }) public static Vector getUpdatedDataSetsDetails(Vector<String> revisionsDetails) { // check the input packages if (revisionsDetails == null) { return null; } // the vector to store return results Vector toreturn = new Vector(); // a variable to hold the already visited packages Vector<String> visitedPackages = new Vector<String>(); // iterate over each single package for (int i = 0; i < revisionsDetails.size(); i++) { // parse the JSON string and obtain an array of JSON objects Object obj = JSONValue.parse(revisionsDetails.get(i)); Map array = (Map) obj; // get the packages JSONArray arr = (JSONArray) (array.get("packages")); // iterate over all the packages for (int j = 0; j < arr.size(); j++) { // get the name of the next package String pkg = (String) arr.get(j); // check whether the package was already visited if (visitedPackages.contains(pkg)) { continue; } // add the package to the list of visited packages visitedPackages.add(pkg); // get the package details Object pkgObject = CKANGatewayCore.getDataSetDetails(pkg); // add the package details to the toreturn object if (pkgObject != null) { toreturn.add(pkgObject); } } } return toreturn; }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.snpData.SetTissueListener.java
@Override public void handleEvent(Event event) { Vector<String> values = this.ui.getValues(); Vector<String> samples = this.ui.getSamples(); File file = new File(this.dataType.getPath().toString() + File.separator + this.dataType.getStudy().toString() + ".subject_mapping.tmp"); File mappingFile = ((SnpData) this.dataType).getMappingFile(); if (mappingFile == null) { this.ui.displayMessage("Error: no subject to sample mapping file"); }/*from w ww.jav a2 s. co m*/ try { FileWriter fw = new FileWriter(file); BufferedWriter out = new BufferedWriter(fw); try { BufferedReader br = new BufferedReader(new FileReader(mappingFile)); String line; while ((line = br.readLine()) != null) { String[] fields = line.split("\t", -1); String sample = fields[3]; String tissueType; if (samples.contains(sample)) { tissueType = values.get(samples.indexOf(sample)); } else { br.close(); return; } out.write(fields[0] + "\t" + fields[1] + "\t" + fields[2] + "\t" + sample + "\t" + fields[4] + "\t" + tissueType + "\t" + fields[6] + "\t" + fields[7] + "\t" + "PLATFORM+TISSUETYPE" + "\n"); } br.close(); } catch (Exception e) { this.ui.displayMessage("File error: " + e.getLocalizedMessage()); out.close(); e.printStackTrace(); } out.close(); try { File fileDest; if (mappingFile != null) { String fileName = mappingFile.getName(); mappingFile.delete(); fileDest = new File(this.dataType.getPath() + File.separator + fileName); } else { fileDest = new File(this.dataType.getPath() + File.separator + this.dataType.getStudy().toString() + ".subject_mapping"); } FileUtils.moveFile(file, fileDest); ((SnpData) this.dataType).setMappingFile(fileDest); } catch (IOException ioe) { this.ui.displayMessage("File error: " + ioe.getLocalizedMessage()); return; } } catch (Exception e) { this.ui.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } this.ui.displayMessage("Subject to sample mapping file updated"); WorkPart.updateSteps(); WorkPart.updateFiles(); }
From source file:com.innate.cresterp.explorer.services.LocationService.java
public List<Company> queryLocalCompanies(final String latitude, final String longitude, final String user, final String radius) { NetworkManager networkManager = NetworkManager.getInstance(); networkManager.start();/*from w w w .jav a 2s . c om*/ networkManager.addErrorListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { NetworkEvent n = (NetworkEvent) evt; n.getError().printStackTrace(); System.out.println(n.getError()); } }); ConnectionRequest request; request = new ConnectionRequest() { int chr; StringBuffer sb = new StringBuffer(); String response = ""; @Override protected void readResponse(InputStream input) throws IOException { Vector vector = new Vector(); JSONParser parser = new JSONParser(); Hashtable hm = parser.parse(new InputStreamReader(input)); vector = (Vector) hm.get("companies"); if (vector == null) { Company company = new Company(); company.setDescription("Searching within 1KM radius..."); company.setName("Nothing found yet"); company.setAddress("..."); company.setCategory("..."); company.setEmail("..."); company.setWebsite("..."); company.setMobile("...."); if (!companies.contains(company)) { companies.add(company); } } else { for (int i = 0; i < vector.size(); i++) { Hashtable h = (Hashtable) vector.get(i); Company company = new Company(); company.setAddress(h.get("address").toString()); company.setCategory(h.get("category").toString()); company.setDescription(h.get("description").toString()); company.setEmail(h.get("email").toString()); company.setId(h.get("id").toString()); company.setLatitude(h.get("latitude").toString()); company.setLongitude(h.get("longitude").toString()); company.setMobile(h.get("mobile").toString()); company.setName(h.get("name").toString()); company.setWebsite(h.get("website").toString()); if (!companies.contains(company)) { companies.add(company); } } } } @Override protected void handleException(Exception err) { /* Display.getInstance().callSerially(new Runnable() { public void run() { Dialog.show("Oops", "Please make sure you still have data", "Ok", "Cancel"); } });*/ } }; String url = new UrlManager().getGetLocalCompanies() + "action=2&userlat=" + latitude + "&userlong=" + longitude + "&distance=" + radius; url = new Utility(null, null).replaceAll(url, " ", "%20"); request.setUrl(url); request.setPost(false); networkManager.addToQueueAndWait(request); return companies; }
From source file:info.puzz.trackprofiler.gui.TrackProfilerFrame.java
protected void drawChart() throws TrackProfilerException { if (this.track == null) { throw new TrackProfilerException("track_not_loaded"); //$NON-NLS-1$ }/*from ww w .j a va2 s . c o m*/ this.computeTrackInfo(); String name = trackFile != null ? trackFile.getName() : "TrackProfiler"; //$NON-NLS-1$ JFreeChart chart; if (TrackProfilerAppContext.getInstance().isFilledGraph()) { chart = ChartFactory.createXYAreaChart(name, new Message(Messages.LENGTH).toString(), new Message(Messages.ELEVATION).toString(), this.toDataset(), PlotOrientation.VERTICAL, true, true, false); } else { chart = ChartFactory.createXYLineChart(name, new Message(Messages.LENGTH).toString(), new Message(Messages.ELEVATION).toString(), this.toDataset(), PlotOrientation.VERTICAL, true, true, false); } chart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) chart.getPlot(); XYAreaRenderer xyarearenderer = new XYAreaRenderer(); xyarearenderer.setSeriesPaint(0, new Color(186, 197, 231, 200)); xyplot.setRenderer(0, xyarearenderer); drawSelectedPoints(xyplot); if (this.track.getWaypoints().size() > 0) { Waypoints markerPoints = new Waypoints(); markerPoints.addAll(this.track.getWaypoints()); for (int i = 0; i < this.track.getWaypoints().size(); i++) { Waypoint waypoint = (Waypoint) this.track.getWaypoints().get(i); prepareWaypontOnChart(xyplot, waypoint); } xyplot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); xyplot.getRangeAxis().setUpperMargin(0.15); } if (showExtreemes) { Vector/* <TrackExtreeme> */ extreemes = this.track.findExtremes(); for (int i = 0; i < extreemes.size(); i++) { Waypoint ex = (Waypoint) extreemes.get(i); prepareWaypontOnChart(xyplot, ex); } } getChartPanel().setChart(chart); getJPanel1().repaint(); }
From source file:edu.ucla.stat.SOCR.analyses.gui.Clustering.java
/**This method defines the specific statistical Analysis to be carried our on the user specified data. ANOVA is done in this case. */ public void doAnalysis() { if (dataTable.isEditing()) dataTable.getCellEditor().stopCellEditing(); if (!hasExample) { JOptionPane.showMessageDialog(this, DATA_MISSING_MESSAGE); return;/* w ww .ja va 2 s. co m*/ } Data data = new Data(); String dendroData[][] = new String[dataTable.getRowCount()][dataTable.getColumnCount()]; for (int k = 0; k < dataTable.getRowCount(); k++) for (int j = 0; j < dataTable.getColumnCount(); j++) { if (dataTable.getValueAt(k, j) != null && !dataTable.getValueAt(k, j).equals("")) { dendroData[k][j] = (String) dataTable.getValueAt(k, j); } } ClusteringData = new LinkedList<String[]>(); // added (for lstdades) Vector<String> vectorDataRow = new Vector(); for (int k = 0; k < dataTable.getRowCount(); k++) { for (int j = 0; j < dataTable.getColumnCount(); j++) { if (dendroData[k][j] != null && !dendroData[k][j].equals("")) vectorDataRow.add(dendroData[k][j]); } String stringDataRow[] = new String[vectorDataRow.size()]; for (int i = 0; i < vectorDataRow.size(); i++) { stringDataRow[i] = vectorDataRow.get(i); } if (vectorDataRow.size() != 0) { ClusteringData.add(k, stringDataRow); // now exactly same as lstdades vectorDataRow.clear(); } } f.getPwBtn().doLoad("Calculate"); resultPanelTextArea.append("Click on DENDROGRAM panel to view the graph" + "\nSee SOCR Hierarchical Clustering Activity:\n" + "http://wiki.stat.ucla.edu/socr/index.php/SOCR_EduMaterials_AnalysisActivities_HierarchicalClustering"); /* every one has to have its own, otherwise one Exception spills the whole. */ /* doGraph is underconstruction thus commented out. annie che 20060314 */ //if (useGraph) }