Coverage Report - com.buckosoft.PicMan.domain.JobLogEntry
 
Classes in this File Line Coverage Branch Coverage Complexity
JobLogEntry
0%
0/52
0%
0/16
2.1
 
 1  
 /******************************************************************************
 2  
  * JobLogEntry.java - Describe what happened
 3  
  * 
 4  
  * PicMan - The BuckoSoft Picture Manager in Java
 5  
  * Copyright(c) 2007 - Dick Balaska
 6  
  * 
 7  
  */
 8  
 package com.buckosoft.PicMan.domain;
 9  
 
 10  
 import java.text.SimpleDateFormat;
 11  
 import java.util.Date;
 12  
 
 13  
 import com.buckosoft.PicMan.util.DateUtil;
 14  
 
 15  
 /** describe an event.
 16  
  * @author Dick Balaska
 17  
  * @since 2007/12/07
 18  
  * @see <a href="http://cvs.buckosoft.com/Projects/java/PicMan/PicMan/src/com/buckosoft/PicMan/domain/JobLogEntry.java">JobLogEntry.java</a>
 19  
  */
 20  0
 public class JobLogEntry {
 21  
         public static final int        CONTACT        = 0;
 22  
         public static final int        PICSIZE = 1;
 23  
         public static final int        MLBFIXER = 2;
 24  
         public static final int        MD5SUM        = 3;        
 25  
         public static final int        MOSAIC        = 4;
 26  
         public static final int        MOSAICV        = 5;
 27  
         public static final int INFO        = 6;
 28  
 
 29  
         /** Finished processing a batch run */
 30  
         public static final int        DONE        = 7;
 31  
         /** Unknown job log */
 32  
         public static final int        OTHER        = 8;
 33  
         
 34  
         /** For subclasses to continue counting */
 35  
         protected static final int JLELAST = 9;
 36  
 
 37  
         public        static final int        COLOR_NORMAL = 0;
 38  
         public        static final int        COLOR_OK = 1;
 39  
         public        static final int        COLOR_BAD = 2;
 40  
         
 41  0
         static private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 42  
 
 43  0
         protected        int                        type = OTHER;
 44  
 
 45  0
         private        String                note = "";
 46  0
         private        String                name = "";
 47  0
         private        Date                startTime = new Date();
 48  0
         private        Date                endTime = null;
 49  0
         private        int                        color = COLOR_NORMAL;
 50  0
         private        static int        serialKey = 1;
 51  0
         private        int                        serial = serialKey++;
 52  
 
 53  
         /**
 54  
          * @param type the type to set
 55  
          */
 56  
         public void setType(int type) {
 57  0
                 this.type = type;
 58  0
         }
 59  
 
 60  
         /**
 61  
          * @return the type
 62  
          */
 63  
         public int getType() {
 64  0
                 return type;
 65  
         }
 66  
 
 67  
         /** Get the Serial number for this JobLogEntry
 68  
          * @return The "unique" key for this entry
 69  
          */
 70  
         public int        getSerial() {
 71  0
                 return(serial);
 72  
         }
 73  
 
 74  
         /**
 75  
          * @return the type as a string
 76  
          */
 77  
         public        String getTypeAsString() {
 78  0
                 switch (type) {
 79  
                 case CONTACT:
 80  0
                         return("contact");
 81  
                 case PICSIZE:
 82  0
                         return("PicSize");
 83  
                 case MLBFIXER:
 84  0
                         return("mlbFixer");
 85  
                 case MD5SUM:
 86  0
                         return("md5sum");
 87  
                 case MOSAIC:
 88  0
                         return("mosaic");
 89  
                 case MOSAICV:
 90  0
                         return("mosVec");
 91  
                 case INFO:
 92  0
                         return("Info");
 93  
                 case DONE:
 94  0
                         return("done");
 95  
                 case OTHER:
 96  0
                         return("other");
 97  
                 }
 98  0
                 return("unknown");
 99  
         }
 100  
 
 101  
         /**
 102  
          * @return the endTime
 103  
          */
 104  
         public Date getEndTime() {
 105  0
                 return endTime;
 106  
         }
 107  
 
 108  
         /**
 109  
          * @param endTime the endTime to set
 110  
          */
 111  
         public void setEndTime(Date endTime) {
 112  0
                 this.endTime = endTime;
 113  0
         }
 114  
 
 115  
         /** Set the end time of this JobLogEntry to now.
 116  
          */
 117  
         public void setEndTime() {
 118  0
                 this.endTime = new Date();
 119  0
         }
 120  
 
 121  
         /**
 122  
          * @return the name
 123  
          */
 124  
         public String getName() {
 125  0
                 return name;
 126  
         }
 127  
 
 128  
         /**
 129  
          * @param name the name to set
 130  
          */
 131  
         public void setName(String name) {
 132  0
                 this.name = name;
 133  0
         }
 134  
 
 135  
         /** Get any note the job might have about it's status.
 136  
          * @return the note
 137  
          */
 138  
         public String getNote() {
 139  0
                 return note;
 140  
         }
 141  
 
 142  
         /**
 143  
          * @param note the note to set
 144  
          */
 145  
         public void setNote(String note) {
 146  0
                 this.note = note;
 147  0
         }
 148  
 
 149  
         /**
 150  
          * @return the color
 151  
          */
 152  
         public int getColor() {
 153  0
                 return color;
 154  
         }
 155  
 
 156  
         /**
 157  
          * @param color the color to set
 158  
          */
 159  
         public void setColor(int color) {
 160  0
                 this.color = color;
 161  0
         }
 162  
 
 163  
         /**
 164  
          * @return the startTime
 165  
          */
 166  
         public Date getStartTime() {
 167  0
                 return startTime;
 168  
         }
 169  
 
 170  
         public void setError() {
 171  0
                 setColor(COLOR_BAD);
 172  0
         }
 173  
 
 174  
         public boolean isError() {
 175  0
                 return(this.color == COLOR_BAD);
 176  
         }
 177  
         /**
 178  
          * @param startTime the startTime to set
 179  
          */
 180  
         public void setStartTime(Date startTime) {
 181  0
                 this.startTime = startTime;
 182  0
         }
 183  
 
 184  
         public String getStartTimeAsString() {
 185  0
                 return(dateFormat.format(getStartTime()));
 186  
         }
 187  
 
 188  
         public String getEndTimeAsString() {
 189  0
                 if (getEndTime() != null)
 190  0
                         return(dateFormat.format(getEndTime()));
 191  0
                 return("0");
 192  
         }
 193  
 
 194  
         public String getDurationAsString() {
 195  0
                 if (getEndTime() != null) {
 196  0
                         return(DateUtil.timeToString(getEndTime().getTime() - getStartTime().getTime()));
 197  
                 }
 198  0
                 return(DateUtil.timeToString(new Date().getTime() - getStartTime().getTime()));
 199  
         }
 200  
 
 201  
 }