001package org.kuali.ole.deliver.service;
002
003import org.kuali.rice.coreservice.api.CoreServiceApiServiceLocator;
004import org.kuali.rice.coreservice.api.parameter.Parameter;
005import org.kuali.rice.coreservice.api.parameter.ParameterKey;
006
007/**
008 * Created by pvsubrah on 4/6/15.
009 */
010public class ParameterValueResolver {
011
012    private static ParameterValueResolver parameterValueResolver;
013
014    private ParameterValueResolver(){
015
016    }
017
018    public static ParameterValueResolver getInstance(){
019        if(null == parameterValueResolver){
020            parameterValueResolver = new ParameterValueResolver();
021        }
022        return parameterValueResolver;
023    }
024
025    public String getParameter(String applicationId, String namespace, String componentId, String parameterName) {
026        ParameterKey parameterKey = ParameterKey.create(applicationId, namespace, componentId,parameterName);
027        Parameter parameter = CoreServiceApiServiceLocator.getParameterRepositoryService().getParameter(parameterKey);
028
029        return parameter!=null?parameter.getValue():null;
030    }
031
032    public Boolean getParameterAsBoolean(String applicationId, String namespace, String componentId, String
033            parameterName) {
034        ParameterKey parameterKey = ParameterKey.create(applicationId, namespace, componentId, parameterName);
035        Boolean parameterValueAsBoolean = CoreServiceApiServiceLocator.getParameterRepositoryService().getParameterValueAsBoolean(parameterKey);
036        return parameterValueAsBoolean;
037    }
038
039}