Skip to content

Commit

Permalink
Merge branch 'develop' into feature/434618_datasets_count
Browse files Browse the repository at this point in the history
  • Loading branch information
ppel-gmv committed Jun 19, 2024
2 parents 658692f + 31bf6d2 commit 74cf770
Show file tree
Hide file tree
Showing 20 changed files with 691 additions and 343 deletions.
4 changes: 2 additions & 2 deletions extensions/federated-catalog-cache-api/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# S3 Asset API
Federated Catalog API

Provides a management API for uploading files to S3 and creating assets.
Provides a management API for getting the federated catalog paginated.
14 changes: 3 additions & 11 deletions extensions/federated-catalog-cache-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ plugins {

dependencies {
api(project(":spi:federated-catalog-cache-spi"))
api(libs.edc.spi.asset)
api(libs.edc.spi.core)
implementation(libs.edc.spi.transform)
implementation(libs.edc.web.spi)
Expand All @@ -16,23 +15,16 @@ dependencies {
implementation(libs.edc.lib.transform)
implementation(libs.edc.dsp.api.configuration)
implementation(libs.edc.api.management.config)
implementation(libs.swagger.annotations.jakarta)
implementation(libs.edc.transaction.spi)
implementation(libs.edc.lib.validator)
implementation(libs.edc.validator.spi)
implementation(libs.swagger.annotations.jakarta)
implementation(libs.jakarta.rsApi)
implementation(libs.jakarta.eeApi)
implementation(libs.parsson)
implementation(libs.jersey)
implementation(libs.edc.json.ld.lib)
implementation(libs.aws.s3)
implementation(libs.aws.s3.transfer)
implementation(libs.edc.api.asset)
implementation(libs.edc.control.plane.transform)
implementation(libs.edc.aws.s3.core)
runtimeOnly(libs.edc.spi.jsonld)
runtimeOnly(libs.edc.json.ld.lib)
implementation(libs.edc.control.plane.transform)
implementation(libs.edc.federated.catalog.api)
implementation(libs.edc.federated.catalog.core)
implementation(libs.edc.federated.catalog.spi)

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public String name() {
return NAME;
}
/**
* Provides a default vocabularyService implementation
* Provides a default federatedCatalogCacheService implementation
*/
@Provider(isDefault = true)
public FederatedCatalogCacheService federatedCatalogCacheService() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,32 @@
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.json.JsonArray;
import jakarta.json.JsonObject;
import jakarta.ws.rs.core.MediaType;
import org.eclipse.edc.api.model.ApiCoreSchema;
import org.eclipse.edc.catalog.spi.model.FederatedCatalogCacheQuery;
import org.eclipse.edc.connector.controlplane.contract.spi.types.offer.ContractOffer;
import org.eclipse.edc.spi.query.QuerySpec;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;

import java.io.InputStream;

/**
* This interface represents the API for accessing the Federated Catalog. It provides operations to obtain catalogs with
* dataset pagination.
*/
@OpenAPIDefinition(
info = @Info(description = "This represents the Federated Catalog API.",
title = "Federated Catalog API", version = "1"))
info = @Info(description = "This represents the Federated Catalog API.", title = "Federated Catalog API",
version = "1"))
@Tag(name = "Federated Catalog")
public interface FederatedCatalogCacheApi {
@Operation(description = "Obtains all Catalog with dataset pagination",
responses = {
@ApiResponse(responseCode = "200", description = "A list of Catalog is returned, potentially empty",
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ContractOffer.class)))),
@ApiResponse(responseCode = "500", description = "A Query could not be completed due to an internal error")
}
/**
* Obtains all catalogs with dataset pagination based on the provided query specification.
*
* @param querySpec the specification of the query which includes filters, sorting, and pagination details.
* @return a JsonArray containing the list of catalogs that match the query criteria, potentially empty.
*/
@Operation(description = "Obtains all Catalog with dataset pagination", responses = {
@ApiResponse(responseCode = "200", description = "A list of Catalog is returned, potentially empty",
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ContractOffer.class)))),
@ApiResponse(responseCode = "500", description = "A Query could not be completed due to an internal error") }

)
JsonArray getFederatedCatalog(JsonObject querySpec);
)
JsonArray getFederatedCatalog(JsonObject querySpec);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,40 @@
import static org.eclipse.edc.spi.query.QuerySpec.EDC_QUERY_SPEC_TYPE;
import static org.eclipse.edc.web.spi.exception.ServiceResultHandler.exceptionMapper;

@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
/**
* Controller class for the Federated Catalog Cache API. This class implements the {@link FederatedCatalogCacheApi}
* interface and provides the API endpoints to interact with the federated catalog cache.
*/
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Path("/federatedcatalog")
public class FederatedCatalogCacheApiController
implements FederatedCatalogCacheApi {
public class FederatedCatalogCacheApiController implements FederatedCatalogCacheApi {
private final TypeTransformerRegistry transformerRegistry;
private final FederatedCatalogCacheService service;
private final JsonObjectValidatorRegistry validator;
private final Monitor monitor;


public FederatedCatalogCacheApiController(FederatedCatalogCacheService service, TypeTransformerRegistry transformerRegistry,
JsonObjectValidatorRegistry validator, Monitor monitor) {
/**
* Constructs a FederatedCatalogCacheApiController with the specified dependencies.
*
* @param service the service used to access the federated catalog cache.
* @param transformerRegistry the registry for type transformers.
* @param validator the registry for JSON object validators.
* @param monitor the monitor used for logging and monitoring.
*/
public FederatedCatalogCacheApiController(FederatedCatalogCacheService service,
TypeTransformerRegistry transformerRegistry, JsonObjectValidatorRegistry validator, Monitor monitor) {
this.transformerRegistry = transformerRegistry;
this.service = service;
this.validator = validator;
this.monitor = monitor;
}

/**
* (non-javadoc)
*
* @see FederatedCatalogCacheApi#getFederatedCatalog(JsonObject)
*/
@Override
@POST
@Path("/request")
Expand All @@ -62,9 +77,7 @@ public JsonArray getFederatedCatalog(JsonObject querySpecJson) {
}
return service.searchPagination(querySpec).orElseThrow(exceptionMapper(QuerySpec.class, null)).stream()
.map(it -> transformerRegistry.transform(it, JsonObject.class))
.peek(r -> r.onFailure(f -> monitor.warning(f.getFailureDetail())))
.filter(Result::succeeded)
.map(Result::getContent)
.collect(toJsonArray());
.peek(r -> r.onFailure(f -> monitor.warning(f.getFailureDetail()))).filter(Result::succeeded)
.map(Result::getContent).collect(toJsonArray());
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package org.upm.inesdata.federated.service;

import jakarta.json.JsonObject;
import org.eclipse.edc.connector.controlplane.catalog.spi.Catalog;
import org.eclipse.edc.spi.query.QuerySpec;
import org.eclipse.edc.spi.result.ServiceResult;
import org.eclipse.edc.transaction.spi.TransactionContext;
import org.upm.inesdata.federated.controller.FederatedCatalogCacheApi;
import org.upm.inesdata.spi.federated.FederatedCatalogCacheService;
import org.upm.inesdata.spi.federated.index.PaginatedFederatedCacheStoreIndex;

Expand All @@ -14,19 +16,29 @@
*/
public class FederatedCatalogCacheServiceImpl implements FederatedCatalogCacheService {

private final PaginatedFederatedCacheStoreIndex index;
private final TransactionContext transactionContext;
private final PaginatedFederatedCacheStoreIndex index;
private final TransactionContext transactionContext;

/**
* Constructor
*/
public FederatedCatalogCacheServiceImpl(PaginatedFederatedCacheStoreIndex index, TransactionContext transactionContext) {
this.index = index;
/**
* Constructs a FederatedCatalogCacheServiceImpl with the specified dependencies.
*
* @param index the paginated federated cache store index used for managing the catalog cache.
* @param transactionContext the context for handling transactions.
*/
public FederatedCatalogCacheServiceImpl(PaginatedFederatedCacheStoreIndex index,
TransactionContext transactionContext) {
this.index = index;

this.transactionContext = transactionContext;
}
@Override
public ServiceResult<Collection<Catalog>> searchPagination(QuerySpec querySpec) {
return transactionContext.execute(() -> ServiceResult.success(index.queryPagination(querySpec)));
}
this.transactionContext = transactionContext;
}

/**
* (non-javadoc)
*
* @see FederatedCatalogCacheService#searchPagination(QuerySpec)
*/
@Override
public ServiceResult<Collection<Catalog>> searchPagination(QuerySpec querySpec) {
return transactionContext.execute(() -> ServiceResult.success(index.queryPagination(querySpec)));
}
}
39 changes: 38 additions & 1 deletion extensions/federated-catalog-cache-sql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,51 @@ Please apply this [schema](docs/schema.sql) to your SQL database.

## Entity Diagram

![ER Diagram](//www.plantuml.com/plantuml/png/SoWkIImgAStDuKhDAyaigLH8JKcEByjFJamgpKaigbIevb9Gq5B8JB5IA2ufoinBLx2n2V2simEBvYNcfiB4mG9PnVbvmSaPgRc9ACB9HQc99QafZYLM2ZdvO35TNQvQBeVKl1IWnG00)
![ER Diagram](////www.plantuml.com/plantuml/png/ZPF1QiCm38RlUGgTn_82ePIU1cMC3ShEnR6Lef5OHbRBHhjtNzA4uR3Cv2hfp_T9mRkeHlJSjGLw9Vq2TFPeZPgMJt0j01w0N0LHXVm9Dfktv-tsNWrzZ2m5utN_Ep1sX0FsJOmLl9YmETnRZ_1QVw3LCOsVWGJxNCtSel5ziIoBxoArSBr5HCrQSDEWP3XhNAPjzodWQGGiEXqZoeKiPiKKfOkpiw1tWSdhkxH9_I-1XbvzLc8_4HgMpkZiOuF7OTHOyXu78kggfQO3B2sNkKrE8k4a0BZTofAlwS-jmB9NGpuk3oxBpLEpLXfDJrb14BwGmrWa-F-dyu1rRZlqRdXPFm00)
<!--
```plantuml
@startuml
entity edc_catalog {
* id: string <<PK>>
* participantId: string
* properties: Map<String, Object>
* expired: boolean
--
}
entity edc_dataset {
* id: string <<PK>>
* offers: Map<String, Object>
* properties: Map<String, Object>
* catalogId: string <<FK>>
--
}
entity edc_data_service {
* id: string <<PK>>
* terms: string
* endpointUrl: string
--
}
entity edc_distribution {
* format: string
* dataServiceId: string <<FK>>
* datasetId: string <<FK>>
--
}
entity edc_catalog_data_service {
* catalogId: string <<FK>>
* dataServiceId: string <<FK>>
--
}
edc_catalog ||--o{ edc_dataset: contains
edc_catalog ||--o{ edc_catalog_data_service: contains
edc_data_service ||--o{ edc_distribution: provides
edc_dataset ||--o{ edc_distribution: contains
edc_data_service ||--o{ edc_catalog_data_service: contains
@enduml
```
-->
Expand Down
39 changes: 38 additions & 1 deletion extensions/federated-catalog-cache-sql/docs/er.puml
Original file line number Diff line number Diff line change
@@ -1,6 +1,43 @@
@startuml
entity edc_catalog {
* id: string <<PK>>
* participantId: string
* properties: Map<String, Object>
* expired: boolean
--
}
@enduml

entity edc_dataset {
* id: string <<PK>>
* offers: Map<String, Object>
* properties: Map<String, Object>
* catalogId: string <<FK>>
--
}

entity edc_data_service {
* id: string <<PK>>
* terms: string
* endpointUrl: string
--
}

entity edc_distribution {
* format: string
* dataServiceId: string <<FK>>
* datasetId: string <<FK>>
--
}

entity edc_catalog_data_service {
* catalogId: string <<FK>>
* dataServiceId: string <<FK>>
--
}

edc_catalog ||--o{ edc_dataset: contains
edc_catalog ||--o{ edc_catalog_data_service: contains
edc_data_service ||--o{ edc_distribution: provides
edc_dataset ||--o{ edc_distribution: contains
edc_data_service ||--o{ edc_catalog_data_service: contains
@enduml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,17 @@ public class SqlFederatedCacheServiceExtension implements ServiceExtension {
@Inject
private QueryExecutor queryExecutor;


/**
* Provides a defaultCacheStore implementation
*/
@Provider(isDefault = true)
public PaginatedFederatedCacheStoreIndex defaultCacheStore() {
return new SqlFederatedCacheStore(dataSourceRegistry, DATASOURCE_SETTING_NAME,transactionContext,getObjectMapper(),dialect,queryExecutor);
}

/**
* Initializes the service
*/
@Override
public void initialize(ServiceExtensionContext context) {
var dataSourceName = context.getConfig().getString(DATASOURCE_SETTING_NAME, DataSourceRegistry.DEFAULT_DATASOURCE);
Expand Down
Loading

0 comments on commit 74cf770

Please sign in to comment.