Skip to content

Commit

Permalink
Add Refresh behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
robertcsakany committed Jan 16, 2024
1 parent 80a5730 commit bf53202
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 94 deletions.
Original file line number Diff line number Diff line change
@@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
Expand All @@ -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);
}
Expand All @@ -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");
Expand All @@ -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);
}
Expand All @@ -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");
Expand All @@ -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");

Expand All @@ -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");

Expand All @@ -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");

Expand All @@ -134,83 +133,11 @@ rule CreateCardinalityForRefreshEntityTypeInput
@lazy
@greedy
rule CreateCardinalityForRefreshEntityTypeOutput
transform s : JSL!TransferDeclaration
transform s: JSL!TransferDeclaration
to t : JUDOPSM!Cardinality {
t.setId("(jsl/" + s.getId() + ")/CreateCardinalityForRefreshEntityTypeOutput");

t.lower = 1;
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);
}
*/
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ entity Entity {
}



transfer CreateTransfer maps CreateEntity as e {
event instead create createInstance;
}
Expand Down

0 comments on commit bf53202

Please sign in to comment.