001/* 002 * Copyright 2009 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 1.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/ecl1.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.sec.service.impl; 017 018import org.apache.commons.lang.StringUtils; 019import org.kuali.ole.integration.cg.ContractsAndGrantsModuleService; 020import org.kuali.ole.sys.OLEPropertyConstants; 021import org.kuali.ole.sys.context.SpringContext; 022import org.kuali.rice.kim.api.identity.Person; 023 024/** 025 * Custom access permission evaluator for principal investigator restrictions 026 */ 027public class PrincipalInvestigatorAccessPermissionEvaluatorImpl extends AccessPermissionEvaluatorImpl { 028 029 /** 030 * Matches on accounts for which the person is a principal investigator (project director) 031 * 032 * @see org.kuali.ole.sec.service.impl.AccessPermissionEvaluatorImpl#isMatch(java.lang.String, java.lang.String) 033 */ 034 @Override 035 protected boolean isMatch(String matchValue, String value) { 036 boolean match = false; 037 038 String chartCode = (String) otherKeyFieldValues.get(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE); 039 040 Person principalInvestigator = SpringContext.getBean(ContractsAndGrantsModuleService.class).getProjectDirectorForAccount(chartCode, value); 041 if (StringUtils.equals(person.getPrincipalId(), principalInvestigator.getPrincipalId())) { 042 match = true; 043 } 044 045 return match; 046 } 047 048}