Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring

# Conflicts:
#	dmp-frontend/src/app/core/common/enum/permission.enum.ts
This commit is contained in:
Diamantis Tziotzios 2023-11-28 15:16:36 +02:00
commit eb19b9a7d5
138 changed files with 6964 additions and 1662 deletions

View File

@ -80,5 +80,13 @@ public class AuditableAction {
public static final EventId Tenant_Persist = new EventId(12002, "Tenant_Persist"); public static final EventId Tenant_Persist = new EventId(12002, "Tenant_Persist");
public static final EventId Tenant_Delete = new EventId(12003, "Tenant_Delete"); public static final EventId Tenant_Delete = new EventId(12003, "Tenant_Delete");
public static final EventId Language_Query = new EventId(13000, "Language_Query");
public static final EventId Language_Lookup = new EventId(13001, "Language_Lookup");
public static final EventId Language_Persist = new EventId(13002, "Language_Persist");
public static final EventId Language_Delete = new EventId(13003, "Language_Delete");
public static final EventId StorageFile_Download = new EventId(14000, "StorageFile_Download");
public static final EventId StorageFile_Upload = new EventId(14001, "StorageFile_Upload");
} }

View File

@ -28,6 +28,7 @@ public final class Permission {
//Language //Language
public static String BrowseLanguage = "BrowseLanguage"; public static String BrowseLanguage = "BrowseLanguage";
public static String EditLanguage = "EditLanguage"; public static String EditLanguage = "EditLanguage";
public static String DeleteLanguage = "DeleteLanguage";
//Language //Language
public static String BrowseStatistics = "BrowseStatistics"; public static String BrowseStatistics = "BrowseStatistics";
@ -49,6 +50,13 @@ public final class Permission {
public static String EditUser = "EditUser"; public static String EditUser = "EditUser";
public static String DeleteUser = "DeleteUser"; public static String DeleteUser = "DeleteUser";
public static String ExportUsers = "ExportUsers"; public static String ExportUsers = "ExportUsers";
//StorageFile
public static String BrowseStorageFile = "BrowseStorageFile";
public static String EditStorageFile = "EditStorageFile";
public static String DeleteStorageFile = "DeleteStorageFile";
//DescriptionTemplateType //DescriptionTemplateType
public static String BrowseDescriptionTemplateType = "BrowseDescriptionTemplateType"; public static String BrowseDescriptionTemplateType = "BrowseDescriptionTemplateType";

View File

@ -0,0 +1,30 @@
package eu.eudat.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum StorageFilePermission implements DatabaseEnum<Short> {
Read((short) 0),
Write((short) 1);
private final Short value;
StorageFilePermission(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, StorageFilePermission> map = EnumUtils.getEnumValueMap(StorageFilePermission.class);
public static StorageFilePermission of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,30 @@
package eu.eudat.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum StorageType implements DatabaseEnum<Short> {
Temp((short) 0),
Main((short) 1);
private final Short value;
StorageType(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, StorageType> map = EnumUtils.getEnumValueMap(StorageType.class);
public static StorageType of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,126 @@
package eu.eudat.commons.fake;
import org.jetbrains.annotations.NotNull;
import org.springframework.util.Assert;
import org.springframework.web.context.request.RequestAttributes;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
public class FakeRequestAttributes implements RequestAttributes {
private final Map<String, Object> requestAttributeMap = new HashMap<>();
private final Map<String, Runnable> requestDestructionCallbacks = new LinkedHashMap<>(8);
private volatile boolean requestActive = true;
@Override
public Object getAttribute(@NotNull String name, int scope) {
if (scope == RequestAttributes.SCOPE_REQUEST) {
if (!isRequestActive()) {
throw new IllegalStateException("Cannot ask for request attribute - request is not active anymore!");
}
return this.requestAttributeMap.get(name);
} else {
throw new IllegalStateException("Only " + RequestAttributes.SCOPE_REQUEST + " allowed for " + FakeRequestAttributes.class.getSimpleName());
}
}
@Override
public void setAttribute(@NotNull String name, @NotNull Object value, int scope) {
if (scope == RequestAttributes.SCOPE_REQUEST) {
if (!isRequestActive()) {
throw new IllegalStateException("Cannot set request attribute - request is not active anymore!");
}
this.requestAttributeMap.put(name, value);
} else {
throw new IllegalStateException("Only " + RequestAttributes.SCOPE_REQUEST + " allowed for " + FakeRequestAttributes.class.getSimpleName());
}
}
@Override
public void removeAttribute(@NotNull String name, int scope) {
if (scope == RequestAttributes.SCOPE_REQUEST) {
if (isRequestActive()) {
removeRequestDestructionCallback(name);
this.requestAttributeMap.remove(name);
}
} else {
throw new IllegalStateException("Only " + RequestAttributes.SCOPE_REQUEST + " allowed for " + FakeRequestAttributes.class.getSimpleName());
}
}
@Override
public String @NotNull [] getAttributeNames(int scope) {
if (scope == RequestAttributes.SCOPE_REQUEST) {
if (!isRequestActive()) {
throw new IllegalStateException("Cannot ask for request attributes - request is not active anymore!");
}
return this.requestAttributeMap.keySet().toArray(new String[0]);
} else {
throw new IllegalStateException("Only " + RequestAttributes.SCOPE_REQUEST + " allowed for " + FakeRequestAttributes.class.getSimpleName());
}
//return new String[0];
}
@Override
public void registerDestructionCallback(@NotNull String name, @NotNull Runnable callback, int scope) {
if (scope == SCOPE_REQUEST) {
registerRequestDestructionCallback(name, callback);
} else {
throw new IllegalStateException("Only " + RequestAttributes.SCOPE_REQUEST + " allowed for " + FakeRequestAttributes.class.getSimpleName());
}
}
protected final void registerRequestDestructionCallback(String name, Runnable callback) {
Assert.notNull(name, "Name must not be null");
Assert.notNull(callback, "Callback must not be null");
synchronized (this.requestDestructionCallbacks) {
this.requestDestructionCallbacks.put(name, callback);
}
}
@Override
public Object resolveReference(@NotNull String key) {
// Not supported
return null;
}
@Override
public @NotNull String getSessionId() {
return "";
}
@Override
public @NotNull Object getSessionMutex() {
return new Object();
}
public void requestCompleted() {
executeRequestDestructionCallbacks();
for (String name : getAttributeNames(RequestAttributes.SCOPE_REQUEST)) {
this.removeAttribute(name, RequestAttributes.SCOPE_REQUEST);
}
this.requestActive = false;
}
private boolean isRequestActive() {
return this.requestActive;
}
private void removeRequestDestructionCallback(String name) {
Assert.notNull(name, "Name must not be null");
synchronized (this.requestDestructionCallbacks) {
this.requestDestructionCallbacks.remove(name);
}
}
private void executeRequestDestructionCallbacks() {
synchronized (this.requestDestructionCallbacks) {
for (Runnable runnable : this.requestDestructionCallbacks.values()) {
runnable.run();
}
this.requestDestructionCallbacks.clear();
}
}
}

View File

@ -0,0 +1,44 @@
package eu.eudat.commons.fake;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import java.io.Closeable;
public class FakeRequestScope implements Closeable {
private RequestAttributes initialRequestAttributes = null;
private FakeRequestAttributes currentRequestAttributes = null;
boolean isInUse = false;
public FakeRequestScope() {
this.reset();
}
public final void reset() {
this.close();
this.isInUse = true;
this.initialRequestAttributes = RequestContextHolder.getRequestAttributes();
this.currentRequestAttributes = new FakeRequestAttributes();
RequestContextHolder.setRequestAttributes(this.currentRequestAttributes);
}
@Override
public void close() {
if (!this.isInUse)
return;
this.isInUse = false;
if (initialRequestAttributes != null)
RequestContextHolder.setRequestAttributes(initialRequestAttributes);
else
RequestContextHolder.resetRequestAttributes();
if (currentRequestAttributes != null)
currentRequestAttributes.requestCompleted();
this.initialRequestAttributes = null;
this.currentRequestAttributes = null;
}
}

View File

@ -3,7 +3,6 @@ package eu.eudat.data;
import eu.eudat.commons.enums.DescriptionStatus; import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.converters.enums.DescriptionStatusConverter; import eu.eudat.data.converters.enums.DescriptionStatusConverter;
import eu.eudat.data.converters.enums.IsActiveConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
import eu.eudat.data.old.helpers.EntityBinder; import eu.eudat.data.old.helpers.EntityBinder;

View File

@ -1,7 +1,6 @@
package eu.eudat.data; package eu.eudat.data;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.converters.enums.IsActiveConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
import jakarta.persistence.*; import jakarta.persistence.*;

View File

@ -1,7 +1,6 @@
package eu.eudat.data; package eu.eudat.data;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.converters.enums.IsActiveConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
import jakarta.persistence.*; import jakarta.persistence.*;
@ -29,13 +28,11 @@ public class DescriptionTagEntity {
public static final String _tagId = "tagId"; public static final String _tagId = "tagId";
@Column(name = "created_at") @Column(name = "created_at")
@Convert(converter = DateToUTCConverter.class)
private Instant createdAt; private Instant createdAt;
public static final String _createdAt = "createdAt"; public static final String _createdAt = "createdAt";
@Column(name = "updated_at") @Column(name = "updated_at")
@Convert(converter = DateToUTCConverter.class)
private Instant updatedAt; private Instant updatedAt;
public static final String _updatedAt = "updatedAt"; public static final String _updatedAt = "updatedAt";

View File

@ -1,6 +1,5 @@
package eu.eudat.data; package eu.eudat.data;
import eu.eudat.commons.enums.DescriptionTemplateStatus; import eu.eudat.commons.enums.DescriptionTemplateStatus;
import eu.eudat.commons.enums.DescriptionTemplateVersionStatus; import eu.eudat.commons.enums.DescriptionTemplateVersionStatus;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
@ -14,7 +13,6 @@ import java.time.Instant;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@Entity @Entity
@Table(name = "\"DescriptionTemplate\"") @Table(name = "\"DescriptionTemplate\"")
public class DescriptionTemplateEntity implements DataEntity<DescriptionTemplateEntity,UUID>{ public class DescriptionTemplateEntity implements DataEntity<DescriptionTemplateEntity,UUID>{

View File

@ -1,6 +1,5 @@
package eu.eudat.data; package eu.eudat.data;
import eu.eudat.commons.enums.DmpBlueprintStatus; import eu.eudat.commons.enums.DmpBlueprintStatus;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.enums.DmpBlueprintStatusConverter; import eu.eudat.data.converters.enums.DmpBlueprintStatusConverter;
@ -10,7 +9,6 @@ import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;
@Entity @Entity
@Table(name = "\"DmpBlueprint\"") @Table(name = "\"DmpBlueprint\"")
public class DmpBlueprintEntity { public class DmpBlueprintEntity {

View File

@ -2,11 +2,9 @@ package eu.eudat.data;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.enums.IsActiveConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
import eu.eudat.data.old.queryableentity.DataEntity;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.List;
import java.util.UUID; import java.util.UUID;
@Entity @Entity

View File

@ -4,11 +4,9 @@ import eu.eudat.commons.enums.DmpUserRole;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.enums.DmpUserRoleConverter; import eu.eudat.data.converters.enums.DmpUserRoleConverter;
import eu.eudat.data.converters.enums.IsActiveConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
import eu.eudat.data.old.queryableentity.DataEntity;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.List;
import java.util.UUID; import java.util.UUID;
@Entity @Entity

View File

@ -0,0 +1,87 @@
package eu.eudat.data;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.enums.IsActiveConverter;
import jakarta.persistence.*;
import java.time.Instant;
import java.util.UUID;
@Entity
@Table(name = "\"Language\"")
public class LanguageEntity {
@Id
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
private UUID id;
public static final String _id = "id";
@Column(name = "code", length = 20, nullable = false)
private String code;
public static final String _code = "code";
@Column(name = "payload", nullable = false)
private String payload;
public static final String _payload = "payload";
@Column(name = "\"created_at\"", nullable = false)
private Instant createdAt;
public static final String _createdAt = "createdAt";
@Column(name = "\"updated_at\"", nullable = false)
private Instant updatedAt;
public static final String _updatedAt = "updatedAt";
@Column(name = "is_active", nullable = false)
@Convert(converter = IsActiveConverter.class)
private IsActive isActive;
public static final String _isActive = "isActive";
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getPayload() {
return payload;
}
public void setPayload(String payload) {
this.payload = payload;
}
public Instant getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt;
}
public Instant getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Instant updatedAt) {
this.updatedAt = updatedAt;
}
public IsActive getIsActive() {
return isActive;
}
public void setIsActive(IsActive isActive) {
this.isActive = isActive;
}
}

View File

@ -0,0 +1,141 @@
package eu.eudat.data;
import eu.eudat.commons.enums.StorageType;
import eu.eudat.data.converters.enums.StorageTypeConverter;
import jakarta.persistence.*;
import java.time.Instant;
import java.util.UUID;
@Entity
@Table(name = "\"StorageFile\"")
public class StorageFileEntity {
@Id
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
private UUID id;
public final static String _id = "id";
@Column(name = "file_ref", length = _fileRefLen, nullable = false)
private String fileRef;
public final static String _fileRef = "fileRef";
public final static int _fileRefLen = 100;
@Column(name = "name", length = _nameLen, nullable = false)
private String name;
public final static String _name = "name";
public final static int _nameLen = 250;
@Column(name = "extension", length = _extensionLen, nullable = false)
private String extension;
public final static String _extension = "extension";
public final static int _extensionLen = 10;
@Column(name = "mime_type", length = _mimeTypeLen, nullable = false)
private String mimeType;
public final static String _mimeType = "mimeType";
public final static int _mimeTypeLen = 200;
@Column(name = "storage_type", nullable = false)
@Convert(converter = StorageTypeConverter.class)
private StorageType storageType;
public final static String _storageType = "storageType";
@Column(name = "created_at", nullable = false)
private Instant createdAt;
public final static String _createdAt = "createdAt";
@Column(name = "purge_at", nullable = true)
private Instant purgeAt;
public final static String _purgeAt = "purgeAt";
@Column(name = "purged_at", nullable = true)
private Instant purgedAt;
public final static String _purgedAt = "purgedAt";
@Column(name = "owner", nullable = true)
private UUID ownerId;
public final static String _ownerId = "ownerId";
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getFileRef() {
return fileRef;
}
public void setFileRef(String fileRef) {
this.fileRef = fileRef;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getExtension() {
return extension;
}
public void setExtension(String extension) {
this.extension = extension;
}
public String getMimeType() {
return mimeType;
}
public void setMimeType(String mimeType) {
this.mimeType = mimeType;
}
public StorageType getStorageType() {
return storageType;
}
public void setStorageType(StorageType storageType) {
this.storageType = storageType;
}
public Instant getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt;
}
public Instant getPurgeAt() {
return purgeAt;
}
public void setPurgeAt(Instant purgeAt) {
this.purgeAt = purgeAt;
}
public Instant getPurgedAt() {
return purgedAt;
}
public void setPurgedAt(Instant purgedAt) {
this.purgedAt = purgedAt;
}
public UUID getOwnerId() {
return ownerId;
}
public void setOwnerId(UUID ownerId) {
this.ownerId = ownerId;
}
}

View File

@ -1,6 +1,5 @@
package eu.eudat.data; package eu.eudat.data;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.enums.IsActiveConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
import jakarta.persistence.*; import jakarta.persistence.*;
@ -8,7 +7,6 @@ import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;
@Entity @Entity
@Table(name = "\"Tag\"") @Table(name = "\"Tag\"")
public class TagEntity { public class TagEntity {

View File

@ -1,21 +1,16 @@
package eu.eudat.data; package eu.eudat.data;
import eu.eudat.commons.enums.ContactInfoType; import eu.eudat.commons.enums.ContactInfoType;
import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.data.converters.enums.ContactInfoTypeConverter; import eu.eudat.data.converters.enums.ContactInfoTypeConverter;
import eu.eudat.data.converters.enums.DescriptionStatusConverter;
import eu.eudat.data.old.helpers.EntityBinder;
import eu.eudat.data.old.queryableentity.DataEntity;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.List;
import java.util.UUID; import java.util.UUID;
@Entity @Entity
@Table(name = "\"UserContactInfo\"") @Table(name = "\"UserContactInfo\"")
public class UserContactInfoEntity { public class UserContactInfoEntity {
@Id @Id
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
private UUID id; private UUID id;

View File

@ -1,14 +1,13 @@
package eu.eudat.data; package eu.eudat.data;
import eu.eudat.data.old.helpers.EntityBinder; import jakarta.persistence.Column;
import eu.eudat.data.old.queryableentity.DataEntity; import jakarta.persistence.Entity;
import jakarta.persistence.*; import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.time.Instant; import java.time.Instant;
import java.util.List;
import java.util.UUID; import java.util.UUID;
@Entity @Entity
@Table(name = "\"UserCredential\"") @Table(name = "\"UserCredential\"")
public class UserCredentialEntity { public class UserCredentialEntity {

View File

@ -4,12 +4,9 @@ import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.enums.UserDescriptionTemplateRole; import eu.eudat.commons.enums.UserDescriptionTemplateRole;
import eu.eudat.data.converters.enums.IsActiveConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
import eu.eudat.data.converters.enums.UserDescriptionTemplateRoleConverter; import eu.eudat.data.converters.enums.UserDescriptionTemplateRoleConverter;
import eu.eudat.data.old.helpers.EntityBinder;
import eu.eudat.data.old.queryableentity.DataEntity;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.List;
import java.util.UUID; import java.util.UUID;
@Entity @Entity

View File

@ -2,14 +2,10 @@ package eu.eudat.data;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.enums.IsActiveConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
import eu.eudat.data.old.helpers.EntityBinder;
import eu.eudat.data.old.queryableentity.DataEntity;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.*; import java.util.UUID;
@Entity @Entity
@Table(name = "\"User\"") @Table(name = "\"User\"")

View File

@ -1,15 +1,13 @@
package eu.eudat.data; package eu.eudat.data;
import eu.eudat.data.old.helpers.EntityBinder; import jakarta.persistence.Column;
import eu.eudat.data.old.queryableentity.DataEntity; import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.*; import jakarta.persistence.Table;
import java.time.Instant; import java.time.Instant;
import java.util.List;
import java.util.UUID; import java.util.UUID;
@Entity @Entity
@Table(name = "\"UserRole\"") @Table(name = "\"UserRole\"")
public class UserRoleEntity { public class UserRoleEntity {

View File

@ -1,6 +1,5 @@
package eu.eudat.data; package eu.eudat.data;
import eu.eudat.commons.enums.UserSettingsType; import eu.eudat.commons.enums.UserSettingsType;
import eu.eudat.data.converters.enums.UserSettingsTypeConverter; import eu.eudat.data.converters.enums.UserSettingsTypeConverter;
import jakarta.persistence.*; import jakarta.persistence.*;

View File

@ -0,0 +1,12 @@
package eu.eudat.data.converters.enums;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.enums.StorageType;
import jakarta.persistence.Converter;
@Converter
public class StorageTypeConverter extends DatabaseEnumConverter<StorageType, Short> {
public StorageType of(Short i) {
return StorageType.of(i);
}
}

View File

@ -93,7 +93,7 @@ public class Dmp {
private List<DmpUser> dmpUsers; private List<DmpUser> dmpUsers;
public static final String _dmpUsers = "dmoUsers"; public static final String _dmpUsers = "dmpUsers";
public UUID getId() { public UUID getId() {
return id; return id;

View File

@ -0,0 +1,86 @@
package eu.eudat.model;
import eu.eudat.commons.enums.IsActive;
import java.time.Instant;
import java.util.UUID;
public class Language {
private UUID id;
public static final String _id = "id";
private String code;
public static final String _code = "code";
private String payload;
public static final String _payload = "payload";
private Instant createdAt;
public static final String _createdAt = "createdAt";
private Instant updatedAt;
public static final String _updatedAt = "updatedAt";
private IsActive isActive;
public static final String _isActive = "isActive";
private String hash;
public final static String _hash = "hash";
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getPayload() {
return payload;
}
public void setPayload(String payload) {
this.payload = payload;
}
public Instant getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt;
}
public Instant getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Instant updatedAt) {
this.updatedAt = updatedAt;
}
public IsActive getIsActive() {
return isActive;
}
public void setIsActive(IsActive isActive) {
this.isActive = isActive;
}
public String getHash() {
return hash;
}
public void setHash(String hash) {
this.hash = hash;
}
}

View File

@ -0,0 +1,130 @@
package eu.eudat.model;
import eu.eudat.commons.enums.StorageType;
import java.time.Instant;
import java.util.UUID;
public class StorageFile {
private UUID id;
public final static String _id = "id";
private String fileRef;
public final static String _fileRef = "fileRef";
private String name;
public final static String _name = "name";
private String fullName;
public final static String _fullName = "fullName";
private String extension;
public final static String _extension = "extension";
private String mimeType;
public final static String _mimeType = "mimeType";
private StorageType storageType;
public final static String _storageType = "storageType";
private Instant createdAt;
public final static String _createdAt = "createdAt";
private Instant purgeAt;
public final static String _purgeAt = "purgeAt";
private Instant purgedAt;
public final static String _purgedAt = "purgedAt";
private User owner;
public final static String _owner = "owner";
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getFileRef() {
return fileRef;
}
public void setFileRef(String fileRef) {
this.fileRef = fileRef;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getExtension() {
return extension;
}
public void setExtension(String extension) {
this.extension = extension;
}
public String getMimeType() {
return mimeType;
}
public void setMimeType(String mimeType) {
this.mimeType = mimeType;
}
public StorageType getStorageType() {
return storageType;
}
public void setStorageType(StorageType storageType) {
this.storageType = storageType;
}
public Instant getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt;
}
public Instant getPurgeAt() {
return purgeAt;
}
public void setPurgeAt(Instant purgeAt) {
this.purgeAt = purgeAt;
}
public Instant getPurgedAt() {
return purgedAt;
}
public void setPurgedAt(Instant purgedAt) {
this.purgedAt = purgedAt;
}
public User getOwner() {
return owner;
}
public void setOwner(User owner) {
this.owner = owner;
}
}

View File

@ -0,0 +1,61 @@
package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.XmlHandlingService;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.LanguageEntity;
import eu.eudat.model.Language;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.*;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class LanguageBuilder extends BaseBuilder<Language, LanguageEntity>{
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
public LanguageBuilder(
ConventionService conventionService,
BuilderFactory builderFactory, QueryFactory queryFactory, XmlHandlingService xmlHandlingService) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(LanguageBuilder.class)));
}
public LanguageBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<Language> build(FieldSet fields, List<LanguageEntity> data) throws MyApplicationException {
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
this.logger.trace(new DataLogEntry("requested fields", fields));
if (fields == null || data == null || fields.isEmpty())
return new ArrayList<>();
List<Language> models = new ArrayList<>();
for (LanguageEntity d : data) {
Language m = new Language();
if (fields.hasField(this.asIndexer(Language._id))) m.setId(d.getId());
if (fields.hasField(this.asIndexer(Language._code))) m.setCode(d.getCode());
if (fields.hasField(this.asIndexer(Language._payload))) m.setPayload(d.getPayload());
if (fields.hasField(this.asIndexer(Language._createdAt))) m.setCreatedAt(d.getCreatedAt());
if (fields.hasField(this.asIndexer(Language._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(Language._isActive))) m.setIsActive(d.getIsActive());
if (fields.hasField(this.asIndexer(Language._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
}

View File

@ -0,0 +1,111 @@
package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.StorageFileEntity;
import eu.eudat.model.*;
import eu.eudat.query.*;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.stream.Collectors;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class StorageFileBuilder extends BaseBuilder<StorageFile, StorageFileEntity> {
private final QueryFactory queryFactory;
private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
public StorageFileBuilder(
ConventionService conventionService,
QueryFactory queryFactory,
BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(StorageFileBuilder.class)));
this.queryFactory = queryFactory;
this.builderFactory = builderFactory;
}
public StorageFileBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<StorageFile> build(FieldSet fields, List<StorageFileEntity> data) throws MyApplicationException {
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
this.logger.trace(new DataLogEntry("requested fields", fields));
if (fields == null || data == null || fields.isEmpty())
return new ArrayList<>();
FieldSet userFields = fields.extractPrefixed(this.asPrefix(StorageFile._owner));
Map<UUID, User> userItemsMap = this.collectUsers(userFields, data);
List<StorageFile> models = new ArrayList<>();
for (StorageFileEntity d : data) {
StorageFile m = new StorageFile();
if (fields.hasField(this.asIndexer(StorageFile._id))) m.setId(d.getId());
if (fields.hasField(this.asIndexer(StorageFile._name))) m.setName(d.getName());
if (fields.hasField(this.asIndexer(StorageFile._fileRef))) m.setFileRef(d.getFileRef());
if (fields.hasField(this.asIndexer(StorageFile._extension))) m.setExtension(d.getExtension());
if (fields.hasField(this.asIndexer(StorageFile._createdAt))) m.setCreatedAt(d.getCreatedAt());
if (fields.hasField(this.asIndexer(StorageFile._mimeType))) m.setMimeType(d.getMimeType());
if (fields.hasField(this.asIndexer(StorageFile._storageType))) m.setStorageType(d.getStorageType());
if (fields.hasField(this.asIndexer(StorageFile._purgeAt))) m.setPurgeAt(d.getPurgeAt());
if (fields.hasField(this.asIndexer(StorageFile._purgedAt))) m.setPurgedAt(d.getPurgedAt());
if (fields.hasField(this.asIndexer(StorageFile._fullName))) m.setFullName(d.getName() + (d.getExtension().startsWith(".") ? "" : ".") + d.getExtension());
if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getOwnerId())) m.setOwner(userItemsMap.get(d.getOwnerId()));
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
private Map<UUID, User> collectUsers(FieldSet fields, List<StorageFileEntity> data) throws MyApplicationException {
if (fields.isEmpty() || data.isEmpty())
return null;
this.logger.debug("checking related - {}", User.class.getSimpleName());
Map<UUID, User> itemMap;
if (!fields.hasOtherField(this.asIndexer(User._id))) {
itemMap = this.asEmpty(
data.stream().map(StorageFileEntity::getOwnerId).distinct().collect(Collectors.toList()),
x -> {
User item = new User();
item.setId(x);
return item;
},
User::getId);
} else {
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(User._id);
UserQuery q = this.queryFactory.query(UserQuery.class).authorize(this.authorize).ids(data.stream().map(StorageFileEntity::getOwnerId).distinct().collect(Collectors.toList()));
itemMap = this.builderFactory.builder(UserBuilder.class).authorize(this.authorize).asForeignKey(q, clone, User::getId);
}
if (!fields.hasField(User._id)) {
itemMap.forEach((id, item) -> {
if (item != null)
item.setId(null);
});
}
return itemMap;
}
}

View File

@ -0,0 +1,42 @@
package eu.eudat.model.censorship;
import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class LanguageCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(LanguageCensor.class));
protected final AuthorizationService authService;
protected final CensorFactory censorFactory;
public LanguageCensor(ConventionService conventionService,
AuthorizationService authService,
CensorFactory censorFactory) {
super(conventionService);
this.authService = authService;
this.censorFactory = censorFactory;
}
public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorizeForce(Permission.BrowseLanguage);
}
}

View File

@ -0,0 +1,45 @@
package eu.eudat.model.censorship;
import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.StorageFile;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class StorageFileCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(StorageFileCensor.class));
protected final AuthorizationService authService;
protected final CensorFactory censorFactory;
public StorageFileCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) {
super(conventionService);
this.authService = authService;
this.censorFactory = censorFactory;
}
public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorizeForce(Permission.BrowseStorageFile);
FieldSet ownerFields = fields.extractPrefixed(this.asIndexerPrefix(StorageFile._owner));
this.censorFactory.censor(UserCensor.class).censor(ownerFields, userId);
}
}

View File

@ -0,0 +1,78 @@
package eu.eudat.model.deleter;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.LanguageEntity;
import eu.eudat.query.LanguageQuery;
import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.management.InvalidApplicationException;
import java.time.Instant;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class LanguageDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(LanguageDeleter.class));
private final EntityManager entityManager;
protected final QueryFactory queryFactory;
protected final DeleterFactory deleterFactory;
@Autowired
public LanguageDeleter(
EntityManager entityManager,
QueryFactory queryFactory,
DeleterFactory deleterFactory
) {
this.entityManager = entityManager;
this.queryFactory = queryFactory;
this.deleterFactory = deleterFactory;
}
public void deleteAndSaveByIds(List<UUID> ids) throws InvalidApplicationException {
logger.debug(new MapLogEntry("collecting to delete").And("count", Optional.ofNullable(ids).map(List::size).orElse(0)).And("ids", ids));
List<LanguageEntity> data = this.queryFactory.query(LanguageQuery.class).ids(ids).collect();
logger.trace("retrieved {} items", Optional.ofNullable(data).map(List::size).orElse(0));
this.deleteAndSave(data);
}
public void deleteAndSave(List<LanguageEntity> data) throws InvalidApplicationException {
logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
this.delete(data);
logger.trace("saving changes");
this.entityManager.flush();
logger.trace("changes saved");
}
public void delete(List<LanguageEntity> data) throws InvalidApplicationException {
logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
if (data == null || data.isEmpty())
return;
Instant now = Instant.now();
for (LanguageEntity item : data) {
logger.trace("deleting item {}", item.getId());
item.setIsActive(IsActive.Inactive);
item.setUpdatedAt(now);
logger.trace("updating item");
this.entityManager.merge(item);
logger.trace("updated item");
}
}
}

View File

@ -0,0 +1,32 @@
package eu.eudat.model.mapper.publicapi;
import eu.eudat.model.Dmp;
import eu.eudat.model.publicapi.listingmodels.DataManagementPlanPublicListingModel;
import eu.eudat.model.publicapi.researcher.ResearcherPublicModel;
import eu.eudat.model.publicapi.user.UserInfoPublicModel;
import org.springframework.stereotype.Component;
import java.sql.Date;
import java.util.Objects;
@Component
public class DmpToPublicApiDmpListingMapper {
public DataManagementPlanPublicListingModel toPublicListingModel(Dmp dmp) {
DataManagementPlanPublicListingModel model = new DataManagementPlanPublicListingModel();
model.setId(dmp.getId().toString());
model.setLabel(dmp.getLabel());
model.setVersion(dmp.getVersion());
model.setGroupId(dmp.getGroupId());
model.setUsers(dmp.getDmpUsers().stream().map(UserInfoPublicModel::fromDmpUser).toList());
model.setResearchers(dmp.getDmpReferences().stream().map(ResearcherPublicModel::fromDmpReference).filter(Objects::isNull).toList());
model.setCreatedAt(Date.from(dmp.getCreatedAt()));
model.setModifiedAt(Date.from(dmp.getUpdatedAt()));
model.setFinalizedAt(Date.from(dmp.getFinalizedAt()));
return model;
}
}

View File

@ -0,0 +1,33 @@
package eu.eudat.model.mapper.publicapi;
import eu.eudat.model.Dmp;
import eu.eudat.model.publicapi.overviewmodels.DataManagementPlanPublicModel;
import eu.eudat.model.publicapi.researcher.ResearcherPublicModel;
import eu.eudat.model.publicapi.user.UserInfoPublicModel;
import org.springframework.stereotype.Component;
import java.sql.Date;
import java.util.Objects;
@Component
public class DmpToPublicApiDmpMapper {
public DataManagementPlanPublicModel toPublicModel(Dmp dmp) {
DataManagementPlanPublicModel model = new DataManagementPlanPublicModel();
model.setId(dmp.getId().toString());
model.setLabel(dmp.getLabel());
model.setDescription(dmp.getDescription());
model.setVersion(dmp.getVersion());
model.setGroupId(dmp.getGroupId());
model.setUsers(dmp.getDmpUsers().stream().map(UserInfoPublicModel::fromDmpUser).toList());
model.setResearchers(dmp.getDmpReferences().stream().map(ResearcherPublicModel::fromDmpReference).filter(Objects::isNull).toList());
model.setCreatedAt(Date.from(dmp.getCreatedAt()));
model.setModifiedAt(Date.from(dmp.getUpdatedAt()));
model.setFinalizedAt(Date.from(dmp.getFinalizedAt()));
return model;
}
}

View File

@ -0,0 +1,56 @@
package eu.eudat.model.persist;
import eu.eudat.commons.validation.ValidId;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.util.UUID;
public class LanguagePersist {
@ValidId(message = "{validation.invalidid}")
private UUID id;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
@Size(max = 20, message = "{validation.largerthanmax}")
private String code;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String payload;
private String hash;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getPayload() {
return payload;
}
public void setPayload(String payload) {
this.payload = payload;
}
public String getHash() {
return hash;
}
public void setHash(String hash) {
this.hash = hash;
}
}

View File

@ -0,0 +1,86 @@
package eu.eudat.model.persist;
import eu.eudat.commons.enums.StorageType;
import eu.eudat.commons.validation.ValidEnum;
import eu.eudat.data.StorageFileEntity;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.Duration;
import java.util.UUID;
public class StorageFilePersist {
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
@Size(max = StorageFileEntity._nameLen, message = "{validation.largerthanmax}")
private String name;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
@Size(max = StorageFileEntity._extensionLen, message = "{validation.largerthanmax}")
private String extension;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
@Size(max = StorageFileEntity._mimeTypeLen, message = "{validation.largerthanmax}")
private String mimeType;
@NotNull(message = "{validation.empty}")
@ValidEnum(message = "{validation.empty}")
private StorageType storageType;
private Duration lifetime;
private UUID ownerId;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getExtension() {
return extension;
}
public void setExtension(String extension) {
this.extension = extension;
}
public String getMimeType() {
return mimeType;
}
public void setMimeType(String mimeType) {
this.mimeType = mimeType;
}
public StorageType getStorageType() {
return storageType;
}
public void setStorageType(StorageType storageType) {
this.storageType = storageType;
}
public UUID getOwnerId() {
return ownerId;
}
public void setOwnerId(UUID ownerId) {
this.ownerId = ownerId;
}
public Duration getLifetime() {
return lifetime;
}
public void setLifetime(Duration lifetime) {
this.lifetime = lifetime;
}
}

View File

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

View File

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

View File

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

View File

@ -1,11 +1,10 @@
package eu.eudat.publicapi.models.datasetprofile; package eu.eudat.model.publicapi.datasetprofile;
import eu.eudat.data.DescriptionTemplateEntity; import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.models.DataModel;
import java.util.UUID; import java.util.UUID;
public class DatasetProfilePublicModel implements DataModel<DescriptionTemplateEntity, DatasetProfilePublicModel> { public class DatasetProfilePublicModel {
private UUID id; private UUID id;
private String label; private String label;
@ -23,14 +22,12 @@ public class DatasetProfilePublicModel implements DataModel<DescriptionTemplateE
this.label = label; this.label = label;
} }
@Override
public DatasetProfilePublicModel fromDataModel(DescriptionTemplateEntity entity) { public DatasetProfilePublicModel fromDataModel(DescriptionTemplateEntity entity) {
this.id = entity.getId(); this.id = entity.getId();
this.label = entity.getLabel(); this.label = entity.getLabel();
return this; return this;
} }
@Override
public DescriptionTemplateEntity toDataModel() { public DescriptionTemplateEntity toDataModel() {
DescriptionTemplateEntity entity = new DescriptionTemplateEntity(); DescriptionTemplateEntity entity = new DescriptionTemplateEntity();
entity.setId(this.getId()); entity.setId(this.getId());
@ -38,8 +35,4 @@ public class DatasetProfilePublicModel implements DataModel<DescriptionTemplateE
return entity; return entity;
} }
@Override
public String getHint() {
return null;
}
} }

View File

@ -1,13 +1,11 @@
package eu.eudat.publicapi.models.datasetwizard; package eu.eudat.model.publicapi.datasetwizard;
import eu.eudat.data.old.DataRepository; import eu.eudat.data.old.DataRepository;
import eu.eudat.logic.utilities.helpers.LabelGenerator;
import eu.eudat.models.DataModel;
import java.util.Date; import java.util.Date;
import java.util.UUID; import java.util.UUID;
public class DataRepositoryPublicModel implements DataModel<DataRepository, DataRepositoryPublicModel>, LabelGenerator { public class DataRepositoryPublicModel {
private String id; private String id;
private String pid; private String pid;
private String name; private String name;
@ -124,12 +122,10 @@ public class DataRepositoryPublicModel implements DataModel<DataRepository, Data
return entity; return entity;
} }
@Override
public String generateLabel() { public String generateLabel() {
return this.getName(); return this.getName();
} }
@Override
public String getHint() { public String getHint() {
return null; return null;
} }

View File

@ -0,0 +1,86 @@
package eu.eudat.model.publicapi.datasetwizard;
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
import java.util.List;
import java.util.Map;
public class DatasetProfile implements PropertiesModelBuilder {
private String description;
private String language;
private String type;
private List<Section> sections;
private List<Rule> rules;
private List<Page> pages;
private int status;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public List<Section> getSections() {
return sections;
}
public void setSections(List<Section> sections) {
this.sections = sections;
}
public List<Rule> getRules() {
return rules;
}
public void setRules(List<Rule> rules) {
this.rules = rules;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public List<Page> getPages() {
return pages;
}
public void setPages(List<Page> pages) {
this.pages = pages;
}
@Override
public void fromJsonObject(Map<String, Object> properties) {
this.sections.forEach(item -> item.fromJsonObject(properties));
}
@Override
public void fromJsonObject(Map<String, Object> properties, String index) {
// TODO Auto-generated method stub
}
}

View File

@ -0,0 +1,33 @@
package eu.eudat.model.publicapi.datasetwizard;
import java.util.List;
public class DatasetProfilePage {
private Integer ordinal;
private String title;
private List<Section> sections;
public Integer getOrdinal() {
return ordinal;
}
public void setOrdinal(Integer ordinal) {
this.ordinal = ordinal;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public List<Section> getSections() {
return sections;
}
public void setSections(List<Section> sections) {
this.sections = sections;
}
}

View File

@ -1,13 +1,11 @@
package eu.eudat.publicapi.models.datasetwizard; package eu.eudat.model.publicapi.datasetwizard;
import eu.eudat.data.old.ExternalDataset; import eu.eudat.data.old.ExternalDataset;
import eu.eudat.models.DataModel;
import eu.eudat.types.externalsourcetype.ExternalDatasetType;
import java.util.Date; import java.util.Date;
import java.util.UUID; import java.util.UUID;
public class ExternalDatasetPublicListingModel implements DataModel<ExternalDataset, ExternalDatasetPublicListingModel> { public class ExternalDatasetPublicListingModel {
private UUID id; private UUID id;
private String name; private String name;
private String abbreviation; private String abbreviation;
@ -105,7 +103,6 @@ public class ExternalDatasetPublicListingModel implements DataModel<ExternalData
this.source = source; this.source = source;
} }
@Override
public ExternalDatasetPublicListingModel fromDataModel(ExternalDataset entity) { public ExternalDatasetPublicListingModel fromDataModel(ExternalDataset entity) {
this.id = entity.getId(); this.id = entity.getId();
this.abbreviation = entity.getAbbreviation(); this.abbreviation = entity.getAbbreviation();
@ -122,7 +119,6 @@ public class ExternalDatasetPublicListingModel implements DataModel<ExternalData
return this; return this;
} }
@Override
public ExternalDataset toDataModel() throws Exception { public ExternalDataset toDataModel() throws Exception {
ExternalDataset externalDataset = new ExternalDataset(); ExternalDataset externalDataset = new ExternalDataset();
externalDataset.setAbbreviation(this.abbreviation); externalDataset.setAbbreviation(this.abbreviation);
@ -146,7 +142,6 @@ public class ExternalDatasetPublicListingModel implements DataModel<ExternalData
return externalDataset; return externalDataset;
} }
@Override
public String getHint() { public String getHint() {
return null; return null;
} }

View File

@ -1,10 +1,5 @@
package eu.eudat.types.externalsourcetype; package eu.eudat.model.publicapi.datasetwizard;
import eu.eudat.types.ApiMessageCode;
/**
* Created by ikalyvas on 5/28/2018.
*/
public enum ExternalDatasetType{ public enum ExternalDatasetType{
SOURCE(0), OUTPUT(1) ; SOURCE(0), OUTPUT(1) ;

View File

@ -0,0 +1,296 @@
package eu.eudat.model.publicapi.datasetwizard;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.commons.enums.FieldValidationType;
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
import eu.eudat.commons.types.descriptiontemplate.MultiplicityEntity;
import eu.eudat.commons.types.descriptiontemplate.todelete.DefaultValueEntity;
import eu.eudat.commons.types.descriptiontemplate.todelete.FieldDescriptionEntity;
import eu.eudat.commons.types.descriptiontemplate.todelete.VisibilityEntity;
import org.apache.commons.lang3.NotImplementedException;
import org.json.JSONException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class Field implements Comparable, PropertiesModelBuilder {
private static final Logger logger = LoggerFactory.getLogger(Field.class);
private String id;
private Integer ordinal;
private Object value;
private FieldDescriptionEntity viewStyle;
private String datatype;
private String numbering;
private int page;
private DefaultValueEntity defaultValue;
private MultiplicityEntity multiplicity;
private Object data;
private List<Field> multiplicityItems;
private List<FieldValidationType> validations;
private VisibilityEntity visible;
private List<String> schematics;
private Boolean export;
public List<Field> getMultiplicityItems() {
return multiplicityItems;
}
public void setMultiplicityItems(List<Field> multiplicityItems) {
this.multiplicityItems = multiplicityItems;
}
public void setOrdinal(Integer ordinal) {
this.ordinal = ordinal;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Integer getOrdinal() {
return ordinal;
}
public void setOrdinal(int ordinal) {
this.ordinal = ordinal;
}
public Object getValue() {
return value;
}
public void setValue(Object value) {
this.value = value;
}
public FieldDescriptionEntity getViewStyle() {
return viewStyle;
}
public void setViewStyle(FieldDescriptionEntity viewStyle) {
this.viewStyle = viewStyle;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public DefaultValueEntity getDefaultValue() {
return defaultValue;
}
public void setDefaultValue(DefaultValueEntity defaultValue) {
this.defaultValue = defaultValue;
}
public String getDatatype() {
return datatype;
}
public void setDatatype(String datatype) {
this.datatype = datatype;
}
public MultiplicityEntity getMultiplicity() {
return multiplicity;
}
public void setMultiplicity(MultiplicityEntity multiplicity) {
this.multiplicity = multiplicity;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
public VisibilityEntity getVisible() {
return visible;
}
public void setVisible(VisibilityEntity visible) {
this.visible = visible;
}
public List<Integer> getValidations() {
if(this.validations == null) {
return null;
}
return this.validations.stream().map(item -> (int) item.getValue()).collect(Collectors.toList());
}
public void setValidations(List<Integer> validations) {
this.validations = validations.stream().map(x-> FieldValidationType.of(x.shortValue())).collect(Collectors.toList());
}
public String getNumbering() {
return numbering;
}
public void setNumbering(String numbering) {
this.numbering = numbering;
}
public List<String> getSchematics() {
return schematics;
}
public void setSchematics(List<String> schematics) {
this.schematics = schematics;
}
public Boolean getExport() {
return export;
}
public void setExport(Boolean export) {
this.export = export;
}
Field cloneForMultiplicity(String key, Map<String, Object> properties, int index) {
Field newField = new Field();
newField.id = key;
newField.ordinal = this.ordinal;
newField.value = properties.containsKey(key)? properties.get(key): null;
newField.viewStyle = this.viewStyle;
newField.datatype = this.datatype;
newField.page = this.page;
newField.defaultValue = this.defaultValue;
newField.data = this.data;
newField.validations = this.validations;
newField.schematics = this.schematics;
newField.numbering = "mult" + index + "_" + this.numbering;
newField.export = this.export;
return newField;
}
public FieldEntity toDatabaseDefinition(FieldEntity fieldEntity) {
fieldEntity.setId(this.id);
fieldEntity.setOrdinal(this.ordinal);
throw new NotImplementedException(" Use new logic");
//TODO: Use new logic
// fieldEntity.setData(new FieldDataHelper().toFieldData(data, this.viewStyle.getFieldType()));
// fieldEntity.setDefaultValue(this.defaultValue.getValue());
// fieldEntity.setVisibilityRules(this.visible.getRules());
// fieldEntity.setValidations(this.validations);
// fieldEntity.setSchematics(this.schematics);
// fieldEntity.setIncludeInExport(this.export);
// return fieldEntity;
}
public void fromDatabaseDefinition(FieldEntity item) {
this.id = item.getId();
this.ordinal = item.getOrdinal();
FieldDescriptionEntity fieldDescription = new FieldDescriptionEntity();
fieldDescription.setFieldType(item.getData().getFieldType());
this.viewStyle = fieldDescription;
this.numbering = item.getNumbering();
this.data = item.getData();
DefaultValueEntity defaultValueEntity = new DefaultValueEntity();
defaultValueEntity.setValue(item.getDefaultValue());
this.defaultValue = defaultValueEntity;
VisibilityEntity visibilityEntity = new VisibilityEntity();
visibilityEntity.setRules(item.getVisibilityRules());
this.visible = visibilityEntity;
this.validations = item.getValidations();
this.schematics = item.getSchematics();
this.export = item.getIncludeInExport();
}
@Override
public void fromJsonObject(Map<String, Object> properties) {
try {
ObjectMapper mapper = new ObjectMapper();
List<String> stringList = mapper.readValue(properties.get(this.id).toString(), LinkedList.class);
this.value = stringList;
} catch (JSONException | NullPointerException | IOException e) {
try {
this.value = (String) properties.get(this.id);
} catch (ClassCastException ce) {
this.value = properties.get(this.id);
}
}
this.multiplicityItems = new LinkedList<>();
List<String> compositeKeys = properties.keySet().stream().filter(keys -> keys.startsWith("multiple_" + this.getId())).collect(Collectors.toList());
int index = 1;
for (String key : compositeKeys) {
this.multiplicityItems.add(this.cloneForMultiplicity(key, properties, index));
}
}
@Override
public int compareTo(Object o) {
Field comparedField = (Field) o;
if(this.ordinal != null) {
return this.ordinal.compareTo(comparedField.getOrdinal());
} else if (comparedField.getOrdinal() != null) {
return comparedField.getOrdinal().compareTo(this.ordinal);
} else {
return 0;
}
}
@Override
public void fromJsonObject(Map<String, Object> properties, String path) {
this.value = (String) properties.get(path);
}
public void toMap(Map<String, Object> fieldValues) {
if (this.value != null) {
if ((this.viewStyle != null && this.viewStyle.getFieldType().equals("datasetIdentifier") && this.value instanceof Map || this.value instanceof Collection)) {
ObjectMapper mapper = new ObjectMapper();
String valueString = null;
try {
valueString = mapper.writeValueAsString(this.value);
fieldValues.put(this.id, valueString);
} catch (JsonProcessingException e) {
logger.error(e.getMessage(), e);
}
} /*else if (this.value instanceof Collection) {
Collection valueCollection = (Collection) this.value;
StringBuilder valueBuilder = new StringBuilder();
valueBuilder.append("[");
for (int i = 0; i < valueCollection.size(); i++) {
valueBuilder.append("\"").append(valueCollection.toArray()[i]).append("\"");
if (i < valueCollection.size() - 1) {
valueBuilder.append(", ");
}
}
valueBuilder.append("]");
fieldValues.put(this.id, valueBuilder.toString());
}*/
else if ((this.viewStyle != null && this.viewStyle.getFieldType().equals("upload"))) {
fieldValues.put(this.id, this.value);
}
else {
fieldValues.put(this.id, this.value.toString());
}
} else {
fieldValues.put(this.id, "");
}
}
public void toMap(Map<String, Object> fieldValues, int index) {
fieldValues.put(this.id, this.value);
}
}

View File

@ -0,0 +1,215 @@
package eu.eudat.model.publicapi.datasetwizard;
import eu.eudat.commons.types.descriptiontemplate.FieldSetEntity;
import eu.eudat.commons.types.descriptiontemplate.MultiplicityEntity;
import java.util.*;
import java.util.stream.Collectors;
public class FieldSet implements Comparable<Object>, PropertiesModelBuilder {
private String id;
private Integer ordinal;
private String title;
private String numbering;
private String description;
private String extendedDescription;
private String additionalInformation;
private MultiplicityEntity multiplicity;
private List<Field> fields;
private List<FieldSet> multiplicityItems;
private boolean hasCommentField;
private String commentFieldValue;
public List<Field> getFields() {
Collections.sort(this.fields);
return fields;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getExtendedDescription() {
return extendedDescription;
}
public void setExtendedDescription(String extendedDescription) {
this.extendedDescription = extendedDescription;
}
public void setFields(List<Field> fields) {
this.fields = fields;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getOrdinal() {
return ordinal;
}
public void setOrdinal(int ordinal) {
this.ordinal = ordinal;
}
public MultiplicityEntity getMultiplicity() {
return multiplicity;
}
public void setMultiplicity(MultiplicityEntity multiplicity) {
this.multiplicity = multiplicity;
}
public List<FieldSet> getMultiplicityItems() {
if (multiplicityItems != null) Collections.sort(multiplicityItems);
return multiplicityItems;
}
public String getNumbering() {
return numbering;
}
public void setNumbering(String numbering) {
this.numbering = numbering;
}
public void setMultiplicityItems(List<FieldSet> multiplicityItems) {
this.multiplicityItems = multiplicityItems;
}
public void setOrdinal(Integer ordinal) {
this.ordinal = ordinal;
}
public void setHasCommentField(boolean hasCommentField) {
this.hasCommentField = hasCommentField;
}
public boolean getHasCommentField() {
return hasCommentField;
}
public String getCommentFieldValue() {
return commentFieldValue;
}
public void setCommentFieldValue(String commentFieldValue) {
this.commentFieldValue = commentFieldValue;
}
public String getAdditionalInformation() {
return additionalInformation;
}
public void setAdditionalInformation(String additionalInformation) {
this.additionalInformation = additionalInformation;
}
public FieldSetEntity toDatabaseDefinition(FieldSetEntity item) {
// List<FieldEntity> viewStylefields = new ModelBuilder().toViewStyleDefinition(this.fields, FieldEntity.class);
// item.setFields(viewStylefields);
// item.setId(this.id);
// item.setOrdinal(this.ordinal);
// item.setHasCommentField(this.hasCommentField);
// item.setMultiplicity(this.multiplicity);
//// item.setCommentFieldValue(this.commentFieldValue);
// return item;
return null;
}
public void fromDatabaseDefinition(FieldSetEntity item) {
// this.fields = new ModelBuilder().fromViewStyleDefinition(item.getFields(), Field.class);
// this.id = item.getId();
// this.ordinal = item.getOrdinal();
// this.title = item.getTitle();
// this.description = item.getDescription();
// this.additionalInformation=item.getAdditionalInformation();
// this.numbering = item.getNumbering();
// this.extendedDescription = item.getExtendedDescription();
// this.hasCommentField = item.getHasCommentField();
// this.multiplicity = item.getMultiplicity();
//// this.commentFieldValue = item.getCommentFieldValue();
}
@Override
public void fromJsonObject(Map<String, Object> properties) {
this.commentFieldValue = (String) properties.get("commentFieldValue" + this.id);
this.multiplicityItems = new LinkedList<FieldSet>();
this.fields.forEach(item -> {
item.fromJsonObject(properties);
});
List<String> compositeKeysFather = properties.keySet().stream().filter(keys -> keys.startsWith("multiple_" + this.getId())).collect(Collectors.toList());
List<String> Ids=new ArrayList<>();
int index = 1;
for (String composite : compositeKeysFather) {
String[] split = composite.split("_");
if (!Ids.contains(split[2])) {
Ids.add(split[2]);
this.multiplicityItems.add(this.CloneForMultiplicity2(properties.keySet().stream().filter(keys -> keys.startsWith("multiple_" + this.getId() + "_" + split[2])).collect(Collectors.toList()), properties,split, index));
index++;
}
}
}
private FieldSet CloneForMultiplicity2(List<String> key, Map<String, Object> properties,String[] ids, int index){
FieldSet newFieldSet = new FieldSet();
newFieldSet.id = ids[0]+"_"+ids[1]+"_"+ids[2] + (ids.length > 4 ? "_" + ids[3] : "");
newFieldSet.description = this.description;
newFieldSet.extendedDescription = this.extendedDescription;
newFieldSet.additionalInformation=this.additionalInformation;
newFieldSet.title = this.title;
newFieldSet.ordinal = ids.length > 4 ? Integer.valueOf(ids[3]) : this.ordinal;
newFieldSet.fields = new LinkedList();
for (Field field: this.fields) {
newFieldSet.fields.add(field.cloneForMultiplicity(newFieldSet.id + "_" + field.getId(), properties, index));
}
return newFieldSet;
}
@Override
public int compareTo(Object o) {
return this.ordinal.compareTo(((FieldSet) o).getOrdinal());
}
@Override
public void fromJsonObject(Map<String, Object> properties, String path) {
// TODO Auto-generated method stub
}
public void toMap(Map<String, Object> fieldValues) {
fieldValues.put("commentFieldValue" + this.id, this.commentFieldValue);
this.fields.forEach(item -> item.toMap(fieldValues));
Map<String, Object> multiplicity = new HashMap<String, Object>();
if (this.multiplicityItems != null) {
this.multiplicityItems.forEach(item -> item.toMap(fieldValues, this.multiplicityItems.indexOf(item)));
}
//fieldValues.put(this.id,multiplicity);
}
public void toMap(Map<String, Object> fieldValues, int index) {
this.fields.forEach(item -> item.toMap(fieldValues, index));
//this.multiplicityItems.forEach(item->item.toMap(fieldValues,index));
}
}

View File

@ -0,0 +1,51 @@
package eu.eudat.model.publicapi.datasetwizard;
import eu.eudat.commons.types.descriptiontemplate.PageEntity;
public class Page implements Comparable<Object> {
private String id;
private Integer ordinal;
private String title;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getOrdinal() {
return ordinal;
}
public void setOrdinal(int ordinal) {
this.ordinal = ordinal;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public PageEntity toDatabaseDefinition(PageEntity item) {
item.setId(this.id);
item.setOrdinal(this.ordinal);
item.setTitle(this.title);
return item;
}
public void fromDatabaseDefinition(PageEntity item) {
this.title = item.getTitle();
this.ordinal = item.getOrdinal();
this.id = item.getId();
}
@Override
public int compareTo(Object o) {
return this.ordinal.compareTo((Integer) o);
}
}

View File

@ -0,0 +1,60 @@
package eu.eudat.model.publicapi.datasetwizard;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class PagedDatasetProfile {
private List<DatasetProfilePage> pages;
private List<Rule> rules;
private int status;
public List<DatasetProfilePage> getPages() {
return pages;
}
public void setPages(List<DatasetProfilePage> pages) {
this.pages = pages;
}
public List<Rule> getRules() {
return rules;
}
public void setRules(List<Rule> rules) {
this.rules = rules;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public PagedDatasetProfile buildPagedDatasetProfile(DatasetProfile profile) {
this.status = profile.getStatus();
this.rules = profile.getRules();
this.pages = new LinkedList<>();
List<Page> pages = profile.getPages();
for (Page page : pages) {
DatasetProfilePage datasetProfilePage = new DatasetProfilePage();
datasetProfilePage.setOrdinal(page.getOrdinal());
datasetProfilePage.setTitle(page.getTitle());
datasetProfilePage.setSections(profile.getSections().stream().filter(item -> item.getPage().equals(page.getId())).collect(Collectors.toList()));
this.pages.add(datasetProfilePage);
}
return this;
}
public void toMap(Map<String, Object> fieldValues) {
this.pages.forEach(item -> item.getSections().forEach(sectionItem -> sectionItem.toMap(fieldValues)));
}
public void toMap(Map<String, Object> fieldValues, int index) {
}
}

View File

@ -0,0 +1,9 @@
package eu.eudat.model.publicapi.datasetwizard;
import java.util.Map;
public interface PropertiesModelBuilder {
void fromJsonObject(Map<String, Object> properties);
void fromJsonObject(Map<String, Object> properties, String pathKey);
}

View File

@ -1,13 +1,11 @@
package eu.eudat.publicapi.models.datasetwizard; package eu.eudat.model.publicapi.datasetwizard;
import eu.eudat.data.old.Registry; import eu.eudat.data.old.Registry;
import eu.eudat.logic.utilities.helpers.LabelGenerator;
import eu.eudat.models.DataModel;
import java.util.Date; import java.util.Date;
import java.util.UUID; import java.util.UUID;
public class RegistryPublicModel implements DataModel<Registry,RegistryPublicModel>, LabelGenerator { public class RegistryPublicModel {
private UUID id; private UUID id;
private String label; private String label;
private String abbreviation; private String abbreviation;
@ -33,7 +31,7 @@ public class RegistryPublicModel implements DataModel<Registry,RegistryPublicMod
public String getAbbreviation() { public String getAbbreviation() {
return abbreviation; return abbreviation;
} }
@Override
public String generateLabel() { public String generateLabel() {
return getLabel(); return getLabel();
} }
@ -105,7 +103,6 @@ public class RegistryPublicModel implements DataModel<Registry,RegistryPublicMod
return entity; return entity;
} }
@Override
public String getHint() { public String getHint() {
return null; return null;
} }

View File

@ -0,0 +1,49 @@
package eu.eudat.model.publicapi.datasetwizard;
import eu.eudat.commons.types.descriptiontemplate.RuleEntity;
public class Rule {
private String sourceField;
private String targetField;
private String requiredValue;
private String type;
public String getSourceField() {
return sourceField;
}
public void setSourceField(String sourceField) {
this.sourceField = sourceField;
}
public String getTargetField() {
return targetField;
}
public void setTargetField(String targetField) {
this.targetField = targetField;
}
public String getRequiredValue() {
return requiredValue;
}
public void setRequiredValue(String requiredValue) {
this.requiredValue = requiredValue;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Rule fromDefinitionRule(RuleEntity rule) {
this.targetField = rule.getTarget();
this.requiredValue = rule.getValue();
return this;
}
}

View File

@ -0,0 +1,157 @@
package eu.eudat.model.publicapi.datasetwizard;
import eu.eudat.commons.types.descriptiontemplate.SectionEntity;
import java.util.Collections;
import java.util.List;
import java.util.Map;
public class Section implements Comparable<Object>, PropertiesModelBuilder {
private List<Section> sections;
private List<FieldSet> compositeFields;
private Boolean defaultVisibility;
private String numbering;
private String page;
private Integer ordinal;
private String id;
private String title;
private String description;
private Boolean multiplicity;
public List<Section> getSections() {
Collections.sort(sections);
return sections;
}
public void setSections(List<Section> sections) {
this.sections = sections;
}
public List<FieldSet> getCompositeFields() {
Collections.sort(compositeFields);
return compositeFields;
}
public void setCompositeFields(List<FieldSet> compositeFields) {
this.compositeFields = compositeFields;
}
public Boolean getDefaultVisibility() {
return defaultVisibility;
}
public void setDefaultVisibility(Boolean defaultVisibility) {
this.defaultVisibility = defaultVisibility;
}
public String getPage() {
return page;
}
public void setPage(String page) {
this.page = page;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public int getOrdinal() {
return ordinal;
}
public void setOrdinal(int ordinal) {
this.ordinal = ordinal;
}
public String getNumbering() {
return numbering;
}
public void setNumbering(String numbering) {
this.numbering = numbering;
}
public Boolean getMultiplicity() {
return multiplicity;
}
public void setMultiplicity(Boolean multiplicity) {
this.multiplicity = multiplicity;
}
public SectionEntity toDatabaseDefinition(SectionEntity item) {
// item.setDefaultVisibility(this.defaultVisibility);
// item.setDescription(this.description);
// if (this.compositeFields != null)
// item.setFieldSets(new ModelBuilder().toViewStyleDefinition(this.compositeFields, FieldSetEntity.class));
// item.setId(this.id);
// item.setOrdinal(this.ordinal);
// item.setPage(this.page);
// if (this.sections != null)
// item.setSections(new ModelBuilder().toViewStyleDefinition(this.sections, SectionEntity.class));
// item.setTitle(this.title);
// item.setMultiplicity(this.multiplicity);
// return item;
return null;
}
public void fromDatabaseDefinition(SectionEntity item) {
// this.defaultVisibility = item.isDefaultVisibility();
// this.description = item.getDescription();
// this.compositeFields = new ModelBuilder().fromViewStyleDefinition(item.getFieldSets(), FieldSet.class);
// this.id = item.getId();
// this.ordinal = item.getOrdinal();
// this.numbering = item.getNumbering();
// this.page = item.getPage();
// this.sections = new ModelBuilder().fromViewStyleDefinition(item.getSections(), Section.class);
// this.title = item.getTitle();
// this.multiplicity = item.getMultiplicity();
}
@Override
public void fromJsonObject(Map<String, Object> properties) {
this.sections.forEach(item -> item.fromJsonObject(properties));
this.compositeFields.forEach(item -> item.fromJsonObject(properties));
}
@Override
public int compareTo(Object o) {
return this.ordinal.compareTo(((Section) o).getOrdinal());
}
@Override
public void fromJsonObject(Map<String, Object> properties, String index) {
// TODO Auto-generated method stub
}
public void toMap(Map<String, Object> fieldValues) {
this.sections.forEach(item -> item.toMap(fieldValues));
this.compositeFields.forEach(item -> item.toMap(fieldValues));
}
public void toMap(Map<String, Object> fieldValues, int index) {
}
}

View File

@ -1,13 +1,11 @@
package eu.eudat.publicapi.models.datasetwizard; package eu.eudat.model.publicapi.datasetwizard;
import eu.eudat.data.old.Service; import eu.eudat.data.old.Service;
import eu.eudat.logic.utilities.helpers.LabelGenerator;
import eu.eudat.models.DataModel;
import java.util.Date; import java.util.Date;
import java.util.UUID; import java.util.UUID;
public class ServicePublicModel implements DataModel<Service, ServicePublicModel>, LabelGenerator { public class ServicePublicModel {
private UUID id; private UUID id;
private String label; private String label;
private String abbreviation; private String abbreviation;
@ -101,12 +99,10 @@ public class ServicePublicModel implements DataModel<Service, ServicePublicModel
return entity; return entity;
} }
@Override
public String generateLabel() { public String generateLabel() {
return this.label; return this.label;
} }
@Override
public String getHint() { public String getHint() {
return null; return null;
} }

View File

@ -1,12 +1,10 @@
package eu.eudat.publicapi.models.doi; package eu.eudat.model.publicapi.doi;
import eu.eudat.data.EntityDoiEntity; import eu.eudat.data.EntityDoiEntity;
import eu.eudat.logic.utilities.helpers.LabelGenerator;
import eu.eudat.models.DataModel;
import java.util.UUID; import java.util.UUID;
public class DoiPublicModel implements LabelGenerator { public class DoiPublicModel {
private UUID id; private UUID id;
private String repositoryId; private String repositoryId;
private String doi; private String doi;
@ -47,7 +45,6 @@ public class DoiPublicModel implements LabelGenerator {
return entity; return entity;
} }
@Override
public String generateLabel() { public String generateLabel() {
return this.getDoi(); return this.getDoi();
} }

View File

@ -1,11 +1,10 @@
package eu.eudat.publicapi.models.funder; package eu.eudat.model.publicapi.funder;
import eu.eudat.data.old.Funder; import eu.eudat.data.old.Funder;
import eu.eudat.models.DataModel;
import java.util.UUID; import java.util.UUID;
public class FunderPublicOverviewModel implements DataModel<Funder, FunderPublicOverviewModel> { public class FunderPublicOverviewModel {
private UUID id; private UUID id;
private String label; private String label;
@ -23,19 +22,16 @@ public class FunderPublicOverviewModel implements DataModel<Funder, FunderPublic
this.label = label; this.label = label;
} }
@Override
public FunderPublicOverviewModel fromDataModel(Funder entity) { public FunderPublicOverviewModel fromDataModel(Funder entity) {
this.id = entity.getId(); this.id = entity.getId();
this.label = entity.getLabel(); this.label = entity.getLabel();
return this; return this;
} }
@Override
public Funder toDataModel() throws Exception { public Funder toDataModel() throws Exception {
return null; return null;
} }
@Override
public String getHint() { public String getHint() {
return null; return null;
} }

View File

@ -1,13 +1,12 @@
package eu.eudat.publicapi.models.grant; package eu.eudat.model.publicapi.grant;
import eu.eudat.data.old.Grant; import eu.eudat.data.old.Grant;
import eu.eudat.models.DataModel; import eu.eudat.model.publicapi.funder.FunderPublicOverviewModel;
import eu.eudat.publicapi.models.funder.FunderPublicOverviewModel;
import java.util.Date; import java.util.Date;
import java.util.UUID; import java.util.UUID;
public class GrantPublicOverviewModel implements DataModel<Grant, GrantPublicOverviewModel> { public class GrantPublicOverviewModel {
private UUID id; private UUID id;
private String label; private String label;
private String abbreviation; private String abbreviation;
@ -73,7 +72,6 @@ public class GrantPublicOverviewModel implements DataModel<Grant, GrantPublicOve
this.funder = funder; this.funder = funder;
} }
@Override
public GrantPublicOverviewModel fromDataModel(Grant entity) { public GrantPublicOverviewModel fromDataModel(Grant entity) {
this.id = entity.getId(); this.id = entity.getId();
this.label = entity.getLabel(); this.label = entity.getLabel();
@ -88,12 +86,10 @@ public class GrantPublicOverviewModel implements DataModel<Grant, GrantPublicOve
return this; return this;
} }
@Override
public Grant toDataModel() throws Exception { public Grant toDataModel() throws Exception {
return null; return null;
} }
@Override
public String getHint() { public String getHint() {
return null; return null;
} }

View File

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

View File

@ -0,0 +1,129 @@
package eu.eudat.model.publicapi.listingmodels;
import eu.eudat.data.DescriptionEntity;
import eu.eudat.model.publicapi.datasetprofile.DatasetProfilePublicModel;
import eu.eudat.model.publicapi.user.UserInfoPublicModel;
import java.util.Date;
import java.util.List;
public class DatasetPublicListingModel {
private String id;
private String label;
private String grant;
private String dmp;
private String dmpId;
private DatasetProfilePublicModel profile;
private Date createdAt;
private Date modifiedAt;
private String description;
private Date finalizedAt;
private Date dmpPublishedAt;
private int version;
private List<UserInfoPublicModel> users;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getGrant() {
return grant;
}
public void setGrant(String grant) {
this.grant = grant;
}
public String getDmp() {
return dmp;
}
public void setDmp(String dmp) {
this.dmp = dmp;
}
public String getDmpId() {
return dmpId;
}
public void setDmpId(String dmpId) {
this.dmpId = dmpId;
}
public DatasetProfilePublicModel getProfile() {
return profile;
}
public void setProfile(DatasetProfilePublicModel profile) {
this.profile = profile;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getModifiedAt() {
return modifiedAt;
}
public void setModifiedAt(Date modifiedAt) {
this.modifiedAt = modifiedAt;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Date getFinalizedAt() {
return finalizedAt;
}
public void setFinalizedAt(Date finalizedAt) {
this.finalizedAt = finalizedAt;
}
public Date getDmpPublishedAt() {
return dmpPublishedAt;
}
public void setDmpPublishedAt(Date dmpPublishedAt) {
this.dmpPublishedAt = dmpPublishedAt;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public List<UserInfoPublicModel> getUsers() {
return users;
}
public void setUsers(List<UserInfoPublicModel> users) {
this.users = users;
}
public DatasetPublicListingModel fromDataModel(DescriptionEntity entity) {
return this;
}
public DescriptionEntity toDataModel() {
DescriptionEntity entity = new DescriptionEntity();
return entity;
}
public static String getHint() {
return "datasetListingModel";
}
}

View File

@ -1,14 +1,12 @@
package eu.eudat.publicapi.models.organisation; package eu.eudat.model.publicapi.organisation;
import eu.eudat.data.old.Organisation; import eu.eudat.data.old.Organisation;
import eu.eudat.logic.utilities.helpers.LabelGenerator;
import eu.eudat.models.DataModel;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.UUID; import java.util.UUID;
public class OrganizationPublicModel implements DataModel<Organisation, OrganizationPublicModel>, LabelGenerator { public class OrganizationPublicModel {
private String label; private String label;
private String name; private String name;
private String id; private String id;
@ -66,7 +64,6 @@ public class OrganizationPublicModel implements DataModel<Organisation, Organiza
this.key = key; this.key = key;
} }
@Override
public OrganizationPublicModel fromDataModel(Organisation entity) { public OrganizationPublicModel fromDataModel(Organisation entity) {
this.id = entity.getId().toString(); this.id = entity.getId().toString();
this.name = entity.getLabel(); this.name = entity.getLabel();
@ -78,7 +75,6 @@ public class OrganizationPublicModel implements DataModel<Organisation, Organiza
return this; return this;
} }
@Override
public Organisation toDataModel() { public Organisation toDataModel() {
Organisation organisationEntity = new Organisation(); Organisation organisationEntity = new Organisation();
if (this.key != null && this.reference != null) { if (this.key != null && this.reference != null) {
@ -112,12 +108,10 @@ public class OrganizationPublicModel implements DataModel<Organisation, Organiza
return model; return model;
} }
@Override
public String generateLabel() { public String generateLabel() {
return this.getName(); return this.getName();
} }
@Override
public String getHint() { public String getHint() {
return null; return null;
} }

View File

@ -0,0 +1,161 @@
package eu.eudat.model.publicapi.overviewmodels;
import eu.eudat.data.DmpEntity;
import eu.eudat.model.publicapi.associatedprofile.AssociatedProfilePublicModel;
import eu.eudat.model.publicapi.doi.DoiPublicModel;
import eu.eudat.model.publicapi.grant.GrantPublicOverviewModel;
import eu.eudat.model.publicapi.organisation.OrganizationPublicModel;
import eu.eudat.model.publicapi.researcher.ResearcherPublicModel;
import eu.eudat.model.publicapi.user.UserInfoPublicModel;
import java.util.Date;
import java.util.List;
import java.util.UUID;
public class DataManagementPlanPublicModel {
private String id;
private String label;
private String profile;
private GrantPublicOverviewModel grant;
private Date createdAt;
private Date modifiedAt;
private Date finalizedAt;
private List<OrganizationPublicModel> organisations;
private int version;
private UUID groupId;
private List<DatasetPublicModel> datasets;
private List<AssociatedProfilePublicModel> associatedProfiles;
private List<ResearcherPublicModel> researchers;
private List<UserInfoPublicModel> users;
private String description;
private Date publishedAt;
private List<DoiPublicModel> dois;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getProfile() {
return profile;
}
public void setProfile(String profile) {
this.profile = profile;
}
public GrantPublicOverviewModel getGrant() {
return grant;
}
public void setGrant(GrantPublicOverviewModel grant) {
this.grant = grant;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getModifiedAt() {
return modifiedAt;
}
public void setModifiedAt(Date modifiedAt) {
this.modifiedAt = modifiedAt;
}
public Date getFinalizedAt() {
return finalizedAt;
}
public void setFinalizedAt(Date finalizedAt) {
this.finalizedAt = finalizedAt;
}
public List<OrganizationPublicModel> getOrganisations() {
return organisations;
}
public void setOrganisations(List<OrganizationPublicModel> organizations) {
this.organisations = organizations;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public UUID getGroupId() {
return groupId;
}
public void setGroupId(UUID groupId) {
this.groupId = groupId;
}
public List<DatasetPublicModel> getDatasets() {
return datasets;
}
public void setDatasets(List<DatasetPublicModel> datasets) {
this.datasets = datasets;
}
public List<AssociatedProfilePublicModel> getAssociatedProfiles() {
return associatedProfiles;
}
public void setAssociatedProfiles(List<AssociatedProfilePublicModel> associatedProfiles) {
this.associatedProfiles = associatedProfiles;
}
public List<UserInfoPublicModel> getUsers() {
return users;
}
public void setUsers(List<UserInfoPublicModel> users) {
this.users = users;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<ResearcherPublicModel> getResearchers() {
return researchers;
}
public void setResearchers(List<ResearcherPublicModel> researchers) {
this.researchers = researchers;
}
public Date getPublishedAt() {
return publishedAt;
}
public void setPublishedAt(Date publishedAt) {
this.publishedAt = publishedAt;
}
public List<DoiPublicModel> getDois() {
return dois;
}
public void setDois(List<DoiPublicModel> dois) {
this.dois = dois;
}
public DmpEntity toDataModel() {
return null;
}
public String getHint() {
return "dataManagementPlanOverviewModel";
}
}

View File

@ -1,19 +1,14 @@
package eu.eudat.publicapi.models.overviewmodels; package eu.eudat.model.publicapi.overviewmodels;
import eu.eudat.commons.enums.DescriptionStatus; import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.model.publicapi.datasetprofile.DatasetProfilePublicModel;
import eu.eudat.model.publicapi.datasetwizard.*;
import eu.eudat.model.publicapi.listingmodels.DataManagementPlanPublicListingModel;
import eu.eudat.data.DescriptionEntity; import eu.eudat.data.DescriptionEntity;
import eu.eudat.models.DataModel;
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import eu.eudat.publicapi.models.datasetprofile.DatasetProfilePublicModel;
import eu.eudat.publicapi.models.datasetwizard.DataRepositoryPublicModel;
import eu.eudat.publicapi.models.datasetwizard.ExternalDatasetPublicListingModel;
import eu.eudat.publicapi.models.datasetwizard.RegistryPublicModel;
import eu.eudat.publicapi.models.datasetwizard.ServicePublicModel;
import eu.eudat.publicapi.models.listingmodels.DataManagementPlanPublicListingModel;
import java.util.*; import java.util.*;
public class DatasetPublicModel implements DataModel<DescriptionEntity, DatasetPublicModel> { public class DatasetPublicModel {
private UUID id; private UUID id;
private String label; private String label;
private String reference; private String reference;
@ -143,7 +138,6 @@ public class DatasetPublicModel implements DataModel<DescriptionEntity, DatasetP
this.modifiedAt = modifiedAt; this.modifiedAt = modifiedAt;
} }
@Override
public DatasetPublicModel fromDataModel(DescriptionEntity entity) { public DatasetPublicModel fromDataModel(DescriptionEntity entity) {
//TODO: //TODO:
// this.id = entity.getId(); // this.id = entity.getId();
@ -217,7 +211,6 @@ public class DatasetPublicModel implements DataModel<DescriptionEntity, DatasetP
return this; return this;
} }
@Override
public DescriptionEntity toDataModel() throws Exception { public DescriptionEntity toDataModel() throws Exception {
//TODO: //TODO:
DescriptionEntity entity = new DescriptionEntity(); DescriptionEntity entity = new DescriptionEntity();
@ -285,9 +278,7 @@ public class DatasetPublicModel implements DataModel<DescriptionEntity, DatasetP
// } // }
return entity; return entity;
} }
@Override
public String getHint() { public String getHint() {
return "datasetOverviewModel"; return "datasetOverviewModel";
} }

View File

@ -0,0 +1,90 @@
package eu.eudat.model.publicapi.researcher;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import eu.eudat.commons.enums.ReferenceType;
import eu.eudat.data.old.Researcher;
import eu.eudat.model.DmpReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.UUID;
@JsonIgnoreProperties(ignoreUnknown = true)
public class ResearcherPublicModel {
private static final Logger logger = LoggerFactory.getLogger(ResearcherPublicModel.class);
private String label;
private String name;
private String id;
private String reference;
private int status;
private String tag;
private String key;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public static ResearcherPublicModel fromDmpReference(DmpReference dmpReference) {
if (dmpReference.getReference().getType() != ReferenceType.Researcher)
return null;
ResearcherPublicModel model = new ResearcherPublicModel();
model.setId(dmpReference.getReference().getId().toString());
model.setReference(dmpReference.getReference().getReference());
model.setLabel(dmpReference.getReference().getLabel());
model.setName(dmpReference.getReference().getLabel());
String[] refParts = dmpReference.getReference().getReference().split(":");
String source = refParts[0];
if (source.equals("dmp"))
model.setKey("Internal");
else
model.setKey(source);
return model;
}
}

View File

@ -0,0 +1,44 @@
package eu.eudat.model.publicapi.user;
import eu.eudat.model.DmpUser;
import java.util.UUID;
public class UserInfoPublicModel {
private UUID id;
private String name;
private int role;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getRole() {
return role;
}
public void setRole(int role) {
this.role = role;
}
public static UserInfoPublicModel fromDmpUser(DmpUser dmpUser) {
UserInfoPublicModel model = new UserInfoPublicModel();
model.setId(dmpUser.getUser().getId());
model.setName(dmpUser.getUser().getName());
model.setRole(dmpUser.getRole().getValue());
return model;
}
public String getHint() {
return "UserInfoListingModel";
}
}

View File

@ -0,0 +1,182 @@
package eu.eudat.query;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.LanguageEntity;
import eu.eudat.model.Language;
import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.data.query.QueryBase;
import gr.cite.tools.data.query.QueryContext;
import jakarta.persistence.Tuple;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.Predicate;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.time.Instant;
import java.util.*;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class LanguageQuery extends QueryBase<LanguageEntity> {
private String like;
private Collection<UUID> ids;
private Collection<IsActive> isActives;
private Collection<String> codes;
private Collection<UUID> excludedIds;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
public LanguageQuery like(String value) {
this.like = value;
return this;
}
public LanguageQuery ids(UUID value) {
this.ids = List.of(value);
return this;
}
public LanguageQuery ids(UUID... value) {
this.ids = Arrays.asList(value);
return this;
}
public LanguageQuery ids(Collection<UUID> values) {
this.ids = values;
return this;
}
public LanguageQuery isActive(IsActive value) {
this.isActives = List.of(value);
return this;
}
public LanguageQuery isActive(IsActive... value) {
this.isActives = Arrays.asList(value);
return this;
}
public LanguageQuery isActive(Collection<IsActive> values) {
this.isActives = values;
return this;
}
public LanguageQuery codes(String value) {
this.codes = List.of(value);
return this;
}
public LanguageQuery codes(String... value) {
this.codes = Arrays.asList(value);
return this;
}
public LanguageQuery codes(Collection<String> values) {
this.codes = values;
return this;
}
public LanguageQuery excludedIds(Collection<UUID> values) {
this.excludedIds = values;
return this;
}
public LanguageQuery excludedIds(UUID value) {
this.excludedIds = List.of(value);
return this;
}
public LanguageQuery excludedIds(UUID... value) {
this.excludedIds = Arrays.asList(value);
return this;
}
public LanguageQuery authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
public LanguageQuery(
) {
}
@Override
protected Class<LanguageEntity> entityClass() {
return LanguageEntity.class;
}
@Override
protected Boolean isFalseQuery() {
return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.excludedIds) || this.isEmpty(this.codes);
}
@Override
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
List<Predicate> predicates = new ArrayList<>();
if (this.ids != null) {
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(LanguageEntity._id));
for (UUID item : this.ids)
inClause.value(item);
predicates.add(inClause);
}
if (this.like != null && !this.like.isEmpty()) {
predicates.add(queryContext.CriteriaBuilder.like(queryContext.Root.get(LanguageEntity._code), this.like));
}
if (this.isActives != null) {
CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(LanguageEntity._isActive));
for (IsActive item : this.isActives)
inClause.value(item);
predicates.add(inClause);
}
if (this.codes != null) {
CriteriaBuilder.In<String> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(LanguageEntity._code));
for (String item : this.codes)
inClause.value(item);
predicates.add(inClause);
}
if (this.excludedIds != null) {
CriteriaBuilder.In<UUID> notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(LanguageEntity._id));
for (UUID item : this.excludedIds)
notInClause.value(item);
predicates.add(notInClause.not());
}
if (!predicates.isEmpty()) {
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
return queryContext.CriteriaBuilder.and(predicatesArray);
} else {
return null;
}
}
@Override
protected LanguageEntity convert(Tuple tuple, Set<String> columns) {
LanguageEntity item = new LanguageEntity();
item.setId(QueryBase.convertSafe(tuple, columns, LanguageEntity._id, UUID.class));
item.setCode(QueryBase.convertSafe(tuple, columns, LanguageEntity._code, String.class));
item.setPayload(QueryBase.convertSafe(tuple, columns, LanguageEntity._payload, String.class));
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, LanguageEntity._createdAt, Instant.class));
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, LanguageEntity._updatedAt, Instant.class));
item.setIsActive(QueryBase.convertSafe(tuple, columns, LanguageEntity._isActive, IsActive.class));
return item;
}
@Override
protected String fieldNameOf(FieldResolver item) {
if (item.match(Language._id)) return LanguageEntity._id;
else if (item.match(Language._code)) return LanguageEntity._code;
else if (item.match(Language._payload)) return LanguageEntity._payload;
else if (item.match(Language._createdAt)) return LanguageEntity._createdAt;
else if (item.match(Language._updatedAt)) return LanguageEntity._updatedAt;
else if (item.match(Language._hash)) return LanguageEntity._updatedAt;
else if (item.match(Language._isActive)) return LanguageEntity._isActive;
else return null;
}
}

View File

@ -0,0 +1,206 @@
package eu.eudat.query;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission;
import eu.eudat.commons.enums.StorageType;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.StorageFileEntity;
import eu.eudat.model.StorageFile;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.data.query.QueryBase;
import gr.cite.tools.data.query.QueryContext;
import jakarta.persistence.Tuple;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.Predicate;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.time.Instant;
import java.util.*;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class StorageFileQuery extends QueryBase<StorageFileEntity> {
private String like;
private Collection<UUID> ids;
private Boolean canPurge;
private Boolean isPurged;
private Instant createdAfter;
private Collection<UUID> excludedIds;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
private final UserScope userScope;
private final AuthorizationService authService;
public StorageFileQuery(UserScope userScope, AuthorizationService authService) {
this.userScope = userScope;
this.authService = authService;
}
public StorageFileQuery like(String value) {
this.like = value;
return this;
}
public StorageFileQuery ids(UUID value) {
this.ids = List.of(value);
return this;
}
public StorageFileQuery ids(UUID... value) {
this.ids = Arrays.asList(value);
return this;
}
public StorageFileQuery ids(Collection<UUID> values) {
this.ids = values;
return this;
}
public StorageFileQuery createdAfter(Instant value) {
this.createdAfter = value;
return this;
}
public StorageFileQuery canPurge(Boolean value) {
this.canPurge = value;
return this;
}
public StorageFileQuery isPurged(Boolean value) {
this.isPurged = value;
return this;
}
public StorageFileQuery excludedIds(Collection<UUID> values) {
this.excludedIds = values;
return this;
}
public StorageFileQuery excludedIds(UUID value) {
this.excludedIds = List.of(value);
return this;
}
public StorageFileQuery excludedIds(UUID... value) {
this.excludedIds = Arrays.asList(value);
return this;
}
public StorageFileQuery authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
protected Boolean isFalseQuery() {
return
this.isEmpty(this.ids) ||
this.isEmpty(this.excludedIds) ;
}
@Override
protected Class<StorageFileEntity> entityClass() {
return StorageFileEntity.class;
}
@Override
protected <X, Y> Predicate applyAuthZ(QueryContext<X, Y> queryContext) {
if (this.authorize.contains(AuthorizationFlags.None)) return null;
if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseStorageFile)) return null;
UUID userId;
if (this.authorize.contains(AuthorizationFlags.Owner)) userId = this.userScope.getUserIdSafe();
else userId = null;
List<Predicate> predicates = new ArrayList<>();
if (userId != null) {
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(StorageFileEntity._ownerId)).value(userId));
}
if (!predicates.isEmpty()) {
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
return queryContext.CriteriaBuilder.and(predicatesArray);
} else {
return queryContext.CriteriaBuilder.or(); //Creates a false query
}
}
@Override
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
List<Predicate> predicates = new ArrayList<>();
if (this.like != null && !this.like.isEmpty()) {
predicates.add( queryContext.CriteriaBuilder.like(queryContext.Root.get(StorageFileEntity._name), this.like));
}
if (this.ids != null) {
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(StorageFileEntity._id));
for (UUID item : this.ids)
inClause.value(item);
predicates.add(inClause);
}
if (this.createdAfter != null) {
predicates.add(queryContext.CriteriaBuilder.greaterThan(queryContext.Root.get(StorageFileEntity._createdAt), this.createdAfter));
}
if (this.canPurge != null) {
predicates.add(
queryContext.CriteriaBuilder.and(
queryContext.CriteriaBuilder.isNull(queryContext.Root.get(StorageFileEntity._purgeAt)).not(),
queryContext.CriteriaBuilder.lessThan(queryContext.Root.get(StorageFileEntity._purgeAt), Instant.now())
)
);
}
if (this.isPurged != null) {
if (!this.isPurged){
predicates.add(queryContext.CriteriaBuilder.isNull(queryContext.Root.get(StorageFileEntity._purgedAt)).not());
} else {
predicates.add(queryContext.CriteriaBuilder.isNull(queryContext.Root.get(StorageFileEntity._purgedAt)));
}
}
if (this.excludedIds != null) {
CriteriaBuilder.In<UUID> notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(StorageFileEntity._id));
for (UUID item : this.excludedIds)
notInClause.value(item);
predicates.add(notInClause.not());
}
if (!predicates.isEmpty()) {
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
return queryContext.CriteriaBuilder.and(predicatesArray);
} else {
return null;
}
}
@Override
protected String fieldNameOf(FieldResolver item) {
if (item.match(StorageFile._id)) return StorageFileEntity._id;
else if (item.match(StorageFile._name)) return StorageFileEntity._name;
else if (item.match(StorageFile._fileRef)) return StorageFileEntity._fileRef;
else if (item.match(StorageFile._fullName)) return StorageFileEntity._name;
else if (item.match(StorageFile._extension)) return StorageFileEntity._extension;
else if (item.match(StorageFile._mimeType)) return StorageFileEntity._mimeType;
else if (item.match(StorageFile._storageType)) return StorageFileEntity._storageType;
else if (item.match(StorageFile._createdAt)) return StorageFileEntity._createdAt;
else if (item.match(StorageFile._purgeAt)) return StorageFileEntity._purgeAt;
else if (item.match(StorageFile._purgedAt)) return StorageFileEntity._purgedAt;
else if (item.match(StorageFile._owner)) return StorageFileEntity._ownerId;
else if (item.prefix(StorageFile._owner)) return StorageFileEntity._ownerId;
else return null;
}
@Override
protected StorageFileEntity convert(Tuple tuple, Set<String> columns) {
StorageFileEntity item = new StorageFileEntity();
item.setId(QueryBase.convertSafe(tuple, columns, StorageFileEntity._id, UUID.class));
item.setName(QueryBase.convertSafe(tuple, columns, StorageFileEntity._name, String.class));
item.setFileRef(QueryBase.convertSafe(tuple, columns, StorageFileEntity._fileRef, String.class));
item.setExtension(QueryBase.convertSafe(tuple, columns, StorageFileEntity._extension, String.class));
item.setMimeType(QueryBase.convertSafe(tuple, columns, StorageFileEntity._mimeType, String.class));
item.setStorageType(QueryBase.convertSafe(tuple, columns, StorageFileEntity._storageType, StorageType.class));
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, StorageFileEntity._createdAt, Instant.class));
item.setPurgeAt(QueryBase.convertSafe(tuple, columns, StorageFileEntity._purgeAt, Instant.class));
item.setPurgedAt(QueryBase.convertSafe(tuple, columns, StorageFileEntity._purgedAt, Instant.class));
item.setOwnerId(QueryBase.convertSafe(tuple, columns, StorageFileEntity._ownerId, UUID.class));
return item;
}
}

View File

@ -0,0 +1,76 @@
package eu.eudat.query.lookup;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.query.LanguageQuery;
import gr.cite.tools.data.query.Lookup;
import gr.cite.tools.data.query.QueryFactory;
import java.util.List;
import java.util.UUID;
public class LanguageLookup extends Lookup {
private String like;
private List<IsActive> isActive;
private List<String> codes;
private List<UUID> ids;
private List<UUID> excludedIds;
public String getLike() {
return like;
}
public void setLike(String like) {
this.like = like;
}
public List<IsActive> getIsActive() {
return isActive;
}
public void setIsActive(List<IsActive> isActive) {
this.isActive = isActive;
}
public List<UUID> getIds() {
return ids;
}
public void setIds(List<UUID> ids) {
this.ids = ids;
}
public List<UUID> getExcludedIds() {
return excludedIds;
}
public void setExcludedIds(List<UUID> excludeIds) {
this.excludedIds = excludeIds;
}
public List<String> getCodes() {
return codes;
}
public void setCodes(List<String> codes) {
this.codes = codes;
}
public LanguageQuery enrich(QueryFactory queryFactory) {
LanguageQuery query = queryFactory.query(LanguageQuery.class);
if (this.like != null) query.like(this.like);
if (this.isActive != null) query.isActive(this.isActive);
if (this.codes != null) query.codes(this.codes);
if (this.ids != null) query.ids(this.ids);
if (this.excludedIds != null) query.excludedIds(this.excludedIds);
this.enrichCommon(query);
return query;
}
}

View File

@ -0,0 +1,19 @@
package eu.eudat.service.language;
import eu.eudat.model.Language;
import eu.eudat.model.persist.LanguagePersist;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.exception.MyForbiddenException;
import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.exception.MyValidationException;
import gr.cite.tools.fieldset.FieldSet;
import javax.management.InvalidApplicationException;
import java.util.UUID;
public interface LanguageService {
Language persist(LanguagePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException;
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;
}

View File

@ -0,0 +1,102 @@
package eu.eudat.service.language;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.LanguageEntity;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import eu.eudat.model.Language;
import eu.eudat.model.builder.LanguageBuilder;
import eu.eudat.model.deleter.LanguageDeleter;
import eu.eudat.model.persist.LanguagePersist;
import eu.eudat.service.dmpblueprint.DmpBlueprintServiceImpl;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.exception.MyForbiddenException;
import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.exception.MyValidationException;
import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import org.slf4j.LoggerFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service;
import javax.management.InvalidApplicationException;
import java.time.Instant;
import java.util.List;
import java.util.UUID;
@Service
public class LanguageServiceImpl implements LanguageService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintServiceImpl.class));
private final EntityManager entityManager;
private final AuthorizationService authorizationService;
private final DeleterFactory deleterFactory;
private final BuilderFactory builderFactory;
private final ConventionService conventionService;
private final MessageSource messageSource;
private final ErrorThesaurusProperties errors;
public LanguageServiceImpl(
EntityManager entityManager, AuthorizationService authorizationService, DeleterFactory deleterFactory, BuilderFactory builderFactory,
ConventionService conventionService, MessageSource messageSource, ErrorThesaurusProperties errors){
this.entityManager = entityManager;
this.authorizationService = authorizationService;
this.deleterFactory = deleterFactory;
this.builderFactory = builderFactory;
this.conventionService = conventionService;
this.messageSource = messageSource;
this.errors = errors;
}
public Language persist(LanguagePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException{
logger.debug(new MapLogEntry("persisting data").And("model", model).And("fields", fields));
this.authorizationService.authorizeForce(Permission.EditLanguage);
Boolean isUpdate = this.conventionService.isValidGuid(model.getId());
LanguageEntity data;
if (isUpdate) {
data = this.entityManager.find(LanguageEntity.class, model.getId());
if (data == null)
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Language.class.getSimpleName()}, LocaleContextHolder.getLocale()));
if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage());
} else {
data = new LanguageEntity();
data.setId(UUID.randomUUID());
data.setIsActive(IsActive.Active);
data.setCreatedAt(Instant.now());
}
data.setCode(model.getCode());
data.setPayload(model.getPayload());
data.setUpdatedAt(Instant.now());
if (isUpdate) this.entityManager.merge(data);
else this.entityManager.persist(data);
this.entityManager.flush();
return this.builderFactory.builder(LanguageBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, Language._id), data);
}
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
logger.debug("deleting : {}", id);
this.authorizationService.authorizeForce(Permission.DeleteLanguage);
this.deleterFactory.deleter(LanguageDeleter.class).deleteAndSaveByIds(List.of(id));
}
}

View File

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

View File

@ -0,0 +1,71 @@
package eu.eudat.controllers.publicapi;
import eu.eudat.controllers.BaseController;
import eu.eudat.model.publicapi.listingmodels.DatasetPublicListingModel;
import eu.eudat.controllers.publicapi.response.DataTableData;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.model.publicapi.overviewmodels.DatasetPublicModel;
import eu.eudat.controllers.publicapi.request.dataset.DatasetPublicTableRequest;
import eu.eudat.types.ApiMessageCode;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
@Tag(name = "Datasets Description", description = "Provides Dataset description public API's.")
@RestController
@CrossOrigin
@RequestMapping(value = {"/api/public/datasets/"})
public class PublicDatasetsDescriptionDocumentation extends BaseController {
private static final Logger logger = LoggerFactory.getLogger(PublicDatasetsDescriptionDocumentation.class);
@Autowired
public PublicDatasetsDescriptionDocumentation(ApiContext apiContext) {
super(apiContext);
}
@Operation(summary = "This method is used to get a listing of public datasets.", description = PublicApiStaticHelpers.Description.getPagedNotes)
@io.swagger.v3.oas.annotations.responses.ApiResponses(value = {@io.swagger.v3.oas.annotations.responses.ApiResponse(
responseCode = "200",
description = "The following example is generated using body: *{\"criteria\": {},\"length\": 2,\"offset\": 0,\"orderings\": {\"fields\": []} }*",
content = @Content(mediaType = APPLICATION_JSON_VALUE, examples = {@ExampleObject(
value = PublicApiStaticHelpers.Description.getPagedResponseExample
)})
)})
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public @ResponseBody ResponseEntity<ResponseItem<DataTableData<DatasetPublicListingModel>>> getPaged(
@Valid @RequestBody @io.swagger.v3.oas.annotations.parameters.RequestBody(description = PublicApiStaticHelpers.Description.getPagedRequestBodyDescription) DatasetPublicTableRequest datasetTableRequest
) throws Exception {
// DataTableData<DatasetPublicListingModel> dataTable = this.datasetManager.getPublicPaged(datasetTableRequest); TODO
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetPublicListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(null));
}
@Operation(summary = "This method is used to get the overview of a public dataset.", description = PublicApiStaticHelpers.Description.getOverviewSinglePublicNotes)
@io.swagger.v3.oas.annotations.responses.ApiResponses(value = {@ApiResponse(
responseCode = "200",
description = "The following example is generated using id: *ef7dfbdc-c5c1-46a7-a37b-c8d8692f1c0e*",
content = @Content(mediaType = APPLICATION_JSON_VALUE, examples = {@ExampleObject(
value = PublicApiStaticHelpers.Description.getOverviewSinglePublicResponseExample
)})
)})
@RequestMapping(method = RequestMethod.GET, value = {"/{id}"}, produces = "application/json")
public @ResponseBody ResponseEntity<ResponseItem<DatasetPublicModel>> getOverviewSinglePublic(
@PathVariable @Parameter(description = "fetch the dataset with the given id", example = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") String id
) {
// DatasetPublicModel dataset = this.datasetManager.getOverviewSinglePublic(id); TODO
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetPublicModel>().status(ApiMessageCode.NO_MESSAGE).payload(null));
}
}

View File

@ -0,0 +1,177 @@
package eu.eudat.controllers.publicapi;
import eu.eudat.commons.enums.DmpAccessType;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.controllers.BaseController;
import eu.eudat.controllers.publicapi.request.dmp.DataManagmentPlanPublicTableRequest;
import eu.eudat.controllers.publicapi.response.DataTableData;
import eu.eudat.data.DmpEntity;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.model.*;
import eu.eudat.model.builder.DmpBuilder;
import eu.eudat.model.mapper.publicapi.DmpToPublicApiDmpListingMapper;
import eu.eudat.model.mapper.publicapi.DmpToPublicApiDmpMapper;
import eu.eudat.model.publicapi.listingmodels.DataManagementPlanPublicListingModel;
import eu.eudat.model.publicapi.overviewmodels.DataManagementPlanPublicModel;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.query.DmpQuery;
import eu.eudat.query.lookup.DmpLookup;
import eu.eudat.types.ApiMessageCode;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.fieldset.BaseFieldSet;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
@Tag(name = "DMPs", description = "Provides DMP public API's.")
@RestController
@CrossOrigin
@RequestMapping(value = {"/api/public/dmps"})
public class PublicDmpsDocumentation extends BaseController {
private static final Logger logger = LoggerFactory.getLogger(PublicDmpsDocumentation.class);
private final QueryFactory queryFactory;
private final BuilderFactory builderFactory;
private final MessageSource messageSource;
private final DmpToPublicApiDmpMapper dmpToPublicApiDmpMapper;
private final DmpToPublicApiDmpListingMapper dmpToPublicApiDmpListingMapper;
@Autowired
public PublicDmpsDocumentation(ApiContext apiContext, QueryFactory queryFactory, BuilderFactory builderFactory, MessageSource messageSource, DmpToPublicApiDmpMapper dmpToPublicApiDmpMapper, DmpToPublicApiDmpListingMapper dmpToPublicApiDmpListingMapper) {
super(apiContext);
this.queryFactory = queryFactory;
this.builderFactory = builderFactory;
this.messageSource = messageSource;
this.dmpToPublicApiDmpMapper = dmpToPublicApiDmpMapper;
this.dmpToPublicApiDmpListingMapper = dmpToPublicApiDmpListingMapper;
}
@Operation(summary = "This method is used to get a listing of public dmps.", description = PublicApiStaticHelpers.Dmp.getPagedNotes)
@io.swagger.v3.oas.annotations.responses.ApiResponses(value = {@ApiResponse(
responseCode = "200",
description = """
The following example is generated using:
a) body: *{"criteria": {},"length": 2,"offset": 0,"orderings": {"fields": []} }*
b) fieldsGroup: listing""",
content = @Content(mediaType = APPLICATION_JSON_VALUE, examples = {@ExampleObject(
value = PublicApiStaticHelpers.Dmp.getPagedResponseExample
)})
)})
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public @ResponseBody ResponseEntity<ResponseItem<DataTableData<DataManagementPlanPublicListingModel>>> getPaged(
@Valid @RequestBody @io.swagger.v3.oas.annotations.parameters.RequestBody(description = PublicApiStaticHelpers.Dmp.getPagedRequestBodyDescription) DataManagmentPlanPublicTableRequest dmpTableRequest,
@RequestParam @Parameter(description = PublicApiStaticHelpers.Dmp.getPagedRequestParamDescription, example = "listing") String fieldsGroup
) throws Exception {
DmpLookup lookup = getDmpLookup(fieldsGroup, dmpTableRequest);
DmpQuery query = lookup.enrich(this.queryFactory).accessTypes(DmpAccessType.Public).isActive(IsActive.Active);
long count = this.queryFactory.query(DmpQuery.class).accessTypes(DmpAccessType.Public).isActive(IsActive.Active).count();
List<DmpEntity> data = query.collectAs(lookup.getProject());
List<Dmp> models = this.builderFactory.builder(DmpBuilder.class).build(lookup.getProject(), data);
DataTableData<DataManagementPlanPublicListingModel> dataTableData = new DataTableData<>();
dataTableData.setData(models.stream().map(this.dmpToPublicApiDmpListingMapper::toPublicListingModel).toList());
dataTableData.setTotalCount(count);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanPublicListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTableData));
}
@NotNull
private static DmpLookup getDmpLookup(String fieldsGroup, DataManagmentPlanPublicTableRequest request) {
BaseFieldSet fieldSet = new BaseFieldSet();
Set<String> fields;
if (fieldsGroup.equals("listing")) {
fields = Set.of(
Dmp._id,
Dmp._label,
Dmp._description,
Dmp._version,
Dmp._groupId,
String.join(".", Dmp._dmpUsers, String.join(".", DmpUser._user, User._id)),
String.join(".", Dmp._dmpUsers, String.join(".", DmpUser._user, User._name)),
String.join(".", Dmp._dmpUsers, DmpUser._role),
String.join(".", Dmp._dmpReferences, String.join(".", DmpReference._reference, Reference._id)),
String.join(".", Dmp._dmpReferences, String.join(".", DmpReference._reference, Reference._reference)),
String.join(".", Dmp._dmpReferences, String.join(".", DmpReference._reference, Reference._label)),
Dmp._dmpReferences,
Dmp._createdAt,
Dmp._updatedAt,
Dmp._finalizedAt
);
} else {
fields = Set.of(
Dmp._id,
Dmp._label,
Dmp._groupId,
Dmp._createdAt
);
}
fieldSet.setFields(fields);
DmpLookup lookup = new DmpLookup();
lookup.setProject(fieldSet);
return lookup;
}
@Operation(summary = "This method is used to get the overview of a public dmp.", description = PublicApiStaticHelpers.Dmp.getOverviewSinglePublicNotes)
@io.swagger.v3.oas.annotations.responses.ApiResponses(value = {@ApiResponse(
responseCode = "200",
description = "The following example is generated using id: *e9a73d77-adfa-4546-974f-4a4a623b53a8*",
content = @Content(mediaType = APPLICATION_JSON_VALUE, examples = {@ExampleObject(
value = PublicApiStaticHelpers.Dmp.getOverviewSinglePublicResponseExample
)})
)})
@RequestMapping(method = RequestMethod.GET, value = {"/{id}"}, produces = "application/json")
public @ResponseBody ResponseEntity<ResponseItem<DataManagementPlanPublicModel>> getOverviewSinglePublic(
@PathVariable @Parameter(description = "fetch the dmp with the given id", example = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") String id
) {
BaseFieldSet fieldSet = new BaseFieldSet();
Set<String> fields = Set.of(
Dmp._id,
Dmp._label,
Dmp._description,
Dmp._version,
Dmp._groupId,
String.join(".", Dmp._dmpUsers, String.join(".", DmpUser._user, User._id)),
String.join(".", Dmp._dmpUsers, String.join(".", DmpUser._user, User._name)),
String.join(".", Dmp._dmpUsers, DmpUser._role),
String.join(".", Dmp._dmpReferences, String.join(".", DmpReference._reference, Reference._id)),
String.join(".", Dmp._dmpReferences, String.join(".", DmpReference._reference, Reference._reference)),
String.join(".", Dmp._dmpReferences, String.join(".", DmpReference._reference, Reference._label)),
Dmp._createdAt,
Dmp._updatedAt,
Dmp._finalizedAt
);
fieldSet.setFields(fields);
DmpQuery query = this.queryFactory.query(DmpQuery.class).ids(UUID.fromString(id)).accessTypes(DmpAccessType.Public).isActive(IsActive.Active);
Dmp model = this.builderFactory.builder(DmpBuilder.class).build(fieldSet, query.firstAs(fieldSet));
if (model == null)
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
DataManagementPlanPublicModel dataManagementPlan = this.dmpToPublicApiDmpMapper.toPublicModel(model);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanPublicModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,151 @@
package eu.eudat.controllers.v2;
import com.fasterxml.jackson.core.JsonProcessingException;
import eu.eudat.audit.AuditableAction;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.data.LanguageEntity;
import eu.eudat.model.Language;
import eu.eudat.model.builder.LanguageBuilder;
import eu.eudat.model.censorship.LanguageCensor;
import eu.eudat.model.persist.LanguagePersist;
import eu.eudat.model.result.QueryResult;
import eu.eudat.query.LanguageQuery;
import eu.eudat.query.lookup.LanguageLookup;
import eu.eudat.service.language.LanguageService;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.auditing.AuditService;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.exception.MyForbiddenException;
import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry;
import gr.cite.tools.validation.MyValidate;
import jakarta.transaction.Transactional;
import jakarta.xml.bind.JAXBException;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.bind.annotation.*;
import javax.management.InvalidApplicationException;
import java.util.AbstractMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@RestController
@RequestMapping(path = {"api/v2/language"})
public class LanguageV2Controller {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(LanguageV2Controller.class));
private final BuilderFactory builderFactory;
private final AuditService auditService;
private final CensorFactory censorFactory;
private final QueryFactory queryFactory;
private final MessageSource messageSource;
private final AuthorizationService authorizationService;
private final LanguageService languageService;
@Autowired
public LanguageV2Controller(
BuilderFactory builderFactory,
AuditService auditService,
CensorFactory censorFactory,
QueryFactory queryFactory,
MessageSource messageSource, AuthorizationService authorizationService,
LanguageService languageService) {
this.builderFactory = builderFactory;
this.auditService = auditService;
this.censorFactory = censorFactory;
this.queryFactory = queryFactory;
this.messageSource = messageSource;
this.authorizationService = authorizationService;
this.languageService = languageService;
}
@PostMapping("query")
public QueryResult<Language> query(@RequestBody LanguageLookup lookup) throws MyApplicationException, MyForbiddenException {
logger.debug("querying {}", Language.class.getSimpleName());
this.censorFactory.censor(LanguageCensor.class).censor(lookup.getProject(), null);
LanguageQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic);
List<LanguageEntity> data = query.collectAs(lookup.getProject());
List<Language> models = this.builderFactory.builder(LanguageBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data);
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
this.auditService.track(AuditableAction.Language_Query, "lookup", lookup);
return new QueryResult(models, count);
}
@GetMapping("{id}")
public Language get(@PathVariable("id") UUID id, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException {
logger.debug(new MapLogEntry("retrieving" + Language.class.getSimpleName()).And("id", id).And("fields", fieldSet));
this.censorFactory.censor(LanguageCensor.class).censor(fieldSet, null);
LanguageQuery query = this.queryFactory.query(LanguageQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(id);
Language model = this.builderFactory.builder(LanguageBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, query.firstAs(fieldSet));
if (model == null)
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Language.class.getSimpleName()}, LocaleContextHolder.getLocale()));
this.auditService.track(AuditableAction.Language_Lookup, Map.ofEntries(
new AbstractMap.SimpleEntry<String, Object>("id", id),
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
));
return model;
}
@GetMapping("code/{code}")
public Language get(@PathVariable("code") String code, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException {
logger.debug(new MapLogEntry("retrieving" + Language.class.getSimpleName()).And("code", code).And("fields", fieldSet));
this.censorFactory.censor(LanguageCensor.class).censor(fieldSet, null);
LanguageQuery query = this.queryFactory.query(LanguageQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).codes(code);
Language model = this.builderFactory.builder(LanguageBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, query.firstAs(fieldSet));
if (model == null)
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{code, Language.class.getSimpleName()}, LocaleContextHolder.getLocale()));
this.auditService.track(AuditableAction.Language_Lookup, Map.ofEntries(
new AbstractMap.SimpleEntry<String, Object>("code", code),
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
));
return model;
}
@PostMapping("persist")
@Transactional
public Language persist(@MyValidate @RequestBody LanguagePersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, JsonProcessingException, InvalidApplicationException {
logger.debug(new MapLogEntry("persisting" + Language.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
this.censorFactory.censor(LanguageCensor.class).censor(fieldSet, null);
Language persisted = this.languageService.persist(model, fieldSet);
this.auditService.track(AuditableAction.Language_Persist, Map.ofEntries(
new AbstractMap.SimpleEntry<String, Object>("model", model),
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
));
return persisted;
}
@DeleteMapping("{id}")
@Transactional
public void delete(@PathVariable("id") UUID id) throws MyForbiddenException, InvalidApplicationException {
logger.debug(new MapLogEntry("retrieving" + Language.class.getSimpleName()).And("id", id));
this.languageService.deleteAndSave(id);
this.auditService.track(AuditableAction.Language_Delete, "id", id);
}
}

View File

@ -0,0 +1,142 @@
package eu.eudat.controllers.v2;
import com.fasterxml.jackson.core.JsonProcessingException;
import eu.eudat.audit.AuditableAction;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission;
import eu.eudat.commons.enums.*;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.StorageFileEntity;
import eu.eudat.model.*;
import eu.eudat.model.builder.DescriptionBuilder;
import eu.eudat.model.censorship.DescriptionCensor;
import eu.eudat.model.censorship.PublicDescriptionCensor;
import eu.eudat.model.persist.DescriptionPersist;
import eu.eudat.model.persist.StorageFilePersist;
import eu.eudat.model.result.QueryResult;
import eu.eudat.query.DescriptionQuery;
import eu.eudat.query.DmpQuery;
import eu.eudat.query.StorageFileQuery;
import eu.eudat.query.lookup.DescriptionLookup;
import eu.eudat.service.description.DescriptionService;
import eu.eudat.service.elastic.ElasticQueryHelperService;
import eu.eudat.service.storage.StorageFileProperties;
import eu.eudat.service.storage.StorageFileService;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.auditing.AuditService;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.exception.MyForbiddenException;
import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry;
import gr.cite.tools.validation.MyValidate;
import org.apache.commons.io.FilenameUtils;
import org.slf4j.LoggerFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.management.InvalidApplicationException;
import java.io.IOException;
import java.net.URLConnection;
import java.time.Duration;
import java.util.*;
import static eu.eudat.authorization.AuthorizationFlags.Public;
@RestController
@RequestMapping(path = "api/storage-file")
public class StorageFileController {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(StorageFileController.class));
private final AuditService auditService;
private final QueryFactory queryFactory;
private final MessageSource messageSource;
private final StorageFileService storageFileService;
private final StorageFileProperties config;
private final UserScope userScope;
private final AuthorizationService authorizationService;
private final ConventionService conventionService;
public StorageFileController(
AuditService auditService,
QueryFactory queryFactory,
MessageSource messageSource,
StorageFileService storageFileService,
StorageFileProperties config,
UserScope userScope,
AuthorizationService authorizationService, ConventionService conventionService) {
this.auditService = auditService;
this.queryFactory = queryFactory;
this.messageSource = messageSource;
this.storageFileService = storageFileService;
this.config = config;
this.userScope = userScope;
this.authorizationService = authorizationService;
this.conventionService = conventionService;
}
@PostMapping("upload-temp-files")
@Transactional
public List<StorageFile> uploadTempFiles(@RequestParam("files") MultipartFile[] files) throws IOException {
logger.debug("upload temp files");
this.authorizationService.authorizeForce(Permission.EditStorageFile);
List<StorageFile> addedFiles = new ArrayList<>();
for (MultipartFile file : files) {
StorageFilePersist storageFilePersist = new StorageFilePersist();
storageFilePersist.setName(FilenameUtils.removeExtension(file.getName()));
storageFilePersist.setExtension(FilenameUtils.getExtension(file.getName()));
storageFilePersist.setMimeType(URLConnection.guessContentTypeFromName(file.getName()));
storageFilePersist.setOwnerId(this.userScope.getUserIdSafe());
storageFilePersist.setStorageType(StorageType.Temp);
storageFilePersist.setLifetime(Duration.ofSeconds(this.config.getTempStoreLifetimeSeconds()));
StorageFile persisted = this.storageFileService.persistBytes(storageFilePersist, file.getBytes(), new BaseFieldSet(StorageFile._id, StorageFile._name));
addedFiles.add(persisted);
}
this.auditService.track(AuditableAction.StorageFile_Upload, "models", addedFiles);
return addedFiles;
}
@GetMapping("{id}")
public ResponseEntity<ByteArrayResource> get(@PathVariable("id") UUID id) throws MyApplicationException, MyForbiddenException, MyNotFoundException {
logger.debug(new MapLogEntry("download" ).And("id", id));
this.authorizationService.authorizeForce(Permission.BrowseStorageFile);
StorageFileEntity storageFile = this.queryFactory.query(StorageFileQuery.class).ids(id).firstAs(new BaseFieldSet().ensure(StorageFile._createdAt, StorageFile._fullName, StorageFile._mimeType));
if (storageFile == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, StorageFile.class.getSimpleName()}, LocaleContextHolder.getLocale()));
byte[] file = this.storageFileService.readAsBytesSafe(id);
if (file == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, StorageFile.class.getSimpleName()}, LocaleContextHolder.getLocale()));
this.auditService.track(AuditableAction.StorageFile_Download, Map.ofEntries(
new AbstractMap.SimpleEntry<String, Object>("id", id)
));
String contentType = storageFile.getMimeType();
if (this.conventionService.isNullOrEmpty(contentType)) contentType = MediaType.APPLICATION_OCTET_STREAM_VALUE;
return ResponseEntity.ok()
.contentType(MediaType.valueOf(contentType))
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + storageFile.getName() + (storageFile.getExtension().startsWith(".") ? "" : ".") + storageFile.getExtension() + "\"")
.body(new ByteArrayResource(file));
}
}

View File

@ -407,10 +407,8 @@ public class ReferenceService {
if (urlPath.contains("openaire") || urlPath.contains("orcid") ){ if (urlPath.contains("openaire") || urlPath.contains("orcid") ){
if (lookup.getLike() != null) { if (lookup.getLike() != null) {
completedPath = completedPath.replace("{query}", lookup.getLike());
completedPath = completedPath.replace("{like}", lookup.getLike()); completedPath = completedPath.replace("{like}", lookup.getLike());
} else { } else {
completedPath = completedPath.replace("{query}", "*");
completedPath = completedPath.replace("{like}", "*"); completedPath = completedPath.replace("{like}", "*");
} }
} }

View File

@ -2,7 +2,7 @@ package eu.eudat.models.data.externaldataset;
import eu.eudat.data.old.ExternalDataset; import eu.eudat.data.old.ExternalDataset;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;
import eu.eudat.types.externalsourcetype.ExternalDatasetType; import eu.eudat.model.publicapi.datasetwizard.ExternalDatasetType;
import java.util.Date; import java.util.Date;
import java.util.UUID; import java.util.UUID;

View File

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

View File

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

View File

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

View File

@ -1,80 +0,0 @@
package eu.eudat.publicapi.managers;
import eu.eudat.commons.enums.DmpAccessType;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.DmpEntity;
import eu.eudat.exceptions.security.ForbiddenException;
import eu.eudat.logic.managers.PaginationManager;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.models.HintedModelFactory;
import eu.eudat.models.data.helpers.common.DataTableData;
import eu.eudat.publicapi.models.listingmodels.DataManagementPlanPublicListingModel;
import eu.eudat.publicapi.models.overviewmodels.DataManagementPlanPublicModel;
import eu.eudat.publicapi.request.dmp.DataManagmentPlanPublicTableRequest;
import eu.eudat.queryable.QueryableList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@Component
public class DataManagementPlanPublicManager {
private static final Logger logger = LoggerFactory.getLogger(DataManagementPlanPublicManager.class);
private DatabaseRepository databaseRepository;
@Autowired
public DataManagementPlanPublicManager(ApiContext apiContext) {
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
}
public DataTableData<DataManagementPlanPublicListingModel> getPublicPaged(DataManagmentPlanPublicTableRequest dmpTableRequest, String fieldsGroup) throws Exception {
dmpTableRequest.setQuery(databaseRepository.getDmpDao().asQueryable().withHint(HintedModelFactory.getHint(DataManagementPlanPublicListingModel.class)));
QueryableList<DmpEntity> items = dmpTableRequest.applyCriteria();
QueryableList<DmpEntity> pagedItems = PaginationManager.applyPaging(items, dmpTableRequest);
DataTableData<DataManagementPlanPublicListingModel> dataTable = new DataTableData<>();
CompletableFuture itemsFuture;
if (fieldsGroup.equals("listing")) {
itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DataManagementPlanPublicListingModel.class))
.selectAsync(item -> {
// item.setDataset(
// item.getDataset().stream()
// .filter(dataset -> dataset.getStatus().equals(Dataset.Status.FINALISED.getValue())).collect(Collectors.toSet()));
return new DataManagementPlanPublicListingModel().fromDataModelNoDatasets(item);
})
.whenComplete((resultList, throwable) -> dataTable.setData(resultList));
} else {
itemsFuture = pagedItems
.selectAsync(item -> new DataManagementPlanPublicListingModel().fromDataModel(item))
.whenComplete((resultList, throwable) -> dataTable.setData(resultList));
}
CompletableFuture countFuture = pagedItems.countAsync().whenComplete((count, throwable) -> {
dataTable.setTotalCount(count);
});
CompletableFuture.allOf(itemsFuture, countFuture).join();
return dataTable;
}
public DataManagementPlanPublicModel getOverviewSinglePublic(String id) throws Exception {
DmpEntity dataManagementPlanEntity = databaseRepository.getDmpDao().find(UUID.fromString(id));
if (dataManagementPlanEntity.getIsActive().equals(IsActive.Inactive)) {
throw new Exception("DMP is deleted.");
}
if (!dataManagementPlanEntity.getAccessType().equals(DmpAccessType.Public)) {
throw new ForbiddenException("Selected DMP is not public");
}
DataManagementPlanPublicModel datamanagementPlan = new DataManagementPlanPublicModel();
datamanagementPlan.fromDataModelDatasets(dataManagementPlanEntity);
datamanagementPlan.setDatasets(datamanagementPlan.getDatasets());
return datamanagementPlan;
}
}

View File

@ -1,176 +0,0 @@
package eu.eudat.publicapi.managers;
import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
import eu.eudat.data.DescriptionEntity;
import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.data.query.definition.helpers.ColumnOrderings;
import eu.eudat.logic.managers.PaginationManager;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.commons.types.xml.XmlBuilder;
import eu.eudat.models.HintedModelFactory;
import eu.eudat.models.data.helpers.common.DataTableData;
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import eu.eudat.publicapi.models.listingmodels.DatasetPublicListingModel;
import eu.eudat.publicapi.models.overviewmodels.DatasetPublicModel;
import eu.eudat.queryable.QueryableList;
import eu.eudat.types.grant.GrantStateType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import jakarta.transaction.Transactional;
import java.util.*;
import java.util.stream.Collectors;
@Component
public class DatasetPublicManager {
private static final Logger logger = LoggerFactory.getLogger(DatasetPublicManager.class);
private DatabaseRepository databaseRepository;
// private DatasetRepository datasetRepository;
@Autowired
public DatasetPublicManager(ApiContext apiContext){
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
// this.datasetRepository = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository();
}
public DataTableData<DatasetPublicListingModel> getPublicPaged(eu.eudat.publicapi.request.dataset.DatasetPublicTableRequest datasetTableRequest) throws Exception {
Long count = 0L;
// DatasetCriteria datasetCriteria = new DatasetCriteria();
// datasetCriteria.setPublic(true);
// datasetCriteria.setLike(datasetTableRequest.getCriteria().getLike());
// datasetCriteria.setDatasetTemplates(datasetTableRequest.getCriteria().getDatasetTemplates());
// datasetCriteria.setDmps(datasetTableRequest.getCriteria().getDmpIds());
// datasetCriteria.setGrants(datasetTableRequest.getCriteria().getGrants());
// datasetCriteria.setCollaborators(datasetTableRequest.getCriteria().getCollaborators());
// datasetCriteria.setAllowAllVersions(datasetTableRequest.getCriteria().getAllVersions());
// datasetCriteria.setOrganiztions(datasetTableRequest.getCriteria().getDmpOrganisations());
// if(datasetTableRequest.getCriteria().getTags() != null && !datasetTableRequest.getCriteria().getTags().isEmpty()){
// datasetCriteria.setHasTags(true);
// datasetCriteria.setTags(datasetTableRequest.getCriteria().getTags());
// }
// datasetCriteria.setGroupIds(datasetTableRequest.getCriteria().getGroupIds());
// datasetCriteria.setGrantStatus(GrantStateType.ONGOING.getValue().shortValue()); // grant status ongoing
// datasetCriteria.setStatus(DescriptionStatus.Finalized.getValue()); // dataset status finalized
// if (datasetTableRequest.getOrderings() != null) {
// datasetCriteria.setSortCriteria(DmpPublicCriteriaMapper.toElasticSorting(datasetTableRequest.getOrderings()));
// }
// datasetCriteria.setOffset(datasetTableRequest.getOffset());
// datasetCriteria.setSize(datasetTableRequest.getLength());
// List<eu.eudat.elastic.entities.Dataset> datasets;
// try {
//// datasets = datasetRepository.exists() ?
//// datasetRepository.queryIds(datasetCriteria) : new LinkedList<>();
// if(datasetTableRequest.getCriteria().getPeriodStart() != null)
// datasets = datasets.stream().filter(dataset -> dataset.getCreated().after(datasetTableRequest.getCriteria().getPeriodStart())).collect(Collectors.toList());
// if(datasetTableRequest.getCriteria().getPeriodEnd() != null)
// datasets = datasets.stream().filter(dataset -> dataset.getCreated().before(datasetTableRequest.getCriteria().getPeriodEnd())).collect(Collectors.toList());
// count = (long) datasets.size();
// } catch (Exception ex) {
// logger.warn(ex.getMessage());
// datasets = null;
// }
/*datasetTableRequest.setQuery(databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetPublicListingModel.class)));
QueryableList<Dataset> items = datasetTableRequest.applyCriteria();*/
datasetTableRequest.setQuery(databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetPublicListingModel.class)));
QueryableList<DescriptionEntity> items;
// if (datasets != null) {
// if (!datasets.isEmpty()) {
// items = databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetPublicListingModel.class));
// List<eu.eudat.elastic.entities.Dataset> finalDatasets = datasets;
// items.where((builder, root) -> root.get("id").in(finalDatasets.stream().map(x -> UUID.fromString(x.getId())).collect(Collectors.toList())));
// } else
// items = datasetTableRequest.applyCriteria();
// //items.where((builder, root) -> root.get("id").in(new UUID[]{UUID.randomUUID()}));
// } else {
items = datasetTableRequest.applyCriteria();
// }
List<String> strings = new ArrayList<>();
strings.add("-dmp:publishedAt|join|");
if(datasetTableRequest.getOrderings() != null) {
datasetTableRequest.getOrderings().setFields(strings);
}
else{
datasetTableRequest.setOrderings(new ColumnOrderings());
datasetTableRequest.getOrderings().setFields(strings);
}
if (count == 0L) {
count = items.count();
}
QueryableList<DescriptionEntity> pagedItems = PaginationManager.applyPaging(items, datasetTableRequest);
DataTableData<DatasetPublicListingModel> dataTable = new DataTableData<>();
List<DatasetPublicListingModel> datasetLists = pagedItems.
select(this::mapPublicModel);
dataTable.setData(datasetLists.stream().filter(Objects::nonNull).collect(Collectors.toList()));
dataTable.setTotalCount(count);
return dataTable;
}
public DatasetPublicModel getOverviewSinglePublic(String id) throws Exception {
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id));
if (descriptionEntityEntity.getIsActive() == IsActive.Inactive) {
throw new Exception("Dataset is deleted.");
}
//TODO
// if (!descriptionEntityEntity.getDmp().isPublic()) {
// throw new ForbiddenException("Selected Dataset is not public");
// }
DatasetPublicModel dataset = new DatasetPublicModel();
dataset.setDatasetProfileDefinition(this.getPagedProfile(dataset.getStatus(), descriptionEntityEntity));
dataset.fromDataModel(descriptionEntityEntity);
return dataset;
}
@Transactional
private DatasetPublicListingModel mapPublicModel(DescriptionEntity item) {
/*if (item.getProfile() == null)
return null;*/
DatasetPublicListingModel listingPublicModel = new DatasetPublicListingModel().fromDataModel(item);
/*DatasetProfileCriteria criteria = new DatasetProfileCriteria();
criteria.setGroupIds(Collections.singletonList(item.getProfile().getGroupId()));
List<DescriptionTemplate> profiles = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).toList();
boolean islast = false;
if (!profiles.isEmpty()) {
profiles = profiles.stream().sorted(Comparator.comparing(DescriptionTemplate::getVersion)).collect(Collectors.toList());
islast = profiles.get(0).getId().equals(item.getProfile().getId());
}
listingModel.setProfileLatestVersion(islast);*/
return listingPublicModel;
}
private PagedDatasetProfile getPagedProfile(DescriptionStatus status, DescriptionEntity descriptionEntityEntity){
//TODO
// eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = this.generateDatasetProfileModel(descriptionEntityEntity.getProfile());
// datasetprofile.setStatus(status.getValue());
// if (descriptionEntityEntity.getProperties() != null) {
// JSONObject jObject = new JSONObject(descriptionEntityEntity.getProperties());
// Map<String, Object> properties = jObject.toMap();
// datasetprofile.fromJsonObject(properties);
// }
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
// pagedDatasetProfile.buildPagedDatasetProfile(datasetprofile);
return pagedDatasetProfile;
}
private eu.eudat.models.data.user.composite.DatasetProfile generateDatasetProfileModel(DescriptionTemplateEntity profile) {
Document viewStyleDoc = XmlBuilder.fromXml(profile.getDefinition());
Element root = (Element) viewStyleDoc.getDocumentElement();
DefinitionEntity viewstyle = new DefinitionEntity().fromXml(root);
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = new eu.eudat.models.data.user.composite.DatasetProfile();
datasetprofile.buildProfile(viewstyle);
return datasetprofile;
}
}

View File

@ -1,175 +0,0 @@
package eu.eudat.publicapi.models.listingmodels;
import eu.eudat.data.DescriptionEntity;
import eu.eudat.model.DmpUser;
import eu.eudat.models.DataModel;
import eu.eudat.publicapi.models.datasetprofile.DatasetProfilePublicModel;
import java.util.Date;
import java.util.List;
public class DatasetPublicListingModel implements DataModel<DescriptionEntity, DatasetPublicListingModel> {
private String id;
private String label;
private String grant;
private String dmp;
private String dmpId;
private DatasetProfilePublicModel profile;
private Date createdAt;
private Date modifiedAt;
private String description;
private Date finalizedAt;
private Date dmpPublishedAt;
private int version;
private List<DmpUser> users;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getGrant() {
return grant;
}
public void setGrant(String grant) {
this.grant = grant;
}
public String getDmp() {
return dmp;
}
public void setDmp(String dmp) {
this.dmp = dmp;
}
public String getDmpId() {
return dmpId;
}
public void setDmpId(String dmpId) {
this.dmpId = dmpId;
}
public DatasetProfilePublicModel getProfile() {
return profile;
}
public void setProfile(DatasetProfilePublicModel profile) {
this.profile = profile;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getModifiedAt() {
return modifiedAt;
}
public void setModifiedAt(Date modifiedAt) {
this.modifiedAt = modifiedAt;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Date getFinalizedAt() {
return finalizedAt;
}
public void setFinalizedAt(Date finalizedAt) {
this.finalizedAt = finalizedAt;
}
public Date getDmpPublishedAt() {
return dmpPublishedAt;
}
public void setDmpPublishedAt(Date dmpPublishedAt) {
this.dmpPublishedAt = dmpPublishedAt;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public List<DmpUser> getUsers() {
return users;
}
public void setUsers(List<DmpUser> users) {
this.users = users;
}
@Override
public DatasetPublicListingModel fromDataModel(DescriptionEntity entity) {
//TODO
// this.id = entity.getId() != null ? entity.getId().toString() : "";
// this.label = entity.getLabel();
// this.createdAt = entity.getCreated();
// this.modifiedAt = entity.getModified();
// if(entity.getDmp() != null && entity.getDmp().getGrant() != null) {
// this.grant = entity.getDmp().getGrant().getLabel();
// }
// this.dmp = entity.getDmp() != null ? entity.getDmp().getLabel() : "";
// this.dmpId = entity.getDmp() != null ? entity.getDmp().getId().toString() : "";
// this.profile = entity.getProfile() != null ? new DatasetProfilePublicModel().fromDataModel(entity.getProfile()) : null;
// this.description = entity.getDescription();
// if (entity.getFinalizedAt() == null && entity.getStatus() == DescriptionEntity.Status.FINALISED.getValue()) {
// this.finalizedAt = entity.getDmp().getFinalizedAt();
// } else {
// this.finalizedAt = entity.getFinalizedAt();
// }
// this.dmpPublishedAt = entity.getDmp().getPublishedAt();
// this.version = entity.getDmp().getVersion();
// this.users = entity.getDmp() != null ? entity.getDmp().getUsers().stream().map(x -> new UserInfoPublicModel().fromDataModel(x)).collect(Collectors.toList()) : new ArrayList<>();
return this;
}
@Override
public DescriptionEntity toDataModel() {
//TODO
DescriptionEntity entity = new DescriptionEntity();
// entity.setId(UUID.fromString(this.getId()));
// entity.setLabel(this.getLabel());
// entity.setCreated(this.getCreatedAt());
// entity.setModified(this.getModifiedAt());
// entity.setDescription(this.getDescription());
// entity.setFinalizedAt(this.getFinalizedAt());
// entity.setStatus(DescriptionEntity.Status.FINALISED.getValue());
// DMP dmp = new DMP();
// if (this.getGrant() != null && !this.getGrant().isEmpty()) {
// Grant grant = new Grant();
// grant.setLabel(this.getGrant());
// dmp.setGrant(grant);
// }
// dmp.setLabel(this.getDmp());
// dmp.setId(UUID.fromString(this.getDmpId()));
// dmp.setPublishedAt(this.getDmpPublishedAt());
// dmp.setVersion(this.getVersion());
// dmp.setUsers(this.getUsers().stream().map(UserInfoPublicModel::toDataModel).collect(Collectors.toSet()));
// dmp.setFinalizedAt(this.getFinalizedAt());
// entity.setDmp(dmp);
// entity.setProfile(this.getProfile() != null ? this.getProfile().toDataModel() : null);
return entity;
}
@Override
public String getHint() {
return "datasetListingModel";
}
}

View File

@ -1,254 +0,0 @@
package eu.eudat.publicapi.models.overviewmodels;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
import eu.eudat.data.DescriptionEntity;
import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.commons.types.xml.XmlBuilder;
import eu.eudat.data.DmpEntity;
import eu.eudat.model.DmpUser;
import eu.eudat.models.DataModel;
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import eu.eudat.publicapi.models.associatedprofile.AssociatedProfilePublicModel;
import eu.eudat.publicapi.models.doi.DoiPublicModel;
import eu.eudat.publicapi.models.grant.GrantPublicOverviewModel;
import eu.eudat.publicapi.models.organisation.OrganizationPublicModel;
import eu.eudat.publicapi.models.researcher.ResearcherPublicModel;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.*;
import java.util.stream.Collectors;
public class DataManagementPlanPublicModel implements DataModel<DmpEntity, DataManagementPlanPublicModel> {
private String id;
private String label;
private String profile;
private GrantPublicOverviewModel grant;
private Date createdAt;
private Date modifiedAt;
private Date finalizedAt;
private List<OrganizationPublicModel> organisations;
private int version;
private UUID groupId;
private List<DatasetPublicModel> datasets;
private List<AssociatedProfilePublicModel> associatedProfiles;
private List<ResearcherPublicModel> researchers;
private List<DmpUser> users;
private String description;
private Date publishedAt;
private List<DoiPublicModel> dois;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getProfile() {
return profile;
}
public void setProfile(String profile) {
this.profile = profile;
}
public GrantPublicOverviewModel getGrant() {
return grant;
}
public void setGrant(GrantPublicOverviewModel grant) {
this.grant = grant;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getModifiedAt() {
return modifiedAt;
}
public void setModifiedAt(Date modifiedAt) {
this.modifiedAt = modifiedAt;
}
public Date getFinalizedAt() {
return finalizedAt;
}
public void setFinalizedAt(Date finalizedAt) {
this.finalizedAt = finalizedAt;
}
public List<OrganizationPublicModel> getOrganisations() {
return organisations;
}
public void setOrganisations(List<OrganizationPublicModel> organizations) {
this.organisations = organizations;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public UUID getGroupId() {
return groupId;
}
public void setGroupId(UUID groupId) {
this.groupId = groupId;
}
public List<DatasetPublicModel> getDatasets() {
return datasets;
}
public void setDatasets(List<DatasetPublicModel> datasets) {
this.datasets = datasets;
}
public List<AssociatedProfilePublicModel> getAssociatedProfiles() {
return associatedProfiles;
}
public void setAssociatedProfiles(List<AssociatedProfilePublicModel> associatedProfiles) {
this.associatedProfiles = associatedProfiles;
}
public List<DmpUser> getUsers() {
return users;
}
public void setUsers(List<DmpUser> users) {
this.users = users;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<ResearcherPublicModel> getResearchers() {
return researchers;
}
public void setResearchers(List<ResearcherPublicModel> researchers) {
this.researchers = researchers;
}
public Date getPublishedAt() {
return publishedAt;
}
public void setPublishedAt(Date publishedAt) {
this.publishedAt = publishedAt;
}
public List<DoiPublicModel> getDois() {
return dois;
}
public void setDois(List<DoiPublicModel> dois) {
this.dois = dois;
}
@Override
public DataManagementPlanPublicModel fromDataModel(DmpEntity entity) {
this.id = entity.getId().toString();
this.label = entity.getLabel();
this.groupId = entity.getGroupId();
// if (entity.getResearchers() != null) { //TODO
// this.researchers = entity.getResearchers().stream().map(item -> new ResearcherPublicModel().fromDataModel(item)).collect(Collectors.toList());
// }
return this;
}
public DataManagementPlanPublicModel fromDataModelDatasets(DmpEntity entity) {
this.fromDataModel(entity);
this.version = entity.getVersion();//TODO
// if (entity.getGrant() != null) {
// this.grant = new GrantPublicOverviewModel().fromDataModel(entity.getGrant());
// }
// if (entity.getProfile() != null) this.profile = entity.getProfile().getLabel();
// this.createdAt = entity.getCreated();
// this.modifiedAt = entity.getModified();
// this.finalizedAt = entity.getFinalizedAt();
// this.organisations = entity.getOrganisations().stream().map(item -> new OrganizationPublicModel().fromDataModel(item)).collect(Collectors.toList());
// this.datasets = entity.getDataset().stream().filter(dataset -> !dataset.getIsActive().equals(IsActive.Inactive) && !dataset.getStatus().equals(DescriptionStatus.Canceled))
// .map(datasetEntity-> {
// DatasetPublicModel dataset = new DatasetPublicModel();
// dataset.setDatasetProfileDefinition(this.getPagedProfile(dataset.getStatus().getValue(), datasetEntity));
// dataset.fromDataModel(datasetEntity);
// return dataset;
// }).collect(Collectors.toList());
// this.users = entity.getUsers().stream().map(x -> new UserInfoPublicModel().fromDataModel(x)).collect(Collectors.toList());
// this.description = entity.getDescription();
// if (entity.getResearchers() != null) {
// this.researchers = entity.getResearchers().stream().map(item -> new ResearcherPublicModel().fromDataModel(item)).collect(Collectors.toList());
// }
//
// if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
// this.associatedProfiles = new LinkedList<>();
// for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) {
// AssociatedProfilePublicModel associatedProfile = new AssociatedProfilePublicModel().fromData(dmpDescriptionProfile.getDatasetprofile());
// associatedProfile.setId(dmpDescriptionProfile.getId());
// try {
// associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference<Map<String, Object>>() {}));
// }
// catch (Exception e) {
// associatedProfile.setData(null);
// }
// this.associatedProfiles.add(associatedProfile);
// }
// }
// this.publishedAt = entity.getPublishedAt();
// this.dois = entity.getDois().stream().map(item -> new DoiPublicModel().fromDataModel(item)).collect(Collectors.toList());
return this;
}
private PagedDatasetProfile getPagedProfile(int status, DescriptionEntity descriptionEntityEntity){
//TODO
// eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = this.generateDatasetProfileModel(descriptionEntityEntity.getProfile());
// datasetprofile.setStatus(status);
// if (descriptionEntityEntity.getProperties() != null) {
// JSONObject jObject = new JSONObject(descriptionEntityEntity.getProperties());
// Map<String, Object> properties = jObject.toMap();
// datasetprofile.fromJsonObject(properties);
// }
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
//pagedDatasetProfile.buildPagedDatasetProfile(datasetprofile);
return pagedDatasetProfile;
}
private eu.eudat.models.data.user.composite.DatasetProfile generateDatasetProfileModel(DescriptionTemplateEntity profile) {
Document viewStyleDoc = XmlBuilder.fromXml(profile.getDefinition());
Element root = (Element) viewStyleDoc.getDocumentElement();
DefinitionEntity viewstyle = new DefinitionEntity().fromXml(root);
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = new eu.eudat.models.data.user.composite.DatasetProfile();
datasetprofile.buildProfile(viewstyle);
return datasetprofile;
}
@Override
public DmpEntity toDataModel() {
return null;
}
@Override
public String getHint() {
return "dataManagementPlanOverviewModel";
}
}

View File

@ -1,151 +0,0 @@
package eu.eudat.publicapi.models.researcher;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import eu.eudat.data.old.Researcher;
import eu.eudat.logic.utilities.helpers.LabelGenerator;
import eu.eudat.models.DataModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.UUID;
@JsonIgnoreProperties(ignoreUnknown = true)
public class ResearcherPublicModel implements DataModel<Researcher, ResearcherPublicModel>, LabelGenerator {
private static final Logger logger = LoggerFactory.getLogger(eu.eudat.models.data.dmp.Researcher.class);
private String label;
private String name;
private String id;
private String reference;
private int status;
private String tag;
private String key;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
@Override
public ResearcherPublicModel fromDataModel(Researcher entity) {
this.id = entity.getId().toString();
this.label = entity.getUri();
this.name = entity.getLabel();
this.status = entity.getStatus();
this.reference = entity.getReference();
String refParts[] = entity.getReference().split(":");
String source = refParts[0];
if (source.equals("dmp"))
this.key = "Internal";
else
this.key = source;
return this;
}
@Override
public Researcher toDataModel() {
Researcher researcher = new Researcher();
if (this.id == null) {
this.id = UUID.randomUUID().toString();
}
researcher.setId(UUID.fromString(this.id));
if (this.key != null) {
if (this.key.toLowerCase().equals("internal")) {
if (this.reference != null && !this.reference.startsWith("dmp:")) {
researcher.setReference("dmp:" + this.reference);
} else if (this.reference == null) {
researcher.setReference("dmp:" + this.id);
} else {
researcher.setReference(this.reference);
}
} else {
if ((this.key + ":").equals(this.reference.substring(0, this.key.length() + 1))) {
researcher.setReference(this.reference);
} else {
researcher.setReference(this.key + ":" + this.reference);
}
}
} else {
try {
throw new Exception("Researcher has no key value");
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
researcher.setLabel(this.name);
researcher.setUri(this.label);
researcher.setCreated(new Date());
researcher.setStatus((short) this.status);
return researcher;
}
@Override
public String generateLabel() {
return this.getName();
}
@Override
public String getHint() {
return null;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ResearcherPublicModel that = (ResearcherPublicModel) o;
return id.equals(that.id);
}
@Override
public int hashCode() {
return reference.hashCode();
}
}

View File

@ -19,6 +19,7 @@ spring:
optional:classpath:config/swagger.yml[.yml], optional:classpath:config/swagger-${spring.profiles.active}.yml[.yml], optional:file:../config/swagger-${spring.profiles.active}.yml[.yml], optional:classpath:config/swagger.yml[.yml], optional:classpath:config/swagger-${spring.profiles.active}.yml[.yml], optional:file:../config/swagger-${spring.profiles.active}.yml[.yml],
optional:classpath:config/deposit.yml[.yml], optional:classpath:config/deposit-${spring.profiles.active}.yml[.yml], optional:file:../config/deposit-${spring.profiles.active}.yml[.yml], optional:classpath:config/deposit.yml[.yml], optional:classpath:config/deposit-${spring.profiles.active}.yml[.yml], optional:file:../config/deposit-${spring.profiles.active}.yml[.yml],
optional:classpath:config/errors.yml[.yml], optional:classpath:config/errors-${spring.profiles.active}.yml[.yml], optional:file:../config/errors-${spring.profiles.active}.yml[.yml], optional:classpath:config/errors.yml[.yml], optional:classpath:config/errors-${spring.profiles.active}.yml[.yml], optional:file:../config/errors-${spring.profiles.active}.yml[.yml],
optional:classpath:config/storage.yml[.yml], optional:classpath:config/storage-${spring.profiles.active}.yml[.yml], optional:file:../config/storage-${spring.profiles.active}.yml[.yml],
optional:classpath:config/reference-type.yml[.yml], optional:classpath:config/reference-type-${spring.profiles.active}.yml[.yml], optional:file:../config/reference-type-${spring.profiles.active}.yml[.yml], optional:classpath:config/reference-type.yml[.yml], optional:classpath:config/reference-type-${spring.profiles.active}.yml[.yml], optional:file:../config/reference-type-${spring.profiles.active}.yml[.yml],
optional:classpath:config/tenant.yml[.yml], optional:classpath:config/tenant-${spring.profiles.active}.yml[.yml], optional:file:../config/tenant-${spring.profiles.active}.yml[.yml] optional:classpath:config/tenant.yml[.yml], optional:classpath:config/tenant-${spring.profiles.active}.yml[.yml], optional:file:../config/tenant-${spring.profiles.active}.yml[.yml]

View File

@ -101,6 +101,13 @@ permissions:
clients: [ ] clients: [ ]
allowAnonymous: false allowAnonymous: false
allowAuthenticated: false allowAuthenticated: false
DeleteLanguage:
roles:
- Admin
claims: [ ]
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
# Statistics # Statistics
BrowseStatistics: BrowseStatistics:
roles: [ ] roles: [ ]
@ -207,6 +214,27 @@ permissions:
clients: [ ] clients: [ ]
allowAnonymous: false allowAnonymous: false
allowAuthenticated: false allowAuthenticated: false
# StorageFile
BrowseStorageFile:
roles: [ ]
claims: [ ]
clients: [ ]
allowAnonymous: false
allowAuthenticated: true
EditStorageFile:
roles:
- Admin
claims: [ ]
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
DeleteStorageFile:
roles:
- Admin
claims: [ ]
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
# DescriptionTemplate # DescriptionTemplate
BrowseDescriptionTemplate: BrowseDescriptionTemplate:
roles: roles:

View File

@ -0,0 +1,7 @@
storage:
service:
storages:
- type: Temp
basePath: ./storage/temp
- type: Main
basePath: ./storage/main

View File

@ -0,0 +1,6 @@
storage:
task:
enable: true
intervalSeconds: 600
service:
tempStoreLifetimeSeconds: 7200

View File

@ -1,3 +1,3 @@
tenant: tenant:
configEncryptionAesKey: 42J7rLaej8X+kUGR configEncryptionAesKey: rmpTvZnRWzyisUtFADBcZCn0q7Z75Xdz
configEncryptionAesIv: oL859DQRZP+AhfQ+ configEncryptionAesIv: ec05d521a23f80ad

View File

@ -0,0 +1,23 @@
DO $$DECLARE
this_version CONSTANT varchar := '00.01.024';
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
CREATE TABLE public."Language"
(
id uuid NOT NULL,
code character varying(20) NOT NULL,
payload text NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
is_active smallint NOT NULL,
CONSTRAINT "Language_pkey" PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
);
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.024', '2023-11-27 12:00:00.000000+02', now(), 'Add table Language.');
END$$;

View File

@ -0,0 +1,32 @@
DO $$DECLARE
this_version CONSTANT varchar := '00.01.024';
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
CREATE TABLE public."StorageFile"
(
id uuid NOT NULL,
file_ref character varying(100) NOT NULL,
name character varying(250) NOT NULL,
extension character varying(10) NOT NULL,
mime_type character varying(200) NOT NULL,
storage_type smallint NOT NULL,
created_at timestamp without time zone NOT NULL,
purge_at timestamp without time zone,
purged_at timestamp without time zone,
owner uuid,
PRIMARY KEY (id),
FOREIGN KEY (owner)
REFERENCES public."User" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID
)
WITH (
OIDS = FALSE
);
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.024', '2023-11-20 12:00:00.000000+02', now(), 'Add table StorageFile.');
END$$;

View File

@ -232,35 +232,63 @@ const appRoutes: Routes = [
}, },
}, },
{ {
path: 'language-editor', path: 'languages',
loadChildren: () => import('./ui/language-editor/language-editor.module').then(m => m.LanguageEditorModule), loadChildren: () => import('./ui/admin/language/language.module').then(m => m.LanguageModule),
data: { data: {
breadcrumb: true, authContext: {
title: 'GENERAL.TITLES.LANGUAGE-EDITOR' permissions: [AppPermission.ViewLanguagePage]
},
...BreadcrumbService.generateRouteDataConfiguration({
title: 'BREADCRUMBS.LANGUAGES'
})
}, },
}, },
{ {
path: 'supportive-material', path: 'supportive-material',
loadChildren: () => import('./ui/supportive-material-editor/supportive-material-editor.module').then(m => m.SupportiveMaterialEditorModule), loadChildren: () => import('./ui/supportive-material-editor/supportive-material-editor.module').then(m => m.SupportiveMaterialEditorModule),
data: { data: {
breadcrumb: true, authContext: {
title: 'GENERAL.TITLES.SUPPORTIVE-MATERIAL' permissions: [AppPermission.ViewLanguagePage]
},
...BreadcrumbService.generateRouteDataConfiguration({
title: 'GENERAL.TITLES.SUPPORTIVE-MATERIAL'
})
},
},
{
path: 'references',
loadChildren: () => import('./ui/admin/reference/reference.module').then(m => m.ReferenceModule),
data: {
authContext: {
permissions: [AppPermission.ViewReferencePage]
},
...BreadcrumbService.generateRouteDataConfiguration({
title: 'BREADCRUMBS.REFERENCES'
})
}, },
}, },
{ {
path: 'reference-type', path: 'reference-type',
loadChildren: () => import('./ui/admin/reference-type/reference-type.module').then(m => m.ReferenceTypeModule), loadChildren: () => import('./ui/admin/reference-type/reference-type.module').then(m => m.ReferenceTypeModule),
data: { data: {
breadcrumb: true, authContext: {
title: 'GENERAL.TITLES.REFERENCE-TYPES' permissions: [AppPermission.ViewReferenceTypePage]
},
...BreadcrumbService.generateRouteDataConfiguration({
title: 'BREADCRUMBS.REFERENCE-TYPES'
})
}, },
}, },
{ {
path: 'tenants', path: 'tenants',
loadChildren: () => import('./ui/admin/tenant/tenant.module').then(m => m.TenantModule), loadChildren: () => import('./ui/admin/tenant/tenant.module').then(m => m.TenantModule),
data: { data: {
breadcrumb: true, authContext: {
title: 'GENERAL.TITLES.TENANTS' permissions: [AppPermission.ViewTenantPage]
},
...BreadcrumbService.generateRouteDataConfiguration({
title: 'BREADCRUMBS.TENANTS'
})
}, },
}, },
{ {

View File

@ -18,6 +18,11 @@ export enum AppPermission {
ViewDescriptionTemplateTypePage = "ViewDescriptionTemplateTypePage", ViewDescriptionTemplateTypePage = "ViewDescriptionTemplateTypePage",
ViewDmpBlueprintPage = "ViewDmpBlueprintPage", ViewDmpBlueprintPage = "ViewDmpBlueprintPage",
ViewDescriptionTemplatePage = "ViewDescriptionTemplatePage", ViewDescriptionTemplatePage = "ViewDescriptionTemplatePage",
ViewSupportiveMaterialPage = 'ViewSupportiveMaterialPage',
ViewReferenceTypePage = 'ViewReferenceTypePage',
ViewReferencePage = 'ViewReferencePage',
ViewTenantPage = 'ViewTenantPage',
ViewLanguagePage = "ViewLanguagePage",
//ReferenceType //ReferenceType
BrowseReferenceType = "BrowseReferenceType", BrowseReferenceType = "BrowseReferenceType",
@ -34,5 +39,15 @@ export enum AppPermission {
EditUser = "EditUser", EditUser = "EditUser",
DeleteUser = "DeleteUser", DeleteUser = "DeleteUser",
ExportUsers = "ExportUsers", ExportUsers = "ExportUsers",
//Reference
BrowseReference = "BrowseReference",
EditReference = "EditReference",
DeleteReference = "DeleteReference",
//Language
BrowseLanguage = "BrowseLanguage",
EditLanguage = "EditLanguage",
DeleteLanguage = "DeleteLanguage",
} }

View File

@ -61,6 +61,7 @@ import { UserSettingsService } from './services/user-settings/user-settings.serv
import { UserService } from './services/user/user.service'; import { UserService } from './services/user/user.service';
import { FileUtils } from './services/utilities/file-utils.service'; import { FileUtils } from './services/utilities/file-utils.service';
import { QueryParamsService } from './services/utilities/query-params.service'; import { QueryParamsService } from './services/utilities/query-params.service';
import { LanguageV2Service } from './services/language/language-v2.service';
// //
// //
// This is shared module that provides all the services. Its imported only once on the AppModule. // This is shared module that provides all the services. Its imported only once on the AppModule.
@ -140,7 +141,8 @@ export class CoreServiceModule {
DescriptionTemplateService, DescriptionTemplateService,
ReferenceTypeService, ReferenceTypeService,
TenantService, TenantService,
UserService UserService,
LanguageV2Service
], ],
}; };
} }

View File

@ -0,0 +1,13 @@
import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model";
export interface Language extends BaseEntity{
code: string;
payload: string;
}
// Persist
export interface LanguagePersist extends BaseEntityPersist{
code: string;
payload: string;
}

View File

@ -1,12 +1,11 @@
import { IsActive } from "@app/core/common/enum/is-active.enum";
import { ReferenceFieldDataType } from "@app/core/common/enum/reference-field-data-type"; import { ReferenceFieldDataType } from "@app/core/common/enum/reference-field-data-type";
import { ReferenceSourceType } from "@app/core/common/enum/reference-source-type"; import { ReferenceSourceType } from "@app/core/common/enum/reference-source-type";
import { ReferenceType } from "@app/core/common/enum/reference-type"; import { ReferenceType } from "@app/core/common/enum/reference-type";
import { UUID } from "crypto"; import { UUID } from "crypto";
import { DmpModel } from "../dmp/dmp"; import { DmpModel } from "../dmp/dmp";
import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model";
export interface Reference { export interface Reference extends BaseEntity{
id: UUID;
label: string; label: string;
type: ReferenceType; type: ReferenceType;
description: string; description: string;
@ -15,9 +14,6 @@ export interface Reference {
abbreviation: string; abbreviation: string;
source: string; source: string;
sourceType: ReferenceSourceType; sourceType: ReferenceSourceType;
isActive: IsActive;
createdAt: Date;
updatedAt: Date;
dmpReferences: DmpReference[]; dmpReferences: DmpReference[];
} }
@ -61,12 +57,11 @@ export interface FetcherReference {
// Persist // Persist
export interface ReferencePersist { export interface ReferencePersist extends BaseEntityPersist {
id: UUID;
label: string; label: string;
type: ReferenceType; type: ReferenceType;
description: string; description: string;
definition: DefinitionPersist; definition?: DefinitionPersist;
reference: string; reference: string;
abbreviation: string; abbreviation: string;
source: string; source: string;
@ -74,7 +69,7 @@ export interface ReferencePersist {
} }
export interface DefinitionPersist { export interface DefinitionPersist {
fields?: FieldPersist[]; fields: FieldPersist[];
} }
export interface FieldPersist { export interface FieldPersist {

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