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