Skip to content

Commit

Permalink
Merge pull request #178 from FAIRDataTeam/release/1.12.0
Browse files Browse the repository at this point in the history
Release 1.12.0
  • Loading branch information
MarekSuchanek authored Aug 12, 2021
2 parents 84ba8ab + 912b639 commit 859fe61
Show file tree
Hide file tree
Showing 63 changed files with 2,114 additions and 251 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [1.12.0]

### Added

- New endpoints for settings (metrics and ping)

### Changed

- Reset to defaults works with settings as well
- Metadata endpoint `**/expanded` is marked as *Deprecated*
- Several dependencies updated (including Spring Boot 2.5.3)

### Fixed

- Multiple children resource definitions with the same child relation
- Ordering of target classes
- Computing cache on DB migration and reset to defaults
- Profile namespace `/` vs `#`
- Creating metadata of a resource definition that has multiple parents

## [1.11.0]

### Added
Expand Down
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.5</version>
<version>2.5.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>nl.dtls</groupId>
<artifactId>fairdatapoint</artifactId>
<version>1.11.0</version>
<version>1.12.0</version>
<packaging>jar</packaging>

<name>FairDataPoint</name>
Expand Down Expand Up @@ -57,9 +57,9 @@
<!-- Core -->
<springdoc.version>1.5.2</springdoc.version>
<mongock.version>4.3.8</mongock.version>
<mongodb.driver-sync.version>4.1.2</mongodb.driver-sync.version>
<mongodb.spring-data.v3.version>3.2.2</mongodb.spring-data.v3.version>
<rdf4j.version>3.7.1</rdf4j.version>
<mongodb.driver-sync.version>4.2.3</mongodb.driver-sync.version>
<mongodb.spring-data.v3.version>3.2.3</mongodb.spring-data.v3.version>
<rdf4j.version>3.7.2</rdf4j.version>
<unirest.version>1.4.9</unirest.version>
<jwt.version>0.11.2</jwt.version>
<lombok.version>1.18.20</lombok.version>
Expand All @@ -70,7 +70,7 @@
<plugin.jacoco.version>0.7.6.201602180812</plugin.jacoco.version>
<plugin.coveralls.version>4.3.0</plugin.coveralls.version>
<plugin.javax_xml_bind.version>2.3.1</plugin.javax_xml_bind.version>
<plugin.git_commit_id.version>4.0.5</plugin.git_commit_id.version>
<plugin.git_commit_id.version>4.9.10</plugin.git_commit_id.version>
<plugin.rdf4j_generator.version>0.2.0</plugin.rdf4j_generator.version>
</properties>

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/nl/dtls/fairdatapoint/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
Expand All @@ -32,6 +33,7 @@
@EnableWebMvc
@EnableAsync
@ComponentScan(basePackages = "nl.dtls.fairdatapoint.*")
@ConfigurationPropertiesScan("nl.dtls.fairdatapoint.config.*")
public class Application {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
@Log4j2
@RestController
@RequestMapping("/index/admin")
public class AdminController {
public class IndexAdminController {

@Autowired
private UtilityService utilityService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
@Tag(name = "Index")
@RestController
@RequestMapping("/")
public class PingController {
private static final Logger logger = LoggerFactory.getLogger(PingController.class);
public class IndexPingController {
private static final Logger logger = LoggerFactory.getLogger(IndexPingController.class);

@Autowired
private EventService eventService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
@Tag(name = "Index")
@RestController
@RequestMapping("/index/settings")
public class SettingsController {
public class IndexSettingsController {

@Autowired
private IndexSettingsService indexSettingsService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public Model getFormMetadata() {
return shapeService.getShaclFromShapes();
}

@Operation(hidden = true)
@Operation(hidden = true, deprecated = true)
@GetMapping(path = "**/expanded", produces = {"!application/json"})
public Model getMetaDataExpanded(HttpServletRequest request) throws MetadataServiceException {
// 1. Init
Expand Down Expand Up @@ -321,6 +321,7 @@ public ResponseEntity<Model> getMetaDataChildren(
// 4.2 Get all children sorted
var children = getObjectsBy(entity, entityUri, relationUri)
.stream()
.filter((childUri) -> getResourceNameForChild(childUri.toString()).equals(childPrefix))
.filter((childUri) -> {
if (oCurrentUser.isPresent()) return true;
Metadata childState = metadataStateService.get(i(childUri.stringValue()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import nl.dtls.fairdatapoint.api.dto.member.MemberDTO;
import nl.dtls.fairdatapoint.api.dto.metadata.MetaDTO;
import nl.dtls.fairdatapoint.api.dto.metadata.MetaPathDTO;
import nl.dtls.fairdatapoint.api.dto.metadata.MetaStateChangeDTO;
import nl.dtls.fairdatapoint.api.dto.metadata.MetaStateDTO;
import nl.dtls.fairdatapoint.entity.metadata.Metadata;
Expand All @@ -38,6 +39,7 @@
import nl.dtls.fairdatapoint.service.resource.ResourceDefinitionService;
import org.eclipse.rdf4j.model.IRI;
import org.eclipse.rdf4j.model.Model;
import org.eclipse.rdf4j.model.vocabulary.DCTERMS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestBody;
Expand All @@ -47,10 +49,13 @@

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.HashMap;
import java.util.Optional;

import static nl.dtls.fairdatapoint.entity.metadata.MetadataGetter.getMetadataIdentifier;
import static nl.dtls.fairdatapoint.entity.metadata.MetadataGetter.getTitle;
import static nl.dtls.fairdatapoint.util.HttpUtil.getRequestURL;
import static nl.dtls.fairdatapoint.util.RdfUtil.getStringObjectBy;
import static nl.dtls.fairdatapoint.util.RdfUtil.removeLastPartOfIRI;
import static nl.dtls.fairdatapoint.util.ValueFactoryHelper.i;

Expand Down Expand Up @@ -87,17 +92,35 @@ public MetaDTO getMeta(HttpServletRequest request) throws MetadataServiceExcepti
// 3. Get and check existence entity
IRI uri = i(getRequestURL(request, persistentUrl));
IRI entityUri = removeLastPartOfIRI(uri);
Model model = metadataService.retrieve(entityUri);
Model entity = metadataService.retrieve(entityUri);

// 4. Get member
String entityId = getMetadataIdentifier(model).getIdentifier().getLabel();
String entityId = getMetadataIdentifier(entity).getIdentifier().getLabel();
Optional<MemberDTO> oMember = memberService.getMemberForCurrentUser(entityId, Metadata.class);
MemberDTO member = oMember.orElse(new MemberDTO(null, null));

// 5. Get state
MetaStateDTO state = metadataStateService.getState(entityUri, model, rd);
MetaStateDTO state = metadataStateService.getState(entityUri, entity, rd);

// 6. Make path map
HashMap<String, MetaPathDTO> pathMap = new HashMap<>();
while (true) {
MetaPathDTO entry = new MetaPathDTO();
entry.setResourceDefinitionUuid(rd.getUuid());
entry.setTitle(getTitle(entity).stringValue());
IRI parentUri = i(getStringObjectBy(entity, entityUri, DCTERMS.IS_PART_OF));
Optional.ofNullable(parentUri).map(IRI::toString).ifPresent(entry::setParent);
pathMap.put(entityUri.toString(), entry);
if (parentUri == null) {
break;
}
entity = metadataService.retrieve(parentUri);
entityUri = parentUri;
urlPrefix = getResourceNameForList(parentUri.toString());
rd = resourceDefinitionService.getByUrlPrefix(urlPrefix);
}

return new MetaDTO(member, state);
return new MetaDTO(member, state, pathMap);
}

@Operation(hidden = true)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* The MIT License
* Copyright © 2017 DTL
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package nl.dtls.fairdatapoint.api.controller.settings;

import io.swagger.v3.oas.annotations.tags.Tag;
import nl.dtls.fairdatapoint.api.dto.settings.SettingsDTO;
import nl.dtls.fairdatapoint.api.dto.settings.SettingsUpdateDTO;
import nl.dtls.fairdatapoint.service.settings.SettingsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Tag(name = "Client")
@RestController
@RequestMapping("/settings")
public class SettingsController {

@Autowired
private SettingsService settingsService;

@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasRole('ADMIN')")
public SettingsDTO getSettings() {
return settingsService.getCurrentSettings();
}

@PutMapping(produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasRole('ADMIN')")
public SettingsDTO updateSettings(@RequestBody @Valid SettingsUpdateDTO reqDto) {
return settingsService.updateSettings(reqDto);
}

@DeleteMapping(produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasRole('ADMIN')")
public SettingsDTO resetSettings() {
return settingsService.resetSettings();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,30 @@
*/
package nl.dtls.fairdatapoint.api.dto.metadata;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import nl.dtls.fairdatapoint.api.dto.member.MemberDTO;

import javax.validation.constraints.NotNull;
import java.util.Map;

@Schema(name = "MetaDTO")
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
public class MetaDTO {

@JsonInclude
private MemberDTO member;

@JsonInclude
private MetaStateDTO state;

@NotNull
private Map<String, MetaPathDTO> path;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* The MIT License
* Copyright © 2017 DTL
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package nl.dtls.fairdatapoint.api.dto.metadata;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.*;

import javax.validation.constraints.NotNull;

@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@EqualsAndHashCode
public class MetaPathDTO {

@NotNull
private String resourceDefinitionUuid;

@NotNull
private String title;

@JsonInclude
private String parent = null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ public class ResetDTO {
private boolean metadata;

private boolean resourceDefinitions;

private boolean settings;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* The MIT License
* Copyright © 2017 DTL
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package nl.dtls.fairdatapoint.api.dto.settings;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import nl.dtls.fairdatapoint.entity.settings.SettingsMetricsEntry;

import java.util.List;

@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
public class SettingsDTO {

private String clientUrl;

private String persistentUrl;

private List<SettingsMetricsEntry> metadataMetrics;

private SettingsPingDTO ping;

private SettingsRepositoryDTO repository;
}
Loading

0 comments on commit 859fe61

Please sign in to comment.