Commit b47a93c1 authored by Martti Käärik's avatar Martti Käärik
Browse files

Added --compare-model flag + readme.

parent 1109a525
Loading
Loading
Loading
Loading
Loading
+4 −2
Changes for plugins/org.etsi.mts.tdl.constraints.helper/README.md: 4 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -11,8 +11,8 @@ The implementation of the tool makes use of the Apache POI and related libraries
## Command line

    ConstraintExporter --format evl|ocl|ecore --in <file> [--ecore <file>] [--severities <file>]
                       [--interpreted-ocl <file>] [--compare-ocl <file>] [--exclude Class::Name,...]
                       [--import <uri>,...] [--generated-package <name>]
                       [--interpreted-ocl <file>] [--compare-ocl <file>] [--compare-model <file>]
                       [--exclude Class::Name,...] [--import <uri>,...] [--generated-package <name>]

Classpath: the compiled classes, `lib/*` and the plug-ins of an Eclipse Modeling installation (for EMF).

@@ -47,6 +47,8 @@ Classpath: the compiled classes, `lib/*` and the plug-ins of an Eclipse Modeling
- `--compare-ocl` compares the export (the `--interpreted-ocl` one if given) with a deployed Complete OCL
  document, per invariant and ignoring whitespace: expressions that differ, invariants missing on either
  side. Nothing is written.
- `--compare-model` (with a `.docx` input) compares the classes and properties of the specification with
  the given metamodel.
- `--exclude` keeps the named invariants out of the metamodel (they stay in the OCL output), for
  invariants the code generator cannot compile.

+12 −6
Changes for plugins/org.etsi.mts.tdl.constraints.helper/src/org/etsi/mts/tdl/constraints/helper/ConstraintExporter.java: 12 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ public class ConstraintExporter {
		String severities = null;
		String interpretedOcl = null;
		String compareOcl = null;
		String compareModel = null;

		for (int i = 0; i < args.length; i++) {
			if (args[i].equalsIgnoreCase("--format") && args.length > i + 1) {
@@ -71,6 +72,14 @@ public class ConstraintExporter {
				interpretedOcl = args[i + 1];
			if (args[i].equalsIgnoreCase("--compare-ocl") && args.length > i + 1)
				compareOcl = args[i + 1];
			if (args[i].equalsIgnoreCase("--compare-model") && args.length > i + 1)
				compareModel = args[i + 1];
		}
		if (compareModel != null) {
			if (filename.endsWith(".ocl"))
				throw new IllegalArgumentException("--compare-model needs the specification (.docx) as --in");
			if (!new File(compareModel).isFile())
				throw new IllegalArgumentException("--compare-model: no such file " + new File(compareModel).getAbsolutePath());
		}

		ConstraintExporter exporter = new ConstraintExporter();
@@ -92,12 +101,9 @@ public class ConstraintExporter {
			exporter.exportModel(doc, generatedPackage, extraImports, "resources/generated/tdl-generated-" + title + ".txt", true);
			constraints = exporter.getRecords();
			System.out.println("Extracted " + constraints.size() + " invariants from " + filename + " -> " + targetPath);
			//TODO: cleanup / extract
			String ecorePath = "../org.etsi.mts.tdl.model/model/tdl.ecore";
			//TODO: expose in options
			//TODO: separate better
			exporter.compareModel(doc, generatedPackage, extraImports, title, false, ecorePath);
			//TODO: extract end
			// the classes and properties of the specification against a metamodel, on request
			if (compareModel != null)
				exporter.compareModel(doc, generatedPackage, extraImports, title, false, compareModel);
			// part 8
			String grammarFile = "resources/es_20311908v010302e.docx";
			if (new File(grammarFile).exists()) {