Skip to content

Commit

Permalink
feat(assetindex): Refactor the dynamic assembly of queries (#1496)
Browse files Browse the repository at this point in the history
  • Loading branch information
paullatzelsperger committed Jun 21, 2022
1 parent 9395de6 commit 147ae2f
Show file tree
Hide file tree
Showing 25 changed files with 724 additions and 416 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ in the detailed section referring to by linking pull requests or issues.
#### Changed

* Provided default no-op `TransactionContext` (#1461)
* Refactored query capabilites for `Asset` (#1459)

#### Removed

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
* Copyright (c) 2022 Microsoft Corporation
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
Expand All @@ -8,11 +8,11 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
* Microsoft Corporation - initial API and implementation
*
*/

package org.eclipse.dataspaceconnector.test.e2e.postgresql;
package org.eclipse.dataspaceconnector.common.util.postgres;

import java.sql.DriverManager;
import java.sql.SQLException;
Expand Down
6 changes: 3 additions & 3 deletions extensions/sql/asset-index-sql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ Please apply this [schema](docs/schema.sql) to your SQL database.
```plantuml
@startuml
entity edc_asset {
* asset_id: string <<PK>>
* asset_id_fk: string <<PK>>
--
}
entity edc_asset_dataaddress {
* asset_id: string <<PK>>
* asset_id_fk: string <<PK>>
* properties: string <<json>>
--
}
entity edc_asset_property {
* asset_id: string <<PK>>
* asset_id_fk: string <<PK>>
* property_name: string
* property_value: string
* property_type: string
Expand Down
2 changes: 2 additions & 0 deletions extensions/sql/asset-index-sql/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ plugins {

val h2Version: String by project
val assertj: String by project
val postgresVersion: String by project

dependencies {
api(project(":spi:core-spi"))
Expand All @@ -33,6 +34,7 @@ dependencies {
testImplementation("com.h2database:h2:${h2Version}")
testImplementation("org.assertj:assertj-core:${assertj}")
testImplementation(testFixtures(project(":common:util")))
testImplementation("org.postgresql:postgresql:${postgresVersion}")
}

publishing {
Expand Down
6 changes: 3 additions & 3 deletions extensions/sql/asset-index-sql/docs/er.puml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
@startuml
entity edc_asset {
* asset_id: string <<PK>>
* id: string <<PK>>
--
}

entity edc_asset_dataaddress {
* asset_id: string <<PK>>
* asset_id_fk: string <<PK>>
* properties: string <<json>>
--
}

entity edc_asset_property {
* asset_id: string <<PK>>
* asset_id_fk: string <<PK>>
* property_name: string
* property_value: string
* property_type: string
Expand Down
37 changes: 20 additions & 17 deletions extensions/sql/asset-index-sql/docs/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,32 @@
-- THIS SCHEMA HAS BEEN WRITTEN AND TESTED ONLY FOR POSTGRES

-- table: edc_asset
CREATE TABLE IF NOT EXISTS edc_asset (
CREATE TABLE IF NOT EXISTS edc_asset
(
asset_id VARCHAR NOT NULL,
PRIMARY KEY (asset_id)
);
);

-- table: edc_asset_dataaddress
CREATE TABLE IF NOT EXISTS edc_asset_dataaddress (
asset_id VARCHAR NOT NULL,
properties VARCHAR NOT NULL,
PRIMARY KEY (asset_id),
FOREIGN KEY (asset_id) REFERENCES edc_asset (asset_id) ON DELETE CASCADE
);
COMMENT ON COLUMN edc_asset_dataaddress.properties is 'DataAddress properties serialized as JSON';
CREATE TABLE IF NOT EXISTS edc_asset_dataaddress
(
asset_id_fk VARCHAR NOT NULL,
properties JSON NOT NULL,
PRIMARY KEY (asset_id_fk),
FOREIGN KEY (asset_id_fk) REFERENCES edc_asset (asset_id) ON DELETE CASCADE
);
COMMENT ON COLUMN edc_asset_dataaddress.properties IS 'DataAddress properties serialized as JSON';

-- table: edc_asset_property
CREATE TABLE IF NOT EXISTS edc_asset_property (
asset_id VARCHAR NOT NULL,
property_name VARCHAR NOT NULL,
CREATE TABLE IF NOT EXISTS edc_asset_property
(
asset_id_fk VARCHAR NOT NULL,
property_name VARCHAR NOT NULL,
property_value VARCHAR NOT NULL,
property_type VARCHAR NOT NULL,
PRIMARY KEY (asset_id, property_name),
FOREIGN KEY (asset_id) REFERENCES edc_asset (asset_id) ON DELETE CASCADE
);
property_type VARCHAR NOT NULL,
PRIMARY KEY (asset_id_fk, property_name),
FOREIGN KEY (asset_id_fk) REFERENCES edc_asset (asset_id) ON DELETE CASCADE
);

COMMENT ON COLUMN edc_asset_property.property_name IS
'Asset property key';
Expand All @@ -46,4 +49,4 @@ COMMENT ON COLUMN edc_asset_property.property_type IS
'Asset property class name';

CREATE INDEX IF NOT EXISTS idx_edc_asset_property_value
ON edc_asset_property(property_name, property_value);
ON edc_asset_property (property_name, property_value);

This file was deleted.

This file was deleted.

Loading

0 comments on commit 147ae2f

Please sign in to comment.