Coverage Report - org.kuali.rice.kew.edl.dao.impl.EDocLiteDAOOjbImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
EDocLiteDAOOjbImpl
0%
0/58
0%
0/16
1.667
 
 1  
 /*
 2  
  * Copyright 2005-2007 The Kuali Foundation
 3  
  * 
 4  
  * 
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  * 
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  * 
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.kuali.rice.kew.edl.dao.impl;
 18  
 
 19  
 import java.util.ArrayList;
 20  
 import java.util.Iterator;
 21  
 import java.util.List;
 22  
 
 23  
 import org.apache.ojb.broker.query.Criteria;
 24  
 import org.apache.ojb.broker.query.QueryByCriteria;
 25  
 import org.kuali.rice.kew.edl.bo.EDocLiteAssociation;
 26  
 import org.kuali.rice.kew.edl.bo.EDocLiteDefinition;
 27  
 import org.kuali.rice.kew.edl.bo.EDocLiteStyle;
 28  
 import org.kuali.rice.kew.edl.dao.EDocLiteDAO;
 29  
 import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport;
 30  
 
 31  
 
 32  0
 public class EDocLiteDAOOjbImpl extends PersistenceBrokerDaoSupport implements EDocLiteDAO {
 33  
 
 34  
     public void saveEDocLiteStyle(EDocLiteStyle styleData) {
 35  0
         this.getPersistenceBrokerTemplate().store(styleData);
 36  0
     }
 37  
 
 38  
     public void saveEDocLiteDefinition(EDocLiteDefinition edocLiteData) {
 39  0
             this.getPersistenceBrokerTemplate().store(edocLiteData);
 40  0
     }
 41  
 
 42  
     public void saveEDocLiteAssociation(EDocLiteAssociation assoc) {
 43  0
             this.getPersistenceBrokerTemplate().store(assoc);
 44  0
     }
 45  
 
 46  
     public EDocLiteStyle getEDocLiteStyle(String styleName) {
 47  0
         Criteria criteria = new Criteria();
 48  0
         criteria.addEqualTo("name", styleName);
 49  0
         criteria.addEqualTo("activeInd", Boolean.TRUE);
 50  0
         return (EDocLiteStyle) this.getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(EDocLiteStyle.class, criteria));
 51  
     }
 52  
 
 53  
     public EDocLiteDefinition getEDocLiteDefinition(String defName) {
 54  0
         Criteria criteria = new Criteria();
 55  0
         criteria.addEqualTo("name", defName);
 56  0
         criteria.addEqualTo("activeInd", Boolean.TRUE);
 57  0
         return (EDocLiteDefinition) this.getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(EDocLiteDefinition.class, criteria));
 58  
     }
 59  
 
 60  
     public EDocLiteAssociation getEDocLiteAssociation(String docTypeName) {
 61  0
         Criteria criteria = new Criteria();
 62  0
         criteria.addEqualTo("edlName", docTypeName);
 63  0
         criteria.addEqualTo("activeInd", Boolean.TRUE);
 64  0
         return (EDocLiteAssociation) this.getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(EDocLiteAssociation.class, criteria));
 65  
     }
 66  
 
 67  
     /**
 68  
      * Returns names of all active Styles
 69  
      */
 70  
     public List<String> getEDocLiteStyleNames() {
 71  0
         List<EDocLiteStyle> styles = getEDocLiteStyles();
 72  0
         List<String> styleNames = new ArrayList<String>(styles.size());
 73  0
         for (EDocLiteStyle style: styles) {
 74  0
             styleNames.add(style.getName());
 75  
         }
 76  0
         return styleNames;
 77  
     }
 78  
 
 79  
     /**
 80  
      * Returns all active Styles
 81  
      */
 82  
     public List<EDocLiteStyle> getEDocLiteStyles() {
 83  0
         Criteria criteria = new Criteria();
 84  0
         criteria.addEqualTo("activeInd", Boolean.TRUE);
 85  0
         Iterator it = this.getPersistenceBrokerTemplate().getIteratorByQuery(new QueryByCriteria(EDocLiteStyle.class, criteria));
 86  0
         List<EDocLiteStyle> styles = new ArrayList<EDocLiteStyle>();
 87  0
         while (it.hasNext()) {
 88  0
             styles.add((EDocLiteStyle) it.next());
 89  
         }
 90  0
         return styles;
 91  
     }
 92  
 
 93  
     public List getEDocLiteDefinitions() {
 94  0
         Criteria criteria = new Criteria();
 95  0
         criteria.addEqualTo("activeInd", Boolean.TRUE);
 96  0
         Iterator it = this.getPersistenceBrokerTemplate().getIteratorByQuery(new QueryByCriteria(EDocLiteDefinition.class, criteria));
 97  0
         List defs = new ArrayList();
 98  0
         while (it.hasNext()) {
 99  0
             defs.add(((EDocLiteDefinition) it.next()).getName());
 100  
         }
 101  0
         return defs;
 102  
     }
 103  
 
 104  
     public List getEDocLiteAssociations() {
 105  0
         Criteria criteria = new Criteria();
 106  0
         criteria.addEqualTo("activeInd", Boolean.TRUE);
 107  0
         Iterator it = this.getPersistenceBrokerTemplate().getIteratorByQuery(new QueryByCriteria(EDocLiteAssociation.class, criteria));
 108  0
         List assocs = new ArrayList();
 109  0
         while (it.hasNext()) {
 110  0
             assocs.add(it.next());
 111  
         }
 112  0
         return assocs;
 113  
     }
 114  
 
 115  
         public List search(EDocLiteAssociation edocLite) {
 116  0
                 Criteria crit = new Criteria();
 117  0
                 if (edocLite.getActiveInd() != null) {
 118  0
                         crit.addEqualTo("activeInd", edocLite.getActiveInd());
 119  
                 }
 120  0
                 if (edocLite.getDefinition() != null) {
 121  0
                         crit.addLike("UPPER(definition)", "%"+edocLite.getDefinition().toUpperCase()+"%");
 122  
                 }
 123  0
                 if (edocLite.getEdlName() != null) {
 124  0
                         crit.addLike("UPPER(edlName)", "%"+edocLite.getEdlName().toUpperCase()+"%");
 125  
                 }
 126  0
                 if (edocLite.getStyle() != null) {
 127  0
                         crit.addLike("UPPER(style)", "%"+edocLite.getStyle().toUpperCase()+"%");
 128  
                 }
 129  0
                 return (List)this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(EDocLiteAssociation.class, crit));
 130  
         }
 131  
 
 132  
         public EDocLiteAssociation getEDocLiteAssociation(Long associationId) {
 133  0
                 Criteria crit = new Criteria();
 134  0
                 crit.addEqualTo("edocLiteAssocId", associationId);
 135  0
                 return (EDocLiteAssociation)this.getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(EDocLiteAssociation.class, crit));
 136  
         }
 137  
 }