Skip to content

Commit

Permalink
JNG-5866 Add handling UI subtypes of Transfer field, relation (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertcsakany authored Jul 23, 2024
1 parent 362ac30 commit 9d04ce6
Show file tree
Hide file tree
Showing 22 changed files with 329 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ import "data/_importData.eol";
import "type/_importType.eol";
import "action/_importAction.eol";
import "namespace/_importNamespace.eol";
import "ui/_importUi.eol";
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ import "transferUpdateDeclaration.eol";
import "transferDeleteDeclaration.eol";
import "actorDeclaration.eol";
import "actorAccessDeclaration.eol";
import "actorGroupDeclaration.eol";
import "actorLinkDeclaration.eol";
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ operation JSL!ActorAccessDeclaration getId(): String {
return (self.eContainer.getId() + "/" + self.name);
}

@cached
operation JSL!ActorAccessDeclaration getActorDeclaration(): JSL!ActorDeclaration {
if (self.eContainer.isTypeOf(JSL!ActorGroupDeclaration)) {
return self.eContainer.getActorDeclaration();
} else if (self.eContainer.isTypeOf(JSL!ActorDeclaration)) {
return self.eContainer;
}
return null;
}

@cached
operation JSL!ActorAccessDeclaration getTransferContainer(): JSL!TransferDeclaration {
return self.eContainer;
}

/*

@cached
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@cached
operation JSL!ActorGroupDeclaration getFqName(): String {
if (self.eContainer.isTypeOf(JSL!ActorGroupDeclaration) or self.eContainer.isTypeOf(JSL!ActorDeclaration)) {
return self.eContainer.getFqName() + "::MenuItemGroup::" + self.name;
}
return self.tag;
}

@cached
operation JSL!ActorGroupDeclaration getActorDeclaration(): JSL!ActorDeclaration {
if (self.eContainer.isTypeOf(JSL!ActorGroupDeclaration)) {
return self.eContainer.getActorDeclaration();
} else if (self.eContainer.isTypeOf(JSL!ActorDeclaration)) {
return self.eContainer;
}
return null;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@cached
operation JSL!ActorLinkDeclaration getFqName(): String {
if (self.eContainer.isTypeOf(JSL!ActorGroupDeclaration) or self.eContainer.isTypeOf(JSL!ActorDeclaration)) {
return self.eContainer.getFqName() + "::" + self.name;
}
return self.name;
}

@cached
operation JSL!ActorLinkDeclaration getActorDeclaration(): JSL!ActorDeclaration {
if (self.eContainer.isTypeOf(JSL!ActorGroupDeclaration)) {
return self.eContainer.getActorDeclaration();
} else if (self.eContainer.isTypeOf(JSL!ActorDeclaration)) {
return self.eContainer;
}
return null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ operation JSL!TransferDeclaration getId(): String {

@cached
operation JSL!TransferDeclaration getModelRoot(): JUDOPSM!Package {
return self.getTransferDeclarationEquivalent().eContainer().getModelRoot();
return self.eContainer().getModelRoot();
}


@cached
operation JSL!TransferDeclaration isDeleteSupported(): Boolean {
if (self.map.isDefined()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,8 @@ operation JSL!TransferFieldDeclaration isFilterable() : Boolean {
);
}

@cached
operation JSL!TransferFieldDeclaration getTransferContainer(): JSL!TransferDeclaration {
return self.eContainer;
}

Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ operation JSL!TransferRelationDeclaration getMappedTransferRelationEquivalent()

@cached
operation JSL!TransferRelationDeclaration isActorRelated(): Boolean {
return self.isKindOf(JSL!ActorAccessDeclaration);
return self.isKindOf(JSL!ActorAccessDeclaration) or self.isKindOf(JSL!ActorLinkDeclaration);
}

@cached
operation JSL!TransferRelationDeclaration getTransferContainer(): JSL!TransferDeclaration {
return self.eContainer;
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import "viewDeclaration.eol";
import "viewFieldDeclaration.eol";
import "viewGroupDeclaration.eol";
import "viewPanelDeclaration.eol";
import "viewTabsDeclaration.eol";
import "visibleDeclaration.eol";
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@cached
operation JSL!ViewDeclaration getId(): String {
return (self.eContainer.getId() + "/" + self.name);
}

@cached
operation JSL!ViewDeclaration getFqName(): String {
return self.eContainer.getFqName() + "::" + self.name;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@cached
operation JSL!ViewFieldDeclaration getId(): String {
return (self.eContainer.getId() + "/" + self.name);
}

@cached
operation JSL!ViewFieldDeclaration getFqName(): String {
return self.eContainer.getFqName() + "::" + self.name;
}

@cached
operation JSL!ViewFieldDeclaration getTransferContainer(): JSL!TransferDeclaration {
var to = self.eContainer;
while (to.isDefined() and not to.isKindOf(JSL!TransferDeclaration)) {
to = to.eContainer;
}
return to;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@cached
operation JSL!ViewGroupDeclaration getId(): String {
return (self.eContainer.getId() + "/" + self.name);
}

@cached
operation JSL!ViewGroupDeclaration getFqName(): String {
return self.eContainer.getFqName() + "::" + self.name;
}

@cached
operation JSL!ViewGroupDeclaration getTransferContainer(): JSL!TransferDeclaration {
var to = self.eContainer;
while (to.isDefined() and not to.isKindOf(JSL!TransferDeclaration)) {
to = to.eContainer;
}
return to;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@cached
operation JSL!ViewPanelDeclaration getModelRoot(): JUDOPSM!Package {
return self.eContainer().getModelRoot();
}

@cached
operation JSL!ViewPanelDeclaration getTransferContainer(): JSL!TransferDeclaration {
if (self.eContainer.isKindOf(JSL!TransferDeclaration)) {
return self.eContainer;
} else if (self.eContainer.isKindOf(JSL!ViewPanelDeclaration)) {
return self.eContainer.getTransferContainer();
}

return null;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@cached
operation JSL!ViewTabsDeclaration getId(): String {
return (self.eContainer.getId() + "/" + self.name);
}

@cached
operation JSL!ViewTabsDeclaration getFqName(): String {
return self.eContainer.getFqName() + "::" + self.name;
}

@cached
operation JSL!ViewTabsDeclaration getTransferContainer(): JSL!TransferDeclaration {
var to = self.eContainer;
while (to.isDefined() and not to.isKindOf(JSL!TransferDeclaration)) {
to = to.eContainer;
}
return to;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@cached
operation JSL!VisibleDeclaration getId(): String {
return (self.eContainer.getId() + "/" + self.name);
}

@cached
operation JSL!VisibleDeclaration getFqName(): String {
return self.eContainer.getFqName() + "::" + self.name;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ rule CreateTransientTransferObjectRelationForActorAccessDeclaration
if (s.getDefault().isDefined()) {
t.defaultValue = s.getDefault().equivalent("CreateDefaultStaticNavigationForUnmappedTransferObjectConstructor");
}
if (s.eContainer.map.isDefined()) {
if (s.getActorDeclaration().map.isDefined()) {
t.binding = s.getterExpr.equivalent("CreateReadsNavigationPropertyForMappedTransferObjectTransferRelationDeclaration");
} else {
t.binding = s.getterExpr.equivalent("CreateReadsReferenceExpressionForUnmappedTransferObjectTransferRelationDeclaration");
}

s.eContainer.getActorDeclarationEquivalent().relations.add(t);
s.getActorDeclaration().getActorDeclarationEquivalent().relations.add(t);

log.debug("Created TransferObjectRelation for ActorAccessDeclaration: [" + t.name + "] into [" + t.eContainer.name + "]");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ rule CreateActorTypeWithoutPrincipal
guard: s.getPrincipal().isUndefined()

t.setId("(jsl/" + s.getId() + ")/CreateActorTypeWithoutPrincipal");
t.name = s.name;

if (s.getGuard().isDefined()) {
t.filter = s.equivalent("CreateFilterExpressionForMappedActorType");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ rule CreateQueryCustomizerOrderingEnumeration
rule CreateQueryCustomizerOrderingEnumerationMember
transform s : JSL!TransferFieldDeclaration
to t : JUDOPSM!EnumerationMember {
guard: generateBehaviours and s.eContainer.map.isDefined() and s.isSortable()
guard: generateBehaviours and s.getTransferContainer().map.isDefined() and s.isSortable()
t.setId("(jsl/" + s.getId() + ")/CreateQueryCustomizerOrderingEnumerationDerivedTransferAttribute");
t.name = s.name;
t.ordinal = -1; // will be calculated by post operation
s.eContainer.equivalent("CreateQueryCustomizerOrderingEnumeration").members.add(t);
s.getTransferContainer().equivalent("CreateQueryCustomizerOrderingEnumeration").members.add(t);
log.debug("CreateQueryCustomizerOrderingEnumerationDerivedTransferAttribute: " + t.name);
}

Expand All @@ -197,12 +197,12 @@ rule CreateQueryCustomizerSeekLastItem
rule CreateQueryCustomizerSeekLastItemAttribute
transform s : JSL!TransferFieldDeclaration
to t : JUDOPSM!TransferAttribute {
guard: generateBehaviours and s.eContainer.map.isDefined() and (s.isFilterable() or s.isSortable())
guard: generateBehaviours and s.getTransferContainer().map.isDefined() and (s.isFilterable() or s.isSortable())
t.setId("(jsl/" + s.getId() + ")/CreateQueryCustomizerSeekLastItemAttribute");
t.name = s.name;
t.dataType = s.referenceType.getPrimitiveDeclarationEquivalent();
t.required = false;
s.eContainer.equivalent("CreateQueryCustomizerSeekLastItem").attributes.add(t);
s.getTransferContainer().equivalent("CreateQueryCustomizerSeekLastItem").attributes.add(t);
log.debug("CreateQueryCustomizerSeekLastItemAttribute: " + t.name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ rule CreateTransientTransferAttribute

var def = s.getDefault();
if (def.isDefined()) {
if (s.eContainer.map.isUndefined()) {
if (s.getTransferContainer().map.isUndefined()) {
t.defaultValue = def.equivalent("CreateDefaultStaticDataForUnmappedTransferObjectConstructor");
} else {
t.defaultValue = def.equivalent("CreateDefaultDataPropertyForMappedTransferObjectConstructor");
}
}

s.eContainer.getTransferDeclarationEquivalent().attributes.add(t);
s.getTransferContainer().getTransferDeclarationEquivalent().attributes.add(t);
log.debug("Created TransferAttribute (Field) for TransferFieldDeclaration: [" + t.name + "] into [" + t.eContainer.name + "]");
}

Expand All @@ -44,13 +44,13 @@ rule CreateDerivedTransferAttribute
guard: s.reads()
t.setId("(jsl/" + s.getId() + ")/CreateDerivedTransferAttribute");

if (s.eContainer.map.isDefined()) {
if (s.getTransferContainer().map.isDefined()) {
t.binding = s.getterExpr.equivalent("CreateReadsDataPropertyForMappedTransferObjectTransferFieldDeclaration");
} else {
t.binding = s.getterExpr.equivalent("CreateReadsStaticDataForUnmappedTransferObjectTransferFieldDeclaration");
}

s.eContainer.getTransferDeclarationEquivalent().attributes.add(t);
s.getTransferContainer().getTransferDeclarationEquivalent().attributes.add(t);
log.debug("Created TransferAttribute (Derived) for TransferFieldDeclaration: [" + t.name + "] into [" + t.eContainer.name + "]");
}

Expand All @@ -73,7 +73,7 @@ rule CreateMappedTransferAttribute
} else if (s.getterExpr.features.first.member.getDefault().isDefined()) {
t.defaultValue = s.getterExpr.features.first.member.getDefault().equivalent("CreateDefaultValueForPrimitiveEntityMember");
}
s.eContainer.getTransferDeclarationEquivalent().attributes.add(t);
s.getTransferContainer().getTransferDeclarationEquivalent().attributes.add(t);
log.debug("Created TransferAttribute (Field) for TransferFieldDeclaration: [" + t.name + "] into [" + t.eContainer.name + "]");
}

Expand All @@ -85,12 +85,12 @@ rule CreateMappedTransferAttributeEntityDefault
transform s : JSL!TransferFieldDeclaration
to t : JUDOPSM!TransferAttribute {
guard: s.maps() and s.getterExpr.features.first.member.getDefault().isDefined() and s.getDefault().isUndefined()
t.name = defaultDefaultNamePrefix + s.name + defaultDefaultNameMidfix + s.eContainer.eContainer.name + defaultDefaultNamePostfix;
t.name = defaultDefaultNamePrefix + s.name + defaultDefaultNameMidfix + s.getTransferContainer().eContainer.name + defaultDefaultNamePostfix;
t.setId("(jsl/" + s.getId() + ")/CreateMappedTransferAttributeEntityDefault");
t.binding = s.getterExpr.features.first.member.getDefault().equivalent("CreateDefaultValueForPrimitiveEntityMember");
t.dataType = s.referenceType.getPrimitiveDeclarationEquivalent();
t.required = false;
s.eContainer.getTransferDeclarationEquivalent().attributes.add(t);
s.getTransferContainer().getTransferDeclarationEquivalent().attributes.add(t);
log.debug("Created TransferAttribute DefaultValue (Field) for EntityDefault: [" + t.name + "] into [" + t.eContainer.name + "]");
}

Expand All @@ -99,34 +99,34 @@ rule CreateMappedTransferAttributeEntityDefault
rule CreateTransferEntityDefaultValueAttributeForMappedTransferObjectConstructor
transform s: JSL!DefaultModifier
to t: JUDOPSM!TransferAttribute {
guard: s.eContainer.isKindOf(JSL!TransferFieldDeclaration) and s.eContainer.eContainer.map.isDefined()
t.name = defaultDefaultNamePrefix + s.eContainer.name + defaultDefaultNameMidfix + s.eContainer.eContainer.name + defaultDefaultNamePostfix;
guard: s.eContainer.isKindOf(JSL!TransferFieldDeclaration) and s.eContainer.getTransferContainer().map.isDefined()
t.name = defaultDefaultNamePrefix + s.eContainer.name + defaultDefaultNameMidfix + s.eContainer.getTransferContainer().name + defaultDefaultNamePostfix;
t.binding = s.equivalent("CreateDefaultDataPropertyForMappedTransferObjectConstructor");
t.dataType = s.eContainer.referenceType.getPrimitiveDeclarationEquivalent();
t.setId("(jsl/" + s.eContainer.getId() + ")/CreateTransferEntityDefaultValueAttributeForMappedTransferObjectConstructor");
s.eContainer.eContainer.getTransferDeclarationEquivalent().attributes.add(t);
s.eContainer.getTransferContainer().getTransferDeclarationEquivalent().attributes.add(t);
log.debug("Created TransferAttribute DefaultValue (Field) for MappedTransferObjectConstructor: [" + t.name + "] into [" + t.eContainer.name + "]");
}

@greedy
rule CreateTransferEntityDefaultValueAttributeForUnmappedTransferObjectConstructor
transform s: JSL!DefaultModifier
to t: JUDOPSM!TransferAttribute {
guard: s.eContainer.isKindOf(JSL!TransferFieldDeclaration) and s.eContainer.eContainer.map.isUndefined()
t.name = defaultDefaultNamePrefix + s.eContainer.name + defaultDefaultNameMidfix + s.eContainer.eContainer.name + defaultDefaultNamePostfix;
guard: s.eContainer.isKindOf(JSL!TransferFieldDeclaration) and s.eContainer.getTransferContainer().map.isUndefined()
t.name = defaultDefaultNamePrefix + s.eContainer.name + defaultDefaultNameMidfix + s.eContainer.getTransferContainer().name + defaultDefaultNamePostfix;
t.binding = s.equivalent("CreateDefaultStaticDataForUnmappedTransferObjectConstructor");
t.dataType = s.eContainer.referenceType.getPrimitiveDeclarationEquivalent();
t.setId("(jsl/" + s.eContainer.getId() + ")/CreateTransferEntityDefaultValueAttributeForUnmappedTransferObjectConstructor");

s.eContainer.eContainer.getTransferDeclarationEquivalent().attributes.add(t);
s.eContainer.getTransferContainer().getTransferDeclarationEquivalent().attributes.add(t);

log.debug("Created TransferAttribute DefaultValue (Field) for UnmappedTransferObjectConstructor: [" + t.name + "] into [" + t.eContainer.name + "]");
}

rule CreateAnnotationForTransferEntityDefaultValueAttributeForMappedTransferObjectConstructor
transform s : JSL!DefaultModifier
to t : JUDOPSM!Annotation {
guard: s.eContainer.isKindOf(JSL!TransferFieldDeclaration) and s.eContainer.eContainer.map.isDefined()
guard: s.eContainer.isKindOf(JSL!TransferFieldDeclaration) and s.eContainer.getTransferContainer().map.isDefined()

t.name = "TransferObjectAttributeWithDefaultValue";
t.setId("(jsl/" + s.eContainer.getId() + ")/CreateAnnotationForTransferEntityDefaultValueAttributeForMappedTransferObjectConstructor");
Expand All @@ -137,7 +137,7 @@ rule CreateAnnotationForTransferEntityDefaultValueAttributeForMappedTransferObje
rule CreateAnnotationForTransferEntityDefaultValueAttributeForUnmappedTransferObjectConstructor
transform s : JSL!DefaultModifier
to t : JUDOPSM!Annotation {
guard: s.eContainer.isKindOf(JSL!TransferFieldDeclaration) and s.eContainer.eContainer.map.isUndefined()
guard: s.eContainer.isKindOf(JSL!TransferFieldDeclaration) and s.eContainer.getTransferContainer().map.isUndefined()

t.name = "TransferObjectAttributeWithDefaultValue";
t.setId("(jsl/" + s.eContainer.getId() + ")/CreateAnnotationForTransferEntityDefaultValueAttributeForUnmappedTransferObjectConstructor");
Expand Down
Loading

0 comments on commit 9d04ce6

Please sign in to comment.