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.rice.krms.impl.repository;
17  
18  import org.kuali.rice.core.api.uif.RemotableAttributeField;
19  import org.kuali.rice.kns.inquiry.KualiInquirableImpl;
20  import org.kuali.rice.krad.uif.container.Container;
21  import org.kuali.rice.krad.uif.view.View;
22  import org.kuali.rice.krad.web.form.InquiryForm;
23  import org.kuali.rice.krms.impl.ui.AgendaEditor;
24  import org.kuali.rice.krms.impl.util.KrmsRetriever;
25  
26  import java.util.Collections;
27  import java.util.List;
28  import java.util.Map;
29  
30  /**
31   * @author Kuali Rice Team (rice.collab@kuali.org)
32   */
33  public class AgendaStudentInquiryHelperServiceImpl extends KualiInquirableImpl {
34  
35      private transient KrmsRetriever krmsRetriever = new KrmsRetriever();
36  
37      @Override
38      public AgendaEditor retrieveDataObject(Map fieldValues) {
39          AgendaEditor agendaEditor = null;
40  
41          String agendaId = (String) fieldValues.get("id");
42          AgendaBo agenda = getBusinessObjectService().findBySinglePrimaryKey(AgendaBo.class, agendaId);
43          if (agenda != null) {
44              agendaEditor = new AgendaEditor();
45              agendaEditor.setAgenda(agenda);
46              agendaEditor.setNamespace(agenda.getContext().getNamespace());
47              agendaEditor.setContextName(agenda.getContext().getName());
48              agendaEditor.setCustomAttributesMap(agenda.getAttributes());
49          }
50  
51          return agendaEditor;
52      }
53  
54      /**
55       * Returns the AgendaEditor from the given InquiryForm
56       * @param model InquiryFrom to retrieve the AgendaEditor from.
57       * @return AgendaEditor retrieved from the given InquiryForm.
58       */
59      private AgendaEditor retrieveAgendaEditor(InquiryForm model) {
60          InquiryForm inquiryForm = (InquiryForm)model;
61          return (AgendaEditor)inquiryForm.getDataObject();
62      }
63  
64      /**
65       * Returns the Agenda's RemotableAttributeFields
66       * @param view
67       * @param model InquiryFrom to retrieve the AgendaEditor from.
68       * @param container
69       * @return List<RemotableAttributeField>
70       */
71      public List<RemotableAttributeField> retrieveAgendaCustomAttributes(View view, Object model, Container container) {
72          AgendaEditor agendaEditor = retrieveAgendaEditor((InquiryForm) model);
73          return krmsRetriever.retrieveAgendaCustomAttributes(agendaEditor);
74      }
75  
76      /**
77       * Returns the Rule Action RemotableAttributeFields. This only supports a single action within a rule.
78       * @param view
79       * @param model InquiryFrom to retrieve the AgendaEditor from.
80       * @param container
81       * @return List<RemotableAttributeField>
82       */
83      public List<RemotableAttributeField> retrieveRuleActionCustomAttributes(View view, Object model, Container container) {
84          AgendaEditor agendaEditor = retrieveAgendaEditor((InquiryForm)model);
85          return krmsRetriever.retrieveRuleActionCustomAttributes(agendaEditor);
86      }
87  
88      /**
89       * Returns the Rule RemotableAttributeFields. This only supports a single action within a rule.
90       * @param view
91       * @param model InquiryFrom to retrieve the AgendaEditor from.
92       * @param container
93       * @return List<RemotableAttributeField>
94       */
95      public List<RemotableAttributeField> retrieveRuleCustomAttributes(View view, Object model, Container container) {
96          AgendaEditor agendaEditor = retrieveAgendaEditor((InquiryForm)model);
97          return krmsRetriever.retrieveRuleCustomAttributes(agendaEditor);
98      }
99  
100 
101     /**
102      * Retrieve a list of {@link org.kuali.rice.core.api.uif.RemotableAttributeField}s for the parameters (if any) required by the resolver for
103      * the selected term in the proposition that is under edit.  Since this method is part of the inquiry view,
104      * non of the propositions will ever be under edit when it is called, and an empty list will be returned.
105      * @param view
106      * @param model InquiryFrom to retrieve the AgendaEditor from.
107      * @param container
108      * @return List<RemotableAttributeField> Collections.emptyList()
109      */
110     public List<RemotableAttributeField> retrieveTermParameters(View view, Object model, Container container) {
111         return Collections.emptyList();
112     }
113 }