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.labor.web.struts.action;
017:
018: import javax.servlet.http.HttpServletRequest;
019: import javax.servlet.http.HttpServletResponse;
020:
021: import org.apache.commons.lang.StringUtils;
022: import org.apache.struts.action.ActionForm;
023: import org.apache.struts.action.ActionForward;
024: import org.apache.struts.action.ActionMapping;
025: import org.kuali.kfs.KFSConstants;
026: import org.kuali.module.chart.bo.codes.BalanceTyp;
027: import org.kuali.module.financial.web.struts.form.JournalVoucherForm;
028: import org.kuali.module.labor.LaborConstants;
029: import org.kuali.module.labor.bo.LaborLedgerPendingEntry;
030:
031: /**
032: * Struts Action Form for the Labor Ledger Journal Voucher. This class piggy backs on all of the functionality in the
033: * KualiTransactionalDocumentActionBase but is necessary for this document type. The Journal Voucher is unique in that it defines
034: * several fields that aren't typically used by the other financial transaction processing eDocs (i.e. external system fields,
035: * object type override, credit and debit amounts).
036: */
037: public class JournalVoucherAction
038: extends
039: org.kuali.module.financial.web.struts.action.JournalVoucherAction {
040:
041: /**
042: * @see org.kuali.core.web.struts.action.KualiAction#performLookup(org.apache.struts.action.ActionMapping,
043: * org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
044: */
045: @Override
046: public ActionForward performLookup(ActionMapping mapping,
047: ActionForm form, HttpServletRequest request,
048: HttpServletResponse response) throws Exception {
049:
050: // parse out the business object name from our methodToCall parameter
051: String fullParameter = (String) request
052: .getAttribute(KFSConstants.METHOD_TO_CALL_ATTRIBUTE);
053: String boClassName = StringUtils.substringBetween(
054: fullParameter,
055: KFSConstants.METHOD_TO_CALL_BOPARM_LEFT_DEL,
056: KFSConstants.METHOD_TO_CALL_BOPARM_RIGHT_DEL);
057:
058: if (!StringUtils.equals(boClassName,
059: LaborLedgerPendingEntry.class.getName())) {
060: return super
061: .performLookup(mapping, form, request, response);
062: }
063:
064: String path = super .performLookup(mapping, form, request,
065: response).getPath();
066: path = path.replaceFirst(KFSConstants.LOOKUP_ACTION,
067: LaborConstants.LONG_ROW_TABLE_INRUIRY_ACTION);
068:
069: return new ActionForward(path, true);
070: }
071:
072: /**
073: * Labor JV allows reference fields on all encumbrance types. So only want to give message if a change is being made from a
074: * encumbrance balance type to a nor (or vice-versa).
075: *
076: * @see org.kuali.module.financial.web.struts.action.JournalVoucherAction#determineBalanceTypeEncumbranceChangeMode(org.kuali.module.financial.web.struts.form.JournalVoucherForm)
077: */
078: @Override
079: protected int determineBalanceTypeEncumbranceChangeMode(
080: JournalVoucherForm journalVoucherForm) throws Exception {
081: int balanceTypeExternalEncumbranceChangeMode = NO_MODE_CHANGE;
082:
083: // retrieve fully populated balance type instances
084: BalanceTyp origBalType = getPopulatedBalanceTypeInstance(journalVoucherForm
085: .getOriginalBalanceType());
086: BalanceTyp newBalType = getPopulatedBalanceTypeInstance(journalVoucherForm
087: .getSelectedBalanceType().getCode());
088:
089: // then deal with external encumbrance changes
090: if (origBalType.isFinBalanceTypeEncumIndicator()
091: && !newBalType.isFinBalanceTypeEncumIndicator()) {
092: balanceTypeExternalEncumbranceChangeMode = EXT_ENCUMB_TO_NON_EXT_ENCUMB;
093: } else if (!origBalType.isFinBalanceTypeEncumIndicator()
094: && newBalType.isFinBalanceTypeEncumIndicator()) {
095: balanceTypeExternalEncumbranceChangeMode = NON_EXT_ENCUMB_TO_EXT_ENCUMB;
096: }
097:
098: return balanceTypeExternalEncumbranceChangeMode;
099: }
100:
101: }
|