Examples of FeatureState


Examples of org.togglz.core.repository.FeatureState

        DBObject result = togglzCollection().findOne(queryFor(feature));

        if (result != null) {

            FeatureState state = new FeatureState(feature);

            Object enabledValue = result.get(FIELD_ENABLED);
            if (enabledValue instanceof Boolean) {
                state.setEnabled(((Boolean) enabledValue).booleanValue());
            }

            Object strategyValue = result.get(FIELD_STRATEGY);
            if (strategyValue != null) {
                state.setStrategyId(strategyValue.toString().trim());
            }

            Object paramsValue = result.get(FIELD_PARAMS);
            if (paramsValue instanceof DBObject) {
                DBObject params = (DBObject) paramsValue;
                for (String key : params.keySet()) {
                    state.setParameter(key, params.get(key).toString().trim());
                }

            }

            return state;
View Full Code Here

Examples of org.togglz.core.repository.FeatureState

        IndexPageTabView tabView = new IndexPageTabView(strategies);

        for (Feature feature : featureManager.getFeatures()) {
            FeatureMetaData metadata = featureManager.getMetaData(feature);
            FeatureState featureState = featureManager.getFeatureState(feature);
            tabView.add(feature, metadata, featureState);
        }

        Map<String, Object> model = new HashMap<String, Object>();
        model.put("tabView", tabView);
View Full Code Here

Examples of org.togglz.core.repository.FeatureState

     * @return
     */
    @SuppressWarnings("unchecked")
    private FeatureState createFeatureState(final Feature feature, final Entity featureEntity) {
        final Boolean enabled = (Boolean) featureEntity.getProperty(ENABLED);
        final FeatureState state = new FeatureState(feature, enabled);

        final String strategyId = (String) featureEntity.getProperty(STRATEGY_ID);
        if (!Strings.isNullOrEmpty(strategyId)) {
            state.setStrategyId(strategyId.trim());
        }

        final List<String> strategyParamsNames = (List<String>) featureEntity.getProperty(STRATEGY_PARAMS_NAMES);
        final List<String> strategyParamsValues = (List<String>) featureEntity.getProperty(STRATEGY_PARAMS_VALUES);
        if (strategyParamsNames != null && strategyParamsValues != null && !strategyParamsNames.isEmpty()
            && !strategyParamsValues.isEmpty() && strategyParamsNames.size() == strategyParamsValues.size()) {
            for (int i = 0; i < strategyParamsNames.size(); i++) {
                state.setParameter(strategyParamsNames.get(i), strategyParamsValues.get(i));
            }
        }
        return state;
    }
View Full Code Here

Examples of org.togglz.core.repository.FeatureState

        this.expiration = Expiration.byDeltaMillis(ttlInSeconds);
    }

    @Override
    public FeatureState getFeatureState(Feature feature) {
        FeatureState state = (FeatureState) cache.get(key(feature.name()));
        if (state == null) {
            state = delegate.getFeatureState(feature);
            cache.put(key(feature.name()), state, getExpiration());
        }
        return state;
View Full Code Here

Examples of org.togglz.core.repository.FeatureState

        try {

            // modify FEATURE1 and FEATURE2, don't touch FEATURE3
            FileBasedStateRepository repo = new FileBasedStateRepository(file);
            repo.setFeatureState(new FeatureState(MyFeature.FEATURE1, false));
            repo.setFeatureState(new FeatureState(MyFeature.FEATURE2, true)
                .setStrategyId("some-strategy").setParameter("myparam", "myvalue"));

            Properties newProps = readPropertiesFile(file);

            assertThat(newProps.size(), is(5));
View Full Code Here

Examples of org.togglz.core.repository.FeatureState

        try {

            FileBasedStateRepository repo = new FileBasedStateRepository(file);

            FeatureState state = repo.getFeatureState(MyFeature.FEATURE1);
            state.setParameter("other", "something-else");
            repo.setFeatureState(state);

            Properties newProps = readPropertiesFile(file);

            assertThat(newProps.size(), is(4));
View Full Code Here

Examples of org.togglz.core.repository.FeatureState

        try {

            FileBasedStateRepository repo = new FileBasedStateRepository(file);

            FeatureState state = repo.getFeatureState(MyFeature.FEATURE1);
            state.setParameter("myparam", null);
            repo.setFeatureState(state);

            Properties newProps = readPropertiesFile(file);

            assertThat(newProps.size(), is(2));
View Full Code Here

Examples of org.togglz.core.repository.FeatureState

        try {

            FileBasedStateRepository repo = new FileBasedStateRepository(file);

            FeatureState state = repo.getFeatureState(MyFeature.FEATURE1);
            state.setStrategyId("something");
            repo.setFeatureState(state);

            Properties newProps = readPropertiesFile(file);

            assertThat(newProps.size(), is(2));
View Full Code Here

Examples of org.togglz.core.repository.FeatureState

        try {

            FileBasedStateRepository repo = new FileBasedStateRepository(file);

            FeatureState state = repo.getFeatureState(MyFeature.FEATURE1);
            state.setStrategyId(null);
            repo.setFeatureState(state);

            Properties newProps = readPropertiesFile(file);

            assertThat(newProps.size(), is(1));
View Full Code Here

Examples of org.togglz.core.repository.FeatureState

        try {

            FileBasedStateRepository repo = new FileBasedStateRepository(file);

            FeatureState state = repo.getFeatureState(MyFeature.FEATURE1);
            state.enable();
            repo.setFeatureState(state);

            Properties newProps = readPropertiesFile(file);

            assertThat(newProps.size(), is(3));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.