List of usage examples for com.google.common.collect Multiset add
@Override
boolean add(E element);
From source file:de.iteratec.iteraplan.businesslogic.service.DashboardServiceImpl.java
/** {@inheritDoc} */ public Map<String, Integer> getIsrStatusMap(List<InformationSystemRelease> isrs) { Multiset<InformationSystemRelease.TypeOfStatus> multiset = EnumMultiset .create(InformationSystemRelease.TypeOfStatus.class); for (InformationSystemRelease tcr : isrs) { multiset.add(tcr.getTypeOfStatus()); }// w ww . ja v a 2 s. c o m Map<String, Integer> statusMap = Maps.newLinkedHashMap(); for (InformationSystemRelease.TypeOfStatus status : InformationSystemRelease.TypeOfStatus.values()) { statusMap.put(status.toString(), Integer.valueOf(multiset.count(status))); } return statusMap; }
From source file:org.sonar.plugins.core.issue.CountUnresolvedIssuesDecorator.java
public void decorate(Resource resource, DecoratorContext context) { Issuable issuable = perspectives.as(Issuable.class, resource); if (issuable != null) { Collection<Issue> issues = issuable.issues(); boolean shouldSaveNewMetrics = shouldSaveNewMetrics(context); Multiset<RulePriority> severityBag = HashMultiset.create(); Map<RulePriority, Multiset<Rule>> rulesPerSeverity = Maps.newHashMap(); ListMultimap<RulePriority, Issue> issuesPerSeverity = ArrayListMultimap.create(); int countOpen = 0; int countReopened = 0; int countConfirmed = 0; for (Issue issue : issues) { severityBag.add(RulePriority.valueOf(issue.severity())); Multiset<Rule> rulesBag = initRules(rulesPerSeverity, RulePriority.valueOf(issue.severity())); rulesBag.add(rulefinder.findByKey(issue.ruleKey().repository(), issue.ruleKey().rule())); issuesPerSeverity.put(RulePriority.valueOf(issue.severity()), issue); if (Issue.STATUS_OPEN.equals(issue.status())) { countOpen++;//from w w w . j a v a 2 s .c om } if (Issue.STATUS_REOPENED.equals(issue.status())) { countReopened++; } if (Issue.STATUS_CONFIRMED.equals(issue.status())) { countConfirmed++; } } for (RulePriority ruleSeverity : RulePriority.values()) { saveIssuesForSeverity(context, ruleSeverity, severityBag); saveIssuesPerRules(context, ruleSeverity, rulesPerSeverity); saveNewIssuesForSeverity(context, ruleSeverity, issuesPerSeverity, shouldSaveNewMetrics); saveNewIssuesPerRule(context, ruleSeverity, issues, shouldSaveNewMetrics); } saveTotalIssues(context, issues); saveNewIssues(context, issues, shouldSaveNewMetrics); saveMeasure(context, CoreMetrics.OPEN_ISSUES, countOpen); saveMeasure(context, CoreMetrics.REOPENED_ISSUES, countReopened); saveMeasure(context, CoreMetrics.CONFIRMED_ISSUES, countConfirmed); } }
From source file:de.iteratec.iteraplan.businesslogic.service.DashboardServiceImpl.java
/** {@inheritDoc} */ public Map<String, Integer> getTechnicalComponentsStatusMap(List<TechnicalComponentRelease> tcrs) { Multiset<TechnicalComponentRelease.TypeOfStatus> multiset = EnumMultiset .create(TechnicalComponentRelease.TypeOfStatus.class); for (TechnicalComponentRelease tcr : tcrs) { multiset.add(tcr.getTypeOfStatus()); }// w ww .j av a 2s . co m Map<String, Integer> statusMap = Maps.newLinkedHashMap(); for (TechnicalComponentRelease.TypeOfStatus status : TechnicalComponentRelease.TypeOfStatus.values()) { statusMap.put(status.toString(), Integer.valueOf(multiset.count(status))); } return statusMap; }
From source file:org.icgc.dcc.submission.dictionary.DictionaryValidator.java
private void validateCodeLists(Set<DictionaryConstraintViolation> errors, Set<DictionaryConstraintViolation> warnings) { for (val codeListName : dictionary.getCodeListNames()) { val collection = codeListIndex.get(codeListName); int count = collection.size(); if (count == 0) { warnings.add(new DictionaryConstraintViolation("Missing code list", codeListName)); break; }/*from w w w . j ava 2 s. co m*/ if (count > 1) { errors.add(new DictionaryConstraintViolation("Duplicate code lists", collection)); } val codeList = getFirst(collection, null); Multiset<String> codes = HashMultiset.create(); Multiset<String> values = HashMultiset.create(); for (val term : codeList.getTerms()) { codes.add(term.getCode()); values.add(term.getValue()); } for (val term : codeList.getTerms()) { val code = term.getCode(); val value = term.getValue(); if (codes.count(code) > 1) { errors.add( new DictionaryConstraintViolation("Duplicate code list codes", term, code, codeList)); } if (values.count(value) > 1) { errors.add( new DictionaryConstraintViolation("Duplicate code list values", term, value, codeList)); } if (codes.contains(value) && !code.equals(value)) { errors.add(new DictionaryConstraintViolation("Non-disjoint code list code and value", term, value, codeList)); } } } }
From source file:org.sonar.plugins.core.issue.CountOpenIssuesDecorator.java
public void decorate(Resource resource, DecoratorContext context) { Issuable issuable = perspectives.as(Issuable.class, resource); if (issuable != null) { Collection<Issue> issues = getOpenIssues(issuable.issues()); boolean shouldSaveNewMetrics = shouldSaveNewMetrics(context); Multiset<RulePriority> severityBag = HashMultiset.create(); Map<RulePriority, Multiset<Rule>> rulesPerSeverity = Maps.newHashMap(); ListMultimap<RulePriority, Issue> issuesPerSeverity = ArrayListMultimap.create(); int countOpen = 0; int countReopened = 0; int countConfirmed = 0; for (Issue issue : issues) { severityBag.add(RulePriority.valueOf(issue.severity())); Multiset<Rule> rulesBag = initRules(rulesPerSeverity, RulePriority.valueOf(issue.severity())); rulesBag.add(rulefinder.findByKey(issue.ruleKey().repository(), issue.ruleKey().rule())); issuesPerSeverity.put(RulePriority.valueOf(issue.severity()), issue); if (Issue.STATUS_OPEN.equals(issue.status())) { countOpen++;//from w w w. java 2 s .co m } if (Issue.STATUS_REOPENED.equals(issue.status())) { countReopened++; } if (Issue.STATUS_CONFIRMED.equals(issue.status())) { countConfirmed++; } } for (RulePriority ruleSeverity : RulePriority.values()) { saveIssuesForSeverity(context, ruleSeverity, severityBag); saveIssuesPerRules(context, ruleSeverity, rulesPerSeverity); saveNewIssuesForSeverity(context, ruleSeverity, issuesPerSeverity, shouldSaveNewMetrics); saveNewIssuesPerRule(context, ruleSeverity, issues, shouldSaveNewMetrics); } saveTotalIssues(context, issues); saveNewIssues(context, issues, shouldSaveNewMetrics); saveMeasure(context, CoreMetrics.OPEN_ISSUES, countOpen); saveMeasure(context, CoreMetrics.REOPENED_ISSUES, countReopened); saveMeasure(context, CoreMetrics.CONFIRMED_ISSUES, countConfirmed); } }
From source file:br.com.bluesoft.pronto.model.Ticket.java
public boolean isEmAndamento() { if (temFilhos()) { final Multiset<Integer> contadorDeStatus = HashMultiset.create(); final int quantidadeDeFilhos = filhos.size(); for (final Ticket filho : filhos) { contadorDeStatus.add(filho.getKanbanStatus().getKanbanStatusKey()); }//from w w w .j av a 2s .c o m if (contadorDeStatus.count(KanbanStatus.DONE) != quantidadeDeFilhos && contadorDeStatus.count(KanbanStatus.TO_DO) != quantidadeDeFilhos) { return true; } else { return false; } } else { return !isDone() && !isToDo(); } }
From source file:additionalpipes.chunk.ChunkManager.java
public void sendPersistentChunks(EntityPlayerMP player) { Multiset<ChunkCoordIntPair> oldSet = players.get(player); boolean showAllPersistentChunks = oldSet.remove(null); Multiset<ChunkCoordIntPair> newSet = HashMultiset.create(); WorldServer world = (WorldServer) player.worldObj; for (Map.Entry<ChunkCoordIntPair, Ticket> e : ForgeChunkManager.getPersistentChunksFor(world).entries()) { if (!showAllPersistentChunks && !APDefaultProps.ID.equals(e.getValue().getModId())) { continue; }/*from ww w . ja va 2s. c o m*/ if (world.getPlayerManager().isPlayerWatchingChunk(player, e.getKey().chunkXPos, e.getKey().chunkZPos)) { newSet.add(e.getKey()); } } if (!oldSet.equals(newSet)) { PacketChunkCoordList packet = new PacketChunkCoordList(APPacketIds.UPDATE_LASERS, newSet); CoreProxy.proxy.sendToPlayer(player, packet); if (showAllPersistentChunks) { newSet.add(null); } players.put(player, newSet); } }
From source file:tr.com.serkanozal.proxyable.util.JvmUtil.java
private static int guessAlignment(int oopSize) { final int COUNT = 1000 * 1000; Object[] array = new Object[COUNT]; long[] offsets = new long[COUNT]; for (int c = 0; c < COUNT - 3; c += 3) { array[c + 0] = new MyObject1(); array[c + 1] = new MyObject2(); array[c + 1] = new MyObject3(); }//from ww w . j a v a 2 s . c o m for (int c = 0; c < COUNT; c++) { offsets[c] = addressOfObject(array[c], oopSize); } Arrays.sort(offsets); Multiset<Integer> sizes = HashMultiset.create(); for (int c = 1; c < COUNT; c++) { sizes.add((int) (offsets[c] - offsets[c - 1])); } int min = -1; for (int s : sizes.elementSet()) { if (s <= 0) { continue; } if (min == -1) { min = s; } else { min = gcd(min, s); } } return min; }
From source file:com.addthis.hydra.data.filter.value.ValueFilterGrepTags.java
@Override @Nullable//from w w w.j a va2 s . c o m public ValueObject filterValue(ValueObject value) { if (value == null) { return null; } String html = value.asString().asNative(); if (html == null) { return null; } @Nonnull Multiset<String> valueCounts = HashMultiset.create(); try { Parser parser = Parser.htmlParser().setTrackErrors(0); @Nonnull Document doc = parser.parseInput(html, ""); @Nonnull Elements tags = doc.select(tagName); for (Element tag : tags) { for (String tagAttr : tagAttrs) { @Nonnull String attrValue = tag.attr(tagAttr).toLowerCase(); for (String matchValue : values) { if (attrValue.contains(matchValue)) { valueCounts.add(matchValue); } } } } } catch (Exception e) { if (parserErrors++ % logEveryN == 0) { log.error("Failed to extract tags due to : {} Total Parser Errors : {}", e.getMessage(), parserErrors); } } return valueCounts.isEmpty() ? null : multisetToValueMap(valueCounts); }
From source file:de.hzi.helmholtz.Compare.SimpleCompareUsingModules.java
public void comparePathways(String ALGORITHM, String windowsize, String ProcessID) { try {// w ww . j a v a 2 s . c o m Iterator<DBPathwayUsingModules> firstIter = QueryPathway.iterator(); Iterator<DBPathwayUsingModules> secondIter = allPathways.iterator(); SizeofTargetPathwaysInDatabase = allPathways.size(); maxWindowSize = Integer.parseInt(windowsize.trim()); UniqueJobID = ProcessID; while (firstIter.hasNext()) { DBPathwayUsingModules source = firstIter.next(); //secondIter.next(); //////System.out.println("**************************************************"); secondIter = allPathways.iterator(); while (secondIter.hasNext()) { SizeofQueryPathway = 0; DBPathwayUsingModules target = secondIter.next(); //////System.out.println(source.getPathwayID() + " && " + target.getPathwayID()); Map<String, Integer> srcGeneIdToPositionMap = new TreeMap<String, Integer>(); int temp = 0; sourcecopy = new PathwayUsingModules(source.convertToPathwayObj()); targetcopy = new PathwayUsingModules(target.convertToPathwayObj()); for (Map.Entry<String, List<String>> e : source.getPathway().entrySet()) { SizeofQueryPathway += e.getValue().size(); srcGeneIdToPositionMap.put(e.getKey(), temp++); } Map<String, Integer> tgtGeneIdToPositionMap = new TreeMap<String, Integer>(); temp = 0; for (Map.Entry<String, List<String>> e : target.getPathway().entrySet()) { tgtGeneIdToPositionMap.put(e.getKey(), temp++); } source.printPathway(); target.printPathway(); //source.convertToPathwayObj().getModules() Iterator<Module> sourceGeneIt = source.convertToPathwayObj().geneIterator(); Multiset<String> qfunction = LinkedHashMultiset.create(); while (sourceGeneIt.hasNext()) { Module queryGene = sourceGeneIt.next(); for (Domain d : queryGene.getDomains()) { qfunction.add(d.getDomainFunctionString()); } } Iterator<Module> targetGeneIt = target.convertToPathwayObj().geneIterator(); Multiset<String> tfunction = LinkedHashMultiset.create(); while (targetGeneIt.hasNext()) { Module targetGene = targetGeneIt.next(); for (Domain d : targetGene.getDomains()) { tfunction.add(d.getDomainFunctionString()); } } Multiset<String> DomainsCommon = Multisets.intersection(qfunction, tfunction); if (DomainsCommon.size() > 5) { PathwayComparisonUsingModules pComparison = new PathwayComparisonUsingModules( source.convertToPathwayObj(), target.convertToPathwayObj(), maxWindowSize, UniqueJobID, ALGORITHM, self); } //PathwayComparison pComparison = new PathwayComparison(target.convertToPathwayObj(), source.convertToPathwayObj()); // // //////System.out.println(SizeofQueryPathway + " " + SizeofTargetPathwaysInDatabase); //break; } //System.out.println("**************************************************"); } //System.out.println("Done ... Enjoy with your results"); } catch (Exception ex) { //System.out.println("Error in SimpleCompare:" + ex); Logger.getLogger(ThriftServer.class.getName()).log(Level.SEVERE, null, ex); } ////System.out.println("done"); // JOptionPane.showMessageDialog(null, "Done", "less arguments" + " sdsdsd321321", JOptionPane.INFORMATION_MESSAGE); }