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.purap.dataaccess.impl; 017 018 import java.util.List; 019 020 import org.apache.ojb.broker.query.Criteria; 021 import org.apache.ojb.broker.query.QueryByCriteria; 022 import org.kuali.kfs.module.purap.businessobject.ElectronicInvoiceItemMapping; 023 import org.kuali.kfs.module.purap.businessobject.ItemType; 024 import org.kuali.kfs.module.purap.dataaccess.ElectronicInvoiceItemMappingDao; 025 import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport; 026 027 public class ElectronicInvoiceItemMappingDaoOjb extends PersistenceBrokerDaoSupport implements 028 ElectronicInvoiceItemMappingDao { 029 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ElectronicInvoiceItemMappingDaoOjb.class); 030 031 /** 032 * Save an ElectronicInvoiceItemMapping. 033 * 034 * @param row ElectronicInvoiceItemMapping to save 035 */ 036 public void save(ElectronicInvoiceItemMapping row) { 037 LOG.debug("save() started"); 038 getPersistenceBrokerTemplate().store(row); 039 } 040 041 /** 042 * Get list of all ElectronicInvoiceItemMappings 043 */ 044 public List getAll() { 045 LOG.debug("getAll() started"); 046 QueryByCriteria qbc = new QueryByCriteria(ElectronicInvoiceItemMapping.class); 047 qbc.addOrderBy("id", true); 048 List l = (List) getPersistenceBrokerTemplate().getCollectionByQuery(qbc); 049 return l; 050 } 051 052 public ElectronicInvoiceItemMapping getByUniqueKeys(Integer headerId, Integer detailId, String invoiceTypeCode) { 053 LOG.debug("getByUniqueKeys() started"); 054 Criteria criteria = new Criteria(); 055 criteria.addEqualTo("vendorHeaderGeneratedId", headerId); 056 criteria.addEqualTo("vendorDetailAssignedId", detailId); 057 criteria.addEqualTo("electronicInvoiceItemTypeCode", invoiceTypeCode); 058 QueryByCriteria qbc = new QueryByCriteria(ElectronicInvoiceItemMapping.class,criteria); 059 return (ElectronicInvoiceItemMapping)getPersistenceBrokerTemplate().getObjectByQuery(qbc); 060 } 061 062 public List getAllItemTypes() { 063 LOG.debug("getAllItemTypes() started"); 064 065 Criteria criteria = new Criteria(); 066 criteria.addEqualTo("active",Boolean.TRUE); 067 068 QueryByCriteria qbc = new QueryByCriteria(ItemType.class,criteria); 069 qbc.addOrderByAscending("code"); 070 071 return (List)getPersistenceBrokerTemplate().getCollectionByQuery(qbc); 072 } 073 074 public ItemType getItemTypeByCode(String code) { 075 LOG.debug("getItemTypeByCode() started"); 076 Criteria criteria = new Criteria(); 077 criteria.addEqualTo("code", code); 078 QueryByCriteria qbc = new QueryByCriteria(ItemType.class,criteria); 079 return (ItemType)getPersistenceBrokerTemplate().getObjectByQuery(qbc); 080 } 081 /** 082 * Get an ElectronicInvoiceItemMapping by primary key. 083 * 084 * @param id the id to lookup 085 */ 086 public ElectronicInvoiceItemMapping getById(String id) { 087 LOG.debug("getById() started"); 088 Criteria crit = new Criteria(); 089 crit.addEqualTo("id", id); 090 ElectronicInvoiceItemMapping row = (ElectronicInvoiceItemMapping) getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(ElectronicInvoiceItemMapping.class, crit)); 091 return row; 092 } 093 094 /** 095 * Delete a ElectronicInvoiceItemMapping. 096 * 097 * @param row 098 */ 099 public void delete(ElectronicInvoiceItemMapping row) { 100 LOG.debug("delete() started"); 101 getPersistenceBrokerTemplate().delete(row); 102 } 103 104 } 105 /* 106 * Copyright 2007 The Kuali Foundation. 107 * 108 * Licensed under the Educational Community License, Version 1.0 (the "License"); 109 * you may not use this file except in compliance with the License. 110 * You may obtain a copy of the License at 111 * 112 * http://www.opensource.org/licenses/ecl1.php 113 * 114 * Unless required by applicable law or agreed to in writing, software 115 * distributed under the License is distributed on an "AS IS" BASIS, 116 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 117 * See the License for the specific language governing permissions and 118 * limitations under the License. 119 */