01: /*
02: * Copyright 2006-2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.core.lookup;
17:
18: import org.kuali.RiceConstants;
19: import org.kuali.core.service.KualiConfigurationService;
20: import org.kuali.core.util.GlobalVariables;
21:
22: public class UniversalUserLookupableHelperServiceImpl extends
23: KualiLookupableHelperServiceImpl {
24:
25: protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
26: .getLogger(UniversalUserLookupableHelperServiceImpl.class);
27:
28: private KualiConfigurationService configService;
29: private String userEditWorkgroupName;
30: private boolean usersMaintainedByKuali;
31:
32: /**
33: * Determines if underlying lookup bo has associated maintenance document that allows new or copy maintenance actions.
34: *
35: * @return true if bo has maint doc that allows new or copy actions
36: */
37: public boolean allowsMaintenanceNewOrCopyAction() {
38: // get the group name that we need here
39: if (userEditWorkgroupName == null) {
40: userEditWorkgroupName = configService
41: .getParameterValue(
42: RiceConstants.KNS_NAMESPACE,
43: RiceConstants.DetailTypes.UNIVERSAL_USER_DETAIL_TYPE,
44: RiceConstants.CoreApcParms.UNIVERSAL_USER_EDIT_WORKGROUP);
45: // check whether users are editable within Kuali
46: usersMaintainedByKuali = configService
47: .getPropertyAsBoolean(RiceConstants.MAINTAIN_USERS_LOCALLY_KEY);
48: }
49:
50: if (usersMaintainedByKuali
51: && GlobalVariables.getUserSession().getUniversalUser()
52: .isMember(userEditWorkgroupName)) {
53: return super .allowsMaintenanceNewOrCopyAction();
54: }
55: return false;
56: }
57:
58: public KualiConfigurationService getConfigService() {
59: return configService;
60: }
61:
62: public void setConfigService(KualiConfigurationService configService) {
63: this .configService = configService;
64: }
65: /*
66: @Override
67: protected List<? extends BusinessObject> getSearchResultsHelper(Map<String, String> fieldValues, boolean unbounded) {
68: List<UniversalUser> results = (List<UniversalUser>)super.getSearchResultsHelper(fieldValues, unbounded);
69: List<UniversalUser> filteredResults = results;
70: if ( results.size() > 0 ) {
71: String moduleCode = fieldValues.get( "activeModuleCodeString" );
72: if ( StringUtils.isNotBlank( moduleCode ) ) {
73: filteredResults = new ArrayList<UniversalUser>();
74: for ( UniversalUser user : results ) {
75: if ( user.getActiveModuleCodeString().contains( moduleCode ) ) {
76: filteredResults.add( user ) ;
77: }
78: }
79: }
80: }
81: if ( filteredResults instanceof CollectionIncomplete ) {
82: return filteredResults;
83: } else {
84: // TODO: this isn't correct, but I don't think we want to fix it since it would require that
85: // all rows be loaded in and tested
86: return new CollectionIncomplete( filteredResults, ((CollectionIncomplete)results).getActualSizeIfTruncated() );
87: }
88: }
89: */
90:
91: }
|