001: /*
002: * Copyright 2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.kuali.module.financial.document.authorization;
017:
018: import java.util.HashMap;
019: import java.util.List;
020: import java.util.Map;
021:
022: import org.kuali.core.authorization.AuthorizationConstants;
023: import org.kuali.core.bo.user.UniversalUser;
024: import org.kuali.core.document.Document;
025: import org.kuali.core.document.TransactionalDocument;
026: import org.kuali.core.document.authorization.DocumentActionFlags;
027: import org.kuali.core.document.authorization.TransactionalDocumentActionFlags;
028: import org.kuali.core.workflow.service.KualiWorkflowDocument;
029: import org.kuali.kfs.bo.AccountingLine;
030: import org.kuali.kfs.document.authorization.AccountingDocumentAuthorizerBase;
031: import org.kuali.module.chart.bo.ChartUser;
032:
033: /**
034: * Authorization permissions specific to the Advance Deposit document.
035: */
036: public class AdvanceDepositDocumentAuthorizer extends
037: AccountingDocumentAuthorizerBase {
038: /**
039: * Only need to allow initiator or supervisor the ability to edit in pre-route mode. All other situations only present in
040: * non-edit mode. Since doc routes straight to final, no other editing is needed.
041: *
042: * @see org.kuali.core.authorization.TransactionalDocumentAuthorizer#getEditMode(org.kuali.core.document.Document,
043: * org.kuali.core.bo.user.KualiUser, java.util.List, java.util.List)
044: */
045: @Override
046: public Map getEditMode(Document document, UniversalUser user,
047: List sourceAccountingLines, List targetAccountingLines) {
048: String editMode = AuthorizationConstants.TransactionalEditMode.VIEW_ONLY;
049:
050: KualiWorkflowDocument workflowDocument = document
051: .getDocumentHeader().getWorkflowDocument();
052:
053: if ((workflowDocument.stateIsInitiated() || workflowDocument
054: .stateIsSaved())
055: && (document.getDocumentHeader()
056: .getFinancialDocumentInErrorNumber() == null)) {
057: if (workflowDocument.userIsInitiator(user)) {
058: editMode = AuthorizationConstants.TransactionalEditMode.FULL_ENTRY;
059: }
060: }
061:
062: Map editModeMap = new HashMap();
063: editModeMap.put(editMode, "TRUE");
064:
065: return editModeMap;
066: }
067:
068: /**
069: * Overrides to use the parent's implementation, with the exception that AD documents can never be error corrected.
070: *
071: * @see org.kuali.core.authorization.DocumentAuthorizer#getDocumentActionFlags(org.kuali.core.document.Document,
072: * org.kuali.core.bo.user.KualiUser)
073: */
074: @Override
075: public DocumentActionFlags getDocumentActionFlags(
076: Document document, UniversalUser user) {
077: DocumentActionFlags flags = super .getDocumentActionFlags(
078: document, user);
079:
080: TransactionalDocumentActionFlags tflags = (TransactionalDocumentActionFlags) flags;
081: tflags.setCanErrorCorrect(false); // CCR, AD, CR, DV, andd PCDO don't allow error correction
082:
083: return flags;
084: }
085:
086: /**
087: * Overrides to always return false because there is never FO routing or FO approval for AD docs.
088: *
089: * @see org.kuali.module.financial.document.FinancialDocumentAuthorizer#userOwnsAnyAccountingLine(org.kuali.core.bo.user.KualiUser,
090: * java.util.List)
091: */
092: @Override
093: protected boolean userOwnsAnyAccountingLine(ChartUser user,
094: List accountingLines) {
095: return false;
096: }
097:
098: /**
099: * Overrides parent to return an empty Map since FO routing doesn't apply to the AD doc.
100: *
101: * @see org.kuali.core.authorization.TransactionalDocumentAuthorizer#getEditableAccounts(org.kuali.core.document.TransactionalDocument,
102: * org.kuali.core.bo.user.KualiUser)
103: */
104: @Override
105: public Map getEditableAccounts(TransactionalDocument document,
106: ChartUser user) {
107: return new HashMap();
108: }
109:
110: /**
111: * Overrides parent to return an empty Map since FO routing doesn't apply to the AD doc.
112: *
113: * @see org.kuali.kfs.document.authorization.AccountingDocumentAuthorizerBase#getEditableAccounts(java.util.List,
114: * org.kuali.module.chart.bo.ChartUser)
115: */
116: @Override
117: public Map getEditableAccounts(List<AccountingLine> lines,
118: ChartUser user) {
119: return new HashMap();
120: }
121:
122: }
|