1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.job.event.status

File JobStatus.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart0.png
86% of files have more coverage

Code metrics

0
7
6
2
189
54
6
0.86
1.17
3
1

Classes

Class Line # Actions
JobStatus 37 7 0% 6 13
0.00%
JobStatus.State 44 0 - 0 0
-1.0 -
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.job.event.status;
21   
22    import java.util.Date;
23    import java.util.List;
24    import java.util.concurrent.TimeUnit;
25   
26    import org.xwiki.job.Request;
27    import org.xwiki.logging.LogLevel;
28    import org.xwiki.logging.LogQueue;
29    import org.xwiki.logging.event.LogEvent;
30   
31    /**
32    * Describe the current status of a job.
33    *
34    * @version $Id: 0e3756b805493a004ce96ee70fc17b7e893ab1c2 $
35    * @since 4.0M1
36    */
 
37    public interface JobStatus
38    {
39    /**
40    * Job status.
41    *
42    * @version $Id: 0e3756b805493a004ce96ee70fc17b7e893ab1c2 $
43    */
 
44    enum State
45    {
46    /**
47    * Default status, generally mean that the task has not been started yet.
48    */
49    NONE,
50   
51    /**
52    * The job is running.
53    */
54    RUNNING,
55   
56    /**
57    * The job is waiting.
58    */
59    WAITING,
60   
61    /**
62    * The job is done.
63    */
64    FINISHED
65    }
66   
67    /**
68    * @return the type of the job
69    * @since 9.2RC1
70    */
 
71  0 toggle default String getJobType()
72    {
73  0 return null;
74    }
75   
76    /**
77    * @return the general state of the job
78    */
79    State getState();
80   
81    /**
82    * @return the {@link Throwable} on which the job stopped
83    * @since 8.1RC1
84    */
 
85  0 toggle default Throwable getError()
86    {
87  0 return null;
88    }
89   
90    /**
91    * @return the job request provided when starting it
92    */
93    Request getRequest();
94   
95    /**
96    * @return the log sent during job execution
97    */
98    LogQueue getLog();
99   
100    /**
101    * @return progress information about the job (percent, etc.)
102    */
103    JobProgress getProgress();
104   
105    /**
106    * @param question the question to ask as a Java bean
107    * @throws InterruptedException if the current thread is interrupted (and interruption of thread suspension is
108    * supported)
109    * @since 4.0M2
110    */
111    void ask(Object question) throws InterruptedException;
112   
113    /**
114    * @param question the question to ask as a Java bean
115    * @param time the maximum time to wait
116    * @param unit the time unit of the {@code time} argument
117    * @return {@code false} if the waiting time detectably elapsed before return from the method, else {@code true}
118    * @throws InterruptedException if the current thread is interrupted (and interruption of thread suspension is
119    * supported)
120    * @since 9.1RC1
121    */
 
122  0 toggle default boolean ask(Object question, long time, TimeUnit unit) throws InterruptedException
123    {
124  0 ask(question);
125   
126  0 return true;
127    }
128   
129    /**
130    * @param unit the time unit of the returned value
131    * @return the time left before the question timeout
132    * @since 10.2
133    */
 
134  0 toggle default long getQuestionTimeLeft(TimeUnit unit)
135    {
136  0 return -1;
137    }
138   
139    /**
140    * @return the question
141    * @since 4.0M2
142    */
143    Object getQuestion();
144   
145    /**
146    * Indicate that the question has been answered.
147    *
148    * @since 4.0M2
149    */
150    void answered();
151   
152    /**
153    * @return the date and time when the job has been started
154    */
155    Date getStartDate();
156   
157    /**
158    * @return the date and time when the job finished
159    */
160    Date getEndDate();
161   
162    /**
163    * @return true if the job status should be serialized
164    * @since 10.0
165    */
 
166  0 toggle default boolean isSerialized()
167    {
168  0 return true;
169    }
170   
171    /**
172    * @return true if the log should be isolated from standard output
173    * @since 10.0
174    */
 
175  0 toggle default boolean isIsolated()
176    {
177  0 return true;
178    }
179   
180    // Deprecated
181   
182    /**
183    * @param level the level of the log
184    * @return the log sent with the provided level
185    * @deprecated since 4.1RC1 use {@link LogQueue#getLogs(LogLevel)} instead
186    */
187    @Deprecated
188    List<LogEvent> getLog(LogLevel level);
189    }