-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: id availability check endpoints (#1003)
--------- Co-authored-by: Christophe Loiseau <[email protected]>
- Loading branch information
1 parent
d185e6b
commit a78b169
Showing
11 changed files
with
512 additions
and
234 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
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
21 changes: 21 additions & 0 deletions
21
...pper-api/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/IdAvailabilityResponse.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,21 @@ | ||
package de.sovity.edc.ext.wrapper.api.ui.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@RequiredArgsConstructor | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@Schema(description = "Object indicates whether an ID for the given object type is already taken or not") | ||
public class IdAvailabilityResponse { | ||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED) | ||
private final String id; | ||
|
||
@Schema(description = "ID Availability", requiredMode = Schema.RequiredMode.REQUIRED) | ||
private boolean isAvailable; | ||
} | ||
|
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
45 changes: 45 additions & 0 deletions
45
.../main/java/de/sovity/edc/ext/wrapper/api/ui/pages/data_offer/DataOfferPageApiService.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,45 @@ | ||
package de.sovity.edc.ext.wrapper.api.ui.pages.data_offer; | ||
|
||
import de.sovity.edc.ext.db.jooq.Tables; | ||
import de.sovity.edc.ext.wrapper.api.ui.model.IdAvailabilityResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.val; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jooq.DSLContext; | ||
import org.jooq.Table; | ||
import org.jooq.TableField; | ||
|
||
@RequiredArgsConstructor | ||
public class DataOfferPageApiService { | ||
@NotNull | ||
public IdAvailabilityResponse checkIfPolicyIdAvailable(DSLContext dsl, String id) { | ||
val table = Tables.EDC_POLICYDEFINITIONS; | ||
val field = table.POLICY_ID; | ||
|
||
return new IdAvailabilityResponse(id, isIdAvailable(dsl, table, field, id)); | ||
} | ||
|
||
@NotNull | ||
public IdAvailabilityResponse checkIfAssetIdAvailable(DSLContext dsl, String id) { | ||
val table = Tables.EDC_ASSET; | ||
val field = table.ASSET_ID; | ||
|
||
return new IdAvailabilityResponse(id, isIdAvailable(dsl, table, field, id)); | ||
} | ||
|
||
@NotNull | ||
public IdAvailabilityResponse checkIfContractDefinitionIdAvailable(DSLContext dsl, String id) { | ||
val table = Tables.EDC_CONTRACT_DEFINITIONS; | ||
val field = table.CONTRACT_DEFINITION_ID; | ||
|
||
return new IdAvailabilityResponse(id, isIdAvailable(dsl, table, field, id)); | ||
} | ||
|
||
private boolean isIdAvailable(DSLContext dsl, Table<?> table, TableField<?, String> idField, String id) { | ||
return !dsl.fetchExists( | ||
dsl.select(idField) | ||
.from(table) | ||
.where(idField.eq(id)) | ||
); | ||
} | ||
} |
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.