From a288a31f16e16068cb7dba0100fe3b7ea9e65e99 Mon Sep 17 00:00:00 2001 From: Baptiste Toulemonde <toulemonde@cines.fr> Date: Thu, 9 Dec 2021 13:43:33 +0100 Subject: [PATCH] fix --- .../config/MetricsValueConfig.java | 47 ---- .../fairdatapoint/config/SwaggerConfig.java | 101 --------- .../Migration_0002_Custom_metamodel.java | 125 ----------- .../metadata/MetadataMigration.java | 120 ---------- .../metadata/data/MetadataFixtures.java | 211 ------------------ .../entity/membership/MembershipEntity.java | 27 --- .../service/dashboard/DashboardMapper.java | 65 ------ .../FairMetadataMetricsService.java | 46 ---- .../FairMetadataMetricsServiceImpl.java | 108 --------- 9 files changed, 850 deletions(-) delete mode 100755 src/main/java/nl/dtls/fairdatapoint/config/MetricsValueConfig.java delete mode 100755 src/main/java/nl/dtls/fairdatapoint/config/SwaggerConfig.java delete mode 100755 src/main/java/nl/dtls/fairdatapoint/database/mongo/migration/production/Migration_0002_Custom_metamodel.java delete mode 100755 src/main/java/nl/dtls/fairdatapoint/database/rdf/migration/development/metadata/MetadataMigration.java delete mode 100755 src/main/java/nl/dtls/fairdatapoint/database/rdf/migration/development/metadata/data/MetadataFixtures.java delete mode 100755 src/main/java/nl/dtls/fairdatapoint/entity/membership/MembershipEntity.java delete mode 100755 src/main/java/nl/dtls/fairdatapoint/service/dashboard/DashboardMapper.java delete mode 100755 src/main/java/nl/dtls/fairdatapoint/service/metadatametrics/FairMetadataMetricsService.java delete mode 100755 src/main/java/nl/dtls/fairdatapoint/service/metadatametrics/FairMetadataMetricsServiceImpl.java diff --git a/src/main/java/nl/dtls/fairdatapoint/config/MetricsValueConfig.java b/src/main/java/nl/dtls/fairdatapoint/config/MetricsValueConfig.java deleted file mode 100755 index 397530d..0000000 --- a/src/main/java/nl/dtls/fairdatapoint/config/MetricsValueConfig.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * 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. - */ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package nl.dtls.fairdatapoint.config; - -import org.springframework.beans.factory.config.YamlMapFactoryBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.io.ClassPathResource; - -import java.util.Map; - -@Configuration -public class MetricsValueConfig { - - @Bean(name = "metadataMetrics") - public Map<String, String> metadataMetrics() { - YamlMapFactoryBean yamlFactory = new YamlMapFactoryBean(); - yamlFactory.setResources(new ClassPathResource("application.yml")); - return (Map<String, String>) yamlFactory.getObject().get("metadataMetrics"); - } - -} diff --git a/src/main/java/nl/dtls/fairdatapoint/config/SwaggerConfig.java b/src/main/java/nl/dtls/fairdatapoint/config/SwaggerConfig.java deleted file mode 100755 index 80ea0aa..0000000 --- a/src/main/java/nl/dtls/fairdatapoint/config/SwaggerConfig.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * 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. - */ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package nl.dtls.fairdatapoint.config; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.*; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spi.service.contexts.SecurityContext; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import java.util.Collections; -import java.util.List; - -import static nl.dtls.fairdatapoint.util.HttpUtil.removeProtocol; - -@Configuration -@EnableSwagger2 -public class SwaggerConfig { - - @Value("${instance.clientUrl}") - private String clientUrl; - - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.any()) - .paths(PathSelectors.any()) - .build() - .apiInfo(apiInfo()) - .host(removeProtocol(clientUrl)) - .securitySchemes(List.of(apiKey())) - .securityContexts(List.of(securityContext())); - } - - private ApiInfo apiInfo() { - return new ApiInfo( - "FAIR Data Point API", - "<a target='_blank' " + - " href='https://github.com/FAIRDataTeam/FAIRDataPoint/wiki/FAIR-Data-Point-Specification'>" + - " FAIR Data Point Specification" + - " </a>" + - " <br/>", - "1.3.0", - "ATO", - new Contact("Luiz Bonino", - "https://github.com/FAIRDataTeam/FAIRDataPoint", - "luiz.bonino@go-fair.org"), - "The MIT License", - "https://opensource.org/licenses/MIT", - Collections.emptyList() - ); - } - - private ApiKey apiKey() { - return new ApiKey("apiKey", "Authorization", "header"); - } - - private SecurityContext securityContext() { - return SecurityContext.builder() - .securityReferences(defaultAuth()) - .forPaths(PathSelectors.any()) - .build(); - } - - private List<SecurityReference> defaultAuth() { - AuthorizationScope[] authorizationScopes = {new AuthorizationScope("global", "global description")}; - return List.of(new SecurityReference("apiKey", authorizationScopes)); - } - -} diff --git a/src/main/java/nl/dtls/fairdatapoint/database/mongo/migration/production/Migration_0002_Custom_metamodel.java b/src/main/java/nl/dtls/fairdatapoint/database/mongo/migration/production/Migration_0002_Custom_metamodel.java deleted file mode 100755 index b4dea02..0000000 --- a/src/main/java/nl/dtls/fairdatapoint/database/mongo/migration/production/Migration_0002_Custom_metamodel.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * 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.database.mongo.migration.production; - -import com.github.mongobee.changeset.ChangeLog; -import com.github.mongobee.changeset.ChangeSet; -import com.mongodb.client.MongoCollection; -import com.mongodb.client.MongoDatabase; -import nl.dtls.fairdatapoint.Profiles; -import org.bson.Document; -import org.springframework.context.annotation.Profile; - -import java.util.List; - -import static com.mongodb.client.model.Updates.combine; -import static com.mongodb.client.model.Updates.set; - -@ChangeLog(order = "0002") -@Profile(Profiles.PRODUCTION) -public class Migration_0002_Custom_metamodel { - - @ChangeSet(order = "0002", id = "0002_Custom_metamodel", author = "migrationBot") - public void run(MongoDatabase db) { - updateAcl(db); - addResourceDefinitions(db); - } - - private void updateAcl(MongoDatabase db) { - MongoCollection<Document> aclCol = db.getCollection("ACL"); - aclCol.updateMany(new Document(), combine(set("className", "nl.dtls.fairdatapoint.entity.metadata.Metadata"))); - } - - private void addResourceDefinitions(MongoDatabase db) { - MongoCollection<Document> rdCol = db.getCollection("resourceDefinition"); - rdCol.insertOne(repositoryDefinition()); - rdCol.insertOne(catalogDefinition()); - rdCol.insertOne(datasetDefinition()); - rdCol.insertOne(distributionDefinition()); - } - - private Document repositoryDefinition() { - Document definition = new Document(); - definition.append("uuid", "77aaad6a-0136-4c6e-88b9-07ffccd0ee4c"); - definition.append("name", "Repository"); - definition.append("uriPrefix", ""); - definition.append("rdfType", "http://www.re3data.org/schema/3-0#Repository"); - definition.append("specs", "https://www.purl.org/fairtools/fdp/schema/0.1/fdpMetadata"); - definition.append("shaclTargetClasses", List.of("http://www.re3data.org/schema/3-0#Repository", - "http://www.w3.org/ns/dcat#Resource")); - definition.append("child", "http://www.re3data.org/schema/3-0#dataCatalog"); - definition.append("parentResourceDefinitionUuid", null); - definition.append("childResourceDefinitionUuid", "a0949e72-4466-4d53-8900-9436d1049a4b"); - definition.append("_class", "nl.dtls.fairdatapoint.entity.resource.ResourceDefinition"); - return definition; - } - - private Document catalogDefinition() { - Document definition = new Document(); - definition.append("uuid", "a0949e72-4466-4d53-8900-9436d1049a4b"); - definition.append("name", "Catalog"); - definition.append("uriPrefix", "catalog"); - definition.append("rdfType", "http://www.w3.org/ns/dcat#Catalog"); - definition.append("specs", "https://www.purl.org/fairtools/fdp/schema/0.1/catalogMetadata"); - definition.append("shaclTargetClasses", List.of("http://www.w3.org/ns/dcat#Catalog", - "http://www.w3.org/ns/dcat#Resource")); - definition.append("child", "http://www.w3.org/ns/dcat#dataset"); - definition.append("parentResourceDefinitionUuid", "77aaad6a-0136-4c6e-88b9-07ffccd0ee4c"); - definition.append("childResourceDefinitionUuid", "2f08228e-1789-40f8-84cd-28e3288c3604"); - definition.append("_class", "nl.dtls.fairdatapoint.entity.resource.ResourceDefinition"); - return definition; - } - - private Document datasetDefinition() { - Document definition = new Document(); - definition.append("uuid", "2f08228e-1789-40f8-84cd-28e3288c3604"); - definition.append("name", "Dataset"); - definition.append("uriPrefix", "dataset"); - definition.append("rdfType", "http://www.w3.org/ns/dcat#Dataset"); - definition.append("specs", "https://www.purl.org/fairtools/fdp/schema/0.1/datasetMetadata"); - definition.append("shaclTargetClasses", List.of("http://www.w3.org/ns/dcat#Dataset", - "http://www.w3.org/ns/dcat#Resource")); - definition.append("child", "http://www.w3.org/ns/dcat#distribution"); - definition.append("parentResourceDefinitionUuid", "a0949e72-4466-4d53-8900-9436d1049a4b"); - definition.append("childResourceDefinitionUuid", "02c649de-c579-43bb-b470-306abdc808c7"); - definition.append("_class", "nl.dtls.fairdatapoint.entity.resource.ResourceDefinition"); - return definition; - } - - private Document distributionDefinition() { - Document definition = new Document(); - definition.append("uuid", "02c649de-c579-43bb-b470-306abdc808c7"); - definition.append("name", "Distribution"); - definition.append("uriPrefix", "distribution"); - definition.append("rdfType", "http://www.w3.org/ns/dcat#Distribution"); - definition.append("specs", "https://www.purl.org/fairtools/fdp/schema/0.1/distributionMetadata"); - definition.append("shaclTargetClasses", List.of("http://www.w3.org/ns/dcat#Distribution", - "http://www.w3.org/ns/dcat#Resource")); - definition.append("child", null); - definition.append("parentResourceDefinitionUuid", "2f08228e-1789-40f8-84cd-28e3288c3604"); - definition.append("childResourceDefinitionUuid", null); - definition.append("_class", "nl.dtls.fairdatapoint.entity.resource.ResourceDefinition"); - return definition; - } - -} diff --git a/src/main/java/nl/dtls/fairdatapoint/database/rdf/migration/development/metadata/MetadataMigration.java b/src/main/java/nl/dtls/fairdatapoint/database/rdf/migration/development/metadata/MetadataMigration.java deleted file mode 100755 index fe3f5f2..0000000 --- a/src/main/java/nl/dtls/fairdatapoint/database/rdf/migration/development/metadata/MetadataMigration.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * 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.database.rdf.migration.development.metadata; - -import nl.dtls.fairdatapoint.database.common.migration.Migration; -import nl.dtls.fairdatapoint.database.mongo.migration.development.resource.data.ResourceDefinitionFixtures; -import nl.dtls.fairdatapoint.database.mongo.migration.development.user.data.UserFixtures; -import nl.dtls.fairdatapoint.database.rdf.migration.development.metadata.data.MetadataFixtures; -import nl.dtls.fairdatapoint.entity.resource.ResourceDefinition; -import nl.dtls.fairdatapoint.service.metadata.common.MetadataService; -import nl.dtls.fairdatapoint.service.metadata.exception.MetadataServiceException; -import nl.dtls.fairdatapoint.service.security.MongoAuthenticationService; -import org.eclipse.rdf4j.model.IRI; -import org.eclipse.rdf4j.model.Model; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.stereotype.Service; - -import static nl.dtls.fairdatapoint.entity.metadata.MetadataGetter.getUri; -import static nl.dtls.fairdatapoint.util.ValueFactoryHelper.i; - -@Service -public class MetadataMigration implements Migration { - - @Autowired - protected MetadataFixtures metadataFixtures; - - @Autowired - @Qualifier("catalogMetadataService") - protected MetadataService catalogMetadataService; - - @Autowired - @Qualifier("genericMetadataService") - protected MetadataService genericMetadataService; - - @Autowired - protected UserFixtures userFixtures; - - @Autowired - protected ResourceDefinitionFixtures resourceDefinitionFixtures; - - @Autowired - private MongoAuthenticationService mongoAuthenticationService; - - @Autowired - @Qualifier("persistentUrl") - private String persistentUrl; - - public void runMigration() { - try { - // 1. Auth user - String albertUuid = userFixtures.albert().getUuid(); - Authentication auth = mongoAuthenticationService.getAuthentication(albertUuid); - SecurityContextHolder.getContext().setAuthentication(auth); - - // 2. Load metadata fixtures - importDefaultFixtures(persistentUrl); - } catch (MetadataServiceException e) { - e.printStackTrace(); - } - } - - public void importDefaultFixtures(String repositoryUrl) throws MetadataServiceException { - ResourceDefinition repositoryRd = resourceDefinitionFixtures.repositoryDefinition(); - ResourceDefinition catalogRd = resourceDefinitionFixtures.catalogDefinition(); - ResourceDefinition datasetRd = resourceDefinitionFixtures.datasetDefinition(); - ResourceDefinition distributionRd = resourceDefinitionFixtures.distributionDefinition(); - - Model repositoryM = metadataFixtures.repositoryMetadata(repositoryUrl); - IRI repositoryUri = getUri(repositoryM); - genericMetadataService.store(repositoryM, i(repositoryUrl), repositoryRd); - - Model catalog1 = metadataFixtures.catalog1(repositoryUrl, i(repositoryUrl)); - IRI catalog1Uri = getUri(catalog1); - catalogMetadataService.store(catalog1, catalog1Uri, catalogRd); - - Model catalog2 = metadataFixtures.catalog2(repositoryUrl, repositoryUri); - IRI catalog2Uri = getUri(catalog2); - catalogMetadataService.store(catalog2, catalog2Uri, catalogRd); - - Model dataset1 = metadataFixtures.dataset1(repositoryUrl, catalog1Uri); - IRI dataset1Uri = getUri(dataset1); - genericMetadataService.store(dataset1, dataset1Uri, datasetRd); - - Model dataset2 = metadataFixtures.dataset2(repositoryUrl, catalog1Uri); - IRI dataset2Uri = getUri(dataset2); - genericMetadataService.store(dataset2, dataset2Uri, datasetRd); - - Model distribution1 = metadataFixtures.distribution1(repositoryUrl, dataset1Uri); - IRI distribution1Uri = getUri(distribution1); - genericMetadataService.store(distribution1, distribution1Uri, distributionRd); - - Model distribution2 = metadataFixtures.distribution2(repositoryUrl, dataset1Uri); - IRI distribution2Uri = getUri(distribution2); - genericMetadataService.store(distribution2, distribution2Uri, distributionRd); - } - -} diff --git a/src/main/java/nl/dtls/fairdatapoint/database/rdf/migration/development/metadata/data/MetadataFixtures.java b/src/main/java/nl/dtls/fairdatapoint/database/rdf/migration/development/metadata/data/MetadataFixtures.java deleted file mode 100755 index b238aaa..0000000 --- a/src/main/java/nl/dtls/fairdatapoint/database/rdf/migration/development/metadata/data/MetadataFixtures.java +++ /dev/null @@ -1,211 +0,0 @@ -/** - * 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.database.rdf.migration.development.metadata.data; - -import nl.dtls.fairdatapoint.database.rdf.migration.development.metadata.factory.MetadataFactory; -import org.eclipse.rdf4j.model.IRI; -import org.eclipse.rdf4j.model.Model; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Arrays; - -@Service -public class MetadataFixtures { - - @Autowired - protected MetadataFactory metadataFactory; - - public Model repositoryMetadata(String repositoryUrl) { - return metadataFactory.createFDPMetadata( - "EOSC-Pillar FAIR Data Point", - "FAIRDataPoint is a REST API and Web Client for creating, storing, and serving FAIR metadata." + - "Here you can store catalogs, datasets, and distributions.", - repositoryUrl - ); - } - - public Model catalog1(String repositoryUrl, IRI repository) { - return metadataFactory.createCatalogMetadata( - "Bio Catalog", - "Nam eget lorem rhoncus, porta odio at, pretium tortor. Morbi dapibus urna magna, at mollis neque " + - "sagittis et. Praesent fringilla, justo malesuada gravida cursus, nibh augue semper enim, et " + - "efficitur augue justo id odio. Donec id malesuada leo, vel molestie sem. Sed vitae libero a " + - "tortor vestibulum ullamcorper vitae ac turpis. Proin posuere nisl sit amet mollis auctor. In" + - " vehicula fringilla lorem, a tristique ligula. Vivamus fringilla leo molestie pellentesque " + - "vehicula. Nam aliquet condimentum varius. In hac habitasse platea dictumst. Maecenas " + - "elementum neque ac ex ultricies auctor. Vestibulum aliquet porttitor enim eu pellentesque. " + - "Aenean dapibus tellus ipsum.", - "catalog-1", - Arrays.asList("https://www.wikidata.org/wiki/Q27317", "https://purl.org/example#theme"), - repositoryUrl, - repository - ); - } - - public Model catalog2(String repositoryUrl, IRI repository) { - return metadataFactory.createCatalogMetadata( - "Tech Catalog", - "Nam eget lorem rhoncus, porta odio at, pretium tortor. Morbi dapibus urna magna, at mollis neque " + - "sagittis et. Praesent fringilla, justo malesuada gravida cursus, nibh augue semper enim, et " + - "efficitur augue justo id odio. Donec id malesuada leo, vel molestie sem. Sed vitae libero a " + - "tortor vestibulum ullamcorper vitae ac turpis. Proin posuere nisl sit amet mollis auctor. In" + - " vehicula fringilla lorem, a tristique ligula. Vivamus fringilla leo molestie pellentesque " + - "vehicula. Nam aliquet condimentum varius. In hac habitasse platea dictumst. Maecenas " + - "elementum neque ac ex ultricies auctor. Vestibulum aliquet porttitor enim eu pellentesque. " + - "Aenean dapibus tellus ipsum.", - "catalog-2", - Arrays.asList("https://www.wikidata.org/wiki/Q27318", "https://purl.org/example#theme"), - repositoryUrl, - repository - ); - } - - public Model catalog3(String repositoryUrl, IRI repository) { - return metadataFactory.createCatalogMetadata( - "IT Catalog", - "Nam eget lorem rhoncus, porta odio at, pretium tortor. Morbi dapibus urna magna, at mollis neque " + - "sagittis et. Praesent fringilla, justo malesuada gravida cursus, nibh augue semper enim, et " + - "efficitur augue justo id odio. Donec id malesuada leo, vel molestie sem. Sed vitae libero a " + - "tortor vestibulum ullamcorper vitae ac turpis. Proin posuere nisl sit amet mollis auctor. In" + - " vehicula fringilla lorem, a tristique ligula. Vivamus fringilla leo molestie pellentesque " + - "vehicula. Nam aliquet condimentum varius. In hac habitasse platea dictumst. Maecenas " + - "elementum neque ac ex ultricies auctor. Vestibulum aliquet porttitor enim eu pellentesque. " + - "Aenean dapibus tellus ipsum.", - "catalog-3", - Arrays.asList("https://www.wikidata.org/wiki/Q27318", "https://purl.org/example#theme"), - repositoryUrl, - repository - ); - } - - public Model dataset1(String repositoryUrl, IRI catalog) { - return metadataFactory.createDatasetMetadata( - "Cat Dataset", - "Sed hendrerit accumsan velit, ut eleifend lorem rhoncus a. Curabitur auctor euismod risus lobortis " + - "viverra. Donec finibus ultricies venenatis. Suspendisse non pulvinar augue, vel dictum erat." + - " Praesent placerat ultrices tempor. Pellentesque posuere sapien eu rutrum efficitur. Quisque" + - " ac risus malesuada, tempus diam at, elementum urna. Suspendisse quis posuere leo.", - "dataset-1", - Arrays.asList("https://www.wikidata.org/wiki/Q27318", "https://www.wikidata.org/wiki/Q27319", "https" + - "://purl.org/example#theme"), - Arrays.asList("Text Mining", "Natural Language Processing"), - repositoryUrl, - catalog - ); - } - - public Model dataset2(String repositoryUrl, IRI catalog) { - return metadataFactory.createDatasetMetadata( - "Dog Dataset", - "Sed hendrerit accumsan velit, ut eleifend lorem rhoncus a. Curabitur auctor euismod risus lobortis " + - "viverra. Donec finibus ultricies venenatis. Suspendisse non pulvinar augue, vel dictum erat." + - " Praesent placerat ultrices tempor. Pellentesque posuere sapien eu rutrum efficitur. Quisque" + - " ac risus malesuada, tempus diam at, elementum urna. Suspendisse quis posuere leo.", - "dataset-2", - Arrays.asList("https://www.wikidata.org/wiki/Q27318", "https://purl.org/example#theme"), - Arrays.asList("Text Mining", "Natural Language Processing"), - repositoryUrl, - catalog - ); - } - - public Model dataset3(String repositoryUrl, IRI catalog) { - return metadataFactory.createDatasetMetadata( - "Pig Dataset", - "Sed hendrerit accumsan velit, ut eleifend lorem rhoncus a. Curabitur auctor euismod risus lobortis " + - "viverra. Donec finibus ultricies venenatis. Suspendisse non pulvinar augue, vel dictum erat." + - " Praesent placerat ultrices tempor. Pellentesque posuere sapien eu rutrum efficitur. Quisque" + - " ac risus malesuada, tempus diam at, elementum urna. Suspendisse quis posuere leo.", - "dataset-3", - Arrays.asList("https://www.wikidata.org/wiki/Q27318", "https://purl.org/example#theme"), - Arrays.asList("Text Mining", "Natural Language Processing"), - repositoryUrl, - catalog - ); - } - - public Model distribution1(String repositoryUrl, IRI dataset) { - return metadataFactory.createDistributionMetadata( - "Downloadable Distribution", - "Maecenas et mollis purus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere " + - "cubilia Curae; Pellentesque pulvinar augue at ultricies placerat. Vestibulum faucibus sem " + - "vel massa egestas consectetur at et nisi. Nullam consectetur, mi et lacinia commodo, arcu " + - "eros tempus risus, nec porta justo metus in orci. Pellentesque mattis tortor a ultrices " + - "pharetra. Phasellus tristique urna orci, ut vulputate tortor accumsan sit amet. Nulla sed " + - "nunc varius, finibus sapien eget, venenatis tortor. Nam gravida diam ut sapien sodales, ut " + - "sodales tellus feugiat. Duis auctor rutrum dictum. Phasellus facilisis, nibh at tempus " + - "efficitur, odio sem molestie lectus, at bibendum metus orci in nibh. Mauris facilisis est " + - "nibh, vitae iaculis risus lacinia at. Aliquam in lectus est.", - "distribution-1", - "http://example.com", - null, - "text/plain", - repositoryUrl, - dataset - ); - } - - public Model distribution2(String repositoryUrl, IRI dataset) { - return metadataFactory.createDistributionMetadata( - "Accessible Distribution", - "Maecenas et mollis purus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere " + - "cubilia Curae; Pellentesque pulvinar augue at ultricies placerat. Vestibulum faucibus sem " + - "vel massa egestas consectetur at et nisi. Nullam consectetur, mi et lacinia commodo, arcu " + - "eros tempus risus, nec porta justo metus in orci. Pellentesque mattis tortor a ultrices " + - "pharetra. Phasellus tristique urna orci, ut vulputate tortor accumsan sit amet. Nulla sed " + - "nunc varius, finibus sapien eget, venenatis tortor. Nam gravida diam ut sapien sodales, ut " + - "sodales tellus feugiat. Duis auctor rutrum dictum. Phasellus facilisis, nibh at tempus " + - "efficitur, odio sem molestie lectus, at bibendum metus orci in nibh. Mauris facilisis est " + - "nibh, vitae iaculis risus lacinia at. Aliquam in lectus est.", - "distribution-2", - null, - "http://example.com", - "text/plain", - repositoryUrl, - dataset - ); - } - - public Model distribution3(String repositoryUrl, IRI dataset) { - return metadataFactory.createDistributionMetadata( - "Nice Distribution", - "Maecenas et mollis purus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere " + - "cubilia Curae; Pellentesque pulvinar augue at ultricies placerat. Vestibulum faucibus sem " + - "vel massa egestas consectetur at et nisi. Nullam consectetur, mi et lacinia commodo, arcu " + - "eros tempus risus, nec porta justo metus in orci. Pellentesque mattis tortor a ultrices " + - "pharetra. Phasellus tristique urna orci, ut vulputate tortor accumsan sit amet. Nulla sed " + - "nunc varius, finibus sapien eget, venenatis tortor. Nam gravida diam ut sapien sodales, ut " + - "sodales tellus feugiat. Duis auctor rutrum dictum. Phasellus facilisis, nibh at tempus " + - "efficitur, odio sem molestie lectus, at bibendum metus orci in nibh. Mauris facilisis est " + - "nibh, vitae iaculis risus lacinia at. Aliquam in lectus est.", - "distribution-3", - null, - "http://example.com", - "text/plain", - repositoryUrl, - dataset - ); - } - -} diff --git a/src/main/java/nl/dtls/fairdatapoint/entity/membership/MembershipEntity.java b/src/main/java/nl/dtls/fairdatapoint/entity/membership/MembershipEntity.java deleted file mode 100755 index d6ce757..0000000 --- a/src/main/java/nl/dtls/fairdatapoint/entity/membership/MembershipEntity.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * 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.entity.membership; - -public enum MembershipEntity { - CATALOG, DATASET, DISTRIBUTION -} diff --git a/src/main/java/nl/dtls/fairdatapoint/service/dashboard/DashboardMapper.java b/src/main/java/nl/dtls/fairdatapoint/service/dashboard/DashboardMapper.java deleted file mode 100755 index 3ca7c0e..0000000 --- a/src/main/java/nl/dtls/fairdatapoint/service/dashboard/DashboardMapper.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * 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.service.dashboard; - -import nl.dtls.fairdatapoint.api.dto.dashboard.DashboardItemDTO; -import nl.dtls.fairdatapoint.api.dto.membership.MembershipDTO; -import org.eclipse.rdf4j.model.Model; -import org.springframework.stereotype.Service; - -import java.util.List; -import java.util.Optional; - -import static nl.dtls.fairdatapoint.entity.metadata.MetadataGetter.getTitle; -import static nl.dtls.fairdatapoint.entity.metadata.MetadataGetter.getUri; - -@Service -public class DashboardMapper { - - public DashboardItemDTO toCatalogDTO(Model c, List<DashboardItemDTO> datasets, Optional<MembershipDTO> membership) { - return new DashboardItemDTO( - getUri(c).toString(), - getTitle(c).getLabel(), - datasets, - membership - ); - } - - public DashboardItemDTO toDatasetDTO(Model d, List<DashboardItemDTO> datasets, Optional<MembershipDTO> membership) { - return new DashboardItemDTO( - getUri(d).toString(), - getTitle(d).getLabel(), - datasets, - membership - ); - } - - public DashboardItemDTO toDistributionDTO(Model d, Optional<MembershipDTO> membership) { - return new DashboardItemDTO( - getUri(d).toString(), - getTitle(d).getLabel(), - List.of(), - membership - ); - } -} diff --git a/src/main/java/nl/dtls/fairdatapoint/service/metadatametrics/FairMetadataMetricsService.java b/src/main/java/nl/dtls/fairdatapoint/service/metadatametrics/FairMetadataMetricsService.java deleted file mode 100755 index dd39043..0000000 --- a/src/main/java/nl/dtls/fairdatapoint/service/metadatametrics/FairMetadataMetricsService.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * 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. - */ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package nl.dtls.fairdatapoint.service.metadatametrics; - -import nl.dtls.fairdatapoint.entity.metadata.Metric; -import org.eclipse.rdf4j.model.IRI; - -import javax.annotation.Nonnull; -import java.util.List; - -public interface FairMetadataMetricsService { - - /** - * This method returns list of fair metrics for the given metadata URI - * - * @param metadataURI metadata URI - * @return List of fair metrics - */ - List<Metric> getMetrics(@Nonnull IRI metadataURI); - -} diff --git a/src/main/java/nl/dtls/fairdatapoint/service/metadatametrics/FairMetadataMetricsServiceImpl.java b/src/main/java/nl/dtls/fairdatapoint/service/metadatametrics/FairMetadataMetricsServiceImpl.java deleted file mode 100755 index c23a757..0000000 --- a/src/main/java/nl/dtls/fairdatapoint/service/metadatametrics/FairMetadataMetricsServiceImpl.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * 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. - */ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package nl.dtls.fairdatapoint.service.metadatametrics; - -import com.google.common.base.Preconditions; -import nl.dtls.fairdatapoint.entity.metadata.Metric; -import org.apache.commons.codec.digest.DigestUtils; -import org.eclipse.rdf4j.model.IRI; -import org.eclipse.rdf4j.model.ValueFactory; -import org.eclipse.rdf4j.model.impl.SimpleValueFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -import javax.annotation.Nonnull; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -@Service -public class FairMetadataMetricsServiceImpl implements FairMetadataMetricsService { - - private static final Logger LOGGER = LoggerFactory.getLogger(FairMetadataMetricsServiceImpl.class); - - private static final ValueFactory VALUEFACTORY = SimpleValueFactory.getInstance(); - - @Autowired - @Qualifier("metadataMetrics") - private Map<String, String> metadataMetrics; - - /** - * This method returns list of fair metrics for metadata - * - * @param metadataURI metadata URI - * @return List of fair metrics - */ - @Override - public List<Metric> getMetrics(@Nonnull IRI metadataURI) { - Preconditions.checkNotNull(metadataURI, "Metadata URI must not be null."); - List<Metric> metrics = new ArrayList<>(); - - metadataMetrics.forEach((metric, metricValue) -> { - - // Create metric uri - StringBuilder metricUri = new StringBuilder(metadataURI.toString()); - metricUri.append("/metrics/"); - metricUri.append(DigestUtils.md5Hex(metric)); - - addMetric(metrics, metricUri.toString(), metric, metricValue); - }); - return metrics; - } - - /** - * We are using this method to reduce the NPath complexity measure. This method add a FM to the - * list if the metric valueUri URI is provided. - * - * @param metrics List<Mertic> object - * @param uri Metric uri - * @param typeUri Metric typeUri uri - * @param valueUri Metric valueUri uri - */ - private void addMetric(List<Metric> metrics, String uri, String typeUri, String valueUri) { - try { - Preconditions.checkNotNull(uri, "Metadata URI must not be null."); - Preconditions.checkState(!uri.isEmpty(), "Metadata URI must not be empty."); - Preconditions.checkNotNull(typeUri, "Type URI must not be null."); - Preconditions.checkState(!typeUri.isEmpty(), "Type URI must not be empty."); - Preconditions.checkNotNull(valueUri, "Value URI must not be null."); - Preconditions.checkState(!valueUri.isEmpty(), "Value URI must not be empty."); - - Metric m = new Metric(); - m.setUri(VALUEFACTORY.createIRI(uri)); - m.setMetricType(VALUEFACTORY.createIRI(typeUri)); - m.setValue(VALUEFACTORY.createIRI(valueUri)); - metrics.add(m); - } catch (Exception e) { - LOGGER.error("Error adding metrics {}", e.getMessage()); - } - } -} -- GitLab