use of org.ff4j.core.Feature in project ff4j by ff4j.
the class CassandraMapper method mapFeature.
/**
* Marshall bean {@link Feature} from line in Cassandra table.
*
* @param row
* current line
* @return
* Populated object
*/
public static Feature mapFeature(Row row) {
Feature f = new Feature(row.getString(COL_FEAT_UID));
f.setDescription(row.getString(COL_FEAT_DESCRIPTION));
f.setEnable(1 == row.getInt(COL_FEAT_ENABLE));
f.setGroup(row.getString(COL_FEAT_GROUPNAME));
f.setPermissions(mapFeaturePermissions(row));
// Custom Properties
Map<String, String> mapOfProperties = row.getMap(COL_FEAT_CUSTOMPROPERTIES, String.class, String.class);
if (mapOfProperties != null) {
Map<String, Property<?>> customProperties = new HashMap<String, Property<?>>();
for (Map.Entry<String, String> propString : mapOfProperties.entrySet()) {
customProperties.put(propString.getKey(), PropertyJsonParser.parseProperty(propString.getValue()));
}
f.setCustomProperties(customProperties);
}
// Flipping Strategy
String jsonFlippingStrategy = row.getString(COL_FEAT_STRATEGY);
if (Util.hasLength(jsonFlippingStrategy)) {
f.setFlippingStrategy(FeatureJsonParser.parseFlipStrategyAsJson(f.getUid(), jsonFlippingStrategy));
}
return f;
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class FeatureStoreServices method getAllFeatures.
public Collection<FeatureApiBean> getAllFeatures() {
List<FeatureApiBean> features;
Map<String, Feature> featureMap = ff4j.getFeatureStore().readAll();
if (CollectionUtils.isEmpty(featureMap)) {
features = new ArrayList<FeatureApiBean>(0);
} else {
features = new ArrayList<FeatureApiBean>(featureMap.size());
for (Feature feature : featureMap.values()) {
features.add(new FeatureApiBean(feature));
}
}
return features;
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class FeatureStoreServices method getAllGroups.
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();
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class GroupServices method getFeaturesByGroup.
public Collection<FeatureApiBean> getFeaturesByGroup(String groupName) {
featureValidator.assertGroupExist(groupName);
Collection<Feature> features = ff4j.getFeatureStore().readGroup(groupName).values();
Collection<FeatureApiBean> featureApiBeans = new ArrayList<FeatureApiBean>();
if (!CollectionUtils.isEmpty(features)) {
for (Feature feature : features) {
featureApiBeans.add(new FeatureApiBean(feature));
}
}
return featureApiBeans;
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class AbstractStepDef method createFeatures.
protected void createFeatures(List<FeaturePojo> features) {
for (FeaturePojo featurePojo : features) {
Feature feature = new Feature(featurePojo.getUid(), Boolean.valueOf(featurePojo.getEnable()), featurePojo.getDescription(), featurePojo.getGroup(), Arrays.asList(featurePojo.getPermissions().split(",")));
createFeature(feature);
}
}
Aggregations