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.module.kra.routingform.document;
17:
18: import org.kuali.core.bo.user.UniversalUser;
19: import org.kuali.core.document.MaintenanceDocument;
20: import org.kuali.core.document.authorization.MaintenanceDocumentAuthorizations;
21: import org.kuali.core.document.authorization.MaintenanceDocumentAuthorizerBase;
22: import org.kuali.core.service.BusinessObjectService;
23: import org.kuali.core.util.ObjectUtils;
24: import org.kuali.kfs.context.SpringContext;
25: import org.kuali.module.kra.KraPropertyConstants;
26: import org.kuali.module.kra.routingform.bo.ResearchRiskType;
27:
28: /**
29: * Authorizer class for ResearchRiskTypeMaintenanceDocument - allows for targeted field disabling.
30: */
31: public class ResearchRiskTypeMaintenanceDocumentAuthorizer extends
32: MaintenanceDocumentAuthorizerBase {
33:
34: @Override
35: public MaintenanceDocumentAuthorizations getFieldAuthorizations(
36: MaintenanceDocument document, UniversalUser user) {
37:
38: MaintenanceDocumentAuthorizations auths = new MaintenanceDocumentAuthorizations();
39: ResearchRiskType researchRisk = (ResearchRiskType) document
40: .getNewMaintainableObject().getBusinessObject();
41: BusinessObjectService service = SpringContext
42: .getBean(BusinessObjectService.class);
43: ResearchRiskType persistedResearchRisk = (ResearchRiskType) service
44: .retrieve(researchRisk);
45:
46: // If the research risk exists in db, set read-only fields
47: if (ObjectUtils.isNotNull(persistedResearchRisk)
48: && persistedResearchRisk.getResearchRiskTypeCode() != null) {
49: auths
50: .addReadonlyAuthField(KraPropertyConstants.RESEARCH_RISK_TYPE_DESCRIPTION);
51: auths
52: .addReadonlyAuthField(KraPropertyConstants.CONTROL_ATTRIBUTE_TYPE_CODE);
53: }
54:
55: return auths;
56: }
57: }
|