Interface Port<R extends Realm>

Type Parameters:
R - Realm of the bounded domain

public interface Port<R extends Realm>
Defines the inbound and outbound communication port to the bounded domain. It is a secondary port in the DDD terminology.

The realm is available to the port due to the default import and export functionality specific to this framework.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Pattern
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    clearEntities(@NotNull DomainAudit audit)
    Clears all entities of the bounded domain.
    static void
    createDirectories(@NotNull Path directory)
     
    static void
    entitiesCleared(@NotNull DomainAudit audit, @NotNull String entities)
     
    void
    exportEntities(@NotNull DomainAudit audit)
    Exports all entities of the bounded domain to the file system as TSV, JSON, TOML, and YAML files.
    default void
    importConfiguration(@NotNull DomainAudit audit, @NotNull TypeRegistry registry)
    Imports configuration specific to the bounded domain in the context of a tenant.
    void
    importEntities(@NotNull DomainAudit audit)
    Imports all entities of the bounded domain from the file system.
    Returns the realm containing all the entities of the bounded domain.
    static Path
    resolvePath(@NotNull Path directory, int year, @NotNull String filename)
    Resolves the uri to where a document should be located in the file system.
    static Path
    resolvePath(@NotNull Path directory, int year, Month month, @NotNull String filename)
    Resolves the uri to where a document should be located in the file system.
  • Field Details

    • PATTERN

      static final Pattern PATTERN
  • Method Details

    • importEntities

      void importEntities(@NotNull @NotNull DomainAudit audit)
      Imports all entities of the bounded domain from the file system. All TSV, JSON, TOML, and YAML files are imported. The domain is responsible for the order of the import and the handling of the entities. A bounded domain should not depend on other domains to perform the operation.

      You should trigger a user interface update by calling DomainAudit.entityImported(String) for each entity clas which was imported.

      Parameters:
      audit - domain audit sink to log the operation events
      See Also:
    • exportEntities

      void exportEntities(@NotNull @NotNull DomainAudit audit)
      Exports all entities of the bounded domain to the file system as TSV, JSON, TOML, and YAML files. A bounded domain should not depend on other domains to perform the operation.
      Parameters:
      audit - domain audit sink to log the operation events
      See Also:
    • clearEntities

      void clearEntities(@NotNull @NotNull DomainAudit audit)
      Clears all entities of the bounded domain. All generated documents and reports are cleared. Upon execution, the domain is empty. Use with caution as the operation is not reversible. Typically, the operation is used before an import to ensure that the domain is empty.

      You should trigger a user interface update by calling DomainAudit.entityImported(String) for each entity clas which was cleared.

      Parameters:
      audit - domain audit sink to log the operation events
    • importConfiguration

      default void importConfiguration(@NotNull @NotNull DomainAudit audit, @NotNull @NotNull TypeRegistry registry)
      Imports configuration specific to the bounded domain in the context of a tenant. The reference code values and tags are imported and registered in the type registry. The configuration is typically used to configure codes and tags.
      Parameters:
      audit - domain audit sink to log the operation events
    • realm

      R realm()
      Returns the realm containing all the entities of the bounded domain.
      Returns:
      realm of the bounded domain
    • entitiesCleared

      static void entitiesCleared(@NotNull @NotNull DomainAudit audit, @NotNull @NotNull String entities)
    • resolvePath

      static Path resolvePath(@NotNull @NotNull Path directory, int year, @NotNull @NotNull String filename)
      Resolves the uri to where a document should be located in the file system. The convention is base directory/year. If folders do not exist, they are created. The year must contain four digits.
      Parameters:
      directory - base directory containing all reports and documents
      year - year of the document
      filename - filename of the document to write
      Returns:
      uri to the file where the document should be written
    • resolvePath

      static Path resolvePath(@NotNull @NotNull Path directory, int year, Month month, @NotNull @NotNull String filename)
      Resolves the uri to where a document should be located in the file system. The convention is base directory/year/month. If folders do not exist, they are created. The year must contain four digits. The month is transformed to a two-digit string.
      Parameters:
      directory - base directory containing all reports and documents
      year - year of the document
      filename - filename of the document to write
      Returns:
      uri to the file where the document should be written
    • createDirectories

      static void createDirectories(@NotNull @NotNull Path directory)