Class AbstractWorkDirs

java.lang.Object
org.pgcodekeeper.core.database.base.project.AbstractWorkDirs
All Implemented Interfaces:
IWorkDirs
Direct Known Subclasses:
ChWorkDirs, MsWorkDirs, PgWorkDirs

public abstract class AbstractWorkDirs extends Object implements IWorkDirs
Base implementation of IWorkDirs. Holds the directory mapping and loads overrides from "structure.properties" when the project path is provided. Subclasses supply defaults via getDefaultDirNames() and the initial split-by-schema flag via isSplitBySchemaByDefault().
  • Field Details

  • Method Details

    • resolveAltDirsFile

      public static Path resolveAltDirsFile(Path projectPath)
      Resolves the alt-dirs file path inside the given project directory.
    • isSplitBySchema

      public boolean isSplitBySchema()
      Description copied from interface: IWorkDirs
      Returns true if objects are organized into subdirectories per schema/database container, false if the schema name is encoded in the filename instead.
      Specified by:
      isSplitBySchema in interface IWorkDirs
    • getDirMapping

      public Map<String,DirRule> getDirMapping()
      Description copied from interface: IWorkDirs
      Returns the mapping of configurable type names to their placement rules. Defines which object types participate in the project layout and may be overridden by external configuration.

      Keys are type names (e.g. TABLE, VIEW, TRIGGER_FUNC). Values are IDirRule instances carrying the current directory name (default or overridden) together with matching metadata.

      Specified by:
      getDirMapping in interface IWorkDirs
      Returns:
      map of type names to their placement rules
    • getRelativeFilePath

      public Path getRelativeFilePath(IStatement st)
      Description copied from interface: IWorkDirs
      Computes the relative path (inside a project directory) where the given statement should be stored. Walks up ISubElement chains so that sub-elements share the file of their parent.
      Specified by:
      getRelativeFilePath in interface IWorkDirs
      Parameters:
      st - statement to locate
      Returns:
      project-relative path to the statement's SQL file
    • getDirNameForType

      public String getDirNameForType(DbObjType type)
      Description copied from interface: IWorkDirs
      Returns the current directory name of the generic rule for the given type. Specific-subset rules (e.g. MAT_VIEW, TRIGGER_FUNC) are skipped so the result reflects where the "regular" objects of the type live.
      Specified by:
      getDirNameForType in interface IWorkDirs
      Parameters:
      type - object type
      Returns:
      directory name, or null if no generic rule is registered
    • saveAltDirs

      public void saveAltDirs(Path projectPath) throws IOException
      Description copied from interface: IWorkDirs
      Persists the current directory layout overrides to the given project. Implementations write only entries that differ from the defaults, so an unchanged layout may produce an empty file.
      Specified by:
      saveAltDirs in interface IWorkDirs
      Parameters:
      projectPath - target project directory; must exist
      Throws:
      IOException - if the configuration file cannot be written