List of usage examples for java.util Set iterator
Iterator<E> iterator();
From source file:org.eel.kitchen.jsonschema.keyword.AbstractKeywordValidatorTest.java
@DataProvider protected Iterator<Object[]> getData() { final Set<Object[]> set = Sets.newHashSet(); for (final JsonNode node : testData) set.add(mungeArguments(node));/*from ww w.ja v a 2 s.c o m*/ return set.iterator(); }
From source file:com.mycompany.addressbookv4.dao.AddressBookDaoDbImpl.java
@Override public List<Address> searchAddresss(Map<SearchTerm, String> criteria) { if (criteria.size() == 0) { return getAllAddresss(); } else {//from w ww.j a v a 2s . com StringBuilder sQuery = new StringBuilder("select * from addresses where "); // build the where clause int numParams = criteria.size(); int paramPosition = 0; String[] paramVals = new String[numParams]; Set<SearchTerm> keySet = criteria.keySet(); Iterator<SearchTerm> iter = keySet.iterator(); while (iter.hasNext()) { SearchTerm currentKey = iter.next(); if (paramPosition > 0) { sQuery.append(" and "); } sQuery.append(currentKey); sQuery.append(" = ? "); paramVals[paramPosition] = criteria.get(currentKey); paramPosition++; } return jdbcTemplate.query(sQuery.toString(), new AddressMapper(), paramVals); } }
From source file:com.tsg.contactlistmvc.dao.ContactListDaoDbImpl.java
@Override public List<Contact> searchContacts(Map<SearchTerm, String> criteria) { if (criteria.size() == 0) { return getAllContacts(); } else {//w ww . j a va 2 s . co m StringBuilder sQuery = new StringBuilder("select * from contacts where "); int numParams = criteria.size(); int paramPosition = 0; String[] paramVals = new String[numParams]; Set<SearchTerm> keyset = criteria.keySet(); Iterator<SearchTerm> iter = keyset.iterator(); while (iter.hasNext()) { SearchTerm currentKey = iter.next(); if (paramPosition > 0) { sQuery.append(" and "); } //adding new functionality to search partial values must use % symbol sQuery.append(currentKey); sQuery.append(" " + currentKey.getSearchOperator() + " ? "); paramVals[paramPosition] = criteria.get(currentKey); paramPosition++; } return jdbcTemplate.query(sQuery.toString(), new ContactMapper(), paramVals); } }
From source file:com.tsg.dvdlibrarymvc.dao.DvdLibraryDaoDbImpl.java
@Override public List<DVD> searchDvd(Map<SearchTerm, String> criteria) { if (criteria.size() == 0) { return getAllDVDs(); } else {//from w ww. java2 s.com StringBuilder sQuery = new StringBuilder("select * from dvds where "); int numParams = criteria.size(); int paramPosition = 0; String[] paramVals = new String[numParams]; Set<SearchTerm> keyset = criteria.keySet(); Iterator<SearchTerm> iter = keyset.iterator(); while (iter.hasNext()) { SearchTerm currentKey = iter.next(); if (paramPosition > 0) { sQuery.append(" and "); } sQuery.append(currentKey); sQuery.append(" = ? "); paramVals[paramPosition] = criteria.get(currentKey); paramPosition++; } return jdbcTemplate.query(sQuery.toString(), new DvdMapper(), paramVals); } }
From source file:WpRDFFunctionLibrary.java
public static void getUnifiedIdentifiers(Model model, IDMapper mapper, Xref idXref, Resource internalWPDataNodeResource) throws IDMapperException, UnsupportedEncodingException { //ENSEMBL/*from w ww .j a v a 2 s. co m*/ Set<Xref> unifiedEnsemblIdXref = mapper.mapID(idXref, BioDataSource.ENSEMBL); Iterator<Xref> iter = unifiedEnsemblIdXref.iterator(); while (iter.hasNext()) { Xref unifiedId = (Xref) iter.next(); String unifiedEnsemblDataNodeIdentifier = URLEncoder.encode(unifiedId.getId(), "UTF-8"); Resource unifiedEnsemblIdResource = model .createResource("http://identifiers.org/ensembl/" + unifiedEnsemblDataNodeIdentifier); internalWPDataNodeResource.addProperty(Wp.bdbEnsembl, unifiedEnsemblIdResource); } //Uniprot Set<Xref> unifiedUniprotIdXref = mapper.mapID(idXref, DataSource.getBySystemCode("S")); Iterator<Xref> iterUniprot = unifiedUniprotIdXref.iterator(); while (iterUniprot.hasNext()) { Xref unifiedUniprotId = (Xref) iterUniprot.next(); String unifiedUniprotDataNodeIdentifier = URLEncoder.encode(unifiedUniprotId.getId(), "UTF-8"); Resource unifiedUniprotIdResource = model .createResource("http://identifiers.org/uniprot/" + unifiedUniprotDataNodeIdentifier); internalWPDataNodeResource.addProperty(Wp.bdbUniprot, unifiedUniprotIdResource); } //Entrez Gene Set<Xref> unifiedEntrezGeneIdXref = mapper.mapID(idXref, BioDataSource.ENTREZ_GENE); Iterator<Xref> iterEntrezGene = unifiedEntrezGeneIdXref.iterator(); while (iterEntrezGene.hasNext()) { Xref unifiedEntrezGeneId = (Xref) iterEntrezGene.next(); String unifiedEntrezGeneDataNodeIdentifier = URLEncoder.encode(unifiedEntrezGeneId.getId(), "UTF-8"); Resource unifiedEntrezGeneIdResource = model .createResource("http://identifiers.org/ncbigene/" + unifiedEntrezGeneDataNodeIdentifier); internalWPDataNodeResource.addProperty(Wp.bdbEntrezGene, unifiedEntrezGeneIdResource); } //HGNC Symbols Set<Xref> unifiedHGNCSymboXref = mapper.mapID(idXref, DataSource.getBySystemCode("H")); Iterator<Xref> iterhgncsymbol = unifiedHGNCSymboXref.iterator(); while (iterhgncsymbol.hasNext()) { Xref unifiedHGNCSymbol = (Xref) iterhgncsymbol.next(); String unifiedHGNCSymbolDataNodeIdentifier = URLEncoder.encode(unifiedHGNCSymbol.getId(), "UTF-8"); Resource unifiedHGNCSymbolResource = model .createResource("http://identifiers.org/hgnc.symbol/" + unifiedHGNCSymbolDataNodeIdentifier); internalWPDataNodeResource.addProperty(Wp.bdbHgncSymbol, unifiedHGNCSymbolResource); } //HMDB Set<Xref> unifiedHmdbIdXref = mapper.mapID(idXref, BioDataSource.HMDB); Iterator<Xref> iterHmdb = unifiedHmdbIdXref.iterator(); while (iterHmdb.hasNext()) { Xref unifiedHmdbId = (Xref) iterHmdb.next(); String unifiedHmdbDataNodeIdentifier = URLEncoder.encode(unifiedHmdbId.getId(), "UTF-8"); Resource unifiedHmdbIdResource = model .createResource("http://identifiers.org/hmdb/" + unifiedHmdbDataNodeIdentifier); internalWPDataNodeResource.addProperty(Wp.bdbHmdb, unifiedHmdbIdResource); //createCHEMINFBits(model, // internalWPDataNodeResource, CHEMINF.CHEMINF_000408, unifiedHmdbDataNodeIdentifier //); } //CHEMSPIDER Set<Xref> unifiedChemspiderIdXref = mapper.mapID(idXref, BioDataSource.CHEMSPIDER); Iterator<Xref> iterChemspider = unifiedChemspiderIdXref.iterator(); while (iterChemspider.hasNext()) { Xref unifiedChemspiderId = (Xref) iterChemspider.next(); String unifiedChemspiderDataNodeIdentifier = URLEncoder.encode(unifiedChemspiderId.getId(), "UTF-8"); Resource unifiedChemspiderIdResource = model .createResource("http://identifiers.org/chemspider/" + unifiedChemspiderDataNodeIdentifier); internalWPDataNodeResource.addProperty(Wp.bdbChemspider, unifiedChemspiderIdResource); //createCHEMINFBits(model, // internalWPDataNodeResource, CHEMINF.CHEMINF_000405, unifiedChemspiderDataNodeIdentifier //); } }
From source file:com.jkoolcloud.tnt4j.streams.utils.NamespaceMap.java
@Override public Iterator<String> getPrefixes(String namespaceURI) { Set<String> nsList = mapURI.get(namespaceURI); return nsList == null ? EMPTY_NS_LIST.iterator() : nsList.iterator(); }
From source file:me.springframework.di.spring.PropertyValuesTest.java
@Test public void beanShouldInheritTypeOfParentBeanIfNotSpecified() { Resource resource = new ClassPathResource("/properties.xml", getClass()); Configuration configuration = readConfiguration(resource); InMemoryDestination dest = new InMemoryDestination("test"); BeanFactoryGenerator.generate(dest, configuration, MINIMAL_JAVA_SE); Instance person = configuration.get("person"); assertEquals(Teacher.class.getName(), person.getReferencedType()); Set<? extends PropertySetter> props = person.getSetters(); assertEquals(1, props.size());/*w w w . ja va2 s .c om*/ PropertySetter setter = props.iterator().next(); LiteralSource source = (LiteralSource) setter.getSource(); assertEquals("Bob", source.getValue()); }
From source file:org.ala.apps.RkColumnFamilyExporter.java
private void exportRanks() throws Exception { FileOutputStream csvOut = FileUtils .openOutputStream(new File("/data/bie/rk_" + System.currentTimeMillis() + ".csv")); long start = System.currentTimeMillis(); int i = 0;/*from ww w. j a v a2s . c o m*/ int j = 0; logger.debug("export Ranks..."); Scanner scanner = storeHelper.getScanner(RK_COLUMN_FAMILY, RK_COLUMN_FAMILY, "", ColumnType.columnsToIndex); byte[] guidAsBytes = null; while ((guidAsBytes = scanner.getNextGuid()) != null) { String guid = new String(guidAsBytes); String taxonGuid = guid.substring(0, guid.indexOf("|")); String sciName = ""; try { ExtendedTaxonConceptDTO etc = taxonConceptDao.getExtendedTaxonConceptByGuid(taxonGuid, false); if (etc != null && etc.getTaxonConcept() != null) { sciName = etc.getTaxonConcept().getNameString(); } } catch (Exception e) { logger.error("etc.getTaxonConcept(): " + e); } i++; try { //get taxon concept details List<String> list = storeHelper.getSuperColumnsByGuid(guid, RK_COLUMN_FAMILY); for (String superColumnName : list) { try { Map<String, List<Comparable>> columnList = storeHelper.getColumnList(RK_COLUMN_FAMILY, guid, Map.class); Set<String> keys = columnList.keySet(); Iterator<String> itr = keys.iterator(); while (itr.hasNext()) { j++; String key = itr.next(); List rankingList = columnList.get(key); String type = guid.substring(guid.indexOf("|") + 1, guid.length()); csvOut.write((guid + "; " + sciName + "; " + type + "; " + key + "; " + mapper.writeValueAsString(rankingList) + "\n").getBytes()); logger.debug("Indexed records: " + j + ", current guid: " + guid); } } catch (Exception ex) { logger.error("***** guid: " + guid + " ," + ex); } } } catch (Exception ex) { logger.error("***** guid: " + guid + " ," + ex); } } csvOut.flush(); csvOut.close(); long finish = System.currentTimeMillis(); logger.info("Index created in: " + ((finish - start) / 1000) + " seconds with species: " + i + ", column items: " + j); logger.debug("reload Ranks finished..."); }
From source file:com.abm.mainet.water.ui.controller.PlumberLicenseFormController.java
@RequestMapping(method = RequestMethod.POST, params = "getCheckListAndCharges") public ModelAndView doGetApplicableCheckListAndCharges(HttpServletRequest httpServletRequest) { this.bindModel(httpServletRequest); long orgId = UserSession.getCurrent().getOrganisation().getOrgid(); ModelAndView modelAndView = null;/* w ww. j av a2 s . c o m*/ PlumberLicenseFormModel model = this.getModel(); try { for (Iterator<Entry<Long, Set<File>>> it = FileUploadUtility.getCurrent().getFileMap().entrySet() .iterator(); it.hasNext();) { Entry<Long, Set<File>> entry = it.next(); if (entry.getKey().longValue() == 0) { Set<File> set = entry.getValue(); File file = set.iterator().next(); String bytestring = ""; Base64 base64 = new Base64(); try { bytestring = base64.encodeToString(FileUtils.readFileToByteArray(file)); } catch (IOException e) { logger.error("Exception has been occurred in file byte to string conversions", e); } String plumberImage = file.getName(); model.setPlumberImage(plumberImage); model.getPlumberLicenseReqDTO().setPlumberImage(plumberImage); model.getPlumberLicenseReqDTO().setImageByteCode(bytestring); break; } } if (model.getPlumberImage() == null || model.getPlumberImage().isEmpty()) { this.getModel().addValidationError(ApplicationSession.getInstance() .getMessage("water.plumberLicense.valMsg.uploadPlumberPhoto")); } else { model.findApplicableCheckListAndCharges(this.getModel().getServiceId(), orgId); } modelAndView = new ModelAndView("PlumberLicenseFormValidn", "command", model); if (model.getBindingResult() != null) { modelAndView.addObject(BindingResult.MODEL_KEY_PREFIX + MainetConstants.FORM_NAME, getModel().getBindingResult()); } } catch (Exception ex) { modelAndView = defaultExceptionFormView(); } return modelAndView; }
From source file:com.prey.receivers.C2DMReceiver.java
private void handleMessage(Context context, Intent intent) { PreyLogger.d("PUSH_______________"); PreyConfig config = PreyConfig.getPreyConfig(context); Set<String> set = intent.getExtras().keySet(); Iterator<String> ite = set.iterator(); while (ite.hasNext()) { String key = ite.next();/* ww w. j a v a 2 s . co m*/ PreyLogger.d("___[" + key + "]" + intent.getExtras().getString(key)); } String body = intent.getExtras().getString("body"); String version = intent.getExtras().getString("version"); String api_key = intent.getExtras().getString("api_key"); String remote_email = intent.getExtras().getString("remote_email"); String cmd = intent.getExtras().getString("cmd"); if ((api_key != null && !"".equals(api_key)) || (body != null && body.indexOf("api_key") > 0)) { registrationPlanB(context, api_key, remote_email, body); } else { handleMessageBeta(context, body, version, cmd); config.setVersion(PreyConfig.VERSION_V2); } }