Example usage for org.apache.commons.collections15.multimap MultiHashMap MultiHashMap

List of usage examples for org.apache.commons.collections15.multimap MultiHashMap MultiHashMap

Introduction

In this page you can find the example usage for org.apache.commons.collections15.multimap MultiHashMap MultiHashMap.

Prototype

public MultiHashMap() 

Source Link

Document

Constructor.

Usage

From source file:de.dhke.projects.cutil.collections.aspect.AspectMultiMapTest.java

@Test
public void testPutAll_MultiMap_veto() {
    MultiMap<String, String> addMap = new MultiHashMap<>();
    addMap.put("1", "");
    addMap.put("1", "alpha");
    addMap.put("2", "");
    addMap.put("2", "beta");
    _listener.vetoAdd = true;//from   www  .  j a  va  2  s  . c  o  m
    try {
        _aspectMap.putAll(addMap);
        fail("Add veto not raised");
    } catch (AssertionError ex) {
        /* ignore */
    }
    assertTrue(_listener.beforeAddEvents.isEmpty());
    assertTrue(_listener.afterAddEvents.isEmpty());
}

From source file:net.sqs2.omr.model.Row.java

public void addException(PageTaskException taskException) {
    if (this.taskExceptionMap == null) {
        this.taskExceptionMap = new MultiHashMap<PageID, PageTaskException>();
    }//from   w  ww.j a  va 2s.  c o m
    if (!this.taskExceptionMap.containsKey(taskException)) {
        this.taskExceptionMap.put(taskException.getExceptionModel().getPageID(), taskException);
    }
}

From source file:net.sqs2.omr.result.model.Row.java

public void addError(TaskError taskError) {
    if (this.taskErrorMap == null) {
        this.taskErrorMap = new MultiHashMap<PageID, TaskError>();
    }// w  w  w  .j  a va  2  s  .  c o m
    if (!this.taskErrorMap.containsKey(taskError)) {
        this.taskErrorMap.put(taskError.getSource(), taskError);
    }
}

From source file:org.dataconservancy.dcs.index.rebuild.OrderedDcpEntitySource.java

private DcsEntity[] createMetadataFor(DcsEntity entity, boolean... oldStyle) {

    DcsDeliverableUnit metadataDU = new DcsDeliverableUnit();
    metadataDU.setTitle("MetadataDU");
    metadataDU.setId("metadata_du_for_" + entity.getId());
    metadataDU.addCollection(new DcsCollectionRef(COLLECTION_OF_METADATA));
    metadataDU.addParent(new DcsDeliverableUnitRef(DU_COLLECTION_OF_METADATA));
    entities.put(metadataDU.getId(), metadataDU);

    DcsFile file = createMetadataFileDescribing(entity);

    DcsManifestation manifestation;//from  ww w.  j ava 2s  .  c  o m
    MultiMap<DcsFile, DcsEntity> metadataFor = new MultiHashMap<DcsFile, DcsEntity>();

    if (oldStyle.length == 0) {
        /* use IS_METADATA_FOR relationships */
        metadataFor.put(file, entity);
        manifestation = createManifestation(metadataDU, metadataFor);
    } else {
        /* Suitable for old-style direct reference from containing entity */
        manifestation = createManifestation(metadataDU, metadataFor, file);
    }

    addChldrenTo(COLLECTION_OF_METADATA, metadataDU);
    addChldrenTo(DU_COLLECTION_OF_METADATA, metadataDU);
    addChldrenTo(metadataDU, manifestation);
    addChldrenTo(manifestation, file);

    return new DcsEntity[] { file, metadataDU, manifestation };
}

From source file:org.dataconservancy.dcs.index.rebuild.OrderedDcpEntitySource.java

private void createDataDU(String id, String[] parentCollections, String[] parentDUs) {
    DcsDeliverableUnit du = new DcsDeliverableUnit();
    Dcp pkg = new Dcp();

    du.setId(id);/*from   w  w w .j av a  2  s  . c o  m*/
    du.setTitle("data DU " + id);

    for (String parentColl : parentCollections) {
        if (parentColl != null) {
            du.addCollection(new DcsCollectionRef(parentColl));
            parentChildMap.put(parentColl, du);
        }
    }

    for (String parentDU : parentDUs) {
        if (parentDU != null) {
            du.addParent(new DcsDeliverableUnitRef(parentDU));
            parentChildMap.put(parentDU, du);
        }
    }

    entities.put(id, du);

    /* Create a manifesation containing metadata describing this DU */
    DcsFile duMetadataFile = createMetadataFileDescribing(du);
    MultiHashMap<DcsFile, DcsEntity> duMetadataFileMap = new MultiHashMap<DcsFile, DcsEntity>();
    duMetadataFileMap.put(duMetadataFile, du);
    DcsManifestation duMetadataManifestation = createManifestation(du, duMetadataFileMap);

    /*
     * Create a manifestation containing a data file, and a metadata file
     * describing it
     */
    DcsFile dataFile = createDataFile();
    DcsFile dataMetadataFile = createMetadataFileDescribing(dataFile);
    MultiHashMap<DcsFile, DcsEntity> dataMetadataFileMap = new MultiHashMap<DcsFile, DcsEntity>();
    dataMetadataFileMap.put(dataMetadataFile, dataFile);
    DcsManifestation dataManifestation = createManifestation(du, dataMetadataFileMap, dataFile);

    /*
     * Create a manifestation containing three metadata files: one
     * describing all parent collections, one describing all parent DU
     * collections, and one describing all parents together
     */
    DcsFile collectionsMdFile = createMetadataFileDescribing(entities.get(parentCollections[0]));
    DcsFile duCollectionsMdFile = createMetadataFileDescribing(entities.get(parentDUs[0]));
    DcsFile comprehensiveMdFile = createMetadataFileDescribing(du);
    MultiHashMap<DcsFile, DcsEntity> collectionsMetadataFileMap = new MultiHashMap<DcsFile, DcsEntity>();
    for (String collectionParent : parentCollections) {
        collectionsMetadataFileMap.put(collectionsMdFile, entities.get(collectionParent));
        collectionsMetadataFileMap.put(comprehensiveMdFile, entities.get(collectionParent));

    }
    for (String duParent : parentDUs) {
        collectionsMetadataFileMap.put(duCollectionsMdFile, entities.get(duParent));
        collectionsMetadataFileMap.put(comprehensiveMdFile, entities.get(duParent));
    }
    DcsManifestation collectionManifestation = createManifestation(du, collectionsMetadataFileMap);

    /* Finally, create an event for the whole darn thing */
    DcsEvent event = createEvent("createDataDU",
            new DcsEntity[] { du, duMetadataManifestation, duMetadataFile, dataFile, dataMetadataFile,
                    dataManifestation, collectionsMdFile, duCollectionsMdFile, comprehensiveMdFile,
                    collectionManifestation });

    addChldrenTo(du, duMetadataManifestation, dataManifestation, collectionManifestation);

    addChldrenTo(duMetadataManifestation, duMetadataFile);
    addChldrenTo(dataManifestation, dataFile, dataMetadataFile);
    addChldrenTo(collectionManifestation, collectionsMdFile, duCollectionsMdFile, comprehensiveMdFile);

    addTo(pkg, du, duMetadataManifestation, duMetadataFile, dataFile, dataMetadataFile, dataManifestation,
            collectionsMdFile, duCollectionsMdFile, comprehensiveMdFile, collectionManifestation, event);

    packages.add(pkg);

}

From source file:org.echocat.jomon.runtime.CollectionUtilsUnitTest.java

@Test
public void testIsNotEmpty() throws Exception {
    // Test multi map ...
    final MultiMap<String, String> multiMap = new MultiHashMap<>();
    assertThat(CollectionUtils.isNotEmpty(multiMap), is(false));
    multiMap.put("Key", "Value");
    assertThat(CollectionUtils.isNotEmpty(multiMap), is(true));
    // Test null values (incl. the MultiMap) ...
    assertThat(CollectionUtils.isNotEmpty(
            Collections.singletonMap("Testkey", asList("Testvalue")).get("NonexistentKey")), is(false));
    assertThat(//w ww .  j a  v a 2 s.  c  o m
            CollectionUtils.isNotEmpty(
                    Collections.singletonMap("Testkey", asMap("Testkey", "Testvalue")).get("NonexistentKey")),
            is(false));
    assertThat(
            CollectionUtils.isNotEmpty(
                    Collections.singletonMap("Testkey", asMap("Testkey", "Testvalue")).get("NonexistentKey")),
            is(false));
    assertThat(CollectionUtils.isNotEmpty(Collections.singletonMap("Testkey", multiMap).get("NonexistentKey")),
            is(false));
    // Test empty values ...
    assertThat(CollectionUtils.isNotEmpty(Collections.emptyList()), is(false));
    assertThat(CollectionUtils.isNotEmpty(Collections.emptyMap()), is(false));
    // Test non empty values ...
    assertThat(CollectionUtils.isNotEmpty(Collections.singletonList("Test")), is(true));
    assertThat(CollectionUtils.isNotEmpty(Collections.singletonMap("Testkey", "Testvalue")), is(true));
}

From source file:org.nlp2rdf.corpusconversion.Tiger.java

private void addSyntax(Individual sentence, Result r) {
    OliaSyntaxOntologyConnector.SyntaxTree root = oliaSyntaxOntologyConnector.createSyntaxTreeRoot(sentence);
    MultiHashMap mhm = new MultiHashMap<String, OneLine>();
    for (OneLine ol : oneEntry) {
        mhm.put(ol.parent, ol);//  w  w  w . ja  v  a  2 s. co  m
    }

    OneLine currentLine = new OneLine();
    currentLine.word = "#0";
    currentLine.edge = "--";
    processTree(currentLine, root, mhm, sentence);

    oliaSyntaxOntologyConnector.connect(r.model);
    //System.out.println(mhm);
    //System.exit(0);

}

From source file:org.openanzo.combus.realtime.RealtimeUpdatePublisher.java

private MultiHashMap<URI, DestinationDatasetTracker> matchingDatasetTrackers(URI namedGraphUri) {
    MultiHashMap<URI, DestinationDatasetTracker> results = new MultiHashMap<URI, DestinationDatasetTracker>();
    Collection<DestinationDatasetTracker> trackers = datasetTrackers.get(namedGraphUri);
    if (trackers != null) {
        for (DestinationDatasetTracker entry : trackers) {
            results.put(entry.userUri, entry);
        }//from w  ww  .  jav  a 2  s  . com
    }
    return results;
}

From source file:org.openanzo.combus.realtime.RealtimeUpdatePublisher.java

private MultiHashMap<Destination, URI> byDestination(Collection<DestinationDatasetTracker> trackers) {
    MultiHashMap<Destination, URI> results = new MultiHashMap<Destination, URI>();
    for (DestinationDatasetTracker entry : trackers) {
        results.put(entry.destination, entry.getTrackerURI());
    }/*from   w w w  . ja  v a2  s .co m*/
    return results;
}

From source file:org.openanzo.combus.realtime.RealtimeUpdatePublisher.java

private void removeDestination(Destination destination) {
    synchronized (datasetTrackers) {
        MultiMap<URI, DestinationDatasetTracker> toRemove = new MultiHashMap<URI, DestinationDatasetTracker>();
        for (Map.Entry<URI, Collection<DestinationDatasetTracker>> entry : datasetTrackers.entrySet()) {
            for (DestinationDatasetTracker tracker : entry.getValue()) {
                if (tracker.getDestination().equals(destination)) {
                    toRemove.put(entry.getKey(), tracker);
                }/*  w ww  .  j a  v a2  s .  c o m*/
            }
        }
        for (Map.Entry<URI, Collection<DestinationDatasetTracker>> entry : toRemove.entrySet()) {
            for (DestinationDatasetTracker tracker : entry.getValue()) {
                datasetTrackers.remove(entry.getKey(), tracker);
            }
        }
    }
    synchronized (namedGraphTrackers) {
        MultiMap<URI, DestinationNamedgraphTracker> toRemove = new MultiHashMap<URI, DestinationNamedgraphTracker>();
        for (Map.Entry<URI, Collection<DestinationNamedgraphTracker>> entry : namedGraphTrackers.entrySet()) {
            for (DestinationNamedgraphTracker dest : entry.getValue()) {
                if (dest.getDestination().equals(destination)) {
                    toRemove.put(entry.getKey(), dest);
                }
            }
        }
        for (Map.Entry<URI, Collection<DestinationNamedgraphTracker>> entry : toRemove.entrySet()) {
            for (DestinationNamedgraphTracker dest : entry.getValue()) {
                namedGraphTrackers.remove(entry.getKey(), dest);
            }
        }
    }
}