Coverage Report - org.kuali.rice.kew.useroptions.UserOptionsServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
UserOptionsServiceImpl
0%
0/47
0%
0/20
1.8
 
 1  
 /*
 2  
  * Copyright 2005-2008 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.useroptions;
 18  
 
 19  
 import java.util.ArrayList;
 20  
 import java.util.Collection;
 21  
 import java.util.List;
 22  
 import java.util.Map;
 23  
 import java.util.Properties;
 24  
 import java.util.Map.Entry;
 25  
 
 26  
 import org.kuali.rice.kew.useroptions.dao.ReloadActionListDAO;
 27  
 import org.kuali.rice.kew.useroptions.dao.UserOptionsDAO;
 28  
 import org.kuali.rice.kew.util.KEWConstants;
 29  
 import org.springframework.transaction.annotation.Transactional;
 30  
 
 31  
 @Transactional
 32  0
 public class UserOptionsServiceImpl implements UserOptionsService {
 33  
 
 34  
     private UserOptionsDAO userOptionsDAO;
 35  
     private ReloadActionListDAO reloadActionListDAO;
 36  
 
 37  0
     private static final Properties defaultProperties = new Properties();
 38  
 
 39  
     static {
 40  0
         defaultProperties.setProperty(KEWConstants.EMAIL_RMNDR_KEY, KEWConstants.EMAIL_RMNDR_WEEK_VAL);
 41  0
     }
 42  
 
 43  
     private Long getNewOptionIdForActionList() {
 44  0
                 return getUserOptionsDAO().getNewOptionIdForActionList();
 45  
         }
 46  
 
 47  
     public List<UserOptions> findByUserQualified(String principalId, String likeString) {
 48  0
         if ((principalId == null)) {
 49  0
             return new ArrayList<UserOptions>(0);
 50  
         }
 51  0
         return this.getUserOptionsDAO().findByUserQualified(principalId, likeString);
 52  
     }
 53  
 
 54  
     public UserOptions findByOptionId(String optionId, String principalId) {
 55  0
         if (optionId == null || "".equals(optionId) || principalId == null || "".equals(principalId)) {
 56  0
             return null;
 57  
         }
 58  0
         return this.getUserOptionsDAO().findByOptionId(optionId, principalId);
 59  
     }
 60  
 
 61  
     public Collection<UserOptions> findByOptionValue(String optionId, String optionValue){
 62  0
         return this.getUserOptionsDAO().findByOptionValue(optionId, optionValue);
 63  
     }
 64  
 
 65  
     public Collection<UserOptions> findByWorkflowUser(String principalId) {
 66  0
         return this.getUserOptionsDAO().findByWorkflowUser(principalId);
 67  
     }
 68  
 
 69  
     public void save(UserOptions userOptions) {
 70  0
         this.getUserOptionsDAO().save(userOptions);
 71  0
     }
 72  
     
 73  
     /**
 74  
      * This overridden method saves an option for each optionsMap entry, all for the given principalId
 75  
      * 
 76  
      * @see org.kuali.rice.kew.useroptions.UserOptionsService#save(java.lang.String, java.util.Map)
 77  
      */
 78  
     public void save(String principalId, Map<String,String> optionsMap) {
 79  
             // create a collection of UserOptions and save it
 80  0
             if (optionsMap != null && optionsMap.size() > 0) {
 81  0
                     List<UserOptions> toSave = new ArrayList<UserOptions>();
 82  0
                     for (Entry<String, String> entry : optionsMap.entrySet()) {
 83  0
                             UserOptions option = findByOptionId(entry.getKey(), principalId);
 84  0
                             if (option == null) {
 85  0
                                     option = new UserOptions();
 86  0
                                     option.setWorkflowId(principalId);
 87  
                             }
 88  0
                             option.setOptionId(entry.getKey());
 89  0
                             option.setOptionVal(entry.getValue());
 90  0
                             toSave.add(option);
 91  0
                     }
 92  0
                         getUserOptionsDAO().save(toSave);
 93  
             }
 94  0
     }
 95  
     
 96  
     public void deleteUserOptions(UserOptions userOptions) {
 97  0
         this.getUserOptionsDAO().deleteUserOptions(userOptions);
 98  0
     }
 99  
 
 100  
     public void save(String principalId, String optionId, String optionValue) {
 101  0
         UserOptions option = findByOptionId(optionId, principalId);
 102  0
         if (option == null) {
 103  0
             option = new UserOptions();
 104  0
             option.setWorkflowId(principalId);
 105  
         }
 106  0
         option.setOptionId(optionId);
 107  0
         option.setOptionVal(optionValue);
 108  0
         getUserOptionsDAO().save(option);
 109  0
     }
 110  
 
 111  
     public boolean refreshActionList(String principalId) {
 112  0
             return getReloadActionListDAO().checkAndResetReloadActionListFlag(principalId);
 113  
     }
 114  
 
 115  
     public void saveRefreshUserOption(String principalId) {
 116  0
             getReloadActionListDAO().setReloadActionListFlag(principalId);
 117  0
     }
 118  
 
 119  
     public UserOptionsDAO getUserOptionsDAO() {
 120  0
         return userOptionsDAO;
 121  
     }
 122  
 
 123  
     public void setUserOptionsDAO(UserOptionsDAO optionsDAO) {
 124  0
         userOptionsDAO = optionsDAO;
 125  0
     }
 126  
     
 127  
     /**
 128  
          * @return the reloadActionListDAO
 129  
          */
 130  
         public ReloadActionListDAO getReloadActionListDAO() {
 131  0
                 return this.reloadActionListDAO;
 132  
         }
 133  
         
 134  
         public void setReloadActionListDAO(ReloadActionListDAO rald) {
 135  0
                 this.reloadActionListDAO = rald;
 136  0
         }
 137  
 
 138  
 }