001: /*
002: * Copyright 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.service.impl;
017:
018: import java.util.HashMap;
019: import java.util.Iterator;
020: import java.util.Map;
021:
022: import org.kuali.kfs.KFSPropertyConstants;
023: import org.kuali.module.gl.bo.OriginEntryGroup;
024: import org.kuali.module.gl.bo.OriginEntryLite;
025: import org.kuali.module.gl.dao.OriginEntryDao;
026: import org.kuali.module.gl.service.OriginEntryLiteService;
027: import org.springframework.transaction.annotation.Transactional;
028:
029: /**
030: * The base implementation of OriginEntryLiteService
031: */
032: @Transactional
033: public class OriginEntryLiteServiceImpl implements
034: OriginEntryLiteService {
035: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
036: .getLogger(OriginEntryLiteServiceImpl.class);
037:
038: private OriginEntryDao originEntryDao;
039:
040: private static final String ENTRY_GROUP_ID = "entryGroupId";
041: private static final String FINANCIAL_DOCUMENT_TYPE_CODE = "financialDocumentTypeCode";
042: private static final String FINANCIAL_SYSTEM_ORIGINATION_CODE = "financialSystemOriginationCode";
043:
044: /**
045: * Return all the entries for a specific document in a specific group
046: *
047: * @param oeg the origin entry group to find entries in
048: * @param documentNumber the document number of origin entries to return
049: * @param documentTypeCode the document type code of origin entries to return
050: * @param originCode the origination code to return
051: * @return iterator to all qualifying entries
052: * @see org.kuali.module.gl.service.OriginEntryLiteService#getEntriesByDocument(org.kuali.module.gl.bo.OriginEntryGroup, java.lang.String, java.lang.String, java.lang.String)
053: */
054: public Iterator<OriginEntryLite> getEntriesByDocument(
055: OriginEntryGroup originEntryGroup, String documentNumber,
056: String documentTypeCode, String originCode) {
057: LOG.debug("getEntriesByDocument() started");
058:
059: Map criteria = new HashMap();
060: criteria.put(ENTRY_GROUP_ID, originEntryGroup.getId());
061: criteria.put(KFSPropertyConstants.DOCUMENT_NUMBER,
062: documentNumber);
063: criteria.put(FINANCIAL_DOCUMENT_TYPE_CODE, documentTypeCode);
064: criteria.put(FINANCIAL_SYSTEM_ORIGINATION_CODE, originCode);
065:
066: return originEntryDao.getMatchingEntries(criteria);
067: }
068:
069: /**
070: * Return all the entries in a specific group
071: *
072: * @param oeg Group used to select entries
073: * @return Iterator to all the entires
074: * @see org.kuali.module.gl.service.OriginEntryLiteService#getEntriesByGroup(org.kuali.module.gl.bo.OriginEntryGroup)
075: */
076: public Iterator<OriginEntryLite> getEntriesByGroup(
077: OriginEntryGroup originEntryGroup) {
078: LOG.debug("getEntriesByGroup() started");
079:
080: return originEntryDao.getEntriesByGroup(originEntryGroup,
081: OriginEntryDao.SORT_DOCUMENT);
082: }
083:
084: /**
085: * Gets the originEntryDao attribute.
086: *
087: * @return Returns the originEntryDao.
088: */
089: public OriginEntryDao getOriginEntryDao() {
090: return originEntryDao;
091: }
092:
093: /**
094: * Sets the originEntryDao attribute value.
095: *
096: * @param originEntryDao The originEntryDao to set.
097: */
098: public void setOriginEntryDao(OriginEntryDao originEntryDao) {
099: this .originEntryDao = originEntryDao;
100: }
101:
102: /**
103: * Saves an origin entry to the persistence store, defers to the DAO
104: * @param entry the origin entry lite to save
105: * @see org.kuali.module.gl.service.OriginEntryLiteService#save(org.kuali.module.gl.bo.OriginEntryLite)
106: */
107: public void save(OriginEntryLite entry) {
108: LOG.debug("save() started");
109: originEntryDao.saveOriginEntry(entry);
110: }
111:
112: /**
113: * Deletes an origin entry from the persistence store, defers to the DAO
114: * @param entry the origin entry lite to delete
115: * @see org.kuali.module.gl.service.OriginEntryLiteService#delete(org.kuali.module.gl.bo.OriginEntryLite)
116: */
117: public void delete(OriginEntryLite entry) {
118: LOG.debug("delete() started");
119: originEntryDao.deleteEntry(entry);
120: }
121: }
|