View Javadoc

1   /*
2    * $Id: QuerierStatus.java,v 1.1.1.1 2005/02/17 18:37:35 mch Exp $
3    *
4    * (C) Copyright Astrogrid...
5    */
6   
7   package org.astrogrid.dataservice.queriers.status;
8   
9   import org.astrogrid.query.QueryState;
10  import org.astrogrid.status.DefaultTaskStatus;
11  
12  /***
13   * Records the status and past activity of a querier
14   */
15  
16  public abstract class QuerierStatus extends DefaultTaskStatus
17  {
18  
19     
20     /*** A constructor makes a status from a previous status.  This means
21      * we can carry previous information along with it
22      *
23     public QuerierStatus(Querier querier) {
24        if ( (querier!= null) && (querier.getStatus() != null)) {
25           //copy in old details to new ones
26           String[] oldDetails = querier.getStatus().getDetails();
27           for (int i=0;i<oldDetails.length;i++) { addDetail(oldDetails[i]); }
28           id = querier.getId();
29        }
30     }
31  
32     /** Initial constructor - should only be called by subclasses that form
33      * the beginning of the task status chain (see 'previous')*/
34     protected QuerierStatus() {
35     }
36  
37     /*** Constructor from a previous status */
38     protected QuerierStatus(QuerierStatus oldStatus, String newStage) {
39        super(oldStatus, newStage);
40     }
41     
42     /*** Returns true if this status should come before the given status */
43     public boolean isBefore(QuerierStatus status)
44     {
45        return this.getState().getOrder() < status.getState().getOrder();
46     }
47  
48     /*** Subclasses should return the appropriate enumerated state */
49     public abstract QueryState getState();
50     
51     public String toString() {
52        return getState().toString();
53     }
54     
55     /*** Returns a full human-readable message string */
56     public String asFullMessage() {
57        StringBuffer s = new StringBuffer(getState().toString()+": "+getMessage()+" ("+getProgressMsg()+")");
58        String[] details = getDetails();
59        for (int i = 0; i < details.length; i++) {
60           s.append("\n"+details[i]);
61        }
62        return s.toString();
63     }
64     
65     /*** Start a new progress with the given descriptive note and max value for pos
66      * (leave max -1 if unknown) */
67     public void newProgress(String note, long max) {
68        setProgressText(note);
69        setProgressMax(max);
70        setProgress(-1);
71     }
72     
73     /*** Resets the progress message to nothing - ie clears it */
74     public void clearProgress() {
75        newProgress("", -1);
76     }
77  
78     
79  }
80  
81  /*
82  $Log: QuerierStatus.java,v $
83  Revision 1.1.1.1  2005/02/17 18:37:35  mch
84  Initial checkin
85  
86  Revision 1.1.1.1  2005/02/16 17:11:24  mch
87  Initial checkin
88  
89  Revision 1.10.2.4  2004/11/26 18:17:21  mch
90  More status persisting, browsing and aborting
91  
92  Revision 1.10.2.3  2004/11/25 18:33:43  mch
93  more status (incl persisting) more tablewriting lots of fixes
94  
95  Revision 1.10.2.2  2004/11/24 20:59:37  mch
96  doc fixes and added slinger browser
97  
98  Revision 1.10.2.1  2004/11/22 00:57:16  mch
99  New interfaces for SIAP etc and new slinger package
100 
101 Revision 1.10  2004/11/11 20:42:50  mch
102 Fixes to Vizier plugin, introduced SkyNode, started SssImagePlugin
103 
104 Revision 1.9  2004/11/08 23:15:38  mch
105 Various fixes for SC demo, more store browser, more Vizier stuff
106 
107 Revision 1.8  2004/11/08 15:03:23  mch
108 Added doc
109 
110 Revision 1.7  2004/11/03 00:17:56  mch
111 PAL_MCH Candidate 2 merge
112 
113 Revision 1.3.10.2  2004/11/01 15:04:58  mch
114 Fix to progress pos update
115 
116 Revision 1.3.10.1  2004/10/20 18:12:45  mch
117 CEA fixes, resource tests and fixes, minor navigation changes
118 
119 Revision 1.3.12.1  2004/10/20 12:43:28  mch
120 Fixes to CEA interface to write directly to target
121 
122 Revision 1.3  2004/10/05 14:57:01  mch
123 Added queued
124 
125 Revision 1.2  2004/10/01 18:04:59  mch
126 Some factoring out of status stuff, added monitor page
127 
128 Revision 1.1  2004/09/28 15:02:13  mch
129 Merged PAL and server packages
130 
131 Revision 1.3  2004/09/01 21:37:59  mch
132 Fixes for Servlets, more servlets and better and nicer status reports
133 
134 Revision 1.2  2004/03/15 19:16:12  mch
135 Lots of fixes to status updates
136 
137 Revision 1.1  2004/03/12 04:45:26  mch
138 It05 MCH Refactor
139 
140  */
141