01: /*
02: * Copyright 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.lookup.keyvalues;
17:
18: import java.util.ArrayList;
19: import java.util.List;
20:
21: import org.kuali.core.lookup.keyvalues.KeyValuesBase;
22: import org.kuali.core.web.ui.KeyLabelPair;
23: import org.kuali.kfs.context.SpringContext;
24: import org.kuali.module.kra.routingform.bo.ControlAttributeType;
25: import org.kuali.module.kra.service.ResearchDocumentControlAttributeTypeService;
26:
27: /**
28: * This class is used to acquire and build a collection of possible ControlAttributeTypes that can be used to generate user drop
29: * downs.
30: */
31: public class ResearchControlAttributeTypeCodeValuesFinder extends
32: KeyValuesBase {
33:
34: /**
35: * Constructs a ResearchControlAttributeTypeCodeValuesFinder.java.
36: */
37: public ResearchControlAttributeTypeCodeValuesFinder() {
38: super ();
39: }
40:
41: /**
42: * Retrieves the list of possible control attribute type codes from the DB and builds a KeyLabelPair collection from these
43: * values.
44: *
45: * @return A collection of KeyLabelPair objects representing the possible ControlAttributeType codes.
46: * @see org.kuali.core.lookup.keyvalues.KeyValuesFinder#getKeyValues()
47: */
48: public List getKeyValues() {
49:
50: List<ControlAttributeType> controlAttributeTypeCodes = new ArrayList(
51: SpringContext
52: .getBean(
53: ResearchDocumentControlAttributeTypeService.class)
54: .getControlAttributeTypeCodes());
55: List<KeyLabelPair> controlAttributeTypeCodePairs = new ArrayList(
56: 3);
57:
58: for (ControlAttributeType controlAttributeType : controlAttributeTypeCodes) {
59:
60: String description = "";
61: if (ControlAttributeType.TYPE_CODE_A
62: .equalsIgnoreCase(controlAttributeType
63: .getControlAttributeTypeCode())) {
64: description = ControlAttributeType.TYPE_CODE_A_DESC;
65: } else if (ControlAttributeType.TYPE_CODE_S
66: .equalsIgnoreCase(controlAttributeType
67: .getControlAttributeTypeCode())) {
68: description = ControlAttributeType.TYPE_CODE_S_DESC;
69: } else if (ControlAttributeType.TYPE_CODE_D
70: .equals(controlAttributeType
71: .getControlAttributeTypeCode())) {
72: description = ControlAttributeType.TYPE_CODE_D_DESC;
73: }
74:
75: controlAttributeTypeCodePairs.add(new KeyLabelPair(
76: controlAttributeType.getControlAttributeTypeCode(),
77: controlAttributeType.getControlAttributeTypeCode()
78: + " - " + description));
79: }
80:
81: return controlAttributeTypeCodePairs;
82: }
83:
84: }
|