Class FWSimMigrator

java.lang.Object
net.simplace.sim.FWSimMigrator

public class FWSimMigrator extends Object
Migrates solution and project files of older SIMPLACE versions to the current version (FWConstants.SOLUTION_VERSION). The migration rules are read from MigrationRules.csv (separator ;): the header contains column pairs ClassName_<version> and VarName_<version>, each line maps a class (line without variable name) or a variable of a class from one version to the next. A missing variable name in the newer version means the variable was removed; elements referring to it are deleted.

Migrated are the class names of transformers, SimComponents and project elements (generators, iterators, selectors) and the variable names in component inputs, management rules, output rules and resource keys. The DTD references in the file headers are updated to the current version.

Author:
Andreas Enders
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    check(File aPath)
    Checks solution and project files for class names (transformers, SimComponents, project elements) that neither exist on the class path nor are covered by the old-to-new class mapping.
    Returns the singleton instance and creates it if necessary.
    static void
    main(String[] args)
    Developer tool: writes the old-to-new class mapping to FWSimComponentMigration.csv in DEVELOPER_FILES_DIR.
    void
    migrate(File aPath)
    Migrates solution and project files to the current version and overwrites them (UTF-8): solutions older than FWConstants.SOLUTION_VERSION are migrated with migrate(Element, float); version and DTD reference are set to the current version for project files the DTD reference is set to the current version (a missing DOCTYPE is added), then the content is migrated if the version is older; the file is only rewritten if its content changed and could be parsed Errors are logged per file.
    boolean
    migrate(org.jdom2.Element aSolutionElement, float aSolutionVersion)
    Migrates a solution or project element step by step through all versions of the migration rules that are not older than the element version (versions below 3.0 are treated as 3.0).

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getInstance

      public static FWSimMigrator getInstance()
      Returns the singleton instance and creates it if necessary.
      Returns:
      the migrator
    • migrate

      public boolean migrate(org.jdom2.Element aSolutionElement, float aSolutionVersion) throws IOException
      Migrates a solution or project element step by step through all versions of the migration rules that are not older than the element version (versions below 3.0 are treated as 3.0). The attribute version is set to the reached version.
      Parameters:
      aSolutionElement - root element of the solution or project; changed in place
      aSolutionVersion - version of the element
      Returns:
      true if the content was changed, false if not or if there are no migration rules
      Throws:
      IOException - if the element cannot be converted to a string for the comparison
    • check

      public void check(File aPath)
      Checks solution and project files for class names (transformers, SimComponents, project elements) that neither exist on the class path nor are covered by the old-to-new class mapping. Each such class is logged as warning, and the list of all of them is logged at the end.

      Note: the class mapping is built from files in DEVELOPER_FILES_DIR.

      Parameters:
      aPath - directory (searched recursively for .sol.xml and .proj.xml files) or single file
    • migrate

      public void migrate(File aPath)
      Migrates solution and project files to the current version and overwrites them (UTF-8):
      • solutions older than FWConstants.SOLUTION_VERSION are migrated with migrate(Element, float); version and DTD reference are set to the current version
      • for project files the DTD reference is set to the current version (a missing DOCTYPE is added), then the content is migrated if the version is older; the file is only rewritten if its content changed and could be parsed
      Errors are logged per file.
      Parameters:
      aPath - directory (searched recursively for .sol.xml and .proj.xml files) or single file
    • main

      public static void main(String[] args)
      Developer tool: writes the old-to-new class mapping to FWSimComponentMigration.csv in DEVELOPER_FILES_DIR.
      Parameters:
      args - not used