001: /*
002: * Copyright 2006-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.purap.web.struts.form;
017:
018: import java.util.ArrayList;
019: import java.util.List;
020:
021: import org.kuali.module.purap.bo.PurApAccountingLine;
022: import org.kuali.module.purap.bo.PurApAccountingLineBase;
023: import org.kuali.module.purap.bo.PurApItem;
024:
025: /**
026: * Struts Action Form for Purchasing documents.
027: */
028: public class PurchasingFormBase extends
029: PurchasingAccountsPayableFormBase {
030:
031: private Boolean notOtherDeliveryBuilding = true;
032: private Boolean hideDistributeAccounts = true;
033: private PurApItem newPurchasingItemLine;
034:
035: // *** Note that the following variables do not use camel caps ON PURPOSE, because of how the accounting lines tag uses the
036: // accountPrefix
037: private Integer accountDistributionnextSourceLineNumber;
038: private List<PurApAccountingLine> accountDistributionsourceAccountingLines;
039: private PurApAccountingLine accountDistributionnewSourceLine;
040:
041: /**
042: * Constructs a PurchasingFormBase instance and sets up the appropriately casted document.
043: */
044: public PurchasingFormBase() {
045: super ();
046: this .setNewPurchasingItemLine(setupNewPurchasingItemLine());
047: newPurchasingItemLine.setItemTypeCode("ITEM");
048:
049: this .accountDistributionnextSourceLineNumber = new Integer(1);
050: setAccountDistributionsourceAccountingLines(new ArrayList());
051: this
052: .setAccountDistributionnewSourceLine(setupNewAccountDistributionAccountingLine());
053: }
054:
055: public Boolean getNotOtherDeliveryBuilding() {
056: return notOtherDeliveryBuilding;
057: }
058:
059: public void setNotOtherDeliveryBuilding(
060: Boolean notOtherDeliveryBuilding) {
061: this .notOtherDeliveryBuilding = notOtherDeliveryBuilding;
062: }
063:
064: public Boolean getHideDistributeAccounts() {
065: return hideDistributeAccounts;
066: }
067:
068: public void setHideDistributeAccounts(Boolean hideDistributeAccounts) {
069: this .hideDistributeAccounts = hideDistributeAccounts;
070: }
071:
072: public Integer getAccountDistributionnextSourceLineNumber() {
073: return accountDistributionnextSourceLineNumber;
074: }
075:
076: public void setAccountDistributionnextSourceLineNumber(
077: Integer accountDistributionnextSourceLineNumber) {
078: this .accountDistributionnextSourceLineNumber = accountDistributionnextSourceLineNumber;
079: }
080:
081: public List<PurApAccountingLine> getAccountDistributionsourceAccountingLines() {
082: return accountDistributionsourceAccountingLines;
083: }
084:
085: public void setAccountDistributionsourceAccountingLines(
086: List<PurApAccountingLine> accountDistributionAccountingLines) {
087: this .accountDistributionsourceAccountingLines = accountDistributionAccountingLines;
088: }
089:
090: public PurApAccountingLine getAccountDistributionnewSourceLine() {
091: return accountDistributionnewSourceLine;
092: }
093:
094: public void setAccountDistributionnewSourceLine(
095: PurApAccountingLine accountDistributionnewSourceLine) {
096: this .accountDistributionnewSourceLine = accountDistributionnewSourceLine;
097: }
098:
099: public PurApItem getNewPurchasingItemLine() {
100: return newPurchasingItemLine;
101: }
102:
103: public void setNewPurchasingItemLine(PurApItem newPurchasingItemLine) {
104: this .newPurchasingItemLine = newPurchasingItemLine;
105: }
106:
107: /**
108: * Returns the Account Distribution Source Accounting Line at the specified index.
109: *
110: * @param index the index of the Account Distribution Source Accounting Line.
111: * @return the specified Account Distribution Source Accounting Line.
112: */
113: public PurApAccountingLine getAccountDistributionsourceAccountingLine(
114: int index) {
115: while (accountDistributionsourceAccountingLines.size() <= index) {
116: accountDistributionsourceAccountingLines
117: .add(setupNewAccountDistributionAccountingLine());
118: }
119: return accountDistributionsourceAccountingLines.get(index);
120: }
121:
122: /**
123: * Returns the new Purchasing Item Line and resets it to null.
124: *
125: * @return the new Purchasing Item Line.
126: */
127: public PurApItem getAndResetNewPurchasingItemLine() {
128: PurApItem aPurchasingItemLine = getNewPurchasingItemLine();
129: setNewPurchasingItemLine(setupNewPurchasingItemLine());
130: return aPurchasingItemLine;
131: }
132:
133: /**
134: * This method should be overriden (or see accountingLines for an alternate way of doing this with newInstance)
135: */
136: public PurApItem setupNewPurchasingItemLine() {
137: return null;
138: }
139:
140: /**
141: * This method should be overriden (or see accountingLines for an alternate way of doing this with newInstance)
142: */
143: public PurApAccountingLineBase setupNewPurchasingAccountingLine() {
144: return null;
145: }
146:
147: /**
148: * This method should be overriden.
149: */
150: public PurApAccountingLineBase setupNewAccountDistributionAccountingLine() {
151: return null;
152: }
153:
154: /**
155: * Sets the sequence number appropriately for the passed in source accounting line using the value that has been stored in the
156: * nextSourceLineNumber variable, adds the accounting line to the list that is aggregated by this object, and then handles
157: * incrementing the nextSourceLineNumber variable.
158: *
159: * @param line the accounting line to add to the list.
160: * @see org.kuali.kfs.document.AccountingDocument#addSourceAccountingLine(SourceAccountingLine)
161: */
162: public void addAccountDistributionsourceAccountingLine(
163: PurApAccountingLine line) {
164: line.setSequenceNumber(this
165: .getAccountDistributionnextSourceLineNumber());
166: this .accountDistributionsourceAccountingLines.add(line);
167: this .accountDistributionnextSourceLineNumber = new Integer(this
168: .getAccountDistributionnextSourceLineNumber()
169: .intValue() + 1);
170: this
171: .setAccountDistributionnewSourceLine(setupNewAccountDistributionAccountingLine());
172: }
173:
174: }
|