Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JNG-5995 Update eclipse #273

Merged
merged 12 commits into from
Nov 27, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ operation Any equivalentDiscriminated(transformation : String, id : String, disc
throw "Transformation called in empty object: " + id + " / " + discriminator + " Transformation: " + transformation;
}
var targetId = id + "/(discriminator/" + discriminator + ")";
var r = JSL.target.resource;
var r = JSL.resource;

// Find the discriminated id in cahe first
var f = __cacheMap.get(targetId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ operation JSL!EntityDeclaration getModelRoot(): JUDOPSM!Package {


@cached
operation JSL!EntityDeclaration getInheritedMembers(): Sequence<EntityMemberDeclaration> {
var members = new Sequence<EntityMemberDeclaration>();
operation JSL!EntityDeclaration getInheritedMembers(): Sequence {
var members = new Sequence();

for (member in self.members) {
members.add(member);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ pre {
var __cacheMap = new ConcurrentMap();
var __originalMap = new ConcurrentMap();

JUDOPSM.target.resource.contents.add(defaultModelName.equivalent("CreateRootModel"));
JUDOPSM.resource.contents.add(defaultModelName.equivalent("CreateRootModel"));
}

post {
for (c in JUDOPSM!Cardinality.all()) {
c.setId(c.eContainer.getId()+"/cardinality");
}
//for (c in JUDOPSM!Cardinality.all()) {
// c.setId(c.eContainer.getId()+"/cardinality");
//}

// Collect primitive types which are not directly referenced as field types
for (c in JSL!NavigationBaseDeclarationReference.all().select(n | n.reference.isKindOf(JSL!PrimitiveDeclaration))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.common.collect.ImmutableMap;
import hu.blackbelt.epsilon.runtime.execution.ExecutionContext;
import hu.blackbelt.epsilon.runtime.execution.ExecutionContext.ExecutionContextBuilder;
import hu.blackbelt.epsilon.runtime.execution.model.emf.WrappedEmfModelContext;
import org.slf4j.Logger;
import hu.blackbelt.epsilon.runtime.execution.api.ModelContext;
import hu.blackbelt.epsilon.runtime.execution.contexts.EtlExecutionContext;
Expand All @@ -45,9 +46,6 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;

import static hu.blackbelt.epsilon.runtime.execution.ExecutionContext.executionContextBuilder;
import static hu.blackbelt.epsilon.runtime.execution.contexts.EtlExecutionContext.etlExecutionContextBuilder;
import static hu.blackbelt.epsilon.runtime.execution.model.emf.WrappedEmfModelContext.wrappedEmfModelContextBuilder;
import static hu.blackbelt.judo.tatami.core.TransformationTraceUtil.getTransformationTraceFromEtlExecutionContext;
import static hu.blackbelt.judo.tatami.jsl.jsl2psm.Jsl2PsmTransformationTrace.JSL_2_PSM_URI_POSTFIX;
import static hu.blackbelt.judo.tatami.jsl.jsl2psm.Jsl2PsmTransformationTrace.resolveJsl2PsmTrace;
Expand Down Expand Up @@ -162,6 +160,10 @@ public static class Jsl2PsmParameter {
@NonNull
Boolean generateBehaviours = false;

@Builder.Default
@NonNull
Boolean useCache = true;

}


Expand All @@ -181,21 +183,25 @@ public static Jsl2PsmTransformationTrace executeJsl2PsmTransformation(Jsl2PsmPar
EtlExecutionContext etlExecutionContext;
try {
// Execution context
ExecutionContextBuilder executionContextBuilder = executionContextBuilder();
ExecutionContextBuilder executionContextBuilder = ExecutionContext.executionContextBuilder();

ExecutionContext executionContext = executionContextBuilder
.log(log)
.modelContexts(ImmutableList.<ModelContext>builder()
.add(wrappedEmfModelContextBuilder()
.add(WrappedEmfModelContext.wrappedEmfModelContextBuilder()
.log(log)
.name("JSL")
.resource(parameter.jslModel.getResource())
.useCache(parameter.useCache)
.validateModel(false)
.build()
)
.add(wrappedEmfModelContextBuilder()
.add(WrappedEmfModelContext.wrappedEmfModelContextBuilder()
.log(log)
.name("JUDOPSM")
.resource(parameter.psmModel.getResource())
.validateModel(false)
.useCache(parameter.useCache)
.build()
)
.build()
Expand Down Expand Up @@ -227,12 +233,13 @@ public static Jsl2PsmTransformationTrace executeJsl2PsmTransformation(Jsl2PsmPar
.put("ecoreUtil", new EcoreUtil())
.put("jslUtils", new JslDslModelExtension())
.put("psmUtils", new PsmUtils(parameter.psmModel.getResourceSet())).build())
.useCache(parameter.useCache)
.build();

// run the model / metadata loading
executionContext.load();

etlExecutionContext = etlExecutionContextBuilder()
etlExecutionContext = EtlExecutionContext.etlExecutionContextBuilder()
.source(UriUtil.resolve("jslToPsm.etl", parameter.scriptUri))
.parallel(parameter.parallel)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ protected void transform() throws Exception {
.log(slf4jlog)
.jslModel(jslModel)
.psmModel(psmModel)
.parallel(true)
.useCache(true)
.generateBehaviours(generateBehaviours())
.createTrace(true)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,39 +68,35 @@ static void prepareTestFolders() throws IOException {

@Override
public Jsl2PsmParameterBuilder addTransformationParameters(String testName, Jsl2PsmParameterBuilder parameters) {

if (testName.equals("TestNoDefaultTransferObject")) {
if (testName.equals(this.getClass().getSimpleName() + ".testNoDefaultTransferObject")) {
return parameters.generateDefaultTransferObject(false);
} else if (testName.equals("TestEntityPrefix")) {
} else if (testName.equals(this.getClass().getSimpleName() + ".testEntityPrefix")) {
return parameters.entityNamePrefix("_Entity_");
} else if (testName.equals("TestEntityPostfix")) {
} else if (testName.equals(this.getClass().getSimpleName() + ".testEntityPostfix")) {
return parameters.entityNamePrefix("").entityNamePostfix("_Entity");
} else if (testName.equals("TestTransferObjectPrefix")) {
} else if (testName.equals(this.getClass().getSimpleName() + ".testTransferObjectPrefix")) {
return parameters.defaultTransferObjectNamePrefix("_DefaultTransferObject");
} else if (testName.equals("TestTransferObjectPostfix")) {
} else if (testName.equals(this.getClass().getSimpleName() + ".testTransferObjectPostfix")) {
return parameters.defaultTransferObjectNamePostfix("_DefaultTransferObject");
} else if (testName.equals("TestDefaultDefaultNamePrefix")) {
} else if (testName.equals(this.getClass().getSimpleName() + ".testDefaultDefaultNamePrefix")) {
return parameters.defaultDefaultNamePrefix("_pre_");
} else if (testName.equals("TestDefaultDefaultNameMidfix")) {
} else if (testName.equals(this.getClass().getSimpleName() + ".testDefaultDefaultNameMidfix")) {
return parameters.defaultDefaultNameMidfix("_mid_");
} else if (testName.equals("TestDefaultDefaultNamePostfix")) {
} else if (testName.equals(this.getClass().getSimpleName() + ".testDefaultDefaultNamePostfix")) {
return parameters.defaultDefaultNamePostfix("_post");
} else if (testName.equals("TestDefaultReadsNamePrefix")) {
} else if (testName.equals(this.getClass().getSimpleName() + ".testDefaultReadsNamePrefix")) {
return parameters.defaultReadsNamePrefix("_pre_");
} else if (testName.equals("TestDefaultReadsNameMidfix")) {
} else if (testName.equals(this.getClass().getSimpleName() + ".testDefaultReadsNameMidfix")) {
return parameters.defaultReadsNameMidfix("_mid_");
} else if (testName.equals("TestDefaultReadsNamePostfix")) {
} else if (testName.equals(this.getClass().getSimpleName() + ".testDefaultReadsNamePostfix")) {
return parameters.defaultReadsNamePostfix("_post");
}
return parameters;
}

@Test
void testNoDefaultTransferObject() throws Exception {
testName = "TestNoDefaultTransferObject";

jslModel = JslParser.getModelFromStrings(
"Test",
List.of("model Test;\n" +
"\n" +
"entity T {\n" +
Expand All @@ -116,10 +112,8 @@ void testNoDefaultTransferObject() throws Exception {

@Test
void testEntityPrefix() throws Exception {
testName = "TestEntityPrefix";

jslModel = JslParser.getModelFromStrings(
"Test",
List.of("model Test;\n" +
"\n" +
"entity T {\n" +
Expand All @@ -136,10 +130,8 @@ void testEntityPrefix() throws Exception {

@Test
void testEntityPostfix() throws Exception {
testName = "TestEntityPostfix";

jslModel = JslParser.getModelFromStrings(
"Test",
List.of("model Test;\n" +
"\n" +
"entity T {\n" +
Expand All @@ -157,10 +149,8 @@ void testEntityPostfix() throws Exception {

@Test
void testTransferObjectPrefix() throws Exception {
testName = "TestTransferObjectPrefix";

jslModel = JslParser.getModelFromStrings(
"Test",
List.of("model Test;\n" +
"\n" +
"entity T {\n" +
Expand All @@ -177,10 +167,8 @@ void testTransferObjectPrefix() throws Exception {

@Test
void testTransferObjectPostfix() throws Exception {
testName = "TestTransferObjectPostfix";

jslModel = JslParser.getModelFromStrings(
"Test",
List.of("model Test;\n" +
"\n" +
"entity T {\n" +
Expand All @@ -197,10 +185,7 @@ void testTransferObjectPostfix() throws Exception {

@Test
void testDefaultDefaultNamePrefix() throws Exception {
testName = "TestDefaultDefaultNamePrefix";

jslModel = JslParser.getModelFromStrings(
"Test",
List.of("model Test;\n" +
"\n" +
"type string String min-size:0 max-size:32;\n" +
Expand All @@ -221,10 +206,7 @@ void testDefaultDefaultNamePrefix() throws Exception {

@Test
void testDefaultDefaultNameMidfix() throws Exception {
testName = "TestDefaultDefaultNameMidfix";

jslModel = JslParser.getModelFromStrings(
"Test",
List.of("model Test;\n" +
"\n" +
"type string String min-size:0 max-size:32;\n" +
Expand All @@ -245,10 +227,7 @@ void testDefaultDefaultNameMidfix() throws Exception {

@Test
void testDefaultDefaultNamePostfix() throws Exception {
testName = "TestDefaultDefaultNamePostfix";

jslModel = JslParser.getModelFromStrings(
"Test",
List.of("model Test;\n" +
"\n" +
"type string String min-size:0 max-size:32;\n" +
Expand All @@ -269,10 +248,7 @@ void testDefaultDefaultNamePostfix() throws Exception {

@Test
void testDefaultReadsNamePrefix() throws Exception {
testName = "TestDefaultReadsNamePrefix";

jslModel = JslParser.getModelFromStrings(
"Test",
List.of("model Test;\n" +
"\n" +
"type string String min-size:0 max-size:32;\n" +
Expand All @@ -296,10 +272,7 @@ void testDefaultReadsNamePrefix() throws Exception {

@Test
void testDefaultReadsNameMidfix() throws Exception {
testName = "TestDefaultReadsNameMidfix";

jslModel = JslParser.getModelFromStrings(
"Test",
List.of("model Test;\n" +
"\n" +
"type string String min-size:0 max-size:32;\n" +
Expand All @@ -322,10 +295,7 @@ void testDefaultReadsNameMidfix() throws Exception {

@Test
void testDefaultReadsNamePostfix() throws Exception {
testName = "TestDefaultReadsNamePostfix";

jslModel = JslParser.getModelFromStrings(
"Test",
List.of("model Test;\n" +
"\n" +
"type string String min-size:0 max-size:32;\n" +
Expand All @@ -347,3 +317,4 @@ void testDefaultReadsNamePostfix() throws Exception {
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ static void prepareTestFolders() throws IOException {
void testActors() throws Exception {

jslModel = JslParser.getModelFromFiles(
"ActorTestModel",
List.of(new File("src/test/resources/actor/ActorTestModel.jsl"))
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ static void prepareTestFolders() throws IOException {
void testActors() throws Exception {

jslModel = JslParser.getModelFromFiles(
"AnonymousActorTestModel",
List.of(new File("src/test/resources/actor/AnonymousActorTestModel.jsl"))
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,8 @@ static void prepareTestFolders() throws IOException {

@Test
void testPrimitiveDerivedDeclarationModel() throws Exception {
testName = "TestPrimitiveDerivedDeclarationModel";

jslModel = JslParser.getModelFromStrings(
"PrimitiveDerivedDeclarationModel",
List.of("model PrimitiveDerivedDeclarationModel;\n" +
"\n" +
"type numeric Integer precision:9 scale:0;\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ static void prepareTestFolders() throws IOException {

@Test
void testDerivedRelationDeclarationModel() throws Exception {
testName = "TestDerivedRelationModel";

jslModel = JslParser.getModelFromFiles(
"DerivedRelationModel",
List.of(new File("src/test/resources/derived/TestDerivedRelationModel.jsl"))
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ static void prepareTestFolders() throws IOException {

@Test
void testEntityDerivedWithParametersTest() throws Exception {
testName = "TestEntityDerivedWithParametersTest";

jslModel = JslParser.getModelFromFiles(
"TestDerivedWithParameters",
List.of(new File("src/test/resources/derived/TestDerivedWithParametersModel.jsl"))
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ static void prepareTestFolders() throws IOException {

@Test
void testDerivedExpressionModel() throws Exception {
testName = "TestDerivedExpressionModel";

jslModel = JslParser.getModelFromFiles(
"TestDerivedExpressionModel",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,8 @@ static void prepareTestFolders() throws IOException {

@Test
void testCreateEntityType() throws Exception {
testName = "TestCreateEntityType";

jslModel = JslParser.getModelFromStrings(
"EntityTypeCreateModel",
List.of("model EntityTypeCreateModel;\n" +
"\n" +
"entity Test {\n" +
Expand Down Expand Up @@ -104,10 +102,8 @@ void testCreateEntityType() throws Exception {

@Test
void testEntityLocalName() throws Exception {
testName = "TestEntityLocaleName";

jslModel = JslParser.getModelFromStrings(
"First::Second::EntityLocaleNameModel",
List.of("model First::Second::EntityLocaleNameModel;\n" +
"\n" +
"entity Test {\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ static void prepareTestFolders() throws IOException {

@Test
void testDefaultValues() throws Exception {
testName = "TestDefaultValues";

jslModel = JslParser.getModelFromFiles(
"TestDefaultExpressionModel",
List.of(new File("src/test/resources/entity/TestDefaultExpressionModel.jsl"))
);

Expand Down
Loading
Loading