Package com.logicaldoc.core.task

# Class Task

java.lang.Object
com.logicaldoc.core.task.Task

All Implemented Interfaces:
  `Runnable`

Direct Known Subclasses:
  `AbstractDocumentProcessor`, `IndexOptimizer`, `PathCalculator`, `StatsCollector`, `TagsProcessor`

public abstract class Task extends Object implements Runnable
A task is a long running process that is fired regularly

Since:
  3.5.0
Author:
  Marco Meschieri - LogicalDOC

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`STATUS_IDLE`
`static final int`
`STATUS_RUNNING`
`static final int`
`STATUS_STOPPING`

## Method Summary

Modifier and Type
Method
Description
`void`
`addTaskListener(TaskListener listener)`
`int`
`getCompletionPercentage()`
The percentage of completion(1-100)
`ContextProperties`
`getConfig()`
`String`
`getName()`
`long`
`getProgress()`
The current processing step
`String`
`getReportRecipients()`
`TaskScheduling`
`getScheduling()`
Scheduling policies
`long`
`getSize()`
The the total size of the processing(number of units of work)
`int`
`getStatus()`
The task status.
`void`
`interrupt()`
`abstract boolean`
`isConcurrent()`
Concrete implementations must override this method declaring if the task supports multiple instances running concurrently.
`abstract boolean`
`isIndeterminate()`
Concrete implementations must override this method declaring if the task is indeterminate.
`boolean`
`isInterrupted()`
`boolean`
`isInterruptRequested()`
`boolean`
`isRunning()`
Check if the task is currently running
`boolean`
`isSendActivityReport()`
`void`
`notifyReport()`
`void`
`removeTaskListener(TaskListener listener)`
`void`
`run()`
`void`
`save()`
Saves the task configuration
`void`
`saveWork()`
Concrete implementations must insert here the code needed to save the elaboration state in a persistent store
`void`
`setReportRecipients(String reportRecipients)`
`void`
`setSendActivityReport(boolean sendActivityReport)`
`void`
`setSize(long size)`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### STATUS_IDLE

public static final int STATUS_IDLE

See Also:
  - Constant Field Values

### STATUS_RUNNING

public static final int STATUS_RUNNING

See Also:
  - Constant Field Values

### STATUS_STOPPING

public static final int STATUS_STOPPING

See Also:
  - Constant Field Values

## Method Details

### getName

public String getName()

### run

public void run()

Specified by:
  `run` in interface `Runnable`

### interrupt

public void interrupt()

### isInterrupted

public boolean isInterrupted()

### getSize

public long getSize()
The the total size of the processing(number of units of work)

Returns:
  total number of steps

### setSize

public void setSize(long size)

### getStatus

public int getStatus()
The task status.

Returns:
  the status
See Also:
  - `STATUS_IDLE`
  - `STATUS_RUNNING`
  - `STATUS_STOPPING`

### getProgress

public long getProgress()
The current processing step

Returns:
  the current step

### getCompletionPercentage

public int getCompletionPercentage()
The percentage of completion(1-100)

Returns:
  a percentage(1-100)

### isRunning

public boolean isRunning()
Check if the task is currently running

Returns:
  true if the task is running(`STATUS_RUNNING`)

### saveWork

public void saveWork()
Concrete implementations must insert here the code needed to save the elaboration state in a persistent store

### getScheduling

public TaskScheduling getScheduling()
Scheduling policies

Returns:
  the scheduling policies

### addTaskListener

public void addTaskListener(TaskListener listener)

### removeTaskListener

public void removeTaskListener(TaskListener listener)

### notifyReport

public void notifyReport()

### isIndeterminate

public abstract boolean isIndeterminate()
Concrete implementations must override this method declaring if the task is indeterminate. An indeterminate task is not able to compute it's time length

Returns:
  true if the task is indeterminate

### isConcurrent

public abstract boolean isConcurrent()
Concrete implementations must override this method declaring if the task supports multiple instances running concurrently. tHIbernat

Returns:
  true if the task is concurrent

### getReportRecipients

public String getReportRecipients()

### getConfig

public ContextProperties getConfig()

### save

public void save() throws IOException, ParseException
Saves the task configuration

Throws:
  `ParseException` - raised if the configuration cannot be parsed
  `IOException` - raised if the configuration cannot be written

### isSendActivityReport

public boolean isSendActivityReport()

### setSendActivityReport

public void setSendActivityReport(boolean sendActivityReport)

### setReportRecipients

public void setReportRecipients(String reportRecipients)

### isInterruptRequested

public boolean isInterruptRequested()