Class Serializer

java.lang.Object
com.logicaldoc.ai.serializer.Serializer
Direct Known Subclasses:
DocumentSerializer, FileSerializer

public abstract class Serializer extends Object
Takes care of serializing / deserializing the files required by an AIModel
Since:
9.2
Author:
Marco Meschieri - LogicalDOC
  • Constructor Details

    • Serializer

      public Serializer()
  • Method Details

    • loadTrainingData

      public abstract InputStream loadTrainingData(AIModel<?,?> model) throws IOException, com.logicaldoc.core.PersistenceException
      Throws:
      IOException
      com.logicaldoc.core.PersistenceException
    • loadTrainedModel

      public abstract InputStream loadTrainedModel(AIModel<?,?> model) throws IOException, com.logicaldoc.core.PersistenceException
      Throws:
      IOException
      com.logicaldoc.core.PersistenceException
    • saveTrainingData

      public abstract void saveTrainingData(AIModel<?,?> model, InputStream data) throws IOException, com.logicaldoc.core.PersistenceException
      Saves the training data set, the input stream gets closed
      Parameters:
      model - The model
      data - The data to save
      Throws:
      IOException - Error storing the training data
      com.logicaldoc.core.PersistenceException - Error in the data layer
    • saveTrainedModel

      public abstract void saveTrainedModel(AIModel<?,?> model, InputStream data) throws IOException, com.logicaldoc.core.PersistenceException
      Saves the trained model, the input stream gets closed
      Parameters:
      model - The model
      data - The data to save
      Throws:
      IOException - Error storing the model
      com.logicaldoc.core.PersistenceException - Error in the data layer
    • getFile

      public abstract String getFile(AIModel<?,?> model, String suffix) throws IOException, com.logicaldoc.core.PersistenceException
      Retrieves a reference (path, id or other) to a file used by the model
      Parameters:
      model - The model
      suffix - The file suffix
      Returns:
      the file's reference
      Throws:
      IOException - Error retrieving the file
      com.logicaldoc.core.PersistenceException - Error in the data layer
    • exportModel

      public void exportModel(AIModel<?,?> model, File file) throws IOException, com.logicaldoc.core.PersistenceException
      Exports into an zip archive this model plus the training files
      Parameters:
      model - The model to export
      file - The archive to export to
      Throws:
      IOException - I/O error
      com.logicaldoc.core.PersistenceException - Error in the data layers
    • importModel

      public AIModel importModel(String modelName, long tenantId, File file) throws IOException, com.logicaldoc.core.PersistenceException
      Imports a model from a provided archive, if present it saves the trained file and the training data but it does not store the model itself in the database.
      Parameters:
      modelName - Name of the new model to create or an existing one to override
      tenantId - Identifier of the tenant
      file - The archive containing model definition and it's trained data
      Returns:
      The model extracted from the archive, not stored in the database
      Throws:
      IOException - Generic IO Error
      com.logicaldoc.core.PersistenceException - Error in the data layers