use of org.ff4j.core.Feature in project ff4j by ff4j.
the class MongoFeatureMapper method fromStore.
/**
* {@inheritDoc}
*/
@Override
public Feature fromStore(Document document) {
String featUid = document.getString(FEATURE_UUID);
boolean status = document.getBoolean(FEATURE_ENABLE);
Feature f = new Feature(featUid, status);
f.setDescription(document.getString(FEATURE_DESCRIPTION));
f.setGroup(document.getString(FEATURE_GROUPNAME));
f.setPermissions(mapAuthorization(document));
f.setFlippingStrategy(mapStrategy(featUid, document));
f.setCustomProperties(mapCustomProperties(document));
return f;
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class FeatureStoreMongo method readAll.
/**
* {@inheritDoc}
*/
@Override
public Map<String, Feature> readAll() {
LinkedHashMap<String, Feature> mapFP = new LinkedHashMap<String, Feature>();
for (Document document : getFeaturesCollection().find()) {
Feature feature = FMAPPER.fromStore(document);
mapFP.put(feature.getUid(), feature);
}
return mapFP;
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class FeatureStoreCouchbase method removeFromGroup.
/**
* {@inheritDoc}
*/
@Override
public void removeFromGroup(String uid, String groupName) {
Util.assertHasLength(groupName);
assertFeatureExist(uid);
Feature f = readGroup(groupName).get(uid);
if (f != null) {
f.setGroup(null);
update(f);
}
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class FeatureStoreCouchbase method enableGroup.
/**
* {@inheritDoc}
*/
@Override
public void enableGroup(String groupName) {
Map<String, Feature> featuresInGroup = readGroup(groupName);
featuresInGroup.entrySet().forEach(kv -> {
Feature f = kv.getValue();
f.setGroup(groupName);
f.setEnable(true);
update(f);
});
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class FeatureStoreCouchbase method addToGroup.
/**
* {@inheritDoc}
*/
@Override
public void addToGroup(String uid, String groupName) {
Util.assertHasLength(groupName);
assertFeatureExist(uid);
Feature f = read(uid);
f.setGroup(groupName);
update(f);
}
Aggregations