public class Schedule extends DefaultTableModel implements GenericListener<ScheduleListener>, RepeatingScriptedExecutable, RefactoringCapable
TestSuite
and provides framework for I/O
operations, execution and displaying in the GUI.T-Plan Robot Enterprise, (C) 2009-2022 T-Plan Limited. All rights reserved.
Modifier and Type | Field and Description |
---|---|
static String |
SCHEDULER_HOME_DIR_NAME |
static String |
SCHEDULER_REPORT_DIR_SUFFIX |
EVENT_REPEATED_EXECUTION_COMPLETED
Modifier and Type | Method and Description |
---|---|
static void |
addGlobalScheduleListener(ScheduleListener l) |
void |
addScheduleListener(ScheduleListener l) |
void |
execute()
Execute the schedule.
|
void |
genericEvent(ScheduleListener listener,
EventObject event,
Object customObject)
Call the listener method on a particular listener.
|
int |
getBranchCount()
Find out how many branches the schedule contains.
|
int |
getColumnCount()
Implementation of
TableModel.getColumnCount() allowing to use the
schedule directly with JTable . |
Integer |
getCommandNo() |
static File |
getDefaultScheduleDir()
Get the default directory to store the schedule to.
|
long |
getEndTime() |
Thread |
getExecThread()
Get the execution thread.The method returns null if the schedule is not
executing.
|
int |
getExecutionCount()
Get the number of requested executions.
|
Integer |
getExecutionSeqNo()
Get the executor sequence number.
|
int |
getExitCode()
Get the schedule exit code to be returned to the underlying OS.
|
File |
getFile()
Get the file this schedule is stored to.
|
List<RefactoringTask> |
getFileMoveOrCopyRefactoringTasks(Map<File,File> changes)
Get the list of refactoring tasks for the argument map of file updates.
|
long |
getLastChanged() |
PrintStream |
getLogStream()
Get the log stream.
|
int |
getRowCount()
Implementation of
TableModel.getRowCount() allowing to use the
schedule directly with JTable . |
ScriptManager |
getScriptManager()
Get the script manager.
|
long |
getStartTime() |
List<File> |
getTemporaryFiles(File scriptFile)
Get the temporary files created by the script.
|
TestSuite |
getTestSuite()
Get the test suite (the sequence of tasks and their dependencies).
|
String |
getUid() |
Object |
getValueAt(int rowIndex,
int columnIndex)
Implementation of
TableModel.getValueAt(int, int) allowing to use
the schedule directly with JTable . |
boolean |
isAskForMandatoryInputParametersOnly()
Indicates whether the workitem is configured to pop up the input
parameter prompt always (
false ) or only when at least one
mandatory parameter is not populated. |
boolean |
isCellEditable(int rowIndex,
int columnIndex)
Implementation of
TableModel.isCellEditable(int, int) allowing to
use the schedule directly with JTable . |
boolean |
isChanged() |
boolean |
isExecuting()
Find out if the schedule is executing or not.
|
boolean |
isExecutingOrFinishing()
Test whether it is safe to exit, i.e.
|
boolean |
isPause()
Find out if the executable is executing and paused.
|
boolean |
isSchedule()
Indicate whether this object is a workitem or a schedule (i.e.
|
boolean |
isStop()
Find out if the executable was stopped.
|
void |
read(File descriptor) |
void |
read(InputStream stream) |
void |
read(String content)
Read the schedule from a string.
|
void |
refactoringCompleted()
Called after the refactoring of the tasks returned by the implementing
object gets successfully completed.
|
static Object |
removeGlobalScheduleListener(ScheduleListener l) |
Object |
removeScheduleListener(ScheduleListener l) |
void |
saveAs(File target)
Save the schedule to an XML file.
|
void |
saveAs(File target,
boolean resetUid) |
void |
setAskForMandatoryInputParametersOnly(boolean askMandatoryOnly)
Configure the workitem to pop up the input parameter prompt always
(
false ) or only when at least one mandatory parameter is not
populated. |
void |
setCommandNo(Integer commandNo) |
void |
setExecutionCount(Integer count)
Set the number of requested executions.
|
void |
setFile(File f)
Set the target schedule file.
|
void |
setLogStream(PrintStream logStream)
Set the log stream.
|
void |
setPause(Object source,
boolean pause,
String reason)
Request to pause the executing object.
|
void |
setScriptManager(ScriptManager scriptManager)
Set the script manager.
|
void |
setStop(Object source,
boolean stop,
boolean isManual,
String manualStopJustification)
Request to stop the executing object.
|
String |
toString(boolean indented)
Export the schedule to an XML string.
|
static String |
toString(Document doc) |
static String |
toString(Document doc,
boolean indent) |
Document |
toXML() |
addColumn, addColumn, addColumn, addRow, addRow, getColumnName, getDataVector, insertRow, insertRow, moveRow, newDataAvailable, newRowsAdded, removeRow, rowsRemoved, setColumnCount, setColumnIdentifiers, setColumnIdentifiers, setDataVector, setDataVector, setNumRows, setRowCount, setValueAt
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListener
public static final String SCHEDULER_HOME_DIR_NAME
public static final String SCHEDULER_REPORT_DIR_SUFFIX
public Schedule()
public Schedule(String name)
public void read(File descriptor) throws ParserConfigurationException, SAXException, IOException
public void read(InputStream stream) throws ParserConfigurationException, SAXException, IOException
public void read(String content) throws ParserConfigurationException, SAXException, IOException
content
- the schedule XML descriptor.ParserConfigurationException
- on parser configuration error.SAXException
- on SAX error.IOException
- on I/O error.public static String toString(Document doc) throws IOException
IOException
public static String toString(Document doc, boolean indent) throws IOException
IOException
public Document toXML()
public String toString(boolean indented) throws IOException
indented
- true to indent the code to make it human readable.IOException
- on an I/O error.public TestSuite getTestSuite()
public int getBranchCount()
public boolean isCellEditable(int rowIndex, int columnIndex)
TableModel.isCellEditable(int, int)
allowing to
use the schedule directly with JTable
.isCellEditable
in interface TableModel
isCellEditable
in class DefaultTableModel
rowIndex
- row index.columnIndex
- column index.public int getRowCount()
TableModel.getRowCount()
allowing to use the
schedule directly with JTable
.getRowCount
in interface TableModel
getRowCount
in class DefaultTableModel
public int getColumnCount()
TableModel.getColumnCount()
allowing to use the
schedule directly with JTable
.getColumnCount
in interface TableModel
getColumnCount
in class DefaultTableModel
public Object getValueAt(int rowIndex, int columnIndex)
TableModel.getValueAt(int, int)
allowing to use
the schedule directly with JTable
.getValueAt
in interface TableModel
getValueAt
in class DefaultTableModel
rowIndex
- row index.columnIndex
- column index.TestSuite
or Task
.public File getFile()
read(java.io.File)
,
saveAs(java.io.File)
of setFile(java.io.File)
method.
If none of the methods has been called the method returns null.public static File getDefaultScheduleDir()
schedules/
folder in the project home
folder. If no project is open the method returns the
<USER_HOME>/schedules
folder. As there's no guarantee
that the returned location exists the class that wants to save the
schedule to it must call File.mkdirs()
to ensure it gets created.public void saveAs(File target) throws IOException
target
- the target file. If it is relative it will be resolved
against the default schedule home directory returned by
getDefaultScheduleDir()
.IOException
- on an I/O error.public void saveAs(File target, boolean resetUid) throws IOException
IOException
public void setFile(File f)
saveAs(java.io.File)
.f
- a new file.public void setExecutionCount(Integer count)
RepeatingScriptedExecutable
setExecutionCount
in interface RepeatingScriptedExecutable
count
- the number of executions.public int getExecutionCount()
RepeatingScriptedExecutable
getExecutionCount
in interface RepeatingScriptedExecutable
public void execute()
IllegalStateException
- if the schedule is already executing or
cleaning up after execution. To test whether it's safe to execute the
schedule use the isExecutingOrFinishing()
method.public Thread getExecThread()
public boolean isExecuting()
isExecuting
in interface ScriptedExecutable
public boolean isExecutingOrFinishing()
public Integer getExecutionSeqNo()
public boolean isStop()
ScriptedExecutable
isStop
in interface ScriptedExecutable
public void setStop(Object source, boolean stop, boolean isManual, String manualStopJustification)
ScriptedExecutable
setStop
in interface ScriptedExecutable
source
- source of the request (for tracking purposes).stop
- true to request stop, false to reset the stop flag.isManual
- true if the stop is manual/user requested (for tracking
purposes).manualStopJustification
- optional stop justification.public void setPause(Object source, boolean pause, String reason)
ScriptedExecutable
setPause
in interface ScriptedExecutable
source
- source of the request (for tracking purposes).pause
- true to request pause, false to reset the pause flag.reason
- optional pause justification.public boolean isPause()
ScriptedExecutable
isPause
in interface ScriptedExecutable
public void addScheduleListener(ScheduleListener l)
public Object removeScheduleListener(ScheduleListener l)
public static void addGlobalScheduleListener(ScheduleListener l)
public static Object removeGlobalScheduleListener(ScheduleListener l)
public void genericEvent(ScheduleListener listener, EventObject event, Object customObject)
GenericListener
ChangeListener
the method should call
listener.stateChanged((ChangeEvent)event)
. This method will
be called by the GenericListenerSupport.fireEvent(com.tplan.robot.util.GenericListener, java.util.EventObject, java.lang.Object)
method for each registered listener.genericEvent
in interface GenericListener<ScheduleListener>
listener
- the registered listener.event
- an event to fire to the listener. The implementing class should
check whether it is an appropriate event matching the listener type and
throw an IllegalArgumentException
if not. For example, if the listener
is a ChangeListener
the event must be a ChangeEvent
.customObject
- an optional object allowing the implementing class to transfer
data between individual call of this method. For example, the argument may be a
List where the method will store all exceptions thrown by the listener to.public boolean isChanged()
public long getStartTime()
public long getEndTime()
public ScriptManager getScriptManager()
MainFrame.getScriptHandler()
method. For CLI mode the calling
AutomatedRunnable
must set the script manager through
setScriptManager(com.tplan.robot.scripting.ScriptManager)
prior
to executing the schedule.public void setScriptManager(ScriptManager scriptManager)
scriptManager
- the script manager instance to be used for schedule
execution.public PrintStream getLogStream()
public void setLogStream(PrintStream logStream)
logStream
- the CLI execution log stream.public List<RefactoringTask> getFileMoveOrCopyRefactoringTasks(Map<File,File> changes)
RefactoringCapable
getFileMoveOrCopyRefactoringTasks
in interface RefactoringCapable
changes
- a map of [newFile, oldFile] pairs identifying the files
that were moved or copied.public List<File> getTemporaryFiles(File scriptFile)
RefactoringCapable
Get the temporary files created by the script. For example, a Java test script may have one or more .class files in the classes/ folder. A TPR script may also produce .class files resulting from a compilation of a Java code block.
The method should work even if the script source code hasn't been loaded yet. Rather than caching the list of created files and returning it the method should query the local file system and search the usual locations for files that meet a certain pattern. For example, a Java test script may expect that the /classes folder will contain the compiled code as one or more .class files of known name or name pattern.
getTemporaryFiles
in interface RefactoringCapable
scriptFile
- optional script file to be used when the test script
interpret hasn't been associated with a file (URI) yet. If the argument
is null the interpret must default to the file returned by TestScriptInterpret.getURI()
.public void refactoringCompleted()
RefactoringCapable
refactoringCompleted
in interface RefactoringCapable
public String getUid()
public long getLastChanged()
public Integer getCommandNo()
public void setCommandNo(Integer commandNo)
commandNo
- the commandNo to setpublic int getExitCode()
public boolean isSchedule()
public boolean isAskForMandatoryInputParametersOnly()
false
) or only when at least one
mandatory parameter is not populated.public void setAskForMandatoryInputParametersOnly(boolean askMandatoryOnly)
false
) or only when at least one mandatory parameter is not
populated.askMandatoryOnly
- false/true to display the input parameter prompt
always/on missing mandatory params only.