1 /*
2 * Copyright 2009 The Kuali Foundation.
3 *
4 * Licensed under the Educational Community License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl1.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.ole.sec.service.impl;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.ole.integration.cg.ContractsAndGrantsModuleService;
20 import org.kuali.ole.sys.OLEPropertyConstants;
21 import org.kuali.ole.sys.context.SpringContext;
22 import org.kuali.rice.kim.api.identity.Person;
23
24 /**
25 * Custom access permission evaluator for principal investigator restrictions
26 */
27 public class PrincipalInvestigatorAccessPermissionEvaluatorImpl extends AccessPermissionEvaluatorImpl {
28
29 /**
30 * Matches on accounts for which the person is a principal investigator (project director)
31 *
32 * @see org.kuali.ole.sec.service.impl.AccessPermissionEvaluatorImpl#isMatch(java.lang.String, java.lang.String)
33 */
34 @Override
35 protected boolean isMatch(String matchValue, String value) {
36 boolean match = false;
37
38 String chartCode = (String) otherKeyFieldValues.get(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE);
39
40 Person principalInvestigator = SpringContext.getBean(ContractsAndGrantsModuleService.class).getProjectDirectorForAccount(chartCode, value);
41 if (StringUtils.equals(person.getPrincipalId(), principalInvestigator.getPrincipalId())) {
42 match = true;
43 }
44
45 return match;
46 }
47
48 }