From bf532023a533d8026faef97c37dca96f872153e6 Mon Sep 17 00:00:00 2001 From: Robert Csakany Date: Tue, 16 Jan 2024 11:54:06 +0100 Subject: [PATCH] Add Refresh behaviour --- .../psm/modules/action/refreshBehaviour.etl | 105 +++--------------- .../operation/JslAction2PsmOperationTest.java | 10 +- .../JslModel2PsmCrudBehaviourTest.java | 4 +- .../operation/CrudBehaviourTestModel.jsl | 1 - 4 files changed, 26 insertions(+), 94 deletions(-) diff --git a/judo-tatami-jsl-jsl2psm/src/main/epsilon/transformations/psm/modules/action/refreshBehaviour.etl b/judo-tatami-jsl-jsl2psm/src/main/epsilon/transformations/psm/modules/action/refreshBehaviour.etl index f718ea36..83f8991c 100644 --- a/judo-tatami-jsl-jsl2psm/src/main/epsilon/transformations/psm/modules/action/refreshBehaviour.etl +++ b/judo-tatami-jsl-jsl2psm/src/main/epsilon/transformations/psm/modules/action/refreshBehaviour.etl @@ -1,15 +1,14 @@ import "../../../../operations/_importAll.eol"; -/* @greedy rule CreateRefreshOperationForEntityType transform s: JSL!TransferDeclaration to t: JUDOPSM!BoundOperation { - guard: s.isRefreshSupported() + guard: generateBehaviours and s.map.isDefined() t.setId("(jsl/" + s.getId() + ")/CreateRefreshOperationForEntityType"); t.instanceRepresentation = s.equivalent("CreateMappedTransferObjectType"); - t.name = s.name + s.getFqName().fqNameToCamelCase(); + t.name = "Refresh" + s.getFqName().fqNameToCamelCase(); s.map.entity.getPSMEquivalent().operations.add(t); log.debug("Created CreateRefreshOperationForEntityType: " + t.name); } @@ -18,10 +17,10 @@ rule CreateRefreshOperationForEntityType rule CreateRefreshBehaviourForTransferType transform s: JSL!TransferDeclaration to t: JUDOPSM!TransferOperationBehaviour { - guard: s.isRefreshSupported() + guard: generateBehaviours and s.map.isDefined() t.setId("(jsl/" + s.getId() + ")/CreateRefreshBehaviourForTransferType"); - t.behaviourType = JUDOPSM!TransferOperationBehaviourType#REFRESH_INSTANCE; + t.behaviourType = JUDOPSM!TransferOperationBehaviourType#REFRESH; t.owner = s.equivalent("CreateMappedTransferObjectType"); log.debug("Created CreateRefreshBehaviourForTransferType: " + s.name); } @@ -30,10 +29,10 @@ rule CreateRefreshBehaviourForTransferType rule CreateRefreshOperationForTransferType transform s: JSL!TransferDeclaration to t: JUDOPSM!BoundTransferOperation { - guard: s.isRefreshSupported() + guard: generateBehaviours and s.map.isDefined() t.setId("(jsl/" + s.getId() + ")/CreateRefreshOperationForTransferType"); - t.name = s.name; + t.name = "refreshInstance"; t.binding = s.equivalent("CreateRefreshOperationForEntityType"); t.behaviour = s.equivalent("CreateRefreshBehaviourForTransferType"); s.equivalent("CreateMappedTransferObjectType").operations.add(t); @@ -45,12 +44,12 @@ rule CreateRefreshOperationForTransferType rule CreateRefreshOperationForTransferTypeInputParameter transform s: JSL!TransferDeclaration to t: JUDOPSM!Parameter { - guard: s.isRefreshSupported() + guard: generateBehaviours and s.map.isDefined() t.setId("(jsl/" + s.getId() + ")/CreateRefreshOperationForTransferTypeInputParameter"); t.cardinality = s.equivalent("CreateCardinalityForRefreshTransferTypeInput"); t.name = "input"; - t.type = s.getPSMEquivalent(); + t.type = s.equivalent("CreateQueryCustomizerType"); s.equivalent("CreateRefreshOperationForTransferType").input = t; log.debug("Created CreateRefreshOperationForTransferTypeInputParameter: " + t.name); } @@ -59,7 +58,7 @@ rule CreateRefreshOperationForTransferTypeInputParameter rule CreateRefreshOperationForTransferTypeOutputParameter transform s: JSL!TransferDeclaration to t: JUDOPSM!Parameter { - guard: s.isRefreshSupported() + guard: generateBehaviours and s.map.isDefined() t.setId("(jsl/" + s.getId() + ")/CreateRefreshOperationForTransferTypeOutputParameter"); t.cardinality = s.equivalent("CreateCardinalityForRefreshTransferTypeOutput"); @@ -73,12 +72,12 @@ rule CreateRefreshOperationForTransferTypeOutputParameter rule CreateRefreshOperationForEntityTypeInputParameter transform s: JSL!TransferDeclaration to t: JUDOPSM!Parameter { - guard: s.isRefreshSupported() + guard: generateBehaviours and s.map.isDefined() t.setId("(jsl/" + s.getId() + ")/CreateRefreshOperationForEntityTypeInputParameter"); t.cardinality = s.equivalent("CreateCardinalityForRefreshEntityTypeInput"); t.name = "input"; - t.type = s.getPSMEquivalent(); + t.type = s.equivalent("CreateQueryCustomizerType"); s.equivalent("CreateRefreshOperationForEntityType").input = t; log.debug("Created CreateRefreshOperationForEntityTypeInputParameter: " + t.name); } @@ -87,7 +86,7 @@ rule CreateRefreshOperationForEntityTypeInputParameter rule CreateRefreshOperationForEntityTypeOutputParameter transform s: JSL!TransferDeclaration to t: JUDOPSM!Parameter { - guard: s.isRefreshSupported() + guard: generateBehaviours and s.map.isDefined() t.setId("(jsl/" + s.getId() + ")/CreateRefreshOperationForEntityTypeOutputParameter"); t.cardinality = s.equivalent("CreateCardinalityForRefreshEntityTypeOutput"); @@ -101,7 +100,7 @@ rule CreateRefreshOperationForEntityTypeOutputParameter @lazy @greedy rule CreateCardinalityForRefreshTransferTypeInput - transform s : JSL!TransferDeclaration + transform s: JSL!TransferDeclaration to t : JUDOPSM!Cardinality { t.setId("(jsl/" + s.getId() + ")/CreateCardinalityForRefreshTransferTypeInput"); @@ -112,7 +111,7 @@ rule CreateCardinalityForRefreshTransferTypeInput @lazy @greedy rule CreateCardinalityForRefreshTransferTypeOutput - transform s : JSL!TransferDeclaration + transform s: JSL!TransferDeclaration to t : JUDOPSM!Cardinality { t.setId("(jsl/" + s.getId() + ")/CreateCardinalityForRefreshTransferTypeOutput"); @@ -123,7 +122,7 @@ rule CreateCardinalityForRefreshTransferTypeOutput @lazy @greedy rule CreateCardinalityForRefreshEntityTypeInput - transform s : JSL!TransferDeclaration + transform s: JSL!TransferDeclaration to t : JUDOPSM!Cardinality { t.setId("(jsl/" + s.getId() + ")/CreateCardinalityForRefreshEntityTypeInput"); @@ -134,7 +133,7 @@ rule CreateCardinalityForRefreshEntityTypeInput @lazy @greedy rule CreateCardinalityForRefreshEntityTypeOutput - transform s : JSL!TransferDeclaration + transform s: JSL!TransferDeclaration to t : JUDOPSM!Cardinality { t.setId("(jsl/" + s.getId() + ")/CreateCardinalityForRefreshEntityTypeOutput"); @@ -142,75 +141,3 @@ rule CreateCardinalityForRefreshEntityTypeOutput t.upper = 1; } -*/ - -/* -@greedy -rule CreateRefreshOperationForTransferObjectType - transform s : ESM!TransferObjectType - to t : JUDOPSM!BoundOperation { - guard: esmUtils.isRefreshSupported(s) - - t.setId("(esm/" + s.getId() + ")/RefreshOperationForTransferObjectType"); - - t.name = "_refreshInstance" + "For" + esmUtils.getNamespaceElementFQName(s).replace("::", "_").firstToUpperCase(); - t.instanceRepresentation = s.getPSMTransferObjectTypeEquivalent(); - - t.input = new JUDOPSM!Parameter; - t.input.setId("(esm/" + s.getId() + ")/RefreshOperationForTransferObjectType/Input"); - t.input.name = "input"; - t.input.type = s.equivalent("CreateQueryCustomizerType"); - t.input.cardinality = new JUDOPSM!Cardinality; - t.input.cardinality.setId("(esm/" + s.getId() + ")/RefreshOperationForTransferObjectType/Input/Cardinality"); - t.input.cardinality.lower = 0; - t.input.cardinality.upper = 1; - - t.output = new JUDOPSM!Parameter; - t.output.setId("(esm/" + s.getId() + ")/RefreshOperationForTransferObjectType/Output"); - t.output.name = "output"; - t.output.type = s.getPSMTransferObjectTypeEquivalent(); - t.output.cardinality = new JUDOPSM!Cardinality; - t.output.cardinality.setId("(esm/" + s.getId() + ")/RefreshOperationForTransferObjectType/Output/Cardinality"); - t.output.cardinality.lower = 1; - t.output.cardinality.upper = 1; - - s.mapping.target.equivalent("CreateEntityType").operations.add(t); -} - -@greedy -rule CreateRefreshTransferOperationForTransferObjectType - transform s : ESM!TransferObjectType - to t : JUDOPSM!BoundTransferOperation { - guard: esmUtils.isRefreshSupported(s) - - t.setId("(esm/" + s.getId() + ")/RefreshTransferOperationForTransferObjectType"); - - t.name = "_refreshInstance" + esmUtils.getNamespaceElementFQName(s).replace("::", "_").firstToUpperCase(); - t.behaviour = new JUDOPSM!TransferOperationBehaviour; - t.behaviour.setId("(esm/" + s.getId() + ")/RefreshTransferOperationForTransferObjectType/Behaviour"); - t.behaviour.behaviourType = JUDOPSM!TransferOperationBehaviourType#REFRESH; - t.behaviour.owner = s.getPSMTransferObjectTypeEquivalent(); - - t.input = new JUDOPSM!Parameter; - t.input.setId("(esm/" + s.getId() + ")/RefreshTransferOperationForTransferObjectType/Input"); - t.input.name = "input"; - t.input.type = s.equivalent("CreateQueryCustomizerType"); - t.input.cardinality = new JUDOPSM!Cardinality; - t.input.cardinality.setId("(esm/" + s.getId() + ")/RefreshTransferOperationForTransferObjectType/Input/Cardinality"); - t.input.cardinality.lower = 0; - t.input.cardinality.upper = 1; - - t.output = new JUDOPSM!Parameter; - t.output.setId("(esm/" + s.getId() + ")/RefreshTransferOperationForTransferObjectType/Output"); - t.output.name = "output"; - t.output.type = s.getPSMTransferObjectTypeEquivalent(); - t.output.cardinality = new JUDOPSM!Cardinality; - t.output.cardinality.setId("(esm/" + s.getId() + ")/RefreshTransferOperationForTransferObjectType/Output/Cardinality"); - t.output.cardinality.lower = 1; - t.output.cardinality.upper = 1; - - t.binding = s.equivalent("CreateRefreshOperationForTransferObjectType"); - - s.getPSMTransferObjectTypeEquivalent().operations.add(t); -} -*/ diff --git a/judo-tatami-jsl-jsl2psm/src/test/java/hu/blackbelt/judo/tatami/jsl/jsl2psm/operation/JslAction2PsmOperationTest.java b/judo-tatami-jsl-jsl2psm/src/test/java/hu/blackbelt/judo/tatami/jsl/jsl2psm/operation/JslAction2PsmOperationTest.java index d59a162d..69ea94fc 100644 --- a/judo-tatami-jsl-jsl2psm/src/test/java/hu/blackbelt/judo/tatami/jsl/jsl2psm/operation/JslAction2PsmOperationTest.java +++ b/judo-tatami-jsl-jsl2psm/src/test/java/hu/blackbelt/judo/tatami/jsl/jsl2psm/operation/JslAction2PsmOperationTest.java @@ -101,7 +101,7 @@ void testActions() throws Exception { assertMappedTransferObject("MappedTransfer"); - assertThat(assertMappedTransferObject("MappedTransfer").getOperations().size(), equalTo(18)); + assertThat(assertMappedTransferObject("MappedTransfer").getOperations().size(), equalTo(19)); assertOperation("MappedTransfer", "voidAction", true, false, false, false, false); assertOperation("MappedTransfer", "staticVoidAction", false, false, false, false, false); @@ -128,13 +128,17 @@ void testActions() throws Exception { assertThat(assertTransferObjectOperation("UnmappedInputParameter", "default").getBehaviour().getBehaviourType(), equalTo(TransferOperationBehaviourType.GET_TEMPLATE)); - assertThat(assertMappedTransferObject("MappedInputParameter").getOperations().size(), equalTo(0)); + assertThat(assertMappedTransferObject("MappedInputParameter").getOperations().size(), equalTo(1)); + assertThat(assertTransferObjectOperation("MappedInputParameter", "refreshInstance").getBehaviour().getBehaviourType(), + equalTo(TransferOperationBehaviourType.REFRESH)); assertMappedTransferObject("MappedFaultTransfer"); - assertThat(assertMappedTransferObject("MappedFaultTransfer").getOperations().size(), equalTo(2)); + assertThat(assertMappedTransferObject("MappedFaultTransfer").getOperations().size(), equalTo(3)); assertOperationFaults("MappedFaultTransfer", "faults"); assertOperationFaults("MappedFaultTransfer", "staticFaults"); + assertThat(assertTransferObjectOperation("MappedFaultTransfer", "refreshInstance").getBehaviour().getBehaviourType(), + equalTo(TransferOperationBehaviourType.REFRESH)); assertUnmappedTransferObject("UnmappedFaultTransfer"); assertThat(assertUnmappedTransferObject("UnmappedFaultTransfer").getOperations().size(), equalTo(1)); diff --git a/judo-tatami-jsl-jsl2psm/src/test/java/hu/blackbelt/judo/tatami/jsl/jsl2psm/operation/JslModel2PsmCrudBehaviourTest.java b/judo-tatami-jsl-jsl2psm/src/test/java/hu/blackbelt/judo/tatami/jsl/jsl2psm/operation/JslModel2PsmCrudBehaviourTest.java index 0e0e3956..0a946400 100644 --- a/judo-tatami-jsl-jsl2psm/src/test/java/hu/blackbelt/judo/tatami/jsl/jsl2psm/operation/JslModel2PsmCrudBehaviourTest.java +++ b/judo-tatami-jsl-jsl2psm/src/test/java/hu/blackbelt/judo/tatami/jsl/jsl2psm/operation/JslModel2PsmCrudBehaviourTest.java @@ -87,7 +87,7 @@ void testBehaviours() throws Exception { transform(); assertMappedTransferObject("MappedTransfer"); - assertThat(assertMappedTransferObject("MappedTransfer").getOperations().size(), equalTo(12)); + assertThat(assertMappedTransferObject("MappedTransfer").getOperations().size(), equalTo(13)); assertCrudOperation("MappedTransfer", "deleteInstance", TransferOperationBehaviourType.DELETE_INSTANCE, true, null, false, null, false); @@ -122,6 +122,8 @@ void testBehaviours() throws Exception { assertCrudOperation("MappedTransfer", "unsetReferencesOfRelationCrudBehaviourTestModelMappedTransferCreateEntities", TransferOperationBehaviourType.UNSET_REFERENCE, true, "CreateTransfer", true, null, false); + assertCrudOperation("MappedTransfer", "refreshInstance", + TransferOperationBehaviourType.REFRESH, true, "_MappedTransferQueryCustomizer", false, "MappedTransfer", true); } diff --git a/judo-tatami-jsl-jsl2psm/src/test/resources/operation/CrudBehaviourTestModel.jsl b/judo-tatami-jsl-jsl2psm/src/test/resources/operation/CrudBehaviourTestModel.jsl index 9d3dfc51..408707d6 100644 --- a/judo-tatami-jsl-jsl2psm/src/test/resources/operation/CrudBehaviourTestModel.jsl +++ b/judo-tatami-jsl-jsl2psm/src/test/resources/operation/CrudBehaviourTestModel.jsl @@ -57,7 +57,6 @@ entity Entity { } - transfer CreateTransfer maps CreateEntity as e { event instead create createInstance; }