001    /*
002     * Copyright 2011 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     */
016    package org.kuali.kfs.fp.document.service.impl;
017    
018    import org.kuali.kfs.fp.document.service.TransferOfFundsService;
019    import org.kuali.kfs.sys.document.validation.impl.AccountingDocumentRuleBaseConstants.APPLICATION_PARAMETER;
020    import org.kuali.kfs.sys.service.impl.KfsParameterConstants;
021    import org.kuali.rice.kns.service.ParameterEvaluator;
022    import org.kuali.rice.kns.service.ParameterService;
023    
024    /**
025     * The default implementation of the TransferOfFundsService
026     */
027    public class TransferOfFundsServiceImpl implements TransferOfFundsService {
028        private ParameterService parameterService;
029    
030        /**
031         * @see org.kuali.kfs.fp.document.service.TransferOfFundsService#isMandatoryTransfersSubType(java.lang.String)
032         */
033        public boolean isMandatoryTransfersSubType(String objectSubTypeCode) {
034            return checkMandatoryTransfersSubType(objectSubTypeCode, APPLICATION_PARAMETER.MANDATORY_TRANSFER_SUBTYPE_CODES);
035        }
036    
037        /**
038         * @see org.kuali.kfs.fp.document.service.TransferOfFundsService#isNonMandatoryTransfersSubType(java.lang.String)
039         */
040        public boolean isNonMandatoryTransfersSubType(String objectSubTypeCode) {
041            return checkMandatoryTransfersSubType(objectSubTypeCode, APPLICATION_PARAMETER.NONMANDATORY_TRANSFER_SUBTYPE_CODES);
042        }
043        
044        /**
045         * Helper method for checking the isMandatoryTransfersSubType() and isNonMandatoryTransfersSubType().
046         * 
047         * @param objectSubTypeCode
048         * @param parameterName
049         * @return boolean
050         */
051        protected boolean checkMandatoryTransfersSubType(String objectSubTypeCode, String parameterName) {
052            if (objectSubTypeCode == null) {
053                throw new IllegalArgumentException("An illegal argument has been passed. Cannot allow (null) subtypes.");
054            }
055            ParameterEvaluator evaluator = getParameterService().getParameterEvaluator(KfsParameterConstants.FINANCIAL_PROCESSING_DOCUMENT.class, parameterName, objectSubTypeCode);
056            boolean returnboolean = evaluator.evaluationSucceeds();
057            return returnboolean;
058        }
059    
060        /**
061         * Gets the parameterService attribute. 
062         * @return Returns the parameterService.
063         */
064        public ParameterService getParameterService() {
065            return parameterService;
066        }
067    
068        /**
069         * Sets the parameterService attribute value.
070         * @param parameterService The parameterService to set.
071         */
072        public void setParameterService(ParameterService parameterService) {
073            this.parameterService = parameterService;
074        }
075    }