Interface FileImportHandler<T extends Persistent>

All Known Implementing Classes:
ImportHandler

public interface FileImportHandler<T extends Persistent>
Abstract class for defining a import handler.
  • Method Details

    • init

      default void init(ImportContext ctx)
      called before any work starts
      Parameters:
      ctx - contains information about the current context
    • beforeInsert

      default boolean beforeInsert(Map<String,Object> m, T o)
      Parameters:
      m - the map with all the data
      o - the object which will be inserted
      Returns:
      true if object should be inserted, false otherwise
    • beforeUpdate

      default boolean beforeUpdate(Map<String,Object> m, T o)
      Parameters:
      m - the map with all the data
      o - the object which will be updated
      Returns:
      true if object should be updated, false otherwise
    • getKey

      default Object getKey(Map<String,Object> map)
      will be called if the keyField property isn't set
      Parameters:
      map - the map with all the data
      Returns:
      the identifier for the given data row
    • getKey

      default Object getKey(T o)
      will be called if the keyField property isn't set
      Parameters:
      o - the object
      Returns:
      the key for the given object
    • beforeImport

      default boolean beforeImport(Map<String,Object> m, Map<String,Object> ext)
      called after reading a row
      Parameters:
      m - the data for this row
      ext - the extended data
      Returns:
      true if import should continue, false otherwise
    • afterImport

      default void afterImport(Map<String,Object> m, T o)
      called after importing a row
      Parameters:
      m - the data map
      o - the imported object
    • prepareFile

      default void prepareFile(File f)
      use this if you want to modify the file first
      Parameters:
      f - the file
    • getExistingObject

      default Persistent getExistingObject(Object key, Map<String,Object> values, Map<Object,T> cache)
      should return the corresponding Persistent object for the current data row.
      Parameters:
      key - the key for the object either from keyField or getKey(Map)
      values - the values of the current row
      cache - the cached targetClass-objects
      Returns:
      the existing object
    • importCompleted

      default String importCompleted()
      Called after import is done. May do some cleanup, return a message for the page.