Merge branch 'Development' of code-repo.d4science.org:MaDgiK-CITE/argos into Development
This commit is contained in:
commit
6720504b7b
|
@ -42,7 +42,7 @@
|
||||||
<org.junit.version>4.11</org.junit.version>
|
<org.junit.version>4.11</org.junit.version>
|
||||||
<log4j.version>1.2.17</log4j.version>
|
<log4j.version>1.2.17</log4j.version>
|
||||||
<log4j2.version>2.15.0</log4j2.version>
|
<log4j2.version>2.15.0</log4j2.version>
|
||||||
<slf4j.version>1.7.12</slf4j.version>
|
<slf4j.version>1.7.15</slf4j.version>
|
||||||
<!--<jetty.version>11.0.5
|
<!--<jetty.version>11.0.5
|
||||||
</jetty.version>--> <!-- Adapt this to a version found on http://repo.maven.apache.org/maven2/org/eclipse/jetty/jetty-maven-plugin/ -->
|
</jetty.version>--> <!-- Adapt this to a version found on http://repo.maven.apache.org/maven2/org/eclipse/jetty/jetty-maven-plugin/ -->
|
||||||
<logback.version>1.2.3</logback.version>
|
<logback.version>1.2.3</logback.version>
|
||||||
|
|
|
@ -95,6 +95,16 @@
|
||||||
<artifactId>springfox-swagger-ui</artifactId>
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
|
<version>3.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-boot-starter</artifactId>
|
||||||
|
<version>3.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- facebook Login -->
|
<!-- facebook Login -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -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());
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<DataTableData< DatasetPublicListingModel >>** 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<ResponseItem<DataTableData<DatasetPublicListingModel>>> getPaged(@RequestBody @ApiParam(value = getPagedRequestBodyDescription) DatasetPublicTableRequest datasetTableRequest) throws Exception {
|
||||||
|
DataTableData<DatasetPublicListingModel> dataTable = this.datasetManager.getPublicPaged(datasetTableRequest);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetPublicListingModel>>().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<ResponseItem<DatasetPublicModel>> 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<DatasetPublicModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
|
||||||
|
// } catch (Exception ex) {
|
||||||
|
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<DataTableData< DataManagementPlanPublicListingModel >>** 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<ResponseItem<DataTableData<DataManagementPlanPublicListingModel>>> getPaged(@Valid @RequestBody @ApiParam(value = getPagedRequestBodyDescription) DataManagmentPlanPublicTableRequest dmpTableRequest,
|
||||||
|
@RequestParam @ApiParam(value = getPagedRequestParamDescription, example = "listing") String fieldsGroup) throws Exception {
|
||||||
|
DataTableData<DataManagementPlanPublicListingModel> dataTable = this.dataManagementPlanManager.getPublicPaged(dmpTableRequest, fieldsGroup);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanPublicListingModel>>().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<ResponseItem<DataManagementPlanPublicModel>> 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<DataManagementPlanPublicModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
||||||
|
// } catch (Exception ex) {
|
||||||
|
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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<Dataset> {
|
||||||
|
private Date periodStart;
|
||||||
|
private Date periodEnd;
|
||||||
|
private List<UUID> grants;
|
||||||
|
private List<UUID> collaborators;
|
||||||
|
private List<UUID> datasetTemplates;
|
||||||
|
private List<String> dmpOrganisations;
|
||||||
|
private List<Tag> tags;
|
||||||
|
private List<UUID> dmpIds;
|
||||||
|
private List<UUID> 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<UUID> getGrants() {
|
||||||
|
return grants;
|
||||||
|
}
|
||||||
|
public void setGrants(List<UUID> grants) {
|
||||||
|
this.grants = grants;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UUID> getCollaborators() {
|
||||||
|
return collaborators;
|
||||||
|
}
|
||||||
|
public void setCollaborators(List<UUID> collaborators) {
|
||||||
|
this.collaborators = collaborators;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UUID> getDatasetTemplates() {
|
||||||
|
return datasetTemplates;
|
||||||
|
}
|
||||||
|
public void setDatasetTemplates(List<UUID> datasetTemplates) {
|
||||||
|
this.datasetTemplates = datasetTemplates;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getDmpOrganisations() {
|
||||||
|
return dmpOrganisations;
|
||||||
|
}
|
||||||
|
public void setDmpOrganisations(List<String> dmpOrganisations) {
|
||||||
|
this.dmpOrganisations = dmpOrganisations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Tag> getTags() {
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
public void setTags(List<Tag> tags) {
|
||||||
|
this.tags = tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UUID> getDmpIds() {
|
||||||
|
return dmpIds;
|
||||||
|
}
|
||||||
|
public void setDmpIds(List<UUID> dmpIds) {
|
||||||
|
this.dmpIds = dmpIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UUID> getGroupIds() {
|
||||||
|
return groupIds;
|
||||||
|
}
|
||||||
|
public void setGroupIds(List<UUID> groupIds) {
|
||||||
|
this.groupIds = groupIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getAllVersions() {
|
||||||
|
return allVersions;
|
||||||
|
}
|
||||||
|
public void setAllVersions(boolean allVersions) {
|
||||||
|
this.allVersions = allVersions;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<DMP> {
|
||||||
|
private Date periodStart;
|
||||||
|
private Date periodEnd;
|
||||||
|
private List<UUID> grants;
|
||||||
|
private List<UUID> funders;
|
||||||
|
private List<UUID> datasetTemplates;
|
||||||
|
private List<String> dmpOrganisations;
|
||||||
|
private List<UUID> collaborators;
|
||||||
|
private boolean allVersions;
|
||||||
|
private List<UUID> 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<UUID> getGrants() {
|
||||||
|
return grants;
|
||||||
|
}
|
||||||
|
public void setGrants(List<UUID> grants) {
|
||||||
|
this.grants = grants;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UUID> getFunders() {
|
||||||
|
return funders;
|
||||||
|
}
|
||||||
|
public void setFunders(List<UUID> funders) {
|
||||||
|
this.funders = funders;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UUID> getDatasetTemplates() {
|
||||||
|
return datasetTemplates;
|
||||||
|
}
|
||||||
|
public void setDatasetTemplates(List<UUID> datasetTemplates) {
|
||||||
|
this.datasetTemplates = datasetTemplates;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getDmpOrganisations() {
|
||||||
|
return dmpOrganisations;
|
||||||
|
}
|
||||||
|
public void setDmpOrganisations(List<String> dmpOrganisations) {
|
||||||
|
this.dmpOrganisations = dmpOrganisations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UUID> getCollaborators() {
|
||||||
|
return collaborators;
|
||||||
|
}
|
||||||
|
public void setCollaborators(List<UUID> collaborators) {
|
||||||
|
this.collaborators = collaborators;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getAllVersions() {
|
||||||
|
return allVersions;
|
||||||
|
}
|
||||||
|
public void setAllVersions(boolean allVersions) {
|
||||||
|
this.allVersions = allVersions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UUID> getGroupIds() {
|
||||||
|
return groupIds;
|
||||||
|
}
|
||||||
|
public void setGroupIds(List<UUID> groupIds) {
|
||||||
|
this.groupIds = groupIds;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<SortCriteria> toElasticSorting(ColumnOrderings columnOrderings) {
|
||||||
|
List<SortCriteria> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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<DataManagementPlanPublicListingModel> getPublicPaged(DataManagmentPlanPublicTableRequest dmpTableRequest, String fieldsGroup) throws Exception {
|
||||||
|
dmpTableRequest.setQuery(databaseRepository.getDmpDao().asQueryable().withHint(HintedModelFactory.getHint(DataManagementPlanPublicListingModel.class)));
|
||||||
|
QueryableList<DMP> items = dmpTableRequest.applyCriteria();
|
||||||
|
QueryableList<DMP> pagedItems = PaginationManager.applyPaging(items, dmpTableRequest);
|
||||||
|
|
||||||
|
DataTableData<DataManagementPlanPublicListingModel> 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<DatasetPublicListingModel> 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<eu.eudat.elastic.entities.Dataset> 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<Dataset> items = datasetTableRequest.applyCriteria();*/
|
||||||
|
datasetTableRequest.setQuery(databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetPublicListingModel.class)));
|
||||||
|
QueryableList<Dataset> items;
|
||||||
|
if (datasets != null) {
|
||||||
|
if (!datasets.isEmpty()) {
|
||||||
|
items = databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetPublicListingModel.class));
|
||||||
|
List<eu.eudat.elastic.entities.Dataset> 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<String> 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<Dataset> pagedItems = PaginationManager.applyPaging(items, datasetTableRequest);
|
||||||
|
DataTableData<DatasetPublicListingModel> dataTable = new DataTableData<>();
|
||||||
|
|
||||||
|
List<DatasetPublicListingModel> 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<DatasetProfile> 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<String, Object> 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<AssociatedProfilePublicModel> {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<DatasetProfile, DatasetProfilePublicModel> {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<DataRepository, DataRepositoryPublicModel>, 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<ExternalDataset, ExternalDatasetPublicListingModel> {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<Registry,RegistryPublicModel>, 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<Service, ServicePublicModel>, 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<Funder, FunderPublicOverviewModel> {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<Grant, GrantPublicOverviewModel> {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<DMP, DataManagementPlanPublicListingModel> {
|
||||||
|
private String id;
|
||||||
|
private String label;
|
||||||
|
private String grant;
|
||||||
|
private Date createdAt;
|
||||||
|
private Date modifiedAt;
|
||||||
|
private int version;
|
||||||
|
private UUID groupId;
|
||||||
|
private List<UserInfoPublicModel> 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<UserInfoPublicModel> getUsers() {
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
public void setUsers(List<UserInfoPublicModel> 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";
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<Dataset, DatasetPublicListingModel> {
|
||||||
|
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<UserInfoPublicModel> 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<UserInfoPublicModel> getUsers() {
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsers(List<UserInfoPublicModel> 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";
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<Organisation, OrganizationPublicModel>, 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<String, Object> 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<DMP, DataManagementPlanPublicModel> {
|
||||||
|
private String id;
|
||||||
|
private String label;
|
||||||
|
private String profile;
|
||||||
|
private GrantPublicOverviewModel grant;
|
||||||
|
private Date createdAt;
|
||||||
|
private Date modifiedAt;
|
||||||
|
private Date finalizedAt;
|
||||||
|
private List<OrganizationPublicModel> organisations;
|
||||||
|
private int version;
|
||||||
|
private UUID groupId;
|
||||||
|
private List<DatasetPublicModel> datasets;
|
||||||
|
private List<AssociatedProfilePublicModel> associatedProfiles;
|
||||||
|
private List<ResearcherPublicModel> researchers;
|
||||||
|
private List<UserInfoPublicModel> 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<OrganizationPublicModel> getOrganisations() {
|
||||||
|
return organisations;
|
||||||
|
}
|
||||||
|
public void setOrganisations(List<OrganizationPublicModel> 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<DatasetPublicModel> getDatasets() {
|
||||||
|
return datasets;
|
||||||
|
}
|
||||||
|
public void setDatasets(List<DatasetPublicModel> datasets) {
|
||||||
|
this.datasets = datasets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AssociatedProfilePublicModel> getAssociatedProfiles() {
|
||||||
|
return associatedProfiles;
|
||||||
|
}
|
||||||
|
public void setAssociatedProfiles(List<AssociatedProfilePublicModel> associatedProfiles) {
|
||||||
|
this.associatedProfiles = associatedProfiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UserInfoPublicModel> getUsers() {
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
public void setUsers(List<UserInfoPublicModel> users) {
|
||||||
|
this.users = users;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ResearcherPublicModel> getResearchers() {
|
||||||
|
return researchers;
|
||||||
|
}
|
||||||
|
public void setResearchers(List<ResearcherPublicModel> 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<String, Object> 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";
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<Dataset, DatasetPublicModel> {
|
||||||
|
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<RegistryPublicModel> registries;
|
||||||
|
private List<ServicePublicModel> services;
|
||||||
|
private List<DataRepositoryPublicModel> dataRepositories;
|
||||||
|
private List<Tag> tags;
|
||||||
|
private List<ExternalDatasetPublicListingModel> 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<RegistryPublicModel> getRegistries() {
|
||||||
|
return registries;
|
||||||
|
}
|
||||||
|
public void setRegistries(List<RegistryPublicModel> registries) {
|
||||||
|
this.registries = registries;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ServicePublicModel> getServices() {
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
public void setServices(List<ServicePublicModel> services) {
|
||||||
|
this.services = services;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<DataRepositoryPublicModel> getDataRepositories() {
|
||||||
|
return dataRepositories;
|
||||||
|
}
|
||||||
|
public void setDataRepositories(List<DataRepositoryPublicModel> dataRepositories) {
|
||||||
|
this.dataRepositories = dataRepositories;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DatasetProfilePublicModel getProfile() {
|
||||||
|
return profile;
|
||||||
|
}
|
||||||
|
public void setProfile(DatasetProfilePublicModel profile) {
|
||||||
|
this.profile = profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ExternalDatasetPublicListingModel> getExternalDatasets() {
|
||||||
|
return externalDatasets;
|
||||||
|
}
|
||||||
|
public void setExternalDatasets(List<ExternalDatasetPublicListingModel> externalDatasets) {
|
||||||
|
this.externalDatasets = externalDatasets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Tag> getTags() {
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
public void setTags(List<Tag> 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<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
|
||||||
|
Map<String, String> 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<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
|
||||||
|
Map<String, String> 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<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
|
||||||
|
Map<String, String> 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<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
|
||||||
|
Map<String, String> 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<String, Map<String, String>> data = new HashMap<>();
|
||||||
|
Map<String, String> 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<String,Map<String,String>> data = new HashMap<>();
|
||||||
|
Map<String,String> 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";
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<Researcher, ResearcherPublicModel>, 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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<UserDMP, UserInfoPublicModel> {
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<DatasetPublicCriteria, Dataset, UUID> {
|
||||||
|
@Override
|
||||||
|
public QueryableList<Dataset> applyCriteria() {
|
||||||
|
QueryableList<Dataset> 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.<String>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.<String>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<Dataset> applyPaging(QueryableList<Dataset> items) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<DataManagementPlanPublicCriteria, DMP, UUID> {
|
||||||
|
|
||||||
|
public QueryableList<DMP> applyCriteria() {
|
||||||
|
QueryableList<DMP> 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.<String>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<DMP> applyPaging(QueryableList<DMP> items) {
|
||||||
|
return PaginationService.applyPaging(items, this);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue