diff --git a/dmp-backend/pom.xml b/dmp-backend/pom.xml
index 4c03539aa..daf645f04 100644
--- a/dmp-backend/pom.xml
+++ b/dmp-backend/pom.xml
@@ -42,7 +42,7 @@
4.11
1.2.17
2.15.0
- 1.7.12
+ 1.7.15
1.2.3
diff --git a/dmp-backend/web/pom.xml b/dmp-backend/web/pom.xml
index 906d08f1a..6d05bdeb8 100644
--- a/dmp-backend/web/pom.xml
+++ b/dmp-backend/web/pom.xml
@@ -95,6 +95,16 @@
springfox-swagger-ui
3.0.0
+
+ io.springfox
+ springfox-swagger2
+ 3.0.0
+
+
+ io.springfox
+ springfox-boot-starter
+ 3.0.0
+
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/configurations/SwaggerConfiguration.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/configurations/SwaggerConfiguration.java
new file mode 100644
index 000000000..3708b7b9f
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/configurations/SwaggerConfiguration.java
@@ -0,0 +1,39 @@
+package eu.eudat.publicapi.configurations;
+
+import eu.eudat.models.data.security.Principal;
+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.ApiInfo;
+import springfox.documentation.service.Contact;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+
+import java.util.Collections;
+
+@Configuration
+public class SwaggerConfiguration {
+
+ // private static final TypeResolver resolver = new TypeResolver();
+
+ @Bean
+ public Docket api() {
+ return new Docket(DocumentationType.SWAGGER_2)
+ .select()
+ .apis(RequestHandlerSelectors.basePackage("eu.eudat.publicapi.controllers"))
+ .paths(PathSelectors.regex("/api/public/(dmps|datasets)/?.*"))
+ .build().apiInfo(apiInfo())//.ignoredParameterTypes(Principal.class)
+ .useDefaultResponseMessages(false);
+ }
+
+ private ApiInfo apiInfo() {
+ return new ApiInfo(
+ "OpenDMP public API",
+ "Argos public API.",
+ "1.0",
+ "https://argos.openaire.eu/terms-and-conditions",
+ new Contact("Argos", "https://argos.openaire.eu/", "argos@openaire.eu "),
+ null, null, Collections.emptyList());
+ }
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/controllers/PublicDatasetsDescriptionDocumentation.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/controllers/PublicDatasetsDescriptionDocumentation.java
new file mode 100644
index 000000000..c30c9b860
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/controllers/PublicDatasetsDescriptionDocumentation.java
@@ -0,0 +1,252 @@
+package eu.eudat.publicapi.controllers;
+
+import eu.eudat.controllers.BaseController;
+import eu.eudat.logic.security.claims.ClaimedAuthorities;
+import eu.eudat.logic.services.ApiContext;
+import eu.eudat.models.data.helpers.common.DataTableData;
+import eu.eudat.models.data.helpers.responses.ResponseItem;
+import eu.eudat.models.data.security.Principal;
+import eu.eudat.publicapi.managers.DatasetPublicManager;
+import eu.eudat.publicapi.models.listingmodels.DatasetPublicListingModel;
+import eu.eudat.publicapi.models.overviewmodels.DatasetPublicModel;
+import eu.eudat.publicapi.request.dataset.DatasetPublicTableRequest;
+import eu.eudat.types.ApiMessageCode;
+import eu.eudat.types.Authorities;
+import io.swagger.annotations.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
+
+@Api(tags = "Datasets Description", description = "Provides Dataset description public API's.")
+@RestController
+@CrossOrigin
+@RequestMapping(value = {"/api/public/datasets/"})
+public class PublicDatasetsDescriptionDocumentation extends BaseController {
+
+ private static final Logger logger = LoggerFactory.getLogger(PublicDatasetsDescriptionDocumentation.class);
+
+ private DatasetPublicManager datasetManager;
+
+ public static final String getPagedNotes = "The json response is of type **ResponseItem>** containing the following properties:\n" +
+ " 1. **message**: string, message indicating error, null if everything went well\n" +
+ " 2. **statusCode**: integer, status code indicating if something unexpected happened, otherwise 0\n" +
+ " 3. **responseType**: integer, 0 for json, 1 for file\n" +
+ " 4. **payload**: DataTableData, containing the number of values of actual data returned and the data of type **DatasetPublicListingModel**\n" +
+ "4.1. id: string, id of dataset returned\n" +
+ "4.2. label: string, label of dataset\n" +
+ "4.3. grant: string, grant of dataset\n" +
+ "4.4. dmp: string, dmp description\n" +
+ "4.5. dmpId: string, dmp's id\n" +
+ "4.6. profile: DatasetProfilePublicModel, dataset's profile\n" +
+ "4.8. createdAt: date, creation date\n" +
+ "4.9. modifiedAt: date, modification date\n" +
+ "4.10. description: string, dataset's description\n" +
+ "4.11. finalizedAt: date, finalization date\n" +
+ "4.12. dmpPublishedAt: date, dmp's publication date\n" +
+ "4.13. version: integer, dataset's version\n" +
+ "4.14. users: list of UserInfoPublicModel, user who collaborated on the dataset\n";
+ public static final String getPagedResponseExample = "{\n" +
+ " \"statusCode\": 0,\n" +
+ " \"responseType\": 0,\n" +
+ " \"message\": null,\n" +
+ " \"payload\": {\n" +
+ " \"totalCount\": 2,\n" +
+ " \"data\": [\n" +
+ " {\n" +
+ " \"id\": \"aefc0f61-f2a7-410d-80c6-d3737afc0cd4\",\n" +
+ " \"label\": \"Copied 27: Agrion forcipula .\",\n" +
+ " \"grant\": \"Advanced Nitrogen Recovery from Sludge and other Organic Waste Materials (NITRO)\",\n" +
+ " \"dmp\": \"DMP_Advanced_Nitrogen_Recovery_from_Sludge_and_other_Organic_Waste_Materials_(NITRO)_0.xml\",\n" +
+ " \"dmpId\": \"8a8368a5-59e9-4d53-aaab-723da2df2d3b\",\n" +
+ " \"profile\": {\n" +
+ " \"id\": \"0b5b52f3-266a-45cf-8066-d1e5a70d65e1\",\n" +
+ " \"label\": \"Horizon 2020 (Devel Clone)\",\n" +
+ " \"hint\": null\n" +
+ " },\n" +
+ " \"createdAt\": 1652274681000,\n" +
+ " \"modifiedAt\": 1652275258000,\n" +
+ " \"description\": null,\n" +
+ " \"finalizedAt\": 1652275257000,\n" +
+ " \"dmpPublishedAt\": 1652276406000,\n" +
+ " \"version\": 0,\n" +
+ " \"users\": [\n" +
+ " {\n" +
+ " \"id\": \"4cb5671a-0575-4a50-878a-d1bdf59648a0\",\n" +
+ " \"name\": \"George Kalampokis\",\n" +
+ " \"role\": 0,\n" +
+ " \"email\": \"gkfortests@gmail.com\",\n" +
+ " \"hint\": \"UserInfoListingModel\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"hint\": \"datasetListingModel\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"id\": \"f3b241fc-c692-4bb6-b10e-b2a4e2829f9e\",\n" +
+ " \"label\": \"manually 23\",\n" +
+ " \"grant\": \"Advanced Nitrogen Recovery from Sludge and other Organic Waste Materials (NITRO)\",\n" +
+ " \"dmp\": \"DMP_Advanced_Nitrogen_Recovery_from_Sludge_and_other_Organic_Waste_Materials_(NITRO)_0.xml\",\n" +
+ " \"dmpId\": \"8a8368a5-59e9-4d53-aaab-723da2df2d3b\",\n" +
+ " \"profile\": {\n" +
+ " \"id\": \"0b5b52f3-266a-45cf-8066-d1e5a70d65e1\",\n" +
+ " \"label\": \"Horizon 2020 (Devel Clone)\",\n" +
+ " \"hint\": null\n" +
+ " },\n" +
+ " \"createdAt\": 1652274735000,\n" +
+ " \"modifiedAt\": 1652275259000,\n" +
+ " \"description\": null,\n" +
+ " \"finalizedAt\": 1652275258000,\n" +
+ " \"dmpPublishedAt\": 1652276406000,\n" +
+ " \"version\": 0,\n" +
+ " \"users\": [\n" +
+ " {\n" +
+ " \"id\": \"4cb5671a-0575-4a50-878a-d1bdf59648a0\",\n" +
+ " \"name\": \"George Kalampokis\",\n" +
+ " \"role\": 0,\n" +
+ " \"email\": \"gkfortests@gmail.com\",\n" +
+ " \"hint\": \"UserInfoListingModel\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"hint\": \"datasetListingModel\"\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ "}";
+ public static final String getPagedRequestBodyDescription = "The datasetTableRequest is a DatasetPublicTableRequest object with the following fields:\n" +
+ "• **length**: how many datasets should be fetched *(required)*\n" + "• **offset**: offset of the returned datasets, first time should be 0, then offset += length\n" +
+ "• **orderings**: array of strings specifying the order, format:= +string or -string or asc or desc. " +
+ "**+** means ascending order. **-** means descending order.\n Available strings are: 1) status, 2) label, 3) created.\n" +
+ " **asc** equivalent to +label.\n **desc** equivalent to -label.\n" +
+ "**criteria**: this is DatasetPublicCriteria object which applies filters for the datasets returned. More specifically:\n" +
+ " 1. periodStart: date, datasets created date greater than periodStart\n" +
+ " 2. periodEnd: date, datasets created date less than periodEnd\n" +
+ " 3. grants: list of uuids, dmps(datasets) with the corresponding grants\n" +
+ " 4. collaborators: list of uuids, user who collaborated on the creation/modification of datasets\n" +
+ " 5. datasetTemplates: list of uuids, dataset templates uuids to be included\n" +
+ " 6. dmpOrganisations: list of strings, datasets involved in dmps which belong to these organisations\n" +
+ " 7. tags: list of Tag objects, tags involved in datasets\n" +
+ " 8. dmpIds: list of uuids, dmps with the specific ids\n" +
+ " 9. groupIds: list of uuids, in which groups the datasets are\n" +
+ "10. allVersions: boolean, if datasets should be fetched with all their versions\n" +
+ "11. like: string, datasets fetched have this string matched in their label or description\n";
+
+ public static final String getOverviewSinglePublicNotes = "The json response is of type **ResponseItem< DatasetPublicModel >** containing the following properties:\n" +
+ " 1. **message**: string, message indicating error, null if everything went well\n" +
+ " 2. **statusCode**: integer, status code indicating if something unexpected happened, otherwise 0\n" +
+ " 3. **responseType**: integer, 0 for json, 1 for file\n" +
+ " 4. **payload**: DatasetPublicModel, dmp returned\n" +
+ "4.1. id: uuid, id of dataset returned\n" +
+ "4.2. label: string, label of dataset\n" +
+ "4.3. reference: string, reference of dataset\n" +
+ "4.4. uri: string, uri of dataset\n" +
+ "4.5. description: string, dataset's description\n" +
+ "4.6. status: string, dataset's status\n" +
+ "4.7. createdAt: date, creation time of dataset\n" +
+ "4.8. dmp: DataManagementPlanPublicListingModel, dmp to which dataset belongs\n" +
+ "4.9. datasetProfileDefinition: PagedDatasetProfile, dataset's paged description\n" +
+ "4.10. registries: list of RegistryPublicModel, dataset's registries\n" +
+ "4.11. services: list of ServicePublicModel, dataset's services\n" +
+ "4.12. dataRepositories: list of DataRepositoryPublicModel, dataset's data repositories\n" +
+ "4.13. tags: list of Tag, dataset's tags\n" +
+ "4.14. externalDatasets: list of ExternalDatasetPublicListingModel, dataset's external datasets\n" +
+ "4.15. profile: DatasetProfilePublicModel, dataset's profile\n" +
+ "4.16. modifiedAt: date, modification time of dataset\n";
+ public static final String getOverviewSinglePublicResponseExample = "{\n" +
+ " \"statusCode\": 0,\n" +
+ " \"responseType\": 0,\n" +
+ " \"message\": null,\n" +
+ " \"payload\": {\n" +
+ " \"id\": \"aefc0f61-f2a7-410d-80c6-d3737afc0cd4\",\n" +
+ " \"label\": \"Copied 27: Agrion forcipula .\",\n" +
+ " \"reference\": null,\n" +
+ " \"uri\": null,\n" +
+ " \"description\": null,\n" +
+ " \"status\": 1,\n" +
+ " \"createdAt\": 1652274681000,\n" +
+ " \"dmp\": {\n" +
+ " \"id\": \"8a8368a5-59e9-4d53-aaab-723da2df2d3b\",\n" +
+ " \"label\": \"DMP_Advanced_Nitrogen_Recovery_from_Sludge_and_other_Organic_Waste_Materials_(NITRO)_0.xml\",\n" +
+ " \"grant\": \"Advanced Nitrogen Recovery from Sludge and other Organic Waste Materials (NITRO)\",\n" +
+ " \"createdAt\": 1652274679000,\n" +
+ " \"modifiedAt\": 1652276406000,\n" +
+ " \"version\": 0,\n" +
+ " \"groupId\": \"5c3f8569-e3f2-4701-a5f0-8d8b2c07cc49\",\n" +
+ " \"users\": [\n" +
+ " {\n" +
+ " \"id\": \"4cb5671a-0575-4a50-878a-d1bdf59648a0\",\n" +
+ " \"name\": \"George Kalampokis\",\n" +
+ " \"role\": 0,\n" +
+ " \"email\": \"gkfortests@gmail.com\",\n" +
+ " \"hint\": \"UserInfoListingModel\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"finalizedAt\": 1652276406000,\n" +
+ " \"publishedAt\": 1652276406000,\n" +
+ " \"hint\": \"dataManagementPlanListingModel\"\n" +
+ " },\n" +
+ " \"datasetProfileDefinition\": {\n" +
+ " \"pages\": [...],\n" +
+ " \"rules\": [...],\n" +
+ " \"status\": 0\n" +
+ " },\n" +
+ " \"registries\": [],\n" +
+ " \"services\": [],\n" +
+ " \"dataRepositories\": [],\n" +
+ " \"tags\": null,\n" +
+ " \"externalDatasets\": [],\n" +
+ " \"profile\": {\n" +
+ " \"id\": \"0b5b52f3-266a-45cf-8066-d1e5a70d65e1\",\n" +
+ " \"label\": \"Horizon 2020 (Devel Clone)\",\n" +
+ " \"hint\": null\n" +
+ " },\n" +
+ " \"modifiedAt\": 1652275258000,\n" +
+ " \"hint\": \"datasetOverviewModel\"\n" +
+ " }\n" +
+ "}";
+
+ @Autowired
+ public PublicDatasetsDescriptionDocumentation(ApiContext apiContext, DatasetPublicManager datasetManager) {
+ super(apiContext);
+ this.datasetManager = datasetManager;
+ }
+
+ @ApiOperation(value = "This method is used to get a listing of public datasets.", notes = getPagedNotes)
+ @ApiResponses(value = {@ApiResponse(
+ code = 200,
+ message = "The following example is generated using body: *{\"criteria\": {},\"length\": 2,\"offset\": 0,\"orderings\": {\"fields\": []} }*",
+ examples = @Example({@ExampleProperty(
+ value = getPagedResponseExample,
+ mediaType = APPLICATION_JSON_VALUE
+ )})
+ )})
+ @RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
+ public @ResponseBody
+ ResponseEntity>> getPaged(@RequestBody @ApiParam(value = getPagedRequestBodyDescription) DatasetPublicTableRequest datasetTableRequest) throws Exception {
+ DataTableData dataTable = this.datasetManager.getPublicPaged(datasetTableRequest);
+ return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
+ }
+
+ @ApiOperation(value = "This method is used to get the overview of a public dataset.", notes = getOverviewSinglePublicNotes)
+ @ApiResponses(value = {@ApiResponse(
+ code = 200,
+ message = "The following example is generated using id: *aefc0f61-f2a7-410d-80c6-d3737afc0cd4*",
+ examples = @Example({@ExampleProperty(
+ value = getOverviewSinglePublicResponseExample,
+ mediaType = APPLICATION_JSON_VALUE
+ )})
+ )})
+ @RequestMapping(method = RequestMethod.GET, value = {"/{id}"}, produces = "application/json")
+ public @ResponseBody
+ ResponseEntity> getOverviewSinglePublic(@PathVariable @ApiParam(value = "fetch the dataset with the given id", example = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") String id) throws Exception {
+// try {
+ DatasetPublicModel dataset = this.datasetManager.getOverviewSinglePublic(id);
+ return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
+// } catch (Exception ex) {
+// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
+// }
+ }
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/controllers/PublicDmpsDocumentation.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/controllers/PublicDmpsDocumentation.java
new file mode 100644
index 000000000..e121145e7
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/controllers/PublicDmpsDocumentation.java
@@ -0,0 +1,277 @@
+package eu.eudat.publicapi.controllers;
+
+import eu.eudat.controllers.BaseController;
+import eu.eudat.logic.security.claims.ClaimedAuthorities;
+import eu.eudat.logic.services.ApiContext;
+import eu.eudat.models.data.helpers.common.DataTableData;
+import eu.eudat.models.data.helpers.responses.ResponseItem;
+import eu.eudat.models.data.security.Principal;
+import eu.eudat.publicapi.managers.DataManagementPlanPublicManager;
+import eu.eudat.publicapi.models.listingmodels.DataManagementPlanPublicListingModel;
+import eu.eudat.publicapi.models.overviewmodels.DataManagementPlanPublicModel;
+import eu.eudat.publicapi.request.dmp.DataManagmentPlanPublicTableRequest;
+import eu.eudat.types.ApiMessageCode;
+import eu.eudat.types.Authorities;
+import io.swagger.annotations.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+
+import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
+
+@Api(tags = "DMPs", description = "Provides DMP public API's.")
+@RestController
+@CrossOrigin
+@RequestMapping(value = {"/api/public/dmps"})
+public class PublicDmpsDocumentation extends BaseController {
+
+ private static final Logger logger = LoggerFactory.getLogger(PublicDmpsDocumentation.class);
+
+ private DataManagementPlanPublicManager dataManagementPlanManager;
+
+ private static final String getPagedNotes = "The json response is of type **ResponseItem>** containing the following properties:\n" +
+ " 1. **message**: string, message indicating error, null if everything went well\n" +
+ " 2. **statusCode**: integer, status code indicating if something unexpected happened, otherwise 0\n" +
+ " 3. **responseType**: integer, 0 for json, 1 for file\n" +
+ " 4. **payload**: DataTableData, containing the number of values of actual data returned and the data of type **DataManagementPlanPublicListingModel**\n" +
+ "4.1. id: string, id of dmp returned\n" +
+ "4.2. label: string, label of dmp\n" +
+ "4.3. grant: string, grant of dmp\n" +
+ "4.4. createdAt: date, creation time of dmp\n" +
+ "4.5. modifiedAt: date, modification time of dmp\n" +
+ "4.6. version: integer, version of dmp\n" +
+ "4.7. groupId: uuid, group id in which dmp belongs\n" +
+ "4.8. users: list of UserInfoPublicModel, user who collaborated on the dmp\n" +
+ "4.9. finalizedAt: date, finalization date\n" +
+ "4.10. publishedAt: date, publication date\n";
+ private static final String getPagedResponseExample = "{\n" +
+ " \"statusCode\": 0,\n" +
+ " \"responseType\": 0,\n" +
+ " \"message\": null,\n" +
+ " \"payload\": {\n" +
+ " \"totalCount\": 2,\n" +
+ " \"data\": [\n" +
+ " {\n" +
+ " \"id\": \"912d87de-fce9-48e0-84a7-d5499d10682d\",\n" +
+ " \"label\": \"Dmp For Project : 0/ANDRE\",\n" +
+ " \"grant\": \"0/ANDRE\",\n" +
+ " \"createdAt\": 1554128271000,\n" +
+ " \"modifiedAt\": 1554128271000,\n" +
+ " \"version\": 0,\n" +
+ " \"groupId\": \"764ec97d-2475-4a75-843f-d620cffbdc3f\",\n" +
+ " \"users\": [],\n" +
+ " \"finalizedAt\": 1554128271000,\n" +
+ " \"publishedAt\": 1554128271000,\n" +
+ " \"hint\": \"dataManagementPlanListingModel\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"id\": \"43809706-0176-4d5c-b47c-c240ac5d874e\",\n" +
+ " \"label\": \"Dmp new version clone\",\n" +
+ " \"grant\": \"SMAD\",\n" +
+ " \"createdAt\": 1539593145000,\n" +
+ " \"modifiedAt\": 1539593145000,\n" +
+ " \"version\": 2,\n" +
+ " \"groupId\": \"536d9779-166e-4b55-ad3e-f93c06338598\",\n" +
+ " \"users\": [],\n" +
+ " \"finalizedAt\": 1539593145000,\n" +
+ " \"publishedAt\": 1539593145000,\n" +
+ " \"hint\": \"dataManagementPlanListingModel\"\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ "}";
+ private static final String getPagedRequestBodyDescription = "The dmpTableRequest is a DataManagementPlanPublicTableRequest object with the following fields:\n" +
+ "• **length**: how many dmps should be fetched *(required)*\n" + "• **offset**: offset of the returned dmps, first time should be 0, then offset += length\n" +
+ "• **orderings**: array of strings specifying the order, format:= +string or -string or asc or desc. " +
+ "**+** means ascending order. **-** means descending order.\n Available strings are: 1) status, 2) label, 3) publishedAt, 4) created.\n" +
+ " **asc** equivalent to +label.\n **desc** equivalent to -label.\n" +
+ "**criteria**: this is DataManagementPlanPublicCriteria object which applies filters for the dmp returned. More specifically:\n" +
+ " 1. periodStart: date, dmps created date greater than periodStart\n" +
+ " 2. periodEnd: date, dmps created date less than periodEnd\n" +
+ " 3. grants: list of uuids, dmps with the corresponding grants\n" +
+ " 4. funders: list of uuids, dmps with the corresponding funders\n" +
+ " 5. datasetTemplates: list of uuids, dataset templates which are described in the dmps\n" +
+ " 6. dmpOrganisations: list of strings, dmps belonging to these organisations\n" +
+ " 7. collaborators: list of uuids, user who collaborated on the creation/modification of dmps\n" +
+ " 8. allVersions: boolean, if dmps should be fetched with all their versions\n" +
+ " 9. groupIds: list of uuids, in which groups the dmps are\n" +
+ "10. like: string, dmps fetched have this string matched in their label or description\n";
+ private static final String getPagedRequestParamDescription = "The fieldsGroup is a string which indicates if the returned objects would have all their properties\n" +
+ "There are two available values: 1) listing and 2) autocomplete\n" +
+ "**listing**: returns objects with all their properties completed\n" +
+ "**autocomplete**: returns objects with only id, label, groupId and creationTime assigned";
+
+ private static final String getOverviewSinglePublicNotes = "The json response is of type **ResponseItem< DataManagementPlanPublicModel >** containing the following properties:\n" +
+ " 1. **message**: string, message indicating error, null if everything went well\n" +
+ " 2. **statusCode**: integer, status code indicating if something unexpected happened, otherwise 0\n" +
+ " 3. **responseType**: integer, 0 for json, 1 for file\n" +
+ " 4. **payload**: DataManagementPlanPublicModel, dmp returned\n" +
+ "4.1. id: string, id of dmp returned\n" +
+ "4.2. label: string, label of dmp\n" +
+ "4.3. profile: string, profile of dmp\n" +
+ "4.4. grant: GrantPublicOverviewModel, grant of dmp\n" +
+ "4.5. createdAt: date, creation time of dmp\n" +
+ "4.6. modifiedAt: date, modification time of dmp\n" +
+ "4.7. finalizedAt: date, finalization date of dmp\n" +
+ "4.8. organisations: list of OrganizationPublicModel, organizations in which dmp belongs\n" +
+ "4.9. version: integer, version of dmp\n" +
+ "4.10. groupId: uuid, group id in which dmp belongs\n" +
+ "4.11. datasets: list of DatasetPublicModel, contained datasets\n" +
+ "4.12. associatedProfiles: list of AssociatedProfilePublicModel, associated profiles of dmp\n" +
+ "4.13. researchers: list of ResearcherPublicModel, researchers involved in dmp\n" +
+ "4.14. users: list of UserInfoPublicModel, user who collaborated on the dmp\n" +
+ "4.15. description: string, description of dmp\n" +
+ "4.16. publishedAt: date, publication date\n" +
+ "4.17. doi: string, if dmp has been published to zenodo so it has doi\n";
+ private static final String getOverviewSinglePublicResponseExample = "{\n" +
+ " \"statusCode\": 0,\n" +
+ " \"responseType\": 0,\n" +
+ " \"message\": null,\n" +
+ " \"payload\": {\n" +
+ " \"id\": \"912d87de-fce9-48e0-84a7-d5499d10682d\",\n" +
+ " \"label\": \"Dmp For Project : 0/ANDRE\",\n" +
+ " \"profile\": null,\n" +
+ " \"grant\": {\n" +
+ " \"id\": \"79d35744-3bf4-4178-8bb0-bbc7110788d5\",\n" +
+ " \"label\": \"0/ANDRE\",\n" +
+ " \"abbreviation\": null,\n" +
+ " \"description\": null,\n" +
+ " \"startDate\": null,\n" +
+ " \"endDate\": null,\n" +
+ " \"uri\": null,\n" +
+ " \"funder\": {\n" +
+ " \"id\": \"baa92ce2-5ed8-4af0-8b9d-8eeabb8c3dbc\",\n" +
+ " \"label\": \"0/ANDRE\",\n" +
+ " \"hint\": null\n" +
+ " },\n" +
+ " \"hint\": null\n" +
+ " },\n" +
+ " \"createdAt\": 1554128271000,\n" +
+ " \"modifiedAt\": 1554128271000,\n" +
+ " \"finalizedAt\": 1554128271000,\n" +
+ " \"organisations\": [],\n" +
+ " \"version\": 0,\n" +
+ " \"groupId\": \"764ec97d-2475-4a75-843f-d620cffbdc3f\",\n" +
+ " \"datasets\": [\n" +
+ " {\n" +
+ " \"id\": \"ac0bf9b2-5804-456c-a5eb-6f797f888a28\",\n" +
+ " \"label\": \"Dataset : Checks export order For Dmp : Dmp For Project : 0/ANDRE\",\n" +
+ " \"reference\": null,\n" +
+ " \"uri\": null,\n" +
+ " \"description\": null,\n" +
+ " \"status\": 1,\n" +
+ " \"createdAt\": 1554127718000,\n" +
+ " \"dmp\": {\n" +
+ " \"id\": \"912d87de-fce9-48e0-84a7-d5499d10682d\",\n" +
+ " \"label\": \"Dmp For Project : 0/ANDRE\",\n" +
+ " \"grant\": \"0/ANDRE\",\n" +
+ " \"createdAt\": 1554128271000,\n" +
+ " \"modifiedAt\": 1554128271000,\n" +
+ " \"version\": 0,\n" +
+ " \"groupId\": \"764ec97d-2475-4a75-843f-d620cffbdc3f\",\n" +
+ " \"users\": [\n" +
+ " {\n" +
+ " \"id\": \"e602dad2-2814-401b-b03f-ba05ba799bdc\",\n" +
+ " \"name\": \"Georgios Kolokythas\",\n" +
+ " \"role\": 0,\n" +
+ " \"email\": \"iamgeorgioskolokythas@gmail.com\",\n" +
+ " \"hint\": \"UserInfoListingModel\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"finalizedAt\": 1554128271000,\n" +
+ " \"publishedAt\": 1554128271000,\n" +
+ " \"hint\": \"dataManagementPlanListingModel\"\n" +
+ " },\n" +
+ " \"datasetProfileDefinition\": {\n" +
+ " \"pages\": [...],\n" +
+ " \"rules\": [...],\n" +
+ " \"status\": 0\n" +
+ " },\n" +
+ " \"registries\": [],\n" +
+ " \"services\": [],\n" +
+ " \"dataRepositories\": [],\n" +
+ " \"tags\": null,\n" +
+ " \"externalDatasets\": [],\n" +
+ " \"profile\": {\n" +
+ " \"id\": \"01a85982-7cec-41c5-b1f1-74a646e0368b\",\n" +
+ " \"label\": \"Checks export order\",\n" +
+ " \"hint\": null\n" +
+ " },\n" +
+ " \"modifiedAt\": 1554128182000,\n" +
+ " \"hint\": \"datasetOverviewModel\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"associatedProfiles\": [\n" +
+ " {\n" +
+ " \"id\": \"01a85982-7cec-41c5-b1f1-74a646e0368b\",\n" +
+ " \"label\": \"Checks export order\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"researchers\": [],\n" +
+ " \"users\": [\n" +
+ " {\n" +
+ " \"id\": \"e602dad2-2814-401b-b03f-ba05ba799bdc\",\n" +
+ " \"name\": \"Georgios Kolokythas\",\n" +
+ " \"role\": 0,\n" +
+ " \"email\": \"iamgeorgioskolokythas@gmail.com\",\n" +
+ " \"hint\": \"UserInfoListingModel\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"description\": \"Hello\",\n" +
+ " \"publishedAt\": 1554128271000,\n" +
+ " \"doi\": null,\n" +
+ " \"hint\": \"dataManagementPlanOverviewModel\"\n" +
+ " }\n" +
+ "}";
+
+ @Autowired
+ public PublicDmpsDocumentation(ApiContext apiContext, DataManagementPlanPublicManager dataManagementPlanManager) {
+ super(apiContext);
+ this.dataManagementPlanManager = dataManagementPlanManager;
+ }
+
+ @ApiOperation(value = "This method is used to get a listing of public dmps.", notes = getPagedNotes)
+ @ApiResponses(value = {@ApiResponse(
+ code = 200,
+ message = "The following example is generated using:\n" +
+ "a) body: *{\"criteria\": {},\"length\": 2,\"offset\": 0,\"orderings\": {\"fields\": []} }*\n" +
+ "b) fieldsGroup: listing",
+ examples = @Example({@ExampleProperty(
+ value = getPagedResponseExample,
+ mediaType = APPLICATION_JSON_VALUE
+ )})
+ )})
+ @RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
+ public @ResponseBody
+ ResponseEntity>> getPaged(@Valid @RequestBody @ApiParam(value = getPagedRequestBodyDescription) DataManagmentPlanPublicTableRequest dmpTableRequest,
+ @RequestParam @ApiParam(value = getPagedRequestParamDescription, example = "listing") String fieldsGroup) throws Exception {
+ DataTableData dataTable = this.dataManagementPlanManager.getPublicPaged(dmpTableRequest, fieldsGroup);
+ return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
+ }
+
+ @ApiOperation(value = "This method is used to get the overview of a public dmp.", notes = getOverviewSinglePublicNotes)
+ @ApiResponses(value = {@ApiResponse(
+ code = 200,
+ message = "The following example is generated using id: *912d87de-fce9-48e0-84a7-d5499d10682d*",
+ examples = @Example({@ExampleProperty(
+ value = getOverviewSinglePublicResponseExample,
+ mediaType = APPLICATION_JSON_VALUE
+ )})
+ )})
+ @RequestMapping(method = RequestMethod.GET, value = {"/{id}"}, produces = "application/json")
+ public @ResponseBody
+ ResponseEntity> getOverviewSinglePublic(@PathVariable @ApiParam(value = "fetch the dmp with the given id", example = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") String id) throws Exception {
+// try {
+ DataManagementPlanPublicModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSinglePublic(id);
+ return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
+// } catch (Exception ex) {
+// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
+// }
+ }
+
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/criteria/dataset/DatasetPublicCriteria.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/criteria/dataset/DatasetPublicCriteria.java
new file mode 100644
index 000000000..f332c7db3
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/criteria/dataset/DatasetPublicCriteria.java
@@ -0,0 +1,93 @@
+package eu.eudat.publicapi.criteria.dataset;
+
+import eu.eudat.data.dao.criteria.Criteria;
+import eu.eudat.data.entities.Dataset;
+import eu.eudat.elastic.entities.Tag;
+
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+
+public class DatasetPublicCriteria extends Criteria {
+ private Date periodStart;
+ private Date periodEnd;
+ private List grants;
+ private List collaborators;
+ private List datasetTemplates;
+ private List dmpOrganisations;
+ private List tags;
+ private List dmpIds;
+ private List groupIds;
+ private boolean allVersions;
+
+ public Date getPeriodStart() {
+ return periodStart;
+ }
+ public void setPeriodStart(Date periodStart) {
+ this.periodStart = periodStart;
+ }
+
+ public Date getPeriodEnd() {
+ return periodEnd;
+ }
+ public void setPeriodEnd(Date periodEnd) {
+ this.periodEnd = periodEnd;
+ }
+
+ public List getGrants() {
+ return grants;
+ }
+ public void setGrants(List grants) {
+ this.grants = grants;
+ }
+
+ public List getCollaborators() {
+ return collaborators;
+ }
+ public void setCollaborators(List collaborators) {
+ this.collaborators = collaborators;
+ }
+
+ public List getDatasetTemplates() {
+ return datasetTemplates;
+ }
+ public void setDatasetTemplates(List datasetTemplates) {
+ this.datasetTemplates = datasetTemplates;
+ }
+
+ public List getDmpOrganisations() {
+ return dmpOrganisations;
+ }
+ public void setDmpOrganisations(List dmpOrganisations) {
+ this.dmpOrganisations = dmpOrganisations;
+ }
+
+ public List getTags() {
+ return tags;
+ }
+ public void setTags(List tags) {
+ this.tags = tags;
+ }
+
+ public List getDmpIds() {
+ return dmpIds;
+ }
+ public void setDmpIds(List dmpIds) {
+ this.dmpIds = dmpIds;
+ }
+
+ public List getGroupIds() {
+ return groupIds;
+ }
+ public void setGroupIds(List groupIds) {
+ this.groupIds = groupIds;
+ }
+
+ public boolean getAllVersions() {
+ return allVersions;
+ }
+ public void setAllVersions(boolean allVersions) {
+ this.allVersions = allVersions;
+ }
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/criteria/dmp/DataManagementPlanPublicCriteria.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/criteria/dmp/DataManagementPlanPublicCriteria.java
new file mode 100644
index 000000000..879a9f996
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/criteria/dmp/DataManagementPlanPublicCriteria.java
@@ -0,0 +1,83 @@
+package eu.eudat.publicapi.criteria.dmp;
+
+import eu.eudat.data.dao.criteria.Criteria;
+import eu.eudat.data.entities.DMP;
+
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+public class DataManagementPlanPublicCriteria extends Criteria {
+ private Date periodStart;
+ private Date periodEnd;
+ private List grants;
+ private List funders;
+ private List datasetTemplates;
+ private List dmpOrganisations;
+ private List collaborators;
+ private boolean allVersions;
+ private List groupIds;
+
+ public Date getPeriodStart() {
+ return periodStart;
+ }
+ public void setPeriodStart(Date periodStart) {
+ this.periodStart = periodStart;
+ }
+
+ public Date getPeriodEnd() {
+ return periodEnd;
+ }
+ public void setPeriodEnd(Date periodEnd) {
+ this.periodEnd = periodEnd;
+ }
+
+ public List getGrants() {
+ return grants;
+ }
+ public void setGrants(List grants) {
+ this.grants = grants;
+ }
+
+ public List getFunders() {
+ return funders;
+ }
+ public void setFunders(List funders) {
+ this.funders = funders;
+ }
+
+ public List getDatasetTemplates() {
+ return datasetTemplates;
+ }
+ public void setDatasetTemplates(List datasetTemplates) {
+ this.datasetTemplates = datasetTemplates;
+ }
+
+ public List getDmpOrganisations() {
+ return dmpOrganisations;
+ }
+ public void setDmpOrganisations(List dmpOrganisations) {
+ this.dmpOrganisations = dmpOrganisations;
+ }
+
+ public List getCollaborators() {
+ return collaborators;
+ }
+ public void setCollaborators(List collaborators) {
+ this.collaborators = collaborators;
+ }
+
+ public boolean getAllVersions() {
+ return allVersions;
+ }
+ public void setAllVersions(boolean allVersions) {
+ this.allVersions = allVersions;
+ }
+
+ public List getGroupIds() {
+ return groupIds;
+ }
+ public void setGroupIds(List groupIds) {
+ this.groupIds = groupIds;
+ }
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/criteria/mapper/DmpPublicCriteriaMapper.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/criteria/mapper/DmpPublicCriteriaMapper.java
new file mode 100644
index 000000000..b347dc7e2
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/criteria/mapper/DmpPublicCriteriaMapper.java
@@ -0,0 +1,55 @@
+package eu.eudat.publicapi.criteria.mapper;
+
+import eu.eudat.data.query.definition.helpers.ColumnOrderings;
+import eu.eudat.data.query.definition.helpers.Ordering;
+import eu.eudat.elastic.criteria.DmpCriteria;
+import eu.eudat.elastic.criteria.SortCriteria;
+import eu.eudat.publicapi.criteria.dmp.DataManagementPlanPublicCriteria;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.stream.Collectors;
+
+public class DmpPublicCriteriaMapper {
+
+ public static DmpCriteria toElasticCriteria(DataManagementPlanPublicCriteria criteria) {
+ DmpCriteria elastic = new DmpCriteria();
+
+ elastic.setPublic(true);
+ elastic.setLike(criteria.getLike());
+ elastic.setAllowAllVersions(criteria.getAllVersions());
+ if(criteria.getDatasetTemplates() != null) {
+ elastic.setTemplates(criteria.getDatasetTemplates());
+ }
+ if (criteria.getGrants() != null) {
+ elastic.setGrants(criteria.getGrants());
+ }
+ if (criteria.getCollaborators() != null) {
+ elastic.setCollaborators(criteria.getCollaborators());
+ }
+ if (criteria.getDmpOrganisations() != null) {
+ elastic.setOrganizations(criteria.getDmpOrganisations().stream().map(UUID::fromString).collect(Collectors.toList()));
+ }
+ if(criteria.getGroupIds() != null) {
+ elastic.setGroupIds(criteria.getGroupIds());
+ }
+
+ return elastic;
+ }
+
+ public static List toElasticSorting(ColumnOrderings columnOrderings) {
+ List sortCriteria = new ArrayList<>();
+ if (columnOrderings.getFieldOrderings() != null && !columnOrderings.getFieldOrderings().isEmpty()) {
+ for (Ordering ordering: columnOrderings.getFieldOrderings()) {
+ SortCriteria sortCriteria1 = new SortCriteria();
+ sortCriteria1.setFieldName(ordering.getFieldName() + (ordering.getFieldName().contains("label") ?".keyword" : ""));
+ sortCriteria1.setColumnType(ordering.getColumnType() != null ? SortCriteria.ColumnType.valueOf(ordering.getColumnType().name()): SortCriteria.ColumnType.COLUMN);
+ sortCriteria1.setOrderByType(SortCriteria.OrderByType.valueOf(ordering.getOrderByType().name()));
+ sortCriteria.add(sortCriteria1);
+ }
+ }
+ return sortCriteria;
+ }
+
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/managers/DataManagementPlanPublicManager.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/managers/DataManagementPlanPublicManager.java
new file mode 100644
index 000000000..5c8b67824
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/managers/DataManagementPlanPublicManager.java
@@ -0,0 +1,80 @@
+package eu.eudat.publicapi.managers;
+
+import eu.eudat.data.entities.DMP;
+import eu.eudat.exceptions.security.ForbiddenException;
+import eu.eudat.logic.managers.PaginationManager;
+import eu.eudat.logic.services.ApiContext;
+import eu.eudat.logic.services.operations.DatabaseRepository;
+import eu.eudat.models.HintedModelFactory;
+import eu.eudat.models.data.helpers.common.DataTableData;
+import eu.eudat.publicapi.models.listingmodels.DataManagementPlanPublicListingModel;
+import eu.eudat.publicapi.models.overviewmodels.DataManagementPlanPublicModel;
+import eu.eudat.publicapi.request.dmp.DataManagmentPlanPublicTableRequest;
+import eu.eudat.queryable.QueryableList;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+
+@Component
+public class DataManagementPlanPublicManager {
+ private static final Logger logger = LoggerFactory.getLogger(DataManagementPlanPublicManager.class);
+
+ private DatabaseRepository databaseRepository;
+
+ @Autowired
+ public DataManagementPlanPublicManager(ApiContext apiContext) {
+ this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
+ }
+
+ public DataTableData getPublicPaged(DataManagmentPlanPublicTableRequest dmpTableRequest, String fieldsGroup) throws Exception {
+ dmpTableRequest.setQuery(databaseRepository.getDmpDao().asQueryable().withHint(HintedModelFactory.getHint(DataManagementPlanPublicListingModel.class)));
+ QueryableList items = dmpTableRequest.applyCriteria();
+ QueryableList pagedItems = PaginationManager.applyPaging(items, dmpTableRequest);
+
+ DataTableData dataTable = new DataTableData<>();
+
+ CompletableFuture itemsFuture;
+ if (fieldsGroup.equals("listing")) {
+ itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DataManagementPlanPublicListingModel.class))
+ .selectAsync(item -> {
+// item.setDataset(
+// item.getDataset().stream()
+// .filter(dataset -> dataset.getStatus().equals(Dataset.Status.FINALISED.getValue())).collect(Collectors.toSet()));
+ return new DataManagementPlanPublicListingModel().fromDataModelNoDatasets(item);
+ })
+ .whenComplete((resultList, throwable) -> dataTable.setData(resultList));
+ } else {
+ itemsFuture = pagedItems
+ .selectAsync(item -> new DataManagementPlanPublicListingModel().fromDataModel(item))
+ .whenComplete((resultList, throwable) -> dataTable.setData(resultList));
+ }
+
+ CompletableFuture countFuture = pagedItems.countAsync().whenComplete((count, throwable) -> {
+ dataTable.setTotalCount(count);
+ });
+ CompletableFuture.allOf(itemsFuture, countFuture).join();
+ if(dataTable.getTotalCount() > dmpTableRequest.getLength())
+ dataTable.setTotalCount((long)dmpTableRequest.getLength());
+
+ return dataTable;
+ }
+
+ public DataManagementPlanPublicModel getOverviewSinglePublic(String id) throws Exception {
+ DMP dataManagementPlanEntity = databaseRepository.getDmpDao().find(UUID.fromString(id));
+ if (dataManagementPlanEntity.getStatus() == DMP.DMPStatus.DELETED.getValue()) {
+ throw new Exception("DMP is deleted.");
+ }
+ if (!dataManagementPlanEntity.isPublic()) {
+ throw new ForbiddenException("Selected DMP is not public");
+ }
+ DataManagementPlanPublicModel datamanagementPlan = new DataManagementPlanPublicModel();
+ datamanagementPlan.fromDataModelDatasets(dataManagementPlanEntity);
+ datamanagementPlan.setDatasets(datamanagementPlan.getDatasets());
+
+ return datamanagementPlan;
+ }
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/managers/DatasetPublicManager.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/managers/DatasetPublicManager.java
new file mode 100644
index 000000000..216c8814e
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/managers/DatasetPublicManager.java
@@ -0,0 +1,179 @@
+package eu.eudat.publicapi.managers;
+
+import eu.eudat.data.entities.Dataset;
+import eu.eudat.data.query.definition.helpers.ColumnOrderings;
+import eu.eudat.elastic.criteria.DatasetCriteria;
+import eu.eudat.elastic.repository.DatasetRepository;
+import eu.eudat.exceptions.security.ForbiddenException;
+import eu.eudat.logic.managers.PaginationManager;
+import eu.eudat.logic.services.ApiContext;
+import eu.eudat.logic.services.operations.DatabaseRepository;
+import eu.eudat.logic.utilities.builders.XmlBuilder;
+import eu.eudat.models.HintedModelFactory;
+import eu.eudat.models.data.helpers.common.DataTableData;
+import eu.eudat.models.data.user.composite.PagedDatasetProfile;
+import eu.eudat.publicapi.criteria.mapper.DmpPublicCriteriaMapper;
+import eu.eudat.publicapi.models.listingmodels.DatasetPublicListingModel;
+import eu.eudat.publicapi.models.overviewmodels.DatasetPublicModel;
+import eu.eudat.queryable.QueryableList;
+import eu.eudat.types.grant.GrantStateType;
+import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import javax.transaction.Transactional;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Component
+public class DatasetPublicManager {
+ private static final Logger logger = LoggerFactory.getLogger(DatasetPublicManager.class);
+
+ private DatabaseRepository databaseRepository;
+ private DatasetRepository datasetRepository;
+
+ @Autowired
+ public DatasetPublicManager(ApiContext apiContext){
+ this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
+ this.datasetRepository = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository();
+ }
+
+ public DataTableData getPublicPaged(eu.eudat.publicapi.request.dataset.DatasetPublicTableRequest datasetTableRequest) throws Exception {
+ Long count = 0L;
+ DatasetCriteria datasetCriteria = new DatasetCriteria();
+ datasetCriteria.setPublic(true);
+ datasetCriteria.setLike(datasetTableRequest.getCriteria().getLike());
+ datasetCriteria.setDatasetTemplates(datasetTableRequest.getCriteria().getDatasetTemplates());
+ datasetCriteria.setDmps(datasetTableRequest.getCriteria().getDmpIds());
+ datasetCriteria.setGrants(datasetTableRequest.getCriteria().getGrants());
+ datasetCriteria.setCollaborators(datasetTableRequest.getCriteria().getCollaborators());
+ datasetCriteria.setAllowAllVersions(datasetTableRequest.getCriteria().getAllVersions());
+ datasetCriteria.setOrganiztions(datasetTableRequest.getCriteria().getDmpOrganisations());
+ if(datasetTableRequest.getCriteria().getTags() != null && !datasetTableRequest.getCriteria().getTags().isEmpty()){
+ datasetCriteria.setHasTags(true);
+ datasetCriteria.setTags(datasetTableRequest.getCriteria().getTags());
+ }
+ datasetCriteria.setGroupIds(datasetTableRequest.getCriteria().getGroupIds());
+ datasetCriteria.setGrantStatus(GrantStateType.ONGOING.getValue().shortValue()); // grant status ongoing
+ datasetCriteria.setStatus(Dataset.Status.FINALISED.getValue()); // dataset status finalized
+ if (datasetTableRequest.getOrderings() != null) {
+ datasetCriteria.setSortCriteria(DmpPublicCriteriaMapper.toElasticSorting(datasetTableRequest.getOrderings()));
+ }
+ datasetCriteria.setOffset(datasetTableRequest.getOffset());
+ datasetCriteria.setSize(datasetTableRequest.getLength());
+ List datasets;
+ try {
+ datasets = datasetRepository.exists() ?
+ datasetRepository.queryIds(datasetCriteria) : new LinkedList<>();
+ if(datasetTableRequest.getCriteria().getPeriodStart() != null)
+ datasets = datasets.stream().filter(dataset -> dataset.getCreated().after(datasetTableRequest.getCriteria().getPeriodStart())).collect(Collectors.toList());
+ if(datasetTableRequest.getCriteria().getPeriodEnd() != null)
+ datasets = datasets.stream().filter(dataset -> dataset.getCreated().before(datasetTableRequest.getCriteria().getPeriodEnd())).collect(Collectors.toList());
+ count = (long) datasets.size();
+ } catch (Exception ex) {
+ logger.warn(ex.getMessage());
+ datasets = null;
+ }
+ /*datasetTableRequest.setQuery(databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetPublicListingModel.class)));
+ QueryableList items = datasetTableRequest.applyCriteria();*/
+ datasetTableRequest.setQuery(databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetPublicListingModel.class)));
+ QueryableList items;
+ if (datasets != null) {
+ if (!datasets.isEmpty()) {
+ items = databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetPublicListingModel.class));
+ List finalDatasets = datasets;
+ items.where((builder, root) -> root.get("id").in(finalDatasets.stream().map(x -> UUID.fromString(x.getId())).collect(Collectors.toList())));
+ } else
+ items = datasetTableRequest.applyCriteria();
+ //items.where((builder, root) -> root.get("id").in(new UUID[]{UUID.randomUUID()}));
+ } else {
+ items = datasetTableRequest.applyCriteria();
+ }
+
+ List strings = new ArrayList<>();
+ strings.add("-dmp:publishedAt|join|");
+ if(datasetTableRequest.getOrderings() != null) {
+ datasetTableRequest.getOrderings().setFields(strings);
+ }
+ else{
+ datasetTableRequest.setOrderings(new ColumnOrderings());
+ datasetTableRequest.getOrderings().setFields(strings);
+ }
+ if (count == 0L) {
+ count = items.count();
+ }
+ QueryableList pagedItems = PaginationManager.applyPaging(items, datasetTableRequest);
+ DataTableData dataTable = new DataTableData<>();
+
+ List datasetLists = pagedItems.
+ select(this::mapPublicModel);
+
+ dataTable.setData(datasetLists.stream().filter(Objects::nonNull).collect(Collectors.toList()));
+ if(count <= datasetTableRequest.getLength())
+ dataTable.setTotalCount(count);
+ else
+ dataTable.setTotalCount((long)datasetTableRequest.getLength());
+ //CompletableFuture.allOf(countFuture).join();
+ return dataTable;
+ }
+
+ public DatasetPublicModel getOverviewSinglePublic(String id) throws Exception {
+ Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id));
+ if (datasetEntity.getStatus() == Dataset.Status.DELETED.getValue()) {
+ throw new Exception("Dataset is deleted.");
+ }
+ if (!datasetEntity.getDmp().isPublic()) {
+ throw new ForbiddenException("Selected Dataset is not public");
+ }
+ DatasetPublicModel dataset = new DatasetPublicModel();
+ dataset.setDatasetProfileDefinition(this.getPagedProfile(dataset.getStatus(), datasetEntity));
+ dataset.fromDataModel(datasetEntity);
+
+ return dataset;
+ }
+
+ @Transactional
+ private DatasetPublicListingModel mapPublicModel(Dataset item) {
+ /*if (item.getProfile() == null)
+ return null;*/
+ DatasetPublicListingModel listingPublicModel = new DatasetPublicListingModel().fromDataModel(item);
+ /*DatasetProfileCriteria criteria = new DatasetProfileCriteria();
+ criteria.setGroupIds(Collections.singletonList(item.getProfile().getGroupId()));
+ List profiles = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).toList();
+ boolean islast = false;
+ if (!profiles.isEmpty()) {
+ profiles = profiles.stream().sorted(Comparator.comparing(DatasetProfile::getVersion)).collect(Collectors.toList());
+ islast = profiles.get(0).getId().equals(item.getProfile().getId());
+ }
+ listingModel.setProfileLatestVersion(islast);*/
+ return listingPublicModel;
+ }
+
+ private PagedDatasetProfile getPagedProfile(int status, Dataset datasetEntity){
+ eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = this.generateDatasetProfileModel(datasetEntity.getProfile());
+ datasetprofile.setStatus(status);
+ if (datasetEntity.getProperties() != null) {
+ JSONObject jObject = new JSONObject(datasetEntity.getProperties());
+ Map properties = jObject.toMap();
+ datasetprofile.fromJsonObject(properties);
+ }
+ PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
+ pagedDatasetProfile.buildPagedDatasetProfile(datasetprofile);
+ return pagedDatasetProfile;
+ }
+
+ private eu.eudat.models.data.user.composite.DatasetProfile generateDatasetProfileModel(eu.eudat.data.entities.DatasetProfile profile) {
+ Document viewStyleDoc = XmlBuilder.fromXml(profile.getDefinition());
+ Element root = (Element) viewStyleDoc.getDocumentElement();
+ eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewstyle = new eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel().fromXml(root);
+
+ eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = new eu.eudat.models.data.user.composite.DatasetProfile();
+ datasetprofile.buildProfile(viewstyle);
+
+ return datasetprofile;
+ }
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/associatedprofile/AssociatedProfilePublicModel.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/associatedprofile/AssociatedProfilePublicModel.java
new file mode 100644
index 000000000..10edac3ca
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/associatedprofile/AssociatedProfilePublicModel.java
@@ -0,0 +1,57 @@
+package eu.eudat.publicapi.models.associatedprofile;
+
+import eu.eudat.data.entities.DatasetProfile;
+import eu.eudat.logic.utilities.interfaces.XmlSerializable;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import java.util.UUID;
+
+public class AssociatedProfilePublicModel implements XmlSerializable {
+ private UUID id;
+ private String label;
+
+ public UUID getId() {
+ return id;
+ }
+
+ public void setId(UUID id) {
+ this.id = id;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ @Override
+ public Element toXml(Document doc) {
+ Element profile = doc.createElement("profile");
+ profile.setAttribute("profileId", this.id.toString());
+ profile.setAttribute("label", this.label);
+ return profile;
+ }
+
+ @Override
+ public AssociatedProfilePublicModel fromXml(Element item) {
+ this.id = UUID.fromString(item.getAttribute("profileId"));
+ this.label = item.getAttribute("label");
+ return this;
+ }
+
+ public DatasetProfile toData() {
+ DatasetProfile profile = new DatasetProfile();
+ profile.setId(this.id);
+ profile.setLabel(this.label);
+ return profile;
+ }
+
+ public AssociatedProfilePublicModel fromData(DatasetProfile entity) {
+ this.id = entity.getId();
+ this.label = entity.getLabel();
+ return this;
+ }
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/datasetprofile/DatasetProfilePublicModel.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/datasetprofile/DatasetProfilePublicModel.java
new file mode 100644
index 000000000..317e1a8fb
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/datasetprofile/DatasetProfilePublicModel.java
@@ -0,0 +1,45 @@
+package eu.eudat.publicapi.models.datasetprofile;
+
+import eu.eudat.data.entities.DatasetProfile;
+import eu.eudat.models.DataModel;
+
+import java.util.UUID;
+
+public class DatasetProfilePublicModel implements DataModel {
+ private UUID id;
+ private String label;
+
+ public UUID getId() {
+ return id;
+ }
+ public void setId(UUID id) {
+ this.id = id;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ @Override
+ public DatasetProfilePublicModel fromDataModel(DatasetProfile entity) {
+ this.id = entity.getId();
+ this.label = entity.getLabel();
+ return this;
+ }
+
+ @Override
+ public DatasetProfile toDataModel() {
+ DatasetProfile entity = new DatasetProfile();
+ entity.setId(this.getId());
+ entity.setLabel(this.getLabel());
+ return entity;
+ }
+
+ @Override
+ public String getHint() {
+ return null;
+ }
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/datasetwizard/DataRepositoryPublicModel.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/datasetwizard/DataRepositoryPublicModel.java
new file mode 100644
index 000000000..a99af2a20
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/datasetwizard/DataRepositoryPublicModel.java
@@ -0,0 +1,136 @@
+package eu.eudat.publicapi.models.datasetwizard;
+
+import eu.eudat.data.entities.DataRepository;
+import eu.eudat.logic.utilities.helpers.LabelGenerator;
+import eu.eudat.models.DataModel;
+
+import java.util.Date;
+import java.util.UUID;
+
+public class DataRepositoryPublicModel implements DataModel, LabelGenerator {
+ private String id;
+ private String pid;
+ private String name;
+ private String uri;
+ private String info;
+ private String reference;
+ private String abbreviation;
+ private String tag;
+ private String source;
+
+ public String getId() {
+ return id;
+ }
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+ public void setPid(String pid) {
+ this.pid = pid;
+ }
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+
+ public String getInfo() {
+ return info;
+ }
+ public void setInfo(String info) {
+ this.info = info;
+ }
+
+ public String getReference() {
+ return reference;
+ }
+ public void setReference(String reference) {
+ this.reference = reference;
+ }
+
+ public String getAbbreviation() {
+ return abbreviation;
+ }
+ public void setAbbreviation(String abbreviation) {
+ this.abbreviation = abbreviation;
+ }
+
+ public String getTag() {
+ return tag;
+ }
+ public void setTag(String tag) {
+ this.tag = tag;
+ }
+
+ public String getSource() {
+ return source;
+ }
+ public void setSource(String source) {
+ this.source = source;
+ }
+
+ public DataRepositoryPublicModel fromDataModel(DataRepository entity) {
+ this.id = entity.getId().toString();
+ this.pid = entity.getReference();
+ this.name = entity.getLabel();
+ this.uri = entity.getUri();
+ this.abbreviation = entity.getAbbreviation();
+ this.reference = entity.getReference();
+ String source1 = entity.getReference().substring(0, entity.getReference().indexOf(":"));
+ if (source1.equals("dmp")) {
+ this.source = "Internal";
+ } else {
+ this.source = source1;
+ }
+ return this;
+ }
+
+ public DataRepository toDataModel() {
+ DataRepository entity = new DataRepository();
+ if (this.id != null) {
+ entity.setId(UUID.fromString(this.id));
+ }
+ entity.setReference(this.pid);
+ entity.setLabel(this.name);
+ entity.setUri(this.uri);
+ entity.setCreated(new Date());
+ entity.setModified(new Date());
+ entity.setStatus((short) 0);
+ if (this.source != null && this.source.equals("Internal")) this.source = "dmp";
+ if (this.reference != null && !this.reference.trim().isEmpty()
+ && this.source != null && !this.source.trim().isEmpty()) {
+ if (this.source.equals(this.reference.substring(0, this.source.length()))) {
+ entity.setReference(this.reference);
+ } else {
+ entity.setReference(this.source.toLowerCase() + ":" + this.reference);
+ }
+ }
+
+ if (this.abbreviation != null)
+ entity.setAbbreviation(this.abbreviation);
+
+ return entity;
+ }
+
+ @Override
+ public String generateLabel() {
+ return this.getName();
+ }
+
+ @Override
+ public String getHint() {
+ return null;
+ }
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/datasetwizard/ExternalDatasetPublicListingModel.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/datasetwizard/ExternalDatasetPublicListingModel.java
new file mode 100644
index 000000000..e625eff85
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/datasetwizard/ExternalDatasetPublicListingModel.java
@@ -0,0 +1,153 @@
+package eu.eudat.publicapi.models.datasetwizard;
+
+import eu.eudat.data.entities.ExternalDataset;
+import eu.eudat.models.DataModel;
+import eu.eudat.types.externalsourcetype.ExternalDatasetType;
+
+import java.util.Date;
+import java.util.UUID;
+
+public class ExternalDatasetPublicListingModel implements DataModel {
+ private UUID id;
+ private String name;
+ private String abbreviation;
+ private String reference;
+ private Date created;
+ private Date modified;
+ private String info;
+ private ExternalDatasetType type;
+ private String pid;
+ private String uri;
+ private String tag; // Api fetching the data
+ private String source; // Actual harvested source
+
+ public UUID getId() {
+ return id;
+ }
+ public void setId(UUID id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getAbbreviation() {
+ return abbreviation;
+ }
+ public void setAbbreviation(String abbreviation) {
+ this.abbreviation = abbreviation;
+ }
+
+ public String getReference() {
+ return reference;
+ }
+ public void setReference(String reference) {
+ this.reference = reference;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+ public Date getModified() {
+ return modified;
+ }
+ public void setModified(Date modified) {
+ this.modified = modified;
+ }
+
+ public Integer getType() {
+ return type != null ? type.getValue() : null;
+ }
+ public void setType(Integer type) {
+ this.type = ExternalDatasetType.fromInteger(type);
+ }
+
+ public String getInfo() {
+ return info;
+ }
+ public void setInfo(String info) {
+ this.info = info;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+ public void setPid(String pid) {
+ this.pid = pid;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+
+ public String getTag() {
+ return tag;
+ }
+ public void setTag(String tag) {
+ this.tag = tag;
+ }
+
+ public String getSource() {
+ return source;
+ }
+ public void setSource(String source) {
+ this.source = source;
+ }
+
+ @Override
+ public ExternalDatasetPublicListingModel fromDataModel(ExternalDataset entity) {
+ this.id = entity.getId();
+ this.abbreviation = entity.getAbbreviation();
+ this.name = entity.getLabel();
+ this.modified = entity.getModified();
+ this.created = entity.getCreated();
+ this.reference = entity.getReference();
+ String source1 = entity.getReference().substring(0, entity.getReference().indexOf(":"));
+ if (source1.equals("dmp")) {
+ this.source = "Internal";
+ } else {
+ this.source = source1;
+ }
+ return this;
+ }
+
+ @Override
+ public ExternalDataset toDataModel() throws Exception {
+ ExternalDataset externalDataset = new ExternalDataset();
+ externalDataset.setAbbreviation(this.abbreviation);
+ externalDataset.setCreated(this.created != null ? this.created : new Date());
+ externalDataset.setLabel(this.name);
+ externalDataset.setId(this.id);
+ externalDataset.setModified(this.modified);
+ if (this.source != null && this.source.equals("Internal")) this.source = "dmp";
+ if (this.reference != null && !this.reference.trim().isEmpty()
+ && this.source != null && !this.source.trim().isEmpty()) {
+ if (this.source.equals(this.reference.substring(0, this.source.length()))) {
+ externalDataset.setReference(this.reference);
+ } else {
+ externalDataset.setReference(this.source.toLowerCase() + ":" + this.reference);
+ }
+ }
+ if (externalDataset.getReference() == null) {
+ externalDataset.setReference(this.pid);
+ }
+ externalDataset.setModified(new Date());
+ return externalDataset;
+ }
+
+ @Override
+ public String getHint() {
+ return null;
+ }
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/datasetwizard/RegistryPublicModel.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/datasetwizard/RegistryPublicModel.java
new file mode 100644
index 000000000..8fbfa8329
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/datasetwizard/RegistryPublicModel.java
@@ -0,0 +1,112 @@
+package eu.eudat.publicapi.models.datasetwizard;
+
+import eu.eudat.data.entities.Registry;
+import eu.eudat.logic.utilities.helpers.LabelGenerator;
+import eu.eudat.models.DataModel;
+
+import java.util.Date;
+import java.util.UUID;
+
+public class RegistryPublicModel implements DataModel, LabelGenerator {
+ private UUID id;
+ private String label;
+ private String abbreviation;
+ private String reference;
+ private String uri;
+ private String definition;
+ private String source;
+
+ public UUID getId() {
+ return id;
+ }
+ public void setId(UUID id) {
+ this.id = id;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public String getAbbreviation() {
+ return abbreviation;
+ }
+ @Override
+ public String generateLabel() {
+ return getLabel();
+ }
+ public void setAbbreviation(String abbreviation) {
+ this.abbreviation = abbreviation;
+ }
+
+ public String getReference() {
+ return reference;
+ }
+ public void setReference(String reference) {
+ this.reference = reference;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+
+ public String getDefinition() {
+ return definition;
+ }
+ public void setDefinition(String definition) {
+ this.definition = definition;
+ }
+
+ public String getSource() {
+ return source;
+ }
+ public void setSource(String source) {
+ this.source = source;
+ }
+
+ public RegistryPublicModel fromDataModel(Registry entity) {
+ this.id = entity.getId();
+ this.label = entity.getLabel();
+ this.abbreviation = entity.getAbbreviation();
+ this.reference = entity.getReference();
+ this.uri = entity.getUri();
+ this.definition = entity.getDefinition();
+ String source1 = entity.getReference().substring(0, entity.getReference().indexOf(":"));
+ if (source1.equals("dmp")) {
+ this.source = "Internal";
+ } else {
+ this.source = source1;
+ }
+ return this;
+ }
+
+ public Registry toDataModel() {
+ Registry entity = new Registry();
+ entity.setId(this.id != null ? this.id : UUID.randomUUID());
+ entity.setLabel(this.label);
+ entity.setAbbreviation(this.abbreviation);
+ if (this.source != null && this.source.equals("Internal")) this.source = "dmp";
+ if (this.reference != null && !this.reference.trim().isEmpty()
+ && this.source != null && !this.source.trim().isEmpty()) {
+ if (this.source.equals(this.reference.substring(0, this.source.length()))) {
+ entity.setReference(this.reference);
+ } else {
+ entity.setReference(this.source.toLowerCase() + ":" + this.reference);
+ }
+ }
+ entity.setUri(this.uri);
+ entity.setModified(new Date());
+ entity.setStatus((short)0);
+ return entity;
+ }
+
+ @Override
+ public String getHint() {
+ return null;
+ }
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/datasetwizard/ServicePublicModel.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/datasetwizard/ServicePublicModel.java
new file mode 100644
index 000000000..8ff8184f2
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/datasetwizard/ServicePublicModel.java
@@ -0,0 +1,113 @@
+package eu.eudat.publicapi.models.datasetwizard;
+
+import eu.eudat.data.entities.Service;
+import eu.eudat.logic.utilities.helpers.LabelGenerator;
+import eu.eudat.models.DataModel;
+
+import java.util.Date;
+import java.util.UUID;
+
+public class ServicePublicModel implements DataModel, LabelGenerator {
+ private UUID id;
+ private String label;
+ private String abbreviation;
+ private String reference;
+ private String uri;
+ private String definition;
+ private String source;
+
+ public UUID getId() {
+ return id;
+ }
+ public void setId(UUID id) {
+ this.id = id;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public String getAbbreviation() {
+ return abbreviation;
+ }
+ public void setAbbreviation(String abbreviation) {
+ this.abbreviation = abbreviation;
+ }
+
+ public String getReference() {
+ return reference;
+ }
+ public void setReference(String reference) {
+ this.reference = reference;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+
+ public String getDefinition() {
+ return definition;
+ }
+ public void setDefinition(String definition) {
+ this.definition = definition;
+ }
+
+ public String getSource() {
+ return source;
+ }
+ public void setSource(String source) {
+ this.source = source;
+ }
+
+ public ServicePublicModel fromDataModel(Service entity) {
+ this.id = entity.getId();
+ this.label = entity.getLabel();
+ this.abbreviation = entity.getAbbreviation();
+ this.reference = entity.getReference();
+ this.uri = entity.getUri();
+ this.definition = entity.getDefinition();
+ String source1 = entity.getReference().substring(0, entity.getReference().indexOf(":"));
+ if (source1.equals("dmp")) {
+ this.source = "Internal";
+ } else {
+ this.source = source1;
+ }
+ return this;
+ }
+
+ public Service toDataModel() {
+ Service entity = new Service();
+ entity.setId(this.id != null ? this.id : UUID.randomUUID());
+ entity.setLabel(this.label);
+ entity.setAbbreviation(this.abbreviation);
+ if (this.source != null && this.source.equals("Internal")) this.source = "dmp";
+ if (this.reference != null && !this.reference.trim().isEmpty()
+ && this.source != null && !this.source.trim().isEmpty()) {
+ if (this.source.equals(this.reference.substring(0, this.source.length()))) {
+ entity.setReference(this.reference);
+ } else {
+ entity.setReference(this.source.toLowerCase() + ":" + this.reference);
+ }
+ }
+ entity.setUri(this.uri);
+ entity.setModified(new Date());
+ entity.setStatus((short)0);
+ return entity;
+ }
+
+ @Override
+ public String generateLabel() {
+ return this.label;
+ }
+
+ @Override
+ public String getHint() {
+ return null;
+ }
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/funder/FunderPublicOverviewModel.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/funder/FunderPublicOverviewModel.java
new file mode 100644
index 000000000..86accf613
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/funder/FunderPublicOverviewModel.java
@@ -0,0 +1,42 @@
+package eu.eudat.publicapi.models.funder;
+
+import eu.eudat.data.entities.Funder;
+import eu.eudat.models.DataModel;
+
+import java.util.UUID;
+
+public class FunderPublicOverviewModel implements DataModel {
+ private UUID id;
+ private String label;
+
+ public UUID getId() {
+ return id;
+ }
+ public void setId(UUID id) {
+ this.id = id;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ @Override
+ public FunderPublicOverviewModel fromDataModel(Funder entity) {
+ this.id = entity.getId();
+ this.label = entity.getLabel();
+ return this;
+ }
+
+ @Override
+ public Funder toDataModel() throws Exception {
+ return null;
+ }
+
+ @Override
+ public String getHint() {
+ return null;
+ }
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/grant/GrantPublicOverviewModel.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/grant/GrantPublicOverviewModel.java
new file mode 100644
index 000000000..75f17c937
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/grant/GrantPublicOverviewModel.java
@@ -0,0 +1,100 @@
+package eu.eudat.publicapi.models.grant;
+
+import eu.eudat.data.entities.Grant;
+import eu.eudat.models.DataModel;
+import eu.eudat.publicapi.models.funder.FunderPublicOverviewModel;
+
+import java.util.Date;
+import java.util.UUID;
+
+public class GrantPublicOverviewModel implements DataModel {
+ private UUID id;
+ private String label;
+ private String abbreviation;
+ private String description;
+ private Date startDate;
+ private Date endDate;
+ private String uri;
+ private FunderPublicOverviewModel funder;
+
+ public UUID getId() {
+ return id;
+ }
+ public void setId(UUID id) {
+ this.id = id;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public String getAbbreviation() {
+ return abbreviation;
+ }
+ public void setAbbreviation(String abbreviation) {
+ this.abbreviation = abbreviation;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Date getStartDate() {
+ return startDate;
+ }
+ public void setStartDate(Date startDate) {
+ this.startDate = startDate;
+ }
+
+ public Date getEndDate() {
+ return endDate;
+ }
+ public void setEndDate(Date endDate) {
+ this.endDate = endDate;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+
+ public FunderPublicOverviewModel getFunder() {
+ return funder;
+ }
+ public void setFunder(FunderPublicOverviewModel funder) {
+ this.funder = funder;
+ }
+
+ @Override
+ public GrantPublicOverviewModel fromDataModel(Grant entity) {
+ this.id = entity.getId();
+ this.label = entity.getLabel();
+ this.abbreviation = entity.getAbbreviation();
+ this.description = entity.getDescription();
+ this.startDate = entity.getStartdate();
+ this.endDate = entity.getEnddate();
+ this.uri = entity.getUri();
+ this.funder = new FunderPublicOverviewModel();
+ if (entity.getFunder() != null)
+ this.funder.fromDataModel(entity.getFunder());
+ return this;
+ }
+
+ @Override
+ public Grant toDataModel() throws Exception {
+ return null;
+ }
+
+ @Override
+ public String getHint() {
+ return null;
+ }
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/listingmodels/DataManagementPlanPublicListingModel.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/listingmodels/DataManagementPlanPublicListingModel.java
new file mode 100644
index 000000000..2c0b65c69
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/listingmodels/DataManagementPlanPublicListingModel.java
@@ -0,0 +1,161 @@
+package eu.eudat.publicapi.models.listingmodels;
+
+import eu.eudat.data.entities.DMP;
+import eu.eudat.data.entities.Grant;
+import eu.eudat.models.DataModel;
+import eu.eudat.publicapi.models.user.UserInfoPublicModel;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+import java.util.stream.Collectors;
+
+public class DataManagementPlanPublicListingModel implements DataModel {
+ private String id;
+ private String label;
+ private String grant;
+ private Date createdAt;
+ private Date modifiedAt;
+ private int version;
+ private UUID groupId;
+ private List users;
+ private Date finalizedAt;
+ private Date publishedAt;
+
+ public String getId() {
+ return id;
+ }
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public String getGrant() {
+ return grant;
+ }
+ public void setGrant(String grant) {
+ this.grant = grant;
+ }
+
+ public Date getCreatedAt() {
+ return createdAt;
+ }
+ public void setCreatedAt(Date createdAt) {
+ this.createdAt = createdAt;
+ }
+
+ public Date getModifiedAt() {
+ return modifiedAt;
+ }
+ public void setModifiedAt(Date modifiedAt) {
+ this.modifiedAt = modifiedAt;
+ }
+
+ public int getVersion() {
+ return version;
+ }
+ public void setVersion(int version) {
+ this.version = version;
+ }
+
+ public UUID getGroupId() {
+ return groupId;
+ }
+ public void setGroupId(UUID groupId) {
+ this.groupId = groupId;
+ }
+
+ public List getUsers() {
+ return users;
+ }
+ public void setUsers(List users) {
+ this.users = users;
+ }
+
+ public Date getFinalizedAt() {
+ return finalizedAt;
+ }
+ public void setFinalizedAt(Date finalizedAt) {
+ this.finalizedAt = finalizedAt;
+ }
+
+ public Date getPublishedAt() {
+ return publishedAt;
+ }
+ public void setPublishedAt(Date publishedAt) {
+ this.publishedAt = publishedAt;
+ }
+
+ @Override
+ public DataManagementPlanPublicListingModel fromDataModel(DMP entity) {
+ this.id = entity.getId().toString();
+ this.label = entity.getLabel();
+ this.groupId = entity.getGroupId();
+ return this;
+ }
+
+ public DataManagementPlanPublicListingModel fromDataModelAssociatedProfiles(DMP entity) {
+ this.id = entity.getId().toString();
+ this.label = entity.getLabel();
+ this.groupId = entity.getGroupId();
+ this.createdAt = entity.getCreated();
+ return this;
+ }
+
+ public DataManagementPlanPublicListingModel fromDataModelAutoComplete(DMP entity) {
+ this.id = entity.getId().toString();
+ this.label = entity.getLabel();
+ this.groupId = entity.getGroupId();
+ this.createdAt = entity.getCreated();
+ return this;
+ }
+
+ public DataManagementPlanPublicListingModel fromDataModelNoDatasets(DMP entity) {
+ this.fromDataModel(entity);
+ this.version = entity.getVersion();
+ this.grant = entity.getGrant().getLabel();
+ this.createdAt = entity.getCreated();
+ this.modifiedAt = entity.getModified();
+ try {
+ this.users = entity.getUsers() != null ? entity.getUsers().stream().map(x -> new UserInfoPublicModel().fromDataModel(x)).collect(Collectors.toList()) : new ArrayList<>();
+ }
+ catch(Exception ex){
+ this.users = new ArrayList<>();
+ }
+ this.finalizedAt = entity.getFinalizedAt();
+ this.publishedAt = entity.getPublishedAt();
+
+ return this;
+ }
+
+ @Override
+ public DMP toDataModel() {
+ DMP entity = new DMP();
+ entity.setId(UUID.fromString(this.getId()));
+ entity.setLabel(this.getLabel());
+ entity.setGroupId(this.getGroupId());
+ entity.setCreated(this.getCreatedAt());
+ entity.setFinalizedAt(this.getFinalizedAt());
+ entity.setModified(this.getModifiedAt());
+ entity.setPublishedAt(this.getPublishedAt());
+ entity.setVersion(this.getVersion());
+
+ Grant grant = new Grant();
+ grant.setLabel(this.getGrant());
+ entity.setGrant(grant);
+ entity.setUsers(this.getUsers().stream().map(UserInfoPublicModel::toDataModel).collect(Collectors.toSet()));
+ return entity;
+ }
+
+ @Override
+ public String getHint() {
+ return "dataManagementPlanListingModel";
+ }
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/listingmodels/DatasetPublicListingModel.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/listingmodels/DatasetPublicListingModel.java
new file mode 100644
index 000000000..8f5c4e6c3
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/listingmodels/DatasetPublicListingModel.java
@@ -0,0 +1,174 @@
+package eu.eudat.publicapi.models.listingmodels;
+
+import eu.eudat.data.entities.DMP;
+import eu.eudat.data.entities.Dataset;
+import eu.eudat.data.entities.Grant;
+import eu.eudat.models.DataModel;
+import eu.eudat.publicapi.models.datasetprofile.DatasetProfilePublicModel;
+import eu.eudat.publicapi.models.user.UserInfoPublicModel;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+import java.util.stream.Collectors;
+
+public class DatasetPublicListingModel implements DataModel {
+ private String id;
+ private String label;
+ private String grant;
+ private String dmp;
+ private String dmpId;
+ private DatasetProfilePublicModel profile;
+ private Date createdAt;
+ private Date modifiedAt;
+ private String description;
+ private Date finalizedAt;
+ private Date dmpPublishedAt;
+ private int version;
+ private List users;
+
+ public String getId() {
+ return id;
+ }
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public String getGrant() {
+ return grant;
+ }
+ public void setGrant(String grant) {
+ this.grant = grant;
+ }
+
+ public String getDmp() {
+ return dmp;
+ }
+ public void setDmp(String dmp) {
+ this.dmp = dmp;
+ }
+
+ public String getDmpId() {
+ return dmpId;
+ }
+ public void setDmpId(String dmpId) {
+ this.dmpId = dmpId;
+ }
+
+ public DatasetProfilePublicModel getProfile() {
+ return profile;
+ }
+ public void setProfile(DatasetProfilePublicModel profile) {
+ this.profile = profile;
+ }
+
+ public Date getCreatedAt() {
+ return createdAt;
+ }
+ public void setCreatedAt(Date createdAt) {
+ this.createdAt = createdAt;
+ }
+
+ public Date getModifiedAt() {
+ return modifiedAt;
+ }
+ public void setModifiedAt(Date modifiedAt) {
+ this.modifiedAt = modifiedAt;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Date getFinalizedAt() {
+ return finalizedAt;
+ }
+ public void setFinalizedAt(Date finalizedAt) {
+ this.finalizedAt = finalizedAt;
+ }
+
+ public Date getDmpPublishedAt() {
+ return dmpPublishedAt;
+ }
+ public void setDmpPublishedAt(Date dmpPublishedAt) {
+ this.dmpPublishedAt = dmpPublishedAt;
+ }
+
+ public int getVersion() {
+ return version;
+ }
+ public void setVersion(int version) {
+ this.version = version;
+ }
+
+ public List getUsers() {
+ return users;
+ }
+
+ public void setUsers(List users) {
+ this.users = users;
+ }
+
+ @Override
+ public DatasetPublicListingModel fromDataModel(Dataset entity) {
+ this.id = entity.getId() != null ? entity.getId().toString() : "";
+ this.label = entity.getLabel();
+ this.createdAt = entity.getCreated();
+ this.modifiedAt = entity.getModified();
+ this.grant = entity.getDmp() != null ? entity.getDmp().getGrant().getLabel() : "";
+ this.dmp = entity.getDmp() != null ? entity.getDmp().getLabel() : "";
+ this.dmpId = entity.getDmp() != null ? entity.getDmp().getId().toString() : "";
+ this.profile = entity.getProfile() != null ? new DatasetProfilePublicModel().fromDataModel(entity.getProfile()) : null;
+ this.description = entity.getDescription();
+ if (entity.getFinalizedAt() == null && entity.getStatus() == Dataset.Status.FINALISED.getValue()) {
+ this.finalizedAt = entity.getDmp().getFinalizedAt();
+ } else {
+ this.finalizedAt = entity.getFinalizedAt();
+ }
+ this.dmpPublishedAt = entity.getDmp().getPublishedAt();
+ this.version = entity.getDmp().getVersion();
+ this.users = entity.getDmp() != null ? entity.getDmp().getUsers().stream().map(x -> new UserInfoPublicModel().fromDataModel(x)).collect(Collectors.toList()) : new ArrayList<>();
+ return this;
+ }
+
+ @Override
+ public Dataset toDataModel() {
+ Dataset entity = new Dataset();
+ entity.setId(UUID.fromString(this.getId()));
+ entity.setLabel(this.getLabel());
+ entity.setCreated(this.getCreatedAt());
+ entity.setModified(this.getModifiedAt());
+ entity.setDescription(this.getDescription());
+ entity.setFinalizedAt(this.getFinalizedAt());
+ entity.setStatus(Dataset.Status.FINALISED.getValue());
+ DMP dmp = new DMP();
+ Grant grant = new Grant();
+ grant.setLabel(this.getGrant());
+ dmp.setGrant(grant);
+ dmp.setLabel(this.getDmp());
+ dmp.setId(UUID.fromString(this.getDmpId()));
+ dmp.setPublishedAt(this.getDmpPublishedAt());
+ dmp.setVersion(this.getVersion());
+ dmp.setUsers(this.getUsers().stream().map(UserInfoPublicModel::toDataModel).collect(Collectors.toSet()));
+ dmp.setFinalizedAt(this.getFinalizedAt());
+ entity.setDmp(dmp);
+ entity.setProfile(this.getProfile() != null ? this.getProfile().toDataModel() : null);
+ return entity;
+ }
+
+ @Override
+ public String getHint() {
+ return "datasetListingModel";
+ }
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/organisation/OrganizationPublicModel.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/organisation/OrganizationPublicModel.java
new file mode 100644
index 000000000..05042d65e
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/organisation/OrganizationPublicModel.java
@@ -0,0 +1,124 @@
+package eu.eudat.publicapi.models.organisation;
+
+import eu.eudat.data.entities.Organisation;
+import eu.eudat.logic.utilities.helpers.LabelGenerator;
+import eu.eudat.models.DataModel;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.UUID;
+
+public class OrganizationPublicModel implements DataModel, LabelGenerator {
+ private String label;
+ private String name;
+ private String id;
+ private String reference;
+ private int status;
+ private String tag; // how the external source is displayed. ex: "Cristin".
+ private String key; // the external source. ex: "cristin".
+
+ public String getLabel() {
+ return label;
+ }
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getId() {
+ return id;
+ }
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getReference() {
+ return reference;
+ }
+ public void setReference(String reference) {
+ this.reference = reference;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+ public String getTag() {
+ return tag;
+ }
+ public void setTag(String tag) {
+ this.tag = tag;
+ }
+
+ public String getKey() {
+ return key;
+ }
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ @Override
+ public OrganizationPublicModel fromDataModel(Organisation entity) {
+ this.id = entity.getId().toString();
+ this.name = entity.getLabel();
+ this.label = entity.getUri();
+ if (entity.getReference() != null) {
+ this.reference = entity.getReference();
+ this.key = entity.getReference().substring(0, entity.getReference().indexOf(":"));
+ }
+ return this;
+ }
+
+ @Override
+ public Organisation toDataModel() {
+ Organisation organisationEntity = new Organisation();
+ if (this.key != null && this.reference != null) {
+ if (this.reference.startsWith(this.key + ":")) {
+ organisationEntity.setReference(this.reference);
+ } else {
+ organisationEntity.setReference(this.key + ":" + this.reference);
+ }
+ }
+ if (this.id != null) {
+ organisationEntity.setId(UUID.fromString(this.id));
+ }
+ organisationEntity.setLabel(this.name);
+ organisationEntity.setUri(this.label);
+ organisationEntity.setCreated(new Date());
+ organisationEntity.setStatus((short) this.status);
+ return organisationEntity;
+ }
+
+ public static OrganizationPublicModel fromMap(HashMap map) {
+ OrganizationPublicModel model = new OrganizationPublicModel();
+ if (map != null) {
+ model.id = (String) map.get("id");
+ model.key = (String) map.get("key");
+ model.label = (String) map.get("label");
+ model.name = (String) map.get("name");
+ model.reference = (String) map.get("reference");
+ model.status = (int) map.get("status");
+ model.tag = (String) map.get("tag");
+ }
+ return model;
+ }
+
+ @Override
+ public String generateLabel() {
+ return this.getName();
+ }
+
+ @Override
+ public String getHint() {
+ return null;
+ }
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/overviewmodels/DataManagementPlanPublicModel.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/overviewmodels/DataManagementPlanPublicModel.java
new file mode 100644
index 000000000..6b5040371
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/overviewmodels/DataManagementPlanPublicModel.java
@@ -0,0 +1,239 @@
+package eu.eudat.publicapi.models.overviewmodels;
+
+import eu.eudat.data.entities.DMP;
+import eu.eudat.data.entities.Dataset;
+import eu.eudat.data.entities.DatasetProfile;
+import eu.eudat.logic.utilities.builders.XmlBuilder;
+import eu.eudat.models.DataModel;
+import eu.eudat.models.data.user.composite.PagedDatasetProfile;
+import eu.eudat.publicapi.models.associatedprofile.AssociatedProfilePublicModel;
+import eu.eudat.publicapi.models.grant.GrantPublicOverviewModel;
+import eu.eudat.publicapi.models.organisation.OrganizationPublicModel;
+import eu.eudat.publicapi.models.researcher.ResearcherPublicModel;
+import eu.eudat.publicapi.models.user.UserInfoPublicModel;
+import org.json.JSONObject;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+public class DataManagementPlanPublicModel implements DataModel {
+ private String id;
+ private String label;
+ private String profile;
+ private GrantPublicOverviewModel grant;
+ private Date createdAt;
+ private Date modifiedAt;
+ private Date finalizedAt;
+ private List organisations;
+ private int version;
+ private UUID groupId;
+ private List datasets;
+ private List associatedProfiles;
+ private List researchers;
+ private List users;
+ private String description;
+ private Date publishedAt;
+ private String doi;
+
+
+ public String getId() {
+ return id;
+ }
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public String getProfile() {
+ return profile;
+ }
+ public void setProfile(String profile) {
+ this.profile = profile;
+ }
+
+ public GrantPublicOverviewModel getGrant() {
+ return grant;
+ }
+ public void setGrant(GrantPublicOverviewModel grant) {
+ this.grant = grant;
+ }
+
+ public Date getCreatedAt() {
+ return createdAt;
+ }
+ public void setCreatedAt(Date createdAt) {
+ this.createdAt = createdAt;
+ }
+
+ public Date getModifiedAt() {
+ return modifiedAt;
+ }
+ public void setModifiedAt(Date modifiedAt) {
+ this.modifiedAt = modifiedAt;
+ }
+
+ public Date getFinalizedAt() {
+ return finalizedAt;
+ }
+ public void setFinalizedAt(Date finalizedAt) {
+ this.finalizedAt = finalizedAt;
+ }
+
+ public List getOrganisations() {
+ return organisations;
+ }
+ public void setOrganisations(List organizations) {
+ this.organisations = organizations;
+ }
+
+ public int getVersion() {
+ return version;
+ }
+ public void setVersion(int version) {
+ this.version = version;
+ }
+
+ public UUID getGroupId() {
+ return groupId;
+ }
+ public void setGroupId(UUID groupId) {
+ this.groupId = groupId;
+ }
+
+ public List getDatasets() {
+ return datasets;
+ }
+ public void setDatasets(List datasets) {
+ this.datasets = datasets;
+ }
+
+ public List getAssociatedProfiles() {
+ return associatedProfiles;
+ }
+ public void setAssociatedProfiles(List associatedProfiles) {
+ this.associatedProfiles = associatedProfiles;
+ }
+
+ public List getUsers() {
+ return users;
+ }
+ public void setUsers(List users) {
+ this.users = users;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public List getResearchers() {
+ return researchers;
+ }
+ public void setResearchers(List researchers) {
+ this.researchers = researchers;
+ }
+
+ public Date getPublishedAt() {
+ return publishedAt;
+ }
+ public void setPublishedAt(Date publishedAt) {
+ this.publishedAt = publishedAt;
+ }
+
+ public String getDoi() {
+ return doi;
+ }
+ public void setDoi(String doi) {
+ this.doi = doi;
+ }
+
+ @Override
+ public DataManagementPlanPublicModel fromDataModel(DMP entity) {
+ this.id = entity.getId().toString();
+ this.label = entity.getLabel();
+ this.groupId = entity.getGroupId();
+ if (entity.getResearchers() != null) {
+ this.researchers = entity.getResearchers().stream().map(item -> new ResearcherPublicModel().fromDataModel(item)).collect(Collectors.toList());
+ }
+ return this;
+ }
+
+ public DataManagementPlanPublicModel fromDataModelDatasets(DMP entity) {
+ this.fromDataModel(entity);
+ this.version = entity.getVersion();
+ this.grant = new GrantPublicOverviewModel().fromDataModel(entity.getGrant());
+ if (entity.getProfile() != null) this.profile = entity.getProfile().getLabel();
+ this.createdAt = entity.getCreated();
+ this.modifiedAt = entity.getModified();
+ this.finalizedAt = entity.getFinalizedAt();
+ this.organisations = entity.getOrganisations().stream().map(item -> new OrganizationPublicModel().fromDataModel(item)).collect(Collectors.toList());
+ this.datasets = entity.getDataset().stream().filter(dataset -> !dataset.getStatus().equals(Dataset.Status.DELETED.getValue()) && !dataset.getStatus().equals(Dataset.Status.CANCELED.getValue()))
+ .map(datasetEntity-> {
+ DatasetPublicModel dataset = new DatasetPublicModel();
+ dataset.setDatasetProfileDefinition(this.getPagedProfile(dataset.getStatus(), datasetEntity));
+ dataset.fromDataModel(datasetEntity);
+ return dataset;
+ }).collect(Collectors.toList());
+ this.users = entity.getUsers().stream().map(x -> new UserInfoPublicModel().fromDataModel(x)).collect(Collectors.toList());
+ this.description = entity.getDescription();
+ if (entity.getResearchers() != null) {
+ this.researchers = entity.getResearchers().stream().map(item -> new ResearcherPublicModel().fromDataModel(item)).collect(Collectors.toList());
+ }
+
+ if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
+ this.associatedProfiles = new LinkedList<>();
+ for (DatasetProfile datasetProfile : entity.getAssociatedDmps()) {
+ AssociatedProfilePublicModel associatedProfile = new AssociatedProfilePublicModel().fromData(datasetProfile);
+ this.associatedProfiles.add(associatedProfile);
+ }
+ }
+ this.publishedAt = entity.getPublishedAt();
+ this.doi = entity.getDoi();
+
+ return this;
+ }
+
+ private PagedDatasetProfile getPagedProfile(int status, Dataset datasetEntity){
+ eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = this.generateDatasetProfileModel(datasetEntity.getProfile());
+ datasetprofile.setStatus(status);
+ if (datasetEntity.getProperties() != null) {
+ JSONObject jObject = new JSONObject(datasetEntity.getProperties());
+ Map properties = jObject.toMap();
+ datasetprofile.fromJsonObject(properties);
+ }
+ PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
+ pagedDatasetProfile.buildPagedDatasetProfile(datasetprofile);
+ return pagedDatasetProfile;
+ }
+
+ private eu.eudat.models.data.user.composite.DatasetProfile generateDatasetProfileModel(eu.eudat.data.entities.DatasetProfile profile) {
+ Document viewStyleDoc = XmlBuilder.fromXml(profile.getDefinition());
+ Element root = (Element) viewStyleDoc.getDocumentElement();
+ eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewstyle = new eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel().fromXml(root);
+
+ eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = new eu.eudat.models.data.user.composite.DatasetProfile();
+ datasetprofile.buildProfile(viewstyle);
+
+ return datasetprofile;
+ }
+
+ @Override
+ public DMP toDataModel() {
+ return null;
+ }
+
+ @Override
+ public String getHint() {
+ return "dataManagementPlanOverviewModel";
+ }
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/overviewmodels/DatasetPublicModel.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/overviewmodels/DatasetPublicModel.java
new file mode 100644
index 000000000..b81dbdcb3
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/overviewmodels/DatasetPublicModel.java
@@ -0,0 +1,293 @@
+package eu.eudat.publicapi.models.overviewmodels;
+
+import eu.eudat.data.entities.*;
+import eu.eudat.elastic.entities.Tag;
+import eu.eudat.models.DataModel;
+import eu.eudat.models.data.user.composite.PagedDatasetProfile;
+import eu.eudat.publicapi.models.datasetprofile.DatasetProfilePublicModel;
+import eu.eudat.publicapi.models.datasetwizard.DataRepositoryPublicModel;
+import eu.eudat.publicapi.models.datasetwizard.ExternalDatasetPublicListingModel;
+import eu.eudat.publicapi.models.datasetwizard.RegistryPublicModel;
+import eu.eudat.publicapi.models.datasetwizard.ServicePublicModel;
+import eu.eudat.publicapi.models.listingmodels.DataManagementPlanPublicListingModel;
+import net.minidev.json.JSONValue;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+public class DatasetPublicModel implements DataModel {
+ private UUID id;
+ private String label;
+ private String reference;
+ private String uri;
+ private String description;
+ private short status;
+ private Date createdAt;
+ private DataManagementPlanPublicListingModel dmp;
+ private PagedDatasetProfile datasetProfileDefinition;
+ private List registries;
+ private List services;
+ private List dataRepositories;
+ private List tags;
+ private List externalDatasets;
+ private DatasetProfilePublicModel profile;
+ private Date modifiedAt;
+
+ public UUID getId() {
+ return id;
+ }
+ public void setId(UUID id) {
+ this.id = id;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public String getReference() {
+ return reference;
+ }
+ public void setReference(String reference) {
+ this.reference = reference;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public short getStatus() {
+ return status;
+ }
+ public void setStatus(short status) {
+ this.status = status;
+ }
+
+ public Date getCreatedAt() {
+ return createdAt;
+ }
+ public void setCreatedAt(Date createdAt) {
+ this.createdAt = createdAt;
+ }
+
+ public DataManagementPlanPublicListingModel getDmp() {
+ return dmp;
+ }
+ public void setDmp(DataManagementPlanPublicListingModel dmp) {
+ this.dmp = dmp;
+ }
+
+ public PagedDatasetProfile getDatasetProfileDefinition() {
+ return datasetProfileDefinition;
+ }
+ public void setDatasetProfileDefinition(PagedDatasetProfile datasetProfileDefinition) {
+ this.datasetProfileDefinition = datasetProfileDefinition;
+ }
+
+ public List getRegistries() {
+ return registries;
+ }
+ public void setRegistries(List registries) {
+ this.registries = registries;
+ }
+
+ public List getServices() {
+ return services;
+ }
+ public void setServices(List services) {
+ this.services = services;
+ }
+
+ public List getDataRepositories() {
+ return dataRepositories;
+ }
+ public void setDataRepositories(List dataRepositories) {
+ this.dataRepositories = dataRepositories;
+ }
+
+ public DatasetProfilePublicModel getProfile() {
+ return profile;
+ }
+ public void setProfile(DatasetProfilePublicModel profile) {
+ this.profile = profile;
+ }
+
+ public List getExternalDatasets() {
+ return externalDatasets;
+ }
+ public void setExternalDatasets(List externalDatasets) {
+ this.externalDatasets = externalDatasets;
+ }
+
+ public List getTags() {
+ return tags;
+ }
+ public void setTags(List tags) {
+ this.tags = tags;
+ }
+
+ public Date getModifiedAt() {
+ return modifiedAt;
+ }
+ public void setModifiedAt(Date modifiedAt) {
+ this.modifiedAt = modifiedAt;
+ }
+
+ @Override
+ public DatasetPublicModel fromDataModel(Dataset entity) {
+ this.id = entity.getId();
+ this.label = entity.getLabel();
+ this.reference = entity.getReference();
+ this.description = entity.getDescription();
+ this.status = entity.getStatus();
+ this.profile = new DatasetProfilePublicModel();
+ this.profile = this.profile.fromDataModel(entity.getProfile());
+ this.uri = entity.getUri();
+ this.registries = entity.getRegistries() != null ? entity.getRegistries().stream().map(item -> new RegistryPublicModel().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
+ this.dataRepositories = entity.getDatasetDataRepositories() != null ? entity.getDatasetDataRepositories().stream().map(item -> {
+ DataRepositoryPublicModel dataRepository = new DataRepositoryPublicModel().fromDataModel(item.getDataRepository());
+ if (item.getData() != null) {
+ Map> data = (Map>) JSONValue.parse(item.getData());
+ Map values = data.get("data");
+ dataRepository.setInfo(values.get("info"));
+ }
+ return dataRepository;
+ }).collect(Collectors.toList()) : new ArrayList<>();
+ this.services = entity.getServices() != null ? entity.getServices().stream().map(item -> new ServicePublicModel().fromDataModel(item.getService())).collect(Collectors.toList()) : new ArrayList<>();
+ this.createdAt = entity.getCreated();
+ this.dmp = new DataManagementPlanPublicListingModel().fromDataModelNoDatasets(entity.getDmp());
+ this.externalDatasets = entity.getDatasetExternalDatasets() != null ? entity.getDatasetExternalDatasets().stream().map(item -> {
+ ExternalDatasetPublicListingModel externalDatasetListingModel = new ExternalDatasetPublicListingModel().fromDataModel(item.getExternalDataset());
+ if (item.getData() != null) {
+ Map> data = (Map>) JSONValue.parse(item.getData());
+ Map values = data.get("data");
+ externalDatasetListingModel.setInfo(values.get("info"));
+ externalDatasetListingModel.setType(Integer.parseInt(values.get("type")));
+ }
+ return externalDatasetListingModel;
+ }).collect(Collectors.toList()) : new ArrayList<>();
+ this.modifiedAt = entity.getModified();
+ return this;
+ }
+
+ public DatasetPublicModel fromDataModelNoDmp(Dataset entity) {
+ this.id = entity.getId();
+ this.label = entity.getLabel();
+ this.reference = entity.getReference();
+ this.description = entity.getDescription();
+ this.status = entity.getStatus();
+ this.profile = new DatasetProfilePublicModel();
+ this.profile = this.profile.fromDataModel(entity.getProfile());
+ this.uri = entity.getUri();
+ this.registries = entity.getRegistries() != null ? entity.getRegistries().stream().map(item -> new RegistryPublicModel().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
+ this.dataRepositories = entity.getDatasetDataRepositories() != null ? entity.getDatasetDataRepositories().stream().map(item -> {
+ DataRepositoryPublicModel dataRepository = new DataRepositoryPublicModel().fromDataModel(item.getDataRepository());
+ if (item.getData() != null) {
+ Map> data = (Map>) JSONValue.parse(item.getData());
+ Map values = data.get("data");
+ dataRepository.setInfo(values.get("info"));
+ }
+ return dataRepository;
+ }).collect(Collectors.toList()) : new ArrayList<>();
+ this.services = entity.getServices() != null ? entity.getServices().stream().map(item -> new ServicePublicModel().fromDataModel(item.getService())).collect(Collectors.toList()) : new ArrayList<>();
+ this.createdAt = entity.getCreated();
+ this.externalDatasets = entity.getDatasetExternalDatasets() != null ? entity.getDatasetExternalDatasets().stream().map(item -> {
+ ExternalDatasetPublicListingModel externalDatasetListingModel = new ExternalDatasetPublicListingModel().fromDataModel(item.getExternalDataset());
+ if (item.getData() != null) {
+ Map> data = (Map>) JSONValue.parse(item.getData());
+ Map values = data.get("data");
+ externalDatasetListingModel.setInfo(values.get("info"));
+ externalDatasetListingModel.setType(Integer.parseInt(values.get("type")));
+ }
+ return externalDatasetListingModel;
+ }).collect(Collectors.toList()) : new ArrayList<>();
+ this.modifiedAt = entity.getModified();
+ return this;
+ }
+
+ @Override
+ public Dataset toDataModel() throws Exception {
+ Dataset entity = new Dataset();
+ entity.setId(this.id);
+ entity.setLabel(this.label);
+ entity.setStatus(this.status);
+ entity.setReference(this.reference);
+ entity.setUri(this.uri);
+ entity.setFinalizedAt(new Date());
+ DMP dmp = new DMP();
+ dmp.setId(UUID.fromString(this.dmp.getId()));
+ entity.setDmp(dmp);
+ entity.setDescription(this.description);
+ entity.setCreated(this.createdAt != null ? this.createdAt : new Date());
+ entity.setModified(new Date());
+ DatasetProfile profile = new DatasetProfile();
+ profile.setId(this.profile.getId());
+ entity.setProfile(profile);
+ if (this.registries != null && !this.registries.isEmpty()) {
+ entity.setRegistries(new HashSet<>());
+ for (RegistryPublicModel registry : this.registries) {
+ entity.getRegistries().add(registry.toDataModel());
+ }
+ }
+
+ if (this.dataRepositories != null && !this.dataRepositories.isEmpty()) {
+ entity.setDatasetDataRepositories(new HashSet<>());
+ for (DataRepositoryPublicModel dataRepositoryModel : this.dataRepositories) {
+ DataRepository dataRepository = dataRepositoryModel.toDataModel();
+ DatasetDataRepository datasetDataRepository = new DatasetDataRepository();
+ datasetDataRepository.setDataRepository(dataRepository);
+ Map> data = new HashMap<>();
+ Map values = new HashMap<>();
+ values.put("info", dataRepositoryModel.getInfo());
+ data.put("data", values);
+ datasetDataRepository.setData(JSONValue.toJSONString(data));
+ entity.getDatasetDataRepositories().add(datasetDataRepository);
+ }
+ }
+
+ if (this.services != null && !this.services.isEmpty()) {
+ entity.setServices(new HashSet<>());
+ for (ServicePublicModel serviceModel : this.services) {
+ Service service = serviceModel.toDataModel();
+ DatasetService datasetService = new DatasetService();
+ datasetService.setService(service);
+ entity.getServices().add(datasetService);
+ }
+ }
+
+ if (this.externalDatasets != null && !this.externalDatasets.isEmpty()) {
+ entity.setDatasetExternalDatasets(new HashSet<>());
+ for (ExternalDatasetPublicListingModel externalDataset : this.externalDatasets) {
+ ExternalDataset externalDatasetEntity = externalDataset.toDataModel();
+ DatasetExternalDataset datasetExternalDataset = new DatasetExternalDataset();
+ datasetExternalDataset.setExternalDataset(externalDatasetEntity);
+ Map> data = new HashMap<>();
+ Map values = new HashMap<>();
+ values.put("info",externalDataset.getInfo());
+ values.put("type",externalDataset.getType().toString());
+ data.put("data",values);
+ datasetExternalDataset.setData(JSONValue.toJSONString(data));
+ entity.getDatasetExternalDatasets().add(datasetExternalDataset);
+ }
+ }
+ return entity;
+ }
+
+
+ @Override
+ public String getHint() {
+ return "datasetOverviewModel";
+ }
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/researcher/ResearcherPublicModel.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/researcher/ResearcherPublicModel.java
new file mode 100644
index 000000000..0630ffd12
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/researcher/ResearcherPublicModel.java
@@ -0,0 +1,151 @@
+package eu.eudat.publicapi.models.researcher;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import eu.eudat.data.entities.Researcher;
+import eu.eudat.logic.utilities.helpers.LabelGenerator;
+import eu.eudat.models.DataModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+import java.util.UUID;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ResearcherPublicModel implements DataModel, LabelGenerator {
+ private static final Logger logger = LoggerFactory.getLogger(eu.eudat.models.data.dmp.Researcher.class);
+ private String label;
+ private String name;
+ private String id;
+ private String reference;
+ private int status;
+ private String tag;
+ private String key;
+
+ public String getLabel() {
+ return label;
+ }
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getId() {
+ return id;
+ }
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getReference() {
+ return reference;
+ }
+ public void setReference(String reference) {
+ this.reference = reference;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+ public String getTag() {
+ return tag;
+ }
+ public void setTag(String tag) {
+ this.tag = tag;
+ }
+
+ public String getKey() {
+ return key;
+ }
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ @Override
+ public ResearcherPublicModel fromDataModel(Researcher entity) {
+ this.id = entity.getId().toString();
+ this.label = entity.getUri();
+ this.name = entity.getLabel();
+ this.status = entity.getStatus();
+ this.reference = entity.getReference();
+ String refParts[] = entity.getReference().split(":");
+ String source = refParts[0];
+ if (source.equals("dmp"))
+ this.key = "Internal";
+ else
+ this.key = source;
+ return this;
+ }
+
+ @Override
+ public Researcher toDataModel() {
+ Researcher researcher = new Researcher();
+ if (this.id == null) {
+ this.id = UUID.randomUUID().toString();
+ }
+ researcher.setId(UUID.fromString(this.id));
+ if (this.key != null) {
+ if (this.key.toLowerCase().equals("internal")) {
+ if (this.reference != null && !this.reference.startsWith("dmp:")) {
+ researcher.setReference("dmp:" + this.reference);
+ } else if (this.reference == null) {
+ researcher.setReference("dmp:" + this.id);
+ } else {
+ researcher.setReference(this.reference);
+ }
+ } else {
+ if ((this.key + ":").equals(this.reference.substring(0, this.key.length() + 1))) {
+ researcher.setReference(this.reference);
+ } else {
+ researcher.setReference(this.key + ":" + this.reference);
+ }
+ }
+ } else {
+ try {
+ throw new Exception("Researcher has no key value");
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ }
+ }
+
+ researcher.setLabel(this.name);
+ researcher.setUri(this.label);
+ researcher.setCreated(new Date());
+ researcher.setStatus((short) this.status);
+ return researcher;
+ }
+
+ @Override
+ public String generateLabel() {
+ return this.getName();
+ }
+
+ @Override
+ public String getHint() {
+ return null;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ ResearcherPublicModel that = (ResearcherPublicModel) o;
+
+ return id.equals(that.id);
+ }
+
+ @Override
+ public int hashCode() {
+ return reference.hashCode();
+ }
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/user/UserInfoPublicModel.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/user/UserInfoPublicModel.java
new file mode 100644
index 000000000..8e08fab36
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/user/UserInfoPublicModel.java
@@ -0,0 +1,68 @@
+package eu.eudat.publicapi.models.user;
+
+import eu.eudat.data.entities.UserDMP;
+import eu.eudat.data.entities.UserInfo;
+import eu.eudat.models.DataModel;
+
+import java.util.UUID;
+
+public class UserInfoPublicModel implements DataModel {
+ private UUID id;
+ private String name;
+ private int role;
+ private String email;
+
+ public UUID getId() {
+ return id;
+ }
+ public void setId(UUID id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getRole() {
+ return role;
+ }
+ public void setRole(int role) {
+ this.role = role;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ @Override
+ public UserInfoPublicModel fromDataModel(UserDMP entity) {
+ this.id = entity.getUser().getId();
+ this.name = entity.getUser().getName();
+ this.role = entity.getRole();
+ this.email = entity.getUser().getEmail();
+ return this;
+ }
+
+ @Override
+ public UserDMP toDataModel() {
+ UserDMP entity = new UserDMP();
+ entity.setId(this.getId());
+ entity.setRole(this.getRole());
+ UserInfo userInfo = new UserInfo();
+ userInfo.setName(this.getName());
+ userInfo.setEmail(this.getEmail());
+ entity.setUser(userInfo);
+ return entity;
+ }
+
+ @Override
+ public String getHint() {
+ return "UserInfoListingModel";
+ }
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/request/dataset/DatasetPublicTableRequest.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/request/dataset/DatasetPublicTableRequest.java
new file mode 100644
index 000000000..44f096e89
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/request/dataset/DatasetPublicTableRequest.java
@@ -0,0 +1,65 @@
+package eu.eudat.publicapi.request.dataset;
+
+import eu.eudat.data.entities.Dataset;
+import eu.eudat.data.query.definition.TableQuery;
+import eu.eudat.publicapi.criteria.dataset.DatasetPublicCriteria;
+import eu.eudat.queryable.QueryableList;
+import eu.eudat.queryable.types.FieldSelectionType;
+import eu.eudat.queryable.types.SelectionField;
+
+import java.util.Arrays;
+import java.util.Date;
+import java.util.UUID;
+
+
+public class DatasetPublicTableRequest extends TableQuery {
+ @Override
+ public QueryableList applyCriteria() {
+ QueryableList query = this.getQuery();
+ query.where((builder, root) -> builder.equal(root.get("dmp").get("isPublic"), true));
+ query.where((builder, root) -> builder.equal(root.get("status"), Dataset.Status.FINALISED.getValue()));
+// query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"),
+// query.subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")),
+// Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class)));
+ if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
+ query.where((builder, root) -> builder.or(
+ builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"),
+ builder.like(builder.upper(root.get("description")), "%" + this.getCriteria().getLike().toUpperCase() + "%")));
+ if (this.getCriteria().getPeriodStart() != null)
+ query.where((builder, root) -> builder.greaterThan(root.get("created"), this.getCriteria().getPeriodStart()));
+ if (this.getCriteria().getPeriodEnd() != null)
+ query.where((builder, root) -> builder.lessThan(root.get("created"), this.getCriteria().getPeriodEnd()));
+ if (this.getCriteria().getGrants() != null && !this.getCriteria().getGrants().isEmpty())
+ query.where(((builder, root) -> root.get("dmp").get("grant").get("id").in(this.getCriteria().getGrants())));
+ if (this.getCriteria().getCollaborators() != null && !this.getCriteria().getCollaborators().isEmpty())
+ query.where(((builder, root) -> root.join("dmp").join("researchers").get("id").in(this.getCriteria().getCollaborators())));
+ if (this.getCriteria().getDatasetTemplates() != null && !this.getCriteria().getDatasetTemplates().isEmpty())
+ query.where((builder, root) -> root.get("id").in(this.getCriteria().getDatasetTemplates()));
+ if (this.getCriteria().getDmpOrganisations() != null && !this.getCriteria().getDmpOrganisations().isEmpty())
+ query.where(((builder, root) -> root.join("dmp").join("organisations").get("reference").in(this.getCriteria().getDmpOrganisations())));
+ if (this.getCriteria().getDmpIds() != null && !this.getCriteria().getDmpIds().isEmpty()) {
+ query.where(((builder, root) -> root.get("dmp").get("id").in(this.getCriteria().getDmpIds())));
+ }
+ if (this.getCriteria().getGroupIds() != null && !this.getCriteria().getGroupIds().isEmpty()) {
+ query.where((builder, root) -> root.get("dmp").get("groupId").in(this.getCriteria().getGroupIds()));
+ }
+
+ //query.where((builder, root) -> builder.lessThan(root.get("dmp").get("grant").get("enddate"), new Date())); // GrantStateType.FINISHED
+ query.where((builder, root) ->
+ builder.or(builder.greaterThan(root.get("dmp").get("grant").get("enddate"), new Date())
+ , builder.isNull(root.get("dmp").get("grant").get("enddate")))); // GrantStateType.ONGOING
+
+ if (!this.getCriteria().getAllVersions()) {
+ query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("profile").get("version"),
+ query.subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(builder1.equal(externalRoot.get("profile").get("groupId"),
+ nestedRoot.get("profile").get("groupId")), builder1.equal(nestedRoot.get("dmp").get("isPublic"), true)), Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "profile:version")), String.class)));
+ }
+ query.where((builder, root) -> builder.notEqual(root.get("status"), Dataset.Status.DELETED.getValue()));
+ return query;
+ }
+
+ @Override
+ public QueryableList applyPaging(QueryableList items) {
+ return null;
+ }
+}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/request/dmp/DataManagmentPlanPublicTableRequest.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/request/dmp/DataManagmentPlanPublicTableRequest.java
new file mode 100644
index 000000000..9c37ff4ac
--- /dev/null
+++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/request/dmp/DataManagmentPlanPublicTableRequest.java
@@ -0,0 +1,59 @@
+package eu.eudat.publicapi.request.dmp;
+
+import eu.eudat.data.entities.DMP;
+import eu.eudat.data.query.PaginationService;
+import eu.eudat.data.query.definition.TableQuery;
+import eu.eudat.publicapi.criteria.dmp.DataManagementPlanPublicCriteria;
+import eu.eudat.queryable.QueryableList;
+import eu.eudat.queryable.types.FieldSelectionType;
+import eu.eudat.queryable.types.SelectionField;
+
+import java.util.Arrays;
+import java.util.Date;
+import java.util.UUID;
+
+public class DataManagmentPlanPublicTableRequest extends TableQuery {
+
+ public QueryableList applyCriteria() {
+ QueryableList query = this.getQuery();
+ query.where((builder, root) -> builder.equal(root.get("isPublic"), true));
+ if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
+ query.where((builder, root) -> builder.or(
+ builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"),
+ builder.like(builder.upper(root.get("description")), "%" + this.getCriteria().getLike().toUpperCase() + "%")));
+ if (this.getCriteria().getPeriodStart() != null)
+ query.where((builder, root) -> builder.greaterThan(root.get("created"), this.getCriteria().getPeriodStart()));
+ if (this.getCriteria().getPeriodEnd() != null)
+ query.where((builder, root) -> builder.lessThan(root.get("created"), this.getCriteria().getPeriodEnd()));
+ if (this.getCriteria().getGrants() != null && !this.getCriteria().getGrants().isEmpty())
+ query.where(((builder, root) -> root.get("grant").get("id").in(this.getCriteria().getGrants())));
+ if (this.getCriteria().getFunders() != null && !this.getCriteria().getFunders().isEmpty())
+ query.where(((builder, root) -> root.get("grant").get("funder").get("id").in(this.getCriteria().getFunders())));
+
+ //query.where((builder, root) -> builder.lessThan(root.get("grant").get("enddate"), new Date())); // GrantStateType.FINISHED
+ query.where((builder, root) ->
+ builder.or(builder.greaterThan(root.get("grant").get("enddate"), new Date())
+ , builder.isNull(root.get("grant").get("enddate")))); // GrantStateType.ONGOING
+
+ if (this.getCriteria().getDatasetTemplates() != null && !this.getCriteria().getDatasetTemplates().isEmpty())
+ query.where((builder, root) -> root.join("dataset").get("id").in(this.getCriteria().getDatasetTemplates()));
+ if (this.getCriteria().getDmpOrganisations() != null && !this.getCriteria().getDmpOrganisations().isEmpty())
+ query.where(((builder, root) -> root.join("organisations").get("reference").in(this.getCriteria().getDmpOrganisations())));
+ if (this.getCriteria().getCollaborators() != null && !this.getCriteria().getCollaborators().isEmpty())
+ query.where(((builder, root) -> root.join("researchers").get("id").in(this.getCriteria().getCollaborators())));
+ if (!this.getCriteria().getAllVersions()) {
+ query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"),
+ query.subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(builder1.equal(externalRoot.get("groupId"),
+ nestedRoot.get("groupId")), builder1.equal(nestedRoot.get("isPublic"), true)), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class)));
+ }
+ if (this.getCriteria().getGroupIds() != null && !this.getCriteria().getGroupIds().isEmpty()) {
+ query.where((builder, root) -> root.get("groupId").in(this.getCriteria().getGroupIds()));
+ }
+ return query;
+ }
+
+ @Override
+ public QueryableList applyPaging(QueryableList items) {
+ return PaginationService.applyPaging(items, this);
+ }
+}