001package org.kuali.ole.describe.keyvalue;
002
003import org.kuali.ole.OLEConstants;
004import org.kuali.ole.describe.form.BoundwithForm;
005import org.kuali.rice.core.api.util.ConcreteKeyValue;
006import org.kuali.rice.core.api.util.KeyValue;
007import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase;
008import org.kuali.rice.krad.uif.view.ViewModel;
009
010import java.util.ArrayList;
011import java.util.List;
012
013/**
014 * Created with IntelliJ IDEA.
015 * User: PP7788
016 * Date: 11/29/12
017 * Time: 5:02 PM
018 * To change this template use File | Settings | File Templates.
019 */
020public class BoundwithDocFieldKeyValueFinder extends UifKeyValuesFinderBase {
021
022    @Override
023    public List<KeyValue> getKeyValues(ViewModel viewModel) {
024        BoundwithForm boundwithForm = (BoundwithForm) viewModel;
025        List<KeyValue> options = new ArrayList<KeyValue>();
026        //TODO: Get drop-down values dynamically by parsing DocumentConfig.xml file
027        if (boundwithForm.getSearchParams().getSearchConditions().get(0).getSearchField().getDocType().equalsIgnoreCase(OLEConstants.BIB_DOC_TYPE)) {
028            options.add(new ConcreteKeyValue("all", "ALL"));
029            options.add(new ConcreteKeyValue("Title_search", "Title"));
030            options.add(new ConcreteKeyValue("Author_search", "Author"));
031            options.add(new ConcreteKeyValue("PublicationDate_search", "Publication Date"));
032        } else if (boundwithForm.getSearchParams().getSearchConditions().get(0).getSearchField().getDocType().equalsIgnoreCase(OLEConstants.HOLDING_DOC_TYPE)) {
033            options.add(new ConcreteKeyValue("all", "ALL"));
034            options.add(new ConcreteKeyValue("Location_search", "Location"));
035            options.add(new ConcreteKeyValue("CallNumber_search", "Call Number"));
036        } else if (boundwithForm.getSearchParams().getSearchConditions().get(0).getSearchField().getDocType().equalsIgnoreCase(OLEConstants.ITEM_DOC_TYPE)) {
037            options.add(new ConcreteKeyValue("all", "ALL"));
038            options.add(new ConcreteKeyValue("Location_search", "Location"));
039            options.add(new ConcreteKeyValue("CallNumber_search", "Call Number"));
040            options.add(new ConcreteKeyValue("ItemBarcode_search", "Barcode"));
041        }
042        return options;
043    }
044}