Skip to content
Snippets Groups Projects
Commit d642201d authored by Ludovic Apvrille's avatar Ludovic Apvrille
Browse files

Adding saving of TMAP after Z3 explo

parent 68b616ff
No related branches found
No related tags found
No related merge requests found
......@@ -40,6 +40,7 @@
package cli;
import common.ConfigurationTTool;
import common.SpecConfigTTool;
import launcher.RTLLauncher;
import myutil.FileUtils;
import myutil.PluginManager;
......@@ -170,6 +171,18 @@ public class TML extends Command {
};
subcommands.add(saveResult);
Command saveResultMapping = new Command() {
public String getCommand() { return "save-result-tml-mapping"; }
public String getShortCommand() { return "srtm"; }
public String getDescription() { return "srtm <file>: save the produced results of a mapping exploration"; }
public String executeCommand(String command, Interpreter interpreter) {
//interpreter.print("Command=" + command);
return saveResultTMLMapping(command);
}
};
subcommands.add(saveResultMapping);
}
......@@ -394,5 +407,44 @@ public class TML extends Command {
return null;
}
@SuppressWarnings("unchecked")
private String saveResultTMLMapping(String command) {
if (result == null) {
return "No mapping to save";
}
if (command.length() == 0) {
return "Must give a file as argument";
}
if (result.hasError()) {
return "No mapping to save since the mapping exploration encountered errors";
}
if (result.resultingMapping == null) {
return "Empty mapping: cannot generate TML file";
}
File fileResult = new File(command);
try {
boolean b = FileUtils.checkFileForSave(fileResult);
if (!b) {
return "Results cannot be written to " + command + ": access denied";
}
TMLMappingTextSpecification spec = new TMLMappingTextSpecification("fromZ3");
spec.toTextFormat(result.resultingMapping);
spec.saveFile(fileResult.getAbsolutePath(), "");
} catch (Exception e) {
return "Exception when writing resulting mapping to file: " + e.getMessage();
}
return null;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment