List of usage examples for com.google.common.collect ArrayListMultimap create
public static <K, V> ArrayListMultimap<K, V> create()
From source file:io.mapzone.arena.analytics.graph.OrganisationPersonGraphFunction.java
@Override public void generate(MdToolkit tk, IProgressMonitor monitor, Graph graph) throws Exception { if (!tk.isClosed()) { tk.createSnackbar(Appearance.FadeIn, "Analysis started - stay tuned..."); }//from ww w. ja v a 2s . c o m final Map<String, Node> organisations = Maps.newHashMap(); final Map<String, Node> persons = Maps.newHashMap(); final Multimap<Node, Node> organisation2Persons = ArrayListMultimap.create(); final Multimap<Node, Node> person2Organisations = ArrayListMultimap.create(); // iterate on features // create Node for each organisation // increase weight for each entry per organisation FeatureIterator iterator = featureSource.getFeatures().features(); int i = 0; while (iterator.hasNext() && i < 5000) { i++; SimpleFeature feature = (SimpleFeature) iterator.next(); String organisationKey = (String) feature.getAttribute("Organisation"); Node organisationFeature = organisations.get(organisationKey); if (organisationFeature == null) { organisationFeature = new Node(Node.Type.virtual, "o:" + feature.getID(), featureSource, feature, organisationKey, 1); organisations.put(organisationKey, organisationFeature); graph.addOrUpdateNode(organisationFeature); } else { // add weight int size = organisation2Persons.get(organisationFeature).size() + 1; if (size <= 15) { organisationFeature.increaseWeight(); } graph.addOrUpdateNode(organisationFeature); } String personKey = (String) feature.getAttribute("Name") + " " + (String) feature.getAttribute("Vorname"); Node personFeature = persons.get(personKey); if (personFeature == null) { personFeature = new Node(Node.Type.real, "p:" + feature.getID(), featureSource, feature, personKey, 1); persons.put(personKey, personFeature); graph.addOrUpdateNode(personFeature); } else { int size = person2Organisations.get(personFeature).size() + 1; if (size <= 15) { personFeature.increaseWeight(); } graph.addOrUpdateNode(personFeature); } // add also the person to the organisation organisation2Persons.put(organisationFeature, personFeature); person2Organisations.put(personFeature, organisationFeature); graph.addOrUpdateEdge(organisationFeature, personFeature); if (i % 100 == 0) { log.info("added " + i); } } if (!tk.isClosed()) { tk.createSnackbar(Appearance.FadeIn, organisations.size() + " organisations, " + persons.size() + " persons and " + organisation2Persons.size() + " relations analysed"); } organisations.clear(); persons.clear(); organisation2Persons.clear(); person2Organisations.clear(); graph.layout(); }
From source file:org.opendaylight.controller.md.sal.dom.store.impl.replica.ResolveDataChangeEventsTask.java
/** * Resolves and submits notification tasks to the specified manager. *//* w w w . ja v a2s .c o m*/ public synchronized void resolve( final NotificationManager<DataChangeListenerRegistration<?>, DOMImmutableDataChangeEvent> manager) { try (final Walker w = listenerRoot.getWalker()) { // Defensive: reset internal state collectedEvents = ArrayListMultimap.create(); // Run through the tree final ResolveDataChangeState s = ResolveDataChangeState.initial(candidate.getRootPath(), w.getRootNode()); resolveAnyChangeEvent(s, candidate.getRootNode()); /* * Convert to tasks, but be mindful of multiple values -- those indicate multiple * wildcard matches, which need to be merged. */ for (Entry<DataChangeListenerRegistration<?>, Collection<DOMImmutableDataChangeEvent>> e : collectedEvents .asMap().entrySet()) { final Collection<DOMImmutableDataChangeEvent> col = e.getValue(); final DOMImmutableDataChangeEvent event; if (col.size() != 1) { final Builder b = DOMImmutableDataChangeEvent.builder(DataChangeScope.BASE); for (DOMImmutableDataChangeEvent i : col) { b.merge(i); } event = b.build(); LOG.trace("Merged events {} into event {}", col, event); } else { event = col.iterator().next(); } manager.submitNotification(e.getKey(), event); } } }
From source file:com.isotrol.impe3.support.action.RedirectAction.java
protected final void registerSuccessQP(String name, Object value) { if (hasText(name) && hasValue(value)) { if (okQP == null) { okQP = ArrayListMultimap.create(); }/*from w w w .jav a 2 s . co m*/ okQP.put(name, value); } }
From source file:com.google.idea.blaze.base.run.testmap.FilteredTargetMap.java
private static Multimap<File, TargetKey> createRootsMap(ArtifactLocationDecoder artifactLocationDecoder, Collection<TargetIdeInfo> targets) { Multimap<File, TargetKey> result = ArrayListMultimap.create(); for (TargetIdeInfo target : targets) { for (ArtifactLocation source : target.sources) { result.put(artifactLocationDecoder.decode(source), target.key); }/* w w w . j a v a 2 s . co m*/ } return result; }
From source file:com.greensopinion.finance.services.reports.ReportsService.java
public IncomeVersusExpensesReport incomeVersusExpenses() { IncomeVersusExpensesReport report = new IncomeVersusExpensesReport(); Transactions transactions = transactionsService.retrieve(); ListMultimap<Long, Transaction> transactionsByMonth = ArrayListMultimap.create(); for (Transaction transaction : transactions.getTransactions()) { Long yearMonth = yearMonth(transaction.getDate()); transactionsByMonth.put(yearMonth, transaction); }/* w ww . j a v a 2s. c om*/ List<Long> sortedMonths = new ArrayList<>(transactionsByMonth.keySet()); Collections.sort(sortedMonths); for (final Long yearMonth : sortedMonths) { String name = monthName(yearMonth); report.addMonth(new Month(yearMonth, name, transactionsByMonth.get(yearMonth))); } return report; }
From source file:com.android.build.gradle.integration.common.truth.NativeAndroidProjectSubject.java
@NonNull private Multimap<String, NativeArtifact> getArtifactsByName() { Multimap<String, NativeArtifact> groupToArtifacts = ArrayListMultimap.create(); for (NativeArtifact artifact : getSubject().getArtifacts()) { groupToArtifacts.put(artifact.getName(), artifact); }//from w w w.jav a2 s. com return groupToArtifacts; }
From source file:com.github.drbookings.model.data.manager.MainManager.java
MainManager() { roomProvider = new RoomProvider(); guestProvider = new GuestProvider(); cleaningProvider = new CleaningProvider(); bookingOriginProvider = new BookingOriginProvider(); bookings = new ArrayList<>(); cleaningEntries = ArrayListMultimap.create(); bookingEntries = ArrayListMultimap.create(); uiData = new SimpleListProperty<>(FXCollections.observableArrayList(DateBean.extractor())); uiDataMap = new LinkedHashMap<>(); }
From source file:org.robotframework.ide.eclipse.main.plugin.model.locators.AccessibleKeywordsEntities.java
public ListMultimap<KeywordScope, KeywordEntity> getPossibleKeywords() { final Map<String, Collection<KeywordEntity>> allKeywords = getAccessibleKeywords(); final ListMultimap<KeywordScope, KeywordEntity> scopedKeywords = ArrayListMultimap.create(); for (final Collection<KeywordEntity> entities : allKeywords.values()) { for (final KeywordEntity entity : filterDuplicates(entities)) { scopedKeywords.put(entity.getScope(getFilepath()), entity); }//from www . java2 s.co m } return scopedKeywords; }
From source file:com.proofpoint.galaxy.shared.MockUriInfo.java
public static MultivaluedMap<String, String> decodeQuery(String query, boolean decode) { if (query == null) { return emptyMultivaluedMap(); }/* w ww. j a va 2 s . c om*/ ArrayListMultimap<String, String> map = ArrayListMultimap.create(); for (String param : QUERY_STRING_SPLITTER.split(query)) { List<String> pair = ImmutableList.copyOf(QUERY_PARAM_SPLITTER.split(param)); if (pair.isEmpty()) { continue; } String key = urlDecode(pair.get(0)); String value = null; if (pair.size() == 1) { } else { value = QUERY_PARAM_VALUE_JOINER.join(pair.subList(1, pair.size())); if (decode) { value = urlDecode(value); } } map.put(key, value); } return createGuavaMultivaluedMap(map); }
From source file:eu.esdihumboldt.hale.ui.function.generic.pages.AbstractParameterPage.java
/** * @see ParameterPage#setParameter(Set, ListMultimap) *//*from w ww . ja v a 2 s . c om*/ @Override public void setParameter(Set<FunctionParameterDefinition> params, ListMultimap<String, ParameterValue> initialValues) { Builder<String, FunctionParameterDefinition> builder = ImmutableMap.builder(); for (FunctionParameterDefinition param : params) { builder.put(param.getName(), param); } this.parametersToHandle = builder.build(); if (initialValues == null) { this.initialValues = ArrayListMultimap.create(); } else { this.initialValues = Multimaps.unmodifiableListMultimap(initialValues); } }