Remove even more deprecated stuff (Explore criteria and old rda Models)

This commit is contained in:
George Kalampokis 2020-06-19 16:41:25 +03:00
parent c93f8eda52
commit d5374d41b4
33 changed files with 88 additions and 1460 deletions

View File

@ -1,56 +0,0 @@
package eu.eudat.data.query.items.table.dataset;
import eu.eudat.data.dao.criteria.DatasetPublicCriteria;
import eu.eudat.data.entities.Dataset;
import eu.eudat.data.query.definition.TableQuery;
import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField;
import eu.eudat.types.grant.GrantStateType;
import java.util.Arrays;
import java.util.Date;
import java.util.UUID;
/**
* Created by ikalyvas on 10/2/2018.
*/
public class DatasetPublicTableRequest extends TableQuery<DatasetPublicCriteria, Dataset, UUID> {
@Override
public QueryableList<Dataset> applyCriteria() {
QueryableList<Dataset> query = this.getQuery();
query.where((builder, root) -> builder.equal(root.get("dmp").get("isPublic"), true));
query.where((builder, root) -> builder.equal(root.get("status"), Dataset.Status.FINALISED.getValue()));
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"),
query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")),
Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class)));
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
query.where((builder, root) -> builder.or(
builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"),
builder.like(builder.upper(root.get("description")), "%" + this.getCriteria().getLike().toUpperCase() + "%")));
if (this.getCriteria().getGrants() != null && !this.getCriteria().getGrants().isEmpty())
query.where(((builder, root) -> root.get("dmp").get("grant").get("id").in(this.getCriteria().getGrants())));
if (this.getCriteria().getGrantStatus() != null) {
if (this.getCriteria().getGrantStatus().getValue().equals(GrantStateType.FINISHED.getValue()))
query.where((builder, root) -> builder.lessThan(root.get("dmp").get("grant").get("enddate"), new Date()));
if (this.getCriteria().getGrantStatus().getValue().equals(GrantStateType.ONGOING.getValue()))
query.where((builder, root) ->
builder.or(builder.greaterThan(root.get("dmp").get("grant").get("enddate"), new Date())
, builder.isNull(root.get("dmp").get("grant").get("enddate"))));
}
if (this.getCriteria().getDmpIds() != null && !this.getCriteria().getDmpIds().isEmpty()) {
query.where(((builder, root) -> root.get("dmp").get("id").in(this.getCriteria().getDmpIds())));
}
if (this.getCriteria().getDatasetProfile() != null && !this.getCriteria().getDatasetProfile().isEmpty()) query
.where(((builder, root) -> root.get("profile").get("id").in(this.getCriteria().getDatasetProfile())));
if (this.getCriteria().getDmpOrganisations() != null && !this.getCriteria().getDmpOrganisations().isEmpty()) query
.where(((builder, root) -> root.join("dmp").join("organisations").get("reference").in(this.getCriteria().getDmpOrganisations())));
query.where((builder, root) -> builder.notEqual(root.get("status"), Dataset.Status.DELETED.getValue()));
return query;
}
@Override
public QueryableList<Dataset> applyPaging(QueryableList<Dataset> items) {
return null;
}
}

View File

@ -1,54 +0,0 @@
package eu.eudat.data.query.items.table.dmp;
import eu.eudat.data.dao.criteria.DataManagementPlanPublicCriteria;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.query.PaginationService;
import eu.eudat.data.query.definition.TableQuery;
import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField;
import eu.eudat.types.grant.GrantStateType;
import java.util.Arrays;
import java.util.Date;
import java.util.UUID;
public class DataManagmentPlanPublicTableRequest extends TableQuery<DataManagementPlanPublicCriteria, DMP, UUID> {
public QueryableList<DMP> applyCriteria() {
QueryableList<DMP> query = this.getQuery();
query.where((builder, root) -> builder.equal(root.get("isPublic"), true));
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
query.where((builder, root) -> builder.or(
builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"),
builder.like(builder.upper(root.get("description")), "%" + this.getCriteria().getLike().toUpperCase() + "%")));
if (this.getCriteria().getGrants() != null && !this.getCriteria().getGrants().isEmpty())
query.where(((builder, root) -> root.get("grant").get("id").in(this.getCriteria().getGrants())));
if (this.getCriteria().getGrantStatus() != null) {
if (this.getCriteria().getGrantStatus().getValue().equals(GrantStateType.FINISHED.getValue()))
query.where((builder, root) -> builder.lessThan(root.get("grant").get("enddate"), new Date()));
if (this.getCriteria().getGrantStatus().getValue().equals(GrantStateType.ONGOING.getValue()))
query.where((builder, root) ->
builder.or(builder.greaterThan(root.get("grant").get("enddate"), new Date())
, builder.isNull(root.get("grant").get("enddate"))));
}
if (this.getCriteria().datasetProfile != null && !this.getCriteria().datasetProfile.isEmpty())
query.where((builder, root) -> root.join("associatedDmps").get("id").in(this.getCriteria().datasetProfile));
if (this.getCriteria().getDmpOrganisations() != null && !this.getCriteria().getDmpOrganisations().isEmpty())
query.where(((builder, root) -> root.join("organisations").get("reference").in(this.getCriteria().getDmpOrganisations())));
if (!this.getCriteria().getAllVersions()) {
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"),
query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(builder1.equal(externalRoot.get("groupId"),
nestedRoot.get("groupId")), builder1.equal(nestedRoot.get("isPublic"), true)), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class)));
}
if (this.getCriteria().getGroupIds() != null && !this.getCriteria().getGroupIds().isEmpty()) {
query.where((builder, root) -> root.get("groupId").in(this.getCriteria().getGroupIds()));
}
return query;
}
@Override
public QueryableList<DMP> applyPaging(QueryableList<DMP> items) {
return PaginationService.applyPaging(items, this);
}
}

View File

@ -9,7 +9,6 @@ import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.Dataset;
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
import eu.eudat.data.query.items.table.dmp.DataManagmentPlanPublicTableRequest;
import eu.eudat.exceptions.datamanagementplan.DMPNewVersionException;
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsDeleteException;
import eu.eudat.exceptions.security.UnauthorisedException;

View File

@ -31,7 +31,7 @@ public class DashBoardController extends BaseController {
}
@RequestMapping(method = RequestMethod.GET, value = {"/dashboard/getStatistics"}, produces = "application/json")
public ResponseEntity<ResponseItem<DashBoardStatistics>> getStatistics() {
public ResponseEntity<ResponseItem<DashBoardStatistics>> getStatistics() throws Exception {
DashBoardStatistics statistics = dashBoardManager.getStatistics();
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DashBoardStatistics>().status(ApiMessageCode.NO_MESSAGE).payload(statistics));
}

View File

@ -1,7 +1,6 @@
package eu.eudat.controllers;
import eu.eudat.data.entities.Dataset;
import eu.eudat.data.query.items.table.dataset.DatasetPublicTableRequest;
import eu.eudat.data.query.items.table.dataset.DatasetTableRequest;
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
import eu.eudat.logic.managers.DatasetManager;
@ -44,14 +43,6 @@ public class Datasets extends BaseController {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
}
/*@RequestMapping(method = RequestMethod.POST, value = {"/public/paged"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DatasetListingModel>>> getPublicPaged(@RequestBody DatasetPublicTableRequest datasetTableRequest,
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
DataTableData<DatasetListingModel> dataTable = this.datasetManager.getPaged(datasetTableRequest, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
}*/
@Transactional
@RequestMapping(method = RequestMethod.GET, value = {"/makepublic/{id}"}, produces = "application/json")
public @ResponseBody

View File

@ -6,15 +6,21 @@ import eu.eudat.data.dao.entities.DatasetDao;
import eu.eudat.data.dao.entities.OrganisationDao;
import eu.eudat.data.dao.entities.GrantDao;
import eu.eudat.data.entities.*;
import eu.eudat.data.query.items.table.dmp.DataManagmentPlanPublicTableRequest;
import eu.eudat.data.query.definition.helpers.ColumnOrderings;
import eu.eudat.data.query.items.table.dataset.DatasetTableRequest;
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
import eu.eudat.elastic.entities.Dmp;
import eu.eudat.logic.builders.model.models.RecentActivityDataBuilder;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
import eu.eudat.models.data.dashboard.recent.RecentActivity;
import eu.eudat.models.data.dashboard.recent.RecentActivityData;
import eu.eudat.models.data.dashboard.searchbar.SearchBarItem;
import eu.eudat.models.data.dashboard.statistics.DashBoardStatistics;
import eu.eudat.models.data.helpers.common.DataTableData;
import eu.eudat.models.data.listingmodels.DataManagementPlanListingModel;
import eu.eudat.models.data.listingmodels.DatasetListingModel;
import eu.eudat.models.data.security.Principal;
import eu.eudat.types.searchbar.SearchBarItemType;
import org.slf4j.Logger;
@ -27,6 +33,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
@Component
@ -35,46 +42,62 @@ public class DashBoardManager {
private ApiContext apiContext;
private DatabaseRepository databaseRepository;
private DataManagementPlanManager dmpManager;
private DatasetManager datasetManager;
@Autowired
public DashBoardManager(ApiContext apiContext) {
public DashBoardManager(ApiContext apiContext, DataManagementPlanManager dmpManager, DatasetManager datasetManager) {
this.apiContext = apiContext;
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
this.dmpManager = dmpManager;
this.datasetManager = datasetManager;
}
public DashBoardStatistics getStatistics() {
public DashBoardStatistics getStatistics() throws Exception {
DashBoardStatistics statistics = new DashBoardStatistics();
AtomicReference<DataTableData<DataManagementPlanListingModel>> dmpData = new AtomicReference<>(new DataTableData<>());
AtomicReference<DataTableData<DatasetListingModel>> datasetData = new AtomicReference<>(new DataTableData<>());
LinkedList<Grant> grants = new LinkedList<>();
DataManagmentPlanPublicTableRequest publicTableRequest = new DataManagmentPlanPublicTableRequest();
DataManagementPlanTableRequest tableRequest = new DataManagementPlanTableRequest();
tableRequest.setCriteria(new DataManagementPlanCriteria());
tableRequest.getCriteria().setAllVersions(false);
tableRequest.getCriteria().setOnlyPublic(true);
tableRequest.getCriteria().setIsPublic(true);
CompletableFuture dmpTask = CompletableFuture.runAsync(() -> {
try {
dmpData.set(dmpManager.getPaged(tableRequest, new Principal(), "listing"));
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
});
DataManagementPlanPublicCriteria publicCriteria = new DataManagementPlanPublicCriteria();
DatasetTableRequest datasetRequest = new DatasetTableRequest();
datasetRequest.setCriteria(new DatasetCriteria());
datasetRequest.getCriteria().setAllVersions(false);
datasetRequest.getCriteria().setIsPublic(true);
datasetRequest.setOrderings(new ColumnOrderings());
CompletableFuture datasetTask = CompletableFuture.runAsync(() -> {
try {
datasetData.set(datasetManager.getPaged(datasetRequest, new Principal()));
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
publicCriteria.setAllVersions(false);
});
publicTableRequest.setCriteria(publicCriteria);
publicTableRequest.setQuery(databaseRepository.getDmpDao().asQueryable());
List<DMP> dmps = publicTableRequest.applyCriteria().toList();
// DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria();
OrganisationCriteria organisationCriteria = new OrganisationCriteria();
/*dataManagementPlanCriteria.setAllVersions(false);
dataManagementPlanCriteria.setIsPublic(true);*/
organisationCriteria.setPublic(true);
// List<DMP> dmps = databaseRepository.getDmpDao().getWithCriteria(dataManagementPlanCriteria).toList();
long numberOfDatasets = 0;
LinkedList<Grant> grants = new LinkedList<>();
for (DMP dmp : dmps) {
numberOfDatasets = numberOfDatasets + dmp.getDataset().stream()
.filter(item -> item.getStatus() == Dataset.Status.FINALISED.getValue()).count();
grants.add(dmp.getGrant());
}
CompletableFuture.allOf(dmpTask, datasetTask).join();
statistics.setTotalDataManagementPlanCount((long) dmps.size());
List<DMP> dmps = dmpData.get().getData().stream().map(DataManagementPlanListingModel::toDataModel).collect(Collectors.toList());
long numberOfDatasets = datasetData.get().getTotalCount();
grants.addAll(dmps.stream().map(DMP::getGrant).collect(Collectors.toList()));
statistics.setTotalDataManagementPlanCount(dmpData.get().getTotalCount());
statistics.setTotalDataSetCount(numberOfDatasets);
statistics.setTotalGrantCount(grants.stream().distinct().count());
statistics.setTotalGrantCount(grants.stream().filter(StreamDistinctBy.distinctByKey(Grant::getId)).count());
statistics.setTotalOrganisationCount(databaseRepository.getOrganisationDao().getWithCriteria(organisationCriteria).count());
return statistics;

View File

@ -1,6 +1,5 @@
package eu.eudat.logic.managers;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration;
@ -14,10 +13,8 @@ import eu.eudat.data.enumeration.notification.ActiveStatus;
import eu.eudat.data.enumeration.notification.ContactType;
import eu.eudat.data.enumeration.notification.NotificationType;
import eu.eudat.data.enumeration.notification.NotifyState;
import eu.eudat.data.query.items.item.dmp.DataManagementPlanCriteriaRequest;
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
import eu.eudat.data.query.items.table.dmp.DataManagmentPlanPublicTableRequest;
import eu.eudat.elastic.criteria.DmpCriteria;
import eu.eudat.elastic.entities.Collaborator;
import eu.eudat.elastic.entities.Dmp;
@ -83,8 +80,6 @@ import org.springframework.web.multipart.MultipartFile;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

View File

@ -11,7 +11,6 @@ import eu.eudat.data.enumeration.notification.ActiveStatus;
import eu.eudat.data.enumeration.notification.ContactType;
import eu.eudat.data.enumeration.notification.NotificationType;
import eu.eudat.data.enumeration.notification.NotifyState;
import eu.eudat.data.query.items.table.dataset.DatasetPublicTableRequest;
import eu.eudat.data.query.items.table.dataset.DatasetTableRequest;
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
import eu.eudat.elastic.criteria.DatasetCriteria;
@ -198,7 +197,7 @@ public class DatasetManager {
return dataTable;
}
public DataTableData<DatasetListingModel> getPaged(DatasetPublicTableRequest datasetTableRequest, Principal principal) throws Exception {
/*public DataTableData<DatasetListingModel> getPaged(DatasetPublicTableRequest datasetTableRequest, Principal principal) throws Exception {
DatasetCriteria datasetCriteria = new DatasetCriteria();
datasetCriteria.setLike(datasetTableRequest.getCriteria().getLike());
datasetCriteria.setDatasetTemplates(datasetTableRequest.getCriteria().getDatasetProfile());
@ -214,7 +213,7 @@ public class DatasetManager {
}
datasetTableRequest.setQuery(databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetListingModel.class)));
QueryableList<Dataset> items = datasetTableRequest.applyCriteria();
/*QueryableList<Dataset> items;
*//*QueryableList<Dataset> items;
if (datasets != null) {
if (!datasets.isEmpty()) {
items = databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetListingModel.class));
@ -225,7 +224,7 @@ public class DatasetManager {
items.where((builder, root) -> root.get("id").in(new UUID[]{UUID.randomUUID()}));
} else {
items = datasetTableRequest.applyCriteria();
}*/
}*//*
if (principal.getId() != null && datasetTableRequest.getCriteria().getRole() != null) {
items.where((builder, root) -> {
@ -250,7 +249,7 @@ public class DatasetManager {
CompletableFuture.allOf(itemsFuture, countFuture).join();
return dataTable;
}
}*/
public DatasetWizardModel getSingle(String id, Principal principal) {
DatasetWizardModel dataset = new DatasetWizardModel();

View File

@ -1,17 +1,14 @@
package eu.eudat.models.data.listingmodels;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.DMPProfile;
import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.logic.utilities.builders.XmlBuilder;
import eu.eudat.data.entities.Grant;
import eu.eudat.models.DataModel;
import eu.eudat.models.data.dmp.AssociatedProfile;
import eu.eudat.models.data.dmp.Organisation;
import eu.eudat.logic.utilities.helpers.LabelBuilder;
import eu.eudat.models.data.urls.DatasetUrlListing;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.util.Date;
import java.util.LinkedList;
@ -231,7 +228,38 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
@Override
public DMP toDataModel() {
return null;
DMP entity = new DMP();
entity.setStatus(Integer.valueOf(this.status).shortValue());
entity.setVersion(this.version);
entity.setGrant(new Grant());
entity.getGrant().setId(UUID.fromString(this.grantId));
entity.getGrant().setAbbreviation(this.grantAbbreviation);
entity.getGrant().setLabel(this.grant);
if (this.profile != null) {
entity.setProfile(new DMPProfile());
entity.getProfile().setLabel(this.profile);
}
entity.setCreated(this.creationTime);
entity.setModified(this.modifiedTime);
/*entity.setOrganisations();
this.organisations = LabelBuilder.getLabel(entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList()));*/
/* entity.setDataset(this.datasets.stream().map((Function<DatasetUrlListing, Object>) DatasetUrlListing::toDataModel).co);
this.datasets = entity.getDataset().stream().map(x-> new DatasetUrlListing().fromDataModel(x)).collect(Collectors.toList());
this.users = entity.getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList());*/
entity.setDescription(this.description);
entity.setFinalizedAt(this.finalizedAt);
entity.setPublic(this.isPublic);
entity.setPublishedAt(this.publishedAt);
/*if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
this.associatedProfiles = new LinkedList<>();
for (DatasetProfile datasetProfile: entity.getAssociatedDmps()) {
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(datasetProfile);
this.associatedProfiles.add(associatedProfile);
}
}*/
return entity;
}
@Override

View File

@ -1,44 +0,0 @@
package eu.eudat.models.data.rda;
import eu.eudat.data.entities.UserInfo;
public class ContactRDAExportModel {
private String mbox;
private String name;
private IdRDAExportModel contact_id;
public String getMbox() {
return mbox;
}
public void setMbox(String mbox) {
this.mbox = mbox;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public IdRDAExportModel getContact_id() {
return contact_id;
}
public void setContact_id(IdRDAExportModel contact_id) {
this.contact_id = contact_id;
}
public ContactRDAExportModel fromDataModel(UserInfo entity) {
ContactRDAExportModel contact = new ContactRDAExportModel();
contact.mbox = entity.getEmail();
contact.name = entity.getName();
// TODO: we should use a contact_id and not our UUID.
if (!entity.getId().toString().isEmpty()) {
contact.contact_id = new IdRDAExportModel(entity.getId().toString(), "other");
}
else {
contact.contact_id = null;
}
return contact;
}
}

View File

@ -1,93 +0,0 @@
package eu.eudat.models.data.rda;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.List;
public class DatasetDistributionRDAExportModel {
private String access_url;
private String available_till;
private String byte_size;
private String data_access; // Allowed values: open / shared / closed
private String description;
private String download_url;
private List<String> format; // Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format
private HostRDAExportModel host;
private List<LicenseRDAExportModel> license;
private String title;
public String getAccess_url() {
return access_url;
}
public void setAccess_url(String access_url) {
this.access_url = access_url;
}
public String getAvailable_till() {
return available_till;
}
public void setAvailable_till(String available_till) {
this.available_till = available_till;
}
public String getByte_size() {
return byte_size;
}
public void setByte_size(String byte_size) {
this.byte_size = byte_size;
}
public String getData_access() {
return data_access;
}
public void setData_access(String data_access) {
this.data_access = data_access;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getDownload_url() {
return download_url;
}
public void setDownload_url(String download_url) {
this.download_url = download_url;
}
public List<String> getFormat() {
return format;
}
public void setFormat(List<String> format) {
this.format = format;
}
public HostRDAExportModel getHost() {
return host;
}
public void setHost(HostRDAExportModel host) {
this.host = host;
}
public List<LicenseRDAExportModel> getLicense() {
return license;
}
public void setLicense(List<LicenseRDAExportModel> license) {
this.license = license;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@JsonIgnore
public boolean isValid() {
return title != null || data_access != null;
}
}

View File

@ -1,47 +0,0 @@
package eu.eudat.models.data.rda;
import com.fasterxml.jackson.annotation.JsonIgnore;
public class DatasetMetadataRDAExportModel {
private String description; // Not mandatory.
private String language;
private IdRDAExportModel metadata_standard_id;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public IdRDAExportModel getMetadata_standard_id() {
return metadata_standard_id;
}
public void setMetadata_standard_id(IdRDAExportModel metadata_standard_id) {
this.metadata_standard_id = metadata_standard_id;
}
public DatasetMetadataRDAExportModel fromDataModel(String key, Object value) {
DatasetMetadataRDAExportModel metadataRDAExportModel = new DatasetMetadataRDAExportModel();
if (key.contains("metadata_standard_id"))
metadataRDAExportModel.setMetadata_standard_id(new IdRDAExportModel(value.toString(), "other"));
else if (key.contains("language"))
metadataRDAExportModel.setLanguage(value.toString());
else if (key.contains("description"))
metadataRDAExportModel.setDescription(value.toString());
return metadataRDAExportModel;
}
@JsonIgnore
public boolean isValid() {
return description != null || language != null || metadata_standard_id != null;
}
}

View File

@ -1,474 +0,0 @@
package eu.eudat.models.data.rda;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jayway.jsonpath.JsonPath;
import eu.eudat.data.entities.Dataset;
import eu.eudat.logic.managers.DatasetManager;
import eu.eudat.logic.utilities.builders.XmlBuilder;
import eu.eudat.models.data.security.Principal;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.xml.xpath.*;
import java.text.DateFormat;
import java.util.*;
import static java.util.stream.Collectors.groupingBy;
public class DatasetRDAExportModel {
private static final Logger logger = LoggerFactory.getLogger(DatasetRDAExportModel.class);
private static final ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
private Map<String, String> multiplicityIdToFieldSetId = new HashMap<>();
private List<String> data_quality_assurance;
private IdRDAExportModel dataset_id;
private String description;
private List<DatasetDistributionRDAExportModel> distribution;
private String issued; // Created Date, could also use finalized one.
private List<String> keyword;
private String language;
private List<DatasetMetadataRDAExportModel> metadata;
private String personal_data; // Allowed Values: yes no unknown.
private String preservation_statement;
private List<DatasetSecurityAndPrivacyRDAExportModel> security_and_privacy;
private String sensitive_data; // Allowed Values: yes no unknown.
private List<DatasetTechnicalResourceRDAExportModel> technical_resource;
private String title;
private String type; // Type according to: http://vocabularies.coar-repositories.org/pubby/resource_type.html
public List<String> getData_quality_assurance() {
return data_quality_assurance;
}
public void setData_quality_assurance(List<String> data_quality_assurance) {
this.data_quality_assurance = data_quality_assurance;
}
public IdRDAExportModel getDataset_id() {
return dataset_id;
}
public void setDataset_id(IdRDAExportModel dataset_id) {
this.dataset_id = dataset_id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<DatasetDistributionRDAExportModel> getDistribution() {
return distribution;
}
public void setDistribution(List<DatasetDistributionRDAExportModel> distribution) {
this.distribution = distribution;
}
public String getIssued() {
return issued;
}
public void setIssued(String issued) {
this.issued = issued;
}
public List<String> getKeyword() {
return keyword;
}
public void setKeyword(List<String> keyword) {
this.keyword = keyword;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public List<DatasetMetadataRDAExportModel> getMetadata() {
return metadata;
}
public void setMetadata(List<DatasetMetadataRDAExportModel> metadata) {
this.metadata = metadata;
}
public String getPersonal_data() {
return personal_data;
}
public void setPersonal_data(String personal_data) {
this.personal_data = personal_data;
}
public String getPreservation_statement() {
return preservation_statement;
}
public void setPreservation_statement(String preservation_statement) {
this.preservation_statement = preservation_statement;
}
public List<DatasetSecurityAndPrivacyRDAExportModel> getSecurity_and_privacy() {
return security_and_privacy;
}
public void setSecurity_and_privacy(List<DatasetSecurityAndPrivacyRDAExportModel> security_and_privacy) {
this.security_and_privacy = security_and_privacy;
}
public String getSensitive_data() {
return sensitive_data;
}
public void setSensitive_data(String sensitive_data) {
this.sensitive_data = sensitive_data;
}
public List<DatasetTechnicalResourceRDAExportModel> getTechnical_resource() {
return technical_resource;
}
public void setTechnical_resource(List<DatasetTechnicalResourceRDAExportModel> technical_resource) {
this.technical_resource = technical_resource;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public DatasetRDAExportModel fromDataModel(Dataset dataset, DatasetManager datasetManager, Principal principal) {
// Map of template Ids to rda values.
JSONObject jObject = new JSONObject(dataset.getProperties());
Map<String, Object> templateIdsToValues = jObject.toMap();
/*--------- Building dataset rda export model ---------*/
DatasetRDAExportModel datasetRDAExportModel = new DatasetRDAExportModel();
datasetRDAExportModel.setDataset_id(new IdRDAExportModel(dataset.getId().toString(), "other"));
if (dataset.getDescription() != null) datasetRDAExportModel.setDescription(dataset.getDescription().replace("\n", " "));
datasetRDAExportModel.setIssued(DateFormat.getDateInstance(DateFormat.SHORT).format(dataset.getCreated()));
datasetRDAExportModel.setLanguage("en"); // mock data
datasetRDAExportModel.setTitle(dataset.getLabel());
// Transform the answered dataset description to json so we can parse it and fill the rda model.
JSONObject datasetDescriptionJson = null;
try {
String jsonResult = mapper.writeValueAsString(datasetManager.getSingle(dataset.getId().toString(), principal).getDatasetProfileDefinition());
datasetDescriptionJson = new JSONObject(jsonResult);
} catch (JsonProcessingException e) {
logger.error(e.getMessage(), e);
}
setMultiplicityIdToFieldSetId(datasetDescriptionJson);
/*--------- Building personal data. ---------*/
String personalData = buildSingleProperties("dataset.personal_data", datasetDescriptionJson, templateIdsToValues);
if (personalData != null) {
datasetRDAExportModel.setPersonal_data(personalData);
} else {
datasetRDAExportModel.setPersonal_data("unknown");
}
/*--------- Building preservation statement. ---------*/
datasetRDAExportModel.setPreservation_statement(buildSingleProperties("dataset.preservation_statement", datasetDescriptionJson, templateIdsToValues));
/*--------- Building sensitive data. ---------*/
String sensitiveData = buildSingleProperties("dataset.sensitive_data", datasetDescriptionJson, templateIdsToValues);
if (personalData != null) {
datasetRDAExportModel.setSensitive_data(sensitiveData);
} else {
datasetRDAExportModel.setSensitive_data("unknown");
}
/*--------- Building type. ---------*/
datasetRDAExportModel.setType(buildSingleProperties("dataset.type", datasetDescriptionJson, templateIdsToValues));
/*--------- Building data_quality_assurance. ---------*/
datasetRDAExportModel.setData_quality_assurance(buildDataQualityAssurance(datasetDescriptionJson, templateIdsToValues, dataset.getProfile().getDefinition()));
/*--------- Building distribution. ---------*/
datasetRDAExportModel.setDistribution(buildDistribution(datasetDescriptionJson, templateIdsToValues, dataset.getProfile().getDefinition()));
/*--------- Building keywords. ---------*/
datasetRDAExportModel.setKeyword(buildKeywords(datasetDescriptionJson, templateIdsToValues, dataset.getProfile().getDefinition()));
/*--------- Building metadata items. ---------*/
datasetRDAExportModel.setMetadata(buildMetadata(datasetDescriptionJson, templateIdsToValues, dataset.getProfile().getDefinition()));
/*--------- Building security and privacy items. ---------*/
datasetRDAExportModel.setSecurity_and_privacy(buildSecurityAndPrivacy(datasetDescriptionJson, templateIdsToValues, dataset.getProfile().getDefinition()));
/*--------- Building technical_resource. ---------*/
datasetRDAExportModel.setTechnical_resource(buildTechnicalResource(datasetDescriptionJson, templateIdsToValues, dataset.getProfile().getDefinition()));
return datasetRDAExportModel;
}
private String buildSingleProperties(String rdaKey, JSONObject datasetDescriptionJson, Map<String, Object> templateIdsToValues) {
String expression = "$..fields[*][?(@.rdaProperty == \"" + rdaKey + "\" )].id";
List<String> list = jsonValueListFromExpression(datasetDescriptionJson, expression);
if (!list.isEmpty()) {
return templateIdsToValues.get(list.get(0)).toString();
} else {
return null;
}
}
private List<String> buildDataQualityAssurance(JSONObject datasetDescriptionJson, Map<String, Object> templateIdsToValues, String datasetProfileDefinition) {
List<RdaField> dataQualityFields = getRDAFieldsFromJson(datasetDescriptionJson, new String[]{"dataset.data_quality_assurance"}, datasetProfileDefinition);
for (RdaField rdaField : dataQualityFields) {
rdaField.setRdaValue(templateIdsToValues.get(rdaField.getFieldId()).toString());
}
List<String> dataQualityAssuranceList = new LinkedList<>();
for (RdaField rdaField : dataQualityFields) {
dataQualityAssuranceList.add(rdaField.getRdaValue());
}
return dataQualityAssuranceList;
}
private List<DatasetDistributionRDAExportModel> buildDistribution(JSONObject datasetDescriptionJson, Map<String, Object> templateIdsToValues, String datasetProfileDefinition) {
DatasetDistributionRDAExportModel distributionModel = new DatasetDistributionRDAExportModel();
distributionModel.setAccess_url(buildSingleProperties("dataset.distribution.access_url", datasetDescriptionJson, templateIdsToValues));
distributionModel.setAvailable_till(buildSingleProperties("dataset.distribution.available_till", datasetDescriptionJson, templateIdsToValues));
distributionModel.setByte_size(buildSingleProperties("dataset.distribution.byte_size", datasetDescriptionJson, templateIdsToValues));
distributionModel.setData_access(buildSingleProperties("dataset.distribution.data_access", datasetDescriptionJson, templateIdsToValues));
distributionModel.setDescription(buildSingleProperties("dataset.distribution.description", datasetDescriptionJson, templateIdsToValues));
distributionModel.setDownload_url(buildSingleProperties("dataset.distribution.download_url", datasetDescriptionJson, templateIdsToValues));
distributionModel.setTitle(buildSingleProperties("dataset.distribution.title", datasetDescriptionJson, templateIdsToValues));
/*--------- Building format. ---------*/
// We currently support the return of only one distribution.
List<DatasetDistributionRDAExportModel> distributionList = new LinkedList<>();
if (distributionModel.isValid()) {
distributionList.add(distributionModel);
} else {
DatasetDistributionRDAExportModel model = new DatasetDistributionRDAExportModel();
model.setDescription("Distribution data was not valid");
distributionList.add(model);
}
return distributionList;
}
private List<String> buildKeywords(JSONObject datasetDescriptionJson, Map<String, Object> templateIdsToValues, String datasetProfileDefinition) {
List<RdaField> keywordFields = getRDAFieldsFromJson(datasetDescriptionJson, new String[]{"dataset.keyword"}, datasetProfileDefinition);
for (RdaField rdaField : keywordFields) {
rdaField.setRdaValue(templateIdsToValues.get(rdaField.getFieldId()).toString());
}
List<String> keywordsList = new LinkedList<>();
for (RdaField rdaField : keywordFields) {
keywordsList.add(rdaField.getRdaValue());
}
return keywordsList;
}
private List<DatasetMetadataRDAExportModel> buildMetadata(JSONObject datasetDescriptionJson, Map<String, Object> templateIdsToValues, String datasetProfileDefinition) {
List<RdaField> metadataFields = getRDAFieldsFromJson(datasetDescriptionJson,
new String[]{"dataset.metadata.metadata_standard_id.type", "dataset.metadata.metadata_standard_id.identifier", "dataset.metadata.description", "dataset.metadata.language", "dataset.metadata.metadata_standard_id"},
datasetProfileDefinition);
// Adding rdaValue and FieldSetIds on metadataFields.
for (RdaField rdaField : metadataFields) {
rdaField.setRdaValue(templateIdsToValues.get(rdaField.getFieldId()).toString());
}
// Group metadataFields based on their field set id.
Map<String, List<RdaField>> groupedMetadataFields = metadataFields.stream().collect(groupingBy(RdaField::getFieldSetId));
// Creating the metadata.
List<DatasetMetadataRDAExportModel> metadataRDAExportModelList = new LinkedList<>();
for (String fieldSetId : groupedMetadataFields.keySet()) {
DatasetMetadataRDAExportModel metadataRda = new DatasetMetadataRDAExportModel();
for (RdaField rdaField : groupedMetadataFields.get(fieldSetId)) {
if (rdaField.getRdaProperty().equals("dataset.metadata.metadata_standard_id.identifier")) {
if (metadataRda.getMetadata_standard_id() != null) {
metadataRda.getMetadata_standard_id().setIdentifier(rdaField.getRdaValue());
} else {
metadataRda.setMetadata_standard_id(new IdRDAExportModel(rdaField.getRdaValue(), "other"));
}
}
if (rdaField.getRdaProperty().equals("dataset.metadata.metadata_standard_id.type")) {
if (metadataRda.getMetadata_standard_id() != null) {
metadataRda.getMetadata_standard_id().setType(rdaField.getRdaValue());
} else {
metadataRda.setMetadata_standard_id(new IdRDAExportModel("", rdaField.getRdaValue()));
}
}
if (rdaField.getRdaProperty().equals("dataset.metadata.description")) {
metadataRda.setDescription(rdaField.getRdaValue());
}
if (rdaField.getRdaProperty().equals("dataset.metadata.language")) {
metadataRda.setLanguage(rdaField.getRdaValue());
}
if (rdaField.getRdaProperty().equals("dataset.metadata.metadata_standard_id") && !rdaField.getRdaValue().isEmpty()) {
JSONArray jsonArray = new JSONArray(rdaField.getRdaValue());
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
Map<String, Object> jsonObjectMap = jsonObject.toMap();
DatasetMetadataRDAExportModel metadataRda1 = new DatasetMetadataRDAExportModel();
// metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("label").toString(), jsonObjectMap.get("source").toString()));
metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("uri").toString(), "url"));
metadataRDAExportModelList.add(metadataRda1);
}
}
}
if (metadataRda.isValid()) {
metadataRDAExportModelList.add(metadataRda);
}
}
return new LinkedList<>(metadataRDAExportModelList);
}
private List<DatasetSecurityAndPrivacyRDAExportModel> buildSecurityAndPrivacy(JSONObject datasetDescriptionJson, Map<String, Object> templateIdsToValues, String datasetProfileDefinition) {
List<RdaField> secAndPrFields = getRDAFieldsFromJson(
datasetDescriptionJson,
new String[]{"dataset.security_and_privacy.description", "dataset.security_and_privacy.title", "dataset.security_and_privacy"},
datasetProfileDefinition);
for (RdaField rdaField : secAndPrFields) {
rdaField.setRdaValue(templateIdsToValues.get(rdaField.getFieldId()).toString());
}
Map<String, List<RdaField>> groupedSecurityAndPrivacyFields = secAndPrFields.stream().collect(groupingBy(RdaField::getFieldSetId));
List<DatasetSecurityAndPrivacyRDAExportModel> securityAndPrivacyRDAExportModelList = new LinkedList<>();
for (String fieldSetId : groupedSecurityAndPrivacyFields.keySet()) {
DatasetSecurityAndPrivacyRDAExportModel securityAndPrivacyModel = new DatasetSecurityAndPrivacyRDAExportModel();
for (RdaField rdaField : groupedSecurityAndPrivacyFields.get(fieldSetId)) {
if (rdaField.getRdaProperty().equals("dataset.security_and_privacy.description")) {
securityAndPrivacyModel.setDescription(rdaField.getRdaValue());
}
if (rdaField.getRdaProperty().equals("dataset.security_and_privacy.title")) {
securityAndPrivacyModel.setTitle(rdaField.getRdaValue());
}
if (rdaField.getRdaProperty().equals("dataset.security_and_privacy")) {
JSONArray jsonArray = new JSONArray(rdaField.getRdaValue());
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
Map<String, Object> jsonObjectMap = jsonObject.toMap();
DatasetSecurityAndPrivacyRDAExportModel secAndPrivacy = new DatasetSecurityAndPrivacyRDAExportModel(jsonObjectMap.get("label").toString(), jsonObjectMap.get("source").toString());
securityAndPrivacyRDAExportModelList.add(secAndPrivacy);
}
}
}
securityAndPrivacyRDAExportModelList.add(securityAndPrivacyModel);
}
return securityAndPrivacyRDAExportModelList;
}
private List<DatasetTechnicalResourceRDAExportModel> buildTechnicalResource(JSONObject datasetDescriptionJson, Map<String, Object> templateIdsToValues, String datasetProfileDefinition) {
List<RdaField> dataQualityFields = getRDAFieldsFromJson(datasetDescriptionJson,
new String[]{"dataset.technical_resource.technical_resource", "dataset.technical_resource.technical_resource.description", "dataset.technical_resource.technical_resource.name"},
datasetProfileDefinition);
for (RdaField rdaField : dataQualityFields) {
rdaField.setRdaValue(templateIdsToValues.get(rdaField.getFieldId()).toString());
}
List<DatasetTechnicalResourceRDAExportModel> technicalResourceList = new LinkedList<>();
Map<String, List<RdaField>> groupedDataQualityFields = dataQualityFields.stream().collect(groupingBy(RdaField::getFieldSetId));
for (String fieldSetId : groupedDataQualityFields.keySet()) {
DatasetTechnicalResourceRDAExportModel technicalResourceModel = new DatasetTechnicalResourceRDAExportModel();
for (RdaField rdaField : groupedDataQualityFields.get(fieldSetId)) {
if (rdaField.getRdaProperty().equals("dataset.technical_resource.technical_resource.description")) {
technicalResourceModel.setDescription(rdaField.getRdaValue());
}
if (rdaField.getRdaProperty().equals("dataset.technical_resource.technical_resource.name")) {
technicalResourceModel.setName(rdaField.getRdaValue());
}
if (rdaField.getRdaProperty().equals("dataset.security_and_privacy")) {
JSONArray jsonArray = new JSONArray(rdaField.getRdaValue());
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
Map<String, Object> jsonObjectMap = jsonObject.toMap();
DatasetTechnicalResourceRDAExportModel technicalResource = new DatasetTechnicalResourceRDAExportModel(jsonObjectMap.get("label").toString(), jsonObjectMap.get("label").toString());
technicalResourceList.add(technicalResource);
}
}
}
technicalResourceList.add(technicalResourceModel);
}
return technicalResourceList;
}
private void setMultiplicityIdToFieldSetId(JSONObject json) {
String multiplicityItemsFieldSetIdExp = "$..multiplicityItems[*].id";
List<String> multiplicityItemsFieldSetIdList = jsonValueListFromExpression(json, multiplicityItemsFieldSetIdExp);
for (String fieldSetId : multiplicityItemsFieldSetIdList) {
String fieldsFromFieldSetIdExp = "$..multiplicityItems[*][?(@.id == \""+ fieldSetId +"\")].fields[*].id";
List<String> fieldsIdList = jsonValueListFromExpression(json, fieldsFromFieldSetIdExp);
for (String fieldId : fieldsIdList) {
this.multiplicityIdToFieldSetId.put(fieldId, fieldSetId);
}
}
}
private List<RdaField> getRDAFieldsFromJson(JSONObject json, String[] rdaKey, String datasetProfileDefinition) {
List<RdaField> rdaFields = new LinkedList<>();
for (String key : rdaKey) {
String fieldIdExpression = "$..fields[*][?(@.rdaProperty == \"" + key + "\" )].id";
List<String> listFromExpression = jsonValueListFromExpression(json, fieldIdExpression);
for (String fieldId : listFromExpression) {
RdaField rdaField = new RdaField();
rdaField.setRdaProperty(key);
rdaField.setFieldId(fieldId);
if (fieldId.startsWith("multiple_")) {
rdaField.setFieldSetId(this.multiplicityIdToFieldSetId.get(fieldId));
} else {
rdaField.setFieldSetId(getFieldSetIdForFieldFromXML(datasetProfileDefinition, fieldId));
}
rdaFields.add(rdaField);
}
}
return rdaFields;
}
private List<String> jsonValueListFromExpression(JSONObject json, String expression) {
net.minidev.json.JSONArray jsonArray = JsonPath.parse(json.toString()).read(expression);
List<String> valueList = new LinkedList<>();
for (Object o : jsonArray) {
valueList.add(o.toString());
}
return valueList;
}
private String getFieldSetIdForFieldFromXML(String datasetProfileDefinition, String fieldId) {
String fieldSetIdExpression = "//field[@id ='" + fieldId + "']/ancestor::fieldSet/@id";
List<String> listFromExpression = xmlValueListFromExpression(datasetProfileDefinition, fieldSetIdExpression);
if (listFromExpression.size() == 1) return listFromExpression.get(0);
return null;
}
private List<String> xmlValueListFromExpression(String xml, String expression) {
List<String> valuesList = new LinkedList<>();
Document document = XmlBuilder.fromXml(xml);
XPathFactory xpathFactory = XPathFactory.newInstance();
XPath xpath = xpathFactory.newXPath();
try {
XPathExpression expr = xpath.compile(expression);
NodeList nodeList = (NodeList) expr.evaluate(document, XPathConstants.NODESET);
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
valuesList.add(node.getNodeValue());
}
} catch (XPathExpressionException e) {
logger.error(e.getMessage(), e);
}
return valuesList;
}
}

View File

@ -1,29 +0,0 @@
package eu.eudat.models.data.rda;
public class DatasetSecurityAndPrivacyRDAExportModel {
private String description;
private String title;
public DatasetSecurityAndPrivacyRDAExportModel() {
}
public DatasetSecurityAndPrivacyRDAExportModel(String description, String title) {
this.description = description;
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}

View File

@ -1,28 +0,0 @@
package eu.eudat.models.data.rda;
public class DatasetTechnicalResourceRDAExportModel {
private String description;
private String name;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public DatasetTechnicalResourceRDAExportModel(String description, String name) {
this.description = description;
this.name = name;
}
public DatasetTechnicalResourceRDAExportModel() {
}
}

View File

@ -1,52 +0,0 @@
package eu.eudat.models.data.rda;
import eu.eudat.data.entities.UserInfo;
import java.util.LinkedList;
import java.util.List;
public class DmpContributorRDAExportModel {
private IdRDAExportModel contributor_id;
private String mbox;
private String name;
private List<String> role;
public IdRDAExportModel getContributor_id() {
return contributor_id;
}
public void setContributor_id(IdRDAExportModel contributor_id) {
this.contributor_id = contributor_id;
}
public String getMbox() {
return mbox;
}
public void setMbox(String mbox) {
this.mbox = mbox;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<String> getRole() {
return role;
}
public void setRole(List<String> role) {
this.role = role;
}
public DmpContributorRDAExportModel fromDataModel(UserInfo user, String role) {
DmpContributorRDAExportModel contributor = new DmpContributorRDAExportModel();
contributor.contributor_id = new IdRDAExportModel(user.getId().toString(), "other");
contributor.mbox = user.getEmail();
contributor.name = user.getName();
contributor.role = new LinkedList<>();
contributor.role.add(role);
return contributor;
}
}

View File

@ -1,36 +0,0 @@
package eu.eudat.models.data.rda;
public class DmpCostRDAExportModel {
private String currency_code; //Allowed values defined by ISO 4217.
private String description;
private String title;
private String value;
public String getCurrency_code() {
return currency_code;
}
public void setCurrency_code(String currency_code) {
this.currency_code = currency_code;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

View File

@ -1,164 +0,0 @@
package eu.eudat.models.data.rda;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.Dataset;
import eu.eudat.data.entities.UserDMP;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.logic.managers.DatasetManager;
import eu.eudat.models.data.security.Principal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
public class DmpRDAExportModel {
private ContactRDAExportModel contact;
private List<DmpContributorRDAExportModel> contributor;
private List<DmpCostRDAExportModel> cost;
private String created;
private List<DatasetRDAExportModel> dataset;
private String description;
private IdRDAExportModel dmp_id;
private String ethical_issues_description;
private String ethical_issues_exist; // Allowed Values: yes no unknown.
private String ethical_issues_report;
private String language;
private String modified;
private ProjectRDAExportModel project;
private String title;
public ContactRDAExportModel getContact() {
return contact;
}
public void setContact(ContactRDAExportModel contact) {
this.contact = contact;
}
public List<DmpContributorRDAExportModel> getContributor() {
return contributor;
}
public void setContributor(List<DmpContributorRDAExportModel> contributor) {
this.contributor = contributor;
}
public List<DmpCostRDAExportModel> getCost() {
return cost;
}
public void setCost(List<DmpCostRDAExportModel> cost) {
this.cost = cost;
}
public String getCreated() {
return created;
}
public void setCreated(String created) {
this.created = created;
}
public List<DatasetRDAExportModel> getDataset() {
return dataset;
}
public void setDataset(List<DatasetRDAExportModel> dataset) {
this.dataset = dataset;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public IdRDAExportModel getDmp_id() {
return dmp_id;
}
public void setDmp_id(IdRDAExportModel dmp_id) {
this.dmp_id = dmp_id;
}
public String getEthical_issues_description() {
return ethical_issues_description;
}
public void setEthical_issues_description(String ethical_issues_description) {
this.ethical_issues_description = ethical_issues_description;
}
public String getEthical_issues_exist() {
return ethical_issues_exist;
}
public void setEthical_issues_exist(String ethical_issues_exist) {
this.ethical_issues_exist = ethical_issues_exist;
}
public String getEthical_issues_report() {
return ethical_issues_report;
}
public void setEthical_issues_report(String ethical_issues_report) {
this.ethical_issues_report = ethical_issues_report;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public String getModified() {
return modified;
}
public void setModified(String modified) {
this.modified = modified;
}
public ProjectRDAExportModel getProject() {
return project;
}
public void setProject(ProjectRDAExportModel project) {
this.project = project;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public DmpRDAExportModel fromDataModel(DMP entity, DatasetManager datasetManager, Principal principal) {
DmpRDAExportModel dmpRda = new DmpRDAExportModel();
dmpRda.contact = new ContactRDAExportModel().fromDataModel(entity.getUsers().stream().filter(x -> x.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser());
if (entity.getUsers().stream().anyMatch(x -> x.getRole().equals(UserDMP.UserDMPRoles.USER.getValue()))) {
dmpRda.contributor = new LinkedList<>();
for (UserDMP userdmp : entity.getUsers().stream().filter(x -> x.getRole().equals(UserDMP.UserDMPRoles.USER.getValue())).collect(Collectors.toList())) {
dmpRda.contributor.add(new DmpContributorRDAExportModel().fromDataModel(userdmp.getUser(), UserDMP.UserDMPRoles.fromInteger(userdmp.getRole()).toString()));
}
}
dmpRda.cost = null;
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
dmpRda.created = formatter.format(entity.getCreated());
dmpRda.dataset = new LinkedList<>();
for (Dataset dataset : entity.getDataset()) {
if (dataset.getStatus() != Dataset.Status.DELETED.getValue() && dataset.getStatus() != Dataset.Status.CANCELED.getValue())
dmpRda.dataset.add(new DatasetRDAExportModel().fromDataModel(dataset, datasetManager, principal));
}
dmpRda.description = entity.getDescription().replace("\n", " ");
if (entity.getDoi() != null) {
dmpRda.dmp_id = new IdRDAExportModel(entity.getDoi(), "zenodo");
}
else {
dmpRda.dmp_id = new IdRDAExportModel(entity.getId().toString(), "other");
}
// Mock up data on "language" and "ethical_issues_*" for now.
dmpRda.ethical_issues_exist = "unknown";
dmpRda.language = "en";
dmpRda.modified = formatter.format(new Date());
dmpRda.project = new ProjectRDAExportModel().fromDataModel(entity.getGrant());
dmpRda.title = entity.getLabel();
return dmpRda;
}
}

View File

@ -1,43 +0,0 @@
package eu.eudat.models.data.rda;
import eu.eudat.data.entities.Funder;
import eu.eudat.data.entities.Grant;
public class FundingRDAExportModel {
private IdRDAExportModel funder_id;
private IdRDAExportModel grant_id;
private String funding_status;
public IdRDAExportModel getFunder_id() {
return funder_id;
}
public void setFunder_id(IdRDAExportModel funder_id) {
this.funder_id = funder_id;
}
public IdRDAExportModel getGrant_id() {
return grant_id;
}
public void setGrant_id(IdRDAExportModel grant_id) {
this.grant_id = grant_id;
}
public String getFunding_status() {
return funding_status;
}
public void setFunding_status(String funding_status) {
this.funding_status = funding_status;
}
public FundingRDAExportModel fromDataModel(Funder funder, Grant grant) {
FundingRDAExportModel funding = new FundingRDAExportModel();
funding.funding_status = "planned"; // mock data
if (funder != null) {
funding.funder_id = new IdRDAExportModel(funder.getReference(), "other");
}
if (grant != null) {
funding.grant_id = new IdRDAExportModel(grant.getReference(), "other");
}
return funding;
}
}

View File

@ -1,86 +0,0 @@
package eu.eudat.models.data.rda;
import java.util.List;
public class HostRDAExportModel {
private String availability;
private String backup__frequency;
private String backup_type;
private String certified_with; // Repository certified with one the following standards: DIN31644 / DINI-Zertifikat / DSA / ISO16363 / ISO16919 /TRAC / WDS / CoreTrustSeal
private String description;
private String geo_location; // Physical location of the data expressed using ISO 3166-1 country code.
private List<String> pid_system; // PID System: ark arxiv bibcode doi ean13 eissn handle igsn isbn issn istc lissn lsid pmid purl upc url urn other
private String storage_type;
private String support_versioning; // Allowed values: yes / no / unknown
private String title;
public String getAvailability() {
return availability;
}
public void setAvailability(String availability) {
this.availability = availability;
}
public String getBackup__frequency() {
return backup__frequency;
}
public void setBackup__frequency(String backup__frequency) {
this.backup__frequency = backup__frequency;
}
public String getBackup_type() {
return backup_type;
}
public void setBackup_type(String backup_type) {
this.backup_type = backup_type;
}
public String getCertified_with() {
return certified_with;
}
public void setCertified_with(String certified_with) {
this.certified_with = certified_with;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getGeo_location() {
return geo_location;
}
public void setGeo_location(String geo_location) {
this.geo_location = geo_location;
}
public List<String> getPid_system() {
return pid_system;
}
public void setPid_system(List<String> pid_system) {
this.pid_system = pid_system;
}
public String getStorage_type() {
return storage_type;
}
public void setStorage_type(String storage_type) {
this.storage_type = storage_type;
}
public String getSupport_versioning() {
return support_versioning;
}
public void setSupport_versioning(String support_versioning) {
this.support_versioning = support_versioning;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}

View File

@ -1,25 +0,0 @@
package eu.eudat.models.data.rda;
public class IdRDAExportModel {
private String identifier;
private String type;
public String getIdentifier() {
return identifier;
}
public void setIdentifier(String identifier) {
this.identifier = identifier;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
IdRDAExportModel(String identifier, String type) {
this.identifier = identifier;
this.type = type;
}
}

View File

@ -1,20 +0,0 @@
package eu.eudat.models.data.rda;
public class LicenseRDAExportModel {
private String license_ref;
private String start_date; // If date is set in the future, it indicates embargo period.
public String getLicense_ref() {
return license_ref;
}
public void setLicense_ref(String license_ref) {
this.license_ref = license_ref;
}
public String getStart_date() {
return start_date;
}
public void setStart_date(String start_date) {
this.start_date = start_date;
}
}

View File

@ -1,54 +0,0 @@
package eu.eudat.models.data.rda;
import eu.eudat.data.entities.Grant;
import java.util.Date;
public class ProjectRDAExportModel {
private String title;
private String description;
private Date project_start;
private Date project_end;
private FundingRDAExportModel funding;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Date getProject_start() {
return project_start;
}
public void setProject_start(Date project_start) {
this.project_start = project_start;
}
public Date getProject_end() {
return project_end;
}
public void setProject_end(Date project_end) {
this.project_end = project_end;
}
public FundingRDAExportModel getFunding() {
return funding;
}
public void setFunding(FundingRDAExportModel funding) {
this.funding = funding;
}
public ProjectRDAExportModel fromDataModel(Grant grant) {
this.funding = new FundingRDAExportModel().fromDataModel(grant.getFunder(), grant);
return this;
}
}

View File

@ -1,25 +0,0 @@
package eu.eudat.models.data.rda;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.Dataset;
import eu.eudat.logic.managers.DatasetManager;
import eu.eudat.models.data.security.Principal;
import java.util.LinkedList;
import java.util.List;
public class RDAExportModel {
private DmpRDAExportModel dmp;
public DmpRDAExportModel getDmp() {
return dmp;
}
public void setDmp(DmpRDAExportModel dmp) {
this.dmp = dmp;
}
public RDAExportModel fromDataModel(DMP dmp, DatasetManager datasetManager, Principal principal) {
this.dmp = new DmpRDAExportModel().fromDataModel(dmp, datasetManager, principal);
return this;
}
}

View File

@ -1,36 +0,0 @@
package eu.eudat.models.data.rda;
public class RdaField {
private String rdaProperty;
private String rdaValue;
private String fieldId;
private String fieldSetId;
public String getRdaProperty() {
return rdaProperty;
}
public void setRdaProperty(String rdaProperty) {
this.rdaProperty = rdaProperty;
}
public String getRdaValue() {
return rdaValue;
}
public void setRdaValue(String rdaValue) {
this.rdaValue = rdaValue;
}
public String getFieldId() {
return fieldId;
}
public void setFieldId(String fieldId) {
this.fieldId = fieldId;
}
public String getFieldSetId() {
return fieldSetId;
}
public void setFieldSetId(String fieldSetId) {
this.fieldSetId = fieldSetId;
}
}

View File

@ -14,7 +14,7 @@ public class DatasetUrlListing extends UrlListing<Dataset, DatasetUrlListing> {
}
@Override
public Dataset toDataModel() throws Exception {
public Dataset toDataModel() {
return null;
}

View File

@ -1,13 +0,0 @@
import { GrantStateType } from "../../common/enum/grant-state-type";
import { BaseCriteria } from "../base-criteria";
import { Role } from '../../common/enum/role';
export class ExploreDatasetCriteriaModel extends BaseCriteria {
public grantStatus: GrantStateType;
public role: Role;
public dmpIds: string[] = [];
public grants: string[] = [];
public datasetProfile: string[] = [];
public dmpOrganisations: string[] = [];
public tags = [];
}

View File

@ -1,13 +0,0 @@
import { BaseCriteria } from "../base-criteria";
import { GrantStateType } from "../../common/enum/grant-state-type";
import { Role } from '../../common/enum/role';
export class ExploreDmpCriteriaModel extends BaseCriteria {
public grantStatus: GrantStateType;
public role: Role;
public grants: string[] = [];
public datasetProfile: string[] = [];
public dmpOrganisations: string[] = [];
public allVersions: boolean;
public groupIds: string[] = [];
}

View File

@ -6,7 +6,6 @@ import { DataTableRequest } from '../../model/data-table/data-table-request';
import { DatasetListingModel } from '../../model/dataset/dataset-listing';
import { DatasetProfileModel } from '../../model/dataset/dataset-profile';
import { DatasetCriteria } from '../../query/dataset/dataset-criteria';
import { ExploreDatasetCriteriaModel } from '../../query/explore-dataset/explore-dataset-criteria';
import { BaseHttpService } from '../http/base-http.service';
import { DatasetProfileCriteria } from '../../query/dataset-profile/dataset-profile-criteria';
import { ConfigurationService } from '../configuration/configuration.service';
@ -26,10 +25,6 @@ export class DatasetService {
return this.http.post<DataTableData<DatasetListingModel>>(this.actionUrl + 'paged', dataTableRequest);
}
getPublicPaged(dataTableRequest: DataTableRequest<ExploreDatasetCriteriaModel>): Observable<DataTableData<DatasetListingModel>> {
return this.http.post<DataTableData<DatasetListingModel>>(this.actionUrl + 'public/paged', dataTableRequest);
}
makeDatasetPublic(id: String) {
return this.http.get(this.actionUrl + 'makepublic/' + id);
}

View File

@ -15,7 +15,6 @@ import { DmpListingModel } from '../../model/dmp/dmp-listing';
import { DmpOverviewModel } from '../../model/dmp/dmp-overview';
import { DatasetProfileCriteria } from '../../query/dataset-profile/dataset-profile-criteria';
import { DmpCriteria } from '../../query/dmp/dmp-criteria';
import { ExploreDmpCriteriaModel } from '../../query/explore-dmp/explore-dmp-criteria';
import { RequestItem } from '../../query/request-item';
import { BaseHttpService } from '../http/base-http.service';
import { ConfigurationService } from '../configuration/configuration.service';
@ -142,10 +141,6 @@ export class DmpService {
return this.http.post(this.actionUrl + 'upload', formData, { params: params });
}
getPublicPaged(dataTableRequest: DataTableRequest<ExploreDmpCriteriaModel>, fieldsGroup?: string): Observable<DataTableData<DmpListingModel>> {
return this.http.post<DataTableData<DmpListingModel>>(this.actionUrl + 'public/paged?fieldsGroup=' + fieldsGroup, dataTableRequest, { headers: this.headers });
}
getDatasetProfilesUsedPaged(dataTableRequest: DataTableRequest<DatasetProfileCriteria>) {
return this.http.post<DataTableData<DatasetListingModel>>(this.actionUrl + 'datasetProfilesUsedByDmps/paged', dataTableRequest);
}

View File

@ -1,7 +1,6 @@
import { HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { environment } from '../../../../environments/environment';
import { SearchBarItem } from '../../model/dashboard/search-bar-item';
import { BaseHttpService } from '../http/base-http.service';
import { ConfigurationService } from '../configuration/configuration.service';

View File

@ -8,8 +8,6 @@ import { SearchBarItem } from '@app/core/model/dashboard/search-bar-item';
import { DataTableRequest } from '@app/core/model/data-table/data-table-request';
import { DatasetListingModel } from '@app/core/model/dataset/dataset-listing';
import { DmpListingModel } from '@app/core/model/dmp/dmp-listing';
import { ExploreDatasetCriteriaModel } from '@app/core/query/explore-dataset/explore-dataset-criteria';
import { ExploreDmpCriteriaModel } from '@app/core/query/explore-dmp/explore-dmp-criteria';
import { GrantCriteria } from '@app/core/query/grant/grant-criteria';
import { RequestItem } from '@app/core/query/request-item';
import { AuthService } from '@app/core/services/auth/auth.service';

View File

@ -35,8 +35,6 @@ import { Observable } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import { AuthService } from '@app/core/services/auth/auth.service';
import { isNullOrUndefined } from 'util';
import { ExploreDmpCriteriaModel } from '@app/core/query/explore-dmp/explore-dmp-criteria';
import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile';
@Component({
selector: 'app-dataset-criteria-component',