View Javadoc
1   package org.kuali.ole.batch.keyvalue;
2   
3   import org.kuali.ole.OLEConstants;
4   import org.kuali.ole.describe.bo.OleLocation;
5   import org.kuali.rice.core.api.util.ConcreteKeyValue;
6   import org.kuali.rice.core.api.util.KeyValue;
7   import org.kuali.rice.krad.keyvalues.KeyValuesBase;
8   import org.kuali.rice.krad.service.KRADServiceLocator;
9   
10  import java.util.ArrayList;
11  import java.util.Collection;
12  import java.util.List;
13  
14  /**
15   * Created with IntelliJ IDEA.
16   * User: rajeshbabuk
17   * Date: 3/15/14
18   * Time: 5:08 PM
19   * To change this template use File | Settings | File Templates.
20   */
21  public class OLEBatchConstantsLocationLevel4KeyValues extends KeyValuesBase {
22      @Override
23      public List<KeyValue> getKeyValues() {
24          List<KeyValue> keyValues = new ArrayList<KeyValue>();
25          keyValues = getLocationsByLocationLevel(OLEConstants.OLEBatchProcess.LOCATION_LEVEL_COLLECTION);
26          return keyValues;
27      }
28  
29      private List<KeyValue> getLocationsByLocationLevel(String locationLevel) {
30          List<KeyValue> keyValues = new ArrayList<KeyValue>();
31          Collection<OleLocation> oleLocations = KRADServiceLocator.getBusinessObjectService().findAll(OleLocation.class);
32          for (OleLocation oleLocation : oleLocations) {
33              if (locationLevel.equalsIgnoreCase(oleLocation.getLevelCode()))
34                  keyValues.add(new ConcreteKeyValue(oleLocation.getLocationCode(), oleLocation.getLocationCode()));
35          }
36          return keyValues;
37      }
38  }