public class ScriptManager
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
ScriptManager.ComboBoxRenderer |
Modifier and Type | Field and Description |
---|---|
static org.apache.log4j.Logger |
log
Used for logging.
|
static java.util.concurrent.locks.ReentrantReadWriteLock |
SCRIPT_TEXT_LOCK
A lock used to get script text.
|
Constructor and Description |
---|
ScriptManager() |
Modifier and Type | Method and Description |
---|---|
static Script |
addNewScript(Folder folder)
Adds a new blank script.
|
static void |
addRecentScript(Script script)
Adds a recently used script.
|
static void |
addScript(Script script)
Adds a
Script |
static void |
dumpToLog()
Dumps all of the scripts to the log.
|
static java.util.HashSet |
extractInvokedScriptsFromScrapingSession(ScrapingSession scrapingSession)
Extracts
Scripts invoked in the given ScrapingSession and returns them. |
static void |
generateScriptsComboBox(java.lang.String forScrapingSession)
Generates (or re-generates) the JComboBox that holds all of the scripts.
|
static java.util.concurrent.ExecutorService |
getExecutorService()
Gets a reference to the executor service.
|
static Script |
getMostRecentScript()
Gets the most recently accessed script.
|
static int |
getNumScripts()
Gets the number of
Script s held by the manager. |
static int |
getNumScriptsWithName(java.lang.String scriptName)
Gets the number of scripts carrying the given name.
|
static Script |
getScript(int scriptID)
I'm probably just being lazy, but this allows easy access to any of the scripts,
|
static Script |
getScript(java.lang.String scriptName)
I'm probably just being lazy, but this allows easy access to any of the scripts,
|
static Script |
getScriptBySequence(int sequence)
Gets a
Script based on a sequence, assuming the scraping sessions are sorted alphabetically. |
static java.util.Set<Script> |
getScripts()
Gets a
HashSet of Script objects. |
static java.util.TreeSet<Script> |
getScriptsAsTreeSet()
Returns a sorted
TreeSet containing the Script objects. |
static javax.swing.JComboBox |
getScriptsComboBox(java.lang.String forScrapingSession)
Gets a reference to the JComboBox holding all of the scripts.
|
static java.util.Iterator |
getScriptsIterator()
Returns an
Iterator over which the scripts can be cycled. |
static int |
getSequenceForScript(Script script)
Gets the sequence for a script.
|
static void |
hotSwapScriptsFromDatabase()
Hot swaps scripts by loading them from the database.
|
static void |
hotSwapScriptsFromFiles()
Checks for existing scripts in the "import" directory, and if they exist, hot swaps them in.
|
static boolean |
importScript(Script script,
Folder folder,
boolean promptForOverwrite) |
static int |
importScripts(java.util.HashSet<Script> scripts,
Folder folder,
boolean promptForOverwrite)
Iterates through and imports scripts.
|
static void |
loadScripts()
Loads the model with all scripts found in the database.
|
static void |
removeAllScripts()
Removes all scripts.
|
static void |
removeScript(Script script)
Removes a
Script and any corresponding ScriptInstance objects. |
static void |
removeScriptInstances(ScriptInstances scriptInstances,
Script script)
Removes any
ScriptInstance objects found within the given ScriptInstances object corresponding to the given Script object. |
static void |
replaceScript(Script script)
Replaces the script (if found) with the name matching the given one.
|
static void |
replaceScriptsOnScrapingSession(ScrapingSession scrapingSession)
After the user has imported a scraping session they may have elected to not import some of the scripts associated with the scraping session.
|
static void |
saveScripts()
Saves all scripts.
|
public static java.util.concurrent.locks.ReentrantReadWriteLock SCRIPT_TEXT_LOCK
public static org.apache.log4j.Logger log
public static Script getScript(int scriptID)
scriptID
- The ID of the desired script.Script
.public static Script getScript(java.lang.String scriptName)
scriptName
- The name of the desired script.Script
.public static int getNumScriptsWithName(java.lang.String scriptName)
scriptName
- The name of the desired script.@NotNull public static java.util.Set<Script> getScripts()
HashSet
of Script
objects.public static void removeAllScripts()
public static int getNumScripts()
Script
s held by the manager.public static java.util.TreeSet<Script> getScriptsAsTreeSet()
TreeSet
containing the Script
objects.TreeSet
.public static java.util.Iterator getScriptsIterator()
Iterator
over which the scripts can be cycled.Iterator
.public static int getSequenceForScript(@NotNull Script script)
script
- The Script
.public static Script getScriptBySequence(int sequence)
Script
based on a sequence, assuming the scraping sessions are sorted alphabetically.sequence
- The sequence corresponding to the desired Script
.Script
if the sequence is valid. Returns null, otherwise.public static void addScript(@Nullable Script script)
Script
script
- The Script
to be added.@NotNull public static Script addNewScript(Folder folder)
folder
- The folder that will contain the new script.public static void loadScripts()
public static void removeScriptInstances(@NotNull ScriptInstances scriptInstances, @Nullable Script script)
ScriptInstance
objects found within the given ScriptInstances
object corresponding to the given Script
object.scriptInstances
- The ScriptInstances
.script
- The Script
to match.public static void removeScript(@NotNull Script script)
Script
and any corresponding ScriptInstance
objects.script
- The Script
to remove.public static void saveScripts()
public static void replaceScript(@NotNull Script script)
script
- The Script
to replace.public static void hotSwapScriptsFromFiles()
public static void hotSwapScriptsFromDatabase()
public static boolean importScript(Script script, Folder folder, boolean promptForOverwrite) throws ImportScriptException
script
- Script to importfolder
- The Folder
to contain the scriptpromptForOverwrite
- True if a prompt should be shown for overwriting existing script, false otherwiseImportScriptException
- On import errorpublic static int importScripts(@NotNull java.util.HashSet<Script> scripts, Folder folder, boolean promptForOverwrite) throws ImportScriptException
scripts
- HashSet