View Javadoc
1   /*
2    * Copyright 2007 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
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.ole.module.purap.businessobject.options;
17  
18  import org.kuali.ole.module.purap.PurapConstants.PurchaseOrderStatuses;
19  import org.kuali.rice.core.api.util.ConcreteKeyValue;
20  import org.kuali.rice.krad.keyvalues.KeyValuesBase;
21  
22  import java.util.ArrayList;
23  import java.util.List;
24  import java.util.SortedSet;
25  import java.util.TreeSet;
26  
27  /**
28   * Value Finder for Purchase Order Statuses.
29   */
30  public class PurchaseOrderStatusValuesFinder extends KeyValuesBase {
31  
32      /**
33       * Overide this method to sort the PO statuses for proper display.
34       *
35       * @see org.kuali.ole.module.purap.businessobject.options.PurApStatusKeyValuesBase#getKeyValues()
36       */
37      public List getKeyValues() {
38          // get all PO statuses
39          SortedSet<String> incompleteCodes = new TreeSet<String>(PurchaseOrderStatuses.INCOMPLETE_STATUSES);
40          SortedSet<String> completeCodes = new TreeSet<String>(PurchaseOrderStatuses.COMPLETE_STATUSES);
41  
42          // generate output
43          List labels = new ArrayList();
44  
45          labels.add(new ConcreteKeyValue("INCOMPLETE", "INCOMPLETE STATUSES"));
46          for (String status : incompleteCodes) {
47              labels.add(new ConcreteKeyValue(status, "- " + status));
48          }
49  
50          labels.add(new ConcreteKeyValue("COMPLETE", "COMPLETE STATUSES"));
51          for (String status : completeCodes) {
52              labels.add(new ConcreteKeyValue(status, "- " + status));
53          }
54  
55          return labels;
56      }
57  
58  }