Search in sources :

Example 1 with MultiMap

use of org.apache.commons.collections.MultiMap in project openmrs-core by openmrs.

the class PropertiesFileValidator method getAsPropertiesKeyValueMultiMap.

private MultiMap getAsPropertiesKeyValueMultiMap(List<String> fileLines) {
    MultiMap multiMap = new MultiValueMap();
    for (String line : fileLines) {
        if (isCorectKeyValueLine(line)) {
            Map.Entry<String, String> tuple = extractKeyValue(line);
            multiMap.put(tuple.getKey(), tuple.getValue());
        }
    }
    return multiMap;
}
Also used : MultiMap(org.apache.commons.collections.MultiMap) MultiMap(org.apache.commons.collections.MultiMap) MultiValueMap(org.apache.commons.collections.map.MultiValueMap) AbstractMap(java.util.AbstractMap) Map(java.util.Map) MultiValueMap(org.apache.commons.collections.map.MultiValueMap)

Example 2 with MultiMap

use of org.apache.commons.collections.MultiMap in project openmrs-core by openmrs.

the class PropertiesFileValidator method getDuplicatedKeys.

/**
 * List duplicated key in file.
 * @param inputStream file input stream
 * @return list of duplicated keys
 * @throws IOException in case of reading content from InputStream
 */
public List<String> getDuplicatedKeys(InputStream inputStream) throws IOException {
    List<String> fileLines = getLines(inputStream);
    MultiMap keyValuesMap = getAsPropertiesKeyValueMultiMap(fileLines);
    return filterKeysWithMultipleValues(keyValuesMap);
}
Also used : MultiMap(org.apache.commons.collections.MultiMap)

Example 3 with MultiMap

use of org.apache.commons.collections.MultiMap in project tdq-studio-se by Talend.

the class EventManager method clearEvent.

/**
 * clear all eventReceivers for the current event, for the current context
 *
 * @param context
 * @param event
 * @return
 */
public boolean clearEvent(Object context, EventEnum event) {
    MultiMap receverQueryMap = ctxToReceiverQueueMap.get(context);
    if (receverQueryMap == null) {
        return false;
    }
    receverQueryMap.remove(event);
    return true;
}
Also used : MultiMap(org.apache.commons.collections.MultiMap)

Example 4 with MultiMap

use of org.apache.commons.collections.MultiMap in project tdq-studio-se by Talend.

the class EventManager method publish.

/**
 * call the registered event's related receiver to handle
 *
 * @param context
 * @param event
 * @param data
 */
public boolean publish(Object context, EventEnum event, Object data) {
    MultiMap receverQueryMap = ctxToReceiverQueueMap.get(context);
    if (receverQueryMap == null || receverQueryMap.isEmpty()) {
        return true;
    }
    List<IEventReceiver> receivers = (List<IEventReceiver>) receverQueryMap.get(event);
    if (receivers == null || receivers.size() == 0) {
        return true;
    }
    // Notify the receiver to handle the event.
    boolean handleResult = Boolean.TRUE;
    for (IEventReceiver receiver : receivers) {
        handleResult = receiver.handle(data);
        if (!handleResult) {
            break;
        }
    }
    return handleResult;
}
Also used : MultiMap(org.apache.commons.collections.MultiMap) List(java.util.List)

Example 5 with MultiMap

use of org.apache.commons.collections.MultiMap in project tdq-studio-se by Talend.

the class EventManager method register.

/**
 * register repository node's event receiver with its event type. e.g. when opening a editor, need to call register
 * to remember its receiver with some widgets.
 *
 * @param context: the host of the event receiver
 * @param event: pointed event
 * @param receiver: event handler
 * @return
 */
public boolean register(Object context, EventEnum event, IEventReceiver receiver) {
    MultiMap receverQueryMap = ctxToReceiverQueueMap.get(context);
    if (receverQueryMap == null) {
        receverQueryMap = new MultiValueMap();
        ctxToReceiverQueueMap.put(context, receverQueryMap);
    }
    receverQueryMap.put(event, receiver);
    return false;
}
Also used : MultiMap(org.apache.commons.collections.MultiMap) MultiValueMap(org.apache.commons.collections.map.MultiValueMap)

Aggregations

MultiMap (org.apache.commons.collections.MultiMap)7 MultiValueMap (org.apache.commons.collections.map.MultiValueMap)3 List (java.util.List)2 Map (java.util.Map)2 Pair (com.zimbra.common.util.Pair)1 IO (com.zimbra.znative.IO)1 File (java.io.File)1 IOException (java.io.IOException)1 AbstractMap (java.util.AbstractMap)1 Collection (java.util.Collection)1 LinkedHashMap (java.util.LinkedHashMap)1