List of usage examples for java.util HashSet iterator
public Iterator<E> iterator()
From source file:org.mskcc.cbio.portal.servlet.GeneDataJSON.java
/** * * @param request// w w w .j a v a 2 s. c om * @param response * @throws ServletException * @throws IOException */ @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // OncoQuery Language string String oql = request.getParameter("oql"); if (request instanceof XssRequestWrapper) { oql = ((XssRequestWrapper) request).getRawParameter("oql"); } oql = oql.replaceAll("\n", " \n "); List<String> sampleIdList; try { sampleIdList = WebserviceParserUtils.getSampleIds(request); } catch (ProtocolException e) { throw new ServletException(e); } catch (DaoException e) { throw new ServletException(e); } String _geneticProfileIds = request.getParameter("geneticProfileIds"); // list of geneticProfileIds separated by a space // e.g. gbm_mutations, gbm_cna_consensus HashSet<String> geneticProfileIdSet = new HashSet<String>( Arrays.asList(_geneticProfileIds.trim().split(" "))); // map geneticProfileIds -> geneticProfiles Iterator<String> gpSetIterator = geneticProfileIdSet.iterator(); ArrayList<GeneticProfile> profileList = new ArrayList<GeneticProfile>(); while (gpSetIterator.hasNext()) { String gp_str = gpSetIterator.next(); GeneticProfile gp = DaoGeneticProfile.getGeneticProfileByStableId(gp_str); profileList.add(gp); // pointer to gp is local, but gets added to profileList which is outside } double zScoreThreshold = Double.valueOf(request.getParameter("z_score_threshold")); double rppaScoreThreshold = Double.valueOf(request.getParameter("rppa_score_threshold")); // todo: this is code duplication! // this is a duplication of work that is being done in QueryBuilder. // For now, we cannot remove it from QueryBuilder because other parts use it...for now // ...this is a temporary solution ParserOutput theOncoPrintSpecParserOutput = OncoPrintSpecificationDriver.callOncoPrintSpecParserDriver(oql, geneticProfileIdSet, profileList, zScoreThreshold, rppaScoreThreshold); ArrayList<String> listOfGenes = theOncoPrintSpecParserOutput.getTheOncoPrintSpecification().listOfGenes(); String[] listOfGeneNames = new String[listOfGenes.size()]; listOfGeneNames = listOfGenes.toArray(listOfGeneNames); ArrayList<ProfileData> profileDataList = new ArrayList<ProfileData>(); Iterator<String> profileIterator = geneticProfileIdSet.iterator(); XDebug xdebug = new XDebug(request); while (profileIterator.hasNext()) { String profileId = profileIterator.next(); GeneticProfile profile = GeneticProfileUtil.getProfile(profileId, profileList); if (null == profile) { continue; } xdebug.logMsg(this, "Getting data for: " + profile.getProfileName()); GetProfileData remoteCall; List<Sample.Type> excludes = new ArrayList<Sample.Type>(); excludes.add(Sample.Type.SOLID_NORMAL); excludes.add(Sample.Type.BLOOD_NORMAL); String sampleIds = StringUtils.join(sampleIdList, " "); try { remoteCall = new GetProfileData(profile, listOfGenes, sampleIds); } catch (DaoException e) { throw new ServletException(e); } ProfileData pData = remoteCall.getProfileData(); if (pData == null) { System.err.println("pData == null"); } else { if (pData.getGeneList() == null) { System.err.println("pData.getValidGeneList() == null"); } if (pData.getCaseIdList().size() == 0) { System.err.println("pData.length == 0"); } } if (pData != null) { xdebug.logMsg(this, "Got number of genes: " + pData.getGeneList().size()); xdebug.logMsg(this, "Got number of cases: " + pData.getCaseIdList().size()); } xdebug.logMsg(this, "Number of warnings received: " + remoteCall.getWarnings().size()); profileDataList.add(pData); } xdebug.logMsg(this, "Merging Profile Data"); ProfileMerger merger = new ProfileMerger(profileDataList); ProfileData mergedProfile = merger.getMergedProfile(); ProfileDataSummary dataSummary = new ProfileDataSummary(mergedProfile, theOncoPrintSpecParserOutput.getTheOncoPrintSpecification(), zScoreThreshold, rppaScoreThreshold); GeneticEvent geneticEvents[][] = ConvertProfileDataToGeneticEvents.convert(dataSummary, listOfGeneNames, theOncoPrintSpecParserOutput.getTheOncoPrintSpecification(), zScoreThreshold, rppaScoreThreshold); // out.write the matrix response.setContentType("application/json"); PrintWriter out = response.getWriter(); JSONArray jsonArray = mapGeneticEventMatrix(geneticEvents); JSONArray.writeJSONString(jsonArray, out); }
From source file:com.sec.ose.osi.sdk.protexsdk.discovery.DCStringSearch.java
public ArrayList<String> resetFolder(String pFolderPath, String pStringSearch, String targetComponentName, String targetVersionName, UIResponseObserver mObserver, int compositeType) { ArrayList<String> resetTargetList = new ArrayList<String>(); HashSet<String> hs = IdentificationDBManager.getStringSearchResetTargetFile(this.projectName, pFolderPath, pStringSearch);//from w w w . j a va 2 s . c o m String target = ""; mObserver.setMessageHeader("Reset processing...\n"); if (hs == null) { return resetTargetList; } Iterator<String> it = hs.iterator(); while (it.hasNext()) { target = it.next(); mObserver.pushMessageWithHeader(" > filePath : " + target); updateStringSearchResetForLocalDB(target); resetTargetList.add(target); } return resetTargetList; }
From source file:org.apache.sysml.validation.ValidateLicAndNotice.java
/** * This will validate objects (class files) against license file. * * @param licenseFile is the name of the license file. * @param hashMapPackages is the list of package names to be validated for license. * @return Success or Failure code/*from w ww . jav a2s . co m*/ */ public static int validatePackages(String licenseFile, HashMap<String, Boolean> hashMapPackages) throws Exception { int iRetCode = Constants.SUCCESS; BufferedReader reader = new BufferedReader(new FileReader(licenseFile)); String line = null; HashSet<String> packageValidLic = new HashSet<String>(); while ((line = reader.readLine()) != null) { line = line.trim(); for (int i = 0; i < packageLicenses.length; ++i) { if (line.contains(packageLicenses[i][1])) { packageValidLic.add(packageLicenses[i][0]); Utility.debugPrint(Constants.DEBUG_INFO3, "License for package " + packageLicenses[i][0] + " exists."); } } } Iterator<Map.Entry<String, Boolean>> itPackages = hashMapPackages.entrySet().iterator(); while (itPackages.hasNext()) { Map.Entry<String, Boolean> pairPackage = (Map.Entry<String, Boolean>) itPackages.next(); Iterator<String> itLicPackages = packageValidLic.iterator(); while (itLicPackages.hasNext()) { if (((String) pairPackage.getKey()).startsWith((String) itLicPackages.next())) pairPackage.setValue(Boolean.TRUE); } } itPackages = hashMapPackages.entrySet().iterator(); while (itPackages.hasNext()) { Map.Entry pairPackage = (Map.Entry) itPackages.next(); if (!(Boolean) pairPackage.getValue()) { Utility.debugPrint(Constants.DEBUG_WARNING, "Could not validate license for package " + pairPackage.getKey() + ", please validate manually."); iRetCode = Constants.LIC_NOT_EXIST; } } return iRetCode; }
From source file:abs.backend.erlang.ClassGenerator.java
private void generateExports() { ecs.println("-export([get_val_internal/2,set_val_internal/3,init_internal/0,get_all_state/1])."); ecs.println("-compile(export_all)."); ecs.println();// www .j av a 2s.c om HashSet<MethodSig> callable_sigs = new HashSet<MethodSig>(); HashSet<InterfaceDecl> visited = new HashSet<InterfaceDecl>(); for (InterfaceTypeUse i : classDecl.getImplementedInterfaceUseList()) { visited.add((InterfaceDecl) i.getDecl()); } while (!visited.isEmpty()) { InterfaceDecl id = visited.iterator().next(); visited.remove(id); for (MethodSig ms : id.getBodyList()) { if (ms.isHTTPCallable()) { callable_sigs.add(ms); } } for (InterfaceTypeUse i : id.getExtendedInterfaceUseList()) { visited.add((InterfaceDecl) i.getDecl()); } } ecs.print("exported() -> #{ "); boolean first = true; for (MethodSig ms : callable_sigs) { if (ms.isHTTPCallable()) { if (!first) ecs.print(", "); first = false; ecs.print("<<\"" + ms.getName() + "\">> => { "); ecs.print("'m_" + ms.getName() + "'"); ecs.print(", "); ecs.print("<<\"" + ms.getReturnType().getType().getQualifiedName() + "\">>"); ecs.print(", "); ecs.print("[ "); boolean innerfirst = true; for (ParamDecl p : ms.getParamList()) { if (!innerfirst) ecs.print(", "); innerfirst = false; ecs.print("{ "); ecs.print("<<\"" + p.getName() + "\">>"); ecs.print(", "); ecs.print("<<\"" + p.getAccess().getType().getQualifiedName() + "\">>"); ecs.print(" }"); } ecs.print("] "); ecs.print("}"); } } ecs.println(" }."); ecs.println(); }
From source file:org.paxle.crawler.impl.SubCrawlerManager.java
/** * @see ISubParserManager#disabledMimeType() *//*from w w w. j a v a2 s . co m*/ public Set<String> disabledProtocols() { // get all available mime-types and remove enabled mime-types final HashSet<String> protocols = new HashSet<String>(this.subCrawlerList.keySet()); final Iterator<String> protocolIter = protocols.iterator(); while (protocolIter.hasNext()) { final String protocol = protocolIter.next(); if (this.isSupported(protocol)) { protocolIter.remove(); } } return protocols; }
From source file:org.cloudgraph.hbase.mutation.Update.java
private void collectSingular(EdgeWriter edgeWriter, PlasmaDataObject dataObject, HashSet<PlasmaDataObject> oldValues, PlasmaProperty property, Object value) throws IOException { PlasmaNode dataNode = (PlasmaNode) dataObject; List<PlasmaEdge> edges = dataNode.getEdges(property); PlasmaDataObject oldDataObject = null; if (oldValues.size() > 0) { if (oldValues.size() == 1) { oldDataObject = (PlasmaDataObject) oldValues.iterator().next(); } else//from ww w .java 2 s . c om throw new GraphServiceException( "unexpected List as old value for property, " + property.toString()); } // if has a new value PlasmaDataObject newDataObject = null; if (value != null) { PlasmaEdge edge = edges.get(0); newDataObject = edge.getOpposite(dataNode).getDataObject(); if (oldDataObject != null) edgeWriter.replace(oldDataObject, newDataObject); else // add the new one edgeWriter.add(newDataObject); } else { if (oldDataObject != null) edgeWriter.remove(oldDataObject); } }
From source file:org.paxle.core.impl.RuntimeSettings.java
public Dictionary<?, ?> getCurrentIniSettings() { final Dictionary<String, Object> props = new Hashtable<String, Object>(); final List<String> iniSettings = readSettings(); final StringBuilder sb = new StringBuilder(); final HashSet<OptEntry> opts = new HashSet<OptEntry>(OPTIONS); outer: for (final String opt : iniSettings) { final Iterator<OptEntry> it = opts.iterator(); while (it.hasNext()) { final OptEntry e = it.next(); if (opt.startsWith(e.fixOpt)) { props.put(e.getPid(), e.getValue(opt, true)); it.remove();/*from w ww . j av a 2 s. co m*/ continue outer; } } if (sb.length() > 0) sb.append(OPT_OTHER_SPLIT); sb.append(opt); } for (final OptEntry e : opts) props.put(e.getPid(), e.getValue(null, true)); if (sb.length() > 0) props.put(CM_OTHER_ENTRY.getPid(), sb.toString()); return props; }
From source file:org.plasma.provisioning.xsd.ConverterSupport.java
private void traverse(Class target, Class source, ClassVisitor visitor) { visitor.visit(target, source);// w w w. ja va2 s . c o m HashSet<Class> subclasses = this.subclassMap.get(target); if (subclasses != null) { Iterator<Class> iter = subclasses.iterator(); while (iter.hasNext()) { traverse(iter.next(), target, visitor); } } }
From source file:org.abs_models.backend.erlang.ClassGenerator.java
private void generateExports() { ecs.println(//from w w w. j a v a2s . c om "-export([get_val_internal/2,set_val_internal/3,init_internal/0,get_state_for_modelapi/1,implemented_interfaces/0,exported/0])."); ecs.println("-compile(export_all)."); ecs.println(); HashSet<MethodSig> callable_sigs = new HashSet<>(); HashSet<InterfaceDecl> visited = new HashSet<>(); for (InterfaceTypeUse i : classDecl.getImplementedInterfaceUseList()) { visited.add((InterfaceDecl) i.getDecl()); } while (!visited.isEmpty()) { InterfaceDecl id = visited.iterator().next(); visited.remove(id); for (MethodSig ms : id.getBodyList()) { if (ms.isHTTPCallable()) { callable_sigs.add(ms); } } for (InterfaceTypeUse i : id.getExtendedInterfaceUseList()) { visited.add((InterfaceDecl) i.getDecl()); } } ecs.print("implemented_interfaces() -> [ "); String separator = ""; for (InterfaceDecl i : classDecl.getSuperTypes()) { ecs.format("%s<<\"%s\">>", separator, i.getName()); separator = ", "; } ecs.println(" ]."); ecs.println(); ecs.print("exported() -> #{ "); boolean first = true; for (MethodSig ms : callable_sigs) { if (ms.isHTTPCallable()) { if (!first) ecs.print(", "); first = false; ecs.print("<<\"" + ms.getName() + "\">> => { "); ecs.print("'m_" + ms.getName() + "'"); ecs.print(", "); ecs.print("<<\"" + ms.getReturnType().getType().toString() + "\">>"); ecs.print(", "); ecs.print("[ "); boolean innerfirst = true; for (ParamDecl p : ms.getParamList()) { // For each parameter, we need name, human-readable type, // ABS type, and ABS type arguments (if present) if (!innerfirst) ecs.print(", "); innerfirst = false; ecs.print("{ "); ecs.print("<<\"" + p.getName() + "\">>, "); ecs.print("<<\"" + p.getType().toString() + "\">>, "); generateParameterDescription(p.getType()); ecs.print(" }"); } ecs.print("] "); ecs.print("}"); } } ecs.println(" }."); ecs.println(); }
From source file:crossbear.convergence.ConvergenceConnector.java
/** * Store a set of ConvergenceCertObservations in the local cache (i.e. the ConvergenceCertObservations-table). The local ConvergenceCertObservation-cache is used to reduce the network traffic generated by * Crossbear, to reduce the load on Convergence and to speed up the average response time of Certificate Verification Requests. * /*w w w. j a v a2s.c o m*/ * @param ccos The set of ConvergenceCertObservations that is to store in the local cache * @throws SQLException */ private void storeCCOsInCache(HashSet<ConvergenceCertObservation> ccos) throws SQLException { // Iterate over the whole set ... Iterator<ConvergenceCertObservation> itr = (Iterator<ConvergenceCertObservation>) ccos.iterator(); while (itr.hasNext()) { // ... and add each of its elements to the local cache storeCCOInCache(itr.next()); } }