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