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.gl.web.optionfinder;
17:
18: import java.util.ArrayList;
19: import java.util.Collection;
20: import java.util.Collections;
21: import java.util.List;
22:
23: import org.kuali.core.lookup.keyvalues.KeyValuesBase;
24: import org.kuali.core.web.ui.KeyLabelPair;
25: import org.kuali.kfs.KFSConstants;
26: import org.kuali.kfs.context.SpringContext;
27: import org.kuali.module.gl.bo.OriginEntryGroup;
28: import org.kuali.module.gl.service.OriginEntryGroupService;
29:
30: /**
31: * This class returns list of correction group entries key value pairs.
32: */
33: public class CorrectionGroupEntriesFinder extends KeyValuesBase {
34:
35: /**
36: * Returns a list of key/value pairs to display correction groups that can be used in a Labor Ledger Correction Document
37: *
38: * @return a List of key/value pairs for correction groups
39: * @see org.kuali.core.lookup.keyvalues.KeyValuesFinder#getKeyValues()
40: */
41: public List getKeyValues() {
42: List activeLabels = new ArrayList();
43:
44: OriginEntryGroupService originEntryGroupService = SpringContext
45: .getBean(OriginEntryGroupService.class);
46:
47: Collection<OriginEntryGroup> groupList = originEntryGroupService
48: .getAllOriginEntryGroup();
49:
50: List<OriginEntryGroup> sortedGroupList = (List) groupList;
51:
52: OEGTypeComparator oegTypeComparator = new OEGTypeComparator();
53: Collections.sort(sortedGroupList, oegTypeComparator);
54:
55: String groupException = "";
56: for (int i = 0; i < KFSConstants.LLCP_GROUP_FILTER_EXCEPTION.length; i++) {
57: groupException += KFSConstants.LLCP_GROUP_FILTER_EXCEPTION[i]
58: + " ";
59: }
60:
61: for (OriginEntryGroup oeg : sortedGroupList) {
62: if (!oeg.getSourceCode().startsWith("L")
63: || groupException.contains(oeg.getSourceCode())) {
64: activeLabels.add(new KeyLabelPair(oeg.getId()
65: .toString(), oeg.getName()));
66: }
67: }
68: return activeLabels;
69: }
70:
71: }
|