View Javadoc

1   /**
2    * Copyright 2004-2014 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.position;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.kuali.kpme.pm.PMConstants;
22  import org.kuali.kpme.pm.pstnqlfrtype.PstnQlfrType;
23  import org.kuali.kpme.pm.service.base.PmServiceLocator;
24  import org.kuali.rice.core.api.util.ConcreteKeyValue;
25  import org.kuali.rice.core.api.util.KeyValue;
26  import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase;
27  import org.kuali.rice.krad.uif.view.ViewModel;
28  import org.kuali.rice.krad.web.form.MaintenanceDocumentForm;
29  
30  public class PositionQualifierValueKeyValueFinder  extends UifKeyValuesFinderBase {
31  
32  	private static final long serialVersionUID = 1L;
33  
34  	@Override
35  	public List<KeyValue> getKeyValues(ViewModel model) {
36  		MaintenanceDocumentForm docForm = (MaintenanceDocumentForm) model;
37  		List<KeyValue> options = new ArrayList<KeyValue>();
38  
39  		PositionQualification aQualification = (PositionQualification) docForm.getNewCollectionLines().get("document.newMaintainableObject.dataObject.qualificationList");
40  		if(aQualification != null) {
41  			String aTypeId = aQualification.getQualificationType();
42  			PstnQlfrType aTypeObj = PmServiceLocator.getPstnQlfrTypeService().getPstnQlfrTypeById(aTypeId);
43  			if(aTypeObj != null) {
44  				if(aTypeObj.getTypeValue().equals(PMConstants.PSTN_QLFR_SELECT)){
45  					String[] aCol = aTypeObj.getSelectValues().split(",");
46  					for(String aString : aCol){
47  						options.add(new ConcreteKeyValue(aString, aString));
48  					}
49  				} else{
50  					return new ArrayList<KeyValue>();
51  				}
52  			}
53  		}
54          return options;
55  	}
56  	
57  
58  }