Package io.jmix.core

Interface EntityImportExport

All Known Implementing Classes:
EntityImportExportImpl

public interface EntityImportExport
Bean that is used for exporting a collection of entities and importing them.
  • Method Details

    • exportEntitiesToZIP

      byte[] exportEntitiesToZIP(Collection<Object> entities)

      Serializes a collection of entities to JSON using EntitySerialization and packs the JSON file into ZIP archive.

      Serialization is described in the EntitySerialization.toJson(Collection) method documentation

      Parameters:
      entities - a collection of entities to export
      Returns:
      a byte array of zipped JSON file
    • exportEntitiesToZIP

      byte[] exportEntitiesToZIP(Collection<Object> entities, FetchPlan fetchPlan)

      Serializes a collection of entities to JSON using EntitySerialization and packs the JSON file into ZIP archive. Before the serialization entities will be reloaded with the fetch plan passed as method parameter.

      Serialization is described in the EntitySerialization.toJson(Collection) method documentation

      Parameters:
      entities - a collection of entities to export
      fetchPlan - before serialization to JSON entities will be reloaded with this fetch plan
      Returns:
      a byte array of zipped JSON file
    • exportEntitiesToJSON

      String exportEntitiesToJSON(Collection<Object> entities, FetchPlan fetchPlan)

      Serializes a collection of entities to JSON using EntitySerialization. Before the serialization entities will be reloaded with the fetch plan passed as method parameter.

      Serialization is described in the EntitySerialization.toJson(Collection) method documentation

      Parameters:
      entities - a collection of entities to export
      fetchPlan - before serialization to JSON entities will be reloaded with this fetch plan
      Returns:
      a JSON string
    • exportEntitiesToJSON

      String exportEntitiesToJSON(Collection<Object> entities)

      Serializes a collection of entities to JSON using EntitySerialization.

      Serialization is described in the EntitySerialization.toJson(Collection) method documentation

      Parameters:
      entities - a collection of entities to export
      Returns:
      a JSON string
    • importEntitiesFromJson

      Collection<Object> importEntitiesFromJson(String json, EntityImportPlan importPlan)
      Deserializes the JSON and persists deserialized entities according to the rules, described by the importPlan parameter. If the entity is not present in the database, it will be saved. Otherwise the fields of the existing entity that are in the importPlan will be updated.
      Parameters:
      json - JSON file containing entities
      importPlan - EntityImportPlan with the rules that describes how entities should be persisted.
      Returns:
      a collection of entities that have been imported
      See Also:
    • importEntitiesFromZIP

      Collection<Object> importEntitiesFromZIP(byte[] zipBytes, EntityImportPlan importPlan)
      Reads a zip archive that contains a JSON file, deserializes the JSON and persists deserialized entities according to the rules, described by the importPlan parameter. If the entity is not present in the database, it will be saved. Otherwise the fields of the existing entity that are in the importPlan will be updated.
      Parameters:
      zipBytes - byte array of ZIP archive with JSON file
      importPlan - EntityImportPlan with the rules that describes how entities should be persisted.
      Returns:
      a collection of entities that have been imported
      See Also:
    • importEntities

      Collection<Object> importEntities(Collection<Object> entities, EntityImportPlan importPlan)
      See importEntities(Collection, EntityImportPlan, boolean). The current method doesn't perform bean validation
    • importEntities

      Collection<Object> importEntities(Collection<Object> entities, EntityImportPlan importPlan, boolean validate)
      Persists entities according to the rules, described by the importPlan parameter. If the entity is not present in the database, it will be saved. Otherwise the fields of the existing entity that are in the importPlan will be updated.

      If the import plan contains a property for composition attribute then all composition collection members that are absent in the passed entity will be removed.

      Parameters:
      importPlan - EntityImportPlan with the rules that describes how entities should be persisted.
      validate - whether the passed entities should be validated by the bean validation mechanism before entities are persisted
      Returns:
      a collection of entities that have been imported
    • importEntities

      Collection<Object> importEntities(Collection<Object> entities, EntityImportPlan importPlan, boolean validate, boolean optimisticLocking)
      Persists entities according to the rules, described by the importPlan parameter. If the entity is not present in the database, it will be saved. Otherwise the fields of the existing entity that are in the importPlan will be updated.

      If the import plan contains a property for composition attribute then all composition collection members that are absent in the passed entity will be removed.

      Parameters:
      importPlan - EntityImportPlan with the rules that describes how entities should be persisted.
      validate - whether the passed entities should be validated by the bean validation mechanism before entities are persisted
      optimisticLocking - whether the passed entities versions should be validated before entities are persisted
      Returns:
      a collection of entities that have been imported
    • importEntities

      Collection<Object> importEntities(Collection<Object> entities, EntityImportPlan importPlan, boolean validate, boolean optimisticLocking, boolean additionComposition)
    • importEntityIntoSaveContext

      void importEntityIntoSaveContext(SaveContext saveContext, Object srcEntity, EntityImportPlan importPlan, boolean validate)
    • importEntityIntoSaveContext

      void importEntityIntoSaveContext(SaveContext saveContext, Object srcEntity, EntityImportPlan importPlan, boolean validate, boolean optimisticLocking)
    • importEntityIntoSaveContext

      void importEntityIntoSaveContext(SaveContext saveContext, Object srcEntity, EntityImportPlan importPlan, boolean validate, boolean optimisticLocking, boolean additionComposition)