Coverage Report - org.kuali.rice.ksb.messaging.web.MessageQueueForm
 
Classes in this File Line Coverage Branch Coverage Complexity
MessageQueueForm
0%
0/97
0%
0/2
1.217
MessageQueueForm$SqlTimestampConverter
0%
0/21
0%
0/8
1.217
 
 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.ksb.messaging.web;
 18  
 
 19  
 import org.apache.commons.beanutils.ConversionException;
 20  
 import org.apache.commons.beanutils.ConvertUtils;
 21  
 import org.apache.commons.beanutils.Converter;
 22  
 import org.apache.struts.action.ActionForm;
 23  
 import org.kuali.rice.core.util.KeyValue;
 24  
 import org.kuali.rice.ksb.messaging.PersistedMessageBO;
 25  
 import org.kuali.rice.ksb.util.CodeTranslator;
 26  
 
 27  
 import java.sql.Timestamp;
 28  
 import java.util.ArrayList;
 29  
 import java.util.Collection;
 30  
 import java.util.List;
 31  
 
 32  
 
 33  
 /**
 34  
  * Struts ActionForm for the {@link MessageQueueAction}.
 35  
  *
 36  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 37  
  */
 38  
 public class MessageQueueForm extends ActionForm {
 39  
 
 40  
     private static final long serialVersionUID = -247925603792980036L;
 41  
     public static final int DEFAULT_MAX_ROWS = 1000;
 42  
     public static final int DEFAULT_PAGE_SIZE = 100;
 43  
 
 44  0
     private int maxRows = DEFAULT_MAX_ROWS;
 45  0
     private int pageSize = DEFAULT_PAGE_SIZE;
 46  
     private Long messageId;
 47  0
     private String methodToCall = "";
 48  
     private Collection<PersistedMessageBO> messageQueueRows;
 49  
     private String showEdit;
 50  
     private String command;
 51  
     private PersistedMessageBO messageQueueFromDatabase;
 52  
     private PersistedMessageBO messageQueueFromForm;
 53  
     private String newQueueDate;
 54  
     private String existingQueueDate;
 55  
     private String ipAddress;
 56  
 
 57  
     //  filter stuff
 58  
     private String routeQueueIdFilter;
 59  
     private String serviceNameFilter;
 60  
     private String applicationIdFilter;
 61  
     private String queueStatusFilter;
 62  
     private String ipNumberFilter;
 63  
     private String value1Filter;
 64  
     private String value2Filter;
 65  
     private String filterApplied;
 66  
 
 67  0
     private Integer maxMessageFetcherMessages = Integer.valueOf(50);
 68  
 
 69  
     private String myIpAddress;
 70  
     private String myApplicationId;
 71  
     private String messagePersistence;
 72  
     private String messageDelivery;
 73  
     private String messageOff;
 74  0
     private List<KeyValue> ipAddresses = new ArrayList<KeyValue>();
 75  
 
 76  
     static {
 77  0
         ConvertUtils.register(new SqlTimestampConverter(), Timestamp.class);
 78  0
     }
 79  
 
 80  0
     public MessageQueueForm() {
 81  0
         messageQueueFromForm = new PersistedMessageBO();
 82  0
         maxRows = DEFAULT_MAX_ROWS;
 83  0
         pageSize = DEFAULT_PAGE_SIZE;
 84  0
     }
 85  
 
 86  
     public String getRouteQueueStatusLabel(String statusCode) {
 87  0
         return CodeTranslator.getRouteQueueStatusLabel(statusCode);
 88  
     }
 89  
 
 90  
     public String getMethodToCall() {
 91  0
         return methodToCall;
 92  
     }
 93  
 
 94  
     public void setMethodToCall(String methodToCall) {
 95  0
         this.methodToCall = methodToCall;
 96  0
     }
 97  
 
 98  
     public Long getMessageId() {
 99  0
         return messageId;
 100  
     }
 101  
 
 102  
     public void setMessageId(Long routeQueueId) {
 103  0
         this.messageId = routeQueueId;
 104  0
     }
 105  
 
 106  
     public Collection<PersistedMessageBO> getMessageQueueRows() {
 107  0
         return messageQueueRows;
 108  
     }
 109  
 
 110  
     public void setMessageQueueRows(Collection<PersistedMessageBO> routeQueueRows) {
 111  0
         this.messageQueueRows = routeQueueRows;
 112  0
     }
 113  
 
 114  
     public int getMessageQueueRowsSize() {
 115  0
         if (messageQueueRows == null) {
 116  0
             return 0;
 117  
         }
 118  0
         return messageQueueRows.size();
 119  
     }
 120  
 
 121  
     public String getCommand() {
 122  0
         return command;
 123  
     }
 124  
 
 125  
     public void setCommand(String command) {
 126  0
         this.command = command;
 127  0
     }
 128  
 
 129  
     public PersistedMessageBO getMessageQueueFromDatabase() {
 130  0
         return messageQueueFromDatabase;
 131  
     }
 132  
 
 133  
     public void setMessageQueueFromDatabase(PersistedMessageBO existingRouteQueue) {
 134  0
         this.messageQueueFromDatabase = existingRouteQueue;
 135  0
     }
 136  
 
 137  
     public PersistedMessageBO getMessageQueueFromForm() {
 138  0
         return messageQueueFromForm;
 139  
     }
 140  
 
 141  
     public void setMessageQueueFromForm(PersistedMessageBO routeQueue) {
 142  0
         this.messageQueueFromForm = routeQueue;
 143  0
     }
 144  
 
 145  
     public String getShowEdit() {
 146  0
         return showEdit;
 147  
     }
 148  
 
 149  
     public void setShowEdit(String showEdit) {
 150  0
         this.showEdit = showEdit;
 151  0
     }
 152  
 
 153  
     public String getExistingQueueDate() {
 154  0
         return existingQueueDate;
 155  
     }
 156  
 
 157  
     public void setExistingQueueDate(String existingQueueDate) {
 158  0
         this.existingQueueDate = existingQueueDate;
 159  0
     }
 160  
 
 161  
     public String getNewQueueDate() {
 162  0
         return newQueueDate;
 163  
     }
 164  
 
 165  
     public void setNewQueueDate(String newQueueDate) {
 166  0
         this.newQueueDate = newQueueDate;
 167  0
     }
 168  
 
 169  
     public int getMaxRows() {
 170  0
         return maxRows;
 171  
     }
 172  
 
 173  
     public void setMaxRows(int maxRows) {
 174  0
         this.maxRows = maxRows;
 175  0
     }
 176  
 
 177  
     public int getPageSize() {
 178  0
         return this.pageSize;
 179  
     }
 180  
 
 181  
     public void setPageSize(int pageSize) {
 182  0
         this.pageSize = pageSize;
 183  0
     }
 184  
 
 185  
     /**
 186  
      * @return the ipNumberFilter
 187  
      */
 188  
     public String getIpNumberFilter() {
 189  0
       return ipNumberFilter;
 190  
     }
 191  
 
 192  
     /**
 193  
      * @param ipNumberFilter the ipNumberFilter to set
 194  
      */
 195  
     public void setIpNumberFilter(String ipNumberFilter) {
 196  0
       this.ipNumberFilter = ipNumberFilter;
 197  0
     }
 198  
 
 199  
     /**
 200  
      * @return the applicationIdFilter
 201  
      */
 202  
     public String getApplicationIdFilter() {
 203  0
       return applicationIdFilter;
 204  
     }
 205  
 
 206  
     /**
 207  
      * @param applicationIdFilter the applicationIdFilter to set
 208  
      */
 209  
     public void setApplicationIdFilter(String applicationIdFilter) {
 210  0
       this.applicationIdFilter = applicationIdFilter;
 211  0
     }
 212  
 
 213  
     /**
 214  
      * @return the queueStatusFilter
 215  
      */
 216  
     public String getQueueStatusFilter() {
 217  0
       return queueStatusFilter;
 218  
     }
 219  
 
 220  
     /**
 221  
      * @param queueStatusFilter the queueStatusFilter to set
 222  
      */
 223  
     public void setQueueStatusFilter(String queueStatusFilter) {
 224  0
       this.queueStatusFilter = queueStatusFilter;
 225  0
     }
 226  
 
 227  
     /**
 228  
      * @return the serviceNameFilter
 229  
      */
 230  
     public String getServiceNameFilter() {
 231  0
       return serviceNameFilter;
 232  
     }
 233  
 
 234  
     /**
 235  
      * @param serviceNameFilter the serviceNameFilter to set
 236  
      */
 237  
     public void setServiceNameFilter(String serviceNameFilter) {
 238  0
       this.serviceNameFilter = serviceNameFilter;
 239  0
     }
 240  
 
 241  
     /**
 242  
      * @return the filterApplied
 243  
      */
 244  
     public String getFilterApplied() {
 245  0
       return filterApplied;
 246  
     }
 247  
 
 248  
     /**
 249  
      * @param filterApplied the filterApplied to set
 250  
      */
 251  
     public void setFilterApplied(String filterApplied) {
 252  0
       this.filterApplied = filterApplied;
 253  0
     }
 254  
 
 255  
     public String getRouteQueueIdFilter() {
 256  0
         return this.routeQueueIdFilter;
 257  
     }
 258  
 
 259  
     public void setRouteQueueIdFilter(String messageIdFilter) {
 260  0
         this.routeQueueIdFilter = messageIdFilter;
 261  0
     }
 262  
 
 263  
     public String getValue1Filter() {
 264  0
         return this.value1Filter;
 265  
     }
 266  
 
 267  
     public void setValue1Filter(String value1Filter) {
 268  0
         this.value1Filter = value1Filter;
 269  0
     }
 270  
 
 271  
     public String getValue2Filter() {
 272  0
         return this.value2Filter;
 273  
     }
 274  
 
 275  
     public void setValue2Filter(String value2Filter) {
 276  0
         this.value2Filter = value2Filter;
 277  0
     }
 278  
 
 279  
     public List<KeyValue> getIpAddresses() {
 280  0
         return this.ipAddresses;
 281  
     }
 282  
 
 283  
     public void setIpAddresses(List<KeyValue> ipAddresses) {
 284  0
         this.ipAddresses = ipAddresses;
 285  0
     }
 286  
 
 287  
     public String getIpAddress() {
 288  0
         return this.ipAddress;
 289  
     }
 290  
 
 291  
     public void setIpAddress(String ipAddress) {
 292  0
         this.ipAddress = ipAddress;
 293  0
     }
 294  
 
 295  
     public Integer getMaxMessageFetcherMessages() {
 296  0
         return this.maxMessageFetcherMessages;
 297  
     }
 298  
 
 299  
     public void setMaxMessageFetcherMessages(Integer maxMessageFetcherMessages) {
 300  0
         this.maxMessageFetcherMessages = maxMessageFetcherMessages;
 301  0
     }
 302  
 
 303  
     public String getMyIpAddress() {
 304  0
         return this.myIpAddress;
 305  
     }
 306  
 
 307  
     public void setMyIpAddress(String myIpAddress) {
 308  0
         this.myIpAddress = myIpAddress;
 309  0
     }
 310  
 
 311  
     public String getMyApplicationId() {
 312  0
         return this.myApplicationId;
 313  
     }
 314  
 
 315  
     public void setMyApplicationId(String myApplicationId) {
 316  0
         this.myApplicationId = myApplicationId;
 317  0
     }
 318  
 
 319  
     public String getMessageDelivery() {
 320  0
         return this.messageDelivery;
 321  
     }
 322  
 
 323  
     public void setMessageDelivery(String messageDelivery) {
 324  0
         this.messageDelivery = messageDelivery;
 325  0
     }
 326  
 
 327  
     public String getMessageOff() {
 328  0
         return this.messageOff;
 329  
     }
 330  
 
 331  
     public void setMessageOff(String messageOff) {
 332  0
         this.messageOff = messageOff;
 333  0
     }
 334  
 
 335  
     public String getMessagePersistence() {
 336  0
         return this.messagePersistence;
 337  
     }
 338  
 
 339  
     public void setMessagePersistence(String messagePersistence) {
 340  0
         this.messagePersistence = messagePersistence;
 341  0
     }
 342  
 
 343  
     /**
 344  
      * Converts an incoming object to a timestamp.
 345  
      *
 346  
      * Adapted from org.apache.commons.beanutils.converters.SqlTimestampConverter
 347  
      */
 348  
     public static class SqlTimestampConverter implements Converter {
 349  
 
 350  
         /**
 351  
          * Create a {@link org.apache.commons.beanutils.Converter} that will throw a {@link org.apache.commons.beanutils.ConversionException}
 352  
          * if a conversion error occurs.
 353  
          */
 354  0
         public SqlTimestampConverter() {
 355  0
             this.defaultValue = null;
 356  0
             this.useDefault = true;
 357  0
         }
 358  
 
 359  
         /**
 360  
          * Create a {@link org.apache.commons.beanutils.Converter} that will return the specified default value
 361  
          * if a conversion error occurs.
 362  
          *
 363  
          * @param defaultValue The default value to be returned
 364  
          */
 365  0
         public SqlTimestampConverter(Object defaultValue) {
 366  0
             this.defaultValue = defaultValue;
 367  0
             this.useDefault = true;
 368  0
         }
 369  
 
 370  
         // ----------------------------------------------------- Instance Variables
 371  
 
 372  
         /**
 373  
          * The default value specified to our Constructor, if any.
 374  
          */
 375  0
         private Object defaultValue = null;
 376  
 
 377  
         /**
 378  
          * Should we return the default value on conversion errors?
 379  
          */
 380  0
         private boolean useDefault = true;
 381  
 
 382  
         // --------------------------------------------------------- Public Methods
 383  
 
 384  
         /**
 385  
          * Convert the specified input object into an output object of the
 386  
          * specified type.
 387  
          *
 388  
          * @param type Data type to which this value should be converted
 389  
          * @param value The input value to be converted
 390  
          *
 391  
          * @exception org.apache.commons.beanutils.ConversionException if conversion cannot be performed
 392  
          *  successfully
 393  
          */
 394  
         public Object convert(Class type, Object value) {
 395  0
             if (value == null) {
 396  0
                 if (useDefault) {
 397  0
                     return (defaultValue);
 398  
                 } else {
 399  0
                     throw new ConversionException("No value specified");
 400  
                 }
 401  
             }
 402  
 
 403  0
             if (value instanceof Timestamp) {
 404  0
                 return (value);
 405  
             }
 406  
 
 407  
             try {
 408  0
                 return (Timestamp.valueOf(value.toString()));
 409  0
             } catch (Exception e) {
 410  0
                 if (useDefault) {
 411  0
                     return (defaultValue);
 412  
                 } else {
 413  0
                     throw new ConversionException(e);
 414  
                 }
 415  
             }
 416  
         }
 417  
 
 418  
     }
 419  
 }