Coverage Report - org.kuali.rice.kew.docsearch.dao.impl.SearchableAttributeDAOJpaImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
SearchableAttributeDAOJpaImpl
0%
0/44
0%
0/16
2.333
 
 1  
 /*
 2  
  * Copyright 2007-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.rice.kew.docsearch.dao.impl;
 17  
 
 18  
 import java.math.BigDecimal;
 19  
 import java.sql.Timestamp;
 20  
 import java.util.ArrayList;
 21  
 import java.util.List;
 22  
 
 23  
 import javax.persistence.EntityManager;
 24  
 import javax.persistence.PersistenceContext;
 25  
 import javax.persistence.Query;
 26  
 
 27  
 import org.kuali.rice.kew.docsearch.SearchableAttributeDateTimeValue;
 28  
 import org.kuali.rice.kew.docsearch.SearchableAttributeFloatValue;
 29  
 import org.kuali.rice.kew.docsearch.SearchableAttributeLongValue;
 30  
 import org.kuali.rice.kew.docsearch.SearchableAttributeStringValue;
 31  
 import org.kuali.rice.kew.docsearch.dao.SearchableAttributeDAO;
 32  
 
 33  
 /**
 34  
  * JPA implementation of SearchableAttributeDAO
 35  
  *
 36  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 37  
  *
 38  
  */
 39  0
 public class SearchableAttributeDAOJpaImpl implements SearchableAttributeDAO {
 40  
 
 41  
         @PersistenceContext(unitName = "kew-unit")
 42  
         private EntityManager entityManager;
 43  
 
 44  
         /**
 45  
          * This overridden method queries the SearchableAttributeDateTimeValue persistence class
 46  
          *
 47  
          * @see org.kuali.rice.kew.docsearch.dao.SearchableAttributeDAO#getSearchableAttributeDateTimeValuesByKey(java.lang.Long,
 48  
          *      java.lang.String)
 49  
          */
 50  
         public List<Timestamp> getSearchableAttributeDateTimeValuesByKey(
 51  
                         String documentId, String key) {
 52  
 
 53  0
                 List<Timestamp> lRet = null;
 54  0
                 Query query = entityManager.createNamedQuery("SearchableAttributeDateTimeValue.FindByKey");
 55  0
         query.setParameter("documentId", documentId);
 56  0
         query.setParameter("searchableAttributeKey", key);
 57  0
         List<SearchableAttributeDateTimeValue> results = query.getResultList();
 58  0
         if (!results.isEmpty()) {
 59  0
                 lRet = new ArrayList<Timestamp>();
 60  0
             for (SearchableAttributeDateTimeValue attribute: results) {
 61  0
                     lRet.add(attribute.getSearchableAttributeValue());
 62  
             }
 63  
         }
 64  0
                 return lRet;
 65  
         }
 66  
 
 67  
         /**
 68  
          * This overridden method queries the SearchableAttributeFloatValue persistence class
 69  
          *
 70  
          * @see org.kuali.rice.kew.docsearch.dao.SearchableAttributeDAO#getSearchableAttributeFloatValuesByKey(java.lang.Long,
 71  
          *      java.lang.String)
 72  
          */
 73  
         public List<BigDecimal> getSearchableAttributeFloatValuesByKey(
 74  
                         String documentId, String key) {
 75  0
                 List<BigDecimal> lRet = null;
 76  0
                 Query query = entityManager.createNamedQuery("SearchableAttributeFloatValue.FindByKey");
 77  0
         query.setParameter("documentId", documentId);
 78  0
         query.setParameter("searchableAttributeKey", key);
 79  0
         List<SearchableAttributeFloatValue> results = query.getResultList();
 80  0
         if (!results.isEmpty()) {
 81  0
                 lRet = new ArrayList<BigDecimal>();
 82  0
             for (SearchableAttributeFloatValue attribute: results) {
 83  0
                     lRet.add(attribute.getSearchableAttributeValue());
 84  
             }
 85  
         }
 86  0
                 return lRet;
 87  
         }
 88  
 
 89  
         /**
 90  
          * This overridden method queries the searchableAttributeKey persistence class
 91  
          *
 92  
          * @see org.kuali.rice.kew.docsearch.dao.SearchableAttributeDAO#getSearchableAttributeLongValuesByKey(java.lang.Long,
 93  
          *      java.lang.String)
 94  
          */
 95  
         public List<Long> getSearchableAttributeLongValuesByKey(String documentId,
 96  
                         String key) {
 97  0
                 List<Long> lRet = null;
 98  0
                 Query query = entityManager.createNamedQuery("SearchableAttributeLongValue.FindByKey");
 99  0
         query.setParameter("documentId", documentId);
 100  0
         query.setParameter("searchableAttributeKey", key);
 101  0
         List<SearchableAttributeLongValue> results = query.getResultList();
 102  0
         if (!results.isEmpty()) {
 103  0
                 lRet = new ArrayList<Long>();
 104  0
             for (SearchableAttributeLongValue attribute: results) {
 105  0
                     lRet.add(attribute.getSearchableAttributeValue());
 106  
             }
 107  
         }
 108  0
                 return lRet;
 109  
         }
 110  
 
 111  
         /**
 112  
          * This overridden method queries the SearchableAttributeStringValue persistence class
 113  
          *
 114  
          * @see org.kuali.rice.kew.docsearch.dao.SearchableAttributeDAO#getSearchableAttributeStringValuesByKey(java.lang.Long,
 115  
          *      java.lang.String)
 116  
          */
 117  
         public List<String> getSearchableAttributeStringValuesByKey(
 118  
                         String documentId, String key) {
 119  0
                 List<String> lRet = null;
 120  0
                 Query query = entityManager.createNamedQuery("SearchableAttributeStringValue.FindByKey");
 121  0
         query.setParameter("documentId", documentId);
 122  0
         query.setParameter("searchableAttributeKey", key);
 123  0
         List<SearchableAttributeStringValue> results = query.getResultList();
 124  0
         if (!results.isEmpty()) {
 125  0
                 lRet = new ArrayList<String>();
 126  0
             for (SearchableAttributeStringValue attribute: results) {
 127  0
                     lRet.add(attribute.getSearchableAttributeValue());
 128  
             }
 129  
         }
 130  0
                 return lRet;
 131  
         }
 132  
 
 133  
     public EntityManager getEntityManager() {
 134  0
         return this.entityManager;
 135  
     }
 136  
 
 137  
     public void setEntityManager(EntityManager entityManager) {
 138  0
         this.entityManager = entityManager;
 139  0
     }
 140  
 
 141  
 }