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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations