The expiration time for new job artifacts in CI/CD pipelines is now 30 days (GitLab default). Previously generated artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 0e2fc05a authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

add new helpers for new Migration implementation

parent a75d75fd
package org.vadere.simulator.entrypoints;
import org.jetbrains.annotations.NotNull;
import org.vadere.simulator.projects.migration.incidents.VersionBumpIncident;
import java.util.Optional;
......@@ -30,6 +31,34 @@ public enum Version {
return null;
}
private static int versionId(Version curr){
Version[] versions = values();
for ( int i = 0 ; i < versions.length ; i++){
if (curr.equals(versions[i])){
return i;
}
}
throw new IllegalArgumentException("Value not in Version Enumeration " + curr.toString());
}
public static Version nextVersion(Version curr){
int nextId = versionId(curr) == (values().length -1) ? versionId(curr) : versionId(curr) + 1;
return values()[nextId];
}
public static Version[] listToLatest (Version v){
int start = versionId(v) == (values().length -1) ? versionId(v) : versionId(v) + 1;
int end = values().length;
Version[] ret = new Version[end-start];
System.arraycopy(values(), start, ret, 0, end - start );
return ret;
}
public boolean equalOrSamller(Version test){
return versionId(this) <= versionId(test);
}
public static Version latest() {
return values()[values().length - 1];
}
......
......@@ -36,6 +36,7 @@ import org.vadere.util.reflection.DynamicClassInstantiator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
......@@ -48,6 +49,9 @@ public abstract class StateJsonConverter {
public static final String MAIN_MODEL_KEY = "mainModel";
private static final TypeReference<Map<String, Object>> mapTypeReference =
new TypeReference<Map<String, Object>>() {};
private static Logger logger = LogManager.getLogger(StateJsonConverter.class);
/** Connection to jackson library. */
......@@ -78,6 +82,18 @@ public abstract class StateJsonConverter {
return mapper.readTree(dev);
}
public static Object deserializeToMapOfObjects(String dev) throws IOException {
return mapper.readValue(dev, mapTypeReference);
}
public static Object convertJsonNodeToObject(JsonNode node) throws IOException {
return mapper.convertValue(node, Map.class);
}
public static JsonNode deserializeToNode(Object map){
return mapper.valueToTree(map);
}
private static class TopographyStore {
AttributesTopography attributes = new AttributesTopography();
AttributesAgent attributesPedestrian = new AttributesAgent();
......
......@@ -9,19 +9,20 @@ import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import java.util.StringJoiner;
import java.util.prefs.BackingStoreException;
import java.util.prefs.InvalidPreferencesFormatException;
import java.util.prefs.Preferences;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;
......@@ -171,6 +172,15 @@ public class IOUtils {
}
}
public static String readTextFileFromResources(String resourcePath) throws IOException {
URL url = IOUtils.class.getResource(resourcePath);
try {
return readTextFile(Paths.get(url.toURI()));
} catch (URISyntaxException e) {
throw new IOException("Wrong URI Syntax for " + url.toString(), e);
}
}
public static String readTextFile(String filePath) throws IOException {
return readTextFile(Paths.get(filePath));
}
......
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