Migrating everything is needed for the public api refactor

This commit is contained in:
Thomas Georgios Giannos 2023-11-27 17:33:24 +02:00
parent 516e639153
commit 6fb601929a
33 changed files with 920 additions and 1033 deletions

View File

@ -0,0 +1,7 @@
package eu.eudat.model.mapper.publicapi;
public class DmpToPublicApiDmpMapper {
}

View File

@ -0,0 +1,12 @@
package eu.eudat.model.publicapi;
import eu.eudat.data.old.queryableentity.DataEntity;
public interface DataModel<T extends DataEntity<?,?>, M extends DataModel<?,?>> {
M fromDataModel(T entity);
T toDataModel() throws Exception;
String getHint();
}

View File

@ -0,0 +1,22 @@
package eu.eudat.model.publicapi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.InvocationTargetException;
public class HintedModelFactory {
private static final Logger logger = LoggerFactory.getLogger(HintedModelFactory.class);
public static <T extends DataModel<?,?>> String getHint(Class<T> clazz) {
try {
return clazz.getDeclaredConstructor().newInstance().getHint();
} catch (InstantiationException | IllegalAccessException e) {
logger.error(e.getMessage(), e);
return null;
} catch (InvocationTargetException | NoSuchMethodException e) {
throw new RuntimeException(e);
}
}
}

View File

@ -0,0 +1,424 @@
package eu.eudat.controllers.publicapi;
public final class PublicApiStaticHelpers {
public static final class Dmp {
public static final String getPagedNotes = "The json response is of type **ResponseItem<DataTableData< DataManagementPlanPublicListingModel >>** containing the following properties:\n" +
"<ol>" +
" <li><b>message</b>: string, message indicating error, null if everything went well</li>" +
" <li><b>statusCode</b>: integer, status code indicating if something unexpected happened, otherwise 0</li>" +
" <li><b>responseType</b>: integer, 0 for json, 1 for file</li>" +
" <li><b>payload</b>: DataTableData, containing the number of values of actual data returned and the data of type <b>DataManagementPlanPublicListingModel</b></li>" +
" <ol>" +
" <li>id: string, id of dmp returned</li>" +
" <li>label: string, label of dmp</li>" +
" <li>grant: string, grant of dmp</li>" +
" <li>createdAt: date, creation time of dmp</li>" +
" <li>modifiedAt: date, modification time of dmp</li>" +
" <li>version: integer, version of dmp</li>" +
" <li>groupId: uuid, group id in which dmp belongs</li>" +
" <li>users: list of UserInfoPublicModel, user who collaborated on the dmp</li>" +
" <li>researchers: list of ResearcherPublicModel, researchers involved in the dmp</li>" +
" <li>finalizedAt: date, finalization date</li>" +
" <li>publishedAt: date, publication date</li>" +
" </ol>" +
"</ol>";
public static final String getPagedResponseExample = "{\n" +
" \"statusCode\": 0,\n" +
" \"responseType\": 0,\n" +
" \"message\": null,\n" +
" \"payload\": {\n" +
" \"totalCount\": 2,\n" +
" \"data\": [\n" +
" {\n" +
" \"id\": \"e9a73d77-adfa-4546-974f-4a4a623b53a8\",\n" +
" \"label\": \"Giorgos's DMP\",\n" +
" \"grant\": \"Novel EOSC services for Emerging Atmosphere, Underwater and Space Challenges\",\n" +
" \"createdAt\": 1579077317000,\n" +
" \"modifiedAt\": 1586444334000,\n" +
" \"version\": 0,\n" +
" \"groupId\": \"d949592d-f862-4b31-a43a-f5f70596df5e\",\n" +
" \"users\": [],\n" +
" \"finalizedAt\": 1586444334000,\n" +
" \"publishedAt\": 1586444334000,\n" +
" \"hint\": \"dataManagementPlanListingModel\"\n" +
" },\n" +
" {\n" +
" \"id\": \"e27789f1-de35-4b4a-9587-a46d131c366e\",\n" +
" \"label\": \"TestH2020Clone3\",\n" +
" \"grant\": \"Evaluation of the Benefits of innovative Concepts of laminar nacelle and HTP installed on a business jet configuration\",\n" +
" \"createdAt\": 1600774437000,\n" +
" \"modifiedAt\": 1600879107000,\n" +
" \"version\": 0,\n" +
" \"groupId\": \"7b793c17-cb69-41d2-a97d-e8d1b03ddbed\",\n" +
" \"users\": [],\n" +
" \"finalizedAt\": 1600879107000,\n" +
" \"publishedAt\": 1600879107000,\n" +
" \"hint\": \"dataManagementPlanListingModel\"\n" +
" }\n" +
" ]\n" +
" }\n" +
"}";
public static final String getPagedRequestBodyDescription = "The dmpTableRequest is a DataManagementPlanPublicTableRequest object with the following fields:\n" +
"<ul>" +
" <li><b>length</b>: how many dmps should be fetched <i>(required)</i></li>" +
" <li><b>offset</b>: offset of the returned dmps, first time should be 0, then offset += length</li>" +
" <li><b>orderings</b>: array of strings specifying the order, format:= +string or -string or asc or desc.</li>" +
"<b>+</b> means ascending order. <b>-</b> means descending order.<br>&nbsp;&nbsp;&nbsp;&nbsp;Available strings are: 1) status, 2) label, 3) publishedAt, 4) created.<br>" +
"&nbsp;&nbsp;&nbsp;&nbsp;<b>asc</b> equivalent to +label.<br>&nbsp;&nbsp;&nbsp;&nbsp;<b>desc</b> equivalent to -label.<br>" +
"<li><b>criteria</b>: this is DataManagementPlanPublicCriteria object which applies filters for the dmp returned. More specifically:</li>" +
" <ol>" +
" <li>periodStart: date, dmps created date greater than periodStart</li>" +
" <li>periodEnd: date, dmps created date less than periodEnd</li>" +
" <li>grants: list of uuids, dmps with the corresponding grants</li>" +
" <li>grantsLike: list of strings, dmps fetched having their grant matching any of the strings provided</li>" +
" <li>funders: list of uuids, dmps with the corresponding funders</li>" +
" <li>fundersLike: list of strings, dmps fetched having their funders matching any of the strings provided</li>" +
" <li>datasetTemplates: list of uuids, dataset templates which are described in the dmps</li>" +
" <li>dmpOrganisations: list of strings, dmps belonging to these organisations</li>" +
" <li>collaborators: list of uuids, user who collaborated on the creation/modification of dmps</li>" +
" <li>collaboratorsLike: list of strings, dmps fetched having their collaborators matching any of the strings provided</li>" +
" <li>allVersions: boolean, if dmps should be fetched with all their versions</li>" +
" <li>groupIds: list of uuids, in which groups the dmps are</li>" +
" <li>like: string, dmps fetched have this string matched in their label or description</li>" +
" </ol>" +
"<ul>";
public 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" +
"<ul>" +
" <li><b>listing</b>: returns objects with all their properties completed</li>" +
" <li><b>autocomplete</b>: returns objects with only id, label, groupId and creationTime assigned</li>" +
"<ul>";
public static final String getOverviewSinglePublicNotes = "The json response is of type **ResponseItem< DataManagementPlanPublicModel >** containing the following properties:\n" +
"<ol>" +
" <li><b>message</b>: string, message indicating error, null if everything went well</li>" +
" <li><b>statusCode</b>: integer, status code indicating if something unexpected happened, otherwise 0</li>" +
" <li><b>responseType</b>: integer, 0 for json, 1 for file</li>" +
" <li><b>payload</b>: DataManagementPlanPublicModel, dmp returned</li>" +
" <ol>" +
" <li>id: string, id of dmp returned</li>" +
" <li>label: string, label of dmp</li>" +
" <li>profile: string, profile of dmp</li>" +
" <li>grant: GrantPublicOverviewModel, grant of dmp</li>" +
" <li>createdAt: date, creation time of dmp</li>" +
" <li>modifiedAt: date, modification time of dmp</li>" +
" <li>finalizedAt: date, finalization date of dmp</li>" +
" <li>organisations: list of OrganizationPublicModel, organizations in which dmp belongs</li>" +
" <li>version: integer, version of dmp</li>" +
" <li>groupId: uuid, group id in which dmp belongs</li>" +
" <li>datasets: list of DatasetPublicModel, contained datasets</li>" +
" <li>associatedProfiles: list of AssociatedProfilePublicModel, associated profiles of dmp</li>" +
" <li>researchers: list of ResearcherPublicModel, researchers involved in dmp</li>" +
" <li>users: list of UserInfoPublicModel, user who collaborated on the dmp</li>" +
" <li>description: string, description of dmp</li>" +
" <li>publishedAt: date, publication date</li>" +
" <li>doi: string, if dmp has been published to zenodo so it has doi</li>" +
" </ol>" +
"</ol>";
public static final String getOverviewSinglePublicResponseExample = "{\n" +
" \"statusCode\": 0,\n" +
" \"responseType\": 0,\n" +
" \"message\": null,\n" +
" \"payload\": {\n" +
" \"id\": \"e9a73d77-adfa-4546-974f-4a4a623b53a8\",\n" +
" \"label\": \"Giorgos's DMP\",\n" +
" \"profile\": null,\n" +
" \"grant\": {\n" +
" \"id\": \"c8309ae5-4e56-43eb-aa5a-9950c24051fe\",\n" +
" \"label\": \"Novel EOSC services for Emerging Atmosphere, Underwater and Space Challenges\",\n" +
" \"abbreviation\": null,\n" +
" \"description\": null,\n" +
" \"startDate\": null,\n" +
" \"endDate\": null,\n" +
" \"uri\": null,\n" +
" \"funder\": {\n" +
" \"id\": \"25e76828-3539-4c66-9870-0ecea7a4d16e\",\n" +
" \"label\": \"European Commission||EC\",\n" +
" \"hint\": null\n" +
" },\n" +
" \"hint\": null\n" +
" },\n" +
" \"createdAt\": 1579077317000,\n" +
" \"modifiedAt\": 1586444334000,\n" +
" \"finalizedAt\": 1586444334000,\n" +
" \"organisations\": [],\n" +
" \"version\": 0,\n" +
" \"groupId\": \"d949592d-f862-4b31-a43a-f5f70596df5e\",\n" +
" \"datasets\": [\n" +
" {\n" +
" \"id\": \"853a24c3-def4-4978-985f-92e7fa57ef22\",\n" +
" \"label\": \"Giorgos's Dataset Desc\",\n" +
" \"reference\": null,\n" +
" \"uri\": null,\n" +
" \"description\": null,\n" +
" \"status\": 1,\n" +
" \"createdAt\": 1579077532000,\n" +
" \"dmp\": {\n" +
" \"id\": \"e9a73d77-adfa-4546-974f-4a4a623b53a8\",\n" +
" \"label\": \"Giorgos's DMP\",\n" +
" \"grant\": \"Novel EOSC services for Emerging Atmosphere, Underwater and Space Challenges\",\n" +
" \"createdAt\": 1579077317000,\n" +
" \"modifiedAt\": 1586444334000,\n" +
" \"version\": 0,\n" +
" \"groupId\": \"d949592d-f862-4b31-a43a-f5f70596df5e\",\n" +
" \"users\": [\n" +
" {\n" +
" \"id\": \"00476b4d-0491-44ca-b2fd-92e695062a48\",\n" +
" \"name\": \"OpenDMP OpenDMP\",\n" +
" \"role\": 0,\n" +
" \"email\": \"opendmpeu@gmail.com\",\n" +
" \"hint\": \"UserInfoListingModel\"\n" +
" }\n" +
" ],\n" +
" \"finalizedAt\": 1586444334000,\n" +
" \"publishedAt\": 1586444334000,\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\": \"2a6e0835-349e-412c-9fcc-8e1298ce8a5a\",\n" +
" \"label\": \"Horizon 2020\",\n" +
" \"hint\": null\n" +
" },\n" +
" \"modifiedAt\": 1579077898000,\n" +
" \"hint\": \"datasetOverviewModel\"\n" +
" }\n" +
" ],\n" +
" \"associatedProfiles\": [\n" +
" {\n" +
" \"id\": \"f41bd794-761d-4fe8-ab67-3a989d982c53\",\n" +
" \"label\": \"Swedish Research Council\"\n" +
" },\n" +
" {\n" +
" \"id\": \"2a6e0835-349e-412c-9fcc-8e1298ce8a5a\",\n" +
" \"label\": \"Horizon 2020\"\n" +
" }\n" +
" ],\n" +
" \"researchers\": [],\n" +
" \"users\": [\n" +
" {\n" +
" \"id\": \"00476b4d-0491-44ca-b2fd-92e695062a48\",\n" +
" \"name\": \"OpenDMP OpenDMP\",\n" +
" \"role\": 0,\n" +
" \"email\": \"opendmpeu@gmail.com\",\n" +
" \"hint\": \"UserInfoListingModel\"\n" +
" }\n" +
" ],\n" +
" \"description\": null,\n" +
" \"publishedAt\": 1586444334000,\n" +
" \"doi\": \"10.5072/zenodo.522151\",\n" +
" \"hint\": \"dataManagementPlanOverviewModel\"\n" +
" }\n" +
"}";
}
public static final class Description {
public static final String getPagedNotes = "The json response is of type **ResponseItem<DataTableData< DatasetPublicListingModel >>** containing the following properties:\n" +
"<ol>" +
" <li><b>message</b>: string, message indicating error, null if everything went well</li>" +
" <li><b>statusCode</b>: integer, status code indicating if something unexpected happened, otherwise 0</li>" +
" <li><b>responseType</b>: integer, 0 for json, 1 for file</li>" +
" <li><b>payload</b>: DataTableData, containing the number of values of actual data returned and the data of type <b>DatasetPublicListingModel</b></li>" +
" <ol>" +
" <li>id: string, id of dataset returned</li>" +
" <li>label: string, label of dataset</li>" +
" <li>grant: string, grant of dataset</li>" +
" <li>dmp: string, dmp description</li>" +
" <li>dmpId: string, dmp's id</li>" +
" <li>profile: DatasetProfilePublicModel, dataset's profile</li>" +
" <li>createdAt: date, creation date</li>" +
" <li>modifiedAt: date, modification date</li>" +
" <li>description: string, dataset's description</li>" +
" <li>finalizedAt: date, finalization date</li>" +
" <li>dmpPublishedAt: date, dmp's publication date</li>" +
" <li>version: integer, dataset's version</li>" +
" <li>users: list of UserInfoPublicModel, user who collaborated on the dataset</li>" +
" </ol>" +
"</ol>";
public static final String getPagedResponseExample = "{\n" +
" \"statusCode\": 0,\n" +
" \"responseType\": 0,\n" +
" \"message\": null,\n" +
" \"payload\": {\n" +
" \"totalCount\": 2,\n" +
" \"data\": [\n" +
" {\n" +
" \"id\": \"ef7dfbdc-c5c1-46a7-a37b-c8d8692f1c0e\",\n" +
" \"label\": \"BARKAMOL RIVOJLANGAN SHAXSNI TARBIYALASHDA HARAKATLI O`YINLARNING O`RNI\",\n" +
" \"grant\": \"A next generation nano media tailored to capture and recycle hazardous micropollutants in contaminated industrial wastewater.\",\n" +
" \"dmp\": \"test for demo\",\n" +
" \"dmpId\": \"9dee6e72-7a4c-4fbd-b8a4-1f8cda38eb5e\",\n" +
" \"profile\": {\n" +
" \"id\": \"771283d7-a5be-4a93-bd3c-8b1883fe837c\",\n" +
" \"label\": \"Horizon Europe\",\n" +
" \"hint\": null\n" +
" },\n" +
" \"createdAt\": 1662711279000,\n" +
" \"modifiedAt\": 1662712928000,\n" +
" \"description\": \"<p>&nbsp; &nbsp; &nbsp;Annotatsiya &nbsp;Maqolada &nbsp;bolalarni &nbsp;o`yin &nbsp;mavjud &nbsp;bo`lgan &nbsp;shakllarda &nbsp;mavjud&nbsp;<br>\\nhayot &nbsp;bilan &nbsp;kengroq &nbsp;tanishtirishga &nbsp;imkon &nbsp;beradi. &nbsp;O`yin &nbsp;bolalarning &nbsp;turli &nbsp;xil&nbsp;<br>\\nfaoliyati,o`yin &nbsp;ko`nikmalarini &nbsp;shakllantirishga &nbsp;yordam &nbsp;beradi.Ularni &nbsp;fikrlash, &nbsp;his-<br>\\ntuyg`ular, tajribalar, o`yin muammosini hal qilishning faol usullarini izlash, ularning&nbsp;<br>\\no`yin sharoitlari va sharoitlariga bo`ysunishi, o`yindagi bolalarning munosabatlari,&nbsp;<br>\\no`yin orqali bola organik rivojlanadi, &nbsp;inson madaniyatining muhim qatlami kattalar&nbsp;<br>\\no`rtasidagi &nbsp;munosabatlar &nbsp;- &nbsp;oilada, &nbsp;ularning &nbsp;kasbiy &nbsp;faoliyati &nbsp;va &nbsp;boshqalar. &nbsp;O`yin&nbsp;<br>\\no`qituvchilar barcha ta&rsquo;lim vazifalarini, shu jumladan o`rganishni hal qiladigan eng&nbsp;<br>\\nmuhim faoliyat sifatida foydalaniladi.&nbsp;</p>\",\n" +
" \"finalizedAt\": 1662712928000,\n" +
" \"dmpPublishedAt\": 1662713226000,\n" +
" \"version\": 0,\n" +
" \"users\": [\n" +
" {\n" +
" \"id\": \"33024e48-d528-45a5-8035-ea48641bd2f2\",\n" +
" \"name\": \"DMP author\",\n" +
" \"role\": 0,\n" +
" \"email\": \"kanavou.p@gmail.com\",\n" +
" \"hint\": \"UserInfoListingModel\"\n" +
" }\n" +
" ],\n" +
" \"hint\": \"datasetListingModel\"\n" +
" },\n" +
" {\n" +
" \"id\": \"0f253ab2-18cb-4798-adc1-135b81cfad0c\",\n" +
" \"label\": \"A \\\"zoom-elit\\\" és a kamionosok küzdelme, avagy a meritokrácia és a populizmus összecsapása\",\n" +
" \"grant\": \"Discovery Projects - Grant ID: DP140100157\",\n" +
" \"dmp\": \"TEST UPDATE 2.8.2022\",\n" +
" \"dmpId\": \"1f4daa8f-4e2f-4dc9-a60b-f6b75d313400\",\n" +
" \"profile\": {\n" +
" \"id\": \"3d43ba45-25fa-4815-81b4-9bf22ecd8316\",\n" +
" \"label\": \"HE_Final\",\n" +
" \"hint\": null\n" +
" },\n" +
" \"createdAt\": 1659392761000,\n" +
" \"modifiedAt\": 1659393655000,\n" +
" \"description\": \"<p>A kanadai kamionosok &bdquo;szabads&aacute;gmenete&rdquo; kapcs&aacute;n a&nbsp;New York Times&nbsp;has&aacute;bjain Ross Donthat publicista egy r&eacute;gi k&ouml;nyvre h&iacute;vja fel a figyelmet, amely sok &eacute;vtizeddel ezelőtt megj&oacute;solta az elit elleni hasonl&oacute; l&aacute;zad&aacute;sokat.</p>\",\n" +
" \"finalizedAt\": 1659393654000,\n" +
" \"dmpPublishedAt\": 1659393698000,\n" +
" \"version\": 0,\n" +
" \"users\": [\n" +
" {\n" +
" \"id\": \"33024e48-d528-45a5-8035-ea48641bd2f2\",\n" +
" \"name\": \"DMP author\",\n" +
" \"role\": 0,\n" +
" \"email\": \"kanavou.p@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" +
"<ul>" +
"<li><b>length</b>: how many datasets should be fetched <i>(required)</i></li>" +
"<li><b>offset</b>: offset of the returned datasets, first time should be 0, then offset += length</li>" +
"<li><b>orderings</b>: array of strings specifying the order, format:= +string or -string or asc or desc.</li>" +
"<b>+</b> means ascending order. <b>-</b> means descending order.<br>&nbsp;&nbsp;&nbsp;&nbsp;Available strings are: 1) status, 2) label, 3) created.<br>" +
"&nbsp;&nbsp;&nbsp;&nbsp;<b>asc</b> equivalent to +label.<br>&nbsp;&nbsp;&nbsp;&nbsp;<b>desc</b> equivalent to -label.<br>" +
"<li><b>criteria</b>: this is DatasetPublicCriteria object which applies filters for the datasets returned. More specifically:</li>" +
" <ol>" +
" <li>periodStart: date, datasets created date greater than periodStart</li>" +
" <li>periodEnd: date, datasets created date less than periodEnd</li>" +
" <li>grants: list of uuids, dmps(datasets) with the corresponding grants</li>" +
" <li>collaborators: list of uuids, user who collaborated on the creation/modification of datasets</li>" +
" <li>datasetTemplates: list of uuids, dataset templates uuids to be included</li>" +
" <li>dmpOrganisations: list of strings, datasets involved in dmps which belong to these organisations</li>" +
" <li>tags: list of Tag objects, tags involved in datasets</li>" +
" <li>dmpIds: list of uuids, dmps with the specific ids</li>" +
" <li>groupIds: list of uuids, in which groups the datasets are</li>" +
" <li>allVersions: boolean, if datasets should be fetched with all their versions</li>" +
" <li>like: string, datasets fetched have this string matched in their label or description</li>" +
" </ol>" +
"</ul>";
public static final String getOverviewSinglePublicNotes = "The json response is of type **ResponseItem< DatasetPublicModel >** containing the following properties:\n" +
"<ol>" +
" <li><b>message</b>: string, message indicating error, null if everything went well</li>" +
" <li><b>statusCode</b>: integer, status code indicating if something unexpected happened, otherwise 0</li>" +
" <li><b>responseType</b>: integer, 0 for json, 1 for file</li>" +
" <li><b>payload</b>: DatasetPublicModel, dmp returned</li>" +
" <ol>" +
" <li>id: uuid, id of dataset returned</li>" +
" <li>label: string, label of dataset</li>" +
" <li>reference: string, reference of dataset</li>" +
" <li>uri: string, uri of dataset</li>" +
" <li>description: string, dataset's description</li>" +
" <li>status: string, dataset's status</li>" +
" <li>createdAt: date, creation time of dataset</li>" +
" <li>dmp: DataManagementPlanPublicListingModel, dmp to which dataset belongs</li>" +
" <li>datasetProfileDefinition: PagedDatasetProfile, dataset's paged description</li>" +
" <li>registries: list of RegistryPublicModel, dataset's registries</li>" +
" <li>services: list of ServicePublicModel, dataset's services</li>" +
" <li>dataRepositories: list of DataRepositoryPublicModel, dataset's data repositories</li>" +
" <li>tags: list of Tag, dataset's tags</li>" +
" <li>externalDatasets: list of ExternalDatasetPublicListingModel, dataset's external datasets</li>" +
" <li>profile: DatasetProfilePublicModel, dataset's profile</li>" +
" <li>modifiedAt: date, modification time of dataset</li>" +
" </ol>" +
"</ol>";
public static final String getOverviewSinglePublicResponseExample = "{\n" +
" \"statusCode\": 0,\n" +
" \"responseType\": 0,\n" +
" \"message\": null,\n" +
" \"payload\": {\n" +
" \"id\": \"ef7dfbdc-c5c1-46a7-a37b-c8d8692f1c0e\",\n" +
" \"label\": \"BARKAMOL RIVOJLANGAN SHAXSNI TARBIYALASHDA HARAKATLI O`YINLARNING O`RNI\",\n" +
" \"reference\": null,\n" +
" \"uri\": null,\n" +
" \"description\": \"<p>&nbsp; &nbsp; &nbsp;Annotatsiya &nbsp;Maqolada &nbsp;bolalarni &nbsp;o`yin &nbsp;mavjud &nbsp;bo`lgan &nbsp;shakllarda &nbsp;mavjud&nbsp;<br>\\nhayot &nbsp;bilan &nbsp;kengroq &nbsp;tanishtirishga &nbsp;imkon &nbsp;beradi. &nbsp;O`yin &nbsp;bolalarning &nbsp;turli &nbsp;xil&nbsp;<br>\\nfaoliyati,o`yin &nbsp;ko`nikmalarini &nbsp;shakllantirishga &nbsp;yordam &nbsp;beradi.Ularni &nbsp;fikrlash, &nbsp;his-<br>\\ntuyg`ular, tajribalar, o`yin muammosini hal qilishning faol usullarini izlash, ularning&nbsp;<br>\\no`yin sharoitlari va sharoitlariga bo`ysunishi, o`yindagi bolalarning munosabatlari,&nbsp;<br>\\no`yin orqali bola organik rivojlanadi, &nbsp;inson madaniyatining muhim qatlami kattalar&nbsp;<br>\\no`rtasidagi &nbsp;munosabatlar &nbsp;- &nbsp;oilada, &nbsp;ularning &nbsp;kasbiy &nbsp;faoliyati &nbsp;va &nbsp;boshqalar. &nbsp;O`yin&nbsp;<br>\\no`qituvchilar barcha ta&rsquo;lim vazifalarini, shu jumladan o`rganishni hal qiladigan eng&nbsp;<br>\\nmuhim faoliyat sifatida foydalaniladi.&nbsp;</p>\",\n" +
" \"status\": 1,\n" +
" \"createdAt\": 1662711279000,\n" +
" \"dmp\": {\n" +
" \"id\": \"9dee6e72-7a4c-4fbd-b8a4-1f8cda38eb5e\",\n" +
" \"label\": \"test for demo\",\n" +
" \"grant\": \"A next generation nano media tailored to capture and recycle hazardous micropollutants in contaminated industrial wastewater.\",\n" +
" \"createdAt\": 1662710691000,\n" +
" \"modifiedAt\": 1662713226000,\n" +
" \"version\": 0,\n" +
" \"groupId\": \"adaa4e17-7375-45b8-b052-09edaeb6da86\",\n" +
" \"users\": [\n" +
" {\n" +
" \"id\": \"33024e48-d528-45a5-8035-ea48641bd2f2\",\n" +
" \"name\": \"DMP author\",\n" +
" \"role\": 0,\n" +
" \"email\": \"kanavou.p@gmail.com\",\n" +
" \"hint\": \"UserInfoListingModel\"\n" +
" }\n" +
" ],\n" +
" \"finalizedAt\": 1662713226000,\n" +
" \"publishedAt\": 1662713226000,\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\": \"771283d7-a5be-4a93-bd3c-8b1883fe837c\",\n" +
" \"label\": \"Horizon Europe\",\n" +
" \"hint\": null\n" +
" },\n" +
" \"modifiedAt\": 1662712928000,\n" +
" \"hint\": \"datasetOverviewModel\"\n" +
" }\n" +
"}";
}
}

View File

@ -0,0 +1,73 @@
package eu.eudat.controllers.publicapi;
import eu.eudat.controllers.BaseController;
import eu.eudat.controllers.publicapi.managers.DatasetPublicManager;
import eu.eudat.controllers.publicapi.models.listingmodels.DatasetPublicListingModel;
import eu.eudat.controllers.publicapi.response.DataTableData;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.controllers.publicapi.models.overviewmodels.DatasetPublicModel;
import eu.eudat.controllers.publicapi.request.dataset.DatasetPublicTableRequest;
import eu.eudat.types.ApiMessageCode;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
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;
@Tag(name = "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;
@Autowired
public PublicDatasetsDescriptionDocumentation(ApiContext apiContext, DatasetPublicManager datasetManager) {
super(apiContext);
this.datasetManager = datasetManager;
}
@Operation(summary = "This method is used to get a listing of public datasets.", description = PublicApiStaticHelpers.Description.getPagedNotes)
@io.swagger.v3.oas.annotations.responses.ApiResponses(value = {@io.swagger.v3.oas.annotations.responses.ApiResponse(
responseCode = "200",
description = "The following example is generated using body: *{\"criteria\": {},\"length\": 2,\"offset\": 0,\"orderings\": {\"fields\": []} }*",
content = @Content(mediaType = APPLICATION_JSON_VALUE, examples = {@ExampleObject(
value = PublicApiStaticHelpers.Description.getPagedResponseExample
)})
)})
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DatasetPublicListingModel>>> getPaged(@Valid @RequestBody @io.swagger.v3.oas.annotations.parameters.RequestBody(description = PublicApiStaticHelpers.Description.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));
}
@Operation(summary = "This method is used to get the overview of a public dataset.", description = PublicApiStaticHelpers.Description.getOverviewSinglePublicNotes)
@io.swagger.v3.oas.annotations.responses.ApiResponses(value = {@ApiResponse(
responseCode = "200",
description = "The following example is generated using id: *ef7dfbdc-c5c1-46a7-a37b-c8d8692f1c0e*",
content = @Content(mediaType = APPLICATION_JSON_VALUE, examples = {@ExampleObject(
value = PublicApiStaticHelpers.Description.getOverviewSinglePublicResponseExample
)})
)})
@RequestMapping(method = RequestMethod.GET, value = {"/{id}"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DatasetPublicModel>> getOverviewSinglePublic(@PathVariable @Parameter(description = "fetch the dataset with the given id", example = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") String id) throws Exception {
DatasetPublicModel dataset = this.datasetManager.getOverviewSinglePublic(id);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetPublicModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
}
}

View File

@ -0,0 +1,74 @@
package eu.eudat.controllers.publicapi;
import eu.eudat.controllers.BaseController;
import eu.eudat.controllers.publicapi.managers.DataManagementPlanPublicManager;
import eu.eudat.controllers.publicapi.models.listingmodels.DataManagementPlanPublicListingModel;
import eu.eudat.controllers.publicapi.models.overviewmodels.DataManagementPlanPublicModel;
import eu.eudat.controllers.publicapi.request.dmp.DataManagmentPlanPublicTableRequest;
import eu.eudat.controllers.publicapi.response.DataTableData;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.types.ApiMessageCode;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
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;
@Tag(name = "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);
@Autowired
public PublicDmpsDocumentation(ApiContext apiContext) {
super(apiContext);
}
@Operation(summary = "This method is used to get a listing of public dmps.", description = PublicApiStaticHelpers.Dmp.getPagedNotes)
@io.swagger.v3.oas.annotations.responses.ApiResponses(value = {@ApiResponse(
responseCode = "200",
description = """
The following example is generated using:
a) body: *{"criteria": {},"length": 2,"offset": 0,"orderings": {"fields": []} }*
b) fieldsGroup: listing""",
content = @Content(mediaType = APPLICATION_JSON_VALUE, examples = {@ExampleObject(
value = PublicApiStaticHelpers.Dmp.getPagedResponseExample
)})
)})
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanPublicListingModel>>> getPaged(@Valid @RequestBody @io.swagger.v3.oas.annotations.parameters.RequestBody(description = PublicApiStaticHelpers.Dmp.getPagedRequestBodyDescription) DataManagmentPlanPublicTableRequest dmpTableRequest,
@RequestParam @Parameter(description = PublicApiStaticHelpers.Dmp.getPagedRequestParamDescription, example = "listing") String fieldsGroup) throws Exception {
// DataTableData<DataManagementPlanPublicListingModel> dataTable = this.dataManagementPlanManager.getPublicPaged(dmpTableRequest, fieldsGroup); //TODO
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanPublicListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(null));
}
@Operation(summary = "This method is used to get the overview of a public dmp.", description = PublicApiStaticHelpers.Dmp.getOverviewSinglePublicNotes)
@io.swagger.v3.oas.annotations.responses.ApiResponses(value = {@ApiResponse(
responseCode = "200",
description = "The following example is generated using id: *e9a73d77-adfa-4546-974f-4a4a623b53a8*",
content = @Content(mediaType = APPLICATION_JSON_VALUE, examples = {@ExampleObject(
value = PublicApiStaticHelpers.Dmp.getOverviewSinglePublicResponseExample
)})
)})
@RequestMapping(method = RequestMethod.GET, value = {"/{id}"}, produces = "application/json")
public @ResponseBody ResponseEntity<ResponseItem<DataManagementPlanPublicModel>> getOverviewSinglePublic(@PathVariable @Parameter(description = "fetch the dmp with the given id", example = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") String id) throws Exception {
// DataManagementPlanPublicModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSinglePublic(id); //TODO
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanPublicModel>().status(ApiMessageCode.NO_MESSAGE).payload(null));
}
}

View File

@ -1,4 +1,4 @@
package eu.eudat.publicapi.criteria.dataset; package eu.eudat.controllers.publicapi.criteria.dataset;
import eu.eudat.data.dao.criteria.Criteria; import eu.eudat.data.dao.criteria.Criteria;
import eu.eudat.data.DescriptionEntity; import eu.eudat.data.DescriptionEntity;

View File

@ -1,4 +1,4 @@
package eu.eudat.publicapi.criteria.dmp; package eu.eudat.controllers.publicapi.criteria.dmp;
import eu.eudat.data.DmpEntity; import eu.eudat.data.DmpEntity;
import eu.eudat.data.dao.criteria.Criteria; import eu.eudat.data.dao.criteria.Criteria;

View File

@ -1,17 +1,17 @@
package eu.eudat.publicapi.managers; package eu.eudat.controllers.publicapi.managers;
import eu.eudat.commons.enums.DmpAccessType; import eu.eudat.commons.enums.DmpAccessType;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.controllers.publicapi.models.listingmodels.DataManagementPlanPublicListingModel;
import eu.eudat.controllers.publicapi.response.DataTableData;
import eu.eudat.data.DmpEntity; import eu.eudat.data.DmpEntity;
import eu.eudat.exceptions.security.ForbiddenException; import eu.eudat.exceptions.security.ForbiddenException;
import eu.eudat.logic.managers.PaginationManager; import eu.eudat.logic.managers.PaginationManager;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.DatabaseRepository; import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.models.HintedModelFactory; import eu.eudat.models.HintedModelFactory;
import eu.eudat.models.data.helpers.common.DataTableData; import eu.eudat.controllers.publicapi.models.overviewmodels.DataManagementPlanPublicModel;
import eu.eudat.publicapi.models.listingmodels.DataManagementPlanPublicListingModel; import eu.eudat.controllers.publicapi.request.dmp.DataManagmentPlanPublicTableRequest;
import eu.eudat.publicapi.models.overviewmodels.DataManagementPlanPublicModel;
import eu.eudat.publicapi.request.dmp.DataManagmentPlanPublicTableRequest;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -33,7 +33,7 @@ public class DataManagementPlanPublicManager {
} }
public DataTableData<DataManagementPlanPublicListingModel> getPublicPaged(DataManagmentPlanPublicTableRequest dmpTableRequest, String fieldsGroup) throws Exception { public DataTableData<DataManagementPlanPublicListingModel> getPublicPaged(DataManagmentPlanPublicTableRequest dmpTableRequest, String fieldsGroup) throws Exception {
dmpTableRequest.setQuery(databaseRepository.getDmpDao().asQueryable().withHint(HintedModelFactory.getHint(DataManagementPlanPublicListingModel.class))); dmpTableRequest.setQuery(databaseRepository.getDmpDao().asQueryable().withHint(DataManagementPlanPublicListingModel.getHint()));
QueryableList<DmpEntity> items = dmpTableRequest.applyCriteria(); QueryableList<DmpEntity> items = dmpTableRequest.applyCriteria();
QueryableList<DmpEntity> pagedItems = PaginationManager.applyPaging(items, dmpTableRequest); QueryableList<DmpEntity> pagedItems = PaginationManager.applyPaging(items, dmpTableRequest);
@ -41,7 +41,7 @@ public class DataManagementPlanPublicManager {
CompletableFuture itemsFuture; CompletableFuture itemsFuture;
if (fieldsGroup.equals("listing")) { if (fieldsGroup.equals("listing")) {
itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DataManagementPlanPublicListingModel.class)) itemsFuture = pagedItems.withHint(DataManagementPlanPublicListingModel.getHint())
.selectAsync(item -> { .selectAsync(item -> {
// item.setDataset( // item.setDataset(
// item.getDataset().stream() // item.getDataset().stream()

View File

@ -0,0 +1,113 @@
package eu.eudat.controllers.publicapi.managers;
import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
import eu.eudat.controllers.publicapi.models.listingmodels.DatasetPublicListingModel;
import eu.eudat.controllers.publicapi.request.dataset.DatasetPublicTableRequest;
import eu.eudat.controllers.publicapi.response.DataTableData;
import eu.eudat.data.DescriptionEntity;
import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.data.query.definition.helpers.ColumnOrderings;
import eu.eudat.logic.managers.PaginationManager;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.commons.types.xml.XmlBuilder;
import eu.eudat.models.HintedModelFactory;
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import eu.eudat.controllers.publicapi.models.overviewmodels.DatasetPublicModel;
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 org.w3c.dom.Document;
import org.w3c.dom.Element;
import jakarta.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;
@Autowired
public DatasetPublicManager(ApiContext apiContext){
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
}
public DataTableData<DatasetPublicListingModel> getPublicPaged(DatasetPublicTableRequest datasetTableRequest) throws Exception {
Long count = 0L;
datasetTableRequest.setQuery(databaseRepository.getDatasetDao().asQueryable().withHint(DatasetPublicListingModel.getHint()));
QueryableList<DescriptionEntity> items;
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);
}
count = items.count();
QueryableList<DescriptionEntity> 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()));
dataTable.setTotalCount(count);
return dataTable;
}
public DatasetPublicModel getOverviewSinglePublic(String id) throws Exception {
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id));
if (descriptionEntityEntity.getIsActive() == IsActive.Inactive) {
throw new Exception("Dataset is deleted.");
}
DatasetPublicModel dataset = new DatasetPublicModel();
dataset.setDatasetProfileDefinition(this.getPagedProfile(dataset.getStatus(), descriptionEntityEntity));
dataset.fromDataModel(descriptionEntityEntity);
return dataset;
}
@Transactional
private DatasetPublicListingModel mapPublicModel(DescriptionEntity item) {
DatasetPublicListingModel listingPublicModel = new DatasetPublicListingModel().fromDataModel(item);
return listingPublicModel;
}
private PagedDatasetProfile getPagedProfile(DescriptionStatus status, DescriptionEntity descriptionEntityEntity){
//TODO
// eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = this.generateDatasetProfileModel(descriptionEntityEntity.getProfile());
// datasetprofile.setStatus(status.getValue());
// if (descriptionEntityEntity.getProperties() != null) {
// JSONObject jObject = new JSONObject(descriptionEntityEntity.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(DescriptionTemplateEntity profile) {
Document viewStyleDoc = XmlBuilder.fromXml(profile.getDefinition());
Element root = (Element) viewStyleDoc.getDocumentElement();
DefinitionEntity viewstyle = new DefinitionEntity().fromXml(root);
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = new eu.eudat.models.data.user.composite.DatasetProfile();
datasetprofile.buildProfile(viewstyle);
return datasetprofile;
}
}

View File

@ -1,4 +1,4 @@
package eu.eudat.publicapi.models.associatedprofile; package eu.eudat.controllers.publicapi.models.associatedprofile;
import eu.eudat.data.DescriptionTemplateEntity; import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.commons.types.xml.XmlSerializable; import eu.eudat.commons.types.xml.XmlSerializable;

View File

@ -1,4 +1,4 @@
package eu.eudat.publicapi.models.datasetprofile; package eu.eudat.controllers.publicapi.models.datasetprofile;
import eu.eudat.data.DescriptionTemplateEntity; import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;

View File

@ -1,4 +1,4 @@
package eu.eudat.publicapi.models.datasetwizard; package eu.eudat.controllers.publicapi.models.datasetwizard;
import eu.eudat.data.old.DataRepository; import eu.eudat.data.old.DataRepository;
import eu.eudat.logic.utilities.helpers.LabelGenerator; import eu.eudat.logic.utilities.helpers.LabelGenerator;

View File

@ -1,4 +1,4 @@
package eu.eudat.publicapi.models.datasetwizard; package eu.eudat.controllers.publicapi.models.datasetwizard;
import eu.eudat.data.old.ExternalDataset; import eu.eudat.data.old.ExternalDataset;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;

View File

@ -1,4 +1,4 @@
package eu.eudat.publicapi.models.datasetwizard; package eu.eudat.controllers.publicapi.models.datasetwizard;
import eu.eudat.data.old.Registry; import eu.eudat.data.old.Registry;
import eu.eudat.logic.utilities.helpers.LabelGenerator; import eu.eudat.logic.utilities.helpers.LabelGenerator;

View File

@ -1,4 +1,4 @@
package eu.eudat.publicapi.models.datasetwizard; package eu.eudat.controllers.publicapi.models.datasetwizard;
import eu.eudat.data.old.Service; import eu.eudat.data.old.Service;
import eu.eudat.logic.utilities.helpers.LabelGenerator; import eu.eudat.logic.utilities.helpers.LabelGenerator;

View File

@ -1,8 +1,7 @@
package eu.eudat.publicapi.models.doi; package eu.eudat.controllers.publicapi.models.doi;
import eu.eudat.data.EntityDoiEntity; import eu.eudat.data.EntityDoiEntity;
import eu.eudat.logic.utilities.helpers.LabelGenerator; import eu.eudat.logic.utilities.helpers.LabelGenerator;
import eu.eudat.models.DataModel;
import java.util.UUID; import java.util.UUID;

View File

@ -1,4 +1,4 @@
package eu.eudat.publicapi.models.funder; package eu.eudat.controllers.publicapi.models.funder;
import eu.eudat.data.old.Funder; import eu.eudat.data.old.Funder;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;

View File

@ -1,8 +1,8 @@
package eu.eudat.publicapi.models.grant; package eu.eudat.controllers.publicapi.models.grant;
import eu.eudat.controllers.publicapi.models.funder.FunderPublicOverviewModel;
import eu.eudat.data.old.Grant; import eu.eudat.data.old.Grant;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;
import eu.eudat.publicapi.models.funder.FunderPublicOverviewModel;
import java.util.Date; import java.util.Date;
import java.util.UUID; import java.util.UUID;

View File

@ -1,15 +1,12 @@
package eu.eudat.publicapi.models.listingmodels; package eu.eudat.controllers.publicapi.models.listingmodels;
import eu.eudat.data.DmpEntity; import eu.eudat.data.DmpEntity;
import eu.eudat.data.old.Grant;
import eu.eudat.model.DmpUser; import eu.eudat.model.DmpUser;
import eu.eudat.models.DataModel; import eu.eudat.controllers.publicapi.models.researcher.ResearcherPublicModel;
import eu.eudat.publicapi.models.researcher.ResearcherPublicModel;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
public class DataManagementPlanPublicListingModel implements DataModel<DmpEntity, DataManagementPlanPublicListingModel> { public class DataManagementPlanPublicListingModel {
private String id; private String id;
private String label; private String label;
private String grant; private String grant;
@ -99,7 +96,6 @@ public class DataManagementPlanPublicListingModel implements DataModel<DmpEntity
this.publishedAt = publishedAt; this.publishedAt = publishedAt;
} }
@Override
public DataManagementPlanPublicListingModel fromDataModel(DmpEntity entity) { public DataManagementPlanPublicListingModel fromDataModel(DmpEntity entity) {
this.id = entity.getId().toString(); this.id = entity.getId().toString();
this.label = entity.getLabel(); this.label = entity.getLabel();
@ -125,50 +121,18 @@ public class DataManagementPlanPublicListingModel implements DataModel<DmpEntity
public DataManagementPlanPublicListingModel fromDataModelNoDatasets(DmpEntity entity) { public DataManagementPlanPublicListingModel fromDataModelNoDatasets(DmpEntity entity) {
this.fromDataModel(entity); this.fromDataModel(entity);
// this.version = entity.getVersion(); //TODO
// if (entity.getGrant() != null) {
// 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<>();
// this.researchers = entity.getResearchers() != null ? entity.getResearchers().stream().map(x -> new ResearcherPublicModel().fromDataModel(x)).collect(Collectors.toList()) : new ArrayList<>();
// }
// catch(Exception ex){
// this.users = new ArrayList<>();
// this.researchers = new ArrayList<>();
// }
// this.finalizedAt = entity.getFinalizedAt();
// this.publishedAt = entity.getPublishedAt();
return this; return this;
} }
@Override
public DmpEntity toDataModel() { public DmpEntity toDataModel() {
DmpEntity entity = new DmpEntity(); DmpEntity entity = new DmpEntity();
entity.setId(UUID.fromString(this.getId())); entity.setId(UUID.fromString(this.getId()));
entity.setLabel(this.getLabel()); entity.setLabel(this.getLabel());
entity.setGroupId(this.getGroupId()); entity.setGroupId(this.getGroupId());
// entity.setCreated(this.getCreatedAt()); //TODO
// entity.setFinalizedAt(this.getFinalizedAt());
// entity.setModified(this.getModifiedAt());
// entity.setPublishedAt(this.getPublishedAt());
// entity.setVersion(this.getVersion());
//
// if (this.getGrant() != null) {
// Grant grant = new Grant();
// grant.setLabel(this.getGrant());
// entity.setGrant(grant);
// }
// entity.setUsers(this.getUsers().stream().map(UserInfoPublicModel::toDataModel).collect(Collectors.toSet()));
// entity.setResearchers(this.getResearchers().stream().map(ResearcherPublicModel::toDataModel).collect(Collectors.toSet()));
return entity; return entity;
} }
@Override public static String getHint() {
public String getHint() {
return "fullyDetailed"; return "fullyDetailed";
} }
} }

View File

@ -0,0 +1,129 @@
package eu.eudat.controllers.publicapi.models.listingmodels;
import eu.eudat.data.DescriptionEntity;
import eu.eudat.model.DmpUser;
import eu.eudat.controllers.publicapi.models.datasetprofile.DatasetProfilePublicModel;
import java.util.Date;
import java.util.List;
public class 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<DmpUser> 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<DmpUser> getUsers() {
return users;
}
public void setUsers(List<DmpUser> users) {
this.users = users;
}
public DatasetPublicListingModel fromDataModel(DescriptionEntity entity) {
return this;
}
public DescriptionEntity toDataModel() {
DescriptionEntity entity = new DescriptionEntity();
return entity;
}
public static String getHint() {
return "datasetListingModel";
}
}

View File

@ -1,4 +1,4 @@
package eu.eudat.publicapi.models.organisation; package eu.eudat.controllers.publicapi.models.organisation;
import eu.eudat.data.old.Organisation; import eu.eudat.data.old.Organisation;
import eu.eudat.logic.utilities.helpers.LabelGenerator; import eu.eudat.logic.utilities.helpers.LabelGenerator;

View File

@ -1,10 +1,10 @@
package eu.eudat.publicapi.models.overviewmodels; package eu.eudat.controllers.publicapi.models.overviewmodels;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity; import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
import eu.eudat.controllers.publicapi.models.doi.DoiPublicModel;
import eu.eudat.controllers.publicapi.models.grant.GrantPublicOverviewModel;
import eu.eudat.controllers.publicapi.models.organisation.OrganizationPublicModel;
import eu.eudat.controllers.publicapi.models.researcher.ResearcherPublicModel;
import eu.eudat.data.DescriptionEntity; import eu.eudat.data.DescriptionEntity;
import eu.eudat.data.DescriptionTemplateEntity; import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.commons.types.xml.XmlBuilder; import eu.eudat.commons.types.xml.XmlBuilder;
@ -12,16 +12,11 @@ import eu.eudat.data.DmpEntity;
import eu.eudat.model.DmpUser; import eu.eudat.model.DmpUser;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;
import eu.eudat.models.data.user.composite.PagedDatasetProfile; import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import eu.eudat.publicapi.models.associatedprofile.AssociatedProfilePublicModel; import eu.eudat.controllers.publicapi.models.associatedprofile.AssociatedProfilePublicModel;
import eu.eudat.publicapi.models.doi.DoiPublicModel;
import eu.eudat.publicapi.models.grant.GrantPublicOverviewModel;
import eu.eudat.publicapi.models.organisation.OrganizationPublicModel;
import eu.eudat.publicapi.models.researcher.ResearcherPublicModel;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
public class DataManagementPlanPublicModel implements DataModel<DmpEntity, DataManagementPlanPublicModel> { public class DataManagementPlanPublicModel implements DataModel<DmpEntity, DataManagementPlanPublicModel> {
private String id; private String id;

View File

@ -1,15 +1,15 @@
package eu.eudat.publicapi.models.overviewmodels; package eu.eudat.controllers.publicapi.models.overviewmodels;
import eu.eudat.commons.enums.DescriptionStatus; import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.controllers.publicapi.models.datasetprofile.DatasetProfilePublicModel;
import eu.eudat.controllers.publicapi.models.datasetwizard.DataRepositoryPublicModel;
import eu.eudat.controllers.publicapi.models.datasetwizard.ExternalDatasetPublicListingModel;
import eu.eudat.controllers.publicapi.models.datasetwizard.RegistryPublicModel;
import eu.eudat.controllers.publicapi.models.datasetwizard.ServicePublicModel;
import eu.eudat.controllers.publicapi.models.listingmodels.DataManagementPlanPublicListingModel;
import eu.eudat.data.DescriptionEntity; import eu.eudat.data.DescriptionEntity;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;
import eu.eudat.models.data.user.composite.PagedDatasetProfile; 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 java.util.*; import java.util.*;

View File

@ -1,4 +1,4 @@
package eu.eudat.publicapi.models.researcher; package eu.eudat.controllers.publicapi.models.researcher;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import eu.eudat.data.old.Researcher; import eu.eudat.data.old.Researcher;

View File

@ -1,10 +1,10 @@
package eu.eudat.publicapi.request.dataset; package eu.eudat.controllers.publicapi.request.dataset;
import eu.eudat.commons.enums.DescriptionStatus; import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.controllers.publicapi.criteria.dataset.DatasetPublicCriteria;
import eu.eudat.data.DescriptionEntity; import eu.eudat.data.DescriptionEntity;
import eu.eudat.data.query.definition.TableQuery; import eu.eudat.data.query.definition.TableQuery;
import eu.eudat.publicapi.criteria.dataset.DatasetPublicCriteria;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType; import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField; import eu.eudat.queryable.types.SelectionField;

View File

@ -1,10 +1,10 @@
package eu.eudat.publicapi.request.dmp; package eu.eudat.controllers.publicapi.request.dmp;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.controllers.publicapi.criteria.dmp.DataManagementPlanPublicCriteria;
import eu.eudat.data.DmpEntity; import eu.eudat.data.DmpEntity;
import eu.eudat.data.query.PaginationService; import eu.eudat.data.query.PaginationService;
import eu.eudat.data.query.definition.TableQuery; import eu.eudat.data.query.definition.TableQuery;
import eu.eudat.publicapi.criteria.dmp.DataManagementPlanPublicCriteria;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType; import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField; import eu.eudat.queryable.types.SelectionField;

View File

@ -0,0 +1,24 @@
package eu.eudat.controllers.publicapi.response;
import java.util.List;
public class DataTableData<T> {
private Long totalCount;
private List<T> data;
public Long getTotalCount() {
return totalCount;
}
public void setTotalCount(Long totalCount) {
this.totalCount = totalCount;
}
public List<T> getData() {
return data;
}
public void setData(List<T> data) {
this.data = data;
}
}

View File

@ -1,32 +0,0 @@
package eu.eudat.publicapi.configurations;
//import io.swagger.v3.oas.models.OpenAPI;
//import io.swagger.v3.oas.models.info.Contact;
//import io.swagger.v3.oas.models.info.Info;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.env.Environment;
//
//@Configuration
//public class SwaggerConfiguration {
//
// // private static final TypeResolver resolver = new TypeResolver();
//
// @Autowired
// private Environment environment;
//
// @Bean
// public OpenAPI ArgosOpenApi() {
// return new OpenAPI().info(apiInfo());
// }
//
// private Info apiInfo() {
// return new Info()
// .title("OpenDMP public API")
// .description("Argos public API.")
// .version("1.0")
// .termsOfService("https://argos.openaire.eu/terms-and-conditions")
// .contact(new Contact().name("Argos").url("https://argos.openaire.eu/").email("argos@openaire.eu "));
// }
//}

View File

@ -1,266 +0,0 @@
package eu.eudat.publicapi.controllers;
import eu.eudat.controllers.BaseController;
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.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 io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
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;
@Tag(name = "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" +
"<ol>" +
" <li><b>message</b>: string, message indicating error, null if everything went well</li>" +
" <li><b>statusCode</b>: integer, status code indicating if something unexpected happened, otherwise 0</li>" +
" <li><b>responseType</b>: integer, 0 for json, 1 for file</li>" +
" <li><b>payload</b>: DataTableData, containing the number of values of actual data returned and the data of type <b>DatasetPublicListingModel</b></li>" +
" <ol>" +
" <li>id: string, id of dataset returned</li>" +
" <li>label: string, label of dataset</li>" +
" <li>grant: string, grant of dataset</li>" +
" <li>dmp: string, dmp description</li>" +
" <li>dmpId: string, dmp's id</li>" +
" <li>profile: DatasetProfilePublicModel, dataset's profile</li>" +
" <li>createdAt: date, creation date</li>" +
" <li>modifiedAt: date, modification date</li>" +
" <li>description: string, dataset's description</li>" +
" <li>finalizedAt: date, finalization date</li>" +
" <li>dmpPublishedAt: date, dmp's publication date</li>" +
" <li>version: integer, dataset's version</li>" +
" <li>users: list of UserInfoPublicModel, user who collaborated on the dataset</li>" +
" </ol>" +
"</ol>";
public static final String getPagedResponseExample = "{\n" +
" \"statusCode\": 0,\n" +
" \"responseType\": 0,\n" +
" \"message\": null,\n" +
" \"payload\": {\n" +
" \"totalCount\": 2,\n" +
" \"data\": [\n" +
" {\n" +
" \"id\": \"ef7dfbdc-c5c1-46a7-a37b-c8d8692f1c0e\",\n" +
" \"label\": \"BARKAMOL RIVOJLANGAN SHAXSNI TARBIYALASHDA HARAKATLI O`YINLARNING O`RNI\",\n" +
" \"grant\": \"A next generation nano media tailored to capture and recycle hazardous micropollutants in contaminated industrial wastewater.\",\n" +
" \"dmp\": \"test for demo\",\n" +
" \"dmpId\": \"9dee6e72-7a4c-4fbd-b8a4-1f8cda38eb5e\",\n" +
" \"profile\": {\n" +
" \"id\": \"771283d7-a5be-4a93-bd3c-8b1883fe837c\",\n" +
" \"label\": \"Horizon Europe\",\n" +
" \"hint\": null\n" +
" },\n" +
" \"createdAt\": 1662711279000,\n" +
" \"modifiedAt\": 1662712928000,\n" +
" \"description\": \"<p>&nbsp; &nbsp; &nbsp;Annotatsiya &nbsp;Maqolada &nbsp;bolalarni &nbsp;o`yin &nbsp;mavjud &nbsp;bo`lgan &nbsp;shakllarda &nbsp;mavjud&nbsp;<br>\\nhayot &nbsp;bilan &nbsp;kengroq &nbsp;tanishtirishga &nbsp;imkon &nbsp;beradi. &nbsp;O`yin &nbsp;bolalarning &nbsp;turli &nbsp;xil&nbsp;<br>\\nfaoliyati,o`yin &nbsp;ko`nikmalarini &nbsp;shakllantirishga &nbsp;yordam &nbsp;beradi.Ularni &nbsp;fikrlash, &nbsp;his-<br>\\ntuyg`ular, tajribalar, o`yin muammosini hal qilishning faol usullarini izlash, ularning&nbsp;<br>\\no`yin sharoitlari va sharoitlariga bo`ysunishi, o`yindagi bolalarning munosabatlari,&nbsp;<br>\\no`yin orqali bola organik rivojlanadi, &nbsp;inson madaniyatining muhim qatlami kattalar&nbsp;<br>\\no`rtasidagi &nbsp;munosabatlar &nbsp;- &nbsp;oilada, &nbsp;ularning &nbsp;kasbiy &nbsp;faoliyati &nbsp;va &nbsp;boshqalar. &nbsp;O`yin&nbsp;<br>\\no`qituvchilar barcha ta&rsquo;lim vazifalarini, shu jumladan o`rganishni hal qiladigan eng&nbsp;<br>\\nmuhim faoliyat sifatida foydalaniladi.&nbsp;</p>\",\n" +
" \"finalizedAt\": 1662712928000,\n" +
" \"dmpPublishedAt\": 1662713226000,\n" +
" \"version\": 0,\n" +
" \"users\": [\n" +
" {\n" +
" \"id\": \"33024e48-d528-45a5-8035-ea48641bd2f2\",\n" +
" \"name\": \"DMP author\",\n" +
" \"role\": 0,\n" +
" \"email\": \"kanavou.p@gmail.com\",\n" +
" \"hint\": \"UserInfoListingModel\"\n" +
" }\n" +
" ],\n" +
" \"hint\": \"datasetListingModel\"\n" +
" },\n" +
" {\n" +
" \"id\": \"0f253ab2-18cb-4798-adc1-135b81cfad0c\",\n" +
" \"label\": \"A \\\"zoom-elit\\\" és a kamionosok küzdelme, avagy a meritokrácia és a populizmus összecsapása\",\n" +
" \"grant\": \"Discovery Projects - Grant ID: DP140100157\",\n" +
" \"dmp\": \"TEST UPDATE 2.8.2022\",\n" +
" \"dmpId\": \"1f4daa8f-4e2f-4dc9-a60b-f6b75d313400\",\n" +
" \"profile\": {\n" +
" \"id\": \"3d43ba45-25fa-4815-81b4-9bf22ecd8316\",\n" +
" \"label\": \"HE_Final\",\n" +
" \"hint\": null\n" +
" },\n" +
" \"createdAt\": 1659392761000,\n" +
" \"modifiedAt\": 1659393655000,\n" +
" \"description\": \"<p>A kanadai kamionosok &bdquo;szabads&aacute;gmenete&rdquo; kapcs&aacute;n a&nbsp;New York Times&nbsp;has&aacute;bjain Ross Donthat publicista egy r&eacute;gi k&ouml;nyvre h&iacute;vja fel a figyelmet, amely sok &eacute;vtizeddel ezelőtt megj&oacute;solta az elit elleni hasonl&oacute; l&aacute;zad&aacute;sokat.</p>\",\n" +
" \"finalizedAt\": 1659393654000,\n" +
" \"dmpPublishedAt\": 1659393698000,\n" +
" \"version\": 0,\n" +
" \"users\": [\n" +
" {\n" +
" \"id\": \"33024e48-d528-45a5-8035-ea48641bd2f2\",\n" +
" \"name\": \"DMP author\",\n" +
" \"role\": 0,\n" +
" \"email\": \"kanavou.p@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" +
"<ul>" +
"<li><b>length</b>: how many datasets should be fetched <i>(required)</i></li>" +
"<li><b>offset</b>: offset of the returned datasets, first time should be 0, then offset += length</li>" +
"<li><b>orderings</b>: array of strings specifying the order, format:= +string or -string or asc or desc.</li>" +
"<b>+</b> means ascending order. <b>-</b> means descending order.<br>&nbsp;&nbsp;&nbsp;&nbsp;Available strings are: 1) status, 2) label, 3) created.<br>" +
"&nbsp;&nbsp;&nbsp;&nbsp;<b>asc</b> equivalent to +label.<br>&nbsp;&nbsp;&nbsp;&nbsp;<b>desc</b> equivalent to -label.<br>" +
"<li><b>criteria</b>: this is DatasetPublicCriteria object which applies filters for the datasets returned. More specifically:</li>" +
" <ol>" +
" <li>periodStart: date, datasets created date greater than periodStart</li>" +
" <li>periodEnd: date, datasets created date less than periodEnd</li>" +
" <li>grants: list of uuids, dmps(datasets) with the corresponding grants</li>" +
" <li>collaborators: list of uuids, user who collaborated on the creation/modification of datasets</li>" +
" <li>datasetTemplates: list of uuids, dataset templates uuids to be included</li>" +
" <li>dmpOrganisations: list of strings, datasets involved in dmps which belong to these organisations</li>" +
" <li>tags: list of Tag objects, tags involved in datasets</li>" +
" <li>dmpIds: list of uuids, dmps with the specific ids</li>" +
" <li>groupIds: list of uuids, in which groups the datasets are</li>" +
" <li>allVersions: boolean, if datasets should be fetched with all their versions</li>" +
" <li>like: string, datasets fetched have this string matched in their label or description</li>" +
" </ol>" +
"</ul>";
public static final String getOverviewSinglePublicNotes = "The json response is of type **ResponseItem< DatasetPublicModel >** containing the following properties:\n" +
"<ol>" +
" <li><b>message</b>: string, message indicating error, null if everything went well</li>" +
" <li><b>statusCode</b>: integer, status code indicating if something unexpected happened, otherwise 0</li>" +
" <li><b>responseType</b>: integer, 0 for json, 1 for file</li>" +
" <li><b>payload</b>: DatasetPublicModel, dmp returned</li>" +
" <ol>" +
" <li>id: uuid, id of dataset returned</li>" +
" <li>label: string, label of dataset</li>" +
" <li>reference: string, reference of dataset</li>" +
" <li>uri: string, uri of dataset</li>" +
" <li>description: string, dataset's description</li>" +
" <li>status: string, dataset's status</li>" +
" <li>createdAt: date, creation time of dataset</li>" +
" <li>dmp: DataManagementPlanPublicListingModel, dmp to which dataset belongs</li>" +
" <li>datasetProfileDefinition: PagedDatasetProfile, dataset's paged description</li>" +
" <li>registries: list of RegistryPublicModel, dataset's registries</li>" +
" <li>services: list of ServicePublicModel, dataset's services</li>" +
" <li>dataRepositories: list of DataRepositoryPublicModel, dataset's data repositories</li>" +
" <li>tags: list of Tag, dataset's tags</li>" +
" <li>externalDatasets: list of ExternalDatasetPublicListingModel, dataset's external datasets</li>" +
" <li>profile: DatasetProfilePublicModel, dataset's profile</li>" +
" <li>modifiedAt: date, modification time of dataset</li>" +
" </ol>" +
"</ol>";
public static final String getOverviewSinglePublicResponseExample = "{\n" +
" \"statusCode\": 0,\n" +
" \"responseType\": 0,\n" +
" \"message\": null,\n" +
" \"payload\": {\n" +
" \"id\": \"ef7dfbdc-c5c1-46a7-a37b-c8d8692f1c0e\",\n" +
" \"label\": \"BARKAMOL RIVOJLANGAN SHAXSNI TARBIYALASHDA HARAKATLI O`YINLARNING O`RNI\",\n" +
" \"reference\": null,\n" +
" \"uri\": null,\n" +
" \"description\": \"<p>&nbsp; &nbsp; &nbsp;Annotatsiya &nbsp;Maqolada &nbsp;bolalarni &nbsp;o`yin &nbsp;mavjud &nbsp;bo`lgan &nbsp;shakllarda &nbsp;mavjud&nbsp;<br>\\nhayot &nbsp;bilan &nbsp;kengroq &nbsp;tanishtirishga &nbsp;imkon &nbsp;beradi. &nbsp;O`yin &nbsp;bolalarning &nbsp;turli &nbsp;xil&nbsp;<br>\\nfaoliyati,o`yin &nbsp;ko`nikmalarini &nbsp;shakllantirishga &nbsp;yordam &nbsp;beradi.Ularni &nbsp;fikrlash, &nbsp;his-<br>\\ntuyg`ular, tajribalar, o`yin muammosini hal qilishning faol usullarini izlash, ularning&nbsp;<br>\\no`yin sharoitlari va sharoitlariga bo`ysunishi, o`yindagi bolalarning munosabatlari,&nbsp;<br>\\no`yin orqali bola organik rivojlanadi, &nbsp;inson madaniyatining muhim qatlami kattalar&nbsp;<br>\\no`rtasidagi &nbsp;munosabatlar &nbsp;- &nbsp;oilada, &nbsp;ularning &nbsp;kasbiy &nbsp;faoliyati &nbsp;va &nbsp;boshqalar. &nbsp;O`yin&nbsp;<br>\\no`qituvchilar barcha ta&rsquo;lim vazifalarini, shu jumladan o`rganishni hal qiladigan eng&nbsp;<br>\\nmuhim faoliyat sifatida foydalaniladi.&nbsp;</p>\",\n" +
" \"status\": 1,\n" +
" \"createdAt\": 1662711279000,\n" +
" \"dmp\": {\n" +
" \"id\": \"9dee6e72-7a4c-4fbd-b8a4-1f8cda38eb5e\",\n" +
" \"label\": \"test for demo\",\n" +
" \"grant\": \"A next generation nano media tailored to capture and recycle hazardous micropollutants in contaminated industrial wastewater.\",\n" +
" \"createdAt\": 1662710691000,\n" +
" \"modifiedAt\": 1662713226000,\n" +
" \"version\": 0,\n" +
" \"groupId\": \"adaa4e17-7375-45b8-b052-09edaeb6da86\",\n" +
" \"users\": [\n" +
" {\n" +
" \"id\": \"33024e48-d528-45a5-8035-ea48641bd2f2\",\n" +
" \"name\": \"DMP author\",\n" +
" \"role\": 0,\n" +
" \"email\": \"kanavou.p@gmail.com\",\n" +
" \"hint\": \"UserInfoListingModel\"\n" +
" }\n" +
" ],\n" +
" \"finalizedAt\": 1662713226000,\n" +
" \"publishedAt\": 1662713226000,\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\": \"771283d7-a5be-4a93-bd3c-8b1883fe837c\",\n" +
" \"label\": \"Horizon Europe\",\n" +
" \"hint\": null\n" +
" },\n" +
" \"modifiedAt\": 1662712928000,\n" +
" \"hint\": \"datasetOverviewModel\"\n" +
" }\n" +
"}";
@Autowired
public PublicDatasetsDescriptionDocumentation(ApiContext apiContext, DatasetPublicManager datasetManager) {
super(apiContext);
this.datasetManager = datasetManager;
}
@Operation(summary = "This method is used to get a listing of public datasets.", description = getPagedNotes)
@io.swagger.v3.oas.annotations.responses.ApiResponses(value = {@io.swagger.v3.oas.annotations.responses.ApiResponse(
responseCode = "200",
description = "The following example is generated using body: *{\"criteria\": {},\"length\": 2,\"offset\": 0,\"orderings\": {\"fields\": []} }*",
content = @Content(mediaType = APPLICATION_JSON_VALUE, examples = {@ExampleObject(
value = getPagedResponseExample
)})
)})
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DatasetPublicListingModel>>> getPaged(@Valid @RequestBody @io.swagger.v3.oas.annotations.parameters.RequestBody(description = 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));
}
@Operation(summary = "This method is used to get the overview of a public dataset.", description = getOverviewSinglePublicNotes)
@io.swagger.v3.oas.annotations.responses.ApiResponses(value = {@ApiResponse(
responseCode = "200",
description = "The following example is generated using id: *ef7dfbdc-c5c1-46a7-a37b-c8d8692f1c0e*",
content = @Content(mediaType = APPLICATION_JSON_VALUE, examples = {@ExampleObject(
value = getOverviewSinglePublicResponseExample
)})
)})
@RequestMapping(method = RequestMethod.GET, value = {"/{id}"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DatasetPublicModel>> getOverviewSinglePublic(@PathVariable @Parameter(description = "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()));
// }
}
}

View File

@ -1,300 +0,0 @@
package eu.eudat.publicapi.controllers;
import eu.eudat.controllers.BaseController;
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.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 io.swagger.annotations.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
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;
@Tag(name = "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" +
"<ol>" +
" <li><b>message</b>: string, message indicating error, null if everything went well</li>" +
" <li><b>statusCode</b>: integer, status code indicating if something unexpected happened, otherwise 0</li>" +
" <li><b>responseType</b>: integer, 0 for json, 1 for file</li>" +
" <li><b>payload</b>: DataTableData, containing the number of values of actual data returned and the data of type <b>DataManagementPlanPublicListingModel</b></li>" +
" <ol>" +
" <li>id: string, id of dmp returned</li>" +
" <li>label: string, label of dmp</li>" +
" <li>grant: string, grant of dmp</li>" +
" <li>createdAt: date, creation time of dmp</li>" +
" <li>modifiedAt: date, modification time of dmp</li>" +
" <li>version: integer, version of dmp</li>" +
" <li>groupId: uuid, group id in which dmp belongs</li>" +
" <li>users: list of UserInfoPublicModel, user who collaborated on the dmp</li>" +
" <li>researchers: list of ResearcherPublicModel, researchers involved in the dmp</li>" +
" <li>finalizedAt: date, finalization date</li>" +
" <li>publishedAt: date, publication date</li>" +
" </ol>" +
"</ol>";
private static final String getPagedResponseExample = "{\n" +
" \"statusCode\": 0,\n" +
" \"responseType\": 0,\n" +
" \"message\": null,\n" +
" \"payload\": {\n" +
" \"totalCount\": 2,\n" +
" \"data\": [\n" +
" {\n" +
" \"id\": \"e9a73d77-adfa-4546-974f-4a4a623b53a8\",\n" +
" \"label\": \"Giorgos's DMP\",\n" +
" \"grant\": \"Novel EOSC services for Emerging Atmosphere, Underwater and Space Challenges\",\n" +
" \"createdAt\": 1579077317000,\n" +
" \"modifiedAt\": 1586444334000,\n" +
" \"version\": 0,\n" +
" \"groupId\": \"d949592d-f862-4b31-a43a-f5f70596df5e\",\n" +
" \"users\": [],\n" +
" \"finalizedAt\": 1586444334000,\n" +
" \"publishedAt\": 1586444334000,\n" +
" \"hint\": \"dataManagementPlanListingModel\"\n" +
" },\n" +
" {\n" +
" \"id\": \"e27789f1-de35-4b4a-9587-a46d131c366e\",\n" +
" \"label\": \"TestH2020Clone3\",\n" +
" \"grant\": \"Evaluation of the Benefits of innovative Concepts of laminar nacelle and HTP installed on a business jet configuration\",\n" +
" \"createdAt\": 1600774437000,\n" +
" \"modifiedAt\": 1600879107000,\n" +
" \"version\": 0,\n" +
" \"groupId\": \"7b793c17-cb69-41d2-a97d-e8d1b03ddbed\",\n" +
" \"users\": [],\n" +
" \"finalizedAt\": 1600879107000,\n" +
" \"publishedAt\": 1600879107000,\n" +
" \"hint\": \"dataManagementPlanListingModel\"\n" +
" }\n" +
" ]\n" +
" }\n" +
"}";
private static final String getPagedRequestBodyDescription = "The dmpTableRequest is a DataManagementPlanPublicTableRequest object with the following fields:\n" +
"<ul>" +
" <li><b>length</b>: how many dmps should be fetched <i>(required)</i></li>" +
" <li><b>offset</b>: offset of the returned dmps, first time should be 0, then offset += length</li>" +
" <li><b>orderings</b>: array of strings specifying the order, format:= +string or -string or asc or desc.</li>" +
"<b>+</b> means ascending order. <b>-</b> means descending order.<br>&nbsp;&nbsp;&nbsp;&nbsp;Available strings are: 1) status, 2) label, 3) publishedAt, 4) created.<br>" +
"&nbsp;&nbsp;&nbsp;&nbsp;<b>asc</b> equivalent to +label.<br>&nbsp;&nbsp;&nbsp;&nbsp;<b>desc</b> equivalent to -label.<br>" +
"<li><b>criteria</b>: this is DataManagementPlanPublicCriteria object which applies filters for the dmp returned. More specifically:</li>" +
" <ol>" +
" <li>periodStart: date, dmps created date greater than periodStart</li>" +
" <li>periodEnd: date, dmps created date less than periodEnd</li>" +
" <li>grants: list of uuids, dmps with the corresponding grants</li>" +
" <li>grantsLike: list of strings, dmps fetched having their grant matching any of the strings provided</li>" +
" <li>funders: list of uuids, dmps with the corresponding funders</li>" +
" <li>fundersLike: list of strings, dmps fetched having their funders matching any of the strings provided</li>" +
" <li>datasetTemplates: list of uuids, dataset templates which are described in the dmps</li>" +
" <li>dmpOrganisations: list of strings, dmps belonging to these organisations</li>" +
" <li>collaborators: list of uuids, user who collaborated on the creation/modification of dmps</li>" +
" <li>collaboratorsLike: list of strings, dmps fetched having their collaborators matching any of the strings provided</li>" +
" <li>allVersions: boolean, if dmps should be fetched with all their versions</li>" +
" <li>groupIds: list of uuids, in which groups the dmps are</li>" +
" <li>like: string, dmps fetched have this string matched in their label or description</li>" +
" </ol>" +
"<ul>";
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" +
"<ul>" +
" <li><b>listing</b>: returns objects with all their properties completed</li>" +
" <li><b>autocomplete</b>: returns objects with only id, label, groupId and creationTime assigned</li>" +
"<ul>";
private static final String getOverviewSinglePublicNotes = "The json response is of type **ResponseItem< DataManagementPlanPublicModel >** containing the following properties:\n" +
"<ol>" +
" <li><b>message</b>: string, message indicating error, null if everything went well</li>" +
" <li><b>statusCode</b>: integer, status code indicating if something unexpected happened, otherwise 0</li>" +
" <li><b>responseType</b>: integer, 0 for json, 1 for file</li>" +
" <li><b>payload</b>: DataManagementPlanPublicModel, dmp returned</li>" +
" <ol>" +
" <li>id: string, id of dmp returned</li>" +
" <li>label: string, label of dmp</li>" +
" <li>profile: string, profile of dmp</li>" +
" <li>grant: GrantPublicOverviewModel, grant of dmp</li>" +
" <li>createdAt: date, creation time of dmp</li>" +
" <li>modifiedAt: date, modification time of dmp</li>" +
" <li>finalizedAt: date, finalization date of dmp</li>" +
" <li>organisations: list of OrganizationPublicModel, organizations in which dmp belongs</li>" +
" <li>version: integer, version of dmp</li>" +
" <li>groupId: uuid, group id in which dmp belongs</li>" +
" <li>datasets: list of DatasetPublicModel, contained datasets</li>" +
" <li>associatedProfiles: list of AssociatedProfilePublicModel, associated profiles of dmp</li>" +
" <li>researchers: list of ResearcherPublicModel, researchers involved in dmp</li>" +
" <li>users: list of UserInfoPublicModel, user who collaborated on the dmp</li>" +
" <li>description: string, description of dmp</li>" +
" <li>publishedAt: date, publication date</li>" +
" <li>doi: string, if dmp has been published to zenodo so it has doi</li>" +
" </ol>" +
"</ol>";
private static final String getOverviewSinglePublicResponseExample = "{\n" +
" \"statusCode\": 0,\n" +
" \"responseType\": 0,\n" +
" \"message\": null,\n" +
" \"payload\": {\n" +
" \"id\": \"e9a73d77-adfa-4546-974f-4a4a623b53a8\",\n" +
" \"label\": \"Giorgos's DMP\",\n" +
" \"profile\": null,\n" +
" \"grant\": {\n" +
" \"id\": \"c8309ae5-4e56-43eb-aa5a-9950c24051fe\",\n" +
" \"label\": \"Novel EOSC services for Emerging Atmosphere, Underwater and Space Challenges\",\n" +
" \"abbreviation\": null,\n" +
" \"description\": null,\n" +
" \"startDate\": null,\n" +
" \"endDate\": null,\n" +
" \"uri\": null,\n" +
" \"funder\": {\n" +
" \"id\": \"25e76828-3539-4c66-9870-0ecea7a4d16e\",\n" +
" \"label\": \"European Commission||EC\",\n" +
" \"hint\": null\n" +
" },\n" +
" \"hint\": null\n" +
" },\n" +
" \"createdAt\": 1579077317000,\n" +
" \"modifiedAt\": 1586444334000,\n" +
" \"finalizedAt\": 1586444334000,\n" +
" \"organisations\": [],\n" +
" \"version\": 0,\n" +
" \"groupId\": \"d949592d-f862-4b31-a43a-f5f70596df5e\",\n" +
" \"datasets\": [\n" +
" {\n" +
" \"id\": \"853a24c3-def4-4978-985f-92e7fa57ef22\",\n" +
" \"label\": \"Giorgos's Dataset Desc\",\n" +
" \"reference\": null,\n" +
" \"uri\": null,\n" +
" \"description\": null,\n" +
" \"status\": 1,\n" +
" \"createdAt\": 1579077532000,\n" +
" \"dmp\": {\n" +
" \"id\": \"e9a73d77-adfa-4546-974f-4a4a623b53a8\",\n" +
" \"label\": \"Giorgos's DMP\",\n" +
" \"grant\": \"Novel EOSC services for Emerging Atmosphere, Underwater and Space Challenges\",\n" +
" \"createdAt\": 1579077317000,\n" +
" \"modifiedAt\": 1586444334000,\n" +
" \"version\": 0,\n" +
" \"groupId\": \"d949592d-f862-4b31-a43a-f5f70596df5e\",\n" +
" \"users\": [\n" +
" {\n" +
" \"id\": \"00476b4d-0491-44ca-b2fd-92e695062a48\",\n" +
" \"name\": \"OpenDMP OpenDMP\",\n" +
" \"role\": 0,\n" +
" \"email\": \"opendmpeu@gmail.com\",\n" +
" \"hint\": \"UserInfoListingModel\"\n" +
" }\n" +
" ],\n" +
" \"finalizedAt\": 1586444334000,\n" +
" \"publishedAt\": 1586444334000,\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\": \"2a6e0835-349e-412c-9fcc-8e1298ce8a5a\",\n" +
" \"label\": \"Horizon 2020\",\n" +
" \"hint\": null\n" +
" },\n" +
" \"modifiedAt\": 1579077898000,\n" +
" \"hint\": \"datasetOverviewModel\"\n" +
" }\n" +
" ],\n" +
" \"associatedProfiles\": [\n" +
" {\n" +
" \"id\": \"f41bd794-761d-4fe8-ab67-3a989d982c53\",\n" +
" \"label\": \"Swedish Research Council\"\n" +
" },\n" +
" {\n" +
" \"id\": \"2a6e0835-349e-412c-9fcc-8e1298ce8a5a\",\n" +
" \"label\": \"Horizon 2020\"\n" +
" }\n" +
" ],\n" +
" \"researchers\": [],\n" +
" \"users\": [\n" +
" {\n" +
" \"id\": \"00476b4d-0491-44ca-b2fd-92e695062a48\",\n" +
" \"name\": \"OpenDMP OpenDMP\",\n" +
" \"role\": 0,\n" +
" \"email\": \"opendmpeu@gmail.com\",\n" +
" \"hint\": \"UserInfoListingModel\"\n" +
" }\n" +
" ],\n" +
" \"description\": null,\n" +
" \"publishedAt\": 1586444334000,\n" +
" \"doi\": \"10.5072/zenodo.522151\",\n" +
" \"hint\": \"dataManagementPlanOverviewModel\"\n" +
" }\n" +
"}";
@Autowired
public PublicDmpsDocumentation(ApiContext apiContext, DataManagementPlanPublicManager dataManagementPlanManager) {
super(apiContext);
this.dataManagementPlanManager = dataManagementPlanManager;
}
@Operation(summary = "This method is used to get a listing of public dmps.", description = getPagedNotes)
@io.swagger.v3.oas.annotations.responses.ApiResponses(value = {@ApiResponse(
responseCode = "200",
description = "The following example is generated using:\n" +
"a) body: *{\"criteria\": {},\"length\": 2,\"offset\": 0,\"orderings\": {\"fields\": []} }*\n" +
"b) fieldsGroup: listing",
content = @Content(mediaType = APPLICATION_JSON_VALUE, examples = {@ExampleObject(
value = getPagedResponseExample
)})
)})
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanPublicListingModel>>> getPaged(@Valid @RequestBody @io.swagger.v3.oas.annotations.parameters.RequestBody(description = getPagedRequestBodyDescription) DataManagmentPlanPublicTableRequest dmpTableRequest,
@RequestParam @Parameter(description = 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));
}
@Operation(summary = "This method is used to get the overview of a public dmp.", description = getOverviewSinglePublicNotes)
@io.swagger.v3.oas.annotations.responses.ApiResponses(value = {@ApiResponse(
responseCode = "200",
description = "The following example is generated using id: *e9a73d77-adfa-4546-974f-4a4a623b53a8*",
content = @Content(mediaType = APPLICATION_JSON_VALUE, examples = {@ExampleObject(
value = getOverviewSinglePublicResponseExample
)})
)})
@RequestMapping(method = RequestMethod.GET, value = {"/{id}"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataManagementPlanPublicModel>> getOverviewSinglePublic(@PathVariable @Parameter(description = "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()));
// }
}
}

View File

@ -1,176 +0,0 @@
package eu.eudat.publicapi.managers;
import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
import eu.eudat.data.DescriptionEntity;
import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.data.query.definition.helpers.ColumnOrderings;
import eu.eudat.logic.managers.PaginationManager;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.commons.types.xml.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.models.listingmodels.DatasetPublicListingModel;
import eu.eudat.publicapi.models.overviewmodels.DatasetPublicModel;
import eu.eudat.queryable.QueryableList;
import eu.eudat.types.grant.GrantStateType;
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 jakarta.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(DescriptionStatus.Finalized.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<DescriptionEntity> 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<DescriptionEntity> 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()));
dataTable.setTotalCount(count);
return dataTable;
}
public DatasetPublicModel getOverviewSinglePublic(String id) throws Exception {
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id));
if (descriptionEntityEntity.getIsActive() == IsActive.Inactive) {
throw new Exception("Dataset is deleted.");
}
//TODO
// if (!descriptionEntityEntity.getDmp().isPublic()) {
// throw new ForbiddenException("Selected Dataset is not public");
// }
DatasetPublicModel dataset = new DatasetPublicModel();
dataset.setDatasetProfileDefinition(this.getPagedProfile(dataset.getStatus(), descriptionEntityEntity));
dataset.fromDataModel(descriptionEntityEntity);
return dataset;
}
@Transactional
private DatasetPublicListingModel mapPublicModel(DescriptionEntity 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<DescriptionTemplate> profiles = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).toList();
boolean islast = false;
if (!profiles.isEmpty()) {
profiles = profiles.stream().sorted(Comparator.comparing(DescriptionTemplate::getVersion)).collect(Collectors.toList());
islast = profiles.get(0).getId().equals(item.getProfile().getId());
}
listingModel.setProfileLatestVersion(islast);*/
return listingPublicModel;
}
private PagedDatasetProfile getPagedProfile(DescriptionStatus status, DescriptionEntity descriptionEntityEntity){
//TODO
// eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = this.generateDatasetProfileModel(descriptionEntityEntity.getProfile());
// datasetprofile.setStatus(status.getValue());
// if (descriptionEntityEntity.getProperties() != null) {
// JSONObject jObject = new JSONObject(descriptionEntityEntity.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(DescriptionTemplateEntity profile) {
Document viewStyleDoc = XmlBuilder.fromXml(profile.getDefinition());
Element root = (Element) viewStyleDoc.getDocumentElement();
DefinitionEntity viewstyle = new DefinitionEntity().fromXml(root);
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = new eu.eudat.models.data.user.composite.DatasetProfile();
datasetprofile.buildProfile(viewstyle);
return datasetprofile;
}
}

View File

@ -1,175 +0,0 @@
package eu.eudat.publicapi.models.listingmodels;
import eu.eudat.data.DescriptionEntity;
import eu.eudat.model.DmpUser;
import eu.eudat.models.DataModel;
import eu.eudat.publicapi.models.datasetprofile.DatasetProfilePublicModel;
import java.util.Date;
import java.util.List;
public class DatasetPublicListingModel implements DataModel<DescriptionEntity, 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<DmpUser> 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<DmpUser> getUsers() {
return users;
}
public void setUsers(List<DmpUser> users) {
this.users = users;
}
@Override
public DatasetPublicListingModel fromDataModel(DescriptionEntity entity) {
//TODO
// this.id = entity.getId() != null ? entity.getId().toString() : "";
// this.label = entity.getLabel();
// this.createdAt = entity.getCreated();
// this.modifiedAt = entity.getModified();
// if(entity.getDmp() != null && entity.getDmp().getGrant() != null) {
// this.grant = 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() == DescriptionEntity.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 DescriptionEntity toDataModel() {
//TODO
DescriptionEntity entity = new DescriptionEntity();
// 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(DescriptionEntity.Status.FINALISED.getValue());
// DMP dmp = new DMP();
// if (this.getGrant() != null && !this.getGrant().isEmpty()) {
// 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";
}
}