List of usage examples for java.util Vector contains
public boolean contains(Object o)
From source file:org.mahasen.util.SearchUtil.java
/** * @param searchParameters/*from w w w .ja va 2 s .c o m*/ * @return * @throws MahasenException * @throws InterruptedException */ public Vector<String> multipleOrSearch(Hashtable<String, Vector<String>> searchParameters) throws MahasenException, InterruptedException { ArrayList<SearchBean> searchValues = createSearchBeans(searchParameters); Vector<String> fileNames = new Vector<String>(); Vector<Id> finalResultIds = new Vector<Id>(); for (SearchBean searchBean : searchValues) { Vector<Id> resultIds; if (searchBean.isRangeBased()) { resultIds = getRangeSearchResultIds(searchBean.getPropertyName(), searchBean.getInitialValue(), searchBean.getLastValue()); } else { resultIds = getSearchResultIds(searchBean.getPropertyName(), searchBean.getInitialValue()); } if (finalResultIds.isEmpty()) { finalResultIds.addAll(resultIds); } else { for (Id id : resultIds) { if (!finalResultIds.contains(id)) { finalResultIds.add(id); } } } } fileNames = getResultantFileNames(finalResultIds); return fileNames; }
From source file:EditorPaneExample10A.java
public URL[] findLinks(Document doc, String protocol) { Vector links = new Vector(); Vector urlNames = new Vector(); URL baseURL = (URL) doc.getProperty(Document.StreamDescriptionProperty); if (doc instanceof HTMLDocument) { HTMLDocument.Iterator iterator = ((HTMLDocument) doc).getIterator(HTML.Tag.A); for (; iterator.isValid(); iterator.next()) { AttributeSet attrs = iterator.getAttributes(); Object linkAttr = attrs.getAttribute(HTML.Attribute.HREF); if (linkAttr instanceof String) { try { URL linkURL = new URL(baseURL, (String) linkAttr); if (protocol == null || protocol.equalsIgnoreCase(linkURL.getProtocol())) { String linkURLName = linkURL.toString(); if (urlNames.contains(linkURLName) == false) { urlNames.addElement(linkURLName); links.addElement(linkURL); }// w ww .jav a 2 s. co m } } catch (MalformedURLException e) { // Ignore invalid links } } } } URL[] urls = new URL[links.size()]; links.copyInto(urls); links.removeAllElements(); urlNames.removeAllElements(); return urls; }
From source file:es.pode.administracion.presentacion.adminusuarios.modificarUsuario.ModificarUsuarioControllerImpl.java
private GrupoVOCheck[] obtenerGrupoCheck(GrupoVO[] grupoVO, UsuarioVO usuarioVO) { GrupoVOCheck[] resultado = null;/*w ww .ja v a2s . c o m*/ resultado = new GrupoVOCheck[grupoVO.length]; GrupoVO[] gruposUsuario = usuarioVO.getGrupos(); Vector vRol = new Vector(); for (int j = 0; j < gruposUsuario.length; j++) { vRol.add(gruposUsuario[j].getId()); } for (int i = 0; i < grupoVO.length; i++) { GrupoVOCheck grupo = new GrupoVOCheck(); grupo.setId(grupoVO[i].getId()); grupo.setDescripcion(grupoVO[i].getDescripcion()); grupo.setLoginUsuario(usuarioVO.getUsuario()); if (vRol.contains(grupoVO[i].getId())) { grupo.setChecked(Boolean.TRUE); } else { grupo.setChecked(Boolean.FALSE); } resultado[i] = grupo; } return resultado; }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.SetSiteIdListener.java
@Override public void handleEvent(Event event) { // TODO Auto-generated method stub Vector<String> values = this.setSiteIdUI.getValues(); Vector<String> samples = this.setSiteIdUI.getSamples(); File file = new File(this.dataType.getPath().toString() + File.separator + this.dataType.getStudy().toString() + ".subject_mapping.tmp"); File stsmf = ((GeneExpressionData) this.dataType).getStsmf(); if (stsmf == null) { this.setSiteIdUI.displayMessage("Error: no subject to sample mapping file"); }/*from w w w . j a va2 s . c om*/ try { FileWriter fw = new FileWriter(file); BufferedWriter out = new BufferedWriter(fw); out.write( "study_id\tsite_id\tsubject_id\tSAMPLE_ID\tPLATFORM\tTISSUETYPE\tATTR1\tATTR2\tcategory_cd\n"); try { BufferedReader br = new BufferedReader(new FileReader(stsmf)); String line = br.readLine(); while ((line = br.readLine()) != null) { String[] fields = line.split("\t", -1); String sample = fields[3]; String site; if (samples.contains(sample)) { site = values.get(samples.indexOf(sample)); } else { br.close(); return; } out.write(fields[0] + "\t" + site + "\t" + fields[2] + "\t" + sample + "\t" + fields[4] + "\t" + fields[5] + "\t" + fields[6] + "\t" + fields[7] + "\t" + fields[8] + "\n"); } br.close(); } catch (Exception e) { this.setSiteIdUI.displayMessage("Error: " + e.getLocalizedMessage()); out.close(); e.printStackTrace(); } out.close(); try { File fileDest; if (stsmf != null) { String fileName = stsmf.getName(); stsmf.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); ((GeneExpressionData) this.dataType).setSTSMF(fileDest); } catch (IOException ioe) { this.setSiteIdUI.displayMessage("File error: " + ioe.getLocalizedMessage()); return; } } catch (Exception e) { this.setSiteIdUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } this.setSiteIdUI.displayMessage("Subject to sample mapping file updated"); WorkPart.updateSteps(); WorkPart.updateFiles(); }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.SetPlatformsListener.java
@Override public void handleEvent(Event event) { // TODO Auto-generated method stub Vector<String> values = this.setPlatformsUI.getValues(); Vector<String> samples = this.setPlatformsUI.getSamples(); File file = new File(this.dataType.getPath().toString() + File.separator + this.dataType.getStudy().toString() + ".subject_mapping.tmp"); File stsmf = ((GeneExpressionData) this.dataType).getStsmf(); if (stsmf == null) { this.setPlatformsUI.displayMessage("Error: no subject to sample mapping file"); }/*from ww w. j a v a 2 s.co m*/ try { FileWriter fw = new FileWriter(file); BufferedWriter out = new BufferedWriter(fw); out.write( "study_id\tsite_id\tsubject_id\tSAMPLE_ID\tPLATFORM\tTISSUETYPE\tATTR1\tATTR2\tcategory_cd\n"); try { BufferedReader br = new BufferedReader(new FileReader(stsmf)); String line = br.readLine(); 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.setPlatformsUI.displayMessage("Error: " + e.getLocalizedMessage()); out.close(); e.printStackTrace(); } out.close(); try { File fileDest; if (stsmf != null) { String fileName = stsmf.getName(); stsmf.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); ((GeneExpressionData) this.dataType).setSTSMF(fileDest); } catch (IOException ioe) { this.setPlatformsUI.displayMessage("File error: " + ioe.getLocalizedMessage()); return; } } catch (Exception e) { this.setPlatformsUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } this.setPlatformsUI.displayMessage("Subject to sample mapping file updated"); WorkPart.updateSteps(); WorkPart.updateFiles(); }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.SetAttribute1Listener.java
@Override public void handleEvent(Event event) { // TODO Auto-generated method stub Vector<String> values = this.setAttribute1UI.getValues(); Vector<String> samples = this.setAttribute1UI.getSamples(); File file = new File(this.dataType.getPath().toString() + File.separator + this.dataType.getStudy().toString() + ".subject_mapping.tmp"); File stsmf = ((GeneExpressionData) this.dataType).getStsmf(); if (stsmf == null) { this.setAttribute1UI.displayMessage("Error: no subject to sample mapping file"); }//from w w w .j a v a2s . c o m try { FileWriter fw = new FileWriter(file); BufferedWriter out = new BufferedWriter(fw); out.write( "study_id\tsite_id\tsubject_id\tSAMPLE_ID\tPLATFORM\tTISSUETYPE\tATTR1\tATTR2\tcategory_cd\n"); try { BufferedReader br = new BufferedReader(new FileReader(stsmf)); String line = br.readLine(); while ((line = br.readLine()) != null) { String[] fields = line.split("\t", -1); String sample = fields[3]; String attribute; if (samples.contains(sample)) { attribute = 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" + fields[5] + "\t" + attribute + "\t" + fields[7] + "\t" + fields[8] + "\n"); } br.close(); } catch (Exception e) { setAttribute1UI.displayMessage("File error: " + e.getLocalizedMessage()); out.close(); e.printStackTrace(); } out.close(); try { File fileDest; if (stsmf != null) { String fileName = stsmf.getName(); stsmf.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); ((GeneExpressionData) this.dataType).setSTSMF(fileDest); } catch (IOException ioe) { this.setAttribute1UI.displayMessage("File error: " + ioe.getLocalizedMessage()); return; } } catch (Exception e) { this.setAttribute1UI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } this.setAttribute1UI.displayMessage("Subject to sample mapping file updated"); WorkPart.updateSteps(); WorkPart.updateFiles(); }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.SetAttribute2Listener.java
@Override public void handleEvent(Event event) { // TODO Auto-generated method stub Vector<String> values = this.setAttribute2UI.getValues(); Vector<String> samples = this.setAttribute2UI.getSamples(); File file = new File(this.dataType.getPath().toString() + File.separator + this.dataType.getStudy().toString() + ".subject_mapping.tmp"); File stsmf = ((GeneExpressionData) this.dataType).getStsmf(); if (stsmf == null) { this.setAttribute2UI.displayMessage("Error: no subject to sample mapping file"); }// www .ja va2 s . c o m try { FileWriter fw = new FileWriter(file); BufferedWriter out = new BufferedWriter(fw); out.write( "study_id\tsite_id\tsubject_id\tSAMPLE_ID\tPLATFORM\tTISSUETYPE\tATTR1\tATTR2\tcategory_cd\n"); try { BufferedReader br = new BufferedReader(new FileReader(stsmf)); String line = br.readLine(); while ((line = br.readLine()) != null) { String[] fields = line.split("\t", -1); String sample = fields[3]; String attribute; if (samples.contains(sample)) { attribute = 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" + fields[5] + "\t" + fields[6] + "\t" + attribute + "\t" + fields[8] + "\n"); } br.close(); } catch (Exception e) { this.setAttribute2UI.displayMessage("File error: " + e.getLocalizedMessage()); out.close(); e.printStackTrace(); } out.close(); try { File fileDest; if (stsmf != null) { String fileName = stsmf.getName(); stsmf.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); ((GeneExpressionData) this.dataType).setSTSMF(fileDest); } catch (IOException ioe) { this.setAttribute2UI.displayMessage("File error: " + ioe.getLocalizedMessage()); return; } } catch (Exception e) { this.setAttribute2UI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } this.setAttribute2UI.displayMessage("Subject to sample mapping file updated"); WorkPart.updateSteps(); WorkPart.updateFiles(); }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.SetTissueTypeListener.java
@Override public void handleEvent(Event event) { // TODO Auto-generated method stub Vector<String> values = this.setTissueTypeUI.getValues(); Vector<String> samples = this.setTissueTypeUI.getSamples(); File file = new File(this.dataType.getPath().toString() + File.separator + this.dataType.getStudy().toString() + ".subject_mapping.tmp"); File stsmf = ((GeneExpressionData) this.dataType).getStsmf(); if (stsmf == null) { this.setTissueTypeUI.displayMessage("Error: no subject to sample mapping file"); }// w w w. j a v a 2 s .c o m try { FileWriter fw = new FileWriter(file); BufferedWriter out = new BufferedWriter(fw); out.write( "study_id\tsite_id\tsubject_id\tSAMPLE_ID\tPLATFORM\tTISSUETYPE\tATTR1\tATTR2\tcategory_cd\n"); try { BufferedReader br = new BufferedReader(new FileReader(stsmf)); String line = br.readLine(); 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" + fields[8] + "\n"); } br.close(); } catch (Exception e) { this.setTissueTypeUI.displayMessage("File error: " + e.getLocalizedMessage()); out.close(); e.printStackTrace(); } out.close(); try { File fileDest; if (stsmf != null) { String fileName = stsmf.getName(); stsmf.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); ((GeneExpressionData) this.dataType).setSTSMF(fileDest); } catch (IOException ioe) { this.setTissueTypeUI.displayMessage("File error: " + ioe.getLocalizedMessage()); return; } } catch (Exception e) { this.setTissueTypeUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } this.setTissueTypeUI.displayMessage("Subject to sample mapping file updated"); WorkPart.updateSteps(); WorkPart.updateFiles(); }
From source file:org.mahasen.util.PutUtil.java
/** * @param part/*from w ww .j a v a 2 s .co m*/ * @param parentFileName * @param partName * @throws MahasenConfigurationException * @throws PastException * @throws InterruptedException */ public void replicateFilePart(File part, String parentFileName, String partName) throws MahasenConfigurationException, PastException, InterruptedException, MahasenException { Vector<String> nodeIpsToPut = getNodeIpsToPut(); String resourcePath = MahasenConstants.ROOT_REGISTRY_PATH + parentFileName; Id parentFileId = Id.build(String.valueOf(resourcePath.hashCode())); while (mahasenManager.lookupDHT(parentFileId) == null) { Thread.sleep(1000); } MahasenResource mahasenResourceToUpdate = mahasenManager.lookupDHT(parentFileId); getReplicaReference().put(partName, 0); Random random = new Random(); Hashtable<String, Vector<String>> spittedPartsStoredIps = mahasenResourceToUpdate.getSplittedPartsIpTable(); Vector<String> currentPartStoredIps = spittedPartsStoredIps.get(partName); List<String> replicateIds = new ArrayList<String>(); final BlockFlag blockFlag = new BlockFlag(true, 3000); while (true) { if (nodeIpsToPut.size() >= MahasenConstants.NUMBER_OF_REPLICAS + 1) { if (getReplicaReference().get(partName) == MahasenConstants.NUMBER_OF_REPLICAS) { log.info("Success in replicating :" + getReplicaReference().get(partName) + " parts"); break; } String nodeIp = nodeIpsToPut.get(random.nextInt(nodeIpsToPut.size())); if (!currentPartStoredIps.contains(nodeIp) && !replicateIds.contains(nodeIp)) { replicateIds.add(nodeIp); try { sendReplicateRequest(nodeIp, part, partName, mahasenResourceToUpdate, parentFileId); } catch (URISyntaxException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } } else { for (String ip : nodeIpsToPut) { if (!currentPartStoredIps.contains(ip)) { try { sendReplicateRequest(ip, part, partName, mahasenResourceToUpdate, parentFileId); } catch (URISyntaxException e) { e.printStackTrace(); } } } blockFlag.unblock(); break; } if (blockFlag.isBlocked()) { mahasenManager.getNode().getEnvironment().getTimeSource().sleep(10); } else { throw new MahasenException("Time out in storing " + part.getName()); } Thread.sleep(100); } }
From source file:picocash.Picocash.java
@Action public void managePayees() { Vector<Payee> payees = new Vector<Payee>(Services.getSelectedPersistenceMan().getAllPayees()); ManagePayeesDialog dialog = new ManagePayeesDialog(getMainFrame(), payees, true); dialog.setVisible(true);//from w w w . jav a 2 s.c o m if (dialog.getStatus() == DialogReturnStatus.OK) { log.debug("ManagePayeesDialog [OK]"); Vector<Payee> oldPayees = new Vector<Payee>(Services.getSelectedPersistenceMan().getAllPayees()); for (Payee payee : payees) { Services.getSelectedPersistenceMan().persist(payee); setChangesAvailable(true); } for (Payee payee : oldPayees) { if (!payees.contains(payee)) { List<Transaction> transactions = Services.getSelectedPersistenceMan() .getAllTransactionsForPayee(payee); for (Transaction transaction : transactions) { transaction.setPayee(null); } Services.getSelectedPersistenceMan().delete(payee); setChangesAvailable(true); if (log.isDebugEnabled()) { log.debug("old payee [" + payee.getName() + "] deleted"); } } } } else if (dialog.getStatus() == DialogReturnStatus.CANCEL) { log.debug("ManagePayeesDialog [CANCEL]"); } else { throw new IllegalStateException("ManagePayeesDialog not closed with ReturnStatus"); } }