All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openl.rules.ui.ParameterRegistry Maven / Gradle / Ivy

There is a newer version: 5.27.9
Show newest version
package org.openl.rules.ui;

import org.openl.rules.testmethod.ParameterWithValueDeclaration;
import org.openl.rules.webstudio.web.util.Constants;
import org.openl.rules.webstudio.web.util.WebStudioUtils;

public class ParameterRegistry extends ObjectRegistry {
    private static ParameterRegistry getCurrent(String requestId) {
        return (ParameterRegistry) WebStudioUtils.getExternalContext().getSessionMap()
                .get(Constants.SESSION_PARAM_PARAMETERS + requestId);
    }

    private static ParameterRegistry getCurrentOrCreate(String requestId) {
        ParameterRegistry parameterRegistry = getCurrent(requestId);
        if (parameterRegistry == null) {
            parameterRegistry = new ParameterRegistry();
            WebStudioUtils.getExternalContext().getSessionMap()
                    .put(Constants.SESSION_PARAM_PARAMETERS + requestId, parameterRegistry);
        }
        return parameterRegistry;
    }

    public static int getUniqueId(String requestId, ParameterWithValueDeclaration value) {
        return getCurrentOrCreate(requestId).putIfAbsent(value);
    }

    public static ParameterWithValueDeclaration getParameter(String requestId, String rootID) {
        ParameterRegistry parameterRegistry = getCurrent(requestId);
        return parameterRegistry == null ? null : parameterRegistry.getValue(Integer.parseInt(rootID));
    }

    public static void remove(String requestId) {
        WebStudioUtils.getExternalContext().getSessionMap().remove(Constants.SESSION_PARAM_PARAMETERS + requestId);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy