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-5840 transform relations - round 1 #244

Merged
merged 15 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions judo-tatami-jsl-jsl2ui/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[src/main/epsilon/**.{eol,etl}]
charset = utf-8
indent_style = space
indent_size = 4
insert_final_newline = true
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
operation Any equivalentDiscriminated(transformation : String, id : String, discriminator : String) : Any {
if (self.isUndefined()) {
throw "Transformation called in empty object: " + id + " / " + discriminator + " Transformation: " + transformation;
}
var targetId = id + "/(discriminator/" + discriminator + ")";
if (self.isUndefined()) {
throw "Transformation called in empty object: " + id + " / " + discriminator + " Transformation: " + transformation;
}
noherczeg marked this conversation as resolved.
Show resolved Hide resolved
var targetId = id + "/(discriminator/" + discriminator + ")";
var r = JSL.target.resource;

// Find the discriminated id in cahe first
var f = __cacheMap.get(targetId);
var f = __cacheMap.get(targetId);

// Whenit is not found in cache, search from the model and put to cache when found
if (f.isUndefined()) {
f = ecoreUtil.getAllContents(r, false).select(e | e.getId() == targetId).first;
if (f.isDefined()) {
__cacheMap.put(targetId, f);
return f;
}
}
// When the element found, but ID is different, it is missused of discriminated API, error
if (f.isUndefined()) {
f = ecoreUtil.getAllContents(r, false).select(e | e.getId() == targetId).first;
if (f.isDefined()) {
__cacheMap.put(targetId, f);
return f;
}
}

// When the element found, but ID is different, it is missused of discriminated API, error
if (f.isDefined()) {
if (f.getId() != targetId) {
throw "ID does not match defined in cache: " + f.getId() + " Cache ID: " + targetId;
throw "ID does not match defined in cache: " + f.getId() + " Cache ID: " + targetId;
}
return f;
return f;
noherczeg marked this conversation as resolved.
Show resolved Hide resolved
} else {
// When no model element with discriminated ID found, call equivalent to create original element or get it
f = self.equivalent(transformation);
// When no model element with discriminated ID found, call equivalent to create original element or get it
f = self.equivalent(transformation);

if (f.isUndefined()) {
throw "No instance of transformation call: " + id + " / " + discriminator + " Transformation: " + transformation;
}
// When discriminated ID not matches new clone have to be created
if (__originalMap.containsKey(f) and f.getId() != targetId) {
f = ecoreUtil.copy(f);
r.contents.add(f);
if (f.isUndefined()) {
throw "No instance of transformation call: " + id + " / " + discriminator + " Transformation: " + transformation;
}
noherczeg marked this conversation as resolved.
Show resolved Hide resolved

// When discriminated ID not matches new clone have to be created
if (__originalMap.containsKey(f) and f.getId() != targetId) {
f = ecoreUtil.copy(f);
r.contents.add(f);

__cacheMap.put(targetId, f);
// Store traceability links
/*
for (t in transTrace.transformations) {
if (t.source == self and t.rule.name == transformation) {
t.targets.add(f);
}
} */
__cacheMap.put(targetId, f);
// Store traceability links
/*
for (t in transTrace.transformations) {
if (t.source == self and t.rule.name == transformation) {
t.targets.add(f);
}
} */
}
f.eResource.setId(f, targetId);
if (not __originalMap.containsKey(f)) {
__originalMap.put(f, targetId);
}
f.eResource.setId(f, targetId);
if (not __originalMap.containsKey(f)) {
__originalMap.put(f, targetId);
}
__cacheMap.put(targetId, f);
return f;
__cacheMap.put(targetId, f);
return f;
}
}

operation Any equivalentDiscriminated(transformation : String, discriminator : String) : Any {
return self.equivalentDiscriminated(transformation,
"(jsl/" + self.getId() + ")/" + transformation,
discriminator
);
return self.equivalentDiscriminated(transformation,
"(jsl/" + self.getId() + ")/" + transformation,
discriminator
);
}
32 changes: 16 additions & 16 deletions judo-tatami-jsl-jsl2ui/src/main/epsilon/operations/id.eol
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
operation Any setId(id: String) {
if (id.isUndefined()) {
throw "ID is not defined" + self;
}
if (self.isUndefined()) {
throw "Could not determinate ID of " + self;
}
var r = self.eResource;
if (id.isUndefined()) {
throw "ID is not defined" + self;
}
if (self.isUndefined()) {
throw "Could not determinate ID of " + self;
}
var r = self.eResource;
if (r.isUndefined()) {
throw "Object is not added to resource " + self;
throw "Object is not added to resource " + self;
}
if (__originalMap.containsKey(self)) {
__originalMap.put(self, id);
__originalMap.put(self, id);
}
if (__cacheMap.containsKey(self.getId())) {
__cacheMap.remove(self.getId());
__cacheMap.put(id, self);
__cacheMap.remove(self.getId());
__cacheMap.put(id, self);
}
r.setId(self, id);
}

operation Any getId() : String {
if (self.isUndefined()) {
throw "Could not determinate ID of " + self;
}
var r = self.eResource;
if (self.isUndefined()) {
throw "Could not determinate ID of " + self;
}
var r = self.eResource;
if (r.isUndefined()) {
throw "Object is not added to resource " + self;
throw "Object is not added to resource " + self;
}

return r.getId(self);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
import "actor/_importActor.eol";
import "data/_importData.eol";
import "namespace/_importNamespace.eol";
import "ui/_importUI.eol";
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import "actorAccessDeclaration.eol";
import "actorDeclaration.eol";
import "actorGroupDeclaration.eol";
import "actorLinkDeclaration.eol";
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,3 @@ operation JSL!ActorDeclaration getExposedTransferObjects() : Set {

return collected;
}

@cached
operation JSL!ActorDeclaration getTransferObjects() : Set {
var transfers = new Set();
self.collectExposed(new Set(), transfers, new Set());
return transfers;
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import "actorAccessDeclaration.eol";
import "actorDeclaration.eol";
import "actorGroupDeclaration.eol";
import "actorLinkDeclaration.eol";
import "dataTypeDeclaration.eol";
import "modelDeclaration.eol";
import "entityMemberDeclaration.eol";
import "enumDeclaration.eol";
import "enumLiteral.eol";
import "modifiable.eol";
import "primitiveDeclaration.eol";
import "simpleTransferDeclaration.eol";
import "transferDeclaration.eol";
import "transferFieldDeclaration.eol";
import "transferRelationDeclaration.eol";
import "viewDeclaration.eol";
import "visibleDeclaration.eol";

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@cached
operation JSL!EntityMemberDeclaration isEager() : Boolean {
return jslUtils.isEager(self);
}

@cached
operation JSL!EntityMemberDeclaration isCalculated(): Boolean {
return jslUtils.isCalculated(self);
}

@cached
operation JSL!EntityMemberDeclaration isRequired(): Boolean {
return jslUtils.isRequired(self);
}

This file was deleted.

Loading
Loading