Map<String, Object> capabilitiesObj =
(Map<String, Object>) object.get(CAPABILITIES_CAPABILITIES_FIELD);
Map<EventType, Capability> capabilities = CollectionUtils.newHashMap();
for (Entry<String, Object> capability : capabilitiesObj.entrySet()) {
EventType eventType = EventType.valueOf(capability.getKey());
List<Context> contexts = CollectionUtils.newArrayList();
DBObject capabilityObj = (DBObject) capability.getValue();
DBObject contextsObj = (DBObject) capabilityObj.get(CAPABILITY_CONTEXTS_FIELD);
for (String contextId : contextsObj.keySet()) {
contexts.add(Context.valueOf((String) contextsObj.get(contextId)));