Class FWSimMigrator
java.lang.Object
net.simplace.sim.FWSimMigrator
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 TypeMethodDescriptionvoidChecks 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.static FWSimMigratorReturns the singleton instance and creates it if necessary.static voidDeveloper tool: writes the old-to-new class mapping toFWSimComponentMigration.csvinDEVELOPER_FILES_DIR.voidMigrates solution and project files to the current version and overwrites them (UTF-8): solutions older thanFWConstants.SOLUTION_VERSIONare migrated withmigrate(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.booleanmigrate(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).
-
Method Details
-
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 attributeversionis set to the reached version.- Parameters:
aSolutionElement- root element of the solution or project; changed in placeaSolutionVersion- version of the element- Returns:
trueif the content was changed,falseif not or if there are no migration rules- Throws:
IOException- if the element cannot be converted to a string for the comparison
-
check
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.xmland.proj.xmlfiles) or single file
-
migrate
Migrates solution and project files to the current version and overwrites them (UTF-8):- solutions older than
FWConstants.SOLUTION_VERSIONare migrated withmigrate(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
- Parameters:
aPath- directory (searched recursively for.sol.xmland.proj.xmlfiles) or single file
- solutions older than
-
main
Developer tool: writes the old-to-new class mapping toFWSimComponentMigration.csvinDEVELOPER_FILES_DIR.- Parameters:
args- not used
-