/** {@inheritDoc} */ @Override public void removeFromGroup(String featureId, String groupName) { Util.assertParamHasLength(groupName, "groupName (#2)"); if (!existGroup(groupName)) { throw new GroupNotFoundException(groupName); } // retrieve Feature f = read(featureId); f.setGroup(null); // persist modification update(f); }
/** {@inheritDoc} */ @Override public Set<String> readAllGroups() { Map < String, Feature > features = readAll(); Set < String > groups = new HashSet<String>(); for (Map.Entry<String,Feature> uid : features.entrySet()) { groups.add(uid.getValue().getGroup()); } groups.remove(null); return groups; }
/** {@inheritDoc} */ @Override public Map<String, Feature> readAll() { Map<String, Feature> myMap = new HashMap<String, Feature>(); if (getCache().getKeys() != null) { for (Object key : getCache().getKeys()) { Element element = getCache().get(key); if (element != null) { Feature f = (Feature) getCache().get(key).getObjectValue(); myMap.put((String) key, f); } } } return myMap; }
/** {@inheritDoc} */ @Override public boolean existGroup(String groupName) { Util.assertParamHasLength(groupName, "groupName"); Map < String, Feature > features = readAll(); Map < String, Feature > group = new HashMap<String, Feature>(); for (Map.Entry<String,Feature> uid : features.entrySet()) { if (groupName.equals(uid.getValue().getGroup())) { group.put(uid.getKey(), uid.getValue()); } } return !group.isEmpty(); }
/** {@inheritDoc} */ @Override public boolean exist(String uid) { Util.assertParamHasLength(uid, "Feature identifier"); return getCache().get(uid) != null; }
/** {@inheritDoc} */ @Override public Map<String, Feature> readGroup(String groupName) { Util.assertParamHasLength(groupName, "groupName"); Map < String, Feature > features = readAll(); Map < String, Feature > group = new HashMap<String, Feature>(); for (Map.Entry<String,Feature> uid : features.entrySet()) { if (groupName.equals(uid.getValue().getGroup())) { group.put(uid.getKey(), uid.getValue()); } } if (group.isEmpty()) { throw new GroupNotFoundException(groupName); } return group; }