11.08., 9:00 - 11:00: Due to updates GitLab will be unavailable for some minutes between 09:00 and 11:00.

Commit d84565f3 authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck

fix migrate subcommand to use filesystem not resources

parent 2434d2f9
......@@ -22,8 +22,8 @@ public class VadereConsole {
public static void main(String[] args) {
// rimea_01_pathway_gnm1.scenario rimea_04_flow_gnm1_050_h.scenario
// String[] tmp = {"scenario-run", "-f", "VadereModelTests/TestGNM/scenarios/rimea_04_flow_gnm1_050_h.scenario"};
// args = tmp;
// String[] tmp = {"migrate", "--create-new-version", "0.7", "VadereSimulator/resources/"};
// args = tmp;
ArgumentParser parser = createArgumentParser();
try {
......@@ -35,6 +35,7 @@ public class VadereConsole {
System.exit(1);
} catch (Exception e) {
logger.error("topographyError in command:" + e.getMessage());
e.printStackTrace();
System.exit(1);
}
......@@ -200,7 +201,7 @@ public class VadereConsole {
.required(false)
.type(String.class)
.dest("create-new-version")
.help("Create new transformation and identity file based on current latest version" +
.help("Create new transformation and identity file based on current latest version. " +
"PATH must point to the directory containing the old transformation files." +
" This Argument takes the new Version Label as input.");
}
......
......@@ -9,11 +9,13 @@ import org.vadere.simulator.projects.migration.jolttranformation.JoltTransformat
import org.vadere.util.io.IOUtils;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.FileVisitResult;
import java.nio.file.FileVisitor;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Arrays;
......@@ -48,8 +50,8 @@ public class MigrationUtil {
public void generateNewVersionTransform(Path resourceDir, String newVersionLabel) throws URISyntaxException, IOException {
Path oldTransform = JoltTransformation.getTransforamtionFile(Version.latest());
Path oldIdentity = JoltTransformation.getIdenityFile(Version.latest());
Path oldTransform = JoltTransformation.getTransforamtionFileFromFileSystem(resourceDir, Version.latest());
Path oldIdentity = JoltTransformation.getIdenityFileFromFileSystem(resourceDir, Version.latest());
String newTransformString = JoltTransformation
.getTransforamtionResourcePath(Version.latest().label('-'), newVersionLabel);
......@@ -68,7 +70,6 @@ public class MigrationUtil {
}
public void migrateDirectoryTree(Path p, Version targetVersion, boolean recursive) throws MigrationException {
FileVisitor<Path> visitor = getVisitor(new ArrayList<>(), treeMarker, dirMarker, recursive, path -> migrate(path, targetVersion));
this.err = null;
......
......@@ -54,7 +54,7 @@ public abstract class JoltTransformation implements JsonNodeExplorer{
return ret;
}
public static Path getTransforamtionFile(Version toVersion) {
public static Path getTransforamtionFileFromRessource(Version toVersion) {
String transformString = getTransforamtionResourcePath(
toVersion.previousVersion().label('-'),
toVersion.label('-'));
......@@ -67,7 +67,7 @@ public abstract class JoltTransformation implements JsonNodeExplorer{
return Paths.get(res);
}
public static Path getIdenityFile(Version v) {
public static Path getIdenityFileFromRessource(Version v) {
String idenityString = getIdentiyResoucrePath(v.label('-'));
URI res = null;
try {
......@@ -78,6 +78,23 @@ public abstract class JoltTransformation implements JsonNodeExplorer{
return Paths.get(res);
}
public static Path getTransforamtionFileFromFileSystem(Path baseDir, Version toVersion) {
String transformString = getTransforamtionResourcePath(
toVersion.previousVersion().label('-'),
toVersion.label('-'));
return baseDir.resolve(transformString.substring(1));
}
public static Path getIdenityFileFromFileSystem(Path baseDir, Version v) {
String idenityString = getIdentiyResoucrePath(v.label('-'));
return baseDir.resolve(idenityString.substring(1));
}
public static String getTransforamtionResourcePath(String from, String to) {
return "/transform_v" + from.toUpperCase() + "_to_v" + to.toUpperCase() + ".json";
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment