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

fixed bugs within token-class generation, simplified configuration, added sample configuration

parent b05e3c90
No related branches found
No related tags found
No related merge requests found
......@@ -18,43 +18,30 @@ public class Main {
public static void main(java.lang.String[] args) throws IOException {
// PackageStructureBuilder.build("/home/sebastian/Desktop", "test", "test", null);
// GradleFile gf = new GradleFile();
// gf.setName("TestFile");
// System.out.println(gf.generateSettingsGradle("test-project-name"));
/*if(args.length != 5){
if(args.length != 1){
System.out.println("Error: Invalid arguments.");
return;
}
String packageName = args[0];
String rootName = args[1];
String tokenClassPath = args[2];
String namespace = args[3];
String version = args[4];
*/
// ObjectMapper gcObjectMapper = new ObjectMapper();
// GeneratorConfig config = gcObjectMapper.readValue(Files.readString(Paths.get(args[1])), new TypeReference<List<NetInfo>>(){});
String configPath = args[0];
// String configPath = "src/test/resources/GeneratorConfig.json";
GeneratorConfig gc = new GeneratorConfig("sample", "sample-pkg","/home/sebastian/jastadd-workspaces/dineros-linked-ws/pnml-relast-tools/pnml-relast-pkg-gen/src/test/java/Token.java",
"sample","0.1","/home/sebastian/jastadd-workspaces/dineros-linked-ws/pnml-relast-tools/pnml-relast-pkg-gen/src/test/resources/EngineConfig.json","localhost",
"http://localhost:11311","localhost","/home/sebastian/Desktop");
ObjectMapper generatorConfigObjectMapper = new ObjectMapper();
GeneratorConfig gc = generatorConfigObjectMapper.readValue(Files.readString(Paths.get(configPath)), GeneratorConfig.class);
// GeneratorConfig gc = new GeneratorConfig("sample", "sample-pkg","sample","0.1", "src/test/resources/EngineConfig.json","localhost",
// "http://localhost:11311","localhost","/home/sebastian/Desktop");
DinerosPackage dp = new DinerosPackage();
dp.setName(gc.getPackageName());
dp.setRootName(gc.getRootName());
dp.setNamespace(gc.getNamespace());
dp.setTokenClass(Files.readString(Paths.get(gc.getTokenClassPath())));
dp.setVersion(gc.getVersion());
dp.setName(gc.packageName);
dp.setRootName(gc.rootName);
dp.setNamespace(gc.namespace);
dp.setVersion(gc.version);
String configString = Files.readString(Paths.get(gc.getConfigFile()));
String configString = Files.readString(Paths.get(gc.configFile));
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());
PackageStructureBuilder.build(gc.targetPath, dp, petriNetFilePaths, ENGINE_VERSION
, gc.rosHost, gc.rosMasterUri, gc.mqttHost);
}
}
......@@ -41,8 +41,8 @@ public class PackageStructureBuilder {
includeDirectoriesRecursive(dinerosPackage.getDir(0), packagePath);
includeTemplateFiles(dinerosPackage, nets, engineVersion, stringNetPaths, rosHost, rosMasterUri, mqttHost);
includeFilesInPackageRecursive(dinerosPackage.getDir(0), packagePath);
// includePnmlFiles(dinerosPackage, petriNetFilePaths, packagePath);
includeTokenClass(dinerosPackage, packagePath); // TODO fix
// includePnmlFiles(dinerosPackage, petriNetFilePaths, packagePath);
includeTokenClass(dinerosPackage);
insertStringsAsFilesRecursive(dinerosPackage.getDir(0), packagePath);
......@@ -318,21 +318,12 @@ public class PackageStructureBuilder {
// TREE TO FILE TREE ////////////////
/////////////////////////////////////
private static void includeTokenClass(DinerosPackage dinerosPackage, String packagePath){
private static void includeTokenClass(DinerosPackage dinerosPackage){
for (PackageFile pf : dinerosPackage.allPackageFiles()) {
if(pf.isTokenFile()){
String tokenClass = dinerosPackage.generateTokenClass();
/* try (Writer writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(packagePath + "/" + dinerosPackage.getRootName() + "/src/main/java/tudresden/inf/st/" +
dinerosPackage.getNamespace() + "/Token.java"), StandardCharsets.UTF_8))) {
writer.write(tokenClass);
}
catch (IOException ex) {
System.err.println("ERROR: " + ex.getMessage());
ex.printStackTrace();
}*/
pf.asTokenFile().setFileContent(tokenClass);
}
}
}
......@@ -408,7 +399,7 @@ public class PackageStructureBuilder {
String transitionType = t.asInputSignalTransition().getStaticTransitionInformation().getType();
if (transitionType.equals(PnmlConstants.TRANSITION_TYPE_SERVICE_REQUEST_OUT)) {
pf.setName("Node" + i + "Server" + serviceCountMap.get(nets.get(i).getId()));
pf.setName("Node" + i + "Server" + (serviceCountMap.get(nets.get(i).getId()) - 1));
pf.asServerFile().generate();
serviceCountMap.put(nets.get(i).getId(), serviceCountMap.get(nets.get(i).getId()) + 1);
visitedPackageFileIDs.add(pf.getFileID());
......
......@@ -2,107 +2,13 @@ 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;
}
public String packageName;
public String rootName;
public String namespace;
public String version;
public String configFile;
public String rosHost;
public String rosMasterUri;
public String mqttHost;
public String targetPath;
}
{
"packageName" : "sample",
"rootName" : "sample-pkg",
"namespace" : "sample",
"version" : "0.1",
"configFile" : "/home/sebastian/jastadd-workspaces/dineros-linked-ws/pnml-relast-tools/pnml-relast-pkg-gen/src/test/resources/EngineConfig.json",
"rosHost" : "localhost",
"rosMasterUri" : "http://localhost:11311",
"mqttHost" : "localhost",
"targetPath" :"/home/sebastian/Desktop"
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment