1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.gl.batch.service.impl;
17
18 import java.util.HashSet;
19 import java.util.Iterator;
20 import java.util.Set;
21
22 import org.apache.commons.lang.StringUtils;
23 import org.kuali.ole.gl.businessobject.CollectorDetail;
24 import org.kuali.ole.gl.businessobject.OriginEntryFull;
25 import org.kuali.ole.gl.businessobject.Transaction;
26
27
28
29
30 public class DocumentGroupData {
31 protected String documentNumber;
32 protected String financialDocumentTypeCode;
33 protected String financialSystemOriginationCode;
34
35 public DocumentGroupData(Transaction entry) {
36 documentNumber = entry.getDocumentNumber();
37 financialDocumentTypeCode = entry.getFinancialDocumentTypeCode();
38 financialSystemOriginationCode = entry.getFinancialSystemOriginationCode();
39 }
40
41 public DocumentGroupData(String documentNumber, String financialDocumentTypeCode, String financialSystemOriginationCode) {
42 this.documentNumber = documentNumber;
43 this.financialDocumentTypeCode = financialDocumentTypeCode;
44 this.financialSystemOriginationCode = financialSystemOriginationCode;
45 }
46
47
48
49
50
51
52 @Override
53 public boolean equals(Object obj) {
54 if (obj == null || !(obj instanceof DocumentGroupData)) {
55 return false;
56 }
57 DocumentGroupData o2 = (DocumentGroupData) obj;
58 return StringUtils.equals(documentNumber, o2.documentNumber) && StringUtils.equals(financialDocumentTypeCode, o2.financialDocumentTypeCode) && StringUtils.equals(financialSystemOriginationCode, o2.financialSystemOriginationCode);
59 }
60
61
62
63
64
65
66
67 public boolean matchesTransaction(Transaction transaction) {
68 return StringUtils.equals(documentNumber, transaction.getDocumentNumber()) && StringUtils.equals(financialDocumentTypeCode, transaction.getFinancialDocumentTypeCode()) && StringUtils.equals(financialSystemOriginationCode, transaction.getFinancialSystemOriginationCode());
69 }
70
71 public boolean matchesCollectorDetail(CollectorDetail detail) {
72 return StringUtils.equals(documentNumber, detail.getDocumentNumber()) && StringUtils.equals(financialDocumentTypeCode, detail.getFinancialDocumentTypeCode()) && StringUtils.equals(financialSystemOriginationCode, detail.getFinancialSystemOriginationCode());
73 }
74
75
76
77
78
79 @Override
80 public int hashCode() {
81
82 if (documentNumber == null) {
83 return "".hashCode();
84 }
85 return documentNumber.hashCode();
86 }
87
88
89
90
91
92
93 public OriginEntryFull populateDocumentGroupDataFieldsInOriginEntry() {
94 OriginEntryFull entry = new OriginEntryFull();
95 entry.setDocumentNumber(documentNumber);
96 entry.setFinancialDocumentTypeCode(financialDocumentTypeCode);
97 entry.setFinancialSystemOriginationCode(financialSystemOriginationCode);
98 return entry;
99 }
100
101
102
103
104
105
106 public String getDocumentNumber() {
107 return documentNumber;
108 }
109
110
111
112
113
114
115 public void setDocumentNumber(String documentNumber) {
116 this.documentNumber = documentNumber;
117 }
118
119
120
121
122
123
124 public String getFinancialDocumentTypeCode() {
125 return financialDocumentTypeCode;
126 }
127
128
129
130
131
132
133 public void setFinancialDocumentTypeCode(String financialDocumentTypeCode) {
134 this.financialDocumentTypeCode = financialDocumentTypeCode;
135 }
136
137
138
139
140
141
142 public String getFinancialSystemOriginationCode() {
143 return financialSystemOriginationCode;
144 }
145
146
147
148
149
150
151 public void setFinancialSystemOriginationCode(String financialSystemOriginationCode) {
152 this.financialSystemOriginationCode = financialSystemOriginationCode;
153 }
154
155
156
157
158
159
160
161
162 public static <E extends Transaction> Set<DocumentGroupData> getDocumentGroupDatasForTransactions(Iterator<E> transactions) {
163 Set<DocumentGroupData> documentGroupDatas = new HashSet<DocumentGroupData>();
164 while (transactions.hasNext()) {
165 Transaction transaction = transactions.next();
166 documentGroupDatas.add(new DocumentGroupData(transaction));
167 }
168 return documentGroupDatas;
169 }
170 }