View Javadoc

1   /**
2    * Copyright 2013 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   *
15   * Created by chongzhu on 1/28/13
16   */
17  package org.kuali.student.enrollment.class2.courseoffering.keyvalue;
18  
19  import org.kuali.rice.core.api.util.ConcreteKeyValue;
20  import org.kuali.rice.core.api.util.KeyValue;
21  import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase;
22  import org.kuali.rice.krad.uif.view.ViewModel;
23  import org.kuali.rice.krad.web.form.MaintenanceDocumentForm;
24  import org.kuali.student.enrollment.class2.courseoffering.dto.CourseOfferingWrapper;
25  import org.kuali.student.enrollment.courseoffering.dto.CourseOfferingInfo;
26  import org.kuali.student.r2.lum.course.dto.CourseCrossListingInfo;
27  import org.kuali.student.r2.lum.course.dto.CourseInfo;
28  
29  import java.io.Serializable;
30  import java.util.ArrayList;
31  import java.util.List;
32  
33  /**
34   *
35   * @author Kuali Student Team
36   */
37  public class populateCrossCourseListKeyValues extends UifKeyValuesFinderBase implements Serializable {
38  
39      @Override
40      public List<KeyValue> getKeyValues(ViewModel model) {
41          MaintenanceDocumentForm coForm = (MaintenanceDocumentForm) model;
42          CourseOfferingWrapper wrapper = (CourseOfferingWrapper)coForm.getDocument().getNewMaintainableObject().getDataObject();
43  
44          List<KeyValue> keyValues = new ArrayList<KeyValue>();
45          CourseOfferingInfo courseOffering = wrapper.getCourseOfferingInfo();
46          CourseInfo CoInfo = wrapper.getCourse();
47  
48          if (CoInfo != null && CoInfo.getCrossListings() != null && CoInfo.getCrossListings().size() > 0) {
49              // Always include an option for Course
50              for (CourseCrossListingInfo courseInfo : CoInfo.getCrossListings()) {
51                  if(courseInfo.getCode() != null)   {
52                      if(courseOffering.getCourseNumberSuffix() == null) {
53                          keyValues.add(new ConcreteKeyValue(courseInfo.getCode(), courseInfo.getCode()));
54                      } else {
55                          keyValues.add(new ConcreteKeyValue(courseInfo.getCode()+courseOffering.getCourseNumberSuffix(), courseInfo.getCode()+courseOffering.getCourseNumberSuffix()));
56                      }
57                  }
58              }
59          }
60  
61          return keyValues;
62      }
63  }