View Javadoc
1   /*
2    * Copyright 2008-2009 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.module.purap.dataaccess.impl;
17  
18  import org.apache.ojb.broker.query.Criteria;
19  import org.apache.ojb.broker.query.QueryByCriteria;
20  import org.kuali.ole.module.purap.businessobject.ElectronicInvoiceItemMapping;
21  import org.kuali.ole.module.purap.businessobject.ItemType;
22  import org.kuali.ole.module.purap.dataaccess.ElectronicInvoiceItemMappingDao;
23  import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport;
24  
25  import java.util.List;
26  
27  public class ElectronicInvoiceItemMappingDaoOjb extends PersistenceBrokerDaoSupport implements
28          ElectronicInvoiceItemMappingDao {
29      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ElectronicInvoiceItemMappingDaoOjb.class);
30  
31      /**
32       * Get list of all ElectronicInvoiceItemMappings
33       */
34      public List getAll() {
35          LOG.debug("getAll() started");
36          QueryByCriteria qbc = new QueryByCriteria(ElectronicInvoiceItemMapping.class);
37          qbc.addOrderBy("id", true);
38          List l = (List) getPersistenceBrokerTemplate().getCollectionByQuery(qbc);
39          return l;
40      }
41  
42      public ElectronicInvoiceItemMapping getByUniqueKeys(Integer headerId, Integer detailId, String invoiceTypeCode) {
43          LOG.debug("getByUniqueKeys() started");
44          Criteria criteria = new Criteria();
45          criteria.addEqualTo("vendorHeaderGeneratedId", headerId);
46          criteria.addEqualTo("vendorDetailAssignedId", detailId);
47          criteria.addEqualTo("electronicInvoiceItemTypeCode", invoiceTypeCode);
48          QueryByCriteria qbc = new QueryByCriteria(ElectronicInvoiceItemMapping.class, criteria);
49          return (ElectronicInvoiceItemMapping) getPersistenceBrokerTemplate().getObjectByQuery(qbc);
50      }
51  
52      public List getAllItemTypes() {
53          LOG.debug("getAllItemTypes() started");
54  
55          Criteria criteria = new Criteria();
56          criteria.addEqualTo("active", Boolean.TRUE);
57  
58          QueryByCriteria qbc = new QueryByCriteria(ItemType.class, criteria);
59          qbc.addOrderByAscending("code");
60  
61          return (List) getPersistenceBrokerTemplate().getCollectionByQuery(qbc);
62      }
63  
64      public ItemType getItemTypeByCode(String code) {
65          LOG.debug("getItemTypeByCode() started");
66          Criteria criteria = new Criteria();
67          criteria.addEqualTo("code", code);
68          QueryByCriteria qbc = new QueryByCriteria(ItemType.class, criteria);
69          return (ItemType) getPersistenceBrokerTemplate().getObjectByQuery(qbc);
70      }
71  
72      /**
73       * Get an ElectronicInvoiceItemMapping by primary key.
74       *
75       * @param id the id to lookup
76       */
77      public ElectronicInvoiceItemMapping getById(String id) {
78          LOG.debug("getById() started");
79          Criteria crit = new Criteria();
80          crit.addEqualTo("id", id);
81          ElectronicInvoiceItemMapping row = (ElectronicInvoiceItemMapping) getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(ElectronicInvoiceItemMapping.class, crit));
82          return row;
83      }
84  
85      /**
86       * Delete a ElectronicInvoiceItemMapping.
87       *
88       * @param row
89       */
90      public void delete(ElectronicInvoiceItemMapping row) {
91          LOG.debug("delete() started");
92          getPersistenceBrokerTemplate().delete(row);
93      }
94  
95  }
96  /*
97   * Copyright 2007 The Kuali Foundation.
98   * 
99   * Licensed under the Educational Community License, Version 1.0 (the "License");
100  * you may not use this file except in compliance with the License.
101  * You may obtain a copy of the License at
102  * 
103  * http://www.opensource.org/licenses/ecl1.php
104  * 
105  * Unless required by applicable law or agreed to in writing, software
106  * distributed under the License is distributed on an "AS IS" BASIS,
107  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
108  * See the License for the specific language governing permissions and
109  * limitations under the License.
110  */