Search in sources :

Example 41 with Feature

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;
}
Also used : Feature(org.ff4j.core.Feature)

Example 42 with Feature

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;
}
Also used : Document(org.bson.Document) Feature(org.ff4j.core.Feature) LinkedHashMap(java.util.LinkedHashMap)

Example 43 with Feature

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);
    }
}
Also used : Feature(org.ff4j.core.Feature)

Example 44 with Feature

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);
    });
}
Also used : Feature(org.ff4j.core.Feature)

Example 45 with Feature

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);
}
Also used : Feature(org.ff4j.core.Feature)

Aggregations

Feature (org.ff4j.core.Feature)258 Test (org.junit.Test)136 PropertyString (org.ff4j.property.PropertyString)49 HashMap (java.util.HashMap)29 HashSet (java.util.HashSet)29 PonderationStrategy (org.ff4j.strategy.PonderationStrategy)19 LinkedHashMap (java.util.LinkedHashMap)15 AbstractFf4jTest (org.ff4j.test.AbstractFf4jTest)14 Property (org.ff4j.property.Property)12 Set (java.util.Set)11 FeatureAccessException (org.ff4j.exception.FeatureAccessException)11 FeatureApiBean (org.ff4j.web.api.resources.domain.FeatureApiBean)11 XmlParser (org.ff4j.conf.XmlParser)10 InputStream (java.io.InputStream)9 Map (java.util.Map)9 FlippingStrategy (org.ff4j.core.FlippingStrategy)9 GroupNotFoundException (org.ff4j.exception.GroupNotFoundException)9 ClientResponse (com.sun.jersey.api.client.ClientResponse)8 ArrayList (java.util.ArrayList)8 Response (javax.ws.rs.core.Response)8