001 /*
002 * Copyright 2011 The Kuali Foundation.
003 *
004 * Licensed under the Educational Community License, Version 2.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/ecl2.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.kfs.module.endow.document.service.impl;
017
018 import java.util.ArrayList;
019 import java.util.Collection;
020 import java.util.HashMap;
021 import java.util.Map;
022
023 import org.apache.commons.lang.StringUtils;
024 import org.kuali.kfs.module.endow.EndowPropertyConstants;
025 import org.kuali.kfs.module.endow.businessobject.KemidFee;
026 import org.kuali.kfs.module.endow.businessobject.TransactionArchive;
027 import org.kuali.kfs.module.endow.document.service.TransactionArchiveService;
028 import org.kuali.kfs.sys.context.SpringContext;
029 import org.kuali.rice.kns.service.BusinessObjectService;
030 import org.kuali.rice.kns.service.DataDictionaryService;
031 import org.kuali.rice.kns.service.DateTimeService;
032
033 /**
034 * This class is the dao implementation for the TransactionArchiveServiceImpl.
035 */
036 public class TransactionArchiveServiceImpl implements TransactionArchiveService {
037
038 private BusinessObjectService businessObjectService;
039
040 /**
041 * @see org.kuali.kfs.module.endow.document.service.TransactionArchiveService#getAllTransactionArchives()
042 */
043 public Collection<TransactionArchive> getAllTransactionArchives() {
044 Collection<TransactionArchive> transactionArchives = new ArrayList();
045
046 transactionArchives = businessObjectService.findAll(TransactionArchive.class);
047
048 return transactionArchives;
049 }
050
051 /**
052 * @see org.kuali.kfs.module.endow.document.service.TransactionArchiveService#getByPrimaryKey(String, int, String)
053 */
054 public TransactionArchive getByPrimaryKey(String documentNumber, int lineNumber, String lineTypeCode) {
055 TransactionArchive transactionArchive = null;
056
057 Map primaryKeys = new HashMap();
058 primaryKeys.put(EndowPropertyConstants.TRANSACTION_ARCHIVE_DOCUMENT_NUMBER, documentNumber);
059 primaryKeys.put(EndowPropertyConstants.TRANSACTION_ARCHIVE_LINE_NUMBER, lineNumber);
060 primaryKeys.put(EndowPropertyConstants.TRANSACTION_ARCHIVE_LINE_TYPE_CODE, lineTypeCode);
061
062 transactionArchive = (TransactionArchive) businessObjectService.findByPrimaryKey(TransactionArchive.class, primaryKeys);
063
064 return transactionArchive;
065 }
066
067 /**
068 * @see org.kuali.kfs.module.endow.document.service.TransactionArchiveService#getTransactionArchivesByDocumentTypeName(String)
069 */
070 public Collection<TransactionArchive> getTransactionArchivesByDocumentTypeName(String typeCode) {
071 Collection<TransactionArchive> transactionArchives = new ArrayList();
072
073 if (StringUtils.isNotBlank(typeCode)) {
074 Map<String, String> criteria = new HashMap<String, String>();
075
076 if (SpringContext.getBean(DataDictionaryService.class).getAttributeForceUppercase(TransactionArchive.class, EndowPropertyConstants.TRANSACTION_ARCHIVE_TYPE_CODE)) {
077 typeCode = typeCode.toUpperCase();
078 }
079
080 criteria.put(EndowPropertyConstants.TRANSACTION_ARCHIVE_TYPE_CODE, typeCode);
081 transactionArchives = businessObjectService.findMatching(TransactionArchive.class, criteria);
082 }
083
084 return transactionArchives;
085 }
086
087 /**
088 * @see org.kuali.kfs.module.endow.document.service.TransactionArchiveService#getTransactionArchivesByETranCode(String)
089 */
090 public Collection<TransactionArchive> getTransactionArchivesByETranCode(String etranCode) {
091 Collection<TransactionArchive> transactionArchives = new ArrayList();
092
093 if (StringUtils.isNotBlank(etranCode)) {
094 Map<String, String> criteria = new HashMap<String, String>();
095
096 if (SpringContext.getBean(DataDictionaryService.class).getAttributeForceUppercase(TransactionArchive.class, EndowPropertyConstants.TRANSACTION_ARCHIVE_ETRAN_CODE)) {
097 etranCode = etranCode.toUpperCase();
098 }
099
100 criteria.put(EndowPropertyConstants.TRANSACTION_ARCHIVE_ETRAN_CODE, etranCode);
101 transactionArchives = businessObjectService.findMatching(TransactionArchive.class, criteria);
102 }
103
104 return transactionArchives;
105 }
106
107 /**
108 * @see org.kuali.kfs.module.endow.document.service.TransactionArchiveService#getTransactionArchivesByDocumentTypeNameAndETranCode(String, String)
109 */
110 public Collection<TransactionArchive> getTransactionArchivesByDocumentTypeNameAndETranCode(String typeCode, String etranCode) {
111 Collection<TransactionArchive> transactionArchives = new ArrayList();
112
113 if (StringUtils.isNotBlank(etranCode) && StringUtils.isNotBlank(typeCode)) {
114 Map<String, String> criteria = new HashMap<String, String>();
115
116 if (SpringContext.getBean(DataDictionaryService.class).getAttributeForceUppercase(TransactionArchive.class, EndowPropertyConstants.TRANSACTION_ARCHIVE_TYPE_CODE)) {
117 typeCode = typeCode.toUpperCase();
118 }
119
120 if (SpringContext.getBean(DataDictionaryService.class).getAttributeForceUppercase(TransactionArchive.class, EndowPropertyConstants.TRANSACTION_ARCHIVE_ETRAN_CODE)) {
121 etranCode = etranCode.toUpperCase();
122 }
123
124 criteria.put(EndowPropertyConstants.TRANSACTION_ARCHIVE_TYPE_CODE, typeCode);
125 criteria.put(EndowPropertyConstants.TRANSACTION_ARCHIVE_ETRAN_CODE, etranCode);
126
127 transactionArchives = businessObjectService.findMatching(TransactionArchive.class, criteria);
128 }
129
130 return transactionArchives;
131 }
132
133 /**
134 * @see org.kuali.kfs.module.endow.document.service.TransactionArchiveService#getTransactionArchivesByIncomeOrPrincipalIndicator(String)
135 */
136 public Collection<TransactionArchive> getTransactionArchivesByIncomeOrPrincipalIndicator(String incomeOrPrincipalIndicator) {
137 Collection<TransactionArchive> transactionArchives = new ArrayList();
138
139 if (StringUtils.isNotBlank(incomeOrPrincipalIndicator)) {
140 Map<String, String> criteria = new HashMap<String, String>();
141
142 if (SpringContext.getBean(DataDictionaryService.class).getAttributeForceUppercase(TransactionArchive.class, EndowPropertyConstants.TRANSACTION_ARCHIVE_INCOME_PRINCIPAL_INDICATOR)) {
143 incomeOrPrincipalIndicator = incomeOrPrincipalIndicator.toUpperCase();
144 }
145
146 criteria.put(EndowPropertyConstants.TRANSACTION_ARCHIVE_INCOME_PRINCIPAL_INDICATOR, incomeOrPrincipalIndicator);
147
148 transactionArchives = businessObjectService.findMatching(TransactionArchive.class, criteria);
149 }
150
151 return transactionArchives;
152 }
153
154 /**
155 * @see org.kuali.kfs.module.endow.document.service.TransactionArchiveService#getAllTransactionArchives(String, String, String)
156 */
157 public Collection<TransactionArchive> getAllTransactionArchives(String typeCode, String etranCode) {
158 Collection<TransactionArchive> transactionArchives = new ArrayList();
159
160 transactionArchives = getTransactionArchivesByDocumentTypeNameAndETranCode(typeCode, etranCode);
161
162 return transactionArchives;
163 }
164
165 /**
166 * This method gets the businessObjectService.
167 *
168 * @return businessObjectService
169 */
170 public BusinessObjectService getBusinessObjectService() {
171 return businessObjectService;
172 }
173
174 /**
175 * This method sets the businessObjectService
176 *
177 * @param businessObjectService
178 */
179 public void setBusinessObjectService(BusinessObjectService businessObjectService) {
180 this.businessObjectService = businessObjectService;
181 }
182 }