001package org.kuali.ole.deliver.keyvalue.drools; 002 003import org.apache.commons.collections.CollectionUtils; 004import org.kuali.ole.deliver.util.ItemInfoUtil; 005import org.kuali.ole.describe.bo.OleLocation; 006import org.kuali.rice.core.api.util.ConcreteKeyValue; 007import org.kuali.rice.core.api.util.KeyValue; 008import org.kuali.rice.krad.keyvalues.KeyValuesBase; 009import org.kuali.rice.krad.service.KRADServiceLocator; 010 011import java.util.ArrayList; 012import java.util.Collection; 013import java.util.Collections; 014import java.util.List; 015 016/** 017 * Created by sheiksalahudeenm on 7/14/15. 018 */ 019public class LibraryLocationKeyValueFinder extends KeyValuesBase { 020 @Override 021 public List getKeyValues() { 022 List<KeyValue> keyValues = new ArrayList<KeyValue>(); 023 List<ConcreteKeyValue> concreteKeyValues = new ArrayList<ConcreteKeyValue>(); 024 Collection<OleLocation> oleLocations = KRADServiceLocator.getBusinessObjectService().findAll(OleLocation.class); 025 if (CollectionUtils.isNotEmpty(oleLocations)) { 026 for (OleLocation oleLocation : oleLocations) { 027 if(oleLocation.getLevelId().equalsIgnoreCase(String.valueOf(ItemInfoUtil.LEVEL_CODES.LIBRARY.getId()))){ 028 keyValues.add(new ConcreteKeyValue(oleLocation.getLocationCode(), oleLocation.getLocationCode())); 029 } 030 } 031 } 032 Collections.sort(concreteKeyValues); 033 keyValues.addAll(concreteKeyValues); 034 return keyValues; 035 } 036}