List of usage examples for java.util Vector elementAt
public synchronized E elementAt(int index)
From source file:gov.nih.nci.evs.browser.utils.SearchUtils.java
ResolvedConceptReferencesIterator getResolvedConceptReferencesIteratorUnion(String scheme, String version, Vector<ResolvedConceptReferencesIterator> v) { if (v == null) return null; int maxReturn = 100; Vector w = new Vector(); HashSet hset = new HashSet(); ResolvedConceptReferencesIterator matchIterator = null; for (int i = 0; i < v.size(); i++) { ResolvedConceptReferencesIterator iterator = (ResolvedConceptReferencesIterator) v.elementAt(i); try {/*from w ww .j a va 2 s . c o m*/ while (iterator != null && iterator.hasNext()) { ResolvedConceptReferenceList rcrl = iterator.next(maxReturn); if (rcrl != null) { ResolvedConceptReference[] refs = rcrl.getResolvedConceptReference(); if (refs != null) { for (ResolvedConceptReference ref : refs) { if (ref != null) { if (!hset.contains(ref.getConceptCode())) { w.add(ref.getConceptCode()); hset.add(ref.getConceptCode()); } } } } } } } catch (Exception ex) { ex.printStackTrace(); } } if (w.size() > 0) { String[] codes = new String[w.size()]; for (int i = 0; i < w.size(); i++) { String code = (String) w.elementAt(i); codes[i] = code; } try { LexBIGService lbSvc = new RemoteServerUtil().createLexBIGService(); if (lbSvc == null) { _logger.warn("lbSvc == null???"); return null; } CodingSchemeVersionOrTag versionOrTag = new CodingSchemeVersionOrTag(); if (version != null) versionOrTag.setVersion(version); ConceptReferenceList crefs = createConceptReferenceList(codes, scheme); CodedNodeSet cns = lbSvc.getCodingSchemeConcepts(scheme, null); cns = cns.restrictToCodes(crefs); CodedNodeSet.PropertyType[] types = new PropertyType[] { PropertyType.PRESENTATION }; cns = cns.restrictToProperties(null, types, null, null, null); try { matchIterator = cns.resolve(null, null, null); } catch (Exception ex) { ex.printStackTrace(); } } catch (Exception ex) { ex.printStackTrace(); } hset.clear(); } return matchIterator; }
From source file:gov.nih.nci.evs.browser.utils.DataUtils.java
private ArrayList removeRedundantRelationships(ArrayList associationList, String rel) { ArrayList a = new ArrayList(); HashSet target_set = new HashSet(); for (int i = 0; i < associationList.size(); i++) { String s = (String) associationList.get(i); Vector<String> w = parseData(s, "|"); String associationName = w.elementAt(0); if (associationName.compareTo(rel) != 0) { String associationTargetCode = w.elementAt(2); target_set.add(associationTargetCode); }//from w ww. j a v a2 s .c o m } for (int i = 0; i < associationList.size(); i++) { String s = (String) associationList.get(i); Vector<String> w = parseData(s, "|"); String associationName = w.elementAt(0); if (associationName.compareTo(rel) != 0) { a.add(s); } else { String associationTargetCode = w.elementAt(2); if (!target_set.contains(associationTargetCode)) { a.add(s); } } } return a; }
From source file:gov.nih.nci.evs.browser.utils.DataUtils.java
public Vector removeRedundantRecords(Vector v) { HashSet hset = new HashSet(); Vector u = new Vector(); for (int k = 0; k < v.size(); k++) { String t = (String) v.elementAt(k); if (!hset.contains(t)) { u.add(t);/*from w w w . jav a 2s .c o m*/ hset.add(t); } } return u; }
From source file:com.globalsight.everest.workflowmanager.WorkflowManagerLocal.java
private void createTasks(Session p_session, Vector p_workflowTaskInstances, Hashtable p_modifiedTasks, Workflow p_workflow, List p_wfTaskInfos) throws Exception { TaskImpl task = null;//ww w . j a va2s .co m try { int size = p_workflowTaskInstances.size(); CostingEngine ce = ServerProxy.getCostingEngine(); for (int i = 0; i < size; i++) { WorkflowTaskInstance inst = (WorkflowTaskInstance) p_workflowTaskInstances.elementAt(i); TaskInfoBean taskInfo = null; taskInfo = (TaskInfoBean) p_modifiedTasks.get(new Long(inst.getSequence())); task = new TaskImpl(); task.setId(inst.getTaskId()); task.setWorkflow(p_workflow); p_workflow.addTask(task); task.setName(inst.getActivityName()); task.setState(TaskImpl.STATE_DEACTIVE); task.setType(getActivityType(task.getName())); task.setCompanyId(p_workflow.getCompanyId()); Rate pageBasedRate = null; String hourAmount = null; // For Expenses long rateId = inst.getExpenseRateId(); task.setRateSelectionCriteria(inst.getRateSelectionCriteria()); if (rateId > 0) { // need to create a clone because the rate already exists - // so // don't want to try and insert but just set up the // relationship Rate rateClone = (Rate) ce.getRate(rateId); task.setExpenseRate(rateClone); if (rateClone.getRateType().equals(Rate.UnitOfWork.PAGE_COUNT)) { pageBasedRate = rateClone; } else { if (rateClone.getRateType().equals(Rate.UnitOfWork.HOURLY)) { AmountOfWork cloneNewAow = null; if (taskInfo != null) { hourAmount = taskInfo.getEstimatedHours(); } if (hourAmount != null) { AmountOfWork newAow = rateClone.createAmountOfWork(); // set the hour amount as estimated hours newAow.setEstimatedAmount( Double.parseDouble((hourAmount.length() == 0) ? "0" : hourAmount)); cloneNewAow = newAow; // p_session.save(cloneNewAow); } task.setAmountOfWork(cloneNewAow); } } } // for Revenue rateId = inst.getRevenueRateId(); if (rateId > 0) { // need to create a clone because the rate already exists - // so // don't want to try and insert but just set up the // relationship // Rate rateClone = (Rate) p_uow.registerObject(ce // .getRate(rateId)); Rate rateClone = (Rate) ce.getRate(rateId); task.setRevenueRate(rateClone); if (pageBasedRate == null && rateClone.getRateType().equals(Rate.UnitOfWork.PAGE_COUNT)) { pageBasedRate = rateClone; } else { if (rateClone.getRateType().equals(Rate.UnitOfWork.HOURLY)) { AmountOfWork cloneNewAow = null; if (hourAmount == null) { if (taskInfo != null) { hourAmount = taskInfo.getEstimatedHours(); } if (hourAmount != null) { AmountOfWork newAow = rateClone.createAmountOfWork(); // set the hour amount as estimated hours newAow.setEstimatedAmount( Double.parseDouble((hourAmount.length() == 0) ? "0" : hourAmount)); cloneNewAow = newAow; // p_session.save(cloneNewAow); } task.setAmountOfWork(cloneNewAow); } } } } if (s_logger.isDebugEnabled()) { s_logger.debug("createTasks : " + " workflow=" + p_workflow.getId() + " WorkflowTaskInstance=" + WorkflowHelper.toDebugString(inst) + GlobalSightCategory.getLineContinuation() + " task=" + task.toString()); } // if a page based rate is assigned to one of the expenses // then need to add that amount of work to the task class. if (pageBasedRate != null) { AmountOfWork pageAow = pageBasedRate.createAmountOfWork(); int numOfPages = task.getWorkflow().getJob().getPageCount(); pageAow.setEstimatedAmount(numOfPages); // p_session.save(pageAow); task.setAmountOfWork(pageAow); } p_session.saveOrUpdate(task); for (Object ob : task.getWorkSet()) { if (ob instanceof AmountOfWork) { AmountOfWork aWork = (AmountOfWork) ob; p_session.saveOrUpdate(aWork); } } } } catch (Exception e) { s_logger.error("Failed to get a rate for a task.", e); // if a task was set then specify the task - otherwise specify all // because // the costing engine couldn't be retrieved to get rates. String taskId = task != null ? Long.toString(task.getId()) : "all"; String args[] = { taskId }; throw new WorkflowManagerException(WorkflowManagerException.MSG_FAILED_TO_FIND_RATE_FOR_TASK, args, e); } if (s_logger.isDebugEnabled()) { s_logger.debug( "createTasks : " + " setCompletionFraction numerator=" + p_workflow.getCompletionNumerator() + " denominator=" + p_workflow.getCompletionDenominator()); } }
From source file:gov.nih.nci.evs.browser.servlet.AjaxServlet.java
public void selectCSVersionAction(HttpServletRequest request, HttpServletResponse response) { String selectedvalueset = null; String uri = null;/*from w w w . java 2s. co m*/ String multiplematches = HTTPUtils.cleanXSS((String) request.getParameter("multiplematches")); if (multiplematches != null) { selectedvalueset = HTTPUtils.cleanXSS((String) request.getParameter("valueset")); uri = selectedvalueset; } else { uri = HTTPUtils.cleanXSS((String) request.getParameter("vsd_uri")); if (uri.indexOf("|") != -1) { Vector u = DataUtils.parseData(uri); uri = (String) u.elementAt(1); } } request.getSession().setAttribute("vsd_uri", uri); try { String nextJSP = "/pages/resolve_value_set.jsf"; RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP); dispatcher.forward(request, response); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:gov.nih.nci.evs.browser.utils.DataUtils.java
public Vector getSiblings(String scheme, String version, String code) { LexBIGService lbSvc = null;// ww w. j a v a 2s . c om LexBIGServiceConvenienceMethods lbscm = null; Vector sibling_vec = new Vector(); try { lbSvc = RemoteServerUtil.createLexBIGService(); lbscm = (LexBIGServiceConvenienceMethods) lbSvc.getGenericExtension("LexBIGServiceConvenienceMethods"); lbscm.setLexBIGService(lbSvc); } catch (Exception ex) { return sibling_vec; } HashSet hset = new HashSet(); String[] assocNames = new String[] { "PAR" }; // find parents Vector v = getAssociatedConceptsByAssociations(lbSvc, lbscm, scheme, version, code, assocNames); for (int i = 0; i < v.size(); i++) { String t = (String) v.elementAt(i); Vector w = parseData(t); String rel = (String) w.elementAt(0); String rela = (String) w.elementAt(1); String parent_name = (String) w.elementAt(2); String parent_code = (String) w.elementAt(3); Vector u = getAssociatedConceptsByAssociations(lbSvc, lbscm, scheme, version, parent_code, assocNames, false); for (int j = 0; j < u.size(); j++) { String t2 = (String) u.elementAt(j); Vector w2 = parseData(t2); String sib_rel = (String) w2.elementAt(0); String sib_rela = (String) w2.elementAt(1); String sib_name = (String) w2.elementAt(2); String sib_code = (String) w2.elementAt(3); String sib_sab = (String) w2.elementAt(4); if (!hset.contains(t2) && sib_code.compareTo(code) != 0) { sibling_vec.add("SIB" + "|" + sib_name + "|" + sib_code + "|" + sib_sab); } } } return sibling_vec; }
From source file:gov.nih.nci.evs.browser.utils.DataUtils.java
public void removeRedundantRecords(HashMap hmap) { //Set keyset = hmap.keySet(); //Iterator it = keyset.iterator(); Iterator it = hmap.entrySet().iterator(); while (it.hasNext()) { //String rel = (String) it.next(); //Vector v = (Vector) hmap.get(rel); Entry thisEntry = (Entry) it.next(); String rel = (String) thisEntry.getKey(); Vector v = (Vector) thisEntry.getValue(); HashSet hset = new HashSet(); Vector u = new Vector(); for (int k = 0; k < v.size(); k++) { String t = (String) v.elementAt(k); if (!hset.contains(t)) { u.add(t);//from w w w . j ava 2 s . c o m hset.add(t); } } hmap.put(rel, u); } }
From source file:gov.nih.nci.evs.browser.servlet.AjaxServlet.java
public void exportVSDToXMLAction(HttpServletRequest request, HttpServletResponse response) { String selectedvalueset = null; String multiplematches = HTTPUtils.cleanXSS((String) request.getParameter("multiplematches")); if (multiplematches != null) { selectedvalueset = HTTPUtils.cleanXSS((String) request.getParameter("valueset")); } else {/*w w w . ja va 2 s .c o m*/ selectedvalueset = HTTPUtils.cleanXSS((String) request.getParameter("vsd_uri")); if (selectedvalueset != null && selectedvalueset.indexOf("|") != -1) { Vector u = DataUtils.parseData(selectedvalueset); selectedvalueset = (String) u.elementAt(1); } } String uri = selectedvalueset; request.getSession().setAttribute("selectedvalueset", uri); String xml_str = valueSetDefinition2XMLString(uri); try { response.setContentType("text/xml"); String vsd_name = DataUtils.valueSetDefiniionURI2Name(uri); vsd_name = vsd_name.replaceAll(" ", "_"); vsd_name = vsd_name + ".xml"; response.setHeader("Content-Disposition", "attachment; filename=" + vsd_name); response.setContentLength(xml_str.length()); ServletOutputStream ouputStream = response.getOutputStream(); ouputStream.write(xml_str.getBytes("UTF8"), 0, xml_str.length()); ouputStream.flush(); ouputStream.close(); } catch (IOException e) { e.printStackTrace(); } FacesContext.getCurrentInstance().responseComplete(); }
From source file:GestoSAT.GestoSAT.java
public boolean actualizarConfiguracion(Vector<String> mySQL, Vector<String> confSeg, int iva, String logo) throws Exception { FileReader file;// w w w. j a v a2 s. c o m try { this.iva = Math.abs(iva); BufferedImage image = null; byte[] imageByte; BASE64Decoder decoder = new BASE64Decoder(); imageByte = decoder.decodeBuffer(logo.split(",")[1]); ByteArrayInputStream bis = new ByteArrayInputStream(imageByte); image = ImageIO.read(bis); bis.close(); // write the image to a file File outputfile = new File("logo"); String formato = logo.split("/")[1].split(";")[0]; ImageIO.write(image, formato, outputfile); // MySQL if (mySQL.elementAt(0).equals(this.mySQL.elementAt(0))) { if (!mySQL.elementAt(1).equals(this.mySQL.elementAt(1)) && !mySQL.elementAt(2).equals(this.mySQL.elementAt(2)) && (!mySQL.elementAt(3).equals(this.mySQL.elementAt(3)) || !mySQL.elementAt(0).equals(""))) { Class.forName("com.mysql.jdbc.Driver"); this.con.close(); this.con = DriverManager.getConnection("jdbc:mysql://" + mySQL.elementAt(0) + ":" + Math.abs(Integer.parseInt(mySQL.elementAt(1))) + "/gestosat?user=" + mySQL.elementAt(2) + "&password=" + mySQL.elementAt(3)); this.mySQL.set(0, mySQL.elementAt(0)); this.mySQL.set(1, Math.abs(Integer.parseInt(mySQL.elementAt(1))) + ""); this.mySQL.set(2, mySQL.elementAt(2)); this.mySQL.set(3, mySQL.elementAt(3)); } } else { // Comprobar que pass != "" Process pGet = Runtime.getRuntime() .exec("mysqldump -u " + this.mySQL.elementAt(2) + " -p" + this.mySQL.elementAt(3) + " -h " + this.mySQL.elementAt(0) + " -P " + this.mySQL.elementAt(1) + " gestosat"); InputStream is = pGet.getInputStream(); FileOutputStream fos = new FileOutputStream("backupGestoSAT.sql"); byte[] bufferOut = new byte[1000]; int leido = is.read(bufferOut); while (leido > 0) { fos.write(bufferOut, 0, leido); leido = is.read(bufferOut); } fos.close(); Class.forName("com.mysql.jdbc.Driver"); this.con.close(); this.con = DriverManager.getConnection( "jdbc:mysql://" + mySQL.elementAt(0) + ":" + Math.abs(Integer.parseInt(mySQL.elementAt(1))) + "/gestosat?user=" + mySQL.elementAt(2) + "&password=" + mySQL.elementAt(3)); this.mySQL.set(0, mySQL.elementAt(0)); this.mySQL.set(1, Math.abs(Integer.parseInt(mySQL.elementAt(1))) + ""); this.mySQL.set(2, mySQL.elementAt(2)); this.mySQL.set(3, mySQL.elementAt(3)); Process pPut = Runtime.getRuntime() .exec("mysql -u " + mySQL.elementAt(2) + " -p" + mySQL.elementAt(3) + " -h " + mySQL.elementAt(0) + " -P " + Math.abs(Integer.parseInt(mySQL.elementAt(1))) + " gestosat"); OutputStream os = pPut.getOutputStream(); FileInputStream fis = new FileInputStream("backupGestoSAT.sql"); byte[] bufferIn = new byte[1000]; int escrito = fis.read(bufferIn); while (escrito > 0) { os.write(bufferIn, 0, leido); escrito = fis.read(bufferIn); } os.flush(); os.close(); fis.close(); } // FTP FTPClient cliente = new FTPClient(); if (!confSeg.elementAt(3).equals("")) { cliente.connect(confSeg.elementAt(0), Integer.parseInt(confSeg.elementAt(1))); if (cliente.login(confSeg.elementAt(2), confSeg.elementAt(3))) { cliente.setFileType(FTP.BINARY_FILE_TYPE); BufferedInputStream buffIn = new BufferedInputStream(new FileInputStream("backupGestoSAT.sql")); cliente.enterLocalPassiveMode(); cliente.storeFile("backupGestoSAT.sql", buffIn); buffIn.close(); cliente.logout(); cliente.disconnect(); this.confSeg = confSeg; } else return false; } File archConf = new File("confGestoSAT"); BufferedWriter bw = new BufferedWriter(new FileWriter(archConf)); bw.write(this.mySQL.elementAt(0) + ";" + Math.abs(Integer.parseInt(this.mySQL.elementAt(1))) + ";" + this.mySQL.elementAt(2) + ";" + this.mySQL.elementAt(3) + ";" + this.confSeg.elementAt(0) + ";" + Math.abs(Integer.parseInt(this.confSeg.elementAt(1))) + ";" + this.confSeg.elementAt(2) + ";" + this.confSeg.elementAt(3) + ";" + Math.abs(iva)); bw.close(); return true; } catch (Exception ex) { file = new FileReader("confGestoSAT"); BufferedReader b = new BufferedReader(file); String cadena; cadena = b.readLine(); String[] valores = cadena.split(";"); this.mySQL.add(valores[0]); this.mySQL.add(Math.abs(Integer.parseInt(valores[1])) + ""); this.mySQL.add(valores[2]); this.mySQL.add(valores[3]); con.close(); Class.forName("com.mysql.jdbc.Driver"); con = DriverManager .getConnection("jdbc:mysql://" + this.mySQL.elementAt(0) + ":" + this.mySQL.elementAt(1) + "/gestosat?user=" + this.mySQL.elementAt(2) + "&password=" + this.mySQL.elementAt(3)); this.confSeg.add(valores[4]); this.confSeg.add(Math.abs(Integer.parseInt(valores[5])) + ""); this.confSeg.add(valores[6]); this.confSeg.add(valores[7]); file.close(); Logger.getLogger(GestoSAT.class.getName()).log(Level.SEVERE, null, ex); return false; } }
From source file:gov.nih.nci.evs.browser.utils.DataUtils.java
public Vector getParentCodes(String scheme, String version, String code) { Vector hierarchicalAssoName_vec = getHierarchyAssociationId(scheme, version); if (hierarchicalAssoName_vec == null || hierarchicalAssoName_vec.size() == 0) { return null; }/*w w w. j av a 2s . c om*/ String hierarchicalAssoName = (String) hierarchicalAssoName_vec.elementAt(0); // KLO, 01/23/2009 // Vector<Concept> superconcept_vec = util.getAssociationSources(scheme, // version, code, hierarchicalAssoName); Vector superconcept_vec = getAssociationSourceCodes(scheme, version, code, hierarchicalAssoName); /* if (superconcept_vec == null) return null; */ // SortUtils.quickSort(superconcept_vec, SortUtils.SORT_BY_CODE); return superconcept_vec; }