-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: workflow for creating an offering (#351)
* feat(wrapper): create OfferingResource * test(wrapper): Add API test for offering endpoint WIP: Test for empty string input * refactor(wrapper): return response for createOfferingEndpoint * refactor(wrapper): delete unnecessary variable * [WIP] feat(wrapper): model dtos * feat(wrapper): replace incomplete and add missing model schemas in open api specification * feat(wrapper): create OfferingResource * test(wrapper): Add API test for offering endpoint WIP: Test for empty string input * refactor(wrapper): return response for createOfferingEndpoint * refactor(wrapper): delete unnecessary variable * [WIP] feat(wrapper): model dtos * feat(wrapper): replace incomplete and add missing model schemas in open api specification * feat(wrapper): Implement PolicyDTO and MappingService * feat(wrapper): Implement PolicyDTO and MappingService * feat(wrapper): Implement first PolicyMappingService test * docs(wrapper): Checkstyle conform JavaDoc * fix(wrapper): OfferingService tests * test: update PolicyMappingServiceTest * test: rename OfferingResourceTest * test: add OfferingServiceTest * chore: checkstyle * refactor(wrapper): PR #351 suggestions WIP * fix(wrapper): Tests * refactor(wrapper): Replace loops with java streams * refactor(wrapper): Move offering endpoint to use-case api * refactor(wrapper): Move validation to service * chore(model): add ExpressionDto * docs(common-api): JavaDoc and OpenAPI schema * fix(wrapper): offering tests * chore(policy): throw exception when permission missing * refactor(common-api): policy model * refactor(wrapper): consistent naming * fix(wrapper): import order --------- Co-authored-by: sbiehs <[email protected]> Co-authored-by: Tim Dahlmanns <[email protected]> Co-authored-by: Richard Treier <[email protected]>
- Loading branch information
1 parent
fc2212d
commit e754e0d
Showing
21 changed files
with
1,195 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...mon-api/src/main/java/de/sovity/edc/ext/wrapper/api/common/model/AtomicConstraintDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package de.sovity.edc.ext.wrapper.api.common.model; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
/** | ||
* Opinionated DTO of an EDC Constraint for permissions. | ||
* | ||
* @author [email protected] | ||
*/ | ||
@Getter | ||
@Setter | ||
@ToString | ||
@AllArgsConstructor | ||
@RequiredArgsConstructor | ||
@Schema(description = | ||
"Type-Safe OpenAPI generator friendly Constraint DTO that supports an opinionated" | ||
+ " subset of the original EDC Constraint Entity.") | ||
public class AtomicConstraintDto { | ||
|
||
@Schema(description = "Left part of the constraint.", | ||
requiredMode = Schema.RequiredMode.REQUIRED) | ||
private String leftExpression; | ||
@Schema(description = "Operator to connect both parts of the constraint.", | ||
requiredMode = Schema.RequiredMode.REQUIRED) | ||
private OperatorDto operator; | ||
@Schema(description = "Right part of the constraint.", | ||
requiredMode = Schema.RequiredMode.REQUIRED) | ||
private String rightExpression; | ||
} |
40 changes: 40 additions & 0 deletions
40
...er-common-api/src/main/java/de/sovity/edc/ext/wrapper/api/common/model/ExpressionDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package de.sovity.edc.ext.wrapper.api.common.model; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import java.util.List; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
/** | ||
* Expression constraints for policies. | ||
* | ||
* @author [email protected] | ||
*/ | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class ExpressionDto { | ||
|
||
@Schema(description = """ | ||
Expression types: | ||
* `EMPTY` - No constraints for the policy | ||
* `ATOMIC_CONSTRAINT` - A single constraint for the policy | ||
* `AND` - Several constraints, all of which must be respected | ||
* `OR` - Several constraints, of which at least one must be respected | ||
* `XOR` - Several constraints, of which exactly one must be respected | ||
""" | ||
) | ||
private Type type; | ||
private AtomicConstraintDto atomicConstraint; | ||
private List<ExpressionDto> and; | ||
private List<ExpressionDto> or; | ||
private List<ExpressionDto> xor; | ||
|
||
/** | ||
* Sum type enum. | ||
*/ | ||
public enum Type { | ||
EMPTY, ATOMIC_CONSTRAINT, AND, OR, XOR | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...pper-common-api/src/main/java/de/sovity/edc/ext/wrapper/api/common/model/OperatorDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package de.sovity.edc.ext.wrapper.api.common.model; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
/** | ||
* The set of supported expression operators. Not all operators may be supported for particular | ||
* expression types. | ||
* Copied from EDC policy-model. | ||
* | ||
* @author [email protected] | ||
*/ | ||
@Schema(description = "Operator for constraints") | ||
public enum OperatorDto { | ||
/** | ||
* Operator expressing equality of two operands. | ||
*/ | ||
EQ, | ||
/** | ||
* Operator expressing inequality of two operands. | ||
*/ | ||
NEQ, | ||
/** | ||
* Operator expressing left operand is greater than right operand. | ||
*/ | ||
GT, | ||
/** | ||
* Operator expressing left operand is greater or equal than to the right operand. | ||
*/ | ||
GEQ, | ||
/** | ||
* Operator expressing left operand is lesser than to the right operand. | ||
*/ | ||
LT, | ||
/** | ||
* Operator expressing left operand is lesser or equal than to the right operand. | ||
*/ | ||
LEQ, | ||
/** | ||
* Operator expressing left operand is contained in the right operand. | ||
*/ | ||
IN | ||
} |
26 changes: 26 additions & 0 deletions
26
...er-common-api/src/main/java/de/sovity/edc/ext/wrapper/api/common/model/PermissionDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package de.sovity.edc.ext.wrapper.api.common.model; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
/** | ||
* Subset of the possible permissions in the EDC. | ||
* | ||
* @author [email protected] | ||
*/ | ||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder(toBuilder = true) | ||
public class PermissionDto { | ||
|
||
@Schema(description = "Possible constraints for the permission", | ||
requiredMode = RequiredMode.REQUIRED) | ||
private ExpressionDto constraints; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,22 +15,34 @@ | |
package de.sovity.edc.ext.wrapper.api.common.model; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
/** | ||
* Opinionated subset of the EDC policy. | ||
* | ||
* @author [email protected] | ||
*/ | ||
@Getter | ||
@Setter | ||
@ToString | ||
@AllArgsConstructor | ||
@Builder(toBuilder = true) | ||
@RequiredArgsConstructor | ||
@Schema(description = "Type-Safe OpenAPI generator friendly Policy DTO that supports an opinionated" + | ||
" subset of the original EDC Policy Entity.") | ||
@Schema(description = "Type-Safe OpenAPI generator friendly Policy DTO that supports an opinionated" | ||
+ " subset of the original EDC Policy Entity.") | ||
public class PolicyDto { | ||
@Schema(description = "Legacy JSON as built by the Management API. Will be replaced " + | ||
"in the future by a type-safe variant without polymorphisms that can be used " + | ||
"for our generated clients.", requiredMode = Schema.RequiredMode.REQUIRED) | ||
private Object legacyPolicy; | ||
|
||
@Schema(description = "Legacy JSON as built by the Management API. Will be replaced " | ||
+ "in the future by a type-safe variant without polymorphisms that can be used " | ||
+ "for our generated clients.", requiredMode = Schema.RequiredMode.NOT_REQUIRED) | ||
private String legacyPolicy; | ||
|
||
@Schema(description = "Permission for this policy", requiredMode = RequiredMode.NOT_REQUIRED) | ||
private PermissionDto permission; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.