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.dataaccess.impl;
017
018 import java.util.HashMap;
019 import java.util.Map;
020
021 import org.apache.ojb.broker.query.Criteria;
022 import org.apache.ojb.broker.query.QueryByCriteria;
023 import org.apache.ojb.broker.query.QueryFactory;
024 import org.kuali.kfs.module.endow.EndowConstants;
025 import org.kuali.kfs.module.endow.EndowPropertyConstants;
026 import org.kuali.kfs.module.endow.businessobject.KemidGeneralLedgerAccount;
027 import org.kuali.kfs.module.endow.dataaccess.KemidGeneralLedgerAccountDao;
028 import org.kuali.kfs.sys.context.SpringContext;
029 import org.kuali.rice.kns.dao.impl.PlatformAwareDaoBaseOjb;
030 import org.kuali.rice.kns.service.DataDictionaryService;
031 import org.kuali.rice.kns.util.ObjectUtils;
032
033 public class KemidGeneralLedgerAccountDaoOjb extends PlatformAwareDaoBaseOjb implements KemidGeneralLedgerAccountDao {
034 protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(KemidGeneralLedgerAccountDaoOjb.class);
035
036 /**
037 * @see KemidGeneralLedgerAccountDao#getChartAndAccountNumber(String, String)
038 */
039 public Map<String, String> getChartAndAccountNumber(String kemid, String incomePrincipalIndicator) {
040 KemidGeneralLedgerAccount kemidGeneralLedgerAccount = null;
041 Map<String, String> chartAndAccountNumber = new HashMap<String, String>();
042
043 Criteria criteria = new Criteria();
044 criteria.addEqualTo(EndowPropertyConstants.TRANSACTION_ARCHIVE_KEM_ID, kemid);
045
046 if (SpringContext.getBean(DataDictionaryService.class).getAttributeForceUppercase(KemidGeneralLedgerAccount.class, EndowPropertyConstants.TRANSACTION_ARCHIVE_INCOME_PRINCIPAL_ID)) {
047 incomePrincipalIndicator = incomePrincipalIndicator.toUpperCase();
048 }
049 criteria.addEqualTo(EndowPropertyConstants.TRANSACTION_ARCHIVE_INCOME_PRINCIPAL_ID, incomePrincipalIndicator);
050 criteria.addEqualTo(EndowPropertyConstants.KEMID_GL_ACCOUNT_ROW_ACTV_IND, EndowConstants.YES);
051
052 QueryByCriteria query = QueryFactory.newQuery(KemidGeneralLedgerAccount.class, criteria);
053 kemidGeneralLedgerAccount = (KemidGeneralLedgerAccount) getPersistenceBrokerTemplate().getObjectByQuery(query);
054
055 if (ObjectUtils.isNotNull(kemidGeneralLedgerAccount)) {
056 chartAndAccountNumber.put(EndowPropertyConstants.KEMID_GL_ACCOUNT_CHART_CD, kemidGeneralLedgerAccount.getChartCode());
057 chartAndAccountNumber.put(EndowPropertyConstants.KEMID_GL_ACCOUNT_NBR, kemidGeneralLedgerAccount.getAccountNumber());
058 }
059
060 return chartAndAccountNumber;
061 }
062 }