001/*
002 * Copyright 2008 The Kuali Foundation
003 * 
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 * 
008 * http://www.opensource.org/licenses/ecl2.php
009 * 
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.ole.fp.document.service.impl;
017
018import org.kuali.ole.fp.document.service.TransferOfFundsService;
019import org.kuali.ole.sys.context.SpringContext;
020import org.kuali.ole.sys.document.validation.impl.AccountingDocumentRuleBaseConstants.APPLICATION_PARAMETER;
021import org.kuali.ole.sys.service.impl.OleParameterConstants;
022import org.kuali.rice.core.api.parameter.ParameterEvaluator;
023import org.kuali.rice.core.api.parameter.ParameterEvaluatorService;
024import org.kuali.rice.coreservice.framework.parameter.ParameterService;
025
026/**
027 * The default implementation of the TransferOfFundsService
028 */
029public class TransferOfFundsServiceImpl implements TransferOfFundsService {
030    private ParameterService parameterService;
031
032    /**
033     * @see org.kuali.ole.fp.document.service.TransferOfFundsService#isMandatoryTransfersSubType(java.lang.String)
034     */
035    public boolean isMandatoryTransfersSubType(String objectSubTypeCode) {
036        return checkMandatoryTransfersSubType(objectSubTypeCode, APPLICATION_PARAMETER.MANDATORY_TRANSFER_SUBTYPE_CODES);
037    }
038
039    /**
040     * @see org.kuali.ole.fp.document.service.TransferOfFundsService#isNonMandatoryTransfersSubType(java.lang.String)
041     */
042    public boolean isNonMandatoryTransfersSubType(String objectSubTypeCode) {
043        return checkMandatoryTransfersSubType(objectSubTypeCode, APPLICATION_PARAMETER.NONMANDATORY_TRANSFER_SUBTYPE_CODES);
044    }
045    
046    /**
047     * Helper method for checking the isMandatoryTransfersSubType() and isNonMandatoryTransfersSubType().
048     * 
049     * @param objectSubTypeCode
050     * @param parameterName
051     * @return boolean
052     */
053    protected boolean checkMandatoryTransfersSubType(String objectSubTypeCode, String parameterName) {
054        if (objectSubTypeCode == null) {
055            throw new IllegalArgumentException("An illegal argument has been passed. Cannot allow (null) subtypes.");
056        }
057        ParameterEvaluator evaluator = /*REFACTORME*/SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(OleParameterConstants.FINANCIAL_PROCESSING_DOCUMENT.class, parameterName, objectSubTypeCode);
058        boolean returnboolean = evaluator.evaluationSucceeds();
059        return returnboolean;
060    }
061
062    /**
063     * Gets the parameterService attribute. 
064     * @return Returns the parameterService.
065     */
066    public ParameterService getParameterService() {
067        return parameterService;
068    }
069
070    /**
071     * Sets the parameterService attribute value.
072     * @param parameterService The parameterService to set.
073     */
074    public void setParameterService(ParameterService parameterService) {
075        this.parameterService = parameterService;
076    }
077}