View Javadoc

1   /*
2    * Copyright 2013 The Kuali Foundation.
3    *
4    * Licensed under the Educational Community License, Version 1.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/ecl1.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.select.businessobject.options;
17  
18  import org.kuali.ole.select.service.OleUrlResolver;
19  import org.kuali.ole.service.impl.OleLocationWebServiceImpl;
20  import org.kuali.rice.core.api.config.property.ConfigContext;
21  import org.kuali.rice.core.api.util.ConcreteKeyValue;
22  import org.kuali.rice.krad.keyvalues.KeyValuesBase;
23  
24  import java.util.ArrayList;
25  import java.util.Iterator;
26  import java.util.List;
27  
28  public class OleLocationKeyValueFinder extends KeyValuesBase {
29  
30      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
31              .getLogger(OleLocationKeyValueFinder.class);
32      private transient OleUrlResolver oleUrlResolver;
33  
34      /**
35       * This method returns list of key value pairs for Item Locations.
36       *
37       * @see org.kuali.rice.kns.lookup.keyvalues.KeyValuesFinder#getKeyValues()
38       */
39      @Override
40      public List getKeyValues() {
41          LOG.debug("Inside getKeyValues of OleLocationKeyValueFinder");
42          OleLocationWebServiceImpl oleLocationWebService = new OleLocationWebServiceImpl();
43          List labels = new ArrayList();
44          List locations = oleLocationWebService.getItemLocation();
45          for (Iterator iter = locations.iterator(); iter.hasNext(); ) {
46              String location = (String) iter.next();
47              labels.add(new ConcreteKeyValue(location, location));
48          }
49          return labels;
50      }
51  
52      /**
53       * This method returns the location web service url
54       *
55       * @return url
56       */
57      public String getLocationURL() {
58          return ConfigContext.getCurrentContextConfig().getProperty("location.web.service.url");
59      }
60  
61  }