View Javadoc
1   /**
2    * Copyright 2005-2014 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.rice.kew.lookup.valuefinder;
17  
18  import org.kuali.rice.core.api.util.ConcreteKeyValue;
19  import org.kuali.rice.core.api.util.KeyValue;
20  import org.kuali.rice.kew.api.KewApiConstants;
21  import org.kuali.rice.krad.keyvalues.KeyValuesBase;
22  
23  import java.util.ArrayList;
24  import java.util.Collection;
25  import java.util.List;
26  
27  /**
28   * This is a description of what this class does - chris don't forget to fill this in.
29   *
30   * @author Kuali Rice Team (rice.collab@kuali.org)
31   *
32   */
33  public class DocumentRouteStatusValuesFinder extends KeyValuesBase {
34  
35  	private static
36  	<T extends Comparable<? super T>> List<T> asSortedList(Collection<T> c) {
37  	  List<T> list = new ArrayList<T>(c);
38  	  java.util.Collections.sort(list);
39  	  return list;
40  	}
41  
42  	/**
43  	 * @see org.kuali.rice.krad.keyvalues.KeyValuesFinder#getKeyValues()
44  	 */
45  	@Override
46  	public List<KeyValue> getKeyValues() {
47  		List<KeyValue> keyValues = new ArrayList<KeyValue>();
48  		List<String> docStatusParentKeys = asSortedList(KewApiConstants.DOCUMENT_STATUS_PARENT_TYPES.keySet());
49  
50  		for (String parentKey : docStatusParentKeys) {
51  			KeyValue keyLabel = new ConcreteKeyValue(parentKey,parentKey + " Statuses");
52  			keyValues.add(keyLabel);
53  
54  			// each parent key, pending, successful, unsuccessful each has a sub list of real document statuses
55  			List<String> docStatusCodes = KewApiConstants.DOCUMENT_STATUS_PARENT_TYPES.get(parentKey);
56  			for(String docStatusCode : docStatusCodes){
57  				KeyValue docStat = new ConcreteKeyValue(docStatusCode, "- "+ KewApiConstants.DOCUMENT_STATUSES.get(docStatusCode));
58  				keyValues.add(docStat);
59  			}
60  		}
61  		return keyValues;
62  	}
63  
64  }