/** {@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); groups.remove(""); return groups; }
/** {@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 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 Set<String> readAllGroups() { return readAll().entrySet().stream() .map(f -> f.getValue().getGroup()) .filter(Util::hasLength).collect(Collectors.toSet()); }
/** {@inheritDoc} */ @Override public Set<String> readAllGroups() { Map < String, Feature > features = readAll(); Set < String > groups = new HashSet<>(); for (Map.Entry<String,Feature> uid : features.entrySet()) { groups.add(uid.getValue().getGroup()); } groups.remove(null); return groups; }
/** * Group is an attribute of the feature and the group structure is rebuild from it. */ private void buildGroupsFromFeatures() { // Reinit if required featureGroups = new HashMap<String, Set<String>>(); for (Entry<String, Feature> item : featuresMap.entrySet()) { String currentGroup = item.getValue().getGroup(); if (!featureGroups.containsKey(currentGroup)) { // Create Group of not exist featureGroups.put(currentGroup, new HashSet<String>()); } featureGroups.get(currentGroup).add(item.getKey()); } }
/** {@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 Map<String, Feature> readGroup(String groupName) { assertGroupExist(groupName); return readAll().entrySet().stream() .filter(f -> groupName.equals(f.getValue().getGroup())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); }
/** {@inheritDoc} */ @Override public boolean existGroup(String groupName) { Util.assertHasLength(groupName); return readAll().entrySet().stream() .filter(f -> groupName.equals(f.getValue().getGroup())) .count() > 0; }
/** {@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 existGroup(String groupName) { Util.assertParamHasLength(groupName, "groupName"); Map < String, Feature > features = readAll(); Map < String, Feature > group = new HashMap<>(); 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 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 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; }
/** {@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; }
public Collection<GroupDescApiBean> getAllGroups() { Map<String, GroupDescApiBean> groups = new HashMap<String, GroupDescApiBean>(); Map<String, Feature> featureMap = ff4j.getFeatureStore().readAll(); if (!CollectionUtils.isEmpty(featureMap)) { for (Feature feature : featureMap.values()) { initGroupMap(groups, feature.getUid(), feature.getGroup()); } } return groups.values(); }
/** {@inheritDoc} */ @Override public void removeFromGroup(String uid, String groupName) { assertFeatureExist(uid); assertGroupExist(groupName); Feature feat = read(uid); if (feat.getGroup() != null && !feat.getGroup().equals(groupName)) { throw new IllegalArgumentException("'" + uid + "' is not in group '" + groupName + "'"); } update(getQueryBuilder().addFeatureToGroup(), "", uid); }
/** * Check that feature is in expected group. * * @param featureName * target feature Name * @param roleName * target role name * @return current object */ public final AssertFf4j assertThatFeatureIsInGroup(String featureName, String groupName) { assertThatFeatureExist(featureName); String group = ff4j.getFeature(featureName).getGroup(); Assert.assertTrue("'" + featureName + "' must be in group '" + groupName + "' but is in <" + group + ">", group != null && groupName.equals(group)); waitSomeSeconds(); return this; }
private void createCoreFeature(Feature fp) { // Transaction wraps the method, could pipe several sql queries String strategyColumn = null; String expressionColumn = null; if (fp.getFlippingStrategy() != null) { strategyColumn = fp.getFlippingStrategy().getClass().getName(); expressionColumn = MappingUtil.fromMap(fp.getFlippingStrategy().getInitParams()); } getJdbcTemplate().update(getQueryBuilder().createFeature(), fp.getUid(), fp.isEnable() ? 1 : 0, fp.getDescription(), strategyColumn, expressionColumn, fp.getGroup()); }
public FeatureApiBean(Feature f) { this.uid = f.getUid(); this.enable = f.isEnable(); this.description = f.getDescription(); this.group = f.getGroup(); this.permissions = new ArrayList<String>(f.getPermissions()); if (f.getFlippingStrategy() != null) { this.flippingStrategy = new FlippingStrategyApiBean(f.getFlippingStrategy()); } if (f.getCustomProperties() != null) { for (Property<?> ap1 : f.getCustomProperties().values()) { customProperties.put(ap1.getName(), new PropertyApiBean(ap1)); } } }