1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.gl.businessobject;
17
18 import java.util.Comparator;
19
20 import org.apache.commons.lang.StringUtils;
21 import org.kuali.ole.sys.OLEPropertyConstants;
22
23
24
25
26 public class LedgerSummaryDetailLine extends LedgerBalanceTypeSummaryTotalLine {
27 private String financialSystemOriginationCode;
28 private Integer universityFiscalYear;
29 private String universityAccountPeriodCode;
30
31
32
33
34
35
36
37
38
39 public LedgerSummaryDetailLine(String balanceTypeCode, String financialSystemOriginationCode, Integer universityFiscalYear, String universityAccountPeriodCode) {
40 super(balanceTypeCode);
41 this.financialSystemOriginationCode = financialSystemOriginationCode;
42 this.universityFiscalYear = universityFiscalYear;
43 this.universityAccountPeriodCode = universityAccountPeriodCode;
44 }
45
46
47
48
49
50
51 public String getFinancialSystemOriginationCode() {
52 return financialSystemOriginationCode;
53 }
54
55
56
57
58
59
60 public Integer getUniversityFiscalYear() {
61 return universityFiscalYear;
62 }
63
64
65
66
67
68
69 public String getUniversityAccountPeriodCode() {
70 return universityAccountPeriodCode;
71 }
72
73
74
75
76 public String getKey() {
77 return LedgerSummaryDetailLine.makeKey(this.getFinancialBalanceTypeCode(), this.getFinancialSystemOriginationCode(), this.getUniversityFiscalYear(), this.getUniversityAccountPeriodCode());
78 }
79
80
81
82
83
84
85
86 public static String getKeyString(OriginEntryInformation entry) {
87 return LedgerSummaryDetailLine.makeKey(entry.getFinancialBalanceTypeCode(), entry.getFinancialSystemOriginationCode(), entry.getUniversityFiscalYear(), entry.getUniversityFiscalPeriodCode());
88 }
89
90
91
92
93
94
95
96
97
98
99 private static String makeKey(String balanceTypeCode, String financialSystemOriginationCode, Integer universityFiscalYear, String universityAccountingPeriodCode) {
100 return StringUtils.join(new String[] { balanceTypeCode, financialSystemOriginationCode, universityFiscalYear == null ? "" : universityFiscalYear.toString(), universityAccountingPeriodCode }, ':');
101 }
102
103
104
105
106 public static Comparator<LedgerSummaryDetailLine> getStandardComparator() {
107 return new Comparator<LedgerSummaryDetailLine>() {
108
109
110
111
112
113
114
115
116 public int compare(LedgerSummaryDetailLine detail1, LedgerSummaryDetailLine detail2) {
117 int comp = 0;
118 comp = nullSafeCompare(detail1.getFinancialBalanceTypeCode(), detail2.getFinancialBalanceTypeCode());
119
120 if (comp == 0) {
121 comp = nullSafeCompare(detail1.getFinancialSystemOriginationCode(), detail2.getFinancialSystemOriginationCode());
122 }
123
124 if (comp == 0) {
125 comp = nullSafeCompare(detail1.getUniversityFiscalYear(), detail2.getUniversityFiscalYear());
126 }
127
128 if (comp == 0) {
129 comp = nullSafeCompare(detail1.getUniversityAccountPeriodCode(), detail2.getUniversityAccountPeriodCode());
130 }
131
132 return comp;
133 }
134
135
136
137
138
139
140
141
142
143 protected int nullSafeCompare(Comparable o1, Comparable o2) {
144 if (o1 == null && o2 != null) {
145 return -1;
146 }
147
148 if (o1 != null && o2 == null) {
149 return 1;
150 }
151
152 if (o1 == null && o2 == null) {
153 return 0;
154 }
155
156 return o1.compareTo(o2);
157 }
158 };
159 }
160
161 public static String[] keyFields = new String[] { OLEPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE, OLEPropertyConstants.FINANCIAL_SYSTEM_ORIGINATION_CODE, OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR, "universityAccountPeriodCode" };
162
163 }