Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
EditorDocumentMaintainable |
|
| 1.6;1.6 |
1 | /* | |
2 | * Copyright 2011 The Kuali Foundation | |
3 | * | |
4 | * Licensed under the Educational Community License, Version 1.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/ecl1.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.ui; | |
17 | ||
18 | import java.util.Map; | |
19 | ||
20 | import org.kuali.rice.krad.bo.BusinessObject; | |
21 | import org.kuali.rice.krad.bo.PersistableBusinessObject; | |
22 | import org.kuali.rice.krad.document.MaintenanceDocument; | |
23 | import org.kuali.rice.krad.maintenance.KualiMaintainableImpl; | |
24 | import org.kuali.rice.krad.service.BusinessObjectService; | |
25 | import org.kuali.rice.krad.service.KRADServiceLocator; | |
26 | import org.kuali.rice.krad.util.KRADConstants; | |
27 | import org.kuali.rice.krms.impl.repository.AgendaBo; | |
28 | import org.kuali.rice.krms.impl.repository.ContextBo; | |
29 | ||
30 | /** | |
31 | * This is a description of what this class does - gilesp don't forget to fill this in. | |
32 | * | |
33 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
34 | * | |
35 | */ | |
36 | 0 | public class EditorDocumentMaintainable extends KualiMaintainableImpl { |
37 | ||
38 | private static final long serialVersionUID = 1L; | |
39 | ||
40 | /** | |
41 | * @return the boService | |
42 | */ | |
43 | public BusinessObjectService getBoService() { | |
44 | 0 | return KRADServiceLocator.getBusinessObjectService(); |
45 | } | |
46 | ||
47 | /** | |
48 | * {@inheritDoc} | |
49 | */ | |
50 | @Override | |
51 | public void setupMaintenanceObject(MaintenanceDocument document, | |
52 | String maintenanceAction, Map<String, String[]> requestParameters) { | |
53 | ||
54 | 0 | super.setupMaintenanceObject(document, maintenanceAction, requestParameters); |
55 | ||
56 | 0 | if (KRADConstants.MAINTENANCE_NEW_ACTION.equals(maintenanceAction)) { |
57 | 0 | String[] agendaIds = requestParameters.get("agendaId"); |
58 | 0 | if (agendaIds == null || agendaIds.length != 1) { |
59 | //throw new RiceRuntimeException("one and only one agendaId request parameter may be passed"); | |
60 | } else { | |
61 | // TODO: change this, it makes more sense for MAINTENANCE_EDIT_ACTION | |
62 | 0 | String agendaId = agendaIds[0]; |
63 | ||
64 | 0 | AgendaBo agenda = getBoService().findBySinglePrimaryKey(AgendaBo.class, agendaId); |
65 | 0 | String contextId = agenda.getContextId(); |
66 | ||
67 | 0 | ContextBo context = getBoService().findBySinglePrimaryKey(ContextBo.class, contextId); |
68 | ||
69 | 0 | EditorDocument editor = (EditorDocument) document.getDocumentBusinessObject(); |
70 | ||
71 | 0 | editor.setContext(context); |
72 | 0 | editor.setAgenda(agenda); |
73 | } | |
74 | } | |
75 | ||
76 | ||
77 | 0 | } |
78 | ||
79 | /** | |
80 | * This overridden method ... | |
81 | * | |
82 | * @see org.kuali.rice.krad.maintenance.KualiMaintainableImpl#saveBusinessObject() | |
83 | */ | |
84 | @Override | |
85 | public void saveBusinessObject() { | |
86 | // TODO here's where we can handle persisting our agenda and context | |
87 | 0 | super.saveBusinessObject(); |
88 | 0 | } |
89 | ||
90 | // /** | |
91 | // * @see org.kuali.rice.krad.maintenance.KualiMaintainableImpl#processAfterNew(org.kuali.rice.krad.document.MaintenanceDocument, java.util.Map) | |
92 | // */ | |
93 | // @Override | |
94 | // public void processAfterNew(MaintenanceDocument document, | |
95 | // Map<String, String[]> parameters) { | |
96 | // // TODO gilesp - THIS METHOD NEEDS JAVADOCS | |
97 | // super.processAfterNew(document, parameters); | |
98 | // | |
99 | // EditorDocument editor = (EditorDocument) document.getDocumentBusinessObject(); | |
100 | // | |
101 | // editor.getContext().setName("new"); | |
102 | // } | |
103 | ||
104 | /** | |
105 | * This overridden method ... | |
106 | * | |
107 | * @see org.kuali.rice.krad.maintenance.KualiMaintainableImpl#getBusinessObject() | |
108 | */ | |
109 | @Override | |
110 | public PersistableBusinessObject getBusinessObject() { | |
111 | // TODO gilesp - THIS METHOD NEEDS JAVADOCS | |
112 | 0 | return super.getBusinessObject(); |
113 | } | |
114 | ||
115 | /** | |
116 | * This overridden method ... | |
117 | * | |
118 | * @see org.kuali.rice.krad.maintenance.KualiMaintainableImpl#prepareBusinessObject(org.kuali.rice.krad.bo.BusinessObject) | |
119 | */ | |
120 | @Override | |
121 | public void prepareBusinessObject(BusinessObject businessObject) { | |
122 | // TODO gilesp - THIS METHOD NEEDS JAVADOCS | |
123 | 0 | super.prepareBusinessObject(businessObject); |
124 | 0 | } |
125 | ||
126 | } |