View Javadoc
1   /*
2    * Copyright 2008 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.ole.sys.document.authorization;
17  
18  import java.util.List;
19  import java.util.Set;
20  
21  import org.kuali.ole.sys.businessobject.AccountingLine;
22  import org.kuali.ole.sys.document.AccountingDocument;
23  import org.kuali.ole.sys.document.web.AccountingLineRenderingContext;
24  import org.kuali.ole.sys.document.web.AccountingLineViewAction;
25  import org.kuali.rice.kim.api.identity.Person;
26  
27  /**
28   * Methods used to determine certain permissions associated with an accounting line.
29   */
30  public interface AccountingLineAuthorizer {
31  
32      /**
33       * Determines which, if any, blocks whose children elements should not in any fashion be rendered
34       * 
35       * @param accountingDocument the accounting document the line to authorize is owned by
36       * @param accountingLine the accounting line that is being authorized against
37       * @param newLine whether the line is a new line or not
38       * @return a Set of the names of blocks that should not being in any way rendered
39       */
40      public abstract Set<String> getUnviewableBlocks(AccountingDocument accountingDocument, AccountingLine accountingLine, boolean newLine, Person currentUser);
41  
42      /**
43       * Determines what actions are available to act upon the given accounting line
44       * 
45       * @param accountingDocument the accounting document the line to authorize is owned by
46       * @param accountingLineRenderingContext a renderable context wrapping the accounting line that is being authorized against
47       * @param accountingLinePropertyName the name of the property that represents the accounting line
48       * @param lineIndex value, as Integer, of the index of the given accounting line within the group's collection of accounting
49       *        lines; if null, then it is assumed that this is a new line
50       * @param groupTitle title of the group from the data dictionary
51       * @return a List of the Actions that are available for this line
52       */
53      public abstract List<AccountingLineViewAction> getActions(AccountingDocument accountingDocument, AccountingLineRenderingContext accountingLineRenderingContext, String accountingLinePropertyName, Integer lineIndex, Person currentUser, String groupTitle);
54  
55      /**
56       * Determines if new lines should be rendered for the given accounting line group (identified by its property name)
57       * 
58       * @param accountingDocument the document that has accounting lines being authorized
59       * @param accountingGroupProperty the property of this accounting group
60       * @return true if new lines should be displayed, false otherwise
61       */
62      public abstract boolean renderNewLine(AccountingDocument accountingDocument, String accountingGroupProperty);
63  
64      /**
65       * Determines if any entire group is rendered as editable, which means that a new line will appear
66       * 
67       * @param accountingDocument the accounting document which the collection of line are on
68       * @param accountingLineRenderingContexts the accounting lines of the group, wrapped in AccountingLineRenderingContext implementations
69       * @param currentUser the current user
70       * @return true if the group can be edited, false otherwise
71       */
72      public abstract boolean isGroupEditable(AccountingDocument accountingDocument, List<? extends AccountingLineRenderingContext> accountingLineRenderingContexts, Person currentUser);
73  
74      /**
75       * determine whether the current user has permission to edit the given field in the given accounting line
76       * 
77       * @param accountingDocument the given accounting document
78       * @param accountingLine the given accounting line in the document
79       * @param accountingLineCollectionProperty the property of the collection the given accounting line is in
80       * @param fieldName the name of a field in the given accounting line
81       * @param editableLine whether the parent line of this field is editable
82       * @param editablePage whether the parent page of this field is editable
83       * @param currentUser the current user
84       * @return true if the the current user has permission to edit the given field in the given accounting line; otherwsie, false
85       */
86      public abstract boolean hasEditPermissionOnField(AccountingDocument accountingDocument, AccountingLine accountingLine, String accountingLineCollectionProperty, String fieldName, boolean editableLine, boolean editablePage, Person currentUser);
87      
88      /**
89       * determine whether the current user has permission to edit the given accounting line as a whole
90       * 
91       * @param accountingDocument the given accounting document
92       * @param accountingLine the given accounting line in the document
93       * @param accountingLineCollectionProperty the property of the group that holds these accounting lines
94       * @param currentUser the current user
95       * @param pageIsEditable whether the current page is editable by the current user or not
96       * @return true if the the current user has permission to edit the given accounting line; otherwsie, false
97       */
98      public abstract boolean hasEditPermissionOnAccountingLine(AccountingDocument accountingDocument, AccountingLine accountingLine, String accountingLineCollectionProperty, Person currentUser, boolean pageIsEditable);
99  }