Klasse DUUIProcessController

java.lang.Object
org.texttechnologylab.duui.api.controllers.processes.DUUIProcessController

public class DUUIProcessController extends Object
A Controller for database operations related to the processes collection.
Autor:
Cedric Borkowski
  • Konstruktordetails

    • DUUIProcessController

      public DUUIProcessController()
  • Methodendetails

    • getLanguageCode

      public static String getLanguageCode(String language)
      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 a Document 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

      public static org.bson.Document findOneById(String id)
      Find one process given its id.
      Parameter:
      id - The id of the process.
      Gibt zurück:
      the process or null.
    • findMany

      public static org.bson.Document findMany(MongoDBFilters filters)
      Retrieve one or more processes from the database given a userId and MongoDBFilters to sort and filter the results.
      Parameter:
      filters - A MongoDBFilters object that contains filter options.
      Gibt zurück:
      A Document containing a list of matched processes.
    • updateOne

      public static com.mongodb.client.result.UpdateResult updateOne(String id, String key, Object value)
      Update a process by setting the key value pair.
      Parameter:
      id - The id of the process
      key - The field name
      value - The updated value of the field
      Gibt zurück:
      The result of the update.
    • deleteOne

      public static boolean deleteOne(String id)
      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. See getDefaultSettings()
      Gibt zurück:
      if the process has been found and stopped.
      Löst aus:
      URISyntaxException
      IOException
      InsufficientWorkersException
      InvalidIOException
    • stop

      public static String stop(String id)
      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

      public static void updatePipelineStatus(String id, Map<String,String> pipelineStatus)
      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

      public static void removeProcess(String id)
      Remove a process from the active processes map.
      Parameter:
      id - The process' id
    • setStatus

      public static void setStatus(String id, String status)
      Update the status of a process.
      Parameter:
      id - The id of the process.
      status - The new status DUUIStatus
    • setProgress

      public static void setProgress(String id, int progress)
      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

      public static void setFinishedAt(String id)
      Sets the finished_at field of a process to the current time.
      Parameter:
      id - The id of the process.
    • setFinishedAt

      public static void setFinishedAt(String id, long endTime)
      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

      public static void setFinished(String id, boolean finished)
      Mark a process as finished.
      Parameter:
      id - The id of the process.
      finished - A flag that indicates if the process is finished.
    • setError

      public static void setError(String id, String error)
      Set an error for a process.
      Parameter:
      id - The id of the process.
      error - The error that occurred.
    • setDocumentPaths

      public static void setDocumentPaths(String id, Set<String> documentPaths)
      Parameter:
      id - The id of the process.
      documentPaths - A Set of Strings holding paths to documents.
    • setInstantiationDuration

      public static void setInstantiationDuration(String id, long instantiationDuration)
      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 - A Bson 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

      public static List<IDUUIProcessHandler> getActiveProcesses()
      Get a list of all active processes
      Gibt zurück:
      a list of IDUUIProcessHandlers
    • getActiveProcesses

      public static List<IDUUIProcessHandler> getActiveProcesses(String pipelineId)
      Get all active processes for a given pipeline.
      Parameter:
      pipelineId - The id of the pipeline.
      Gibt zurück:
      A List of IDUUIProcessHandlers.
    • 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 a Provider 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

      public static boolean deleteTempOutputDirectory(File directory)
      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 an IDUUIDocumentHandler
      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

      public static Optional<String> getProcessSummaryForEmail(String processId) throws IOException
      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.