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.krad.service;
17
18 import org.kuali.rice.krad.maintenance.MaintenanceDocument;
19 import org.kuali.rice.krad.maintenance.MaintenanceLock;
20 import org.kuali.rice.krad.maintenance.Maintainable;
21
22 import java.util.List;
23 import java.util.Map;
24
25 /**
26 * Provides methods for working with {@link org.kuali.rice.krad.maintenance.MaintenanceDocument}.
27 *
28 * @author Kuali Rice Team (rice.collab@kuali.org)
29 */
30 public interface MaintenanceDocumentService {
31
32 /**
33 * Prepares the <code>MaintenanceDocument</code> on initial request.
34 *
35 * <p>This includes retrieving the data object for edit or copy, clearing fields</p>
36 *
37 * @param objectClassName class name for the object being maintained
38 * @param docTypeName workflow doc type for the maintenance document requested
39 * @param maintenanceAction indicates whether this is a new, copy, or edit maintenance action
40 * @return MaintenanceDocument prepared document instance
41 */
42 MaintenanceDocument setupNewMaintenanceDocument(
43 String objectClassName, String docTypeName, String maintenanceAction);
44
45 /**
46 * Called to setup the object being maintained.
47 *
48 * <p>For edit and copy actions, the old record is retrieved and prepared for
49 * editing (in the case of a copy some fields are cleared). In addition some
50 * authorization checks are performed and hooks for custom
51 * <code>Maintainble</code> implementations are invoked.</p>
52 *
53 * @param document document instance for the maintenance object
54 * @param maintenanceAction the requested maintenance action (new, new with existing,
55 * copy, edit)
56 * @param requestParameters Map of parameters from the request
57 */
58 void setupMaintenanceObject(MaintenanceDocument document, String maintenanceAction,
59 Map<String, String[]> requestParameters);
60
61 /**
62 * Attempts to find any other active documents that are pending on the same
63 * maintenance record.
64 *
65 * <p>If any are pending and locked, thereby blocking this document, then the
66 * docHeaderId/documentNumber of the blocking locked document is returned.
67 * Otherwise, if nothing is blocking, then null is returned.</p>
68 *
69 * @param document document to test
70 * @return A String representing the docHeaderId of any blocking document,
71 * or null if none are blocking
72 *
73 */
74 String getLockingDocumentId(MaintenanceDocument document);
75
76 /**
77 * Attempts to find any other active documents that are pending on the same
78 * maintenance record.
79 *
80 * <p>If any are pending and locked, thereby blocking this document, then the
81 * docHeaderId/documentNumber of the blocking locked document is returned. *
82 * Otherwise, if nothing is blocking, then null is returned.</p>
83 *
84 * @param maintainable maintainable representing the document to test
85 * @param documentNumber the documentNumber/docHeaderId of the document to test
86 * @return A String representing the docHeaderId of any blocking document,
87 * or null if none are blocking
88 */
89 String getLockingDocumentId(Maintainable maintainable,
90 String documentNumber);
91
92 /**
93 * Call the same-named method in the Dao, since the service has access to
94 * the Dao, but the caller doesn't.
95 *
96 * <p>This method deletes the locks for the given document number. It is called
97 * when the document is final, thus it can be unlocked, or when the locks
98 * need to be regenerated (thus they get cleared first).</p>
99 *
100 * @param documentNumber document number whose locks should be deleted
101 */
102 void deleteLocks(String documentNumber);
103
104 /**
105 * Call the same-named method in the Dao, since the service has access to
106 * the Dao, but the caller doesn't.
107 *
108 * <p>This method stores the given list of maintenance locks. Typically these
109 * will all be for the same document.</p>
110 *
111 * @param maintenanceLocks the list of maintenance locks to be stored
112 */
113 void storeLocks(List<MaintenanceLock> maintenanceLocks);
114
115 }