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.gl.util;
017:
018: import java.util.Arrays;
019:
020: import org.kuali.core.service.DocumentTypeService;
021: import org.kuali.kfs.context.SpringContext;
022: import org.kuali.module.chart.service.BalanceTypService;
023: import org.kuali.module.gl.bo.OriginEntryFull;
024:
025: /**
026: * This class represents an origin entry key
027: */
028: public class OriginEntryKey {
029: static BalanceTypService balanceTypService = (BalanceTypService) SpringContext
030: .getBean(BalanceTypService.class);
031: static DocumentTypeService documentTypeService = (DocumentTypeService) SpringContext
032: .getBean(DocumentTypeService.class);
033:
034: /*
035: * (non-Javadoc)
036: *
037: * @see java.lang.Object#equals(java.lang.Object)
038: */
039: public boolean equals(Object obj) {
040: if (!(obj instanceof OriginEntryKey) || null == obj) {
041: return false;
042: }
043:
044: OriginEntryKey key = (OriginEntryKey) obj;
045: return ObjectHelper.isEqual(getAccountNumber(), key
046: .getAccountNumber())
047: && ObjectHelper.isEqual(getBalanceTypeCode(), key
048: .getBalanceTypeCode())
049: && ObjectHelper.isEqual(getChartCode(), key
050: .getChartCode())
051: && ObjectHelper.isEqual(getDocumentTypeCode(), key
052: .getDocumentTypeCode())
053: && ObjectHelper.isEqual(getEntrySequenceNumber(), key
054: .getEntrySequenceNumber())
055: && ObjectHelper.isEqual(getDocumentNumber(), key
056: .getDocumentNumber())
057: && ObjectHelper.isEqual(getFinancialObjectCode(), key
058: .getFinancialObjectCode())
059: && ObjectHelper.isEqual(getFiscalPeriodCode(), key
060: .getFiscalPeriodCode())
061: && ObjectHelper.isEqual(getFiscalYear(), key
062: .getFiscalYear())
063: && ObjectHelper.isEqual(getObjectTypeCode(), key
064: .getObjectTypeCode())
065: && ObjectHelper.isEqual(getSubAccountNumber(), key
066: .getSubAccountNumber())
067: && ObjectHelper.isEqual(getSubObjectCode(), key
068: .getSubObjectCode())
069: && ObjectHelper.isEqual(getSystemOriginationCode(), key
070: .getSystemOriginationCode());
071: }
072:
073: /**
074: * @param entry
075: * @return
076: */
077: static public OriginEntryKey buildFromOriginEntry(
078: OriginEntryFull entry) {
079: if (null == entry) {
080: return null;
081: }
082:
083: OriginEntryKey key = new OriginEntryKey();
084: key.setAccountNumber(entry.getAccountNumber());
085: key.setBalanceTypeCode(entry.getFinancialBalanceTypeCode());
086: key.setChartCode(entry.getChartOfAccountsCode());
087: key.setDocumentTypeCode(entry.getFinancialDocumentTypeCode());
088: key.setEntrySequenceNumber(entry
089: .getTransactionLedgerEntrySequenceNumber().toString());
090: key.setDocumentNumber(entry.getDocumentNumber());
091: key.setFinancialObjectCode(entry.getFinancialObjectCode());
092: key.setFiscalPeriodCode(entry.getUniversityFiscalPeriodCode());
093: key.setFiscalYear(entry.getUniversityFiscalYear().toString());
094: key.setObjectTypeCode(entry.getFinancialObjectTypeCode());
095: key.setSubAccountNumber(entry.getSubAccountNumber());
096: key.setSubObjectCode(entry.getFinancialSubObjectCode());
097: key.setSystemOriginationCode(entry
098: .getFinancialSystemOriginationCode());
099: return key;
100: }
101:
102: /**
103: * @param entry
104: */
105: public void setIntoOriginEntry(OriginEntryFull entry) {
106: entry.setAccountNumber(getAccountNumber());
107: entry.setBalanceType(balanceTypService
108: .getBalanceTypByCode(getBalanceTypeCode()));
109: entry.setChartOfAccountsCode(getChartCode());
110: entry.setDocumentType(documentTypeService
111: .getDocumentTypeByCode(getDocumentTypeCode()));
112: entry.setTransactionLedgerEntrySequenceNumber(new Integer(
113: getEntrySequenceNumber()));
114: entry.setDocumentNumber(getDocumentNumber());
115: entry.setFinancialObjectCode(getFinancialObjectCode());
116: entry.setUniversityFiscalPeriodCode(getFiscalPeriodCode());
117: entry.setUniversityFiscalYear(new Integer(getFiscalYear()));
118: entry.setFinancialObjectTypeCode(getObjectTypeCode());
119: entry.setSubAccountNumber(getSubAccountNumber());
120: entry.setFinancialSubObjectCode(getSubObjectCode());
121: entry
122: .setFinancialSystemOriginationCode(getSystemOriginationCode());
123: }
124:
125: /**
126: * @return Returns the accountNumber.
127: */
128: public String getAccountNumber() {
129: return new String(accountNumber);
130: }
131:
132: /**
133: * @param accountNumber The accountNumber to set.
134: */
135: public void setAccountNumber(String accountNumber) {
136: if (null != accountNumber) {
137: System.arraycopy(accountNumber.toCharArray(), 0,
138: this .accountNumber, 0, this .accountNumber.length);
139: } else {
140: Arrays.fill(this .accountNumber, (char) 0);
141: }
142: }
143:
144: /**
145: * @return Returns the balanceTypeCode.
146: */
147: public String getBalanceTypeCode() {
148: return new String(balanceTypeCode);
149: }
150:
151: /**
152: * @param balanceTypeCode The balanceTypeCode to set.
153: */
154: public void setBalanceTypeCode(String balanceTypeCode) {
155: if (null != balanceTypeCode) {
156: System.arraycopy(balanceTypeCode.toCharArray(), 0,
157: this .balanceTypeCode, 0,
158: this .balanceTypeCode.length);
159: } else {
160: Arrays.fill(this .balanceTypeCode, (char) 0);
161: }
162: }
163:
164: /**
165: * @return Returns the chartCode.
166: */
167: public String getChartCode() {
168: return new String(chartCode);
169: }
170:
171: /**
172: * @param chartCode The chartCode to set.
173: */
174: public void setChartCode(String chartCode) {
175: if (null != chartCode) {
176: System.arraycopy(chartCode, 0, this .chartCode, 0,
177: this .chartCode.length);
178: } else {
179: Arrays.fill(this .chartCode, (char) 0);
180: }
181: }
182:
183: /**
184: * @return Returns the documentTypeCode.
185: */
186: public String getDocumentTypeCode() {
187: return new String(documentTypeCode);
188: }
189:
190: /**
191: * @param documentTypeCode The documentTypeCode to set.
192: */
193: public void setDocumentTypeCode(String documentTypeCode) {
194: if (null != documentTypeCode) {
195: System.arraycopy(documentTypeCode.toCharArray(), 0,
196: this .documentTypeCode, 0,
197: this .documentTypeCode.length);
198: } else {
199: Arrays.fill(this .documentTypeCode, (char) 0);
200: }
201: }
202:
203: /**
204: * @return Returns the entrySequenceNumber.
205: */
206: public String getEntrySequenceNumber() {
207: return new String(entrySequenceNumber);
208: }
209:
210: /**
211: * @param entrySequenceNumber The entrySequenceNumber to set.
212: */
213: public void setEntrySequenceNumber(String entrySequenceNumber) {
214: if (null != entrySequenceNumber) {
215: System.arraycopy(entrySequenceNumber, 0,
216: this .entrySequenceNumber, 0,
217: this .entrySequenceNumber.length);
218: } else {
219: Arrays.fill(this .entrySequenceNumber, (char) 0);
220: }
221: }
222:
223: /**
224: * @return Returns the documentNumber.
225: */
226: public String getDocumentNumber() {
227: return new String(documentNumber);
228: }
229:
230: /**
231: * @param documentNumber The documentNumber to set.
232: */
233: public void setDocumentNumber(String documentNumber) {
234: if (null != documentNumber) {
235: System.arraycopy(documentNumber, 0, this .documentNumber, 0,
236: this .documentNumber.length);
237: } else {
238: Arrays.fill(this .documentNumber, (char) 0);
239: }
240: }
241:
242: /**
243: * @return Returns the financialObjectCode.
244: */
245: public String getFinancialObjectCode() {
246: return new String(financialObjectCode);
247: }
248:
249: /**
250: * @param financialObjectCode The financialObjectCode to set.
251: */
252: public void setFinancialObjectCode(String financialObjectCode) {
253: if (null != financialObjectCode) {
254: System.arraycopy(financialObjectCode, 0,
255: this .financialObjectCode, 0,
256: this .financialObjectCode.length);
257: } else {
258: Arrays.fill(this .financialObjectCode, (char) 0);
259: }
260: }
261:
262: /**
263: * @return Returns the fiscalPeriodCode.
264: */
265: public String getFiscalPeriodCode() {
266: return new String(fiscalPeriodCode);
267: }
268:
269: /**
270: * @param fiscalPeriodCode The fiscalPeriodCode to set.
271: */
272: public void setFiscalPeriodCode(String fiscalPeriodCode) {
273: if (null != fiscalPeriodCode) {
274: System.arraycopy(fiscalPeriodCode, 0,
275: this .fiscalPeriodCode, 0,
276: this .fiscalPeriodCode.length);
277: } else {
278: Arrays.fill(this .fiscalPeriodCode, (char) 0);
279: }
280: }
281:
282: /**
283: * @return Returns the fiscalYear.
284: */
285: public String getFiscalYear() {
286: return new String(fiscalYear);
287: }
288:
289: /**
290: * @param fiscalYear The fiscalYear to set.
291: */
292: public void setFiscalYear(String fiscalYear) {
293: if (null != fiscalYear) {
294: System.arraycopy(fiscalYear, 0, this .fiscalYear, 0,
295: this .fiscalYear.length);
296: } else {
297: Arrays.fill(this .fiscalYear, (char) 0);
298: }
299: }
300:
301: /**
302: * @return Returns the objectTypeCode.
303: */
304: public String getObjectTypeCode() {
305: return new String(objectTypeCode);
306: }
307:
308: /**
309: * @param objectTypeCode The objectTypeCode to set.
310: */
311: public void setObjectTypeCode(String objectTypeCode) {
312: if (null != objectTypeCode) {
313: System.arraycopy(objectTypeCode, 0, this .objectTypeCode, 0,
314: this .objectTypeCode.length);
315: } else {
316: Arrays.fill(this .objectTypeCode, (char) 0);
317: }
318: }
319:
320: /**
321: * @return Returns the subAccountNumber.
322: */
323: public String getSubAccountNumber() {
324: return new String(subAccountNumber);
325: }
326:
327: /**
328: * @param subAccountNumber The subAccountNumber to set.
329: */
330: public void setSubAccountNumber(String subAccountNumber) {
331: if (null != subAccountNumber) {
332: System.arraycopy(subAccountNumber, 0,
333: this .subAccountNumber, 0,
334: this .subAccountNumber.length);
335: } else {
336: Arrays.fill(this .subAccountNumber, (char) 0);
337: }
338: }
339:
340: /**
341: * @return Returns the subObjectCode.
342: */
343: public String getSubObjectCode() {
344: return new String(subObjectCode);
345: }
346:
347: /**
348: * @param subObjectCode The subObjectCode to set.
349: */
350: public void setSubObjectCode(String subObjectCode) {
351: if (null != subObjectCode) {
352: System.arraycopy(subObjectCode, 0, this .subObjectCode, 0,
353: this .subObjectCode.length);
354: } else {
355: Arrays.fill(this .subObjectCode, (char) 0);
356: }
357: }
358:
359: /**
360: * @return Returns the systemOriginationCode.
361: */
362: public String getSystemOriginationCode() {
363: return new String(systemOriginationCode);
364: }
365:
366: /**
367: * @param systemOriginationCode The systemOriginationCode to set.
368: */
369: public void setSystemOriginationCode(String systemOriginationCode) {
370: if (null != systemOriginationCode) {
371: System.arraycopy(systemOriginationCode.toCharArray(), 0,
372: this .systemOriginationCode, 0,
373: this .systemOriginationCode.length);
374: } else {
375: Arrays.fill(this .systemOriginationCode, (char) 0);
376: }
377: }
378:
379: public OriginEntryKey() {
380: super ();
381: }
382:
383: final private char[] fiscalYear = new char[4];
384:
385: final private char[] chartCode = new char[2];
386:
387: final private char[] accountNumber = new char[7];
388:
389: final private char[] subAccountNumber = new char[5];
390:
391: final private char[] financialObjectCode = new char[4];
392:
393: final private char[] subObjectCode = new char[3];
394:
395: final private char[] balanceTypeCode = new char[2];
396:
397: final private char[] objectTypeCode = new char[2];
398:
399: final private char[] fiscalPeriodCode = new char[2];
400:
401: final private char[] documentTypeCode = new char[4];
402:
403: final private char[] systemOriginationCode = new char[2];
404:
405: final private char[] documentNumber = new char[9];
406:
407: final private char[] entrySequenceNumber = new char[5];
408: }
|