View Javadoc

1   /**
2    * Copyright 2005-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.student.enrollment.class1.krms.util;
17  
18  import com.google.common.collect.Maps;
19  import org.kuali.rice.krad.uif.component.BindingInfo;
20  import org.kuali.rice.krad.uif.component.Component;
21  import org.kuali.rice.krad.uif.container.CollectionGroup;
22  import org.kuali.rice.krad.uif.container.Group;
23  import org.kuali.rice.krad.uif.container.NodePrototype;
24  import org.kuali.rice.krad.uif.util.ComponentUtils;
25  import org.kuali.rice.krad.uif.util.ObjectPropertyUtils;
26  import org.kuali.rice.krad.uif.view.View;
27  import org.kuali.rice.krms.dto.AgendaEditor;
28  import org.kuali.rice.krms.dto.RuleEditor;
29  import org.kuali.rice.krms.service.RuleViewHelperService;
30  import org.kuali.rice.krms.util.AgendaBuilder;
31  import org.kuali.rice.krms.util.AgendaSection;
32  
33  import java.util.ArrayList;
34  import java.util.List;
35  import java.util.Map;
36  
37  /**
38   * @author Kuali Student Team
39   */
40  public class FinalExamAgendaSection extends AgendaSection {
41  
42      private AgendaBuilder agendaBuilder;
43      private Map<String, Group> agendaPrototypeMap;
44  
45      public AgendaBuilder getAgendaBuilder() {
46          if (this.agendaBuilder == null) {
47              this.agendaBuilder = new FinalExamAgendaBuilder();
48          }
49          return this.agendaBuilder;
50      }
51  
52      public Map<String, Group> getAgendaPrototypeMap() {
53          return agendaPrototypeMap;
54      }
55  
56      public void setAgendaPrototypeMap(Map<String, Group> agendaPrototypeMap) {
57          this.agendaPrototypeMap = agendaPrototypeMap;
58      }
59  
60      @Override
61      public List<Component> getComponentPrototypes() {
62          List<Component> components = super.getComponentPrototypes();
63          for (Map.Entry<String, Group> agendaPrototypeMapEntry : this.getAgendaPrototypeMap().entrySet()) {
64              components.add(agendaPrototypeMapEntry.getValue());
65          }
66  
67          return components;
68      }
69  
70      /**
71       * @see org.kuali.rice.krad.uif.component.ComponentBase#copy()
72       */
73      @Override
74      protected <T> void copyProperties(T component) {
75          super.copyProperties(component);
76  
77          FinalExamAgendaSection agendaSectionCopy = (FinalExamAgendaSection) component;
78          if (this.agendaPrototypeMap != null) {
79              Map<String, Group> agendaPrototypeMapCopy = Maps.newHashMapWithExpectedSize(
80                      this.getAgendaPrototypeMap().size());
81              for (Map.Entry<String, Group> agendaPrototypeMapEntry : agendaPrototypeMap.entrySet()) {
82                  Group prototypeCopy = (Group) agendaPrototypeMapEntry.getValue().copy();
83                  agendaPrototypeMapCopy.put(agendaPrototypeMapEntry.getKey(), prototypeCopy);
84              }
85  
86              agendaSectionCopy.setAgendaPrototypeMap(agendaPrototypeMapCopy);
87          }
88      }
89  }