Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update core dependencies #597

Merged
merged 1 commit into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.12</version>
<version>3.4.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>org.fairdatapoint</groupId>
Expand Down Expand Up @@ -55,15 +55,15 @@
<rdf-resolver.version>0.2.0</rdf-resolver.version>

<!-- Core -->
<springdoc.version>2.5.0</springdoc.version>
<postgresql.version>42.7.3</postgresql.version>
<rdf4j.version>4.3.12</rdf4j.version>
<springdoc.version>2.8.3</springdoc.version>
<postgresql.version>42.7.5</postgresql.version>
<rdf4j.version>5.1.0</rdf4j.version>
<jwt.version>0.12.6</jwt.version>
<lombok.version>1.18.32</lombok.version>
<hypersistence.version>3.7.6</hypersistence.version>
<lombok.version>1.18.36</lombok.version>
<hypersistence.version>3.9.0</hypersistence.version>

<!-- Test -->
<httpclient5.version>5.3.1</httpclient5.version>
<httpclient5.version>5.4.1</httpclient5.version>

<!-- Plugins -->
<plugin.license.version>4.5</plugin.license.version>
Expand Down Expand Up @@ -199,6 +199,10 @@
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-database-postgresql</artifactId>
</dependency>
<dependency>
<groupId>io.hypersistence</groupId>
<artifactId>hypersistence-utils-hibernate-63</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.UUID;

@Component
@RequiredArgsConstructor
Expand Down Expand Up @@ -61,14 +60,14 @@ public Settings defaultSettings() {
public List<SettingsMetric> defaultMetrics(Settings settings) {
return List.of(
SettingsMetric.builder()
.uuid(UUID.randomUUID())
.uuid(null)
.metricUri("https://purl.org/fair-metrics/FM_F1A")
.resourceUri("https://www.ietf.org/rfc/rfc3986.txt")
.settings(settings)
.orderPriority(1)
.build(),
SettingsMetric.builder()
.uuid(UUID.randomUUID())
.uuid(null)
.metricUri("https://purl.org/fair-metrics/FM_A1.1")
.resourceUri("https://www.wikidata.org/wiki/Q8777")
.settings(settings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@
@SuperBuilder
public class MetadataSchema extends BaseEntityCustomUUID {

@OneToMany(fetch = FetchType.LAZY, mappedBy = "schema")
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL,
orphanRemoval = true, mappedBy = "schema")
private List<MetadataSchemaVersion> versions;

@OrderBy("orderPriority")
@OneToMany(mappedBy = "extendedMetadataSchema", fetch = FetchType.LAZY)
@OneToMany(mappedBy = "extendedMetadataSchema", cascade = CascadeType.ALL,
orphanRemoval = true, fetch = FetchType.LAZY)
private List<MetadataSchemaExtension> extensions;

@OrderBy("orderPriority")
@OneToMany(mappedBy = "usedMetadataSchema", fetch = FetchType.LAZY)
@OneToMany(mappedBy = "usedMetadataSchema", cascade = CascadeType.ALL,
orphanRemoval = true, fetch = FetchType.LAZY)
private List<MetadataSchemaUsage> usages;
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ public class MetadataSchemaVersion extends BaseEntityCustomUUID {
@JoinColumn(name = "metadata_schema_id", nullable = false)
private MetadataSchema schema;

@OneToOne(fetch = FetchType.LAZY)
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
@JoinColumn(name = "previous_version_id", nullable = false)
private MetadataSchemaVersion previousVersion;

@OneToOne(fetch = FetchType.LAZY, mappedBy = "previousVersion")
@OneToOne(cascade = CascadeType.PERSIST, mappedBy = "previousVersion")
private MetadataSchemaVersion nextVersion;

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
import org.fairdatapoint.entity.user.UserAccount;
import org.springframework.stereotype.Component;

import java.util.UUID;

@Component
public class ApiKeyMapper {

Expand All @@ -38,7 +36,7 @@ public ApiKeyDTO toDTO(ApiKey apiKey) {

public ApiKey createApiKey(UserAccount userAccount, String token) {
return ApiKey.builder()
.uuid(UUID.randomUUID())
.uuid(null)
.token(token)
.userAccount(userAccount)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public IndexEntry storeEntry(@Valid PingDTO pingDTO) {
else {
log.info("Storing new entry {}", clientUrl);
entry = new IndexEntry();
entry.setUuid(UUID.randomUUID());
entry.setUuid(null);
entry.setClientUrl(clientUrl);
entry.setCreatedAt(Instant.now());
if (settings.getAutoPermit()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@

import java.time.Instant;
import java.util.List;
import java.util.UUID;

@Service
public class ResourceDefinitionMapper {

public ResourceDefinition fromChangeDTO(ResourceDefinitionChangeDTO dto) {
return ResourceDefinition.builder()
.uuid(UUID.randomUUID())
.uuid(null)
.name(dto.getName())
.urlPrefix(dto.getUrlPrefix())
.build();
Expand Down Expand Up @@ -119,7 +118,7 @@ private ResourceDefinitionChildListViewMetadataDTO toChildMetadataDTO(ResourceDe

public MetadataSchemaUsage toUsage(MetadataSchema schema, ResourceDefinition definition, int orderPriority) {
return MetadataSchemaUsage.builder()
.uuid(UUID.randomUUID())
.uuid(null)
.usedMetadataSchema(schema)
.resourceDefinition(definition)
.orderPriority(orderPriority)
Expand All @@ -130,7 +129,7 @@ public ResourceDefinitionLink toLink(
ResourceDefinitionLinkDTO dto, ResourceDefinition definition, int orderPriority
) {
return ResourceDefinitionLink.builder()
.uuid(UUID.randomUUID())
.uuid(null)
.title(dto.getTitle())
.propertyUri(dto.getPropertyUri())
.resourceDefinition(definition)
Expand All @@ -144,7 +143,7 @@ public ResourceDefinitionChild toChild(
ResourceDefinitionChildDTO dto, ResourceDefinition source, ResourceDefinition target, int orderPriority
) {
return ResourceDefinitionChild.builder()
.uuid(UUID.randomUUID())
.uuid(null)
.relationUri(dto.getRelationUri())
.title(dto.getListView().getTitle())
.tagsUri(dto.getListView().getTagsUri())
Expand All @@ -160,7 +159,7 @@ public ResourceDefinitionChildMetadata toChildMetadata(
ResourceDefinitionChildListViewMetadataDTO dto, ResourceDefinitionChild child, int orderPriority
) {
return ResourceDefinitionChildMetadata.builder()
.uuid(UUID.randomUUID())
.uuid(null)
.title(dto.getTitle())
.propertyUri(dto.getPropertyUri())
.child(child)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public MetadataSchemaExtension newExtension(
MetadataSchemaVersion version, MetadataSchema metadataSchema, int orderPriority
) {
return MetadataSchemaExtension.builder()
.uuid(UUID.randomUUID())
.uuid(null)
.extendedMetadataSchema(metadataSchema)
.metadataSchemaVersion(version)
.orderPriority(orderPriority)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ public boolean deleteSchemaDraft(UUID uuid) {
return false;
}
final MetadataSchemaVersion draft = oDraft.get();
final boolean isOnlyVersion = draft.getSchema().getVersions().size() == 1;
extensionRepository.deleteAll(draft.getExtensions());
versionRepository.delete(draft);
final boolean isOnlyVersion = versionRepository.getBySchemaUuid(draft.getSchema().getUuid()).size() == 1;
entityManager.clear();

if (isOnlyVersion) {
usageRepository.deleteAll(draft.getSchema().getUsages());
extensionRepository.deleteAll(draft.getSchema().getExtensions());
schemaRepository.delete(draft.getSchema());
}
else {
versionRepository.delete(draft);
}
return true;
}

Expand Down Expand Up @@ -256,6 +256,7 @@ public boolean deleteVersion(UUID uuid, String version) {
}
// Validate and fix links
final MetadataSchemaVersion schema = oSchema.get();
final boolean isOnlyVersion = versionRepository.getBySchemaUuid(schema.getSchema().getUuid()).size() == 1;
if (schema.isLatest()) {
if (schema.getPreviousVersion() == null) {
metadataSchemaValidator.validateNotUsed(schema.getSchema());
Expand All @@ -274,14 +275,15 @@ public boolean deleteVersion(UUID uuid, String version) {
schema.getNextVersion().setPreviousVersion(schema.getPreviousVersion());
versionRepository.save(schema.getNextVersion());
}
entityManager.flush();
entityManager.clear();

final boolean isOnlyVersion = schema.getSchema().getVersions().size() == 1;
versionRepository.delete(schema);
if (isOnlyVersion) {
usageRepository.deleteAll(schema.getSchema().getUsages());
extensionRepository.deleteAll(schema.getSchema().getExtensions());
schemaRepository.delete(schema.getSchema());
}
else {
versionRepository.delete(schema);
}
return true;
}

Expand All @@ -300,9 +302,6 @@ public boolean deleteSchemaFull(UUID uuid) {
throw new ValidationException("You can't delete INTERNAL Shape");
}
// Delete
versionRepository.deleteAll(schema.getVersions());
extensionRepository.deleteAll(schema.getExtensions());
usageRepository.deleteAll(schema.getUsages());
schemaRepository.delete(schema);
entityManager.flush();
// Update cache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

import java.time.Instant;
import java.util.Optional;
import java.util.UUID;

@Component
@RequiredArgsConstructor
Expand Down Expand Up @@ -64,7 +63,7 @@ public SearchSavedQuery fromChangeDTO(
SearchSavedQueryChangeDTO reqDto, UserAccount userAccount
) {
return SearchSavedQuery.builder()
.uuid(UUID.randomUUID())
.uuid(null)
.name(reqDto.getName())
.description(reqDto.getDescription())
.type(reqDto.getType())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ private List<SettingsAutocompleteSource> updateSources(SettingsUpdateDTO dto, Se

private List<SettingsSearchFilter> updateSearchFilters(SettingsUpdateDTO dto, Settings settings) {
// Delete old
settings
.getSearchFilters()
.forEach(searchFilter -> searchFilterItemRepository.deleteAll(searchFilter.getItems()));
searchFilterRepository.deleteAll(settings.getSearchFilters());
// Add new
final List<SettingsSearchFilter> searchFilters = new ArrayList<>();
Expand Down
18 changes: 8 additions & 10 deletions src/main/java/org/fairdatapoint/service/user/UserMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

import java.util.UUID;

@Component
@RequiredArgsConstructor
public class UserMapper {
Expand All @@ -56,14 +54,14 @@ public UserSimpleDTO toSimpleDTO(UserAccount user) {
}

public UserAccount fromCreateDTO(UserCreateDTO dto) {
return
new UserAccount(
UUID.randomUUID(),
dto.getFirstName(),
dto.getLastName(),
dto.getEmail(),
passwordEncoder.encode(dto.getPassword()),
dto.getRole());
return UserAccount.builder()
.uuid(null)
.firstName(dto.getFirstName())
.lastName(dto.getLastName())
.email(dto.getEmail())
.passwordHash(passwordEncoder.encode(dto.getPassword()))
.role(dto.getRole())
.build();
}

public UserAccount fromChangeDTO(UserChangeDTO dto, UserAccount user) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.*;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.util.UriComponentsBuilder;

import java.net.URI;
Expand Down Expand Up @@ -90,7 +91,6 @@ public void res200_listFew() {
indexEntryRepository.deleteAll();
List<IndexEntry> entries = TestIndexEntryFixtures.entriesFew();
indexEntryRepository.saveAll(entries);
int size = 9;

// AND: prepare request
RequestEntity<?> request = RequestEntity
Expand Down
Loading
Loading