public abstract class TaskHandler extends Object implements Runnable
Task
class.
TaskHandler task = new TaskHandler(TaskTest.class.toString(), "Task name", "The task description", "http://0.0.0.0:8081/") {
@Override
public void run() {
try {
// here comes the code to run
finish(); //saves task to COMPLETED, SAVED and 100%
} catch (YourException e) {
e.printStackTrace();
}
}
};
task.start(); //run the task
Modifier | Constructor and Description |
---|---|
protected |
TaskHandler(String creator,
String title,
String description,
String baseuri) |
Modifier and Type | Method and Description |
---|---|
void |
cancel()
To cancel a task after it was started
interupts thread and set hasStatus to Task.Status.CANCELLED
|
void |
delete()
Delete task in mongodb
|
void |
finish()
Call at end of task to
set percentageCompleted = 100, hasStatus = Task.Status.CANCELLED, step = Task.Step.SAVED
update task in mongodb
|
Date |
getDate() |
String |
getDescription() |
ErrorReport |
getErrorReport() |
Float |
getPercentageCompleted() |
String |
getResultURI() |
Task.Status |
getStatus() |
Task.Step |
getStep() |
String |
getTaskID() |
String |
getTitle() |
String |
getURI() |
void |
setDescription(String description) |
protected void |
setErrorReport(Exception e,
Integer http_code,
String actor)
Create an error report for a failed task
|
void |
setPercentageCompleted(Float percentageCompleted) |
protected void |
setResultURI(String resultURI) |
void |
setState(Task.Step step,
float percentageComplete) |
void |
setStatus(Task.Status status) |
void |
setTaskID(String id) |
void |
setTitle(String title) |
void |
setURI(String URI) |
void |
start()
Starts task, set hasStatus to RUNNING and percentageCompleted to 0
saves the Task task to mongodb
|
public void start()
public void setState(Task.Step step, float percentageComplete)
public void cancel()
public void finish()
public String getURI()
public void setURI(String URI)
public Task.Status getStatus()
public void setStatus(Task.Status status)
public Date getDate()
public String getTitle()
public void setTitle(String title)
public String getDescription()
public void setDescription(String description)
public Float getPercentageCompleted()
public void setPercentageCompleted(Float percentageCompleted)
public Task.Step getStep()
public String getResultURI()
protected void setResultURI(String resultURI)
public String getTaskID()
public void setTaskID(String id)
public ErrorReport getErrorReport()
protected void setErrorReport(Exception e, Integer http_code, String actor)
e
- Exceptionhttp_code
- http codeactor
- calling methodpublic void delete()
Copyright © 2018. All rights reserved.