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.purap.fixtures;
017:
018: import org.kuali.module.purap.bo.PurchasingItem;
019: import org.kuali.module.purap.bo.RequisitionItem;
020: import org.kuali.module.purap.document.RequisitionDocument;
021:
022: public enum RequisitionItemFixture {
023:
024: REQ_QTY_UNRESTRICTED_ITEM_1(
025: false, // itemRestrictedIndicator
026: PurApItemFixture.BASIC_QTY_ITEM_1, // purApItemFixture
027: new RequisitionAccountingLineFixture[] { RequisitionAccountingLineFixture.BASIC_REQ_ACCOUNT_1 } // requisitionAccountMultiFixtures
028: ),
029:
030: REQ_QTY_APO_ITEM_1(
031: false, // itemRestrictedIndicator
032: PurApItemFixture.APO_QTY_ITEM_1, // purApItemFixture
033: new RequisitionAccountingLineFixture[] { RequisitionAccountingLineFixture.APO_REQ_ACCOUNT_1 } // requisitionAccountMultiFixtures
034: ), REQ_SERVICE_APO_ITEM_1(
035: false, // itemRestrictedIndicator
036: PurApItemFixture.APO_SERVICE_ITEM_1, // purApItemFixture
037: new RequisitionAccountingLineFixture[] {
038: RequisitionAccountingLineFixture.APO_REQ_ACCOUNT_2,
039: RequisitionAccountingLineFixture.APO_REQ_ACCOUNT_3 } // requisitionAccountMultiFixtures
040: ), REQ_FREIGHT_ITEM_1(
041: false, // itemRestrictedIndicator
042: PurApItemFixture.APO_FREIGHT_ITEM_1, // purApItemFixture
043: new RequisitionAccountingLineFixture[] { RequisitionAccountingLineFixture.APO_REQ_ACCOUNT_4 } // requisitionAccountMultiFixtures
044: ),
045:
046: REQ_MULTI_ITEM_QUANTITY(
047: false, // itemRestrictedIndicator
048: PurApItemFixture.REQ_MULTI_ITEM_QUANTITY, // purApItemFixture
049: new RequisitionAccountingLineFixture[] { RequisitionAccountingLineFixture.REQ_ACCOUNT_MULTI_QUANTITY } // requisitionAccountMultiFixtures
050: ), REQ_MULTI_ITEM_NON_QUANTITY(
051: false, // itemRestrictedIndicator
052: PurApItemFixture.REQ_MULTI_ITEM_NON_QUANTITY, // purApItemFixture
053: new RequisitionAccountingLineFixture[] { RequisitionAccountingLineFixture.REQ_ACCOUNT_MULTI_NON_QUANTITY } // requisitionAccountMultiFixtures
054: ), REQ_ITEM_NO_APO(
055: false, // itemRestrictedIndicator
056: PurApItemFixture.BASIC_QTY_ITEM_NO_APO, // purApItemFixture
057: new RequisitionAccountingLineFixture[] { RequisitionAccountingLineFixture.BASIC_REQ_ACCOUNT_1 } // requisitionAccountMultiFixtures
058: ), ;
059:
060: private boolean itemRestrictedIndicator;
061: private PurApItemFixture purApItemFixture;
062: private RequisitionAccountingLineFixture[] requisitionAccountingLineFixtures;
063:
064: private RequisitionItemFixture(
065: boolean itemRestrictedIndicator,
066: PurApItemFixture purApItemFixture,
067: RequisitionAccountingLineFixture[] requisitionAccountingLineFixtures) {
068: this .itemRestrictedIndicator = itemRestrictedIndicator;
069: this .purApItemFixture = purApItemFixture;
070: this .requisitionAccountingLineFixtures = requisitionAccountingLineFixtures;
071: }
072:
073: public void addTo(RequisitionDocument requisitionDocument) {
074: RequisitionItem item = null;
075: item = (RequisitionItem) this .createRequisitionItem();
076: requisitionDocument.addItem(item);
077: // iterate over the accounts
078: for (RequisitionAccountingLineFixture requisitionAccountMultiFixture : requisitionAccountingLineFixtures) {
079: requisitionAccountMultiFixture.addTo(item);
080: }
081: }
082:
083: public PurchasingItem createRequisitionItem() {
084: RequisitionItem item = (RequisitionItem) purApItemFixture
085: .createPurApItem(RequisitionItem.class);
086: item.setItemRestrictedIndicator(itemRestrictedIndicator);
087: return item;
088: }
089:
090: /**
091: * @return
092: */
093: // public PurApItem createRequisitionItem() {
094: // return createRequisitionItem(defaultItemFixture);
095: // }
096: //
097: //
098: //
099: // /**
100: // *
101: // * This method adds an item to a document
102: // * @param document
103: // * @param purApItemFixture
104: // * @throws IllegalAccessException
105: // * @throws InstantiationException
106: // */
107: // public RequisitionItem addTo(PurchasingAccountsPayableDocument document, PurApItemFixture purApItemFixture)
108: // throws IllegalAccessException, InstantiationException {
109: // RequisitionItem item = (RequisitionItem)this.createRequisitionItem(purApItemFixture);
110: // document.addItem(item);
111: // return item;
112: //
113: // }
114: }
|