001 /** 002 * Copyright 2004-2014 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.kpme.pm.util; 017 018 import java.util.ArrayList; 019 import java.util.List; 020 import java.util.Map; 021 022 import org.kuali.kpme.pm.PMConstants; 023 import org.kuali.kpme.pm.classification.qual.ClassificationQualification; 024 import org.kuali.kpme.pm.pstnqlfrtype.PstnQlfrType; 025 import org.kuali.kpme.pm.service.base.PmServiceLocator; 026 import org.kuali.rice.core.api.util.ConcreteKeyValue; 027 import org.kuali.rice.core.api.util.KeyValue; 028 import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase; 029 import org.kuali.rice.krad.uif.view.ViewModel; 030 import org.kuali.rice.krad.web.form.MaintenanceDocumentForm; 031 032 public class PositionClassQualifierKeyValueFinder extends UifKeyValuesFinderBase{ 033 private static final long serialVersionUID = 1L; 034 035 @Override 036 public List<KeyValue> getKeyValues() { 037 List<KeyValue> keyValues = new ArrayList<KeyValue>(); 038 for (Map.Entry entry : PMConstants.PSTN_CLSS_QLFR_VALUE_MAP.entrySet()) { 039 keyValues.add(new ConcreteKeyValue((String) entry.getKey(), (String) entry.getValue())); 040 } 041 return keyValues; 042 } 043 044 @Override 045 public List<KeyValue> getKeyValues(ViewModel model) { 046 MaintenanceDocumentForm docForm = (MaintenanceDocumentForm) model; 047 List<KeyValue> options = new ArrayList<KeyValue>(); 048 049 ClassificationQualification aQualification = (ClassificationQualification) docForm.getNewCollectionLines().get("document.newMaintainableObject.dataObject.qualificationList"); 050 if(aQualification != null) { 051 String aTypeId = aQualification.getQualificationType(); 052 PstnQlfrType aTypeObj = PmServiceLocator.getPstnQlfrTypeService().getPstnQlfrTypeById(aTypeId); 053 if(aTypeObj != null) { 054 if(aTypeObj.getTypeValue().equals(PMConstants.PSTN_QLFR_TEXT) 055 || aTypeObj.getTypeValue().equals(PMConstants.PSTN_QLFR_SELECT)) { 056 options.add(new ConcreteKeyValue(PMConstants.PSTN_CLSS_QLFR_VALUE.EQUAL, PMConstants.PSTN_CLSS_QLFR_VALUE_MAP.get(PMConstants.PSTN_CLSS_QLFR_VALUE.EQUAL))); 057 } else if(aTypeObj.getTypeValue().equals(PMConstants.PSTN_QLFR_NUMBER)){ 058 options = this.getKeyValues(); 059 } 060 } 061 062 } 063 064 return options; 065 } 066 }