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.module.bc.document.authorization;
017
018 import java.util.Map;
019
020 import org.kuali.kfs.module.bc.BCPropertyConstants;
021 import org.kuali.kfs.module.bc.document.BudgetConstructionDocument;
022 import org.kuali.kfs.module.bc.document.service.BudgetDocumentService;
023 import org.kuali.kfs.sys.KFSPropertyConstants;
024 import org.kuali.kfs.sys.context.SpringContext;
025 import org.kuali.kfs.sys.document.authorization.FinancialSystemTransactionalDocumentAuthorizerBase;
026 import org.kuali.kfs.sys.identity.KfsKimAttributes;
027 import org.kuali.rice.kns.bo.BusinessObject;
028
029 public class BudgetConstructionDocumentAuthorizer extends FinancialSystemTransactionalDocumentAuthorizerBase {
030
031 /**
032 * Add role qualifications (chart, account, year, level code) needed from document
033 *
034 * @see org.kuali.kfs.sys.document.authorization.FinancialSystemTransactionalDocumentAuthorizerBase#addRoleQualification(org.kuali.rice.kns.bo.BusinessObject,
035 * java.util.Map)
036 */
037 @Override
038 protected void addRoleQualification(BusinessObject businessObject, Map<String, String> attributes) {
039 super.addRoleQualification(businessObject, attributes);
040
041 BudgetConstructionDocument document = (BudgetConstructionDocument) businessObject;
042
043 attributes.put(KfsKimAttributes.CHART_OF_ACCOUNTS_CODE, document.getChartOfAccountsCode());
044 attributes.put(KfsKimAttributes.ACCOUNT_NUMBER, document.getAccountNumber());
045 attributes.put(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, document.getUniversityFiscalYear().toString());
046 attributes.put(BCPropertyConstants.ORGANIZATION_LEVEL_CODE, document.getOrganizationLevelCode().toString());
047 attributes.put(BCPropertyConstants.ORGANIZATION_CHART_OF_ACCOUNTS_CODE, document.getOrganizationLevelChartOfAccountsCode());
048 attributes.put(KfsKimAttributes.ORGANIZATION_CODE, document.getOrganizationLevelOrganizationCode());
049
050 if (SpringContext.getBean(BudgetDocumentService.class).isAccountReportsExist(document.getChartOfAccountsCode(), document.getAccountNumber())) {
051 attributes.put(BCPropertyConstants.ACCOUNT_REPORTS_EXIST, Boolean.TRUE.toString());
052 }
053 else {
054 attributes.put(BCPropertyConstants.ACCOUNT_REPORTS_EXIST, Boolean.FALSE.toString());
055 }
056 }
057
058 }