Klasse DUUIProcessController
java.lang.Object
org.texttechnologylab.duui.api.controllers.processes.DUUIProcessController
A Controller for database operations related to the processes collection.
- Autor:
- Cedric Borkowski
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic void
deleteMany
(org.bson.conversions.Bson filter) Delete all processes matching a given filter.static boolean
Delete a process and all documents and events referencing this process.static boolean
deleteTempOutputDirectory
(File directory) A utility function that recursively deletes the content of a folder and the folder itself.static InputStream
downloadFile
(org.texttechnologylab.DockerUnifiedUIMAInterface.document_handler.IDUUIDocumentHandler handler, String path) Download a file from a cloud storage given the handler and path to the file.static org.bson.Document
findMany
(MongoDBFilters filters) Retrieve one or more processes from the database given a userId andMongoDBFilters
to sort and filter the results.static org.bson.Document
findOneById
(String id) Find one process given its id.static List
<IDUUIProcessHandler> Get a list of all active processesstatic List
<IDUUIProcessHandler> getActiveProcesses
(String pipelineId) Get all active processes for a given pipeline.static org.texttechnologylab.DockerUnifiedUIMAInterface.document_handler.IDUUIDocumentHandler
getHandler
(String provider, String providerId, String userId) Constructs a IDUUIDocumentHandler given aProvider
as a String.static String
getLanguageCode
(String language) Get the language code for a given language.getProcessSummaryForEmail
(String processId) Get the summary of a process for an email.static void
insertAnnotations
(String processId, Set<org.texttechnologylab.DockerUnifiedUIMAInterface.document_handler.DUUIDocument> documents) Store the annotations in the document in the database.static org.bson.Document
mergeSettings
(org.bson.Document settings) Given aDocument
of settings for a process, compare to the default settings by filling out missing values and checking invalid entries.static void
removeProcess
(String id) Remove a process from the active processes map.static void
setDocumentPaths
(String id, Set<String> documentPaths) static void
Set an error for a process.static void
setFinished
(String id, boolean finished) Mark a process as finished.static void
setFinishedAt
(String id) Sets the finished_at field of a process to the current time.static void
setFinishedAt
(String id, long endTime) Sets the finished_at field of a process to the specified time.static void
setInstantiationDuration
(String id, long instantiationDuration) Update the instantiation duration for a process.static void
setProgress
(String id, int progress) Set the progress of a process to a new value.static void
Update the status of a process.static org.bson.Document
start
(org.bson.Document pipeline, org.bson.Document settings, DUUIDocumentProvider input, DUUIDocumentProvider output) Start and insert a new process.static String
Stop an active process.static com.mongodb.client.result.UpdateResult
Update a process by setting the key value pair.static void
updatePipelineStatus
(String id, Map<String, String> pipelineStatus) Update the status of a pipeline from the pipeline_status property of a process.
-
Konstruktordetails
-
DUUIProcessController
public DUUIProcessController()
-
-
Methodendetails
-
getLanguageCode
Get the language code for a given language.- Parameter:
language
- The language to get the code for.- Gibt zurück:
- the language code.
-
mergeSettings
public static org.bson.Document mergeSettings(org.bson.Document settings) Given aDocument
of settings for a process, compare to the default settings by filling out missing values and checking invalid entries.- Parameter:
settings
- the user defined settings for a process.- Gibt zurück:
- the settings with added missing entries.
-
findOneById
Find one process given its id.- Parameter:
id
- The id of the process.- Gibt zurück:
- the process or null.
-
findMany
Retrieve one or more processes from the database given a userId andMongoDBFilters
to sort and filter the results.- Parameter:
filters
- AMongoDBFilters
object that contains filter options.- Gibt zurück:
- A Document containing a list of matched processes.
-
updateOne
Update a process by setting the key value pair.- Parameter:
id
- The id of the processkey
- The field namevalue
- The updated value of the field- Gibt zurück:
- The result of the update.
-
deleteOne
Delete a process and all documents and events referencing this process.- Parameter:
id
- The id of the process.- Gibt zurück:
- if the process has been deleted successfully.
-
start
public static org.bson.Document start(org.bson.Document pipeline, org.bson.Document settings, DUUIDocumentProvider input, DUUIDocumentProvider output) throws URISyntaxException, IOException, InsufficientWorkersException, InvalidIOException Start and insert a new process.- Parameter:
pipeline
- The pipeline to execute.settings
- The settings for the process. SeegetDefaultSettings()
- Gibt zurück:
- if the process has been found and stopped.
- Löst aus:
URISyntaxException
IOException
InsufficientWorkersException
InvalidIOException
-
stop
Stop an active process.- Parameter:
id
- The id of the process to stop.- Gibt zurück:
- null if the process or pipeline was not found else a confirmation message.
-
updatePipelineStatus
Update the status of a pipeline from the pipeline_status property of a process.- Parameter:
id
- The process' id that holds the property.pipelineStatus
- the new pipeline status.
-
removeProcess
Remove a process from the active processes map.- Parameter:
id
- The process' id
-
setStatus
Update the status of a process.- Parameter:
id
- The id of the process.status
- The new statusDUUIStatus
-
setProgress
Set the progress of a process to a new value.- Parameter:
id
- The id of the process to update.progress
- The new progress value.
-
setFinishedAt
Sets the finished_at field of a process to the current time.- Parameter:
id
- The id of the process.
-
setFinishedAt
Sets the finished_at field of a process to the specified time.- Parameter:
id
- The id of the process.endTime
- The timestamp the process has finished at.
-
setFinished
Mark a process as finished.- Parameter:
id
- The id of the process.finished
- A flag that indicates if the process is finished.
-
setError
Set an error for a process.- Parameter:
id
- The id of the process.error
- The error that occurred.
-
setDocumentPaths
-
setInstantiationDuration
Update the instantiation duration for a process.- Parameter:
id
- The id of the process.instantiationDuration
- The duration it took for the pipeline executed by the process to be instantiated.
-
deleteMany
public static void deleteMany(org.bson.conversions.Bson filter) Delete all processes matching a given filter. Also deletes all documents and events that reference this process.- Parameter:
filter
- ABson
filter to delete only selected processes
-
insertAnnotations
public static void insertAnnotations(String processId, Set<org.texttechnologylab.DockerUnifiedUIMAInterface.document_handler.DUUIDocument> documents) Store the annotations in the document in the database.- Parameter:
processId
- The id of the process the documents are analyzed in.documents
- The documents containing annotation.
-
getActiveProcesses
Get a list of all active processes- Gibt zurück:
- a list of
IDUUIProcessHandler
s
-
getActiveProcesses
Get all active processes for a given pipeline.- Parameter:
pipelineId
- The id of the pipeline.- Gibt zurück:
- A List of
IDUUIProcessHandler
s.
-
getHandler
public static org.texttechnologylab.DockerUnifiedUIMAInterface.document_handler.IDUUIDocumentHandler getHandler(String provider, String providerId, String userId) throws com.dropbox.core.DbxException, GeneralSecurityException, IOException Constructs a IDUUIDocumentHandler given aProvider
as a String.- Parameter:
provider
- The type of provider to construct.userId
- The id of the user that requested the handler.- Gibt zurück:
- the created DocumentHandler.
- Löst aus:
com.dropbox.core.DbxException
- if incorrect credentials for Dropbox are provided.GeneralSecurityException
IOException
-
deleteTempOutputDirectory
A utility function that recursively deletes the content of a folder and the folder itself.- Parameter:
directory
- The folder to delete.- Gibt zurück:
- if the deletion was successful.
-
downloadFile
public static InputStream downloadFile(org.texttechnologylab.DockerUnifiedUIMAInterface.document_handler.IDUUIDocumentHandler handler, String path) throws IOException Download a file from a cloud storage given the handler and path to the file.- Parameter:
handler
- an instance of anIDUUIDocumentHandler
path
- the absolute path to the file in the cloud storage.- Gibt zurück:
- an
InputStream
with the file contents. - Löst aus:
IOException
- when the file is not found or an error occurs while reading.
-
getProcessSummaryForEmail
Get the summary of a process for an email.- Parameter:
processId
- The id of the process.- Gibt zurück:
- an
Optional
of the summary. - Löst aus:
IOException
- when the template file is not found.
-