Merge branch 'Development'

# Conflicts:
#	dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java
#	dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java
This commit is contained in:
dtziotzios 2020-05-13 17:29:52 +03:00
commit d971f02a94
223 changed files with 9653 additions and 2251 deletions

View File

@ -12,7 +12,7 @@ output {
password =>
index =>"opendmp.logs"
#manage_template => true
#template => "/usr/share/logstash/templates/audit/cite_elas_openDMP.json"
#template => "/usr/share/logstash/templates/audit/openDMP.json"
#template_name => "cite.elas.openDMP-audit*"
#template_overwrite => true
}

View File

@ -0,0 +1 @@
PROFILE=staging

View File

@ -1,11 +1,23 @@
FROM openjdk:8-jdk-alpine
RUN apk add --update \
curl \
&& rm -rf /var/cache/apk/*
VOLUME /tmp
ARG PROFILE=production
ENV PROF $PROFILE
ADD web/src/main/resources/ProjectConfiguration.xml /tmp/ProjectConfiguration.xml
ADD web/src/main/resources/ExternalUrls.xml /tmp/ExternalUrls.xml
ADD web/target/web-1.0-SNAPSHOT.jar app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom" ,"-Dspring.profiles.active=${PROF}","-jar","/app.jar"]
FROM maven:3-jdk-8-alpine AS MAVEN_BUILD
COPY pom.xml /build/
COPY data /build/data/
COPY elastic /build/elastic/
COPY logging /build/logging/
COPY queryable /build/queryable/
COPY web /build/web/
WORKDIR /build/
RUN mvn package
FROM openjdk:8-jre-alpine
WORKDIR /app
COPY --from=MAVEN_BUILD /build/web/target/web-1.0-SNAPSHOT.jar /app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom" ,"-Dspring.profiles.active=${PROFILE}","-jar","/app.jar"]

View File

@ -1,7 +1,6 @@
package eu.eudat.data.dao.criteria;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.Grant;
import java.util.Date;
@ -20,6 +19,8 @@ public class DataManagementPlanCriteria extends Criteria<DMP> {
private List<UUID> collaborators;
private List<UUID> datasetTemplates;
private boolean isPublic;
private boolean onlyPublic;
private Short grantStatus;
public Date getPeriodStart() {
return periodStart;
@ -97,4 +98,20 @@ public class DataManagementPlanCriteria extends Criteria<DMP> {
public void setIsPublic(boolean isPublic) {
this.isPublic = isPublic;
}
public boolean isOnlyPublic() {
return onlyPublic;
}
public void setOnlyPublic(boolean onlyPublic) {
this.onlyPublic = onlyPublic;
}
public Short getGrantStatus() {
return grantStatus;
}
public void setGrantStatus(Short grantStatus) {
this.grantStatus = grantStatus;
}
}

View File

@ -33,6 +33,7 @@ public class DatasetProfileCriteria extends Criteria<DatasetProfile> {
private Short filter;
private UUID userId;
private boolean finalized;
private Integer status;
public boolean getAllVersions() { return allVersions; }
public void setAllVersions(boolean allVersions) { this.allVersions = allVersions; }
@ -60,4 +61,12 @@ public class DatasetProfileCriteria extends Criteria<DatasetProfile> {
public void setFinalized(boolean finalized) {
this.finalized = finalized;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
}

View File

@ -9,6 +9,7 @@ import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField;
import eu.eudat.types.grant.GrantStateType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
@ -16,6 +17,7 @@ import org.springframework.stereotype.Component;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@ -73,6 +75,14 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
if (criteria.getDatasetTemplates() != null && !criteria.getDatasetTemplates().isEmpty()) {
query.where((builder, root) -> root.join("associatedDmps", JoinType.LEFT).get("id").in(criteria.getDatasetTemplates()));
}
if (criteria.getGrantStatus() != null) {
if (criteria.getGrantStatus().equals(GrantStateType.FINISHED.getValue().shortValue()))
query.where((builder, root) -> builder.lessThan(root.get("grant").get("enddate"), new Date()));
if (criteria.getGrantStatus().equals(GrantStateType.ONGOING.getValue().shortValue()))
query.where((builder, root) ->
builder.or(builder.greaterThan(root.get("grant").get("enddate"), new Date())
, builder.isNull(root.get("grant").get("enddate"))));
}
query.where((builder, root) -> builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()));
return query;
}

View File

@ -52,6 +52,9 @@ public class DatasetProfileDaoImpl extends DatabaseAccess<DatasetProfile> implem
builder.notEqual(root.get("id"), criteria.getUserId())));
}
}
if (criteria.getStatus() != null) {
query.where(((builder, root) -> builder.equal(root.get("status"), criteria.getStatus())));
}
if (criteria.getFinalized()) {
query.where(((builder, root) -> builder.equal(root.get("status"), DatasetProfile.Status.FINALIZED.getValue())));
} else {

View File

@ -0,0 +1,11 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.entities.DoiFunder;
import java.util.UUID;
public interface DoiFunderDao extends DatabaseAccessLayer<DoiFunder, UUID> {
DoiFunder findFunderByName(String name);
}

View File

@ -0,0 +1,55 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.DoiFunder;
import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@Component("DoiFunderDao")
public class DoiFunderDaoImpl extends DatabaseAccess<DoiFunder> implements DoiFunderDao {
@Autowired
public DoiFunderDaoImpl(DatabaseService<DoiFunder> databaseService) {
super(databaseService);
}
@Override
public DoiFunder findFunderByName(String name) {
return this.asQueryable().toList().stream().filter(doiFunder -> name.contains(doiFunder.getName()) || doiFunder.getName().contains(name)).findFirst().orElse(null);
}
@Override
public DoiFunder createOrUpdate(DoiFunder item) {
return this.getDatabaseService().createOrUpdate(item, DoiFunder.class);
}
@Override
public CompletableFuture<DoiFunder> createOrUpdateAsync(DoiFunder item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
}
@Override
public DoiFunder find(UUID id) {
return this.getDatabaseService().getQueryable(DoiFunder.class).where(((builder, root) -> builder.equal(root.get("id"), id))).getSingle();
}
@Override
public DoiFunder find(UUID id, String hint) {
throw new UnsupportedOperationException();
}
@Override
public void delete(DoiFunder item) {
this.getDatabaseService().delete(item);
}
@Override
public QueryableList<DoiFunder> asQueryable() {
return this.getDatabaseService().getQueryable(DoiFunder.class);
}
}

View File

@ -0,0 +1,15 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.entities.UserAssociation;
import eu.eudat.data.entities.UserInfo;
import java.util.List;
import java.util.UUID;
public interface UserAssociationDao extends DatabaseAccessLayer<UserAssociation, UUID> {
public List<UserAssociation> getAssociated(UserInfo userId);
public Boolean areAssociated(UserInfo firstUser, UserInfo secondUser);
}

View File

@ -0,0 +1,73 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.UserAssociation;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@Component("UserAssociationDao")
public class UserAssociationDaoImpl extends DatabaseAccess<UserAssociation> implements UserAssociationDao {
@Autowired
public UserAssociationDaoImpl(DatabaseService<UserAssociation> databaseService) {
super(databaseService);
}
@Override
public UserAssociation createOrUpdate(UserAssociation item) {
return this.getDatabaseService().createOrUpdate(item, UserAssociation.class);
}
@Override
public CompletableFuture<UserAssociation> createOrUpdateAsync(UserAssociation item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
}
@Override
public UserAssociation find(UUID id) {
return this.getDatabaseService().getQueryable(UserAssociation.class).where(((builder, root) -> builder.equal(root.get("id"), id))).getSingle();
}
@Override
public UserAssociation find(UUID id, String hint) {
throw new UnsupportedOperationException();
}
@Override
public void delete(UserAssociation item) {
this.getDatabaseService().delete(item);
}
@Override
public QueryableList<UserAssociation> asQueryable() {
return this.getDatabaseService().getQueryable(UserAssociation.class);
}
@Override
public List<UserAssociation> getAssociated(UserInfo userId) {
return this.getDatabaseService().getQueryable(UserAssociation.class).where(((builder, root) ->
builder.or(builder.equal(root.get("firstUser"), userId), builder.equal(root.get("secondUser"), userId)))).toList();
}
@Override
public Boolean areAssociated(UserInfo firstUser, UserInfo secondUser) {
return this.getDatabaseService().getQueryable(UserAssociation.class).where(((builder, root) ->
builder.or(
builder.and(
builder.equal(root.get("firstUser"), firstUser),
builder.equal(root.get("secondUser"), secondUser)
),
builder.and(
builder.equal(root.get("secondUser"), firstUser),
builder.equal(root.get("firstUser"), secondUser)
)
))).count() > 0;
}
}

View File

@ -132,6 +132,9 @@ public class DataRepository implements Serializable, DataEntity<DataRepository,
@Override
public void update(DataRepository entity) {
this.label = entity.getLabel();
this.abbreviation = entity.getAbbreviation();
this.uri = entity.getUri();
}

View File

@ -0,0 +1,61 @@
package eu.eudat.data.entities;
import eu.eudat.queryable.queryableentity.DataEntity;
import javax.persistence.*;
import java.util.List;
import java.util.UUID;
@Entity
@Table(name = "\"DoiFunder\"")
public class DoiFunder implements DataEntity<DoiFunder, UUID> {
@Id
private UUID id;
@Column(name = "name")
private String name;
@Column(name = "doi")
private String doi;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDoi() {
return doi;
}
public void setDoi(String doi) {
this.doi = doi;
}
@Override
public void update(DoiFunder entity) {
this.name = entity.name;
this.doi = entity.doi;
}
@Override
public UUID getKeys() {
return id;
}
@Override
public DoiFunder buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
return null;
}
}

View File

@ -139,7 +139,9 @@ public class Registry implements DataEntity<Registry, UUID> {
@Override
public void update(Registry entity) {
this.label = entity.getLabel();
this.abbreviation = entity.getAbbreviation();
this.uri = entity.getUri();
}
@Override

View File

@ -134,7 +134,9 @@ public class Service implements DataEntity<Service, UUID> {
@Override
public void update(Service entity) {
this.label = entity.getLabel();
this.abbreviation = entity.getAbbreviation();
this.uri = entity.getUri();
}
@Override

View File

@ -0,0 +1,66 @@
package eu.eudat.data.entities;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.List;
import java.util.UUID;
@Entity
@Table(name = "\"UserAssociation\"")
public class UserAssociation implements DataEntity<UserAssociation, UUID> {
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"firstUser\"")
private UserInfo firstUser;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"secondUser\"")
private UserInfo secondUser;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public UserInfo getFirstUser() {
return firstUser;
}
public void setFirstUser(UserInfo firstUser) {
this.firstUser = firstUser;
}
public UserInfo getSecondUser() {
return secondUser;
}
public void setSecondUser(UserInfo secondUser) {
this.secondUser = secondUser;
}
@Override
public void update(UserAssociation entity) {
}
@Override
public UUID getKeys() {
return null;
}
@Override
public UserAssociation buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
return null;
}
}

View File

@ -0,0 +1,97 @@
package eu.eudat.elastic.criteria;
import java.util.List;
import java.util.UUID;
public class DmpCriteria extends Criteria {
private String like;
private Short status;
private List<UUID> templates;
private List<UUID> grants;
private List<UUID> collaborators;
private List<UUID> organizations;
private boolean isPublic;
private List<UUID> groupIds;
private boolean allowAllVersions;
private Short grantStatus;
public String getLike() {
return like;
}
public void setLike(String like) {
this.like = like;
}
public Short getStatus() {
return status;
}
public void setStatus(Short status) {
this.status = status;
}
public List<UUID> getTemplates() {
return templates;
}
public void setTemplates(List<UUID> templates) {
this.templates = templates;
}
public List<UUID> getGrants() {
return grants;
}
public void setGrants(List<UUID> grants) {
this.grants = grants;
}
public List<UUID> getCollaborators() {
return collaborators;
}
public void setCollaborators(List<UUID> collaborators) {
this.collaborators = collaborators;
}
public List<UUID> getOrganizations() {
return organizations;
}
public void setOrganizations(List<UUID> organizations) {
this.organizations = organizations;
}
public boolean isPublic() {
return isPublic;
}
public void setPublic(boolean aPublic) {
isPublic = aPublic;
}
public List<UUID> getGroupIds() {
return groupIds;
}
public void setGroupIds(List<UUID> groupIds) {
this.groupIds = groupIds;
}
public boolean isAllowAllVersions() {
return allowAllVersions;
}
public void setAllowAllVersions(boolean allowAllVersions) {
this.allowAllVersions = allowAllVersions;
}
public Short getGrantStatus() {
return grantStatus;
}
public void setGrantStatus(Short grantStatus) {
this.grantStatus = grantStatus;
}
}

View File

@ -0,0 +1,44 @@
package eu.eudat.elastic.entities;
import org.elasticsearch.common.xcontent.XContentBuilder;
import java.io.IOException;
import java.util.Map;
import java.util.UUID;
public class DatasetTempalate implements ElasticEntity<DatasetTempalate> {
private UUID id;
private String name;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public XContentBuilder toElasticEntity(XContentBuilder builder) throws IOException {
builder.startObject();
builder.field("id", this.id.toString());
builder.field("name", this.name);
builder.endObject();
return builder;
}
@Override
public DatasetTempalate fromElasticEntity(Map<String, Object> fields) {
this.id = UUID.fromString((String) fields.get("id"));
this.name = (String) fields.get("name");
return this;
}
}

View File

@ -0,0 +1,297 @@
package eu.eudat.elastic.entities;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
public class Dmp implements ElasticEntity<Dmp> {
private static final Logger logger = LoggerFactory.getLogger(Dmp.class);
public enum DMPStatus {
ACTIVE((short) 0), FINALISED((short) 1),DELETED((short) 99);
private short value;
private DMPStatus(short value) {
this.value = value;
}
public short getValue() {
return value;
}
public static DMPStatus fromInteger(short value) {
switch (value) {
case 0:
return ACTIVE;
case 1:
return FINALISED;
case 99:
return DELETED;
default:
throw new RuntimeException("Unsupported DMP Status");
}
}
}
private UUID id;
private String label;
private String description;
private UUID groupId;
private Short status;
private List<DatasetTempalate> templates;
private List<Collaborator> collaborators;
private List<Organization> organizations;
private Boolean lastVersion;
private Boolean lastPublicVersion;
private Boolean isPublic;
private List<Dataset> datasets;
private UUID grant;
private Short grantStatus;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public UUID getGroupId() {
return groupId;
}
public void setGroupId(UUID groupId) {
this.groupId = groupId;
}
public Short getStatus() {
return status;
}
public void setStatus(Short status) {
this.status = status;
}
public List<DatasetTempalate> getTemplates() {
return templates;
}
public void setTemplates(List<DatasetTempalate> templates) {
this.templates = templates;
}
public List<Collaborator> getCollaborators() {
return collaborators;
}
public void setCollaborators(List<Collaborator> collaborators) {
this.collaborators = collaborators;
}
public List<Organization> getOrganizations() {
return organizations;
}
public void setOrganizations(List<Organization> organizations) {
this.organizations = organizations;
}
public Boolean getLastVersion() {
return lastVersion;
}
public void setLastVersion(Boolean lastVersion) {
this.lastVersion = lastVersion;
}
public Boolean getLastPublicVersion() {
return lastPublicVersion;
}
public void setLastPublicVersion(Boolean lastPublicVersion) {
this.lastPublicVersion = lastPublicVersion;
}
public Boolean getPublic() {
return isPublic;
}
public void setPublic(Boolean aPublic) {
isPublic = aPublic;
}
public List<Dataset> getDatasets() {
return datasets;
}
public void setDatasets(List<Dataset> datasets) {
this.datasets = datasets;
}
public UUID getGrant() {
return grant;
}
public void setGrant(UUID grant) {
this.grant = grant;
}
public Short getGrantStatus() {
return grantStatus;
}
public void setGrantStatus(Short grantStatus) {
this.grantStatus = grantStatus;
}
@Override
public XContentBuilder toElasticEntity(XContentBuilder builder) throws IOException {
builder.startObject();
if (this.id != null) {
builder.field(MapKey.ID.getName(), this.id.toString());
}
builder.field(MapKey.LABEL.getName(), this.label);
builder.field(MapKey.DESCRIPTION.getName(), this.description);
if (this.groupId != null) {
builder.field(MapKey.GROUPID.getName(), this.groupId.toString());
}
builder.field(MapKey.STATUS.getName(), this.status);
if (this.templates != null && !this.templates.isEmpty()) {
builder.startArray(MapKey.TEMPLATES.getName());
this.templates.forEach(template -> {
try {
template.toElasticEntity(builder);
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
});
builder.endArray();
}
if (this.collaborators != null && !this.collaborators.isEmpty()) {
builder.startArray(MapKey.COLLABORATORS.getName());
this.collaborators.forEach(collaborator -> {
try {
collaborator.toElasticEntity(builder);
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
});
builder.endArray();
}
if (this.organizations != null && !this.organizations.isEmpty()) {
builder.startArray(MapKey.ORGANIZATIONS.getName());
this.organizations.forEach(organization -> {
try {
organization.toElasticEntity(builder);
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
});
builder.endArray();
}
builder.field(MapKey.LASTVERSION.getName(), this.lastVersion);
builder.field(MapKey.LASTPUBLICVERSION.getName(), this.lastPublicVersion);
builder.field(MapKey.ISPUBLIC.getName(), this.isPublic);
if (datasets != null && !this.datasets.isEmpty()) {
builder.startArray(MapKey.DATASETS.getName());
this.datasets.forEach(dataset -> {
try {
if (dataset != null) {
dataset.toElasticEntity(builder);
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
});
builder.endArray();
}
if (this.grant != null) {
builder.field(MapKey.GRANT.getName(), this.grant.toString());
}
builder.field(MapKey.GRANTSTATUS.getName(), this.grantStatus);
builder.endObject();
return builder;
}
@Override
public Dmp fromElasticEntity(Map<String, Object> fields) {
this.id = UUID.fromString((String) fields.get(MapKey.ID.getName()));
this.label = (String) fields.get(MapKey.LABEL.getName());
this.description = (String) fields.get(MapKey.DESCRIPTION.getName());
if (fields.get(MapKey.GROUPID.getName()) != null) {
this.groupId = UUID.fromString((String) fields.get(MapKey.GROUPID.getName()));
}
this.status = Short.valueOf(fields.get(MapKey.STATUS.getName()).toString());
if (fields.get(MapKey.TEMPLATES.getName()) != null) {
this.templates = ((List<HashMap<String, Object>>) fields.get(MapKey.TEMPLATES.getName())).stream().map(hashMap -> new DatasetTempalate().fromElasticEntity(hashMap)).collect(Collectors.toList());
}
if (fields.get(MapKey.COLLABORATORS.getName()) != null) {
this.collaborators = ((List<HashMap<String, Object>>) fields.get(MapKey.COLLABORATORS.getName())).stream().map(map -> new Collaborator().fromElasticEntity(map)).collect(Collectors.toList());
}
if (fields.get(MapKey.ORGANIZATIONS.getName()) != null) {
this.organizations = ((List<HashMap<String, Object>>) fields.get(MapKey.ORGANIZATIONS.getName())).stream().map(map -> new Organization().fromElasticEntity(map)).collect(Collectors.toList());
}
this.lastVersion = (Boolean) fields.get(MapKey.LASTVERSION.getName());
this.lastPublicVersion = (Boolean) fields.get(MapKey.LASTPUBLICVERSION.getName());
this.isPublic = (Boolean) fields.get(MapKey.ISPUBLIC.getName());
if (fields.get(MapKey.DATASETS.getName()) != null) {
this.datasets = ((List<HashMap<String, Object>>) fields.get(MapKey.DATASETS.getName())).stream().map(map -> new Dataset().fromElasticEntity(map)).collect(Collectors.toList());
}
this.grant = UUID.fromString((String) fields.get(MapKey.GRANT.getName()));
if (fields.get(MapKey.GRANTSTATUS.getName()) != null) {
this.grantStatus = Short.valueOf(fields.get(MapKey.GRANTSTATUS.getName()).toString());
}
return this;
}
public enum MapKey {
ID ("id"),
LABEL ("label"),
DESCRIPTION ("description"),
GROUPID ("groupId"),
STATUS ("status"),
TEMPLATES ("templates"),
COLLABORATORS ("collaborators"),
ORGANIZATIONS ("organizations"),
LASTVERSION ("lastVersion"),
LASTPUBLICVERSION ("lastPublicVersion"),
ISPUBLIC ("isPublic"),
DATASETS ("datasets"),
GRANT ("grant"),
GRANTSTATUS ("grantStatus");
private final String name;
private MapKey(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
}

View File

@ -2,122 +2,174 @@ package eu.eudat.elastic.repository;
import eu.eudat.elastic.criteria.DatasetCriteria;
import eu.eudat.elastic.entities.Dataset;
import eu.eudat.elastic.entities.Dmp;
import eu.eudat.elastic.entities.Tag;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.apache.lucene.search.join.ScoreMode;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.core.CountRequest;
import org.elasticsearch.client.core.CountResponse;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.InnerHitBuilder;
import org.elasticsearch.index.query.NestedQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.bucket.filter.FiltersAggregationBuilder;
import org.elasticsearch.search.aggregations.bucket.filter.ParsedFilters;
import org.elasticsearch.search.aggregations.bucket.nested.NestedAggregationBuilder;
import org.elasticsearch.search.aggregations.bucket.nested.ParsedNested;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Service("datasetRepository")
public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteria> {
@Autowired
public DatasetRepository(RestHighLevelClient client) {
private final DmpRepository dmpRepository;
public DatasetRepository(RestHighLevelClient client, DmpRepository dmpRepository) {
super(client);
this.dmpRepository = dmpRepository;
}
@Override
public Dataset createOrUpdate(Dataset entity) throws IOException {
if (this.getClient() != null) {
XContentBuilder builder = XContentFactory.jsonBuilder();
IndexRequest request = new IndexRequest("datasets").id(entity.getId()).source(entity.toElasticEntity(builder));//new IndexRequest("datasets", "doc", entity.getId()).source(entity.toElasticEntity(builder));
Dmp dmp = this.dmpRepository.findDocument(entity.getDmp().toString());
boolean found = false;
if (dmp.getDatasets() != null && !dmp.getDatasets().isEmpty()) {
for (int i = 0; i < dmp.getDatasets().size(); i++) {
if (dmp.getDatasets().get(i).getId().equals(entity.getId())) {
dmp.getDatasets().set(i, entity);
found = true;
break;
}
}
}
if (!found) {
if (dmp.getDatasets() == null) {
dmp.setDatasets(new ArrayList<>());
}
dmp.getDatasets().add(entity);
}
IndexRequest request = new IndexRequest("dmps").id(dmp.getId().toString()).source(dmp.toElasticEntity(builder));//new IndexRequest("datasets", "doc", entity.getId()).source(entity.toElasticEntity(builder));
this.getClient().index(request, RequestOptions.DEFAULT);
return entity;
}
return null;
}
@Override
public Dataset findDocument(String id) throws IOException {
GetRequest request = new GetRequest("datasets",id);
GetResponse response = this.getClient().get(request, RequestOptions.DEFAULT);
return new Dataset().fromElasticEntity(response.getSourceAsMap());
if (this.getClient() != null) {
SearchRequest searchRequest = new SearchRequest("dmps");
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().should(QueryBuilders.termQuery("datasets.id.keyword", id));
NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery( "datasets", boolQuery, ScoreMode.Avg).innerHit(new InnerHitBuilder());
searchSourceBuilder.query(nestedQueryBuilder);
searchRequest.source(searchSourceBuilder);
SearchResponse response = this.getClient().search(searchRequest, RequestOptions.DEFAULT);
return ((Stream<Dataset>)Arrays.stream(response.getHits().getHits())
.map(hit -> hit.getInnerHits().values()).flatMap(Collection::stream)
.map(SearchHits::getHits).flatMap(Arrays::stream)
.map(x -> new Dataset().fromElasticEntity(this.transformFromString(x.getSourceAsString(), Map.class)))).findFirst().orElse(null);
// GetRequest request = new GetRequest("datasets", id);
// GetResponse response = this.getClient().get(request, RequestOptions.DEFAULT);
// return new Dataset().fromElasticEntity(response.getSourceAsMap());
}
return null;
}
@Override
public List<Dataset> query(DatasetCriteria criteria) throws IOException {
SearchRequest searchRequest = new SearchRequest("datasets");
if (this.getClient() != null) {
SearchRequest searchRequest = new SearchRequest("dmps");
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
CountRequest countRequest = new CountRequest("datasets");
countRequest.query(QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery("status.keyword", Stream.of(Dataset.Status.DELETED.getValue(), Dataset.Status.CANCELED.getValue()).collect(Collectors.toList()))));
/*CountRequest countRequest = new CountRequest("dmps").routing("datasets").routing("id");
countRequest.query(QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery("datasets.status.keyword", Stream.of(Dataset.Status.DELETED.getValue(), Dataset.Status.CANCELED.getValue()).collect(Collectors.toList()))));
CountResponse countResponse = getClient().count(countRequest, RequestOptions.DEFAULT);
Long count = countResponse.getCount();
Long count = countResponse.getCount();*/
SearchRequest countRequest = new SearchRequest("dmps");
NestedAggregationBuilder nestedAggregationBuilder = AggregationBuilders.nested("by_dataset", "datasets");
FiltersAggregationBuilder filtersAggregationBuilder = AggregationBuilders.filters("dataset_query", QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery("datasets.status.keyword", Stream.of(Dataset.Status.DELETED.getValue(), Dataset.Status.CANCELED.getValue()).collect(Collectors.toList()))));
nestedAggregationBuilder.subAggregation(filtersAggregationBuilder);
SearchSourceBuilder countSourceBuilder = new SearchSourceBuilder();
countSourceBuilder.aggregation(nestedAggregationBuilder);
countRequest.source(countSourceBuilder);
SearchResponse countResponse = getClient().search(countRequest, RequestOptions.DEFAULT);
Long count = ((ParsedFilters)((ParsedNested)countResponse.getAggregations().asMap().get("by_dataset")).getAggregations().get("dataset_query")).getBuckets().get(0).getDocCount();
searchSourceBuilder.size(count.intValue());
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery("status.keyword", Stream.of(Dataset.Status.DELETED.getValue(), Dataset.Status.CANCELED.getValue()).collect(Collectors.toList())));
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery("datasets.status", Stream.of(Dataset.Status.DELETED.getValue(), Dataset.Status.CANCELED.getValue()).collect(Collectors.toList())));
if (criteria.isPublic()) {
boolQuery = boolQuery.should(QueryBuilders.termQuery("public.keyword", "true"));
boolQuery = boolQuery.should(QueryBuilders.termQuery("status.keyword", Dataset.Status.FINALISED.getValue()));
boolQuery = boolQuery.should(QueryBuilders.termQuery("lastPublicVersion.keyword", "true"));
boolQuery = boolQuery.should(QueryBuilders.termQuery("datasets.public", "true"));
boolQuery = boolQuery.should(QueryBuilders.termQuery("datasets.status", Dataset.Status.FINALISED.getValue()));
boolQuery = boolQuery.should(QueryBuilders.termQuery("datasets.lastPublicVersion", "true"));
}
if (criteria.getLike() != null && !criteria.getLike().isEmpty()) {
boolQuery = boolQuery.should(QueryBuilders.queryStringQuery(criteria.getLike()).fields(Stream.of(new Object[][] {
{ "label", 1.0f },
{ "description", 1.0f },
{ "formData", 1.0f }
boolQuery = boolQuery.should(QueryBuilders.queryStringQuery(criteria.getLike()).allowLeadingWildcard(true).fields(Stream.of(new Object[][]{
{"datasets.label", 1.0f},
{"datasets.description", 1.0f},
{"datasets.formData", 1.0f}
}).collect(Collectors.toMap(data -> (String) data[0], data -> (Float) data[1]))));
}
if (criteria.getDatasetTemplates() != null && criteria.getDatasetTemplates().size() > 0) {
boolQuery = boolQuery.should(QueryBuilders.termsQuery("template.keyword", criteria.getDatasetTemplates().stream().map(UUID::toString).collect(Collectors.toList())));
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.template", criteria.getDatasetTemplates().stream().map(UUID::toString).collect(Collectors.toList())));
}
if (criteria.getStatus() != null) {
boolQuery = boolQuery.should(QueryBuilders.termQuery("status.keyword", criteria.getStatus().toString()));
boolQuery = boolQuery.should(QueryBuilders.termQuery("datasets.status", criteria.getStatus().toString()));
}
if (criteria.getDmps() != null && criteria.getDmps().size() > 0) {
boolQuery = boolQuery.should(QueryBuilders.termsQuery("dmp.keyword", criteria.getDmps().stream().map(UUID::toString).collect(Collectors.toList())));
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.dmp", criteria.getDmps().stream().map(UUID::toString).collect(Collectors.toList())));
}
if (criteria.getGroupIds() != null && criteria.getGroupIds().size() > 0) {
boolQuery = boolQuery.should(QueryBuilders.termsQuery("group.keyword", criteria.getGroupIds().stream().map(UUID::toString).collect(Collectors.toList())));
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.group", criteria.getGroupIds().stream().map(UUID::toString).collect(Collectors.toList())));
}
if (criteria.getGrants() != null && criteria.getGrants().size() > 0) {
boolQuery = boolQuery.should(QueryBuilders.termsQuery("grant.keyword", criteria.getGrants().stream().map(UUID::toString).collect(Collectors.toList())));
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.grant", criteria.getGrants().stream().map(UUID::toString).collect(Collectors.toList())));
}
if (criteria.getGrantStatus() != null) {
boolQuery = boolQuery.should(QueryBuilders.termQuery("grantStatus.keyword", criteria.getGrantStatus().toString()));
boolQuery = boolQuery.should(QueryBuilders.termQuery("datasets.grantStatus", criteria.getGrantStatus().toString()));
}
if (criteria.getCollaborators() != null && criteria.getCollaborators().size() > 0) {
boolQuery = boolQuery.should(QueryBuilders.termsQuery("collaborators.id.keyword", criteria.getCollaborators().stream().map(UUID::toString).collect(Collectors.toList())));
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.collaborators.id", criteria.getCollaborators().stream().map(UUID::toString).collect(Collectors.toList())));
}
if (!criteria.isPublic()) {
if (criteria.getAllowAllVersions() != null && !criteria.getAllowAllVersions()) {
boolQuery = boolQuery.should(QueryBuilders.termQuery("lastVersion.keyword", "true"));
boolQuery = boolQuery.should(QueryBuilders.termQuery("datasets.lastVersion", "true"));
}
}
if (criteria.getOrganiztions() != null && criteria.getOrganiztions().size() > 0) {
boolQuery = boolQuery.should(QueryBuilders.termsQuery("organizations.id.keyword", criteria.getOrganiztions()));
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.organizations.id", criteria.getOrganiztions()));
}
if (criteria.getTags() != null && criteria.getTags().size() > 0) {
boolQuery = boolQuery.should(QueryBuilders.termsQuery("tags.name.keyword", criteria.getTags().stream().map(Tag::getName).collect(Collectors.toList())));
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.tags.name", criteria.getTags().stream().map(Tag::getName).collect(Collectors.toList())));
}
if (boolQuery.should().isEmpty() && boolQuery.mustNot().isEmpty()) {
@ -125,25 +177,36 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
} else {
boolQuery.minimumShouldMatch(boolQuery.should().size());
}
searchSourceBuilder.query(boolQuery);
NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("datasets", boolQuery, ScoreMode.Avg).innerHit(new InnerHitBuilder());
searchSourceBuilder.query(nestedQueryBuilder);
searchRequest.source(searchSourceBuilder);
SearchResponse response = this.getClient().search(searchRequest, RequestOptions.DEFAULT);
return Arrays.stream(response.getHits().getHits()).map(x -> this.transformFromString(x.getSourceAsString(), Dataset.class)).collect(Collectors.toList());
return ((Stream<Dataset>)Arrays.stream(response.getHits().getHits())
.map(hit -> hit.getInnerHits().values()).flatMap(Collection::stream)
.map(SearchHits::getHits).flatMap(Arrays::stream)
.map(x -> new Dataset().fromElasticEntity(this.transformFromString(x.getSourceAsString(), Map.class)))).collect(Collectors.toList());
}
return null;
}
@Override
public boolean exists() throws IOException {
GetIndexRequest request = new GetIndexRequest("datasets");
if (this.getClient() != null) {
GetIndexRequest request = new GetIndexRequest("dmps");
// request.indices("datasets");
return this.getClient().indices().exists(request, RequestOptions.DEFAULT);
}
return false;
}
@Override
public void clear() throws IOException {
if (exists()) {
//DON'T
/* if (exists()) {
DeleteByQueryRequest delete = new DeleteByQueryRequest("datasets");
delete.setQuery(QueryBuilders.matchAllQuery());
this.getClient().deleteByQuery(delete, RequestOptions.DEFAULT);
}
}*/
}
}

View File

@ -0,0 +1,185 @@
package eu.eudat.elastic.repository;
import eu.eudat.elastic.criteria.DmpCriteria;
import eu.eudat.elastic.entities.Dmp;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.core.CountRequest;
import org.elasticsearch.client.core.CountResponse;
import org.elasticsearch.client.indices.CreateIndexRequest;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.client.indices.PutMappingRequest;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Service("dmpRepository")
public class DmpRepository extends ElasticRepository<Dmp, DmpCriteria> {
private static final Logger logger = LoggerFactory.getLogger(DmpRepository.class);
@Autowired
public DmpRepository(RestHighLevelClient client) {
super(client);
}
private void generateMapping() throws IOException {
if (this.getClient() != null) {
XContentBuilder builder = XContentFactory.jsonBuilder();
builder.startObject();
builder.startObject("properties");
builder.startObject("datasets");
builder.field("type", "nested");
builder.endObject();
builder.endObject();
builder.endObject();
PutMappingRequest putMappingRequest = new PutMappingRequest("dmps");
putMappingRequest.source(builder);
this.getClient().indices().putMapping(putMappingRequest, RequestOptions.DEFAULT);
}
}
@Override
public Dmp createOrUpdate(Dmp entity) throws IOException {
if (this.getClient() != null) {
XContentBuilder builder = XContentFactory.jsonBuilder();
IndexRequest request = new IndexRequest("dmps").id(entity.getId().toString()).source(entity.toElasticEntity(builder));
IndexResponse response = this.getClient().index(request, RequestOptions.DEFAULT);
return entity;
}
return null;
}
@Override
public Dmp findDocument(String id) throws IOException {
if (this.getClient() != null) {
GetRequest request = new GetRequest("dmps", id);
GetResponse response = this.getClient().get(request, RequestOptions.DEFAULT);
return new Dmp().fromElasticEntity(response.getSourceAsMap());
}
return null;
}
@Override
public List<Dmp> query(DmpCriteria criteria) throws IOException {
if (this.getClient() != null) {
SearchRequest searchRequest = new SearchRequest("dmps");
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
CountRequest countRequest = new CountRequest("dmps");
countRequest.query(QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery(Dmp.MapKey.STATUS.getName(), Collections.singletonList(Dmp.DMPStatus.DELETED.getValue()))));
CountResponse countResponse = getClient().count(countRequest, RequestOptions.DEFAULT);
Long count = countResponse.getCount();
searchSourceBuilder.size(count.intValue());
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery(Dmp.MapKey.STATUS.getName(), Collections.singletonList(Dmp.DMPStatus.DELETED.getValue())));
if (criteria.isPublic()) {
boolQuery = boolQuery.should(QueryBuilders.termQuery(Dmp.MapKey.ISPUBLIC.getName(), true));
boolQuery = boolQuery.should(QueryBuilders.termQuery(Dmp.MapKey.STATUS.getName(), Dmp.DMPStatus.FINALISED.getValue()));
}
if (criteria.getLike() != null && !criteria.getLike().isEmpty()) {
boolQuery = boolQuery.should(QueryBuilders.queryStringQuery(criteria.getLike()).fields(Stream.of(new Object[][]{
{Dmp.MapKey.LABEL.getName(), 1.0f},
{Dmp.MapKey.DESCRIPTION.getName(), 1.0f}
}).collect(Collectors.toMap(data -> (String) data[0], data -> (Float) data[1]))));
}
if (criteria.getTemplates() != null && criteria.getTemplates().size() > 0) {
boolQuery = boolQuery.should(QueryBuilders.termsQuery(Dmp.MapKey.TEMPLATES.getName() + ".id.keyword", criteria.getTemplates().stream().map(UUID::toString).collect(Collectors.toList())));
}
if (criteria.getStatus() != null) {
boolQuery = boolQuery.should(QueryBuilders.termQuery(Dmp.MapKey.STATUS.getName(), criteria.getStatus().intValue()));
}
if (criteria.getGroupIds() != null && criteria.getGroupIds().size() > 0) {
boolQuery = boolQuery.should(QueryBuilders.termsQuery(Dmp.MapKey.GROUPID.getName(), criteria.getGroupIds().stream().map(UUID::toString).collect(Collectors.toList())));
}
if (criteria.getGrants() != null && criteria.getGrants().size() > 0) {
boolQuery = boolQuery.should(QueryBuilders.termsQuery(Dmp.MapKey.GRANT.getName() + ".keyword", criteria.getGrants().stream().map(UUID::toString).collect(Collectors.toList())));
}
if (criteria.getCollaborators() != null && criteria.getCollaborators().size() > 0) {
boolQuery = boolQuery.should(QueryBuilders.termsQuery(Dmp.MapKey.COLLABORATORS.getName() + ".keyword", criteria.getCollaborators().stream().map(UUID::toString).collect(Collectors.toList())));
}
if (!criteria.isAllowAllVersions()) {
boolQuery = boolQuery.should(QueryBuilders.termQuery(criteria.isPublic() ? Dmp.MapKey.LASTPUBLICVERSION.getName() : Dmp.MapKey.LASTVERSION.getName(), true));
}
if (criteria.getOrganizations() != null && criteria.getOrganizations().size() > 0) {
boolQuery = boolQuery.should(QueryBuilders.termsQuery(Dmp.MapKey.ORGANIZATIONS.getName() + ".id.keyword", criteria.getOrganizations().stream().map(UUID::toString).collect(Collectors.toList())));
}
if (criteria.getGrantStatus() != null) {
boolQuery = boolQuery.should(QueryBuilders.termQuery(Dmp.MapKey.GRANTSTATUS.getName(), criteria.getGrantStatus()));
}
if (boolQuery.should().isEmpty() && boolQuery.mustNot().isEmpty()) {
boolQuery = boolQuery.should(QueryBuilders.matchAllQuery());
} else {
boolQuery.minimumShouldMatch(boolQuery.should().size());
}
searchSourceBuilder.query(boolQuery);
searchRequest.source(searchSourceBuilder);
SearchResponse response = this.getClient().search(searchRequest, RequestOptions.DEFAULT);
return Arrays.stream(response.getHits().getHits()).map(x -> new Dmp().fromElasticEntity((Map<String, Object>) this.transformFromString(x.getSourceAsString(), Map.class))).collect(Collectors.toList());
}
return null;
}
public boolean createIndex() {
try {
if (!this.exists()) {
CreateIndexRequest createIndexRequest = new CreateIndexRequest("dmps");
this.getClient().indices().create(createIndexRequest, RequestOptions.DEFAULT);
this.generateMapping();
}
return true;
} catch (Exception e) {
logger.error(e.getMessage(), e);
return false;
}
}
@Override
public boolean exists() throws IOException {
if (this.getClient() != null) {
GetIndexRequest request = new GetIndexRequest("dmps");
return this.getClient().indices().exists(request, RequestOptions.DEFAULT);
}
return false;
}
@Override
public void clear() throws IOException {
if (exists()) {
DeleteByQueryRequest delete = new DeleteByQueryRequest("dmps");
delete.setQuery(QueryBuilders.matchAllQuery());
this.getClient().deleteByQuery(delete, RequestOptions.DEFAULT);
DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest("dmps");
this.getClient().indices().delete(deleteIndexRequest, RequestOptions.DEFAULT);
}
}
}

View File

@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.elastic.criteria.Criteria;
import eu.eudat.elastic.entities.ElasticEntity;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.slf4j.Logger;
@ -23,8 +24,15 @@ public abstract class ElasticRepository<T extends ElasticEntity,C extends Criter
}
public ElasticRepository(RestHighLevelClient client) {
try {
if (client.ping(RequestOptions.DEFAULT)) {
this.client = client;
}
} catch (IOException e) {
logger.warn("Unable to connect to Elastic Services");
this.client = null;
}
}
public <T> T transformFromString(String value, Class<T> tClass) {
ObjectMapper mapper = new ObjectMapper();

View File

@ -6,6 +6,7 @@ import eu.eudat.criteria.DMPCriteria;
import eu.eudat.data.dao.criteria.DynamicFieldsCriteria;
import eu.eudat.data.dao.criteria.RequestItem;
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;
@ -81,17 +82,15 @@ public class DMPs extends BaseController {
this.configLoader = configLoader;
}
/*@Transactional
@RequestMapping(method = RequestMethod.GET, value = {"{id}/unlock"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DMP>> unlock(@PathVariable(value = "id") UUID id, Principal principal) throws Exception {
this.dataManagementPlanManager.unlock(id);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Unlocked"));
}*/
/*
* Data Retrieval
* */
@RequestMapping(method = RequestMethod.POST, value = {"/paged"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanListingModel>>> getPaged(@Valid @RequestBody DataManagementPlanTableRequest dataManagementPlanTableRequest, @RequestParam String fieldsGroup, Principal principal) throws Exception {
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanListingModel>>> getPaged(@Valid @RequestBody DataManagementPlanTableRequest dataManagementPlanTableRequest,
@RequestParam String fieldsGroup,
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
DataTableData<DataManagementPlanListingModel> dataTable = this.dataManagementPlanManager.getPaged(dataManagementPlanTableRequest, principal, fieldsGroup);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
}
@ -99,11 +98,11 @@ public class DMPs extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = {"{id}"})
public @ResponseBody
ResponseEntity getSingle(@PathVariable String id, @RequestHeader("Content-Type") String contentType,
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IllegalAccessException, InstantiationException, IOException {
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
if (contentType.equals("application/xml") || contentType.equals("application/msword")) {
return this.dataManagementPlanManager.getDocument(id, contentType, principal, this.configLoader);
} else {
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(id, principal);
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(id, principal, false);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
}
}
@ -115,17 +114,11 @@ public class DMPs extends BaseController {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
}
@RequestMapping(method = RequestMethod.GET, value = {"rda/{id}"})
public @ResponseBody
ResponseEntity getRDAJsonDocument(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IOException {
return this.dataManagementPlanManager.getRDAJsonDocument(id, datasetManager, principal);
}
@RequestMapping(method = RequestMethod.GET, value = {"/overview/{id}"})
public @ResponseBody
ResponseEntity getOverviewSingle(@PathVariable String id, Principal principal) {
ResponseEntity getOverviewSingle(@PathVariable String id,@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) {
try {
DataManagementPlanOverviewModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSingle(id, principal);
DataManagementPlanOverviewModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSingle(id, principal, false);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
} catch (Exception e) {
if (e instanceof UnauthorisedException) {
@ -138,26 +131,71 @@ public class DMPs extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = {"/public/{id}"})
public @ResponseBody
ResponseEntity getSinglePublic(@PathVariable String id) {
try {
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSinglePublic(id, this.dynamicGrantConfiguration);
ResponseEntity getSinglePublic(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
// try {
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(id, principal, true);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
} catch (Exception ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
}
// } catch (Exception ex) {
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
// }
}
@RequestMapping(method = RequestMethod.GET, value = {"/publicOverview/{id}"})
public @ResponseBody
ResponseEntity getOverviewSinglePublic(@PathVariable String id) {
try {
DataManagementPlanOverviewModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSinglePublic(id);
ResponseEntity getOverviewSinglePublic(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
// try {
DataManagementPlanOverviewModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSingle(id, principal, true);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanOverviewModel>().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()));
// } catch (Exception ex) {
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
// }
}
@RequestMapping(method = RequestMethod.POST, value = {"/dynamic"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<List<Tuple<String, String>>>> getWithCriteria(@RequestBody RequestItem<DynamicFieldsCriteria> criteriaRequestItem, Principal principal) throws InstantiationException, IllegalAccessException {
List<Tuple<String, String>> dataTable = this.dataManagementPlanManager.getDynamicFields(criteriaRequestItem.getCriteria().getId(), this.dynamicGrantConfiguration, criteriaRequestItem.getCriteria());
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Tuple<String, String>>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
}
/*
* Data Export
* */
@RequestMapping(method = RequestMethod.GET, value = {"rda/{id}"})
public @ResponseBody
ResponseEntity getRDAJsonDocument(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IOException {
return this.dataManagementPlanManager.getRDAJsonDocument(id, datasetManager, principal);
}
@RequestMapping(method = RequestMethod.GET, value = {"/getPDF/{id}"})
public @ResponseBody
ResponseEntity<byte[]> getPDFDocument(@PathVariable String id, @RequestHeader("Content-Type") String contentType,
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IllegalAccessException, IOException, InstantiationException, InterruptedException {
FileEnvelope file = this.dataManagementPlanManager.getWordDocument(id, principal, configLoader);
String name = file.getFilename().substring(0, file.getFilename().length() - 5);
File pdffile = datasetManager.convertToPDF(file, environment);
InputStream resource = new FileInputStream(pdffile);
logger.info("Mime Type of " + name + " is " +
new MimetypesFileTypeMap().getContentType(file.getFile()));
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(pdffile.length());
responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
responseHeaders.set("Content-Disposition", "attachment;filename=" + name + ".pdf");
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
byte[] content = org.apache.poi.util.IOUtils.toByteArray(resource);
resource.close();
Files.deleteIfExists(file.getFile().toPath());
Files.deleteIfExists(pdffile.toPath());
return new ResponseEntity<>(content, responseHeaders, HttpStatus.OK);
}
/*
* Data Management
* */
@Transactional
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public @ResponseBody
@ -191,42 +229,11 @@ public class DMPs extends BaseController {
try {
this.dataManagementPlanManager.delete(id);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully Deleted Datamanagement Plan"));
} catch (DMPWithDatasetsDeleteException exception) {
} catch (DMPWithDatasetsDeleteException | IOException exception) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DMP>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
}
}
@RequestMapping(method = RequestMethod.POST, value = {"/dynamic"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<List<Tuple<String, String>>>> getWithCriteria(@RequestBody RequestItem<DynamicFieldsCriteria> criteriaRequestItem, Principal principal) throws InstantiationException, IllegalAccessException {
List<Tuple<String, String>> dataTable = this.dataManagementPlanManager.getDynamicFields(criteriaRequestItem.getCriteria().getId(), this.dynamicGrantConfiguration, criteriaRequestItem.getCriteria());
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Tuple<String, String>>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
}
@RequestMapping(method = RequestMethod.GET, value = {"/getPDF/{id}"})
public @ResponseBody
ResponseEntity<byte[]> getPDFDocument(@PathVariable String id, @RequestHeader("Content-Type") String contentType,
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IllegalAccessException, IOException, InstantiationException, InterruptedException {
FileEnvelope file = this.dataManagementPlanManager.getWordDocument(id, principal, configLoader);
String name = file.getFilename().substring(0, file.getFilename().length() - 5);
File pdffile = datasetManager.convertToPDF(file, environment);
InputStream resource = new FileInputStream(pdffile);
logger.info("Mime Type of " + name + " is " +
new MimetypesFileTypeMap().getContentType(file.getFile()));
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(pdffile.length());
responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
responseHeaders.set("Content-Disposition", "attachment;filename=" + name + ".pdf");
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
byte[] content = org.apache.poi.util.IOUtils.toByteArray(resource);
resource.close();
Files.deleteIfExists(file.getFile().toPath());
Files.deleteIfExists(pdffile.toPath());
return new ResponseEntity<>(content, responseHeaders, HttpStatus.OK);
}
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
public ResponseEntity<ResponseItem> dmpUpload(@RequestParam("file") MultipartFile[] files, Principal principal) throws Exception {
if (files[0].getContentType().equals(APPLICATION_JSON.toString())) {
@ -238,29 +245,6 @@ public class DMPs extends BaseController {
.status(ApiMessageCode.SUCCESS_MESSAGE));
}
@RequestMapping(method = RequestMethod.POST, value = {"/public/paged"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanListingModel>>> getPublicPaged(@RequestBody DataManagmentPlanPublicTableRequest dmpTableRequest,
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal,
@RequestParam String fieldsGroup) throws Exception {
DataTableData<DataManagementPlanListingModel> dmp = this.dataManagementPlanManager.getPublicPaged(dmpTableRequest, fieldsGroup, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dmp));
}
@RequestMapping(method = RequestMethod.POST, value = {"/test"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<Map>>> test(@RequestBody DMPCriteria criteria, @ClaimedAuthorities(claims = {Authorities.ANONYMOUS}) Principal principal) throws Exception {
DatabaseRepository dbRepo = this.getApiContext().getOperationsContext().getDatabaseRepository();
DMPQuery query = criteria.buildQuery(dbRepo);
List<Map> models = query.getQuery().toListWithFields();
DataTableData<Map> dmp = new DataTableData<>();
dmp.setData(models);
dmp.setTotalCount(query.getQuery().count());
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<Map>>().status(ApiMessageCode.NO_MESSAGE).payload(dmp));
}
@RequestMapping(method = RequestMethod.GET, value = {"/makepublic/{id}"})
public ResponseEntity<ResponseItem<DMP>> makePublic(@PathVariable String id, Principal principal) {
try {
@ -282,6 +266,10 @@ public class DMPs extends BaseController {
}
}
/*
* DOI Generation
* */
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/createZenodoDoi/{id}"})
public ResponseEntity<ResponseItem<String>> createZenodoDoi(@PathVariable String id, Principal principal) {
@ -293,4 +281,58 @@ public class DMPs extends BaseController {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<String>().status(ApiMessageCode.ERROR_MESSAGE).message(e.getMessage()));
}
}
/*
* Data Index
* */
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/index"})
public @ResponseBody
ResponseEntity<ResponseItem<Dataset>> generateIndex(Principal principal) throws Exception {
this.dataManagementPlanManager.generateIndex(principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.data.entities.Dataset>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Generated").payload(null));
}
@Transactional
@RequestMapping(method = RequestMethod.DELETE, value = {"/index"})
public @ResponseBody
ResponseEntity<ResponseItem<Dataset>> clearIndex(Principal principal) throws Exception {
this.dataManagementPlanManager.clearIndex(principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.data.entities.Dataset>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Cleared").payload(null));
}
/*
* Misc
* */
@RequestMapping(method = RequestMethod.POST, value = {"/test"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<Map>>> test(@RequestBody DMPCriteria criteria, @ClaimedAuthorities(claims = {Authorities.ANONYMOUS}) Principal principal) throws Exception {
DatabaseRepository dbRepo = this.getApiContext().getOperationsContext().getDatabaseRepository();
DMPQuery query = criteria.buildQuery(dbRepo);
List<Map> models = query.getQuery().toListWithFields();
DataTableData<Map> dmp = new DataTableData<>();
dmp.setData(models);
dmp.setTotalCount(query.getQuery().count());
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<Map>>().status(ApiMessageCode.NO_MESSAGE).payload(dmp));
}
/*@RequestMapping(method = RequestMethod.POST, value = {"/public/paged"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanListingModel>>> getPublicPaged(@RequestBody DataManagmentPlanPublicTableRequest dmpTableRequest,
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal,
@RequestParam String fieldsGroup) throws Exception {
DataTableData<DataManagementPlanListingModel> dmp = this.dataManagementPlanManager.getPublicPaged(dmpTableRequest, fieldsGroup, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dmp));
}*/
/*@Transactional
@RequestMapping(method = RequestMethod.GET, value = {"{id}/unlock"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DMP>> unlock(@PathVariable(value = "id") UUID id, Principal principal) throws Exception {
this.dataManagementPlanManager.unlock(id);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Unlocked"));
}*/
}

View File

@ -1,6 +1,8 @@
package eu.eudat.controllers;
import eu.eudat.exceptions.security.ExpiredTokenException;
import eu.eudat.exceptions.security.NonValidTokenException;
import eu.eudat.exceptions.security.NullEmailException;
import eu.eudat.logic.managers.UserManager;
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
@ -22,6 +24,9 @@ import eu.eudat.logic.security.validators.orcid.ORCIDTokenValidator;
import eu.eudat.logic.security.validators.orcid.helpers.ORCIDRequest;
import eu.eudat.logic.security.validators.orcid.helpers.ORCIDResponseToken;
import eu.eudat.logic.security.validators.twitter.TwitterTokenValidator;
import eu.eudat.logic.security.validators.zenodo.ZenodoTokenValidator;
import eu.eudat.logic.security.validators.zenodo.helpers.ZenodoRequest;
import eu.eudat.logic.security.validators.zenodo.helpers.ZenodoResponseToken;
import eu.eudat.logic.services.operations.authentication.AuthenticationService;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.login.Credentials;
@ -37,6 +42,7 @@ import org.springframework.social.oauth1.OAuthToken;
import org.springframework.web.bind.annotation.*;
import javax.transaction.Transactional;
import java.io.IOException;
import java.security.GeneralSecurityException;
@ -54,28 +60,34 @@ public class Login {
private LinkedInTokenValidator linkedInTokenValidator;
private OpenAIRETokenValidator openAIRETokenValidator;
private ConfigurableProviderTokenValidator configurableProviderTokenValidator;
private ZenodoTokenValidator zenodoTokenValidator;
private ConfigLoader configLoader;
// private Logger logger;
private UserManager userManager;
@Autowired
public Login(CustomAuthenticationProvider customAuthenticationProvider, AuthenticationService nonVerifiedUserAuthenticationService,
TwitterTokenValidator twitterTokenValidator, LinkedInTokenValidator linkedInTokenValidator, B2AccessTokenValidator b2AccessTokenValidator,
ORCIDTokenValidator orcidTokenValidator, OpenAIRETokenValidator openAIRETokenValidator, ConfigurableProviderTokenValidator configurableProviderTokenValidator, ConfigLoader configLoader, UserManager userManager/*, Logger logger*/) {
public Login(CustomAuthenticationProvider customAuthenticationProvider,
AuthenticationService nonVerifiedUserAuthenticationService, TwitterTokenValidator twitterTokenValidator,
B2AccessTokenValidator b2AccessTokenValidator, ORCIDTokenValidator orcidTokenValidator,
LinkedInTokenValidator linkedInTokenValidator, OpenAIRETokenValidator openAIRETokenValidator,
ConfigurableProviderTokenValidator configurableProviderTokenValidator, ZenodoTokenValidator zenodoTokenValidator,
ConfigLoader configLoader, UserManager userManager) {
this.customAuthenticationProvider = customAuthenticationProvider;
this.nonVerifiedUserAuthenticationService = nonVerifiedUserAuthenticationService;
this.twitterTokenValidator = twitterTokenValidator;
this.linkedInTokenValidator = linkedInTokenValidator;
this.b2AccessTokenValidator = b2AccessTokenValidator;
this.orcidTokenValidator = orcidTokenValidator;
this.linkedInTokenValidator = linkedInTokenValidator;
this.openAIRETokenValidator = openAIRETokenValidator;
this.configurableProviderTokenValidator = configurableProviderTokenValidator;
this.zenodoTokenValidator = zenodoTokenValidator;
this.configLoader = configLoader;
// this.logger = logger;
this.userManager = userManager;
}
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/externallogin"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
@ -128,6 +140,12 @@ public class Login {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ConfigurableProviderResponseToken>().payload(this.configurableProviderTokenValidator.getAccessToken(configurableProviderRequest)).status(ApiMessageCode.NO_MESSAGE));
}
@RequestMapping(method = RequestMethod.POST, value = {"/zenodoRequestToken"}, produces = "application/json", consumes = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<ZenodoResponseToken>> ZenodoRequestToken(@RequestBody ZenodoRequest zenodoRequest) {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ZenodoResponseToken>().payload(this.zenodoTokenValidator.getAccessToken(zenodoRequest)).status(ApiMessageCode.NO_MESSAGE));
}
@RequestMapping(method = RequestMethod.POST, value = {"/me"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<Principal>> authMe(Principal principal) throws NullEmailException {

View File

@ -31,13 +31,13 @@ import java.util.stream.Collectors;
@RequestMapping(value = {"/api"})
public class TagController extends BaseController {
private Repository<Dataset, TagCriteria> datasetRepository;
// private Repository<Dataset, TagCriteria> datasetRepository;
private Environment environment;
@Autowired
public TagController(ApiContext apiContext, Repository tagRepository, Environment environment) {
public TagController(ApiContext apiContext, /*Repository tagRepository, */Environment environment) {
super(apiContext);
this.datasetRepository = tagRepository;
// this.datasetRepository = tagRepository;
this.environment = environment;
}
@ -48,7 +48,7 @@ public class TagController extends BaseController {
//ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
/*List<Map<String, String>> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getTags(externalUrlCriteria, type);
TagExternalSourcesModel researchersExternalSourcesModel = new TagExternalSourcesModel().fromExternalItem(remoteRepos);*/
List<Tag> tags = this.getApiContext().getOperationsContext().getDatasetRepository().query(new DatasetCriteria()).stream().map(Dataset::getTags).flatMap(Collection::stream).filter(StreamDistinctBy.distinctByKey(Tag::getId)).collect(Collectors.toList());
List<Tag> tags = this.getApiContext().getOperationsContext().getElasticRepository().getDatasetRepository().query(new DatasetCriteria()).stream().map(Dataset::getTags).flatMap(Collection::stream).filter(StreamDistinctBy.distinctByKey(Tag::getId)).collect(Collectors.toList());
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Tag>>().payload(tags).status(ApiMessageCode.NO_MESSAGE));
}

View File

@ -48,8 +48,8 @@ public class UserInvitationController extends BaseController {
@RequestMapping(method = RequestMethod.POST, value = {"/getUsers"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<List<UserInfoInvitationModel>>> getUsers(@RequestBody UserInfoRequestItem userInfoRequestItem) throws IllegalAccessException, InstantiationException {
List<UserInfoInvitationModel> users = invitationsManager.getUsers(userInfoRequestItem);
ResponseEntity<ResponseItem<List<UserInfoInvitationModel>>> getUsers(Principal principal) throws IllegalAccessException, InstantiationException {
List<UserInfoInvitationModel> users = invitationsManager.getUsers(principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<UserInfoInvitationModel>>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(users));
}
}

View File

@ -1,9 +1,13 @@
package eu.eudat.controllers;
import eu.eudat.data.query.items.table.userinfo.UserInfoTableRequestItem;
import eu.eudat.exceptions.security.ExpiredTokenException;
import eu.eudat.exceptions.security.NonValidTokenException;
import eu.eudat.exceptions.security.NullEmailException;
import eu.eudat.logic.managers.UserManager;
import eu.eudat.logic.security.claims.ClaimedAuthorities;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.doi.DOIRequest;
import eu.eudat.models.data.helpers.common.DataTableData;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.security.Principal;
@ -73,6 +77,32 @@ public class Users extends BaseController {
DataTableData<UserListingModel> dataTable = userManager.getCollaboratorsPaged(userInfoTableRequestItem, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<UserListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
}
@RequestMapping(method = RequestMethod.GET, value = {"/hasDOIToken"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<Boolean>> hasDOIToken(Principal principal) throws NullEmailException {
try {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Boolean>().payload(this.userManager.isDOITokenValid(principal)).status(ApiMessageCode.NO_MESSAGE));
} catch (NonValidTokenException | ExpiredTokenException | IOException e) {
return ResponseEntity.status(460).body(new ResponseItem<Boolean>().payload(false).status(ApiMessageCode.ERROR_MESSAGE).message(e.getMessage()));
}
}
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/registerDOIToken"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<UserProfile>> registerDOIToken(@RequestBody DOIRequest doiRequest, Principal principal) throws NullEmailException, IOException {
userManager.registerDOIToken(doiRequest, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UserProfile>().status(ApiMessageCode.NO_MESSAGE));
}
@Transactional
@RequestMapping(method = RequestMethod.DELETE, value = {"/deleteDOIToken"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<UserProfile>> deleteDOIToken(Principal principal) throws NullEmailException, IOException {
userManager.deleteDOIToken(principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UserProfile>().status(ApiMessageCode.NO_MESSAGE));
}
}

View File

@ -0,0 +1,8 @@
package eu.eudat.exceptions.security;
public class ExpiredTokenException extends Exception {
public ExpiredTokenException(String message) {
super(message);
}
}

View File

@ -0,0 +1,19 @@
package eu.eudat.exceptions.security;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(value = HttpStatus.FORBIDDEN)
public class ForbiddenException extends RuntimeException {
public ForbiddenException() {
super();
}
public ForbiddenException(String message) {
super(message);
}
public ForbiddenException(String message, Throwable cause) {
super(message, cause);
}
}

View File

@ -4,6 +4,7 @@ import eu.eudat.logic.builders.Builder;
import eu.eudat.models.data.security.Principal;
import eu.eudat.types.Authorities;
import java.time.Instant;
import java.util.Date;
import java.util.Set;
import java.util.UUID;
@ -22,6 +23,10 @@ public class PrincipalBuilder extends Builder<Principal> {
private String culture;
private String language;
private String timezone;
private String zenodoToken;
private Instant zenodoDuration;
private String zenodoEmail;
private String zenodoRefresh;
public PrincipalBuilder id(UUID id) {
this.id = id;
@ -68,6 +73,26 @@ public class PrincipalBuilder extends Builder<Principal> {
return this;
}
public PrincipalBuilder zenodoToken(String zenodoToken) {
this.zenodoToken = zenodoToken;
return this;
}
public PrincipalBuilder zenodoDuration(Instant zenodoDuration) {
this.zenodoDuration = zenodoDuration;
return this;
}
public PrincipalBuilder zenodoEmail(String zenodoEmail) {
this.zenodoEmail = zenodoEmail;
return this;
}
public PrincipalBuilder zenodoRefresh(String zenodoRefresh) {
this.zenodoRefresh = zenodoRefresh;
return this;
}
@Override
public Principal build() {
Principal principal = new Principal();
@ -80,6 +105,10 @@ public class PrincipalBuilder extends Builder<Principal> {
principal.setCulture(culture);
principal.setLanguage(language);
principal.setTimezone(timezone);
principal.setZenodoToken(zenodoToken);
principal.setZenodoDuration(zenodoDuration);
principal.setZenodoEmail(zenodoEmail);
principal.setZenodoRefresh(zenodoRefresh);
return principal;
}
}

View File

@ -20,8 +20,8 @@ public class CommonsManager {
.map(item-> new ExternalSourcesConfiguration.ExternalSourcesUrlModel(item.getKey(),item.getLabel())).collect(Collectors.toList()));
externalSourcesConfiguration.setServices(configLoader.getExternalUrls().getServices().getUrls().stream()
.map(item-> new ExternalSourcesConfiguration.ExternalSourcesUrlModel(item.getKey(),item.getLabel())).collect(Collectors.toList()));
externalSourcesConfiguration.setTags(configLoader.getExternalUrls().getTags().getUrls().stream()
.map(item-> new ExternalSourcesConfiguration.ExternalSourcesUrlModel(item.getKey(),item.getLabel())).collect(Collectors.toList()));
/*externalSourcesConfiguration.setTags(configLoader.getExternalUrls().getTags().getUrls().stream()
.map(item-> new ExternalSourcesConfiguration.ExternalSourcesUrlModel(item.getKey(),item.getLabel())).collect(Collectors.toList()));*/
return externalSourcesConfiguration;
}
}

View File

@ -7,6 +7,7 @@ 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.elastic.entities.Dmp;
import eu.eudat.logic.builders.model.models.RecentActivityDataBuilder;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.DatabaseRepository;
@ -81,6 +82,7 @@ public class DashBoardManager {
public DashBoardStatistics getMeStatistics(Principal principal) throws IOException {
List<eu.eudat.elastic.entities.Dataset> datasets = null;
List<eu.eudat.elastic.entities.Dmp> dmps = null;
DashBoardStatistics statistics = new DashBoardStatistics();
DMPDao dataManagementPlanRepository = databaseRepository.getDmpDao();
DatasetDao datasetRepository = databaseRepository.getDatasetDao();
@ -89,12 +91,12 @@ public class DashBoardManager {
UserInfo user = new UserInfo();
user.setId(principal.getId());
DatasetCriteria datasetCriteria = new DatasetCriteria();
if (apiContext.getOperationsContext().getDatasetRepository() != null) {
if (apiContext.getOperationsContext().getElasticRepository().getDatasetRepository() != null) {
try {
eu.eudat.elastic.criteria.DatasetCriteria datasetElasticCriteria = new eu.eudat.elastic.criteria.DatasetCriteria();
datasetElasticCriteria.setAllowAllVersions(false);
datasetElasticCriteria.setPublic(false);
datasets = apiContext.getOperationsContext().getDatasetRepository().query(datasetElasticCriteria);
datasets = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().query(datasetElasticCriteria);
}catch (Exception e) {
logger.warn(e.getMessage(), e);
datasets = null;
@ -103,11 +105,23 @@ public class DashBoardManager {
datasetCriteria.setAllVersions(false);
datasetCriteria.setIsPublic(false);
DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria();
if (apiContext.getOperationsContext().getElasticRepository().getDmpRepository() != null) {
try {
eu.eudat.elastic.criteria.DmpCriteria dmpElasticCriteria = new eu.eudat.elastic.criteria.DmpCriteria();
dmpElasticCriteria.setAllowAllVersions(false);
dmpElasticCriteria.setPublic(false);
dmps = apiContext.getOperationsContext().getElasticRepository().getDmpRepository().query(dmpElasticCriteria);
}catch (Exception e) {
logger.warn(e.getMessage(), e);
dmps = null;
}
}
dataManagementPlanCriteria.setAllVersions(false);
GrantCriteria grantCriteria = new GrantCriteria();
List<Integer> roles = new LinkedList<>();
CompletableFuture dmpFuture = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.getWithCriteria(dataManagementPlanCriteria), principal.getId(), roles).countAsync()
List<Dmp> finalDmps = dmps;
CompletableFuture dmpFuture = dataManagementPlanRepository.getAuthenticated(dmps != null ? dataManagementPlanRepository.asQueryable().where((builder, root) -> root.get("id").in(finalDmps.stream().map(Dmp::getId).collect(Collectors.toList()))) : dataManagementPlanRepository.getWithCriteria(dataManagementPlanCriteria), principal.getId(), roles).countAsync()
.whenComplete((dmpsStats, throwable) -> statistics.setTotalDataManagementPlanCount(dmpsStats));
List<eu.eudat.elastic.entities.Dataset> finalDatasets = datasets;
CompletableFuture datasetFuture = datasetRepository.getAuthenticated(datasets != null ? datasetRepository.asQueryable().where((builder, root) -> root.get("id").in(finalDatasets.stream().map(x -> UUID.fromString(x.getId())).collect(Collectors.toList()))) : datasetRepository.getWithCriteria(datasetCriteria), user, roles).countAsync()

View File

@ -13,13 +13,12 @@ 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;
import eu.eudat.elastic.entities.Collaborator;
import eu.eudat.elastic.entities.Organization;
import eu.eudat.elastic.entities.Tag;
import eu.eudat.elastic.repository.DatasetRepository;
import eu.eudat.exceptions.security.UnauthorisedException;
import eu.eudat.logic.builders.BuilderFactory;
import eu.eudat.logic.builders.entity.UserInfoBuilder;
import eu.eudat.logic.mapper.elastic.DatasetMapper;
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.forms.VisibilityRuleService;
@ -28,7 +27,6 @@ import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
import eu.eudat.logic.utilities.documents.types.ParagraphStyle;
import eu.eudat.logic.utilities.documents.word.WordBuilder;
import eu.eudat.logic.utilities.documents.xml.ExportXmlBuilder;
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
import eu.eudat.models.HintedModelFactory;
import eu.eudat.models.data.datasetImport.DatasetImportField;
import eu.eudat.models.data.datasetImport.DatasetImportPagedDatasetProfile;
@ -104,7 +102,7 @@ public class DatasetManager {
public DatasetManager(ApiContext apiContext, UserManager userManager, ConfigLoader configLoader, Environment environment) {
this.apiContext = apiContext;
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
this.datasetRepository = apiContext.getOperationsContext().getDatasetRepository();
this.datasetRepository = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository();
this.builderFactory = apiContext.getOperationsContext().getBuilderFactory();
this.userManager = userManager;
this.configLoader = configLoader;
@ -136,7 +134,7 @@ public class DatasetManager {
datasets = datasetRepository.exists() ?
datasetRepository.query(datasetCriteria) : null;
} catch (Exception ex) {
logger.warn(ex.getMessage());
logger.warn(ex.getMessage(), ex);
datasets = null;
}
@ -467,8 +465,10 @@ public class DatasetManager {
return exportEnvelope;
}
public String getWordDocumentText (DatasetWizardModel datasetEntity) throws Exception {
XWPFDocument document = getLightWordDocument(this.configLoader, datasetEntity, this.apiContext.getUtilitiesService().getVisibilityRuleService());
public String getWordDocumentText (Dataset datasetEntity) throws Exception {
DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(datasetEntity);
datasetWizardModel.setDatasetProfileDefinition(this.getPagedProfile(datasetWizardModel, datasetEntity));
XWPFDocument document = getLightWordDocument(this.configLoader, datasetWizardModel, this.apiContext.getUtilitiesService().getVisibilityRuleService());
XWPFWordExtractor extractor = new XWPFWordExtractor(document);
return extractor.getText();/*.replaceAll("\n\\s*", " ");*/
}
@ -578,8 +578,8 @@ public class DatasetManager {
datasetWizardModel.setDmp(new DataManagementPlan().fromDataModelNoDatasets(dataset1.getDmp()));
}
dataset1.setProfile(this.apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(datasetWizardModel.getProfile()));
datasetWizardModel.setDatasetProfileDefinition(getPagedProfile(datasetWizardModel, dataset1));
updateTags(apiContext.getOperationsContext().getDatasetRepository(), datasetWizardModel);
// datasetWizardModel.setDatasetProfileDefinition(getPagedProfile(datasetWizardModel, dataset1));
updateTags(dataset1, datasetWizardModel.getTags());
if (sendNotification) {
if (dataset1.getStatus() != Dataset.Status.FINALISED.getValue()) {
this.sendNotification(dataset1, dataset1.getDmp(), userInfo, NotificationType.DATASET_MODIFIED);
@ -646,14 +646,14 @@ public class DatasetManager {
return jobject.toString();
}
public void updateTags(DatasetRepository datasetRepository, DatasetWizardModel datasetWizardModel) throws Exception {
public void updateTags(Dataset datasetEntity, List<Tag> tags) throws Exception {
// if (datasetWizardModel.getTags() != null && !datasetWizardModel.getTags().isEmpty()) {
eu.eudat.elastic.entities.Dataset dataset = new eu.eudat.elastic.entities.Dataset();
/*eu.eudat.elastic.entities.Dataset dataset = new eu.eudat.elastic.entities.Dataset();
dataset.setId(datasetWizardModel.getId().toString());
if (datasetWizardModel.getTags() != null && !datasetWizardModel.getTags().isEmpty()) {
DatasetCriteria criteria = new DatasetCriteria();
criteria.setTags(datasetWizardModel.getTags());
List<Tag> tags = apiContext.getOperationsContext().getDatasetRepository().query(criteria).stream().map(eu.eudat.elastic.entities.Dataset::getTags).flatMap(Collection::stream)
List<Tag> tags = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().query(criteria).stream().map(eu.eudat.elastic.entities.Dataset::getTags).flatMap(Collection::stream)
.filter(StreamDistinctBy.distinctByKey(Tag::getId)).filter(tag -> datasetWizardModel.getTags().stream().anyMatch(tag1 -> tag1.getName().equals(tag.getName()))).collect(Collectors.toList());
if (tags.isEmpty()) {
datasetWizardModel.getTags().forEach(tag -> tag.setId(UUID.randomUUID().toString()));
@ -700,8 +700,10 @@ public class DatasetManager {
}
dataset.setPublic(datasetWizardModel.getDmp().getPublic());
dataset.setGrantStatus(datasetWizardModel.getDmp().getGrant().getStatus());
dataset.setFormData(this.getWordDocumentText(datasetWizardModel));
datasetRepository.createOrUpdate(dataset);
dataset.setFormData(this.getWordDocumentText(datasetWizardModel));*/
DatasetMapper mapper = new DatasetMapper(apiContext, this);
eu.eudat.elastic.entities.Dataset dataset = mapper.toElastic(datasetEntity, tags);
apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().createOrUpdate(dataset);
// }
}
@ -868,7 +870,7 @@ public class DatasetManager {
UserInfo userInfo = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(principal.getId()).build();
entity.setCreator(userInfo);
updateTagsXmlImportDataset(apiContext.getOperationsContext().getDatasetRepository(), entity);
updateTagsXmlImportDataset(apiContext.getOperationsContext().getElasticRepository().getDatasetRepository(), entity);
createRegistriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao(), entity);
createDataRepositoriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao(), entity);
createServicesIfTheyDontExist(entity);
@ -951,19 +953,11 @@ public class DatasetManager {
public void generateIndex(Principal principal) {
if (principal.getAuthorities().contains(Authorities.ADMIN.getValue())) {
this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable().toList();
List<DatasetWizardModel> datasetWizardModels = this.apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().asQueryable().toList()
.stream().map(dataset -> {
DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset);
datasetWizardModel.setDatasetProfileDefinition(getPagedProfile(datasetWizardModel, dataset));
return datasetWizardModel;
}).collect(Collectors.toList());
datasetWizardModels.forEach(datasetWizardModel -> {
List<Dataset> datasetEntities = new ArrayList<>(this.apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().asQueryable().toList());
datasetEntities.forEach(datasetEntity -> {
try {
eu.eudat.elastic.entities.Dataset dataset = apiContext.getOperationsContext().getDatasetRepository().findDocument(datasetWizardModel.getId().toString());
if (dataset != null) {
datasetWizardModel.setTags(dataset.getTags());
}
updateTags(apiContext.getOperationsContext().getDatasetRepository(), datasetWizardModel);
eu.eudat.elastic.entities.Dataset dataset = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(datasetEntity.getId().toString());
updateTags(datasetEntity, dataset != null ? dataset.getTags() : null);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
@ -974,7 +968,7 @@ public class DatasetManager {
public void clearIndex(Principal principal) {
if (principal.getAuthorities().contains(Authorities.ADMIN.getValue())) {
try {
this.apiContext.getOperationsContext().getDatasetRepository().clear();
this.apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().clear();
} catch (IOException e) {
logger.error(e.getMessage(), e);
}

View File

@ -50,12 +50,12 @@ public class DatasetWizardManager {
public void delete(ApiContext apiContext, UUID uuid) throws IOException {
Dataset oldDataset = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(uuid);
eu.eudat.elastic.entities.Dataset oldDatasetElasitc = apiContext.getOperationsContext().getDatasetRepository().findDocument(uuid.toString());
eu.eudat.elastic.entities.Dataset oldDatasetElasitc = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(uuid.toString());
oldDataset.setStatus(Dataset.Status.DELETED.getValue());
oldDatasetElasitc.setStatus(oldDataset.getStatus());
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(oldDataset);
if (uuid != null && oldDatasetElasitc.getId()!= null) {
apiContext.getOperationsContext().getDatasetRepository().createOrUpdate(oldDatasetElasitc);
if (oldDatasetElasitc != null && uuid != null && oldDatasetElasitc.getId()!= null) {
oldDatasetElasitc.setStatus(oldDataset.getStatus());
apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().createOrUpdate(oldDatasetElasitc);
}
}
}

View File

@ -1,6 +1,7 @@
package eu.eudat.logic.managers;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.UserAssociation;
import eu.eudat.data.entities.UserDMP;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.exceptions.security.UnauthorisedException;
@ -38,15 +39,28 @@ public class InvitationsManager {
UserDMP userDMP = new UserDMP();
userDMP.setUser(userInfo);
userInfoToUserDmp.add(userDMP);
if (!apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().areAssociated(principalUser, userInfo)) {
UserAssociation userAssociation = new UserAssociation();
userAssociation.setFirstUser(principalUser);
userAssociation.setSecondUser(userInfo);
apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().createOrUpdate(userAssociation);
}
}
DMP dataManagementPlan = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(invitation.getDataManagementPlan());
apiContext.getUtilitiesService().getInvitationService().createInvitations(apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao(), apiContext.getUtilitiesService().getMailService(), invitation.getUsers().stream().map(item -> item.toDataModel()).collect(Collectors.toList()), dataManagementPlan, principalUser);
apiContext.getUtilitiesService().getInvitationService().assignToDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao(), userInfoToUserDmp, dataManagementPlan);
}
public List<UserInfoInvitationModel> getUsers(UserInfoRequestItem userInfoRequestItem) throws InstantiationException, IllegalAccessException {
QueryableList<UserInfo> users = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().getWithCriteria(userInfoRequestItem.getCriteria());
List<UserInfoInvitationModel> userModels = users.select(item -> new UserInfoInvitationModel().fromDataModel(item));
public List<UserInfoInvitationModel> getUsers(Principal principal) throws InstantiationException, IllegalAccessException {
UserInfo principalUser = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
List<UserInfo> users = apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().getAssociated(principalUser).stream().map(userAssociation -> {
if (userAssociation.getFirstUser().getId().equals(principal.getId())) {
return userAssociation.getSecondUser();
} else {
return userAssociation.getFirstUser();
}
}).collect(Collectors.toList());
List<UserInfoInvitationModel> userModels = users.stream().map(userInfo -> new UserInfoInvitationModel().fromDataModel(userInfo)).collect(Collectors.toList());
return userModels;
}
@ -60,6 +74,12 @@ public class InvitationsManager {
userDMP.setUser(invitedUser);
userDMP.setDmp(invitation.getDmp());
userDMP.setRole(UserDMP.UserDMPRoles.USER.getValue());
if (!apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().areAssociated(invitedUser, invitation.getUser())) {
UserAssociation userAssociation = new UserAssociation();
userAssociation.setFirstUser(invitedUser);
userAssociation.setSecondUser(invitation.getUser());
apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().createOrUpdate(userAssociation);
}
DMP datamanagementPlan = invitation.getDmp();
apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().createOrUpdate(userDMP);
apiContext.getUtilitiesService().getInvitationService().assignToDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao(), userDMP, datamanagementPlan);

View File

@ -4,6 +4,8 @@ import eu.eudat.data.dao.criteria.FunderCriteria;
import eu.eudat.data.dao.criteria.GrantCriteria;
import eu.eudat.data.dao.criteria.ProjectCriteria;
import eu.eudat.data.entities.*;
import eu.eudat.elastic.entities.Dmp;
import eu.eudat.logic.mapper.elastic.DmpMapper;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.models.data.dmp.DataManagementPlan;
@ -20,11 +22,13 @@ public class QuickWizardManager {
private ApiContext apiContext;
private DatabaseRepository databaseRepository;
private DatasetManager datasetManager;
@Autowired
public QuickWizardManager(ApiContext apiContext) {
public QuickWizardManager(ApiContext apiContext, DatasetManager datasetManager) {
this.apiContext = apiContext;
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
this.datasetManager = datasetManager;
}
public Funder createOrUpdate(eu.eudat.models.data.funder.Funder funder, Principal principal) {
@ -63,9 +67,18 @@ public class QuickWizardManager {
DMP dmpret = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
if (dataManagementPlan.getAssociatedUsers().size() == 0)
assignUser(newDmp, user, apiContext);
this.updateIndex(dmpret);
return dmpret;
}
private void updateIndex(DMP dmp) throws IOException {
DmpMapper mapper = new DmpMapper(apiContext, datasetManager);
Dmp elastic = mapper.toElastic(dmp);
apiContext.getOperationsContext().getElasticRepository().getDmpRepository().createOrUpdate(elastic);
}
private void assignUser(DMP dmp, UserInfo userInfo, ApiContext apiContext) {
UserDMP userDMP = new UserDMP();
userDMP.setDmp(dmp);

View File

@ -32,7 +32,7 @@ public class RDAManager {
ObjectMapper mapper = new ObjectMapper();
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss Z"));
result = mapper.writeValueAsString(rdaDmp);
result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(rdaDmp);
return result;
}

View File

@ -7,15 +7,21 @@ import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.data.entities.UserRole;
import eu.eudat.data.query.items.table.userinfo.UserInfoTableRequestItem;
import eu.eudat.exceptions.security.ExpiredTokenException;
import eu.eudat.exceptions.security.NonValidTokenException;
import eu.eudat.exceptions.security.NullEmailException;
import eu.eudat.exceptions.security.UnauthorisedException;
import eu.eudat.logic.builders.entity.UserRoleBuilder;
import eu.eudat.logic.builders.model.models.DataTableDataBuilder;
import eu.eudat.logic.security.customproviders.Zenodo.ZenodoAccessType;
import eu.eudat.logic.security.customproviders.Zenodo.ZenodoCustomProvider;
import eu.eudat.logic.security.validators.zenodo.helpers.ZenodoResponseToken;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.authentication.AuthenticationService;
import eu.eudat.logic.utilities.builders.XmlBuilder;
import eu.eudat.models.HintedModelFactory;
import eu.eudat.models.data.dmp.DataManagementPlan;
import eu.eudat.models.data.doi.DOIRequest;
import eu.eudat.models.data.helpers.common.DataTableData;
import eu.eudat.models.data.login.Credentials;
import eu.eudat.models.data.security.Principal;
@ -24,11 +30,13 @@ import eu.eudat.models.data.userinfo.UserProfile;
import eu.eudat.queryable.QueryableList;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.io.IOException;
import java.time.Instant;
import java.util.*;
import java.util.stream.Collectors;
@ -36,10 +44,14 @@ import java.util.stream.Collectors;
public class UserManager {
private ApiContext apiContext;
private ZenodoCustomProvider zenodoCustomProvider;
private Environment environment;
@Autowired
public UserManager(ApiContext apiContext) {
public UserManager(ApiContext apiContext, ZenodoCustomProvider zenodoCustomProvider, Environment environment) {
this.apiContext = apiContext;
this.zenodoCustomProvider = zenodoCustomProvider;
this.environment = environment;
}
public eu.eudat.models.data.user.composite.DatasetProfile generateDatasetProfileModel(eu.eudat.data.entities.DatasetProfile profile) {
@ -112,4 +124,46 @@ public class UserManager {
dataTableData.setTotalCount((long) colaborators.size());
return dataTableData;
}
public Boolean isDOITokenValid(Principal principal) throws NonValidTokenException, ExpiredTokenException, IOException {
if (principal.getZenodoToken() != null && !principal.getZenodoToken().isEmpty()) {
if (Instant.now().isBefore(principal.getZenodoDuration())) {
return true;
}
try {
this.updateDOIToken(ZenodoAccessType.REFRESH_TOKEN, principal.getZenodoRefresh(), this.environment.getProperty("zenodo.login.redirect_uri"), principal);
return true;
}catch (IOException e) {
this.deleteDOIToken(principal);
throw new ExpiredTokenException("Zenodo Token is expired.");
}
}
throw new NonValidTokenException("This account has no Zenodo Token");
}
public void registerDOIToken(DOIRequest doiRequest, Principal principal) throws IOException {
this.updateDOIToken(ZenodoAccessType.AUTHORIZATION_CODE, doiRequest.getZenodoRequest().getCode(), doiRequest.getRedirectUri(), principal);
}
private void updateDOIToken(ZenodoAccessType accessType, String code, String redirectUri, Principal principal) throws IOException {
ZenodoResponseToken responseToken = this.zenodoCustomProvider.getAccessToken(accessType, code
, this.environment.getProperty("zenodo.login.client_id")
, this.environment.getProperty("zenodo.login.client_secret")
, redirectUri);
Map<String, Object> settings = new HashMap<>();
settings.put("zenodoEmail", responseToken.getEmail());
settings.put("zenodoRefresh", responseToken.getRefreshToken());
settings.put("zenodoToken", responseToken.getAccessToken());
settings.put("expirationDate", Instant.now().plusSeconds(responseToken.getExpiresIn()).toEpochMilli());
this.updateSettings(settings, principal);
}
public void deleteDOIToken(Principal principal) throws IOException {
Map<String, Object> settings = new HashMap<>();
settings.put("zenodoEmail", "");
settings.put("zenodoRefresh", "");
settings.put("zenodoToken", "");
settings.put("expirationDate", 0);
this.updateSettings(settings, principal);
}
}

View File

@ -0,0 +1,14 @@
package eu.eudat.logic.mapper.elastic;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.elastic.entities.Collaborator;
public class CollaboratorMapper {
public static Collaborator toElastic(UserInfo user) {
Collaborator elastic = new Collaborator();
elastic.setId(user.getId().toString());
elastic.setName(user.getName());
return elastic;
}
}

View File

@ -0,0 +1,74 @@
package eu.eudat.logic.mapper.elastic;
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
import eu.eudat.data.entities.DMP;
import eu.eudat.elastic.criteria.DatasetCriteria;
import eu.eudat.elastic.entities.Collaborator;
import eu.eudat.elastic.entities.Dataset;
import eu.eudat.elastic.entities.Organization;
import eu.eudat.elastic.entities.Tag;
import eu.eudat.logic.managers.DatasetManager;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
import java.util.*;
import java.util.stream.Collectors;
public class DatasetMapper {
private final ApiContext apiContext;
private final DatasetManager datasetManager;
public DatasetMapper(ApiContext apiContext, DatasetManager datasetManager) {
this.apiContext = apiContext;
this.datasetManager = datasetManager;
}
public Dataset toElastic(eu.eudat.data.entities.Dataset dataset, List<Tag> tags) throws Exception {
Dataset elastic = new Dataset();
elastic.setId(dataset.getId().toString());
if (tags != null && !tags.isEmpty()) {
DatasetCriteria criteria = new DatasetCriteria();
criteria.setTags(tags);
List<Tag> tags1 = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().query(criteria).stream().map(eu.eudat.elastic.entities.Dataset::getTags).flatMap(Collection::stream)
.filter(StreamDistinctBy.distinctByKey(Tag::getId)).filter(tag -> tags.stream().anyMatch(tag1 -> tag1.getName().equals(tag.getName()))).collect(Collectors.toList());
if (tags1.isEmpty()) {
tags.forEach(tag -> tag.setId(UUID.randomUUID().toString()));
elastic.setTags(tags);
} else {
elastic.setTags(tags1);
}
}
elastic.setLabel(dataset.getLabel());
elastic.setDescription(dataset.getDescription());
elastic.setTemplate(dataset.getProfile().getId());
elastic.setStatus(dataset.getStatus());
elastic.setDmp(dataset.getDmp().getId());
elastic.setGroup(dataset.getDmp().getGroupId());
elastic.setGrant(dataset.getDmp().getGrant().getId());
if (dataset.getDmp().getUsers() != null) {
elastic.setCollaborators(dataset.getDmp().getUsers().stream().map(user -> CollaboratorMapper.toElastic(user.getUser())).collect(Collectors.toList()));
}
DataManagementPlanCriteria dmpCriteria = new DataManagementPlanCriteria();
dmpCriteria.setAllVersions(true);
dmpCriteria.setGroupIds(Collections.singletonList(dataset.getDmp().getGroupId()));
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dmpCriteria).toList().stream()
.max(Comparator.comparing(DMP::getVersion)).ifPresent(dmp -> elastic.setLastVersion(dmp.getId().equals(dataset.getDmp().getId())));
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dmpCriteria).toList().stream().filter(DMP::isPublic)
.max(Comparator.comparing(DMP::getVersion)).ifPresent(dmp -> elastic.setLastPublicVersion(dmp.getId().equals(dataset.getDmp().getId())));
if (elastic.getLastVersion() == null) {
elastic.setLastVersion(true);
}
if (elastic.getLastPublicVersion() == null) {
elastic.setLastPublicVersion(false);
}
if (dataset.getDmp().getOrganisations() != null) {
elastic.setOrganizations(dataset.getDmp().getOrganisations().stream().map(OrganizationMapper::toElastic).collect(Collectors.toList()));
}
elastic.setPublic(dataset.getDmp().isPublic());
elastic.setGrantStatus(dataset.getDmp().getGrant().getStatus());
elastic.setFormData(datasetManager.getWordDocumentText(dataset));
return elastic;
}
}

View File

@ -0,0 +1,14 @@
package eu.eudat.logic.mapper.elastic;
import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.elastic.entities.DatasetTempalate;
public class DatasetTemplateMapper {
public static DatasetTempalate toElastic(DatasetProfile profile) {
DatasetTempalate elastic = new DatasetTempalate();
elastic.setId(profile.getId());
elastic.setName(profile.getLabel());
return elastic;
}
}

View File

@ -0,0 +1,86 @@
package eu.eudat.logic.mapper.elastic;
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
import eu.eudat.data.dao.entities.DMPDao;
import eu.eudat.data.entities.DMP;
import eu.eudat.elastic.entities.Collaborator;
import eu.eudat.elastic.entities.Dataset;
import eu.eudat.elastic.entities.Dmp;
import eu.eudat.elastic.entities.Tag;
import eu.eudat.logic.managers.DatasetManager;
import eu.eudat.logic.services.ApiContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
public class DmpMapper {
private static final Logger logger = LoggerFactory.getLogger(DmpMapper.class);
private final ApiContext apiContext;
private final DatasetManager datasetManager;
private final DatasetMapper datasetMapper;
public DmpMapper(ApiContext apiContext, DatasetManager datasetManager) {
this.apiContext = apiContext;
this.datasetManager = datasetManager;
this.datasetMapper = new DatasetMapper(apiContext, datasetManager);
}
public Dmp toElastic(DMP dmp) {
Dmp elastic = new Dmp();
elastic.setId(dmp.getId());
elastic.setGroupId(dmp.getGroupId());
if (dmp.getUsers() != null) {
elastic.setCollaborators(dmp.getUsers().stream().map(user -> CollaboratorMapper.toElastic(user.getUser())).collect(Collectors.toList()));
}
elastic.setDescription(dmp.getDescription());
elastic.setGrant(dmp.getGrant().getId());
elastic.setLabel(dmp.getLabel());
elastic.setPublic(dmp.isPublic());
elastic.setStatus(dmp.getStatus());
DataManagementPlanCriteria dmpCriteria = new DataManagementPlanCriteria();
dmpCriteria.setAllVersions(true);
dmpCriteria.setGroupIds(Collections.singletonList(dmp.getGroupId()));
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dmpCriteria).toList().stream()
.max(Comparator.comparing(DMP::getVersion)).ifPresent(dmp1 -> elastic.setLastVersion(dmp1.getId().equals(dmp.getId())));
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dmpCriteria).toList().stream().filter(DMP::isPublic)
.max(Comparator.comparing(DMP::getVersion)).ifPresent(dmp1 -> elastic.setLastPublicVersion(dmp1.getId().equals(dmp.getId())));
if (elastic.getLastVersion() == null) {
elastic.setLastVersion(false);
}
if (elastic.getLastPublicVersion() == null) {
elastic.setLastPublicVersion(false);
}
if (dmp.getDataset() != null) {
elastic.setDatasets(dmp.getDataset().stream().map(dataset -> {
List<Tag> tags = null;
try {
Dataset dataset1 = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(dataset.getId().toString());
if (dataset1 != null) {
tags = dataset1.getTags();
}
return datasetMapper.toElastic(dataset, tags);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return null;
}).collect(Collectors.toList()));
}
if (dmp.getAssociatedDmps() != null) {
elastic.setTemplates(dmp.getAssociatedDmps().stream().map(DatasetTemplateMapper::toElastic).collect(Collectors.toList()));
}
if (dmp.getOrganisations() != null) {
elastic.setOrganizations(dmp.getOrganisations().stream().map(OrganizationMapper::toElastic).collect(Collectors.toList()));
}
if (dmp.getGrant() != null) {
elastic.setGrantStatus(dmp.getGrant().getStatus());
}
return elastic;
}
}

View File

@ -0,0 +1,14 @@
package eu.eudat.logic.mapper.elastic;
import eu.eudat.data.entities.Organisation;
import eu.eudat.elastic.entities.Organization;
public class OrganizationMapper {
public static Organization toElastic(Organisation organisation) {
Organization elastic = new Organization();
elastic.setId(organisation.getId().toString());
elastic.setName(organisation.getLabel());
return elastic;
}
}

View File

@ -0,0 +1,33 @@
package eu.eudat.logic.mapper.elastic.criteria;
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
import eu.eudat.data.entities.Grant;
import eu.eudat.elastic.criteria.DmpCriteria;
import java.util.UUID;
import java.util.stream.Collectors;
public class DmpCriteriaMapper {
public static DmpCriteria toElasticCriteria(DataManagementPlanCriteria criteria) {
DmpCriteria elastic = new DmpCriteria();
elastic.setAllowAllVersions(criteria.getAllVersions());
elastic.setCollaborators(criteria.getCollaborators());
if (criteria.getGrants() != null) {
elastic.setGrants(criteria.getGrants().stream().map(Grant::getId).collect(Collectors.toList()));
}
elastic.setGroupIds(criteria.getGroupIds());
elastic.setLike(criteria.getLike());
if (criteria.getOrganisations() != null) {
elastic.setOrganizations(criteria.getOrganisations().stream().map(UUID::fromString).collect(Collectors.toList()));
}
elastic.setPublic(criteria.getIsPublic());
if (criteria.getStatus() != null) {
elastic.setStatus(criteria.getStatus().shortValue());
}
elastic.setTemplates(criteria.getDatasetTemplates());
elastic.setGrantStatus(criteria.getGrantStatus());
return elastic;
}
}

View File

@ -22,7 +22,7 @@ public class ExternalUrls implements Serializable {
ResearcherUrls researchers;
OrganisationUrls organisations;
DatasetUrls datasets;
TagUrls tags;
/*TagUrls tags;*/
FunderUrls funders;
@ -66,14 +66,14 @@ public class ExternalUrls implements Serializable {
}
public TagUrls getTags() {
/*public TagUrls getTags() {
return tags;
}
@XmlElement(name = "tags")
public void setTags(TagUrls tags) {
this.tags = tags;
}
}*/
public OrganisationUrls getOrganisations() {

View File

@ -108,14 +108,14 @@ public class RemoteFetcher {
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
}
@Cacheable("tags")
/*@Cacheable("tags")
public List<Map<String, String>> getTags(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
List<UrlConfiguration> urlConfigs =
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getTags().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
: configLoader.getExternalUrls().getTags().getUrls();
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getTags().getFetchMode();
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
}
}*/
@Cacheable("externalDatasets")
public List<Map<String, String>> getDatasets(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
@ -169,9 +169,13 @@ public class RemoteFetcher {
completedPath = completedPath.replace("{like}", "");
}
if (externalUrlCriteria.getFunderId() != null) {
String funderId = externalUrlCriteria.getFunderId();
String funderPrefix = externalUrlCriteria.getFunderId().split(":")[0];
String funderId = externalUrlCriteria.getFunderId().replace(funderPrefix + ":", "");
if (funderId.toCharArray()[0] == ':') {
funderId = externalUrlCriteria.getFunderId();
}
try {
funderId = URLEncoder.encode(externalUrlCriteria.getFunderId(), "UTF-8");
funderId = URLEncoder.encode(funderId, "UTF-8");
} catch (UnsupportedEncodingException e) {
logger.error(e.getMessage(), e);
}

View File

@ -0,0 +1,22 @@
package eu.eudat.logic.security.customproviders.Zenodo;
public enum ZenodoAccessType {
AUTHORIZATION_CODE("authorization_code", "code"),
REFRESH_TOKEN("refresh_token", "refresh_token");
private final String grantType;
private final String property;
ZenodoAccessType(String grantType, String property) {
this.grantType = grantType;
this.property = property;
}
public String getGrantType() {
return grantType;
}
public String getProperty() {
return property;
}
}

View File

@ -0,0 +1,8 @@
package eu.eudat.logic.security.customproviders.Zenodo;
import eu.eudat.logic.security.validators.orcid.helpers.ORCIDResponseToken;
import eu.eudat.logic.security.validators.zenodo.helpers.ZenodoResponseToken;
public interface ZenodoCustomProvider {
ZenodoResponseToken getAccessToken(ZenodoAccessType accessType, String code, String clientId, String clientSecret, String redirectUri);
}

View File

@ -0,0 +1,73 @@
package eu.eudat.logic.security.customproviders.Zenodo;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.logic.security.validators.orcid.helpers.ORCIDResponseToken;
import eu.eudat.logic.security.validators.zenodo.helpers.ZenodoResponseToken;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
@Component("ZenodoCustomProvider")
public class ZenodoCustomProviderImpl implements ZenodoCustomProvider {
private static final Logger logger = LoggerFactory.getLogger(ZenodoCustomProviderImpl.class);
private Environment environment;
@Autowired
public ZenodoCustomProviderImpl(Environment environment) {
this.environment = environment;
}
@Override
public ZenodoResponseToken getAccessToken(ZenodoAccessType accessType, String code, String clientId, String clientSecret, String redirectUri) {
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
map.add("client_id", clientId);
map.add("client_secret", clientSecret);
map.add("grant_type", accessType.getGrantType());
map.add(accessType.getProperty(), code);
map.add("redirect_uri", redirectUri);
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(map, headers);
try {
Map<String, Object> values = restTemplate.postForObject(this.environment.getProperty("zenodo.login.access_token_url"), request, Map.class);
ZenodoResponseToken zenodoResponseToken = new ZenodoResponseToken();
Map<String, Object> user = (Map<String, Object>) values.get("user");
zenodoResponseToken.setUserId((String) user.get("id"));
zenodoResponseToken.setEmail((String) user.get("email"));
zenodoResponseToken.setExpiresIn((Integer) values.get("expires_in"));
zenodoResponseToken.setAccessToken((String) values.get("access_token"));
zenodoResponseToken.setRefreshToken((String) values.get("refresh_token"));
return zenodoResponseToken;
} catch (HttpClientErrorException ex) {
logger.error(ex.getResponseBodyAsString(), ex);
}
return null;
}
private HttpHeaders createBearerAuthHeaders(String accessToken) {
return new HttpHeaders() {{
String authHeader = "Bearer " + accessToken;
set("Authorization", authHeader);
}};
}
}

View File

@ -0,0 +1,59 @@
package eu.eudat.logic.security.customproviders.Zenodo;
import java.util.Map;
public class ZenodoUser {
private String userId;
private String email;
private String accessToken;
private Integer expiresIn;
private String refreshToken;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getAccessToken() {
return accessToken;
}
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
public Integer getExpiresIn() {
return expiresIn;
}
public void setExpiresIn(Integer expiresIn) {
this.expiresIn = expiresIn;
}
public String getRefreshToken() {
return refreshToken;
}
public void setRefreshToken(String refreshToken) {
this.refreshToken = refreshToken;
}
public ZenodoUser getZenodoUser(Object data) {
this.userId = (String) ((Map) data).get("userId");
this.email = (String) ((Map) data).get("email");
this.accessToken = (String) ((Map) data).get("accessToken");
this.expiresIn = (Integer) ((Map) data).get("expiresIn");
this.refreshToken = (String) ((Map) data).get("refreshToken");
return this;
}
}

View File

@ -6,6 +6,7 @@ import eu.eudat.logic.security.customproviders.ConfigurableProvider.Configurable
import eu.eudat.logic.security.customproviders.LinkedIn.LinkedInCustomProvider;
import eu.eudat.logic.security.customproviders.ORCID.ORCIDCustomProvider;
import eu.eudat.logic.security.customproviders.OpenAIRE.OpenAIRECustomProvider;
import eu.eudat.logic.security.customproviders.Zenodo.ZenodoCustomProvider;
import eu.eudat.logic.security.validators.b2access.B2AccessTokenValidator;
import eu.eudat.logic.security.validators.configurableProvider.ConfigurableProviderTokenValidator;
import eu.eudat.logic.security.validators.facebook.FacebookTokenValidator;
@ -14,6 +15,7 @@ import eu.eudat.logic.security.validators.linkedin.LinkedInTokenValidator;
import eu.eudat.logic.security.validators.openaire.OpenAIRETokenValidator;
import eu.eudat.logic.security.validators.orcid.ORCIDTokenValidator;
import eu.eudat.logic.security.validators.twitter.TwitterTokenValidator;
import eu.eudat.logic.security.validators.zenodo.ZenodoTokenValidator;
import eu.eudat.logic.services.operations.authentication.AuthenticationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
@ -23,7 +25,7 @@ import org.springframework.stereotype.Service;
@Service("tokenValidatorFactory")
public class TokenValidatorFactoryImpl implements TokenValidatorFactory {
public enum LoginProvider {
GOOGLE(1), FACEBOOK(2), TWITTER(3), LINKEDIN(4), NATIVELOGIN(5), B2_ACCESS(6), ORCID(7), OPENAIRE(8), CONFIGURABLE(9);
GOOGLE(1), FACEBOOK(2), TWITTER(3), LINKEDIN(4), NATIVELOGIN(5), B2_ACCESS(6), ORCID(7), OPENAIRE(8), CONFIGURABLE(9), ZENODO(10);
private int value;
@ -55,6 +57,8 @@ public class TokenValidatorFactoryImpl implements TokenValidatorFactory {
return OPENAIRE;
case 9:
return CONFIGURABLE;
case 10:
return ZENODO;
default:
throw new RuntimeException("Unsupported LoginProvider");
}
@ -69,12 +73,15 @@ public class TokenValidatorFactoryImpl implements TokenValidatorFactory {
private OpenAIRECustomProvider openAIRECustomProvider;
private ConfigurableProviderCustomProvider configurableProviderCustomProvider;
private ConfigLoader configLoader;
private ZenodoCustomProvider zenodoCustomProvider;
@Autowired
public TokenValidatorFactoryImpl(
Environment environment,
AuthenticationService nonVerifiedUserAuthenticationService, B2AccessCustomProvider b2AccessCustomProvider,
ORCIDCustomProvider orcidCustomProvider, LinkedInCustomProvider linkedInCustomProvider, OpenAIRECustomProvider openAIRECustomProvider, ConfigurableProviderCustomProvider configurableProviderCustomProvider, ConfigLoader configLoader) {
ORCIDCustomProvider orcidCustomProvider, LinkedInCustomProvider linkedInCustomProvider, OpenAIRECustomProvider openAIRECustomProvider,
ConfigurableProviderCustomProvider configurableProviderCustomProvider, ConfigLoader configLoader,
ZenodoCustomProvider zenodoCustomProvider) {
this.environment = environment;
this.nonVerifiedUserAuthenticationService = nonVerifiedUserAuthenticationService;
this.b2AccessCustomProvider = b2AccessCustomProvider;
@ -83,6 +90,7 @@ public class TokenValidatorFactoryImpl implements TokenValidatorFactory {
this.openAIRECustomProvider = openAIRECustomProvider;
this.configurableProviderCustomProvider = configurableProviderCustomProvider;
this.configLoader = configLoader;
this.zenodoCustomProvider = zenodoCustomProvider;
}
public TokenValidator getProvider(LoginProvider provider) {
@ -103,6 +111,8 @@ public class TokenValidatorFactoryImpl implements TokenValidatorFactory {
return new OpenAIRETokenValidator(this.environment, this.nonVerifiedUserAuthenticationService, this.openAIRECustomProvider);
case CONFIGURABLE:
return new ConfigurableProviderTokenValidator(this.configurableProviderCustomProvider, this.nonVerifiedUserAuthenticationService, this.configLoader);
case ZENODO:
return new ZenodoTokenValidator(this.environment, this.nonVerifiedUserAuthenticationService, this.zenodoCustomProvider);
default:
throw new RuntimeException("Login Provider Not Implemented");
}

View File

@ -39,7 +39,8 @@ public class TwitterTokenValidator implements TokenValidator {
@Override
public Principal validateToken(LoginInfo credentials) throws NonValidTokenException, IOException, GeneralSecurityException, NullEmailException {
String verifier = (String) credentials.getData();
String verifier = (String) ((Map)credentials.getData()).get("verifier");
String email = (String) ((Map) credentials.getData()).get("email");
OAuthToken oAuthToken = new OAuthToken(credentials.getTicket(), verifier);
AuthorizedRequestToken authorizedRequestToken = new AuthorizedRequestToken(oAuthToken, verifier);
OAuthToken finalOauthToken = this.twitterServiceProvider.getOAuthOperations().exchangeForAccessToken(authorizedRequestToken, null);
@ -48,11 +49,18 @@ public class TwitterTokenValidator implements TokenValidator {
LoginProviderUser user = new LoginProviderUser();
Map values = twitterTemplate.getRestTemplate().getForObject("https://api.twitter.com/1.1/account/verify_credentials.json?include_email=true", Map.class);
if (values.get("email") == null)
throw new UnauthorisedException("Cannot login user.Twitter account did not provide email");
if (values.get("email") == null) {
// throw new UnauthorisedException("Cannot login user.Twitter account did not provide email");
user.setIsVerified(false); //TODO
if (email != null && !email.isEmpty()) {
user.setEmail(email);
}
}
else {
user.setEmail((String) values.get("email"));
user.setAvatarUrl(profile.getProfileImageUrl());
user.setIsVerified(true); //TODO
}
user.setAvatarUrl(profile.getProfileImageUrl());
user.setId("" + profile.getId());
user.setName(profile.getName());
user.setProvider(TokenValidatorFactoryImpl.LoginProvider.TWITTER);

View File

@ -0,0 +1,59 @@
package eu.eudat.logic.security.validators.zenodo;
import eu.eudat.exceptions.security.NonValidTokenException;
import eu.eudat.exceptions.security.NullEmailException;
import eu.eudat.logic.security.customproviders.ORCID.ORCIDCustomProvider;
import eu.eudat.logic.security.customproviders.ORCID.ORCIDUser;
import eu.eudat.logic.security.customproviders.Zenodo.ZenodoAccessType;
import eu.eudat.logic.security.customproviders.Zenodo.ZenodoCustomProvider;
import eu.eudat.logic.security.customproviders.Zenodo.ZenodoUser;
import eu.eudat.logic.security.validators.TokenValidator;
import eu.eudat.logic.security.validators.zenodo.helpers.ZenodoRequest;
import eu.eudat.logic.security.validators.zenodo.helpers.ZenodoResponseToken;
import eu.eudat.logic.services.operations.authentication.AuthenticationService;
import eu.eudat.models.data.login.LoginInfo;
import eu.eudat.models.data.loginprovider.LoginProviderUser;
import eu.eudat.models.data.security.Principal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.security.GeneralSecurityException;
@Component("zenodoTokenValidator")
public class ZenodoTokenValidator implements TokenValidator {
private ZenodoCustomProvider zenodoCustomProvider;
private Environment environment;
private AuthenticationService nonVerifiedUserAuthenticationService;
@Autowired
public ZenodoTokenValidator(Environment environment, AuthenticationService nonVerifiedUserAuthenticationService, ZenodoCustomProvider zenodoCustomProvider) {
this.environment = environment;
this.nonVerifiedUserAuthenticationService = nonVerifiedUserAuthenticationService;
this.zenodoCustomProvider = zenodoCustomProvider;
}
@Override
public Principal validateToken(LoginInfo credentials) throws NonValidTokenException, IOException, GeneralSecurityException, NullEmailException {
ZenodoUser zenodoUser = new ZenodoUser().getZenodoUser(credentials.getData());
LoginProviderUser user = new LoginProviderUser();
user.setId(zenodoUser.getUserId());
user.setName(zenodoUser.getEmail());
user.setEmail(zenodoUser.getEmail());
user.setZenodoId(zenodoUser.getAccessToken());
user.setZenodoExpire(zenodoUser.getExpiresIn());
user.setZenodoRefresh(zenodoUser.getRefreshToken());
user.setProvider(credentials.getProvider());
user.setSecret(credentials.getTicket());
return this.nonVerifiedUserAuthenticationService.Touch(user);
}
public ZenodoResponseToken getAccessToken(ZenodoRequest zenodoRequest) {
return this.zenodoCustomProvider.getAccessToken(ZenodoAccessType.AUTHORIZATION_CODE, zenodoRequest.getCode()
, this.environment.getProperty("zenodo.login.client_id")
, this.environment.getProperty("zenodo.login.client_secret")
, this.environment.getProperty("zenodo.login.redirect_uri"));
}
}

View File

@ -0,0 +1,12 @@
package eu.eudat.logic.security.validators.zenodo.helpers;
public class ZenodoRequest {
private String code;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
}

View File

@ -0,0 +1,47 @@
package eu.eudat.logic.security.validators.zenodo.helpers;
public class ZenodoResponseToken {
private String userId;
private String email;
private Integer expiresIn;
private String accessToken;
private String refreshToken;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Integer getExpiresIn() {
return expiresIn;
}
public void setExpiresIn(Integer expiresIn) {
this.expiresIn = expiresIn;
}
public String getAccessToken() {
return accessToken;
}
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
public String getRefreshToken() {
return refreshToken;
}
public void setRefreshToken(String refreshToken) {
this.refreshToken = refreshToken;
}
}

View File

@ -56,5 +56,9 @@ public interface DatabaseRepository {
NotificationDao getNotificationDao();
UserAssociationDao getUserAssociationDao();
DoiFunderDao getDoiFunderDao();
<T> void detachEntity(T entity);
}

View File

@ -37,6 +37,8 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
private FunderDao funderDao;
private LockDao lockDao;
private NotificationDao notificationDao;
private UserAssociationDao userAssociationDao;
private DoiFunderDao doiFunderDao;
private EntityManager entityManager;
@ -290,6 +292,26 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
return notificationDao;
}
@Override
public UserAssociationDao getUserAssociationDao() {
return userAssociationDao;
}
@Override
public DoiFunderDao getDoiFunderDao() {
return doiFunderDao;
}
@Autowired
public void setDoiFunderDao(DoiFunderDao doiFunderDao) {
this.doiFunderDao = doiFunderDao;
}
@Autowired
public void setUserAssociationDao(UserAssociationDao userAssociationDao) {
this.userAssociationDao = userAssociationDao;
}
@Autowired
public void setNotificationDao(NotificationDao notificationDao) {
this.notificationDao = notificationDao;

View File

@ -0,0 +1,11 @@
package eu.eudat.logic.services.operations;
import eu.eudat.elastic.repository.DatasetRepository;
import eu.eudat.elastic.repository.DmpRepository;
public interface ElasticRepository {
DatasetRepository getDatasetRepository();
DmpRepository getDmpRepository();
}

View File

@ -0,0 +1,29 @@
package eu.eudat.logic.services.operations;
import eu.eudat.elastic.repository.DatasetRepository;
import eu.eudat.elastic.repository.DmpRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service("elasticRepository")
public class ElasticRepositoryImpl implements ElasticRepository {
private final DatasetRepository datasetRepository;
private final DmpRepository dmpRepository;
@Autowired
public ElasticRepositoryImpl(DatasetRepository datasetRepository, DmpRepository dmpRepository) {
this.datasetRepository = datasetRepository;
this.dmpRepository = dmpRepository;
}
@Override
public DatasetRepository getDatasetRepository() {
return datasetRepository;
}
@Override
public DmpRepository getDmpRepository() {
return dmpRepository;
}
}

View File

@ -1,6 +1,7 @@
package eu.eudat.logic.services.operations;
import eu.eudat.elastic.repository.DatasetRepository;
import eu.eudat.elastic.repository.DmpRepository;
import eu.eudat.logic.builders.BuilderFactory;
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
import eu.eudat.logic.services.helpers.FileStorageService;
@ -21,5 +22,5 @@ public interface OperationsContext {
FileStorageService getFileStorageService();
DatasetRepository getDatasetRepository();
ElasticRepository getElasticRepository();
}

View File

@ -1,6 +1,7 @@
package eu.eudat.logic.services.operations;
import eu.eudat.elastic.repository.DatasetRepository;
import eu.eudat.elastic.repository.DmpRepository;
import eu.eudat.logic.builders.BuilderFactory;
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
import eu.eudat.logic.services.helpers.FileStorageService;
@ -14,22 +15,22 @@ import org.springframework.stereotype.Service;
@Service("operationsContext")
public class OperationsContextImpl implements OperationsContext {
private DatabaseRepository databaseRepository;
private ApplicationContext applicationContext;
private RemoteFetcher remoteFetcher;
private BuilderFactory builderFactory;
private FileStorageService fileStorageService;
private DatasetRepository datasetRepository;
private final DatabaseRepository databaseRepository;
private final ApplicationContext applicationContext;
private final RemoteFetcher remoteFetcher;
private final BuilderFactory builderFactory;
private final FileStorageService fileStorageService;
private final ElasticRepository elasticRepository;
@Autowired
public OperationsContextImpl(DatabaseRepository databaseRepository, ApplicationContext applicationContext, RemoteFetcher remoteFetcher
, BuilderFactory builderFactory, FileStorageService fileStorageService, DatasetRepository datasetRepository) {
, BuilderFactory builderFactory, FileStorageService fileStorageService, ElasticRepository elasticRepository) {
this.databaseRepository = databaseRepository;
this.applicationContext = applicationContext;
this.remoteFetcher = remoteFetcher;
this.builderFactory = builderFactory;
this.fileStorageService = fileStorageService;
this.datasetRepository = datasetRepository;
this.elasticRepository = elasticRepository;
}
@Override
@ -58,11 +59,7 @@ public class OperationsContextImpl implements OperationsContext {
}
@Override
public DatasetRepository getDatasetRepository() {
return datasetRepository;
}
public void setDatasetRepository(DatasetRepository datasetRepository) {
this.datasetRepository = datasetRepository;
public ElasticRepository getElasticRepository() {
return elasticRepository;
}
}

View File

@ -20,6 +20,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
import org.springframework.transaction.annotation.Transactional;
import java.time.Instant;
import java.util.*;
public abstract class AbstractAuthenticationService implements AuthenticationService {
@ -132,7 +133,11 @@ public abstract class AbstractAuthenticationService implements AuthenticationSer
userInfo = this.apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class)
.name(profile.getName()).verified_email(profile.getIsVerified())
.email(profile.getEmail()).created(new Date()).lastloggedin(new Date())
.additionalinfo("{\"data\":{\"avatar\":{\"url\":\"" + profile.getAvatarUrl() + "\"}}}")
.additionalinfo("{\"data\":{\"avatar\":{\"url\":\"" + profile.getAvatarUrl()
+ "\"},\"zenodoToken\":\"" + profile.getZenodoId()
+ "\", \"expirationDate\": \"" + Instant.now().plusSeconds((profile.getZenodoExpire() != null ? profile.getZenodoExpire(): 0)).toEpochMilli()
+ "\", \"zenodoRefresh\": \"" + profile.getZenodoRefresh()
+ (profile.getProvider() == TokenValidatorFactoryImpl.LoginProvider.ZENODO ? "\", \"zenodoEmail\": \"" + profile.getEmail() : "") +"\"}}")
.authorization_level((short) 1).usertype((short) 1)
.build();
@ -149,7 +154,21 @@ public abstract class AbstractAuthenticationService implements AuthenticationSer
} else {
Map<String, Object> additionalInfo = userInfo.getAdditionalinfo() != null ?
new JSONObject(userInfo.getAdditionalinfo()).toMap() : new HashMap<>();
if (profile.getAvatarUrl() != null && !profile.getAvatarUrl().isEmpty() && !profile.getAvatarUrl().equals("null")) {
additionalInfo.put("avatarUrl", profile.getAvatarUrl());
}
if (profile.getZenodoId() != null && !profile.getZenodoId().isEmpty() && !profile.getZenodoId().equals("null")) {
additionalInfo.put("zenodoToken", profile.getZenodoId());
}
if (profile.getZenodoExpire() != null) {
additionalInfo.put("expirationDate", Instant.now().plusSeconds(profile.getZenodoExpire()).toEpochMilli());
}
if (profile.getZenodoRefresh() != null) {
additionalInfo.put("zenodoRefresh", profile.getZenodoRefresh());
}
if (profile.getProvider() == TokenValidatorFactoryImpl.LoginProvider.ZENODO) {
additionalInfo.put("zenodoEmail", profile.getEmail());
}
userInfo.setLastloggedin(new Date());
userInfo.setAdditionalinfo(new JSONObject(additionalInfo).toString());
Set<Credential> credentials = userInfo.getCredentials();

View File

@ -11,6 +11,7 @@ import eu.eudat.types.Authorities;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import java.time.Instant;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
@ -33,6 +34,30 @@ public class NonVerifiedUserEmailAuthenticationService extends AbstractAuthentic
} catch (Exception e) {
avatarUrl = "";
}
String zenodoToken;
try {
zenodoToken = user.getAdditionalinfo() != null ? new ObjectMapper().readTree(user.getAdditionalinfo()).get("zenodoToken").asText() : "";
} catch (Exception e) {
zenodoToken = "";
}
Instant zenodoDuration;
try {
zenodoDuration = user.getAdditionalinfo() != null ? Instant.ofEpochMilli(new ObjectMapper().readTree(user.getAdditionalinfo()).get("expirationDate").asLong()) : Instant.now();
} catch (Exception e) {
zenodoDuration = Instant.now();
}
String zenodoEmail;
try {
zenodoEmail = user.getAdditionalinfo() != null ? new ObjectMapper().readTree(user.getAdditionalinfo()).get("zenodoEmail").asText() : "";
} catch (Exception e) {
zenodoEmail = "";
}
String zenodoRefresh;
try {
zenodoRefresh = user.getAdditionalinfo() != null ? new ObjectMapper().readTree(user.getAdditionalinfo()).get("zenodoRefresh").asText() : "";
} catch (Exception e) {
zenodoRefresh = "";
}
String culture;
try {
culture = user.getAdditionalinfo() != null ? new ObjectMapper().readTree(user.getAdditionalinfo()).get("culture").get("name").asText() : "";
@ -58,6 +83,10 @@ public class NonVerifiedUserEmailAuthenticationService extends AbstractAuthentic
.culture(culture)
.language(language)
.timezone(timezone)
.zenodoToken(zenodoToken)
.zenodoDuration(zenodoDuration)
.zenodoEmail(zenodoEmail)
.zenodoRefresh(zenodoRefresh)
.build();
List<UserRole> userRoles = apiContext.getOperationsContext().getDatabaseRepository().getUserRoleDao().getUserRoles(user);

View File

@ -20,6 +20,7 @@ import org.json.JSONObject;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import java.time.Instant;
import java.util.*;
@ -42,6 +43,30 @@ public class VerifiedUserAuthenticationService extends AbstractAuthenticationSer
} catch (Exception e) {
avatarUrl = "";
}
String zenodoToken;
try {
zenodoToken = user.getAdditionalinfo() != null ? new ObjectMapper().readTree(user.getAdditionalinfo()).get("zenodoToken").asText() : "";
} catch (Exception e) {
zenodoToken = "";
}
Instant zenodoDuration;
try {
zenodoDuration = user.getAdditionalinfo() != null ? Instant.ofEpochMilli(new ObjectMapper().readTree(user.getAdditionalinfo()).get("expirationDate").asLong()) : Instant.now();
} catch (Exception e) {
zenodoDuration = Instant.now();
}
String zenodoEmail;
try {
zenodoEmail = user.getAdditionalinfo() != null ? new ObjectMapper().readTree(user.getAdditionalinfo()).get("zenodoEmail").asText() : "";
} catch (Exception e) {
zenodoEmail = "";
}
String zenodoRefresh;
try {
zenodoRefresh = user.getAdditionalinfo() != null ? new ObjectMapper().readTree(user.getAdditionalinfo()).get("zenodoRefresh").asText() : "";
} catch (Exception e) {
zenodoRefresh = "";
}
String culture;
try {
culture = user.getAdditionalinfo() != null ? new ObjectMapper().readTree(user.getAdditionalinfo()).get("culture").get("name").asText() : "";
@ -67,6 +92,10 @@ public class VerifiedUserAuthenticationService extends AbstractAuthenticationSer
.culture(culture)
.language(language)
.timezone(timezone)
.zenodoToken(zenodoToken)
.zenodoDuration(zenodoDuration)
.zenodoEmail(zenodoEmail)
.zenodoRefresh(zenodoRefresh)
.build();
List<UserRole> userRoles = apiContext.getOperationsContext().getDatabaseRepository().getUserRoleDao().getUserRoles(user);

View File

@ -164,8 +164,8 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
this.description = entity.getDescription();
this.profile = entity.getProfile().getId();
this.uri = entity.getUri();
this.registries = entity.getRegistries().stream().map(item -> new Registry().fromDataModel(item)).collect(Collectors.toList());
this.dataRepositories = entity.getDatasetDataRepositories().stream().map(item -> {
this.registries = entity.getRegistries() != null ? entity.getRegistries().stream().map(item -> new Registry().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
this.dataRepositories = entity.getDatasetDataRepositories() != null ? entity.getDatasetDataRepositories().stream().map(item -> {
DataRepository dataRepository = new DataRepository().fromDataModel(item.getDataRepository());
if (item.getData() != null) {
Map<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
@ -173,11 +173,11 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
dataRepository.setInfo(values.get("info"));
}
return dataRepository;
}).collect(Collectors.toList());
this.services = entity.getServices().stream().map(item -> new Service().fromDataModel(item.getService())).collect(Collectors.toList());
}).collect(Collectors.toList()) : new ArrayList<>();
this.services = entity.getServices() != null ? entity.getServices().stream().map(item -> new Service().fromDataModel(item.getService())).collect(Collectors.toList()) : new ArrayList<>();
this.created = entity.getCreated();
this.dmp = new DataManagementPlan().fromDataModelNoDatasets(entity.getDmp());
this.externalDatasets = entity.getDatasetExternalDatasets().stream().map(item -> {
this.externalDatasets = entity.getDatasetExternalDatasets() != null ? entity.getDatasetExternalDatasets().stream().map(item -> {
ExternalDatasetListingModel externalDatasetListingModel = new ExternalDatasetListingModel().fromDataModel(item.getExternalDataset());
if (item.getData() != null) {
Map<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
@ -186,7 +186,7 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
externalDatasetListingModel.setType(Integer.parseInt(values.get("type")));
}
return externalDatasetListingModel;
}).collect(Collectors.toList());
}).collect(Collectors.toList()) : new ArrayList<>();
this.modified = entity.getModified();
return this;
}

View File

@ -327,16 +327,15 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
public DataManagementPlan fromDataModelNoDatasets(DMP entity) {
this.id = entity.getId();
this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(entity.getProfile().getId(), entity.getProfile().getLabel()) : null;
this.organisations = entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
this.researchers = entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList());
this.organisations = entity.getOrganisations() != null ? entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
this.researchers = entity.getResearchers() != null ? entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
this.version = entity.getVersion();
this.groupId = this.groupId == null ? null : this.groupId;
this.label = entity.getLabel();
this.grant = new Grant();
this.properties = entity.getProperties() != null ? new org.json.JSONObject(entity.getProperties()).toMap() : null;
this.creator = new eu.eudat.models.data.userinfo.UserInfo();
this.groupId = entity.getGroupId();
this.lockable = entity.getDataset().stream().findAny().isPresent();
this.lockable = entity.getDataset() != null && entity.getDataset().stream().findAny().isPresent();
this.definition = entity.getProfile() == null ? null : new DataManagementPlanProfile().fromXml(XmlBuilder.fromXml(entity.getProfile().getDefinition()).getDocumentElement());
if (this.definition != null && this.definition.getFields() != null && !this.definition.getFields().isEmpty() && this.properties != null) {
this.definition.getFields().forEach(item -> {
@ -344,7 +343,7 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
fieldOptional.ifPresent(stringObjectMap -> item.setValue(stringObjectMap.get("value")));
});
}
if (entity.getUsers().stream().anyMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())))
if (entity.getUsers() != null && entity.getUsers().stream().anyMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())))
this.creator.fromDataModel(entity.getUsers().stream().filter(user -> user.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser());
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
@ -358,8 +357,8 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
this.created = entity.getCreated();
this.description = entity.getDescription();
this.status = entity.getStatus();
this.associatedUsers = entity.getUsers().stream().map(item -> new UserListingModel().fromDataModel(item.getUser())).collect(Collectors.toList());
this.users = entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList());
this.associatedUsers = entity.getUsers() != null ? entity.getUsers().stream().map(item -> new UserListingModel().fromDataModel(item.getUser())).collect(Collectors.toList()) : new ArrayList<>();
this.users = entity.getUsers() != null ? entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
this.doi = entity.getDoi();
this.grant.fromDataModel(entity.getGrant());

View File

@ -68,19 +68,23 @@ public class Organisation implements DataModel<eu.eudat.data.entities.Organisati
this.id = entity.getId().toString();
this.name = entity.getLabel();
this.label = entity.getUri();
if (entity.getReference() != null) {
this.reference = entity.getReference();
this.key = entity.getReference().substring(0, entity.getReference().indexOf(":"));
}
return this;
}
@Override
public eu.eudat.data.entities.Organisation toDataModel() {
eu.eudat.data.entities.Organisation organisationEntity = new eu.eudat.data.entities.Organisation();
if (this.key != null && this.reference != null) {
if ((this.key + ":").equals(this.reference.substring(0, this.key.length() + 1))) {
organisationEntity.setReference(this.reference);
} else {
organisationEntity.setReference(this.key + ":" + this.reference);
}
}
organisationEntity.setLabel(this.name);
organisationEntity.setUri(this.label);
organisationEntity.setCreated(new Date());

View File

@ -0,0 +1,25 @@
package eu.eudat.models.data.doi;
import eu.eudat.logic.security.validators.zenodo.helpers.ZenodoRequest;
public class DOIRequest {
private ZenodoRequest zenodoRequest;
private String redirectUri;
public ZenodoRequest getZenodoRequest() {
return zenodoRequest;
}
public void setZenodoRequest(ZenodoRequest zenodoRequest) {
this.zenodoRequest = zenodoRequest;
}
public String getRedirectUri() {
return redirectUri;
}
public void setRedirectUri(String redirectUri) {
this.redirectUri = redirectUri;
}
}

View File

@ -37,7 +37,7 @@ public class ExternalSourcesConfiguration {
private List<ExternalSourcesUrlModel> dataRepositories;
private List<ExternalSourcesUrlModel> services;
private List<ExternalSourcesUrlModel> externalDatasets;
private List<ExternalSourcesUrlModel> tags;
/* private List<ExternalSourcesUrlModel> tags;
public List<ExternalSourcesUrlModel> getTags() {
return tags;
@ -45,7 +45,7 @@ public class ExternalSourcesConfiguration {
public void setTags(List<ExternalSourcesUrlModel> tags) {
this.tags = tags;
}
}*/
public List<ExternalSourcesUrlModel> getRegistries() {
return registries;

View File

@ -11,6 +11,9 @@ public class LoginProviderUser {
private String avatarUrl;
private boolean isVerified;
private TokenValidatorFactoryImpl.LoginProvider provider;
private String zenodoId;
private Integer zenodoExpire;
private String zenodoRefresh;
public String getId() {
return id;
@ -67,4 +70,28 @@ public class LoginProviderUser {
public void setAvatarUrl(String avatarUrl) {
this.avatarUrl = avatarUrl;
}
public String getZenodoId() {
return zenodoId;
}
public void setZenodoId(String zenodoId) {
this.zenodoId = zenodoId;
}
public Integer getZenodoExpire() {
return zenodoExpire;
}
public void setZenodoExpire(Integer zenodoExpire) {
this.zenodoExpire = zenodoExpire;
}
public String getZenodoRefresh() {
return zenodoRefresh;
}
public void setZenodoRefresh(String zenodoRefresh) {
this.zenodoRefresh = zenodoRefresh;
}
}

View File

@ -164,7 +164,9 @@ public class Project implements DataModel<eu.eudat.data.entities.Project, Projec
this.abbreviation = entity.getAbbreviation();
this.reference = entity.getReference();
this.uri = entity.getUri();
if (entity.getType() != null) {
this.type = entity.getType();
}
this.definition = entity.getDefinition();
this.startDate = entity.getStartdate();
this.endDate = entity.getEnddate();

View File

@ -3,6 +3,7 @@ package eu.eudat.models.data.security;
import com.fasterxml.jackson.annotation.JsonIgnore;
import eu.eudat.types.Authorities;
import java.time.Instant;
import java.util.*;
import java.util.stream.Collectors;
@ -17,6 +18,10 @@ public class Principal {
private String culture;
private String language;
private String timezone;
private String zenodoToken;
private Instant zenodoDuration;
private String zenodoRefresh;
private String zenodoEmail;
public UUID getId() {
return id;
@ -86,6 +91,38 @@ public class Principal {
this.timezone = timezone;
}
public String getZenodoToken() {
return zenodoToken;
}
public void setZenodoToken(String zenodoToken) {
this.zenodoToken = zenodoToken;
}
public Instant getZenodoDuration() {
return zenodoDuration;
}
public void setZenodoDuration(Instant zenodoDuration) {
this.zenodoDuration = zenodoDuration;
}
public String getZenodoRefresh() {
return zenodoRefresh;
}
public void setZenodoRefresh(String zenodoRefresh) {
this.zenodoRefresh = zenodoRefresh;
}
public String getZenodoEmail() {
return zenodoEmail;
}
public void setZenodoEmail(String zenodoEmail) {
this.zenodoEmail = zenodoEmail;
}
@JsonIgnore
public Set<Authorities> getAuthz() {
return this.authorities;

View File

@ -69,8 +69,15 @@ conf_email.subject=OpenDMP email confirmation
#############ZENODO CONFIGURATIONS#########
zenodo.url=https://sandbox.zenodo.org/api/
zenodo.access_token=
zenodo.login.access_token_url=https://sandbox.zenodo.org/oauth/token
zenodo.login.client_id=
zenodo.login.client_secret=
zenodo.login.redirect_uri=http://localhost:4200/login/external/zenodo
#############CONTACT EMAIL CONFIGURATIONS#########
contact_email.mail=
language.path=tempLang/i18n/
language.path=i18n/
#############LOGGING#########
logging.config=classpath:logging/logback-${spring.profiles.active}.xml

View File

@ -1,9 +1,9 @@
dmp.domain = https://devel.opendmp.eu
####################PERSISTENCE OVERRIDES CONFIGURATIONS##########
database.url=
database.username=
database.password=
database.url=jdbc:postgresql://dmp-db:5432/dmptool
database.username=dmptool
database.password=CHANGEME
####################ELASTIIC SEARCH TAGS OVERRIDES CONFIGURATIONS##########
elasticsearch.host = tags-elastic-search
@ -18,10 +18,10 @@ http-logger.server-address = http://logstash:31311
pdf.converter.url=http://docsbox-web/
####################CONFIGURATION FILES OVERRIDES CONFIGURATIONS##########
configuration.externalUrls=/tmp/ExternalUrls.xml
configuration.externalUrls=externalUrls/ExternalUrls.xml
configuration.rda=/tmp/RDACommonStandards.txt
configuration.h2020template=tmp/h2020.docx
configuration.configurable_login_providers=
configuration.h2020template=documents/h2020.docx
configuration.configurable_login_providers=/tmp/ConfigurableLoginProviders.json
####################INVITATION MAIL CONFIGURATIONS##############
####################GENERIC MAIL CONFIGURATIONS#################
@ -87,3 +87,5 @@ zenodo.access_token=
#############CONTACT EMAIL CONFIGURATIONS#########
contact_email.mail=
language.path=i18n/

View File

@ -1,8 +1,8 @@
server.port=8080
server.port=8081
server.tomcat.max-threads = 20
server.tomcat.max-connections = 10000
logging.file=/logs/spring-boot-logging.log
spring.profiles.active=devel
spring.profiles.active=staging
eu.eudat.logic.proxy.allowed.host=https://eestore.paas2.uninett.no
####################INVITATION MAIL CONFIGURATIONS##############
@ -79,7 +79,7 @@ database.lock-fail-interval=120000
##########################MISC##########################################
#############USER GUIDE#########
userguide.path=guide/
userguide.path=user-guide/
#############NOTIFICATION#########
notification.rateInterval=30000
@ -90,7 +90,7 @@ notification.finalised.subject=[OpenDMP] The {name} has been finalised
notification.modifiedFinalised.subject=[OpenDMP] The {name} has been modified and finalised
#############LOGGING#########
logging.config=classpath:logging/logback-${spring.profiles.active}.xml
logging.config=file:logging/logback-${spring.profiles.active}.xml
#############TEMP#########
temp.temp=tmp/

View File

@ -65,7 +65,7 @@
<fetchMode>FIRST</fetchMode> <!-- EITHER 'FIRST' OR 'ALL' -->
</registries>
<tags>
<!--<tags>
<urls>
<urlConfig>
<key>cristin</key>
@ -86,7 +86,7 @@
</data>
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
</urlConfig>
<!-- <urlConfig>
&lt;!&ndash; <urlConfig>
<key>openAire</key>
<label>OpenAIRE</label>
<ordinal>1</ordinal>
@ -120,10 +120,10 @@
</fields>
</data>
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
</urlConfig>-->
</urlConfig>&ndash;&gt;
</urls>
<fetchMode>FIRST</fetchMode> <!-- EITHER 'FIRST' OR 'ALL' -->
</tags>
<fetchMode>FIRST</fetchMode> &lt;!&ndash; EITHER 'FIRST' OR 'ALL' &ndash;&gt;
</tags>-->
<grants>
<urls>

View File

@ -7,9 +7,9 @@
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/files/logs/openDMP.log</file>
<file>/app/logs/openDMP.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/files/logs/openDMP-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<fileNamePattern>/app/logs/openDMP-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>

View File

@ -7,9 +7,9 @@
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/files/logs/openDMP.log</file>
<file>/app/logs/openDMP.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/files/logs/openDMP-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<fileNamePattern>/app/logs/openDMP-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>

View File

@ -16,6 +16,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="what-kinds-data-collected-produced-reused-formats" ordinal="0">
<rdaCommonStandard>dataset.type</rdaCommonStandard>
<numbering>1.1.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -35,6 +36,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="consistency-and-quality-data-controlled" ordinal="0">
<rdaCommonStandard>dataset.data_quality_assurance</rdaCommonStandard>
<numbering>1.2.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -63,6 +65,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="ethical-issues-sensitive-data-gaining" ordinal="0">
<rdaCommonStandard>dataset.sensitive_data</rdaCommonStandard>
<numbering>2.1.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -82,6 +85,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="data-ownership-copyright-ipr-issues" ordinal="0">
<rdaCommonStandard>dataset.distribution.license.license_ref</rdaCommonStandard>
<numbering>2.2.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -110,6 +114,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="document-data-fair" ordinal="0">
<rdaCommonStandard>dataset.metadata.metadata_standard_id</rdaCommonStandard>
<numbering>3.1.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -138,6 +143,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="where-will-data-stored-how-will-backed" ordinal="0">
<rdaCommonStandard>dataset.distribution.host.url</rdaCommonStandard>
<numbering>4.1.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -157,6 +163,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="who-will-be-responsible-how-will-secure" ordinal="0">
<rdaCommonStandard>dataset.security_and_privacy.title</rdaCommonStandard>
<numbering>4.2.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -185,6 +192,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="data-openly-published-where-when" ordinal="0">
<rdaCommonStandard>dataset.distribution.data_access</rdaCommonStandard>
<numbering>5.1.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -204,6 +212,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="will-data-long-term-value-archived" ordinal="0">
<rdaCommonStandard>dataset.preservation_statement</rdaCommonStandard>
<numbering>5.2.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -232,6 +241,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="who-will-responsible-specific-tasks" ordinal="0">
<rdaCommonStandard>dataset.technical_resource.technical_resource.name</rdaCommonStandard>
<numbering>6.1.1</numbering>
<validations/>
<defaultValue type="" value=""/>

View File

@ -14,6 +14,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="what-kinds-of-data-source-code" ordinal="0">
<rdaCommonStandard>dataset.type</rdaCommonStandard>
<numbering>1.1.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -33,6 +34,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="how-will-the-research-data-be-generated" ordinal="0">
<rdaCommonStandard/>
<numbering>1.2.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -52,6 +54,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="how-will-you-structure-the-data" ordinal="0">
<rdaCommonStandard>dataset.distribution.host.supports_versioning</rdaCommonStandard>
<numbering>1.3.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -71,6 +74,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="who-is-the-target" ordinal="0">
<rdaCommonStandard/>
<numbering>1.4.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -101,6 +105,7 @@
<commentField commentFieldValue="" hasCommentField="true"/>
<fields>
<field id="will-use-metadata-question" ordinal="1">
<rdaCommonStandard/>
<numbering>2.1.1.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -116,6 +121,7 @@
<data label=""/>
</field>
<field id="metadata-selector" ordinal="2">
<rdaCommonStandard>dataset.metadata.metadata_standard_id</rdaCommonStandard>
<numbering>2.1.1.2</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -126,6 +132,7 @@
</data>
</field>
<field id="other-checkbox-metadata" ordinal="3">
<rdaCommonStandard/>
<numbering>2.1.1.3</numbering>
<validations/>
<defaultValue type="" value="false"/>
@ -149,6 +156,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="url-metadata" ordinal="1">
<rdaCommonStandard>dataset.metadata.metadata_standard_id.identifier</rdaCommonStandard>
<numbering>2.1.2.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -157,6 +165,7 @@
<data label="URL where metadata can be found"/>
</field>
<field id="location-metadata" ordinal="2">
<rdaCommonStandard>dataset.metadata.description</rdaCommonStandard>
<numbering>2.1.2.2</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -176,6 +185,7 @@
<commentField commentFieldValue="" hasCommentField="true"/>
<fields>
<field id="boolean-metadata-standardized-vocabularies" ordinal="1">
<rdaCommonStandard/>
<numbering>2.1.3.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -191,6 +201,7 @@
<data label=""/>
</field>
<field id="standardized-vocabularies-autocomplete" ordinal="2">
<rdaCommonStandard/>
<numbering>2.1.3.2</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -201,6 +212,7 @@
</data>
</field>
<field id="other-not-listed-items" ordinal="3">
<rdaCommonStandard/>
<numbering>2.1.3.3</numbering>
<validations/>
<defaultValue type="" value="false"/>
@ -224,6 +236,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="url-other-vocabularies" ordinal="1">
<rdaCommonStandard/>
<numbering>2.1.4.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -232,6 +245,7 @@
<data label=" URL where the vocabularies of the data can be found"/>
</field>
<field id="desc-other-vocabularies" ordinal="2">
<rdaCommonStandard/>
<numbering>2.1.4.2</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -262,6 +276,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="openly-accessible-field" ordinal="0">
<rdaCommonStandard>dataset.distribution.data_access</rdaCommonStandard>
<numbering>2.2.1.1.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -276,9 +291,9 @@
<viewStyle cssClass="" renderstyle="combobox"/>
<data label="Select from the list" type="wordlist">
<options>
<option label="all" source="" value="all"/>
<option label="some" source="" value="some"/>
<option label="none" source="" value="none"/>
<option label="all" source="" uri="" value="all"/>
<option label="some" source="" uri="" value="some"/>
<option label="none" source="" uri="" value="none"/>
</options>
</data>
</field>
@ -294,6 +309,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="data-type-openly-accessible" ordinal="1">
<rdaCommonStandard>dataset.distribution.format</rdaCommonStandard>
<numbering>2.2.1.2.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -302,6 +318,7 @@
<data label="Data type"/>
</field>
<field id="reason-openly-accessible" ordinal="2">
<rdaCommonStandard>dataset.distribution.description</rdaCommonStandard>
<numbering>2.2.1.2.2</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -310,6 +327,7 @@
<data label="Please specify"/>
</field>
<field id="url-openly-accessible" ordinal="3">
<rdaCommonStandard>dataset.distribution.access_url</rdaCommonStandard>
<numbering>2.2.1.2.3</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -329,6 +347,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="data-type-openly-accessible2" ordinal="1">
<rdaCommonStandard>dataset.distribution.format</rdaCommonStandard>
<numbering>2.2.1.3.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -337,6 +356,7 @@
<data label="Data Type"/>
</field>
<field id="reason-openly-accessible2" ordinal="2">
<rdaCommonStandard>dataset.distribution.description</rdaCommonStandard>
<numbering>2.2.1.3.2</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -345,6 +365,7 @@
<data label="Please specify"/>
</field>
<field id="url-openly-accessible2" ordinal="3">
<rdaCommonStandard>dataset.distribution.access_url</rdaCommonStandard>
<numbering>2.2.1.3.3</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -364,6 +385,7 @@
<commentField commentFieldValue="" hasCommentField="true"/>
<fields>
<field id="repositories223" ordinal="1">
<rdaCommonStandard>dataset.distribution.host.title</rdaCommonStandard>
<numbering>2.2.1.4.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -374,6 +396,7 @@
</data>
</field>
<field id="not-listed-available" ordinal="2">
<rdaCommonStandard/>
<numbering>2.2.1.4.2</numbering>
<validations/>
<defaultValue type="" value="false"/>
@ -397,6 +420,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="url223" ordinal="1">
<rdaCommonStandard>dataset.distribution.host.url</rdaCommonStandard>
<numbering>2.2.1.5.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -405,6 +429,7 @@
<data label="URL where the data are stored"/>
</field>
<field id="name223" ordinal="2">
<rdaCommonStandard>dataset.distribution.host.title</rdaCommonStandard>
<numbering>2.2.1.5.2</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -433,6 +458,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="provide-persistent-identifiers" ordinal="0">
<rdaCommonStandard/>
<numbering>2.2.2.1.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -456,6 +482,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="persistent-identifiers" ordinal="0">
<rdaCommonStandard/>
<numbering>2.2.2.2.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -463,8 +490,8 @@
<viewStyle cssClass="" renderstyle="combobox"/>
<data label="Select" type="wordlist">
<options>
<option label="DOI" source="" value="DOI"/>
<option label="Persistent Unique Identifier" source="" value="Persistent Unique Identifier"/>
<option label="DOI" source="" uri="" value="DOI"/>
<option label="Persistent Unique Identifier" source="" uri="" value="Persistent Unique Identifier"/>
</options>
</data>
</field>
@ -480,6 +507,7 @@
<commentField commentFieldValue="" hasCommentField="true"/>
<fields>
<field id="provide-searchable-metadata-for-your" ordinal="0">
<rdaCommonStandard/>
<numbering>2.2.2.3.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -503,6 +531,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="search-services-provide-metadata" ordinal="1">
<rdaCommonStandard/>
<numbering>2.2.2.4.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -513,6 +542,7 @@
</data>
</field>
<field id="not-listed-services-provide-metadata" ordinal="2">
<rdaCommonStandard/>
<numbering>2.2.2.4.2</numbering>
<validations/>
<defaultValue type="" value="false"/>
@ -536,6 +566,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="url-not-listed-searchable-metadata" ordinal="1">
<rdaCommonStandard/>
<numbering>2.2.2.5.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -544,6 +575,7 @@
<data label="URL of the services providing searchable metadata"/>
</field>
<field id="name-not-listed-searchable-metadata" ordinal="2">
<rdaCommonStandard/>
<numbering>2.2.2.5.2</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -572,6 +604,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="how-you-planning-document-information-field" ordinal="0">
<rdaCommonStandard/>
<numbering>2.2.3.1.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -607,6 +640,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="quality-assurance-processes-will-you-adopt" ordinal="0">
<rdaCommonStandard>dataset.data_quality_assurance</rdaCommonStandard>
<numbering>2.3.1.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -626,6 +660,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="consistency-and-quality-of-data-collection" ordinal="0">
<rdaCommonStandard/>
<numbering>2.3.2.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -663,6 +698,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="what-persistent-identifier-will-used" ordinal="0">
<rdaCommonStandard>dataset.type</rdaCommonStandard>
<numbering>3.1.1.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -691,6 +727,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="will-data-be-preserved-long-term" ordinal="0">
<rdaCommonStandard>dataset.preservation_statement</rdaCommonStandard>
<numbering>3.2.1.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -714,6 +751,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="data-will-not-be-stored" ordinal="0">
<rdaCommonStandard>dataset.sensitive_data</rdaCommonStandard>
<numbering>3.2.2.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -733,6 +771,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="data-that-will-be-preserved-long-term" ordinal="0">
<rdaCommonStandard/>
<numbering>3.2.3.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -759,6 +798,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="data-items-preserved-long-term" ordinal="0">
<rdaCommonStandard/>
<numbering>3.2.4.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -778,6 +818,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="use-standardized-formats-some-data" ordinal="0">
<rdaCommonStandard/>
<numbering>3.2.5.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -804,6 +845,7 @@
<commentField commentFieldValue="" hasCommentField="true"/>
<fields>
<field id="standardiseddataformats" ordinal="1">
<rdaCommonStandard/>
<numbering>3.2.6.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -814,6 +856,7 @@
</data>
</field>
<field id="other-standardized-format" ordinal="2">
<rdaCommonStandard/>
<numbering>3.2.6.2</numbering>
<validations/>
<defaultValue type="" value="false"/>
@ -837,6 +880,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="url-of-other-standardized-formats" ordinal="1">
<rdaCommonStandard/>
<numbering>3.2.7.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -845,6 +889,7 @@
<data label="URL where this information can be found"/>
</field>
<field id="name-of-other-standardized-formats" ordinal="2">
<rdaCommonStandard/>
<numbering>3.2.7.2</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -864,6 +909,7 @@
<commentField commentFieldValue="" hasCommentField="true"/>
<fields>
<field id="url-formats-to-plan-to-store" ordinal="1">
<rdaCommonStandard/>
<numbering>3.2.8.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -872,6 +918,7 @@
<data label=""/>
</field>
<field id="name-formats-to-plan-to-store" ordinal="2">
<rdaCommonStandard/>
<numbering>3.2.8.2</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -880,6 +927,7 @@
<data label=""/>
</field>
<field id="checkbox-formats-to-plan-to-store" ordinal="3">
<rdaCommonStandard/>
<numbering>3.2.8.3</numbering>
<validations/>
<defaultValue type="" value="false"/>
@ -899,6 +947,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="how-data-stored-sufficiently-secure" ordinal="0">
<rdaCommonStandard>dataset.distribution.host.storage_type</rdaCommonStandard>
<numbering>3.2.9.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -918,6 +967,7 @@
<commentField commentFieldValue="" hasCommentField="true"/>
<fields>
<field id="where-data-stored-sufficiently-secure" ordinal="0">
<rdaCommonStandard/>
<numbering>3.2.10.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -925,10 +975,10 @@
<viewStyle cssClass="" renderstyle="combobox"/>
<data label="Select" type="wordlist">
<options>
<option label="secure with backup and recovery" source="" value="securewithbackupandrecovery"/>
<option label="secure with no backup and recovery" source="" value="securewithnobackupandrecovery"/>
<option label="insecure with backup and recovery" source="" value="insecurewithbackupandrecovery"/>
<option label="insecure with no backup or recovery" source="" value="insecurewithnobackuporrecovery"/>
<option label="secure with backup and recovery" source="" uri="" value="securewithbackupandrecovery"/>
<option label="secure with no backup and recovery" source="" uri="" value="securewithnobackupandrecovery"/>
<option label="insecure with backup and recovery" source="" uri="" value="insecurewithbackupandrecovery"/>
<option label="insecure with no backup or recovery" source="" uri="" value="insecurewithnobackuporrecovery"/>
</options>
</data>
</field>
@ -944,6 +994,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="for-how-long-data-be-stored-3" ordinal="0">
<rdaCommonStandard>dataset.distribution.available_till</rdaCommonStandard>
<numbering>3.2.11.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -951,9 +1002,9 @@
<viewStyle cssClass="" renderstyle="combobox"/>
<data label="Select from the list of answers" type="wordlist">
<options>
<option label="Less than 2 years" source="" value="lessthantwoyears"/>
<option label="Up to 5 years" source="" value="uptofiveyears"/>
<option label="More than 10 years" source="" value="morethantenyears"/>
<option label="Less than 2 years" source="" uri="" value="lessthantwoyears"/>
<option label="Up to 5 years" source="" uri="" value="uptofiveyears"/>
<option label="More than 10 years" source="" uri="" value="morethantenyears"/>
</options>
</data>
</field>
@ -969,6 +1020,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="costs-that-need-coverage" ordinal="0">
<rdaCommonStandard/>
<numbering>3.2.12.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -988,6 +1040,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="point-during-after-data-stored" ordinal="0">
<rdaCommonStandard/>
<numbering>3.2.13.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -1012,6 +1065,7 @@
<commentField commentFieldValue="" hasCommentField="true"/>
<fields>
<field id="technical-barriers-making-research-data-accessible" ordinal="0">
<rdaCommonStandard>dataset.technical_resource.description</rdaCommonStandard>
<numbering>3.2.14.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -1049,6 +1103,7 @@
<commentField commentFieldValue="" hasCommentField="true"/>
<fields>
<field id="are-there-any-legal-barriers-to-making" ordinal="0">
<rdaCommonStandard/>
<numbering>4.1.1.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -1068,6 +1123,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="who-owns-the-data" ordinal="0">
<rdaCommonStandard/>
<numbering>4.1.2.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -1087,6 +1143,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="what-licence-for-reuse-are-you-planning" ordinal="0">
<rdaCommonStandard>dataset.distribution.license.license_ref</rdaCommonStandard>
<numbering>4.1.3.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -1108,6 +1165,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="are-there-any-restrinctions-on-the" ordinal="0">
<rdaCommonStandard/>
<numbering>4.1.4.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -1134,6 +1192,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="how-long-do-you-intend-to-support-data-reuse" ordinal="0">
<rdaCommonStandard/>
<numbering>4.1.5.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -1141,9 +1200,9 @@
<viewStyle cssClass="" renderstyle="combobox"/>
<data label="Select from the list of answers" type="wordlist">
<options>
<option label="Less than 2 years" source="" value="Less than 2 years"/>
<option label="Up to 5 years" source="" value="Up to 5 years"/>
<option label="More than 10 years" source="" value="More than 10 years"/>
<option label="Less than 2 years" source="" uri="" value="Less than 2 years"/>
<option label="Up to 5 years" source="" uri="" value="Up to 5 years"/>
<option label="More than 10 years" source="" uri="" value="More than 10 years"/>
</options>
</data>
</field>
@ -1159,6 +1218,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="when-do-you-plan-to-make-your-data-available" ordinal="1">
<rdaCommonStandard/>
<numbering>4.1.6.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -1170,16 +1230,17 @@
<viewStyle cssClass="" renderstyle="combobox"/>
<data label="Select from the list of answers" type="wordlist">
<options>
<option label="immediately" source="" value="immediately"/>
<option label="after article publication" source="" value="after article publication"/>
<option label="end of project" source="" value="end of project"/>
<option label="later than end of project" source="" value="later than end of project"/>
<option label="never" source="" value="never"/>
<option label="other" source="" value="other"/>
<option label="immediately" source="" uri="" value="immediately"/>
<option label="after article publication" source="" uri="" value="after article publication"/>
<option label="end of project" source="" uri="" value="end of project"/>
<option label="later than end of project" source="" uri="" value="later than end of project"/>
<option label="never" source="" uri="" value="never"/>
<option label="other" source="" uri="" value="other"/>
</options>
</data>
</field>
<field id="other-selection-on-data-available-reuse" ordinal="2">
<rdaCommonStandard/>
<numbering>4.1.6.2</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -1208,6 +1269,7 @@
<commentField commentFieldValue="" hasCommentField="true"/>
<fields>
<field id="are-there-any-ethical-barriers-to-making-the-research" ordinal="0">
<rdaCommonStandard/>
<numbering>4.2.1.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -1227,6 +1289,7 @@
<commentField commentFieldValue="" hasCommentField="true"/>
<fields>
<field id="if-applicable-how-deal-with-sensitive-data" ordinal="0">
<rdaCommonStandard>dataset.sensitive_data</rdaCommonStandard>
<numbering>4.2.2.1</numbering>
<validations/>
<defaultValue type="" value=""/>
@ -1238,9 +1301,9 @@
<viewStyle cssClass="" renderstyle="combobox"/>
<data label="Select from the list of answers" type="wordlist">
<options>
<option label="Kept on secure, managed storage for limited time" source="" value="keptonsecure"/>
<option label="Kept on insecure, unmanaged storage for limited time" source="" value="keptoninsecure"/>
<option label="Delete at end of project" source="" value="deleteatend"/>
<option label="Kept on secure, managed storage for limited time" source="" uri="" value="keptonsecure"/>
<option label="Kept on insecure, unmanaged storage for limited time" source="" uri="" value="keptoninsecure"/>
<option label="Delete at end of project" source="" uri="" value="deleteatend"/>
</options>
</data>
</field>
@ -1256,6 +1319,7 @@
<commentField commentFieldValue="" hasCommentField="false"/>
<fields>
<field id="DatasetSecuritySectionField2" ordinal="0">
<rdaCommonStandard/>
<numbering>4.2.3.1</numbering>
<validations/>
<defaultValue type="" value=""/>

File diff suppressed because it is too large Load Diff

View File

@ -1,557 +0,0 @@
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
drop table if exists "DMP" cascade;
drop table if exists "DMPOrganisation" cascade;
drop table if exists "DMPProfile" cascade;
drop table if exists "DMPResearcher" cascade;
drop table if exists "Dataset" cascade;
drop table if exists "DatasetProfile" cascade;
drop table if exists "DatasetProfileRuleset" cascade;
drop table if exists "DatasetProfileViewstyle" cascade;
drop table if exists "Organisation" cascade;
drop table if exists "Project" cascade;
drop table if exists "Researcher" cascade;
drop table if exists "Service" cascade;
drop table if exists "DataRepository" cascade;
drop table if exists "Registry" cascade;
drop table if exists "DatasetService" cascade;
drop table if exists "DatasetRegistry" cascade;
drop table if exists "DatasetDataRepository" cascade;
DROP table if exists "UserDMP" cascade;
DROP table if exists "UserInfo" cascade;
DROP table if exists "UserAuth" cascade;
-- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
-- CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
CREATE TABLE "DMP" (
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL,
"Previous" uuid,
"Label" character varying(250) NOT NULL,
"Version" integer NOT NULL,
"Project" uuid NOT NULL,
"ProfileData" xml,
"Creator" uuid not null,
"Status" smallint not null default 0,
"Created" timestamp not null default NOW(),
"Modified" timestamp not null default NOW(),
"Description" text,
"Profile" uuid
);
ALTER TABLE "DMP" OWNER TO dmptool;
COMMENT ON COLUMN "DMP"."ProfileData" IS 'More data about the DMP as defined by the profile';
CREATE TABLE "DMPOrganisation" (
"DMP" uuid NOT NULL,
"Organisation" uuid NOT NULL,
"Role" integer,
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL
);
ALTER TABLE "DMPOrganisation" OWNER TO dmptool;
COMMENT ON TABLE "DMPOrganisation" IS 'Linking of DMPs to Organisations';
COMMENT ON COLUMN "DMPOrganisation"."Role" IS 'Enumerator of roles';
CREATE TABLE "DMPProfile" (
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL,
"Label" character varying(250) NOT NULL,
"Status" smallint not null default 0,
"Created" timestamp not null default NOW(),
"Modified" timestamp not null default NOW(),
"Definition" xml
);
ALTER TABLE "DMPProfile" OWNER TO dmptool;
CREATE TABLE "DMPResearcher" (
"DMP" uuid NOT NULL,
"Researcher" uuid NOT NULL,
"Role" integer,
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL
);
ALTER TABLE "DMPResearcher" OWNER TO dmptool;
COMMENT ON TABLE "DMPResearcher" IS 'Linking of DMPs to researchers';
COMMENT ON COLUMN "DMPResearcher"."Role" IS 'Enumerator of roles';
CREATE TABLE "Dataset" (
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL,
"Label" character varying(250) NOT NULL,
"DMP" uuid,
"Uri" character varying(250),
"Properties" xml,
"Reference" xml,
"Creator" uuid not null,
"Status" smallint not null default 0,
"Created" timestamp not null default NOW(),
"Modified" timestamp not null default NOW(),
"Description" text,
"Profile" uuid
);
ALTER TABLE "Dataset" OWNER TO dmptool;
COMMENT ON COLUMN "Dataset"."Uri" IS 'URI of item';
COMMENT ON COLUMN "Dataset"."Properties" IS 'More data about the dataset such as Uri, data types etc as defined by the profile';
CREATE TABLE "DatasetProfile" (
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL,
"Label" character varying(250) NOT NULL,
"Ruleset" uuid,
"Viewstyle" uuid,
"Status" smallint not null default 0,
"Created" timestamp not null default NOW(),
"Modified" timestamp not null default NOW(),
"Description" text,
"Definition" xml NOT NULL
);
-- SHould also force the 1-1 relation between the datasetprofile <-> ruleset and datasetprofile <-> viewstyle
ALTER TABLE "DatasetProfile" ADD CONSTRAINT datasetprofile_unique_ruleset UNIQUE ("Ruleset");
ALTER TABLE "DatasetProfile" ADD CONSTRAINT datasetprofile_unique_viewstyle UNIQUE ("Viewstyle");
ALTER TABLE "DatasetProfile" OWNER TO dmptool;
COMMENT ON TABLE "DatasetProfile" IS 'Profiles for dmp datasets';
CREATE TABLE "DatasetProfileRuleset" (
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL,
"Label" character varying(250) NOT NULL,
"Definition" xml NOT NULL
);
ALTER TABLE "DatasetProfileRuleset" OWNER TO dmptool;
COMMENT ON TABLE "DatasetProfileRuleset" IS 'Sets of Rules for dmp dataset profiles';
CREATE TABLE "DatasetProfileViewstyle" (
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL,
"Label" character varying(250) NOT NULL,
"Definition" xml NOT NULL
);
ALTER TABLE "DatasetProfileViewstyle" OWNER TO dmptool;
COMMENT ON TABLE "DatasetProfileViewstyle" IS 'Style sets for dmp dataset profiles';
CREATE TABLE "Organisation" (
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL,
"Label" character varying(250) NOT NULL,
"Abbreviation" character varying(50),
"Reference" xml,
"Uri" character varying(250),
"Status" smallint not null default 0,
"Created" timestamp not null default NOW(),
"Modified" timestamp not null default NOW(),
"Definition" xml
);
ALTER TABLE "Organisation" OWNER TO dmptool;
COMMENT ON TABLE "Organisation" IS 'Table of organizations utilized in the project';
COMMENT ON COLUMN "Organisation"."ID" IS 'Unique identifier and primary key of item';
COMMENT ON COLUMN "Organisation"."Label" IS 'A human readable long label of the item';
COMMENT ON COLUMN "Organisation"."Abbreviation" IS 'A human readable abbreviation of the item';
COMMENT ON COLUMN "Organisation"."Reference" IS 'Reference to the URI of the item along with information to allow how the item reached the system (e.g. via an external vocabulary)';
COMMENT ON COLUMN "Organisation"."Uri" IS 'URI of item';
COMMENT ON COLUMN "Organisation"."Definition" IS 'More data about the Organisation such as web site, type etc';
CREATE TABLE "Project" (
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL,
"Label" character varying(250) NOT NULL,
"Abbreviation" character varying(50),
"Reference" xml,
"Uri" character varying(250),
"CreationUser" uuid not null,
"Status" smallint not null default 0,
"Created" timestamp not null default NOW(),
"Modified" timestamp not null default NOW(),
"StartDate" timestamp,
"EndDate" timestamp,
"Description" text,
"Definition" xml
);
ALTER TABLE "Project" OWNER TO dmptool;
COMMENT ON TABLE "Project" IS 'Table of project managed in the system';
COMMENT ON COLUMN "Project"."ID" IS 'Unique identifier and primary key of item';
COMMENT ON COLUMN "Project"."Label" IS 'A human readable long label of the item';
COMMENT ON COLUMN "Project"."Abbreviation" IS 'A human readable abbreviation of the item';
COMMENT ON COLUMN "Project"."Reference" IS 'Additional reference data for the item along with information to allow how the item reached the system (e.g. via an external vocabulary)';
COMMENT ON COLUMN "Project"."Uri" IS 'URI of item';
COMMENT ON COLUMN "Project"."Definition" IS 'More data about the project such as web site, start/stop, etc';
CREATE TABLE "Researcher" (
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL,
"Label" character varying(250) NOT NULL,
"Uri" character varying(250),
"PrimaryEmail" character varying(250),
"Definition" xml,
"Status" smallint not null default 0,
"Created" timestamp not null default NOW(),
"Modified" timestamp not null default NOW(),
"Reference" xml
);
ALTER TABLE "Researcher" OWNER TO dmptool;
COMMENT ON TABLE "Researcher" IS 'Table of Researcher managed in the system';
COMMENT ON COLUMN "Researcher"."ID" IS 'Unique identifier and primary key of item';
COMMENT ON COLUMN "Researcher"."Label" IS 'Full name of the researcher (as presented by the system, and composed automatically by data or provided by the reference service)';
COMMENT ON COLUMN "Researcher"."Uri" IS 'URI of item';
COMMENT ON COLUMN "Researcher"."Definition" IS 'More data about the researcher such as: email addresses, affiliations etc';
COMMENT ON COLUMN "Researcher"."Reference" IS 'Additional reference data for the item along with information to allow how the item reached the system (e.g. via an external vocabulary)';
ALTER TABLE ONLY "DMPProfile"
ADD CONSTRAINT "DMPPRofile_pkey" PRIMARY KEY ("ID");
ALTER TABLE ONLY "DMP"
ADD CONSTRAINT "DMP_pkey" PRIMARY KEY ("ID");
ALTER TABLE ONLY "DatasetProfile"
ADD CONSTRAINT "DatasetProfile_pkey" PRIMARY KEY ("ID");
ALTER TABLE ONLY "DatasetProfileRuleset"
ADD CONSTRAINT "DatasetProfileRuleset_pkey" PRIMARY KEY ("ID");
ALTER TABLE ONLY "DatasetProfileViewstyle"
ADD CONSTRAINT "DatasetProfileViewstyle_pkey" PRIMARY KEY ("ID");
ALTER TABLE ONLY "Dataset"
ADD CONSTRAINT "Dataset_pkey" PRIMARY KEY ("ID");
ALTER TABLE ONLY "Organisation"
ADD CONSTRAINT "Organisation_pkey" PRIMARY KEY ("ID");
ALTER TABLE ONLY "DMPOrganisation"
ADD CONSTRAINT "PKey_DMPOrganisation" PRIMARY KEY ("ID");
ALTER TABLE ONLY "DMPResearcher"
ADD CONSTRAINT "PKey_DMPResearcher" PRIMARY KEY ("ID");
ALTER TABLE ONLY "Project"
ADD CONSTRAINT "Project_pkey" PRIMARY KEY ("ID");
ALTER TABLE ONLY "Researcher"
ADD CONSTRAINT "Researcher_pkey" PRIMARY KEY ("ID");
CREATE INDEX "fki_DMPDMPProfileReference" ON "DMP" USING btree ("Profile");
CREATE INDEX "fki_DatasetDatasetProfileReference" ON "Dataset" USING btree ("Profile");
ALTER TABLE ONLY "DMP"
ADD CONSTRAINT "DMPDMPProfileReference" FOREIGN KEY ("Profile") REFERENCES "DMPProfile"("ID");
ALTER TABLE ONLY "DMPOrganisation"
ADD CONSTRAINT "DMPOrganisationDMPReference" FOREIGN KEY ("Organisation") REFERENCES "Organisation"("ID");
ALTER TABLE ONLY "DMPOrganisation"
ADD CONSTRAINT "DMPOrganisationOrganisationReference" FOREIGN KEY ("DMP") REFERENCES "DMP"("ID");
ALTER TABLE ONLY "DMP"
ADD CONSTRAINT "DMPProjectReference" FOREIGN KEY ("Project") REFERENCES "Project"("ID");
ALTER TABLE ONLY "DMPResearcher"
ADD CONSTRAINT "DMPResearcherDMPReference" FOREIGN KEY ("Researcher") REFERENCES "Researcher"("ID");
ALTER TABLE ONLY "DMPResearcher"
ADD CONSTRAINT "DMPResearcherResearcherReference" FOREIGN KEY ("DMP") REFERENCES "DMP"("ID");
ALTER TABLE ONLY "Dataset"
ADD CONSTRAINT "DatasetDatasetProfileReference" FOREIGN KEY ("Profile") REFERENCES "DatasetProfile"("ID");
ALTER TABLE ONLY "Dataset"
ADD CONSTRAINT "DatasetDMPReference" FOREIGN KEY ("DMP") REFERENCES "DMP"("ID");
ALTER TABLE ONLY "DatasetProfile"
ADD CONSTRAINT "DatasetProfileDatasetProfileRulesetReference" FOREIGN KEY ("Ruleset") REFERENCES "DatasetProfileRuleset"("ID");
ALTER TABLE ONLY "DatasetProfile"
ADD CONSTRAINT "DatasetProfileDatasetProfileViewstyleReference" FOREIGN KEY ("Viewstyle") REFERENCES "DatasetProfileViewstyle"("ID");
CREATE TABLE "Service" (
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL,
"Label" character varying(250),
"Abbreviation" character varying(50),
"Reference" xml,
"Uri" character varying(250),
"Status" smallint not null default 0,
"Created" timestamp not null default NOW(),
"Modified" timestamp not null default NOW(),
"Definition" xml
);
ALTER TABLE "Service" OWNER TO dmptool;
ALTER TABLE ONLY "Service"
ADD CONSTRAINT "PKey_Service" PRIMARY KEY ("ID");
CREATE TABLE "DataRepository" (
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL,
"Label" character varying(250),
"Abbreviation" character varying(50),
"Reference" xml,
"Uri" character varying(250),
"Status" smallint not null default 0,
"Created" timestamp not null default NOW(),
"Modified" timestamp not null default NOW(),
"Definition" xml
);
ALTER TABLE "DataRepository" OWNER TO dmptool;
ALTER TABLE ONLY "DataRepository"
ADD CONSTRAINT "PKey_DataRepository" PRIMARY KEY ("ID");
CREATE TABLE "Registry" (
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL,
"Label" character varying(250),
"Abbreviation" character varying(50),
"Reference" xml,
"Uri" character varying(250),
"Status" smallint not null default 0,
"Created" timestamp not null default NOW(),
"Modified" timestamp not null default NOW(),
"Definition" xml
);
ALTER TABLE "Registry" OWNER TO dmptool;
ALTER TABLE ONLY "Registry"
ADD CONSTRAINT "PKey_Registry" PRIMARY KEY ("ID");
CREATE TABLE "DatasetService" (
"Dataset" uuid NOT NULL,
"Service" uuid NOT NULL,
"Role" integer,
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL
);
ALTER TABLE "DatasetService" OWNER TO dmptool;
COMMENT ON TABLE "DatasetService" IS 'Linking Dataset to Service';
CREATE TABLE "DatasetRegistry" (
"Dataset" uuid NOT NULL,
"Registry" uuid NOT NULL,
"Role" integer,
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL
);
ALTER TABLE "DatasetRegistry" OWNER TO dmptool;
COMMENT ON TABLE "DatasetRegistry" IS 'Linking Dataset to Registry';
CREATE TABLE "DatasetDataRepository" (
"Dataset" uuid NOT NULL,
"DataRepository" uuid NOT NULL,
"Role" integer,
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL
);
ALTER TABLE "DatasetDataRepository" OWNER TO dmptool;
COMMENT ON TABLE "DatasetDataRepository" IS 'Linking Dataset to DataRepository';
ALTER TABLE ONLY "DatasetDataRepository"
ADD CONSTRAINT "DatasetDataRepositoryDatasetReference" FOREIGN KEY ("Dataset") REFERENCES "Dataset"("ID");
ALTER TABLE ONLY "DatasetDataRepository"
ADD CONSTRAINT "DatasetDataRepositoryDataRepositoryReference" FOREIGN KEY ("DataRepository") REFERENCES "DataRepository"("ID");
ALTER TABLE ONLY "DatasetRegistry"
ADD CONSTRAINT "DatasetRegistryDatasetReference" FOREIGN KEY ("Dataset") REFERENCES "Dataset"("ID");
ALTER TABLE ONLY "DatasetRegistry"
ADD CONSTRAINT "DatasetRegistryRegistryReference" FOREIGN KEY ("Registry") REFERENCES "Registry"("ID");
ALTER TABLE ONLY "DatasetService"
ADD CONSTRAINT "DatasetServiceDatasetReference" FOREIGN KEY ("Dataset") REFERENCES "Dataset"("ID");
ALTER TABLE ONLY "DatasetService"
ADD CONSTRAINT "DatasetServiceServiceReference" FOREIGN KEY ("Service") REFERENCES "Service"("ID");
CREATE TABLE "UserInfo" (
"id" uuid DEFAULT uuid_generate_v4() UNIQUE NOT NULL,
"email" character varying(250) UNIQUE NOT NULL,
"authorization_level" smallint NOT NULL,
"usertype" smallint NOT NULL,
"authentication" uuid,
"verified_email" boolean,
"name" character varying(250),
"created" timestamp not null,
"lastloggedin" timestamp,
"additionalinfo" xml,
PRIMARY KEY (id)
);
COMMENT ON COLUMN "UserInfo"."authorization_level" IS 'This stores the authorization level of the user: 0 admin, 1 user, being able to be extended furthermore';
COMMENT ON COLUMN "UserInfo"."usertype" IS 'This stores the type of user: 0 -> internal, 1 external';
CREATE TABLE "UserAuth" (
"id" uuid DEFAULT uuid_generate_v4() NOT NULL UNIQUE,
"username" character varying(200) NOT NULL,
"password" character varying(250) NOT NULL,
PRIMARY KEY (username)
);
CREATE INDEX idx_userauth_username ON "UserAuth"(username);
ALTER TABLE "UserInfo" ADD CONSTRAINT fkey_userinfo_userauth FOREIGN KEY ("authentication") REFERENCES "UserAuth"(id);
COMMENT ON COLUMN "UserAuth"."password" IS 'This field stores a password hash';
create table "UserDMP" (
"id" uuid DEFAULT uuid_generate_v4() NOT NULL,
"usr" uuid NOT NULL,
"dmp" uuid NOT NUll,
"role" integer
);
ALTER TABLE "UserDMP" ADD CONSTRAINT fkey_userdmp_user FOREIGN KEY (usr) REFERENCES "UserInfo"("id");
ALTER TABLE "UserDMP" ADD CONSTRAINT fkey_userdmp_dmp FOREIGN KEY (dmp) REFERENCES "DMP"("ID");
ALTER TABLE "DMP" ADD CONSTRAINT fk_dmp_creator FOREIGN KEY ("Creator") REFERENCES "UserInfo"(id);
ALTER TABLE "Dataset" ADD CONSTRAINT fk_dataset_creator FOREIGN KEY ("Creator") REFERENCES "UserInfo"(id);
ALTER TABLE "Project" ADD CONSTRAINT fk_project_creator FOREIGN KEY ("CreationUser") REFERENCES "UserInfo"(id);
ALTER TABLE "UserInfo" OWNER TO dmptool;
ALTER TABLE "UserAuth" OWNER TO dmptool;
ALTER TABLE "UserDMP" OWNER TO dmptool;
REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;

View File

@ -0,0 +1,5 @@
ADMIN_USERNAME=admin
ADMIN_PASSWORD=CHANGEME
POSTGRES_DB=dmptool
POSTGRES_USER=dmptool
POSTGRES_PASSWORD=CHANGEME

View File

@ -0,0 +1,8 @@
@echo off
setlocal
cd ..
for /F "tokens=*" %%p in ('type Docker\dmp-db.env') do SET %%p
psql -d postgres -U postgres -w --set=POSTGRES_USER=%POSTGRES_USER% --set=POSTGRES_PASSWORD=%POSTGRES_PASSWORD% --set=POSTGRES_DB=%POSTGRES_DB% -f main/createDatabase.sql
psql -d %POSTGRES_DB% -U %POSTGRES_USER% --set=POSTGRES_USER=%POSTGRES_USER% -w -f main/dmp-dump.sql
psql --set=ADMIN_USERNAME=%ADMIN_USERNAME% --set=ADMIN_PASSWORD=%ADMIN_PASSWORD% --set=POSTGRES_USER=%POSTGRES_USER% -d %POSTGRES_DB% -U %POSTGRES_USER% -w -f main/data-dump.sql
endlocal

View File

@ -0,0 +1,5 @@
cd ..
source Docker/dmp-db.env
export $(cut -d= -f1 Docker/dmp-db.env)
psql -d postgres -U postgres -w --set=POSTGRES_USER="$POSTGRES_USER" --set=POSTGRES_PASSWORD="$POSTGRES_PASSWORD" --set=POSTGRES_DB="$POSTGRES_DB" -f main/createDatabase.sql
./initdb.sh

2
dmp-db-scema/initdb.sh Normal file
View File

@ -0,0 +1,2 @@
psql -d $POSTGRES_DB -U $POSTGRES_USER --set=POSTGRES_USER="$POSTGRES_USER" -f main/dmp-dump.sql;
psql --set=ADMIN_USERNAME="$ADMIN_USERNAME" --set=ADMIN_PASSWORD="$ADMIN_PASSWORD" -d $POSTGRES_DB -U $POSTGRES_USER -f main/data-dump.sql;

View File

@ -0,0 +1,2 @@
CREATE USER :POSTGRES_USER with PASSWORD :'POSTGRES_PASSWORD' SUPERUSER;
CREATE DATABASE :POSTGRES_DB;

View File

@ -0,0 +1,17 @@
INSERT INTO public."UserInfo"(email, authorization_level, usertype, name, created, additionalinfo) VALUES ('fake@email.org', 1, 1, :'ADMIN_USERNAME', now(), '{}');
INSERT INTO public."Credential" VALUES (uuid_generate_v4(), 0, 5, :'ADMIN_USERNAME', :'ADMIN_PASSWORD', now(), now(), (SELECT public."UserInfo"."id" FROM public."UserInfo" WHERE name = :'ADMIN_USERNAME'), 'dmp');
INSERT INTO public."UserRole"("Role", "UserId") VALUES (2, (SELECT public."UserInfo"."id" FROM public."UserInfo" WHERE name = :'ADMIN_USERNAME'));
INSERT INTO public."DoiFunder"(name, doi) VALUES ('Australian Research Council', '10.13039/501100000923');
INSERT INTO public."DoiFunder"(name, doi) VALUES ('European Commission', '10.13039/501100000780');
INSERT INTO public."DoiFunder"(name, doi) VALUES ('Fundação para a Ciência e a Tecnologia', '10.13039/501100001871');
INSERT INTO public."DoiFunder"(name, doi) VALUES ('Ministarstvo Prosvete, Nauke i Tehnološkog Razvoja', '10.13039/501100004564');
INSERT INTO public."DoiFunder"(name, doi) VALUES ('Ministarstvo Znanosti, Obrazovanja i Sporta', '10.13039/501100006588');
INSERT INTO public."DoiFunder"(name, doi) VALUES ('National Health and Medical Research Council', '10.13039/501100000925');
INSERT INTO public."DoiFunder"(name, doi) VALUES ('National Science Foundation','10.13039/100000001');
INSERT INTO public."DoiFunder"(name, doi) VALUES ('Nederlandse Organisatie voor Wetenschappelijk Onderzoek', '10.13039/501100003246');
INSERT INTO public."DoiFunder"(name, doi) VALUES ('Wellcome Trust', '10.13039/100004440');
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.00.003', '2020-05-06 18:11:00.000000+03', now(), 'Add Doi Funder');

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,21 @@
CREATE TABLE public."UserAssociation" (
id uuid NOT NULL,
"firstUser" uuid NOT NULL,
"secondUser" uuid NOT NULL
);
ALTER TABLE public."UserAssociation" OWNER TO :POSTGRES_USER;
ALTER TABLE ONLY public."UserAssociation"
ADD CONSTRAINT pk_user_association PRIMARY KEY (id);
ALTER TABLE ONLY public."UserAssociation"
ADD CONSTRAINT fk_userinfo_user_association_1 FOREIGN KEY ("firstUser") REFERENCES public."UserInfo"(id);
ALTER TABLE ONLY public."UserAssociation"
ADD CONSTRAINT fk_userinfo_user_association_2 FOREIGN KEY ("secondUser") REFERENCES public."UserInfo"(id);
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.00.002', '2020-05-04 13:42:00.000000+03', now(), 'Add User Association');

View File

@ -0,0 +1,26 @@
CREATE TABLE public."DoiFunder" (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
name character varying,
doi character varying
);
ALTER TABLE ONLY public."DoiFunder"
ADD CONSTRAINT "DoiFunder_pkey" PRIMARY KEY (id);
ALTER TABLE public."DoiFunder" OWNER TO :POSTGRES_USER;
INSERT INTO public."DoiFunder"(name, doi) VALUES ('Australian Research Council', '10.13039/501100000923');
INSERT INTO public."DoiFunder"(name, doi) VALUES ('European Commission', '10.13039/501100000780');
INSERT INTO public."DoiFunder"(name, doi) VALUES ('Fundação para a Ciência e a Tecnologia', '10.13039/501100001871');
INSERT INTO public."DoiFunder"(name, doi) VALUES ('Ministarstvo Prosvete, Nauke i Tehnološkog Razvoja', '10.13039/501100004564');
INSERT INTO public."DoiFunder"(name, doi) VALUES ('Ministarstvo Znanosti, Obrazovanja i Sporta', '10.13039/501100006588');
INSERT INTO public."DoiFunder"(name, doi) VALUES ('National Health and Medical Research Council', '10.13039/501100000925');
INSERT INTO public."DoiFunder"(name, doi) VALUES ('National Science Foundation','10.13039/100000001');
INSERT INTO public."DoiFunder"(name, doi) VALUES ('Nederlandse Organisatie voor Wetenschappelijk Onderzoek', '10.13039/501100003246');
INSERT INTO public."DoiFunder"(name, doi) VALUES ('Wellcome Trust', '10.13039/100004440');
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.00.003', '2020-05-06 18:11:00.000000+03', now(), 'Add Doi Funder');

View File

@ -1,2 +0,0 @@
ALTER TABLE public."DMP"
ADD COLUMN "DOI" text

View File

@ -1,6 +0,0 @@
ALTER TABLE public."DMP"
ADD "PublishedAt" timestamp(6) with time zone
UPDATE public."DMP"
SET "PublishedAt" = "FinalizedDat"
where "isPublic" = True

View File

@ -1,60 +0,0 @@
INSERT INTO public."UserDMP"(
usr, dmp, role)
SELECT "Creator", "ID", 0
FROM public."DMP"
DELETE
FROM public."UserDMP" as us1
using public."UserDMP" as us2
where us1."id" < us2."id" AND us1."dmp" = us2."dmp"
CREATE TABLE public."DMPDatasetProfile"
(
"ID" uuid NOT NULL DEFAULT uuid_generate_v4(),
dmp uuid NOT NULL,
datasetprofile uuid NOT NULL,
CONSTRAINT "DMPDatasetProfile_pkey" PRIMARY KEY ("ID"),
CONSTRAINT "DMPDatasetProfile_datasetprofile_fkey" FOREIGN KEY (datasetprofile)
REFERENCES public."DatasetProfile" ("ID") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT "DMPDatasetProfile_dmp_fkey" FOREIGN KEY (dmp)
REFERENCES public."DMP" ("ID") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public."DMPDatasetProfile"
OWNER to dmtadm;
ALTER TABLE public."UserDMP"
OWNER to dmtadm;
INSERT INTO public."DMPDatasetProfile"(
dmp, datasetprofile)
SELECT "ID", unnest(xpath('/profiles/profile/@profileId', dmpp."AssociatedDmps"::xml)::text[]::UUID[])
FROM public."DMP" as dmpp
Alter table public."DMP"
add "FinalizedDat" timestamp(6) with time zone
update public."DMP" SET "FinalizedDat" = "Modified"
where "Status" = 1
Alter table public."Dataset"
add "FinalizedDat" timestamp(6) with time zone
update public."Dataset" SET "FinalizedDat" = "Modified"
where "Status" = 1

View File

@ -1,7 +0,0 @@
alter table public."DMP"
Add "isPublic" boolean NOT NULL Default False;
UPDATE public."DMP"
SET "isPublic" = True
WHERE "Status" = 1

View File

@ -1,2 +0,0 @@
ALTER TABLE public."Dataset"
DROP COLUMN "IsPublic"

View File

@ -1,2 +0,0 @@
ALTER TABLE public."DMP"
RENAME COLUMN "FinalizedDat" TO "FinalizedAt";

View File

@ -1,2 +0,0 @@
ALTER TABLE public."Dataset"
RENAME COLUMN "FinalizedDat" TO "FinalizedAt";

View File

@ -1,17 +0,0 @@
CREATE TABLE public."LoginConfirmationEmail"
(
"ID" uuid NOT NULL,
email character varying COLLATE pg_catalog."default" NOT NULL,
"isConfirmed" boolean NOT NULL,
token uuid NOT NULL,
userId uuid NOT NULL,
"expiresAt" timestamp(4) with time zone NOT NULL,
CONSTRAINT "LoginConfirmationEmail_pkey" PRIMARY KEY ("ID")
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public."LoginConfirmationEmail"
OWNER to dmtadm;

Some files were not shown because too many files have changed in this diff Show More