01: /*
02: * Copyright 2006-2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.module.gl.web.inquirable;
17:
18: import org.apache.commons.lang.StringUtils;
19: import org.kuali.core.service.KualiConfigurationService;
20: import org.kuali.kfs.KFSConstants;
21: import org.kuali.kfs.context.SpringContext;
22: import org.kuali.module.gl.bo.Encumbrance;
23: import org.kuali.module.gl.bo.Transaction;
24:
25: /**
26: * This class provides a placeholder that can connect General Ledger business object with financial document in the presentation
27: * tier. The typical method is to generate url for the inquirable financial document.
28: */
29: public class InquirableFinancialDocument {
30:
31: private KualiConfigurationService kualiConfigurationService = SpringContext
32: .getBean(KualiConfigurationService.class);
33:
34: /**
35: * get the url of inquirable financial document for the given transaction
36: *
37: * @param transaction the business object that implements Transaction interface
38: * @return the url of inquirable financial document for the given transaction if the document is inquirable; otherwise, return
39: * empty string
40: */
41: public String getInquirableDocumentUrl(Transaction transaction) {
42: if (transaction == null) {
43: return KFSConstants.EMPTY_STRING;
44: }
45:
46: String docNumber = transaction.getDocumentNumber();
47: String originationCode = transaction
48: .getFinancialSystemOriginationCode();
49:
50: return getUrl(originationCode, docNumber);
51: }
52:
53: /**
54: * Creates the url for a document drill down
55: *
56: * @param originCode the originatino code of the document
57: * @param docNumber the document number of the document to drill down on
58: * @return the URL for the drill down
59: */
60: private String getUrl(String originCode, String docNumber) {
61: if (KFSConstants.ORIGIN_CODE_KUALI.equals(originCode)
62: && !StringUtils.isBlank(docNumber)) {
63: return kualiConfigurationService
64: .getPropertyString(KFSConstants.WORKFLOW_URL_KEY)
65: + "/DocHandler.do?docId="
66: + docNumber
67: + "&command=displayDocSearchView";
68: }
69: return KFSConstants.EMPTY_STRING;
70: }
71:
72: /**
73: * get the url of inquirable financial document for the given encumbrance
74: *
75: * @param encumbrance the encumrbance record
76: * @return the url of inquirable financial document for the given encumbrance if the document is inquirable; otherwise, return
77: * empty string
78: */
79: public String getInquirableDocumentUrl(Encumbrance encumbrance) {
80: if (encumbrance == null) {
81: return KFSConstants.EMPTY_STRING;
82: }
83:
84: String docNumber = encumbrance.getDocumentNumber();
85: String originationCode = encumbrance.getOriginCode();
86:
87: return getUrl(originationCode, docNumber);
88: }
89: }
|