Coverage Report - org.kuali.rice.kew.useroptions.dao.impl.UserOptionsDAOOjbImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
UserOptionsDAOOjbImpl
0%
0/30
0%
0/4
1.182
UserOptionsDAOOjbImpl$1
0%
0/2
N/A
1.182
 
 1  
 /**
 2  
  * Copyright 2005-2011 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.useroptions.dao.impl;
 17  
 
 18  
 import org.apache.ojb.broker.PersistenceBroker;
 19  
 import org.apache.ojb.broker.query.Criteria;
 20  
 import org.apache.ojb.broker.query.QueryByCriteria;
 21  
 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
 22  
 import org.kuali.rice.core.api.util.RiceConstants;
 23  
 import org.kuali.rice.core.framework.persistence.platform.DatabasePlatform;
 24  
 import org.kuali.rice.kew.useroptions.UserOptions;
 25  
 import org.kuali.rice.kew.useroptions.dao.UserOptionsDAO;
 26  
 import org.springmodules.orm.ojb.PersistenceBrokerCallback;
 27  
 import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport;
 28  
 
 29  
 import java.util.ArrayList;
 30  
 import java.util.Collection;
 31  
 import java.util.List;
 32  
 
 33  
 
 34  0
 public class UserOptionsDAOOjbImpl extends PersistenceBrokerDaoSupport implements UserOptionsDAO {
 35  
 
 36  
         public Long getNewOptionIdForActionList() {
 37  0
         return (Long)this.getPersistenceBrokerTemplate().execute(new PersistenceBrokerCallback() {
 38  
             public Object doInPersistenceBroker(PersistenceBroker broker) {
 39  0
                     return getPlatform().getNextValSQL("KREW_ACTN_LIST_OPTN_S", broker);
 40  
             }
 41  
         });
 42  
     }
 43  
 
 44  
         protected DatabasePlatform getPlatform() {
 45  0
             return (DatabasePlatform)GlobalResourceLoader.getService(RiceConstants.DB_PLATFORM);
 46  
     }
 47  
 
 48  
     public List<UserOptions> findByUserQualified(String principalId, String likeString) {
 49  0
         Criteria criteria = new Criteria();
 50  0
         criteria.addEqualTo("workflowId", principalId);
 51  0
         criteria.addLike("optionId", likeString);
 52  0
         return new ArrayList<UserOptions>(this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(UserOptions.class, criteria)));
 53  
     }
 54  
 
 55  
     public void deleteByUserQualified(String principalId, String likeString) {
 56  0
         Criteria criteria = new Criteria();
 57  0
         criteria.addEqualTo("workflowId", principalId);
 58  0
         criteria.addLike("optionId", likeString);
 59  0
         this.getPersistenceBrokerTemplate().deleteByQuery(new QueryByCriteria(UserOptions.class, criteria));
 60  0
     }
 61  
 
 62  
     public Collection<UserOptions> findByWorkflowUser(String principalId) {
 63  0
         UserOptions userOptions = new UserOptions();
 64  0
         userOptions.setWorkflowId(principalId);
 65  0
         return this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(userOptions));
 66  
     }
 67  
 
 68  
     public void save(UserOptions userOptions) {
 69  0
             this.getPersistenceBrokerTemplate().store(userOptions);
 70  0
     }
 71  
     
 72  
     public void save(Collection<UserOptions> userOptions) {
 73  0
             if (userOptions != null) for (UserOptions option : userOptions) {
 74  0
                     this.getPersistenceBrokerTemplate().store(option);
 75  
             }
 76  0
     }
 77  
     
 78  
     public void deleteUserOptions(UserOptions userOptions) {
 79  0
             this.getPersistenceBrokerTemplate().delete(userOptions);
 80  0
     }
 81  
 
 82  
     public UserOptions findByOptionId(String optionId, String principalId) {
 83  0
         UserOptions userOptions = new UserOptions();
 84  0
         userOptions.setOptionId(optionId);
 85  0
         userOptions.setWorkflowId(principalId);
 86  0
         return (UserOptions) this.getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(userOptions));
 87  
     }
 88  
 
 89  
     public Collection<UserOptions> findByOptionValue(String optionId, String optionValue) {
 90  0
         UserOptions userOptions = new UserOptions();
 91  0
         userOptions.setOptionId(optionId);
 92  0
         userOptions.setOptionVal(optionValue);
 93  0
         return this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(userOptions));
 94  
     }
 95  
 }