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.cg.lookup.keyvalues;
17:
18: import java.util.ArrayList;
19: import java.util.List;
20:
21: import org.apache.commons.lang.StringUtils;
22: import org.kuali.core.lookup.keyvalues.KeyValuesBase;
23: import org.kuali.core.web.ui.KeyLabelPair;
24: import org.kuali.workflow.KualiWorkflowUtils;
25:
26: /**
27: * Gets a custom-formatted list of types searchable via document search.
28: */
29: public class DocumentSearchTypeOfSearchValuesFinder extends
30: KeyValuesBase {
31:
32: public static final String DOCUMENT_TYPE_SEPARATOR = ";";
33:
34: public static final String[] PROPOSAL_DOCUMENT_TYPE_NAMES = new String[] {
35: "ProposalMaintenanceDocument",
36: KualiWorkflowUtils.C_G_PROPOSAL_DOC_TYPE,
37: "ProposalMaintenanceDocument" };
38: public static final String[] AWARD_DOCUMENT_TYPE_NAMES = new String[] {
39: "AwardMaintenanceDocument",
40: KualiWorkflowUtils.C_G_AWARD_DOC_TYPE,
41: "AwardMaintenanceDocument" };
42:
43: /**
44: * @see org.kuali.keyvalues.KeyValuesFinder#getKeyValues()
45: */
46: public List getKeyValues() {
47: List<KeyLabelPair> labels = new ArrayList<KeyLabelPair>();
48: generatePossibleListElement(labels, "Proposal Documents",
49: PROPOSAL_DOCUMENT_TYPE_NAMES);
50: generatePossibleListElement(labels, "Award Documents",
51: AWARD_DOCUMENT_TYPE_NAMES);
52: return labels;
53: }
54:
55: /**
56: * Add docTypes to labels in an appropriate String format.
57: *
58: * @param labels
59: * @param label
60: * @param docTypes
61: */
62: private void generatePossibleListElement(List<KeyLabelPair> labels,
63: String label, String[] docTypes) {
64: String documentTypes = "";
65: for (int i = 0; i < docTypes.length; i++) {
66: String docTypeName = docTypes[i];
67: documentTypes = documentTypes.concat(docTypeName
68: + DOCUMENT_TYPE_SEPARATOR);
69: }
70: if (StringUtils.isNotBlank(documentTypes)) {
71: labels.add(new KeyLabelPair(documentTypes, label));
72: }
73: }
74:
75: }
|