001: /*
002: * Copyright 2005-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.core.web.struts.form;
017:
018: import java.util.HashMap;
019: import java.util.Map;
020:
021: import org.kuali.core.document.TransactionalDocument;
022: import org.kuali.core.document.authorization.TransactionalDocumentActionFlags;
023: import org.kuali.core.service.DataDictionaryService;
024: import org.kuali.rice.KNSServiceLocator;
025:
026: /**
027: * This class is the base action form for all transactional documents.
028: */
029: public class KualiTransactionalDocumentFormBase extends
030: KualiDocumentFormBase {
031: /**
032: *
033: */
034: private static final long serialVersionUID = 6463383454050206811L;
035: protected Map forcedReadOnlyFields;
036:
037: /**
038: * This constructor sets up empty instances for the dependent objects...
039: */
040: public KualiTransactionalDocumentFormBase() {
041: super ();
042:
043: // create a blank TransactionalDocumentActionFlags instance, since form-recreation needs it
044: setDocumentActionFlags(new TransactionalDocumentActionFlags());
045: forcedReadOnlyFields = new HashMap();
046: }
047:
048: /**
049: * This method retrieves an instance of the form.
050: *
051: * @return
052: */
053: public TransactionalDocument getTransactionalDocument() {
054: return (TransactionalDocument) getDocument();
055: }
056:
057: /**
058: * Locates the <code>DictionaryService</code> to discover the type name of the document.
059: *
060: * @return
061: */
062: protected String discoverDocumentTypeName() {
063: return ((DataDictionaryService) KNSServiceLocator
064: .getDataDictionaryService()).getDataDictionary()
065: .getDocumentEntry(getDocument().getClass().getName())
066: .getDocumentTypeName();
067: }
068:
069: /**
070: * This method formats the given java.sql.Date as MMM d, yyyy.
071: *
072: * @param reversalDate
073: *
074: * @return String
075: */
076: protected static String formatReversalDate(
077: java.sql.Date reversalDate) {
078: if (reversalDate == null) {
079: return "";
080: }
081: // new for thread safety
082: return KNSServiceLocator.getDateTimeService().toString(
083: reversalDate, "MMM d, yyyy");
084: }
085:
086: /**
087: * Gets the forcedReadOnlyFields attribute.
088: *
089: * @return Returns the forcedReadOnlyFields.
090: */
091: public Map getForcedReadOnlyFields() {
092: return forcedReadOnlyFields;
093: }
094:
095: /**
096: * Sets the forcedReadOnlyFields attribute value.
097: *
098: * @param forcedReadOnlyFields The forcedReadOnlyFields to set.
099: */
100: public void setForcedReadOnlyFields(Map forcedReadOnlyFields) {
101: this.forcedReadOnlyFields = forcedReadOnlyFields;
102: }
103: }
|