Rimay DSL added to project
This commit is contained in:
+3
@@ -38,6 +38,9 @@ Workflow {
|
||||
junitSupport = {
|
||||
junitVersion = "5"
|
||||
}
|
||||
generator = {
|
||||
generateJavaMain = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* generated by Xtext 2.30.0
|
||||
*/
|
||||
package org.xtext.generator;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Provider;
|
||||
import java.util.List;
|
||||
import org.eclipse.emf.common.util.URI;
|
||||
import org.eclipse.emf.ecore.resource.Resource;
|
||||
import org.eclipse.emf.ecore.resource.ResourceSet;
|
||||
import org.eclipse.xtext.generator.GeneratorContext;
|
||||
import org.eclipse.xtext.generator.GeneratorDelegate;
|
||||
import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
|
||||
import org.eclipse.xtext.util.CancelIndicator;
|
||||
import org.eclipse.xtext.validation.CheckMode;
|
||||
import org.eclipse.xtext.validation.IResourceValidator;
|
||||
import org.eclipse.xtext.validation.Issue;
|
||||
import org.xtext.Dsl_rimayStandaloneSetup;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length == 0) {
|
||||
System.err.println("Aborting: no path to EMF resource provided!");
|
||||
return;
|
||||
}
|
||||
Injector injector = new Dsl_rimayStandaloneSetup().createInjectorAndDoEMFRegistration();
|
||||
Main main = injector.getInstance(Main.class);
|
||||
main.runGenerator(args[0]);
|
||||
}
|
||||
|
||||
@Inject
|
||||
private Provider<ResourceSet> resourceSetProvider;
|
||||
|
||||
@Inject
|
||||
private IResourceValidator validator;
|
||||
|
||||
@Inject
|
||||
private GeneratorDelegate generator;
|
||||
|
||||
@Inject
|
||||
private JavaIoFileSystemAccess fileAccess;
|
||||
|
||||
protected void runGenerator(String string) {
|
||||
// Load the resource
|
||||
ResourceSet set = resourceSetProvider.get();
|
||||
Resource resource = set.getResource(URI.createFileURI(string), true);
|
||||
|
||||
// Validate the resource
|
||||
List<Issue> list = validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl);
|
||||
if (!list.isEmpty()) {
|
||||
for (Issue issue : list) {
|
||||
System.err.println(issue);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Configure and start the generator
|
||||
fileAccess.setOutputPath("src-gen/");
|
||||
GeneratorContext context = new GeneratorContext();
|
||||
context.setCancelIndicator(CancelIndicator.NullImpl);
|
||||
generator.generate(resource, fileAccess, context);
|
||||
|
||||
System.out.println("Code generation finished.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
Actors: actor SystemA, actor SystemB, actor SystemC, actor X
|
||||
Classes: class Instruction := description record, class Y
|
||||
|
||||
When SystemB receives an "email alert" from SystemA, SystemB must send an Instruction to SystemC.
|
||||
|
||||
//When the SystemA receives a rejection message from SystemB, then it must transform it to the corresponding XML message type and sent it to the SystemC.
|
||||
//When an order cancellation message is received from the SystemA then Reason must be displayed in the SystemB GUI field 'Reason of Cancellation'.
|
||||
|
||||
|
||||
The User must upload the "excel file" to the "SystemA".
|
||||
Binary file not shown.
@@ -7,7 +7,7 @@ from html_gui import setup_ui
|
||||
from nicegui import ui
|
||||
|
||||
|
||||
from rimay_verification import Paska_tool
|
||||
from rimay_verification import Paska_tool, RimayDSL
|
||||
|
||||
client = None
|
||||
|
||||
@@ -28,16 +28,25 @@ client = None
|
||||
# paska_tool.check_rimay_requirement("When the System-A receives a rejection message from System-B, Then it must transform it to the corresponding XML message type and sent it to the System-C.")
|
||||
|
||||
#all gherkin data.
|
||||
csv_importer = GherkinData() #GherkinData
|
||||
all_acceptance_criteria = csv_importer.load()
|
||||
# csv_importer = GherkinData() #GherkinData
|
||||
# all_acceptance_criteria = csv_importer.load()
|
||||
|
||||
for scenario in all_acceptance_criteria:
|
||||
print(scenario["scenario_name"])
|
||||
print(scenario["content"])
|
||||
print("=================")
|
||||
# for scenario in all_acceptance_criteria:
|
||||
# print(scenario["scenario_name"])
|
||||
# print(scenario["content"])
|
||||
# print("=================")
|
||||
|
||||
# setup_ui()
|
||||
# ui.run()
|
||||
|
||||
dsl = RimayDSL()
|
||||
print(dsl.check_rimay_comf_dsl("""
|
||||
Actors: actor SystemA, actor SystemB, actor SystemC, actor X
|
||||
Classes: class Instruction := description record, class Y
|
||||
|
||||
When SystemB receives an "email alert" from SystemA, SystemB must send an Instruction to SystemC.
|
||||
"""))
|
||||
|
||||
setup_ui()
|
||||
ui.run()
|
||||
|
||||
# rimay = RimayData()
|
||||
# print(rimay.load())
|
||||
|
||||
@@ -79,3 +79,32 @@ class Paska_tool():
|
||||
self.__init_directories()
|
||||
|
||||
|
||||
|
||||
class RimayDSL():
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.java_exe = "/home/koebuntu/eclipse//plugins/org.eclipse.justj.openjdk.hotspot.jre.full.linux.x86_64_17.0.6.v20230204-1729/jre/bin/java"
|
||||
self.jar_exe = "/home/koebuntu/LLPTE/existing_research/dsl_rimay-master/rimay_validator_dsl.jar"
|
||||
self.test_rimay_file = "/home/koebuntu/LLPTE/generated_data/dsl_check.rimay"
|
||||
|
||||
def write_input_file(self, rimay_requirement:str):
|
||||
f = open(self.test_rimay_file, "w")
|
||||
f.write(rimay_requirement)
|
||||
f.close()
|
||||
|
||||
def execute_tool(self):
|
||||
all_args = [self.java_exe, "-jar", self.jar_exe, self.test_rimay_file]
|
||||
return self._run_java(all_args)
|
||||
|
||||
def check_rimay_comf_dsl(self, rimay_requirement:str):
|
||||
self.write_input_file(rimay_requirement)
|
||||
return self.execute_tool()
|
||||
|
||||
def _run_java(self, input_args:list):
|
||||
process = Popen(input_args, stdout=PIPE, stderr=PIPE) #["conda activate smell-detector"]+
|
||||
result = process.communicate()
|
||||
print("Result STDOUT: "+ result[0].decode('utf-8'))
|
||||
print("Result STDERR: "+ result[1].decode('utf-8'))
|
||||
|
||||
return (result[0].decode('utf-8'), result[1].decode('utf-8'))
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
Actors: actor SystemA, actor SystemB, actor SystemC, actor X
|
||||
Classes: class Instruction := description record, class Y
|
||||
|
||||
When SystemB receives an "email alert" from SystemA, SystemB must send an Instruction to SystemC.
|
||||
|
||||
When the System-A receives a rejection message from System-B
|
||||
Reference in New Issue
Block a user