View Javadoc

1   /**
2    * Copyright 2004-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.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/ecl2.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.kpme.pm.util;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  import java.util.Map;
21  
22  import org.kuali.kpme.pm.PMConstants;
23  import org.kuali.kpme.pm.classification.qual.ClassificationQualification;
24  import org.kuali.kpme.pm.pstnqlfrtype.PstnQlfrType;
25  import org.kuali.kpme.pm.service.base.PmServiceLocator;
26  import org.kuali.rice.core.api.util.ConcreteKeyValue;
27  import org.kuali.rice.core.api.util.KeyValue;
28  import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase;
29  import org.kuali.rice.krad.uif.view.ViewModel;
30  import org.kuali.rice.krad.web.form.MaintenanceDocumentForm;
31  
32  public class PositionClassQualifierKeyValueFinder extends UifKeyValuesFinderBase{
33  	private static final long serialVersionUID = 1L;
34  
35  	@Override
36  	public List<KeyValue> getKeyValues() {
37  		List<KeyValue> keyValues = new ArrayList<KeyValue>();
38  		for (Map.Entry entry : PMConstants.PSTN_CLSS_QLFR_VALUE_MAP.entrySet()) {
39              keyValues.add(new ConcreteKeyValue((String) entry.getKey(), (String) entry.getValue()));
40          }            
41  		return keyValues;
42  	}
43  
44  	@Override
45      public List<KeyValue> getKeyValues(ViewModel model) {
46  		MaintenanceDocumentForm docForm = (MaintenanceDocumentForm) model;
47  		List<KeyValue> options = new ArrayList<KeyValue>();
48  
49  		ClassificationQualification aQualification = (ClassificationQualification) docForm.getNewCollectionLines().get("document.newMaintainableObject.dataObject.qualificationList");
50  		if(aQualification != null) {
51  			String aTypeId = aQualification.getQualificationType();
52  			PstnQlfrType aTypeObj = PmServiceLocator.getPstnQlfrTypeService().getPstnQlfrTypeById(aTypeId);
53  			if(aTypeObj != null) {
54  				if(aTypeObj.getTypeValue().equals(PMConstants.PSTN_QLFR_TEXT)
55  						|| aTypeObj.getTypeValue().equals(PMConstants.PSTN_QLFR_SELECT)) {
56  					 options.add(new ConcreteKeyValue(PMConstants.PSTN_CLSS_QLFR_VALUE.EQUAL, PMConstants.PSTN_CLSS_QLFR_VALUE_MAP.get(PMConstants.PSTN_CLSS_QLFR_VALUE.EQUAL)));
57  				} else if(aTypeObj.getTypeValue().equals(PMConstants.PSTN_QLFR_NUMBER)){
58  					options = this.getKeyValues();
59  				}
60  			}
61  			
62  		}
63  		
64          return options;
65      }
66  }