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

Commit 8d486772 authored by Jakob Schöttl's avatar Jakob Schöttl

Extract Version class

parent 0d45e3d1
...@@ -6,6 +6,7 @@ import org.vadere.gui.projectview.VadereApplication; ...@@ -6,6 +6,7 @@ import org.vadere.gui.projectview.VadereApplication;
import org.vadere.gui.projectview.model.ProjectViewModel; import org.vadere.gui.projectview.model.ProjectViewModel;
import org.vadere.gui.projectview.view.ProjectView; import org.vadere.gui.projectview.view.ProjectView;
import org.vadere.gui.projectview.view.VDialogManager; import org.vadere.gui.projectview.view.VDialogManager;
import org.vadere.simulator.entrypoints.Version;
import org.vadere.simulator.projects.VadereProject; import org.vadere.simulator.projects.VadereProject;
import org.vadere.simulator.projects.io.IOVadere; import org.vadere.simulator.projects.io.IOVadere;
import org.vadere.simulator.projects.migration.MigrationAssistant; import org.vadere.simulator.projects.migration.MigrationAssistant;
...@@ -113,7 +114,7 @@ public class ActionLoadProject extends AbstractAction { ...@@ -113,7 +114,7 @@ public class ActionLoadProject extends AbstractAction {
String message = String message =
"The migration assistant analyzed the " + total + " scenarios in the scenarios and output " + "The migration assistant analyzed the " + total + " scenarios in the scenarios and output " +
"directories of this project and attempted to upgrade them to the latest version " "directories of this project and attempted to upgrade them to the latest version "
+ MigrationAssistant.Version.latest().label() + ".\n" + + Version.latest().label() + ".\n" +
"Log-files have been created in legacy/scenarios and legacy/output.\n\n"; "Log-files have been created in legacy/scenarios and legacy/output.\n\n";
if (untouched > 0) if (untouched > 0)
......
package org.vadere.simulator.entrypoints;
/** Versions in strict order from oldest to newest. */
public enum Version {
UNDEFINED("undefined"),
NOT_A_RELEASE("not a release"),
V0_1("0.1"),
V0_2("0.2");
private String label;
Version(String label) {
this.label = label;
}
public String label() {
return label;
}
public static Version fromString(String versionStr) {
for (Version v : values()) {
if (v.label.equals(versionStr))
return v;
}
return null;
}
public static Version latest() {
return values()[values().length - 1];
}
@Override
public String toString() {
return label();
}
}
...@@ -7,7 +7,7 @@ import java.util.LinkedList; ...@@ -7,7 +7,7 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.vadere.simulator.projects.migration.MigrationAssistant.Version; import org.vadere.simulator.entrypoints.Version;
import org.vadere.simulator.projects.migration.incidents.AddTextNodeIncident; import org.vadere.simulator.projects.migration.incidents.AddTextNodeIncident;
import org.vadere.simulator.projects.migration.incidents.DeletionIncident; import org.vadere.simulator.projects.migration.incidents.DeletionIncident;
import org.vadere.simulator.projects.migration.incidents.Incident; import org.vadere.simulator.projects.migration.incidents.Incident;
...@@ -19,7 +19,7 @@ import org.vadere.simulator.projects.migration.incidents.specialized.AttributesP ...@@ -19,7 +19,7 @@ import org.vadere.simulator.projects.migration.incidents.specialized.AttributesP
import org.vadere.simulator.projects.migration.incidents.specialized.MoveSpawnDelayIntoDistributionParametersIncident; import org.vadere.simulator.projects.migration.incidents.specialized.MoveSpawnDelayIntoDistributionParametersIncident;
import org.vadere.state.util.StateJsonConverter; import org.vadere.state.util.StateJsonConverter;
import static org.vadere.simulator.projects.migration.MigrationAssistant.Version.*; import static org.vadere.simulator.entrypoints.Version.*;
public class IncidentDatabase { public class IncidentDatabase {
......
...@@ -14,6 +14,7 @@ import java.util.stream.Collectors; ...@@ -14,6 +14,7 @@ import java.util.stream.Collectors;
import org.apache.log4j.LogManager; import org.apache.log4j.LogManager;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.vadere.simulator.entrypoints.Version;
import org.vadere.simulator.projects.migration.incidents.ExceptionIncident; import org.vadere.simulator.projects.migration.incidents.ExceptionIncident;
import org.vadere.simulator.projects.migration.incidents.Incident; import org.vadere.simulator.projects.migration.incidents.Incident;
import org.vadere.simulator.projects.migration.incidents.VersionBumpIncident; import org.vadere.simulator.projects.migration.incidents.VersionBumpIncident;
...@@ -22,36 +23,6 @@ import org.vadere.util.io.IOUtils; ...@@ -22,36 +23,6 @@ import org.vadere.util.io.IOUtils;
public class MigrationAssistant { public class MigrationAssistant {
// versions in strict order from oldest to newest
public enum Version {
UNDEFINED("undefined"),
NOT_A_RELEASE("not a release"),
V0_1("0.1"),
V0_2("0.2");
private String label;
Version(String label) {
this.label = label;
}
public String label() {
return label;
}
static Version fromString(String versionStr) {
for (Version v : values()) {
if (v.label.equals(versionStr))
return v;
}
return null;
}
public static Version latest() {
return values()[values().length - 1];
}
}
public static final String INCIDENT_ORDER_ERROR = "An incident that was found applicable couldn't be resolved. " + public static final String INCIDENT_ORDER_ERROR = "An incident that was found applicable couldn't be resolved. " +
"That means, that a previously resolved incident rendered this one no longer applicable. " + "That means, that a previously resolved incident rendered this one no longer applicable. " +
"Check the order of the incidents in the IncidentDatabase for logical flaws."; "Check the order of the incidents in the IncidentDatabase for logical flaws.";
......
package org.vadere.simulator.projects.migration.incidents; package org.vadere.simulator.projects.migration.incidents;
import org.vadere.simulator.projects.migration.Tree; import org.vadere.simulator.projects.migration.Tree;
import org.vadere.simulator.entrypoints.Version;
import org.vadere.simulator.projects.migration.MigrationException; import org.vadere.simulator.projects.migration.MigrationException;
import org.vadere.simulator.projects.migration.MigrationAssistant.Version;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
......
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