Skip to content
Snippets Groups Projects
Commit 5919d71e authored by Sebastian Ebert's avatar Sebastian Ebert
Browse files

fixed config bug

parent 4b682398
No related branches found
No related tags found
No related merge requests found
package de.tudresden.inf.st.pnml.gen;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import de.tudresden.inf.st.pnml.gen.builders.PackageStructureBuilder;
import de.tudresden.inf.st.pnml.gen.json.GeneratorConfig;
import de.tudresden.inf.st.pnml.gen.json.NetInfo;
import de.tudresden.inf.st.pnml.jastadd.model.DinerosPackage;
import de.tudresden.inf.st.pnml.jastadd.model.GradleFile;
import de.tudresden.inf.st.pnml.jastadd.model.PackageDirectory;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
public class Main {
public static void main(java.lang.String[] args) throws IOException {
static final String ENGINE_VERSION = "0.1";
// TODO: Configuration
public static void main(java.lang.String[] args) throws IOException {
// PackageStructureBuilder.build("/home/sebastian/Desktop", "test", "test", null);
// GradleFile gf = new GradleFile();
......@@ -36,27 +35,26 @@ public class Main {
String version = args[4];
*/
String packageName = "sample";
String rootName = "sample-pkg";
String tokenClassPath = "/home/sebastian/Desktop/Token.java";
String namespace = "sample";
String version = "0.1";
String engineVersion = "0.1";
String configFile = "/home/sebastian/Desktop/EngineConfig.json";
// ObjectMapper gcObjectMapper = new ObjectMapper();
// GeneratorConfig config = gcObjectMapper.readValue(Files.readString(Paths.get(args[1])), new TypeReference<List<NetInfo>>(){});
GeneratorConfig gc = new GeneratorConfig("sample", "sample-pkg","/home/sebastian/Desktop/Token.java",
"sample","0.1","/home/sebastian/Desktop/EngineConfig.json","localhost",
"http://localhost:11311","localhost","/home/sebastian/Desktop");
DinerosPackage dp = new DinerosPackage();
dp.setName(packageName);
dp.setRootName(rootName);
dp.setNamespace(namespace);
dp.setTokenClass(Files.readString(Paths.get(tokenClassPath)));
dp.setVersion(version);
String configString = Files.readString(Paths.get(configFile));
ObjectMapper objectMapper = new ObjectMapper();
List<NetInfo> petriNetFilePaths = objectMapper.readValue(configString, new TypeReference<List<NetInfo>>(){});
PackageStructureBuilder.build("/home/sebastian/Desktop", dp, petriNetFilePaths, engineVersion
, "localhost", "http://localhost:11311", "localhost");
dp.setName(gc.getPackageName());
dp.setRootName(gc.getRootName());
dp.setNamespace(gc.getNamespace());
dp.setTokenClass(Files.readString(Paths.get(gc.getTokenClassPath())));
dp.setVersion(gc.getVersion());
String configString = Files.readString(Paths.get(gc.getConfigFile()));
ObjectMapper netObjectMapper = new ObjectMapper();
List<NetInfo> petriNetFilePaths = Arrays.asList(netObjectMapper.readValue(configString, NetInfo[].class));
PackageStructureBuilder.build(gc.getTargetPath(), dp, petriNetFilePaths, ENGINE_VERSION
, gc.getRosHost(), gc.getRosMasterUri(), gc.getMqttHost());
}
}
......@@ -24,13 +24,13 @@ public class PackageStructureBuilder {
List<PetriNet> nets = new ArrayList<>();
for (NetInfo n : petriNetFilePaths) {
nets.add(PnmlParser.parsePnml(n.getNet()).get(0));
nets.add(PnmlParser.parsePnml(n.net).get(0));
}
List<String> stringNetPaths = new ArrayList<>();
for(NetInfo n : petriNetFilePaths){
stringNetPaths.add(n.getNet());
stringNetPaths.add(n.net);
}
try {
......@@ -332,7 +332,7 @@ public class PackageStructureBuilder {
visitedPackageFileIDs.add(pf.getFileID());
pf.setName("PetriNet-" + i + ".pnml");
Path copied = Paths.get(packagePath + "/src/main/resources/nets/" + pf.getName());
Path originalPath = Paths.get(netPaths.get(i).getNet());
Path originalPath = Paths.get(netPaths.get(i).net);
Files.copy(originalPath, copied, StandardCopyOption.REPLACE_EXISTING);
System.out.println("Copy PNML:" + originalPath + " --> " + copied);
}
......
package de.tudresden.inf.st.pnml.gen.json;
public class GeneratorConfig {
private String packageName;
private String rootName;
private String tokenClassPath;
private String namespace;
private String version;
private String configFile;
private String rosHost;
private String rosMasterUri;
private String mqttHost;
private String targetPath;
public GeneratorConfig(String packageName, String rootName, String tokenClassPath, String namespace, String version, String configFile, String rosHost, String rosMasterUri, String mqttHost, String targetPath) {
this.packageName = packageName;
this.rootName = rootName;
this.tokenClassPath = tokenClassPath;
this.namespace = namespace;
this.version = version;
this.configFile = configFile;
this.rosHost = rosHost;
this.rosMasterUri = rosMasterUri;
this.mqttHost = mqttHost;
this.targetPath = targetPath;
}
public String getPackageName() {
return packageName;
}
public void setPackageName(String packageName) {
this.packageName = packageName;
}
public String getRootName() {
return rootName;
}
public void setRootName(String rootName) {
this.rootName = rootName;
}
public String getTokenClassPath() {
return tokenClassPath;
}
public void setTokenClassPath(String tokenClassPath) {
this.tokenClassPath = tokenClassPath;
}
public String getNamespace() {
return namespace;
}
public void setNamespace(String namespace) {
this.namespace = namespace;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getConfigFile() {
return configFile;
}
public void setConfigFile(String configFile) {
this.configFile = configFile;
}
public String getRosHost() {
return rosHost;
}
public void setRosHost(String rosHost) {
this.rosHost = rosHost;
}
public String getRosMasterUri() {
return rosMasterUri;
}
public void setRosMasterUri(String rosMasterUri) {
this.rosMasterUri = rosMasterUri;
}
public String getMqttHost() {
return mqttHost;
}
public void setMqttHost(String mqttHost) {
this.mqttHost = mqttHost;
}
public String getTargetPath() {
return targetPath;
}
public void setTargetPath(String targetPath) {
this.targetPath = targetPath;
}
}
......@@ -2,17 +2,5 @@ package de.tudresden.inf.st.pnml.gen.json;
public class NetInfo {
private String net;
public NetInfo(String net) {
this.net = net;
}
public String getNet() {
return net;
}
public void setNet(String net) {
this.net = net;
}
public String net;
}
[{
"net" : "/home/sebastian/Desktop/publisher-net.pnml"
},
{
"net" : "/home/sebastian/Desktop/subscriber-net.pnml"
}]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment