Skip to content

Commit

Permalink
JNG-5333 Add update / delete allow flag trnasformation added
Browse files Browse the repository at this point in the history
  • Loading branch information
robertcsakany committed Jan 31, 2024
1 parent fd4fe09 commit a6c7cfb
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@ operation JSL!TransferActionDeclaration getId(): String {

@cached
operation JSL!TransferActionDeclaration isUpdateAllowed() : Boolean {
if (self.output.isDefined()){
// TODO: JNG-5333 Calculate
// return self.`return`.isUpdateAllowed();
if (self.`return`.isDefined()){
return self.modifiers.exists(m | m.isTypeOf(JSL!UpdateModifier) and m.`true`);
}
return false;
}

@cached
operation JSL!TransferActionDeclaration isDeleteAllowed() : Boolean {
if (self.output.isDefined()){
// TODO: JNG-5333 Calculate
// return self.`return`.isDeleteAllowed();
return false;
if (self.`return`.isDefined()){
return self.modifiers.exists (m | m.isTypeOf(JSL!DeleteModifier) and m.`true`);
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,6 @@ rule CreateBoundOperationForMappedTransferObjectType
t.setId("(jsl/" + s.getId() + ")/CreateBoundOperationForMappedTransferObjectType");
t.binding = s.equivalent("CreateBoundOperationForEntityType");

// TODO: JNG-5333 Modifiers for action's return
// t.updateOnResult = s.isUpdateAllowed();
// t.deleteOnResult = s.isDeleteAllowed();

s.eContainer.equivalent("CreateMappedTransferObjectType").operations.add(t);
log.debug("Created CreateBoundOperationForMappedTransferObjectType: " + t.name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ void testActions() throws Exception {
.excpectInput(false)
.expectMappedInput(false)
.excpectOutput(true)
.expectMappedOutput(false));
.expectMappedOutput(false)
);

assertOperation(param()
.transferName("MappedTransfer")
Expand All @@ -254,7 +255,9 @@ void testActions() throws Exception {
.excpectInput(false)
.expectMappedInput(false)
.excpectOutput(true)
.expectMappedOutput(true));
.expectMappedOutput(true)
.deleteOnResult(true)
.updateOnResult(true));

assertOperation(param()
.transferName("MappedTransfer")
Expand Down Expand Up @@ -290,8 +293,10 @@ void testActions() throws Exception {
.excpectInput(true)
.expectMappedInput(false)
.excpectOutput(true)
.expectMappedOutput(true));

.expectMappedOutput(true)
.deleteOnResult(true)
.updateOnResult(true));

assertOperation(param()
.transferName("MappedTransfer")
.operationName("staticMappedOutputActionWithUnmappedInput")
Expand Down Expand Up @@ -326,7 +331,10 @@ void testActions() throws Exception {
.excpectInput(true)
.expectMappedInput(true)
.excpectOutput(true)
.expectMappedOutput(true));
.expectMappedOutput(true)
.deleteOnResult(true)
.updateOnResult(true));


assertOperation(param()
.transferName("MappedTransfer")
Expand Down Expand Up @@ -359,6 +367,10 @@ void testActions() throws Exception {
assertThat(assertUnmappedTransferObject("UnmappedFaultTransfer").getOperations().size(), equalTo(1));
assertOperationFaults("UnmappedFaultTransfer", "staticFaults");


assertThat(assertTransferObjectOperation("UnmappedInputParameter", "default").getBehaviour().getBehaviourType(),
equalTo(TransferOperationBehaviourType.GET_TEMPLATE));

}

@Builder
Expand All @@ -370,6 +382,8 @@ private static class AssertOperationParameters {
boolean expectMappedInput;
boolean excpectOutput;
boolean expectMappedOutput;
boolean deleteOnResult;
boolean updateOnResult;
}

private AssertOperationParameters.AssertOperationParametersBuilder param() {
Expand Down Expand Up @@ -403,7 +417,10 @@ private void assertOperation(AssertOperationParameters.AssertOperationParameters
} else {
assertThat(operation.getOutput().getType(), equalTo(assertUnmappedTransferObject("UnmappedOutputParameter")));
}
assertThat(operation.getOutput().getCardinality().getLower(), equalTo(1));
assertThat(operation.getOutput().getCardinality().getLower(), equalTo(1));

assertThat(operation.isDeleteOnResult(), equalTo(p.deleteOnResult));
assertThat(operation.isUpdateOnResult(), equalTo(p.updateOnResult));
} else {
assertThat(operation.getOutput(), is(nullValue()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ transfer MappedTransfer maps Entity as e {
action UnmappedOutputParameter unmappedOutputAction();
action static UnmappedOutputParameter staticUnmappedOutputAction();

action MappedOutputParameter mappedOutputAction();
action MappedOutputParameter mappedOutputAction() update: true delete: true;
action static MappedOutputParameter staticMappedOutputAction();

action UnmappedOutputParameter unmappedOutputActionWithUnmappedInput(UnmappedInputParameter param);
action static UnmappedOutputParameter staticUnmappedOutputActionWithUnmappedInput(UnmappedInputParameter param);

action MappedOutputParameter mappedOutputActionWithUnmappedInput(UnmappedInputParameter param);
action MappedOutputParameter mappedOutputActionWithUnmappedInput(UnmappedInputParameter param) update: true delete: true;;
action static MappedOutputParameter staticMappedOutputActionWithUnmappedInput(UnmappedInputParameter param);

action UnmappedOutputParameter unmappedOutputActionWithMappedInput(MappedInputParameter param choices:InputParameterEntity.all());
action static UnmappedOutputParameter staticUnmappedOutputActionWithMappedInput(MappedInputParameter param choices:InputParameterEntity.all());

action MappedOutputParameter mappedOutputActionWithMappedInput(MappedInputParameter param choices:InputParameterEntity.all());
action MappedOutputParameter mappedOutputActionWithMappedInput(MappedInputParameter param choices:InputParameterEntity.all()) update: true delete: true;;
action static MappedOutputParameter staticMappedOutputActionWithMappedInput(MappedInputParameter param choices:InputParameterEntity.all());
}

Expand Down Expand Up @@ -77,6 +77,8 @@ transfer UnmappedInputParameter {


transfer MappedOutputParameter maps OutputParameterEntity as o {
event instead update update();
event instead delete delete();
}

transfer MappedInputParameter maps InputParameterEntity as i {
Expand Down

0 comments on commit a6c7cfb

Please sign in to comment.