View Javadoc
1   /*
2    * Copyright 2007-2008 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.vnd.dataaccess.impl;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.apache.ojb.broker.query.Criteria;
20  import org.apache.ojb.broker.query.QueryFactory;
21  import org.kuali.ole.sys.OLEConstants;
22  import org.kuali.ole.vnd.VendorPropertyConstants;
23  import org.kuali.ole.vnd.businessobject.CommodityCode;
24  import org.kuali.ole.vnd.dataaccess.CommodityCodeDao;
25  import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
26  
27  /**
28   * OJB implementation of CommodityCodeDao.
29   */
30  public class CommodityCodeDaoOjb extends PlatformAwareDaoBaseOjb implements CommodityCodeDao {
31      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(CommodityCodeDaoOjb.class);
32  
33      /**
34       * @see org.kuali.ole.vnd.dataaccess.CommodityCodeDao#wildCardCommodityCodeExists(java.lang.String)
35       */
36      public boolean wildCardCommodityCodeExists(String wildCardCommodityCode) {
37          String commodityCodeString = StringUtils.replace(wildCardCommodityCode, OLEConstants.WILDCARD_CHARACTER, OLEConstants.PERCENTAGE_SIGN);
38          Criteria criteria = new Criteria();
39          criteria.addLike(VendorPropertyConstants.PURCHASING_COMMODITY_CODE, commodityCodeString);        
40          int count =  getPersistenceBrokerTemplate().getCount(QueryFactory.newQuery(CommodityCode.class, criteria));
41          boolean exists = ((count > 0) ? true : false);
42          return exists;
43      }
44  }