Example usage for org.apache.commons.collections MultiMap entrySet

List of usage examples for org.apache.commons.collections MultiMap entrySet

Introduction

In this page you can find the example usage for org.apache.commons.collections MultiMap entrySet.

Prototype

Set<Map.Entry<K, V>> entrySet();

Source Link

Document

Returns a Set view of the mappings contained in this map.

Usage

From source file:org.jopendocument.util.CollectionMap.java

/**
 * Fusionne la MultiMap avec celle-ci. C'est  dire rajoute les valeurs de mm  la suite des
 * valeurs de cette map (contrairement  putAll(Map) qui ajoute les valeurs de mm en tant que
 * valeur scalaire et non en tant que collection).
 * //from   w w  w .  ja  va  2  s.c  o  m
 * @param mm la MultiMap  fusionner.
 */
public void merge(MultiMap mm) {
    // copied from super ctor
    for (Iterator it = mm.entrySet().iterator(); it.hasNext();) {
        final Map.Entry entry = (Map.Entry) it.next();
        Collection<V> coll = (Collection<V>) entry.getValue();
        Collection newColl = createCollection(coll);
        this.putAll(entry.getKey(), newColl);
    }
}

From source file:org.lockss.extractor.ArticleMetadata.java

/**
 * Copies values from the raw metadata map to the cooked map according to the
 * supplied map. Any MetadataExceptions thrown while storing into the cooked
 * map are returned in a List.//ww w  . jav a2 s.c o m
 * 
 * @param rawToCooked
 *          maps raw key -> cooked MatadataField.
 */
public List<MetadataException> cook(MultiMap rawToCooked) {
    List<MetadataException> errors = new ArrayList<MetadataException>();
    for (Map.Entry ent : (Collection<Map.Entry<String, Collection<MetadataField>>>) (rawToCooked.entrySet())) {
        String rawKey = (String) ent.getKey();
        Collection<MetadataField> fields = (Collection) ent.getValue();
        for (MetadataField field : fields) {
            cookField(rawKey, field, errors);
        }
    }
    return errors;
}

From source file:org.openmrs.PropertiesFileValidator.java

private List<String> filterKeysWithMultipleValues(MultiMap keyValuesMap) {

    List<String> result = new ArrayList<String>();

    for (Object entryObject : keyValuesMap.entrySet()) {
        // apache commons multimap in version 3.* do not use generics (
        // version 4.0 has)
        @SuppressWarnings("unchecked")
        Map.Entry<String, Collection<?>> mapEntry = (Entry<String, Collection<?>>) entryObject;
        if (mapEntry.getValue().size() > 1) {
            result.add(mapEntry.getKey());
        }/* ww w.  j  a v a2  s .c om*/
    }
    return result;
}

From source file:org.squashtest.tm.service.internal.testautomation.AutomatedSuiteManagerServiceImpl.java

/**
 *
 * @see org.squashtest.tm.service.testautomation.AutomatedSuiteManagerService#sortByProject(org.squashtest.tm.domain.testautomation.AutomatedSuite)
 */// w w  w. ja  v a2 s .co m

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Collection<TestAutomationProjectContent> sortByProject(AutomatedSuite suite) {
    // security handled by in the code

    List<AutomatedExecutionExtender> extenders = suite.getExecutionExtenders();

    PermissionsUtils.checkPermission(permissionService, extenders, EXECUTE);

    // first sort them using a map
    MultiMap testsByProjects = new MultiValueMap();

    for (AutomatedExecutionExtender extender : extenders) {
        if (extender.isProjectDisassociated()) {
            continue;
        }
        TestAutomationProject project = extender.getAutomatedProject();
        AutomatedTest test = extender.getAutomatedTest();

        testsByProjects.put(project, test);
    }

    // now make a friendly bean of it
    Collection<TestAutomationProjectContent> projectContents = new LinkedList<>();

    Set<Entry> entries = testsByProjects.entrySet();
    for (Entry e : entries) {
        TestAutomationProject project = (TestAutomationProject) e.getKey();
        Collection<AutomatedTest> tests = (Collection) e.getValue();
        TestAutomationConnector connector = connectorRegistry
                .getConnectorForKind(project.getServer().getKind());
        boolean orderGuaranteed = connector.testListIsOrderGuaranteed(tests);
        projectContents.add(new TestAutomationProjectContent(project, tests, orderGuaranteed));
    }

    return projectContents;

}