use of org.osgi.framework.Filter in project ddf by codice.
the class ConfigurationAdminExt method addMetaTypeNamesToMap.
public List<Map<String, Object>> addMetaTypeNamesToMap(final Map ocdCollection, final String filterSpec, final String type) {
Filter filter = null;
if (filterSpec != null) {
try {
filter = getBundleContext().createFilter(filterSpec);
} catch (InvalidSyntaxException ignore) {
// don't care
}
}
List<Map<String, Object>> metatypeList = new ArrayList<Map<String, Object>>();
Iterator ei = ocdCollection.entrySet().iterator();
while (ei.hasNext()) {
Entry ociEntry = (Entry) ei.next();
final String pid = (String) ociEntry.getKey();
final ObjectClassDefinition ocd = (ObjectClassDefinition) ociEntry.getValue();
if (filter == null) {
Map<String, Object> metatype = new HashMap<String, Object>();
metatype.put(MAP_ENTRY_ID, pid);
metatype.put(MAP_ENTRY_NAME, ocd.getName());
AttributeDefinition[] defs = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);
metatype.put(MAP_ENTRY_METATYPE, createMetatypeMap(defs));
metatypeList.add(metatype);
} else {
final Dictionary props = new Hashtable();
props.put(type, pid);
if (filter.match(props)) {
Map<String, Object> metatype = new HashMap<String, Object>();
metatype.put(MAP_ENTRY_ID, pid);
metatype.put(MAP_ENTRY_NAME, ocd.getName());
AttributeDefinition[] defs = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);
metatype.put(MAP_ENTRY_METATYPE, createMetatypeMap(defs));
metatypeList.add(metatype);
}
}
}
return metatypeList;
}
Aggregations