Example usage for org.apache.commons.collections.map MultiValueMap clear

List of usage examples for org.apache.commons.collections.map MultiValueMap clear

Introduction

In this page you can find the example usage for org.apache.commons.collections.map MultiValueMap clear.

Prototype

public void clear() 

Source Link

Document

Clear the map.

Usage

From source file:com.radialpoint.uima.typemapper.TypeMapperTest.java

@Test
public void testNormalWorkflow()
        throws ResourceInitializationException, AnalysisEngineProcessException, CASException {

    Annotation sentenceAnnotation = (Annotation) cas.createAnnotation(sentenceType, 0, 4);
    sentenceAnnotation.addToIndexes();/*from w w  w  .j  a va 2 s  .com*/

    Annotation paragraphAnnotation01 = (Annotation) cas.createAnnotation(paragraphType, 3, 6);
    paragraphAnnotation01.addToIndexes();

    Annotation paragraphAnnotation02 = (Annotation) cas.createAnnotation(paragraphType, 10, 25);
    paragraphAnnotation02.addToIndexes();

    AnalysisEngine analysisEngine = AnalysisEngineFactory.createEngine(TypeMapper.class,
            TypeMapper.CONFIG_FILE_NAME,
            "src/test/resources/com/radialpoint/uima/typemapper/NormalWorkflowConfig.xml");

    SimplePipeline.runPipeline(cas, analysisEngine);

    MultiValueMap featureValues = new MultiValueMap();

    featureValues.put("begin", sentenceAnnotation.getBegin());
    featureValues.put("end", sentenceAnnotation.getEnd());

    verifyMappedAnnotation(sentenceType, 1, featureValues);

    featureValues.clear();
    featureValues.put("begin", paragraphAnnotation01.getBegin());
    featureValues.put("end", paragraphAnnotation01.getEnd());
    featureValues.put("begin", paragraphAnnotation02.getBegin());
    featureValues.put("end", paragraphAnnotation02.getEnd());

    verifyMappedAnnotation(paragraphType, 2, featureValues);

}

From source file:org.apache.directory.server.tools.commands.exportcmd.ExportCommandExecutor.java

private void execute() throws Exception {
    // Connecting to server and retreiving entries
    NamingEnumeration entries = connectToServerAndGetEntries();

    // Creating destination file
    File destionationFile = new File(ldifFileName);

    // Deleting the destination file if it already exists
    if (destionationFile.exists()) {
        destionationFile.delete();// w w  w  .  j ava  2s .  c o  m
    }

    // Creating the writer to generate the LDIF file
    FileWriter fw = new FileWriter(ldifFileName, true);

    BufferedWriter writer = new BufferedWriter(fw);
    OtcLdifComposerImpl composer = new OtcLdifComposerImpl();
    MultiValueMap map = new MultiValueMap();
    //      MultiMap map = new MultiMap() {
    //         // FIXME Stop forking commons-collections.
    //         private final MultiValueMap map = new MultiValueMap();
    //
    //         public Object remove(Object arg0, Object arg1) {
    //            return map.remove(arg0, arg1);
    //         }
    //
    //         public int size() {
    //            return map.size();
    //         }
    //
    //         public Object get(Object arg0) {
    //            return map.get(arg0);
    //         }
    //
    //         public boolean containsValue(Object arg0) {
    //            return map.containsValue(arg0);
    //         }
    //
    //         public Object put(Object arg0, Object arg1) {
    //            return map.put(arg0, arg1);
    //         }
    //
    //         public Object remove(Object arg0) {
    //            return map.remove(arg0);
    //         }
    //
    //         public Collection values() {
    //            return map.values();
    //         }
    //
    //         public boolean isEmpty() {
    //            return map.isEmpty();
    //         }
    //
    //         public boolean containsKey(Object key) {
    //            return map.containsKey(key);
    //         }
    //
    //         public void putAll(Map arg0) {
    //            map.putAll(arg0);
    //         }
    //
    //         public void clear() {
    //            map.clear();
    //         }
    //
    //         public Set keySet() {
    //            return map.keySet();
    //         }
    //
    //         public Set entrySet() {
    //            return map.entrySet();
    //         }
    //      };

    int entriesCounter = 1;
    long t0 = System.currentTimeMillis();

    while (entries.hasMoreElements()) {
        SearchResult sr = (SearchResult) entries.nextElement();
        Attributes attributes = sr.getAttributes();
        NamingEnumeration attributesEnumeration = attributes.getAll();

        map.clear();

        while (attributesEnumeration.hasMoreElements()) {
            Attribute attr = (Attribute) attributesEnumeration.nextElement();
            NamingEnumeration e2 = null;

            e2 = attr.getAll();

            while (e2.hasMoreElements()) {
                Object value = e2.nextElement();
                map.put(attr.getID(), value);
            }
        }

        // Writing entry in the file
        writer.write("dn: " + sr.getNameInNamespace() + "\n");
        writer.write(composer.compose(map) + "\n");

        notifyEntryWrittenListener(sr.getNameInNamespace());
        entriesCounter++;

        if (entriesCounter % 10 == 0) {
            notifyOutputListener(new Character('.'));
        }

        if (entriesCounter % 500 == 0) {
            notifyOutputListener("" + entriesCounter);
        }
    }

    writer.flush();
    writer.close();
    fw.close();

    long t1 = System.currentTimeMillis();

    notifyOutputListener("Done!");
    notifyOutputListener(entriesCounter + " entries exported in " + ((t1 - t0) / 1000) + " seconds");
}

From source file:org.oscarehr.PMmodule.utility.RoleCache.java

public static boolean hasAccess(String accessTypeName, long roleId) {
    //temp start: Temporarily add these:
    Map<Long, Secrole> roleMap2 = new HashMap<Long, Secrole>();
    Map<String, Integer> accessTypeMap2 = new HashMap<String, Integer>();
    MultiValueMap defaultRoleAccessMap2 = new MultiValueMap();

    accessTypeMap2.clear();/*from w  w w .  j a v  a 2 s .  c  o  m*/
    for (CaisiAccessType at : accessTypeDao.findAll()) {
        accessTypeMap2.put(at.getName().toLowerCase(), at.getId());
    }
    roleMap2.clear();
    for (Secrole role : secroleDao.getRoles()) {
        setRole(role.getId(), role);
    }
    defaultRoleAccessMap2.clear();
    for (DefaultRoleAccess dra : defaultRoleAccessDAO.findAll()) {
        long roleId2 = dra.getRoleId();
        long accessTypeId = dra.getAccessTypeId();
        defaultRoleAccessMap2.put(accessTypeId, roleId2);
    }
    Integer accessTypeId = accessTypeMap2.get(accessTypeName);
    if (accessTypeId == null) {
        MiscUtils.getLogger().warn("Access Type not found:" + accessTypeName);
        return false;
    }
    Collection<Long> roles = defaultRoleAccessMap2.getCollection(accessTypeId.longValue());
    if (roles != null && roles.contains(roleId))
        return true;
    //temp end

    /*
    Integer accessTypeId = accessTypeMap.get(accessTypeName);
    if(accessTypeId == null) {
       MiscUtils.getLogger().warn("Access Type not found:"+accessTypeName);
       return false;
    }
    Collection<Long> roles = defaultRoleAccessMap.getCollection(accessTypeId.longValue());
    if(roles != null && roles.contains(roleId))
       return true;
       */
    return false;
}