Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • fair-data-austria-db-repository/fda-services
1 result
Select Git revision
Loading items
Show changes

Commits on Source 17

Showing
with 233 additions and 73 deletions
......@@ -10,7 +10,7 @@
# Supported tags
* [`1.4.3`](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/blob/release-1.4.3/dbrepo-DIR/Dockerfile/)
* [`1.4.4`](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/blob/release-1.4.3/dbrepo-DIR/Dockerfile/)
* [`latest`](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/blob/release-latest/dbrepo-DIR/Dockerfile/)
# Non-supported tags
......@@ -29,8 +29,8 @@
* **Source of this description:**
[docs repo's `.docs/docker` directory](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/tree/release-1.4.3/.docs/docker)
([history](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/commits/release-1.4.3/.docs/docker))
[docs repo's `.docs/docker` directory](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/tree/release-1.4.4/.docs/docker)
([history](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/commits/release-1.4.34/.docs/docker))
# What is DBRepo?
......
---
author: Martin Weise
---
## tl;dr
tbd
## Description
TBD
## Solution
TBD
## DBRepo Features
- [x] Large Dataset ≈15GiB
- [x] Subset Citation using PID
- [x] External access from Grafana Dashboard
\ No newline at end of file
......@@ -9,11 +9,34 @@ author: Martin Weise
## Description
TBD
This data base contains concentrations of hazardous substances and other water quality parameters in different
environmental compartments:
* river water (water and suspended sediments)
* ground water
* waste water (treated and untreated) and sewage sludge
* storm water runoff from combined and separate sewer systems
* atmospheric deposition
* soil
Data from many different data sources were collected, checked and combined and meta data were harmonized to allow for
a combined data evaluation.
## Solution
TBD
We imported the database from the [archive](https://doi.org/10.48436/yaecs-dgr27) repository, converted the PostgreSQL
language code to MariaDB:
* `"current_user"()` to `current_user()`
* `SEQUENCE CACHE 1` to `NOCACHE` because of MariaDB Galera distribution not being able to cache sequences
* `(0)::double precision` to `0.0`
* `character varying` to `text` because MariaDB needs sizes, `text` data type can have arbitrary size
* `!~~` to `NOT LIKE`
* `ANY ARRAY` to `<array> OR <array2>` because of different MariaDB syntax
The complex nature of the views (i.e. `SELECT-FROM-SELECT` statements) required a logical overhaul of how DBRepo obtains
view metadata. As a consequence, we removed the SQL parser that tried to parse the metadata up to a depth of 10 to a
simple query to the `information_schema` that is maintained by the database engine.
## DBRepo Features
......
......@@ -2,10 +2,27 @@
author: Martin Weise
---
## tl;dr
[:fontawesome-solid-database: &nbsp;Dataset](https://dbrepo1.ec.tuwien.ac.at/pid/14){ .md-button .md-button--primary target="_blank" }
[:simple-grafana: &nbsp;Dashboard](https://dbrepo1.ec.tuwien.ac.at/admin/grafana/d/8meGcJD4k/wiener-linien){ .md-button .md-button--secondary target="_blank" }
## Description
TBD
The Subway Transportation Data-Dataset is a comprehensive and dynamic collection of data that captures the intricate
details of the city's public transportation system. This dataset encompasses a wide array of information, including bus
and tram schedules, subway routes, ticketing details, and real-time updates on vehicle locations.
## Solution
TBD
\ No newline at end of file
We wrote an algorithm that parses open data (available) information from Wiener Linien, Vienna's public transportation
agency directly and feeds it, after some cleaning, into DBRepo on a 5-minute interval.
![Subway Transportation Data Dashboard](images/screenshots/transportation-dashboard.png)
## DBRepo Features
- [x] Dynamic data (live data)
- [x] System versioning
- [x] Subset exploration
- [x] External visualization of the database
\ No newline at end of file
.docs/images/screenshots/transportation-dashboard.png

145 KiB

......@@ -5,16 +5,16 @@
<head>
<meta charset="UTF-8">
<title>Redirect Notice</title>
<meta http-equiv="Refresh" content="0; url='/infrastructures/dbrepo/__APPVERSION__/'" />
<meta http-equiv="Refresh" content="0; url='/infrastructures/dbrepo/1.4.4/'" />
</head>
<body>
<h1>Redirect Notice</h1>
<p>
This page should automatically open the documentation for version <code>__APPVERSION__</code>. In case this page does not load the site is
This page should automatically open the documentation for version <code>1.4.4</code>. In case this page does not load the site is
available at:
</p>
<p>
<a href="/infrastructures/dbrepo/__APPVERSION__/">/infrastructures/dbrepo/__APPVERSION__/</a>
<a href="/infrastructures/dbrepo/1.4.4/">/infrastructures/dbrepo/1.4.4/</a>
</p>
</body>
</html>
\ No newline at end of file
......@@ -4,7 +4,6 @@ variables:
TRIVY_CACHE_DIR: ".trivycache/"
DOCKER_HOST: "unix:///var/run/dind/docker.sock"
TESTCONTAINERS_RYUK_DISABLED: "false"
DOC_VERSIONS: "latest,1.4.3,1.4.2,1.4.1,1.4.0"
APP_VERSION: "1.4.4"
CHART_VERSION: "1.4.4"
......@@ -601,10 +600,10 @@ release-chart:
before_script:
- "echo ${CI_REGISTRY2_PASSWORD} | docker login --username ${CI_REGISTRY2_USER} --password-stdin $CI_REGISTRY2_URL"
- "apk add sed helm curl"
- "helm package ./helm/dbrepo --destination ./build"
- "helm plugin install https://github.com/sigstore/helm-sigstore"
script:
- "helm push ./build/dbrepo-${CHART_VERSION}.tgz oci://${CI_REGISTRY2_URL}/helm"
- "helm sigstore upload ./build/dbrepo-${CHART_VERSION}.tgz"
release-docs:
stage: release
......@@ -632,7 +631,9 @@ release-docs:
- echo "$CI_DOC_ID" > ~/.ssh/known_hosts
- tar czf ./final.tar.gz ./final
- "scp -oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedAlgorithms=+ssh-rsa final.tar.gz $CI_DOC_USER@$CI_DOC_IP:final.tar.gz"
- "ssh -oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedAlgorithms=+ssh-rsa $CI_DOC_USER@$CI_DOC_IP 'rm -rf /system/user/ifs/infrastructures/public_html/dbrepo/*; tar xzf ./final.tar.gz; rm -f ./final.tar.gz; cp -r ./final/* /system/user/ifs/infrastructures/public_html/dbrepo/${APP_VERSION}; rm -rf ./final'"
- "scp -oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedAlgorithms=+ssh-rsa versions.json $CI_DOC_USER@$CI_DOC_IP:/system/user/ifs/infrastructures/public_html/dbrepo/versions.json"
- "scp -oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedAlgorithms=+ssh-rsa .docs/redirect.html $CI_DOC_USER@$CI_DOC_IP:/system/user/ifs/infrastructures/public_html/dbrepo/index.html"
- "ssh -oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedAlgorithms=+ssh-rsa $CI_DOC_USER@$CI_DOC_IP 'rm -rf /system/user/ifs/infrastructures/public_html/dbrepo/${APP_VERSION}; tar xzf ./final.tar.gz; rm -f ./final.tar.gz; cp -r ./final/* /system/user/ifs/infrastructures/public_html/dbrepo/${APP_VERSION}; rm -rf ./final'"
release-libs:
stage: release
......
......@@ -25,3 +25,14 @@ Explore the available labels in order to proper categorize it and get the fastes
If the contribution it's a bugfix, a little feature or documentation improvement that could be implemented in, lets say,
a couple of days at maximum, one could go directly for a PR. It's fine.
### Release checklist
- [ ] Change variables `APP_VERSION` and `CHART_VERSION` in CI/CD file `.gitlab-ci.yml`
- [ ] Change Helm chart variables in `helm/dbrepo/Chart.yaml` and update the chart README.md and values.schema.json for artifact hub with `make gen-helm-doc`
- [ ] Change Python library version in `lib/python/setup.py` and `lib/python/pyproject.toml` for PyPI
- [ ] Change the supported tags list in `.docs/docker/_header.md` for docker hub
- [ ] Change the maven version in the metadata & data services:
- `mvn -f ./dbrepo-metadata-service/pom.xml versions:set -DnewVersion=VERSION`
- `mvn -f ./dbrepo-data-service/pom.xml versions:set -DnewVersion=VERSION`
- [ ] Change the versions in `versions.json` for the generated website
\ No newline at end of file
.PHONY: all
APP_VERSION ?= 1.4.3
CHART_VERSION ?= 1.4.3
APP_VERSION ?= 1.4.4
CHART_VERSION ?= 1.4.4
REPOSITORY_URL ?= docker.io/dbrepo
.PHONY: all
......
......@@ -53,7 +53,9 @@ public class SchemaServiceIntegrationTest extends AbstractUnitTest {
genesis();
/* metadata database */
MariaDbConfig.dropDatabase(CONTAINER_1_PRIVILEGED_DTO, DATABASE_1_INTERNALNAME);
MariaDbConfig.dropDatabase(CONTAINER_1_PRIVILEGED_DTO, DATABASE_2_INTERNALNAME);
MariaDbConfig.createInitDatabase(CONTAINER_1_PRIVILEGED_DTO, DATABASE_1_DTO);
MariaDbConfig.createInitDatabase(CONTAINER_1_PRIVILEGED_DTO, DATABASE_2_DTO);
}
@Test
......@@ -92,6 +94,46 @@ public class SchemaServiceIntegrationTest extends AbstractUnitTest {
assertEquals(0, foreignKeys.size());
}
@Test
public void inspectTableEnum_succeeds() throws TableNotFoundException, SQLException, QueryMalformedException {
/* test */
final TableDto response = schemaService.inspectTable(DATABASE_2_PRIVILEGED_DTO, "experiments");
assertEquals("experiments", response.getInternalName());
assertEquals("experiments", response.getName());
assertEquals(DATABASE_2_ID, response.getTdbid());
assertTrue(response.getIsVersioned());
assertEquals(DATABASE_2_PUBLIC, response.getIsPublic());
assertEquals(DATABASE_2_OWNER, response.getCreatedBy());
assertNotNull(response.getCreator());
assertEquals(DATABASE_2_OWNER, response.getCreator().getId());
assertEquals(USER_2_NAME, response.getCreator().getName());
assertEquals(USER_2_USERNAME, response.getCreator().getUsername());
assertEquals(USER_2_FIRSTNAME, response.getCreator().getFirstname());
assertEquals(USER_2_LASTNAME, response.getCreator().getLastname());
assertEquals(USER_2_QUALIFIED_NAME, response.getCreator().getQualifiedName());
assertNotNull(response.getCreator().getAttributes());
assertEquals(USER_2_AFFILIATION, response.getCreator().getAttributes().getAffiliation());
assertEquals(USER_2_THEME, response.getCreator().getAttributes().getTheme());
assertEquals(USER_2_LANGUAGE, response.getCreator().getAttributes().getLanguage());
assertEquals(USER_2_ORCID_URL, response.getCreator().getAttributes().getOrcid());
assertNull(response.getCreator().getAttributes().getMariadbPassword());
final List<IdentifierDto> identifiers = response.getIdentifiers();
assertNotNull(identifiers);
assertEquals(0, identifiers.size());
final List<ColumnDto> columns = response.getColumns();
assertNotNull(columns);
assertEquals(3, columns.size());
assertColumn(columns.get(0), null, null, DATABASE_2_ID, "id", "id", ColumnTypeDto.BIGINT, 19L, 0L, false, null, null);
assertColumn(columns.get(1), null, null, DATABASE_2_ID, "mode", "mode", ColumnTypeDto.ENUM, 3L, null, false, null, null);
assertEquals(2, columns.get(1).getEnums().size());
assertEquals(List.of("ABC", "DEF"), columns.get(1).getEnums());
assertColumn(columns.get(2), null, null, DATABASE_2_ID, "seq", "seq", ColumnTypeDto.SET, 5L, null, true, null, null);
assertEquals(3, columns.get(2).getSets().size());
assertEquals(List.of("1", "2", "3"), columns.get(2).getSets());
/* ignore rest (constraints) */
}
@Test
public void inspectTableFullConstraints_succeeds() throws TableNotFoundException, SQLException, QueryMalformedException {
......
......@@ -38,6 +38,15 @@ create table names
unique key (firstname, lastname)
) with system versioning;
CREATE SEQUENCE seq_experiments;
create table experiments
(
id bigint not null default nextval(seq_experiments),
mode enum ('ABC', 'DEF') not null,
seq set ('1','2','3')
) WITH SYSTEM VERSIONING;
create table likes
(
name_id bigint not null,
......
......@@ -754,6 +754,22 @@ public interface MariaDbMapper {
.databaseId(table.getTdbid())
.description(resultSet.getString(11))
.build();
if (column.getColumnType().equals(ColumnTypeDto.ENUM)) {
column.setEnums(Arrays.stream(resultSet.getString(8)
.substring(0, resultSet.getString(8).length() - 1)
.replace("enum(", "")
.split(","))
.map(value -> value.replace("'", ""))
.toList());
}
if (column.getColumnType().equals(ColumnTypeDto.SET)) {
column.setSets(Arrays.stream(resultSet.getString(8)
.substring(0, resultSet.getString(8).length() - 1)
.replace("set(", "")
.split(","))
.map(value -> value.replace("'", ""))
.toList());
}
/* constraints */
if (resultSet.getString(9) != null && resultSet.getString(9).equals("PRI")) {
table.getConstraints().getPrimaryKey().add(PrimaryKeyDto.builder()
......
......@@ -26,17 +26,17 @@ public class ForeignKeyReference {
private Long id;
@ToString.Exclude
@ManyToOne(fetch = FetchType.LAZY)
@ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.MERGE, CascadeType.PERSIST})
@JoinColumn(name = "fkid", referencedColumnName = "fkid", nullable = false)
private ForeignKey foreignKey;
@ManyToOne(fetch = FetchType.LAZY)
@ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.MERGE})
@JoinColumns({
@JoinColumn(name = "cid", referencedColumnName = "id", nullable = false)
})
private TableColumn column;
@ManyToOne(fetch = FetchType.LAZY)
@ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.MERGE})
@JoinColumns({
@JoinColumn(name = "rcid", referencedColumnName = "id", nullable = false)
})
......
......@@ -540,17 +540,14 @@ public interface MetadataMapper {
pk.getColumn().setDatabaseId(data.getDatabase().getId());
});
for (ForeignKeyDto fk : table.getConstraints().getForeignKeys()) {
fk.getTable().setDatabaseId(table.getTdbid());
fk.getReferencedTable().setDatabaseId(table.getTdbid());
for (ForeignKeyReferenceDto ref : fk.getReferences()) {
ref.setForeignKey(foreignKeyDtoToForeignKeyBriefDto(fk));
ref.getColumn().setTableId(table.getId());
ref.getColumn().setDatabaseId(table.getTdbid());
final Optional<TableColumn> optional = data.getDatabase().getTables().stream().map(Table::getColumns).flatMap(List::stream).filter(c -> c.getId().equals(ref.getReferencedColumn().getId())).findFirst();
if (optional.isEmpty()) {
log.error("Failed to find foreign key referenced column {}.{} in columns: {}", table.getInternalName(), ref.getReferencedColumn().getInternalName(), data.getDatabase().getTables().stream().map(Table::getColumns).flatMap(List::stream).toList());
throw new IllegalArgumentException("Failed to find foreign key referenced column");
}
ref.getReferencedColumn().setTableId(optional.get().getTable().getId());
ref.getReferencedColumn().setDatabaseId(optional.get().getTable().getTdbid());
ref.getReferencedColumn().setTableId(fk.getReferencedTable().getId());
ref.getReferencedColumn().setDatabaseId(table.getTdbid());
}
}
table.getConstraints()
......@@ -594,7 +591,7 @@ public interface MetadataMapper {
Unique uniqueDtoToUnique(UniqueDto data);
@Mappings({
@Mapping(target = "ownedBy", source = "owner.id"),
@Mapping(target = "ownedBy", source = "owner.id")
})
Table tableDtoToTable(TableDto data);
......
......@@ -13,6 +13,7 @@ spring:
default_schema: fda
jdbc:
time_zone: UTC
format_sql: false
application:
name: metadata-service
rabbitmq:
......@@ -43,6 +44,7 @@ logging:
root: warn
at.tuwien.: trace
org.springframework.security.web.FilterChainProxy: debug
# org.hibernate.resource.jdbc: trace
org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver: debug
dbrepo:
repository-name: Database Repository
......
......@@ -284,15 +284,17 @@ public class MetadataMapperUnitTest extends AbstractUnitTest {
assertEquals("fk_location", table1fk.getName());
assertEquals(ReferenceTypeDto.NO_ACTION, table1fk.getOnDelete());
assertEquals(ReferenceTypeDto.NO_ACTION, table1fk.getOnUpdate());
assertEquals(TABLE_1_ID, table1fk.getTable().getId());
assertEquals(TABLE_2_ID, table1fk.getReferencedTable().getId());
assertEquals(TABLE_2_ID, table1fk.getTable().getId());
assertEquals(DATABASE_1_ID, table1fk.getTable().getDatabaseId());
assertEquals(TABLE_1_ID, table1fk.getReferencedTable().getId());
assertEquals(DATABASE_1_ID, table1fk.getReferencedTable().getDatabaseId());
final ForeignKeyReferenceDto table1fkr = table1fk.getReferences().get(0);
assertEquals(1L, table1fkr.getId());
assertEquals(TABLE_2_COLUMNS_DTO.get(2).getId(), table1fkr.getColumn().getId());
assertEquals(TABLE_2_COLUMNS_DTO.get(2).getTable().getId(), table1fkr.getColumn().getTableId());
assertEquals(TABLE_2_COLUMNS_DTO.get(2).getTableId(), table1fkr.getColumn().getTableId());
assertEquals(TABLE_2_COLUMNS_DTO.get(2).getDatabaseId(), table1fkr.getColumn().getDatabaseId());
assertEquals(TABLE_1_COLUMNS_DTO.get(0).getDatabaseId(), table1fkr.getReferencedColumn().getId());
assertEquals(TABLE_1_COLUMNS_DTO.get(0).getDatabaseId(), table1fkr.getReferencedColumn().getTableId());
assertEquals(TABLE_1_COLUMNS_DTO.get(0).getId(), table1fkr.getReferencedColumn().getId());
assertEquals(TABLE_1_COLUMNS_DTO.get(0).getTableId(), table1fkr.getReferencedColumn().getTableId());
assertEquals(TABLE_1_COLUMNS_DTO.get(0).getDatabaseId(), table1fkr.getReferencedColumn().getDatabaseId());
assertEquals(1, table1.getConstraints().getPrimaryKey().size());
final PrimaryKeyDto table1pk = new ArrayList<>(table1.getConstraints().getPrimaryKey()).get(0);
......
......@@ -6,13 +6,13 @@ import at.tuwien.api.database.DatabaseModifyVisibilityDto;
import at.tuwien.api.database.ViewDto;
import at.tuwien.api.database.internal.CreateDatabaseDto;
import at.tuwien.api.database.table.TableDto;
import at.tuwien.api.database.table.columns.ColumnDto;
import at.tuwien.api.database.table.constraints.primary.PrimaryKeyDto;
import at.tuwien.api.user.internal.UpdateUserPasswordDto;
import at.tuwien.entities.container.Container;
import at.tuwien.entities.database.*;
import at.tuwien.entities.database.table.Table;
import at.tuwien.entities.database.table.columns.TableColumn;
import at.tuwien.entities.database.table.constraints.foreignKey.ForeignKey;
import at.tuwien.entities.database.table.constraints.foreignKey.ForeignKeyReference;
import at.tuwien.entities.database.table.constraints.primaryKey.PrimaryKey;
import at.tuwien.entities.user.User;
import at.tuwien.exception.*;
......@@ -238,6 +238,46 @@ public class DatabaseServiceImpl implements DatabaseService {
database.getTables()
.add(tableEntity);
}
/* update referenced tables after they are known to the service */
for (ForeignKey foreignKey : database.getTables().stream().map(t -> t.getConstraints().getForeignKeys()).flatMap(List::stream).toList()) {
log.trace("lookup table {} in tables: {}", foreignKey.getReferencedTable().getInternalName(), database.getTables().stream().map(Table::getInternalName).toList());
final Optional<Table> optional = database.getTables()
.stream()
.filter(t -> t.getInternalName().equals(foreignKey.getReferencedTable().getInternalName()))
.findFirst();
if (optional.isEmpty()) {
log.error("Failed to find referenced table: {}.{}", database.getInternalName(), foreignKey.getReferencedTable().getInternalName());
throw new IllegalArgumentException("Failed to find referenced table: " + database.getInternalName() + "." + foreignKey.getReferencedTable().getInternalName());
}
foreignKey.setReferencedTable(optional.get());
for (ForeignKeyReference reference : foreignKey.getReferences()) {
reference.setForeignKey(foreignKey);
final Optional<TableColumn> optional1 = database.getTables()
.stream()
.filter(t -> t.getInternalName().equals(foreignKey.getTable().getInternalName()))
.map(Table::getColumns)
.flatMap(List::stream)
.filter(c -> c.getInternalName().equals(reference.getColumn().getInternalName()))
.findFirst();
if (optional1.isEmpty()) {
log.error("Failed to find foreign key column: {}.{}.{}", database.getInternalName(), foreignKey.getTable().getInternalName(), reference.getColumn().getInternalName());
throw new IllegalArgumentException("Failed to find foreign key column: " + reference.getColumn().getInternalName());
}
reference.setColumn(optional1.get());
final Optional<TableColumn> optional2 = database.getTables()
.stream()
.filter(t -> t.getInternalName().equals(foreignKey.getReferencedTable().getInternalName()))
.map(Table::getColumns)
.flatMap(List::stream)
.filter(c -> c.getInternalName().equals(reference.getReferencedColumn().getInternalName()))
.findFirst();
if (optional2.isEmpty()) {
log.error("Failed to find foreign key referenced column: {}", reference.getReferencedColumn().getInternalName());
throw new IllegalArgumentException("Failed to find foreign key referenced column: " + reference.getReferencedColumn().getInternalName());
}
reference.setReferencedColumn(optional2.get());
}
}
/* update in metadata database */
database = databaseRepository.save(database);
/* save in search service */
......
......@@ -72,9 +72,13 @@ public abstract class AbstractUnitTest extends BaseTest {
/* DATABASE 2 */
DATABASE_2.setSubsets(new LinkedList<>());
DATABASE_2.setAccesses(new LinkedList<>(List.of(DATABASE_2_USER_2_WRITE_ALL_ACCESS, DATABASE_2_USER_3_READ_ACCESS)));
DATABASE_2_PRIVILEGED_DTO.setAccesses(new LinkedList<>(List.of(DATABASE_2_USER_2_WRITE_ALL_ACCESS_DTO, DATABASE_2_USER_3_READ_ACCESS_DTO)));
DATABASE_2.setTables(new LinkedList<>(List.of(TABLE_5, TABLE_6, TABLE_7)));
DATABASE_2.setViews(new LinkedList<>(List.of(VIEW_4)));
DATABASE_2.setIdentifiers(new LinkedList<>(List.of(IDENTIFIER_5)));
DATABASE_2_PRIVILEGED_DTO.setTables(new LinkedList<>(List.of(TABLE_5_DTO, TABLE_6_DTO, TABLE_7_DTO)));
DATABASE_2_PRIVILEGED_DTO.setViews(new LinkedList<>(List.of(VIEW_4_DTO)));
DATABASE_2_PRIVILEGED_DTO.setIdentifiers(new LinkedList<>(List.of(IDENTIFIER_5_DTO)));
TABLE_5.setDatabase(DATABASE_2);
TABLE_5.setColumns(new LinkedList<>(TABLE_5_COLUMNS));
TABLE_5.setConstraints(TABLE_5_CONSTRAINTS);
......
......@@ -29,7 +29,6 @@ import at.tuwien.api.database.table.internal.PrivilegedTableDto;
import at.tuwien.api.datacite.DataCiteBody;
import at.tuwien.api.datacite.DataCiteData;
import at.tuwien.api.datacite.doi.DataCiteDoi;
import at.tuwien.api.error.ApiErrorDto;
import at.tuwien.api.identifier.*;
import at.tuwien.api.keycloak.CredentialDto;
import at.tuwien.api.keycloak.CredentialTypeDto;
......@@ -74,21 +73,15 @@ import at.tuwien.entities.maintenance.BannerMessageType;
import at.tuwien.entities.semantics.Ontology;
import at.tuwien.entities.user.User;
import at.tuwien.test.utils.ArrayUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.MediaType;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.ResponseStatus;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.charset.Charset;
......@@ -592,6 +585,8 @@ public abstract class BaseTest {
.firstname(USER_2_FIRSTNAME)
.lastname(USER_2_LASTNAME)
.name(USER_2_NAME)
.qualifiedName(USER_2_QUALIFIED_NAME)
.attributes(USER_2_ATTRIBUTES_DTO)
.build();
public final static UserBriefDto USER_2_BRIEF_DTO = UserBriefDto.builder()
......@@ -1257,14 +1252,6 @@ public abstract class BaseTest {
public final static UUID DATABASE_2_OWNER = USER_2_ID;
public final static UUID DATABASE_2_CREATOR = USER_2_ID;
public final static PrivilegedDatabaseDto DATABASE_2_PRIVILEGED_DTO = PrivilegedDatabaseDto.builder()
.id(DATABASE_2_ID)
.name(DATABASE_2_NAME)
.internalName(DATABASE_2_INTERNALNAME)
.container(CONTAINER_1_PRIVILEGED_DTO)
.views(new LinkedList<>())
.build();
public final static DatabaseCreateDto DATABASE_2_CREATE = DatabaseCreateDto.builder()
.name(DATABASE_2_NAME)
.isPublic(DATABASE_2_PUBLIC)
......@@ -7178,6 +7165,22 @@ public abstract class BaseTest {
.identifiers(new LinkedList<>())
.build();
public final static PrivilegedDatabaseDto DATABASE_2_PRIVILEGED_DTO = PrivilegedDatabaseDto.builder()
.id(DATABASE_2_ID)
.created(Instant.now().minus(1, HOURS))
.isPublic(DATABASE_2_PUBLIC)
.name(DATABASE_2_NAME)
.container(CONTAINER_1_PRIVILEGED_DTO)
.internalName(DATABASE_2_INTERNALNAME)
.exchangeName(DATABASE_2_EXCHANGE)
.identifiers(List.of(IDENTIFIER_5_DTO))
.tables(List.of(TABLE_5_DTO, TABLE_6_DTO, TABLE_7_DTO))
.views(List.of(VIEW_4_DTO))
.created(DATABASE_2_CREATED)
.creator(USER_2_DTO)
.owner(USER_2_DTO)
.build();
public final static DatabaseDto DATABASE_2_DTO = DatabaseDto.builder()
.id(DATABASE_2_ID)
.created(DATABASE_2_CREATED)
......@@ -7240,6 +7243,13 @@ public abstract class BaseTest {
.user(USER_2)
.build();
public final static DatabaseAccessDto DATABASE_2_USER_2_WRITE_ALL_ACCESS_DTO = DatabaseAccessDto.builder()
.type(AccessTypeDto.WRITE_ALL)
.hdbid(DATABASE_2_ID)
.huserid(USER_2_ID)
.user(USER_2_DTO)
.build();
public final static DatabaseAccess DATABASE_2_USER_3_READ_ACCESS = DatabaseAccess.builder()
.type(AccessType.READ)
.hdbid(DATABASE_2_ID)
......@@ -7248,6 +7258,13 @@ public abstract class BaseTest {
.user(USER_3)
.build();
public final static DatabaseAccessDto DATABASE_2_USER_3_READ_ACCESS_DTO = DatabaseAccessDto.builder()
.type(AccessTypeDto.READ)
.hdbid(DATABASE_2_ID)
.huserid(USER_3_ID)
.user(USER_3_DTO)
.build();
public final static DatabaseAccess DATABASE_2_USER_3_WRITE_OWN_ACCESS = DatabaseAccess.builder()
.type(AccessType.WRITE_OWN)
.hdbid(DATABASE_2_ID)
......@@ -7555,8 +7572,8 @@ public abstract class BaseTest {
.referencedColumn(TABLE_1_COLUMNS.get(0))
.foreignKey(null) // set later
.build())))
.table(TABLE_1)
.referencedTable(TABLE_2)
.table(TABLE_2)
.referencedTable(TABLE_1)
.onUpdate(ReferenceType.NO_ACTION)
.build())))
.uniques(new LinkedList<>(List.of(Unique.builder()
......