Merge branch 'dmp-refactoring' of code-repo.d4science.org:MaDgiK-CITE/argos into dmp-refactoring
# Conflicts: # dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java
This commit is contained in:
commit
75d31cf627
|
@ -80,8 +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 StorageFile_Download = new EventId(13000, "StorageFile_Download");
|
public static final EventId Language_Query = new EventId(13000, "Language_Query");
|
||||||
public static final EventId StorageFile_Upload = new EventId(13001, "StorageFile_Upload");
|
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");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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";
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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.*;
|
||||||
|
|
||||||
|
|
|
@ -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";
|
||||||
|
|
|
@ -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>{
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 {
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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\"")
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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.*;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package eu.eudat.model.mapper.publicapi;
|
||||||
|
|
||||||
|
import eu.eudat.model.Dmp;
|
||||||
|
import eu.eudat.model.publicapi.listingmodels.DataManagementPlanPublicListingModel;
|
||||||
|
import eu.eudat.model.publicapi.user.UserInfoPublicModel;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.sql.Date;
|
||||||
|
|
||||||
|
@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.setCreatedAt(Date.from(dmp.getCreatedAt()));
|
||||||
|
model.setModifiedAt(Date.from(dmp.getUpdatedAt()));
|
||||||
|
model.setFinalizedAt(Date.from(dmp.getFinalizedAt()));
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package eu.eudat.model.mapper.publicapi;
|
||||||
|
|
||||||
|
import eu.eudat.model.Dmp;
|
||||||
|
import eu.eudat.model.publicapi.overviewmodels.DataManagementPlanPublicModel;
|
||||||
|
import eu.eudat.model.publicapi.user.UserInfoPublicModel;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.sql.Date;
|
||||||
|
|
||||||
|
@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.setCreatedAt(Date.from(dmp.getCreatedAt()));
|
||||||
|
model.setModifiedAt(Date.from(dmp.getUpdatedAt()));
|
||||||
|
model.setFinalizedAt(Date.from(dmp.getFinalizedAt()));
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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();
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -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;
|
||||||
}
|
}
|
|
@ -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
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
}
|
}
|
|
@ -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) ;
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
|
@ -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;
|
||||||
}
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
}
|
}
|
|
@ -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();
|
||||||
}
|
}
|
|
@ -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;
|
||||||
}
|
}
|
|
@ -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;
|
||||||
}
|
}
|
|
@ -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";
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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";
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
}
|
}
|
|
@ -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";
|
||||||
|
}
|
||||||
|
}
|
|
@ -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();
|
||||||
|
@ -286,8 +279,6 @@ public class DatasetPublicModel implements DataModel<DescriptionEntity, DatasetP
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getHint() {
|
public String getHint() {
|
||||||
return "datasetOverviewModel";
|
return "datasetOverviewModel";
|
||||||
}
|
}
|
|
@ -1,9 +1,7 @@
|
||||||
package eu.eudat.publicapi.models.researcher;
|
package eu.eudat.model.publicapi.researcher;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import eu.eudat.data.old.Researcher;
|
import eu.eudat.data.old.Researcher;
|
||||||
import eu.eudat.logic.utilities.helpers.LabelGenerator;
|
|
||||||
import eu.eudat.models.DataModel;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -11,8 +9,8 @@ import java.util.Date;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public class ResearcherPublicModel implements DataModel<Researcher, ResearcherPublicModel>, LabelGenerator {
|
public class ResearcherPublicModel {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(eu.eudat.models.data.dmp.Researcher.class);
|
private static final Logger logger = LoggerFactory.getLogger(ResearcherPublicModel.class);
|
||||||
private String label;
|
private String label;
|
||||||
private String name;
|
private String name;
|
||||||
private String id;
|
private String id;
|
||||||
|
@ -70,14 +68,13 @@ public class ResearcherPublicModel implements DataModel<Researcher, ResearcherPu
|
||||||
this.key = key;
|
this.key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResearcherPublicModel fromDataModel(Researcher entity) {
|
public ResearcherPublicModel fromDataModel(Researcher entity) {
|
||||||
this.id = entity.getId().toString();
|
this.id = entity.getId().toString();
|
||||||
this.label = entity.getUri();
|
this.label = entity.getUri();
|
||||||
this.name = entity.getLabel();
|
this.name = entity.getLabel();
|
||||||
this.status = entity.getStatus();
|
this.status = entity.getStatus();
|
||||||
this.reference = entity.getReference();
|
this.reference = entity.getReference();
|
||||||
String refParts[] = entity.getReference().split(":");
|
String[] refParts = entity.getReference().split(":");
|
||||||
String source = refParts[0];
|
String source = refParts[0];
|
||||||
if (source.equals("dmp"))
|
if (source.equals("dmp"))
|
||||||
this.key = "Internal";
|
this.key = "Internal";
|
||||||
|
@ -86,7 +83,6 @@ public class ResearcherPublicModel implements DataModel<Researcher, ResearcherPu
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Researcher toDataModel() {
|
public Researcher toDataModel() {
|
||||||
Researcher researcher = new Researcher();
|
Researcher researcher = new Researcher();
|
||||||
if (this.id == null) {
|
if (this.id == null) {
|
||||||
|
@ -94,7 +90,7 @@ public class ResearcherPublicModel implements DataModel<Researcher, ResearcherPu
|
||||||
}
|
}
|
||||||
researcher.setId(UUID.fromString(this.id));
|
researcher.setId(UUID.fromString(this.id));
|
||||||
if (this.key != null) {
|
if (this.key != null) {
|
||||||
if (this.key.toLowerCase().equals("internal")) {
|
if (this.key.equalsIgnoreCase("internal")) {
|
||||||
if (this.reference != null && !this.reference.startsWith("dmp:")) {
|
if (this.reference != null && !this.reference.startsWith("dmp:")) {
|
||||||
researcher.setReference("dmp:" + this.reference);
|
researcher.setReference("dmp:" + this.reference);
|
||||||
} else if (this.reference == null) {
|
} else if (this.reference == null) {
|
||||||
|
@ -123,29 +119,4 @@ public class ResearcherPublicModel implements DataModel<Researcher, ResearcherPu
|
||||||
researcher.setStatus((short) this.status);
|
researcher.setStatus((short) this.status);
|
||||||
return researcher;
|
return researcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String generateLabel() {
|
|
||||||
return this.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getHint() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
|
|
||||||
ResearcherPublicModel that = (ResearcherPublicModel) o;
|
|
||||||
|
|
||||||
return id.equals(that.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return reference.hashCode();
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -0,0 +1,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";
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
|
@ -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> Available strings are: 1) status, 2) label, 3) publishedAt, 4) created.<br>" +
|
||||||
|
" <b>asc</b> equivalent to +label.<br> <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> Annotatsiya Maqolada bolalarni o`yin mavjud bo`lgan shakllarda mavjud <br>\\nhayot bilan kengroq tanishtirishga imkon beradi. O`yin bolalarning turli xil <br>\\nfaoliyati,o`yin ko`nikmalarini shakllantirishga yordam beradi.Ularni fikrlash, his-<br>\\ntuyg`ular, tajribalar, o`yin muammosini hal qilishning faol usullarini izlash, ularning <br>\\no`yin sharoitlari va sharoitlariga bo`ysunishi, o`yindagi bolalarning munosabatlari, <br>\\no`yin orqali bola organik rivojlanadi, inson madaniyatining muhim qatlami kattalar <br>\\no`rtasidagi munosabatlar - oilada, ularning kasbiy faoliyati va boshqalar. O`yin <br>\\no`qituvchilar barcha ta’lim vazifalarini, shu jumladan o`rganishni hal qiladigan eng <br>\\nmuhim faoliyat sifatida foydalaniladi. </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 „szabadságmenete” kapcsán a New York Times hasábjain Ross Donthat publicista egy régi könyvre hívja fel a figyelmet, amely sok évtizeddel ezelőtt megjósolta az elit elleni hasonló lázadá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> Available strings are: 1) status, 2) label, 3) created.<br>" +
|
||||||
|
" <b>asc</b> equivalent to +label.<br> <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> Annotatsiya Maqolada bolalarni o`yin mavjud bo`lgan shakllarda mavjud <br>\\nhayot bilan kengroq tanishtirishga imkon beradi. O`yin bolalarning turli xil <br>\\nfaoliyati,o`yin ko`nikmalarini shakllantirishga yordam beradi.Ularni fikrlash, his-<br>\\ntuyg`ular, tajribalar, o`yin muammosini hal qilishning faol usullarini izlash, ularning <br>\\no`yin sharoitlari va sharoitlariga bo`ysunishi, o`yindagi bolalarning munosabatlari, <br>\\no`yin orqali bola organik rivojlanadi, inson madaniyatining muhim qatlami kattalar <br>\\no`rtasidagi munosabatlar - oilada, ularning kasbiy faoliyati va boshqalar. O`yin <br>\\no`qituvchilar barcha ta’lim vazifalarini, shu jumladan o`rganishni hal qiladigan eng <br>\\nmuhim faoliyat sifatida foydalaniladi. </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" +
|
||||||
|
"}";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,173 @@
|
||||||
|
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.Dmp;
|
||||||
|
import eu.eudat.model.DmpUser;
|
||||||
|
import eu.eudat.model.User;
|
||||||
|
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),
|
||||||
|
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),
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
|
@ -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;
|
|
@ -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;
|
|
@ -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;
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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}", "*");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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 "));
|
|
||||||
// }
|
|
||||||
//}
|
|
|
@ -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> Annotatsiya Maqolada bolalarni o`yin mavjud bo`lgan shakllarda mavjud <br>\\nhayot bilan kengroq tanishtirishga imkon beradi. O`yin bolalarning turli xil <br>\\nfaoliyati,o`yin ko`nikmalarini shakllantirishga yordam beradi.Ularni fikrlash, his-<br>\\ntuyg`ular, tajribalar, o`yin muammosini hal qilishning faol usullarini izlash, ularning <br>\\no`yin sharoitlari va sharoitlariga bo`ysunishi, o`yindagi bolalarning munosabatlari, <br>\\no`yin orqali bola organik rivojlanadi, inson madaniyatining muhim qatlami kattalar <br>\\no`rtasidagi munosabatlar - oilada, ularning kasbiy faoliyati va boshqalar. O`yin <br>\\no`qituvchilar barcha ta’lim vazifalarini, shu jumladan o`rganishni hal qiladigan eng <br>\\nmuhim faoliyat sifatida foydalaniladi. </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 „szabadságmenete” kapcsán a New York Times hasábjain Ross Donthat publicista egy régi könyvre hívja fel a figyelmet, amely sok évtizeddel ezelőtt megjósolta az elit elleni hasonló lázadá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> Available strings are: 1) status, 2) label, 3) created.<br>" +
|
|
||||||
" <b>asc</b> equivalent to +label.<br> <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> Annotatsiya Maqolada bolalarni o`yin mavjud bo`lgan shakllarda mavjud <br>\\nhayot bilan kengroq tanishtirishga imkon beradi. O`yin bolalarning turli xil <br>\\nfaoliyati,o`yin ko`nikmalarini shakllantirishga yordam beradi.Ularni fikrlash, his-<br>\\ntuyg`ular, tajribalar, o`yin muammosini hal qilishning faol usullarini izlash, ularning <br>\\no`yin sharoitlari va sharoitlariga bo`ysunishi, o`yindagi bolalarning munosabatlari, <br>\\no`yin orqali bola organik rivojlanadi, inson madaniyatining muhim qatlami kattalar <br>\\no`rtasidagi munosabatlar - oilada, ularning kasbiy faoliyati va boshqalar. O`yin <br>\\no`qituvchilar barcha ta’lim vazifalarini, shu jumladan o`rganishni hal qiladigan eng <br>\\nmuhim faoliyat sifatida foydalaniladi. </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()));
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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> Available strings are: 1) status, 2) label, 3) publishedAt, 4) created.<br>" +
|
|
||||||
" <b>asc</b> equivalent to +label.<br> <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()));
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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: [ ]
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
tenant:
|
tenant:
|
||||||
configEncryptionAesKey: 42J7rLaej8X+kUGR
|
configEncryptionAesKey: rmpTvZnRWzyisUtFADBcZCn0q7Z75Xdz
|
||||||
configEncryptionAesIv: oL859DQRZP+AhfQ+
|
configEncryptionAesIv: ec05d521a23f80ad
|
|
@ -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$$;
|
|
@ -232,43 +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: {
|
||||||
|
permissions: [AppPermission.ViewLanguagePage]
|
||||||
|
},
|
||||||
|
...BreadcrumbService.generateRouteDataConfiguration({
|
||||||
title: 'GENERAL.TITLES.SUPPORTIVE-MATERIAL'
|
title: 'GENERAL.TITLES.SUPPORTIVE-MATERIAL'
|
||||||
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'references',
|
path: 'references',
|
||||||
loadChildren: () => import('./ui/admin/reference/reference.module').then(m => m.ReferenceModule),
|
loadChildren: () => import('./ui/admin/reference/reference.module').then(m => m.ReferenceModule),
|
||||||
data: {
|
data: {
|
||||||
breadcrumb: true,
|
authContext: {
|
||||||
title: 'GENERAL.TITLES.REFERENCES'
|
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'
|
||||||
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -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",
|
||||||
|
@ -33,5 +38,10 @@ export enum AppPermission {
|
||||||
BrowseReference = "BrowseReference",
|
BrowseReference = "BrowseReference",
|
||||||
EditReference = "EditReference",
|
EditReference = "EditReference",
|
||||||
DeleteReference = "DeleteReference",
|
DeleteReference = "DeleteReference",
|
||||||
|
|
||||||
|
//Language
|
||||||
|
BrowseLanguage = "BrowseLanguage",
|
||||||
|
EditLanguage = "EditLanguage",
|
||||||
|
DeleteLanguage = "DeleteLanguage",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
import { Lookup } from "@common/model/lookup";
|
||||||
|
import { Guid } from "@common/types/guid";
|
||||||
|
import { IsActive } from "../common/enum/is-active.enum";
|
||||||
|
|
||||||
|
export class LanguageLookup extends Lookup implements LanguageFilter {
|
||||||
|
ids: Guid[];
|
||||||
|
excludedIds: Guid[];
|
||||||
|
like: string;
|
||||||
|
isActive: IsActive[];
|
||||||
|
codes: string[];
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LanguageFilter {
|
||||||
|
ids: Guid[];
|
||||||
|
excludedIds: Guid[];
|
||||||
|
like: string;
|
||||||
|
isActive: IsActive[];
|
||||||
|
codes: string[];
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
||||||
|
import { Language, LanguagePersist } from '@app/core/model/language/language';
|
||||||
|
import { LanguageLookup } from '@app/core/query/language.lookup';
|
||||||
|
import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration';
|
||||||
|
import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration';
|
||||||
|
import { QueryResult } from '@common/model/query-result';
|
||||||
|
import { FilterService } from '@common/modules/text-filter/filter-service';
|
||||||
|
import { Guid } from '@common/types/guid';
|
||||||
|
import { Observable, throwError } from 'rxjs';
|
||||||
|
import { catchError, map } from 'rxjs/operators';
|
||||||
|
import { nameof } from 'ts-simple-nameof';
|
||||||
|
import { ConfigurationService } from '../configuration/configuration.service';
|
||||||
|
import { BaseHttpV2Service } from '../http/base-http-v2.service';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class LanguageV2Service {
|
||||||
|
|
||||||
|
constructor(private http: BaseHttpV2Service, private configurationService: ConfigurationService, private filterService: FilterService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
private get apiBase(): string { return `${this.configurationService.server}v2/language`; }
|
||||||
|
|
||||||
|
query(q: LanguageLookup): Observable<QueryResult<Language>> {
|
||||||
|
const url = `${this.apiBase}/query`;
|
||||||
|
return this.http.post<QueryResult<Language>>(url, q).pipe(catchError((error: any) => throwError(error)));
|
||||||
|
}
|
||||||
|
|
||||||
|
getSingle(id: Guid, reqFields: string[] = []): Observable<Language> {
|
||||||
|
const url = `${this.apiBase}/${id}`;
|
||||||
|
const options = { params: { f: reqFields } };
|
||||||
|
|
||||||
|
return this.http
|
||||||
|
.get<Language>(url, options).pipe(
|
||||||
|
catchError((error: any) => throwError(error)));
|
||||||
|
}
|
||||||
|
|
||||||
|
persist(item: LanguagePersist): Observable<Language> {
|
||||||
|
const url = `${this.apiBase}/persist`;
|
||||||
|
|
||||||
|
return this.http
|
||||||
|
.post<Language>(url, item).pipe(
|
||||||
|
catchError((error: any) => throwError(error)));
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(id: Guid): Observable<Language> {
|
||||||
|
const url = `${this.apiBase}/${id}`;
|
||||||
|
|
||||||
|
return this.http
|
||||||
|
.delete<Language>(url).pipe(
|
||||||
|
catchError((error: any) => throwError(error)));
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Autocomplete Commons
|
||||||
|
//
|
||||||
|
// tslint:disable-next-line: member-ordering
|
||||||
|
singleAutocompleteConfiguration: SingleAutoCompleteConfiguration = {
|
||||||
|
initialItems: (data?: any) => this.query(this.buildAutocompleteLookup()).pipe(map(x => x.items)),
|
||||||
|
filterFn: (searchQuery: string, data?: any) => this.query(this.buildAutocompleteLookup(searchQuery)).pipe(map(x => x.items)),
|
||||||
|
getSelectedItem: (selectedItem: any) => this.query(this.buildAutocompleteLookup(null, null, [selectedItem])).pipe(map(x => x.items[0])),
|
||||||
|
displayFn: (item: Language) => item.code,
|
||||||
|
titleFn: (item: Language) => item.code,
|
||||||
|
valueAssign: (item: Language) => item.id,
|
||||||
|
};
|
||||||
|
|
||||||
|
// tslint:disable-next-line: member-ordering
|
||||||
|
multipleAutocompleteConfiguration: MultipleAutoCompleteConfiguration = {
|
||||||
|
initialItems: (excludedItems: any[], data?: any) => this.query(this.buildAutocompleteLookup(null, excludedItems ? excludedItems : null)).pipe(map(x => x.items)),
|
||||||
|
filterFn: (searchQuery: string, excludedItems: any[]) => this.query(this.buildAutocompleteLookup(searchQuery, excludedItems)).pipe(map(x => x.items)),
|
||||||
|
getSelectedItems: (selectedItems: any[]) => this.query(this.buildAutocompleteLookup(null, null, selectedItems)).pipe(map(x => x.items)),
|
||||||
|
displayFn: (item: Language) => item.code,
|
||||||
|
titleFn: (item: Language) => item.code,
|
||||||
|
valueAssign: (item: Language) => item.id,
|
||||||
|
};
|
||||||
|
|
||||||
|
private buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[]): LanguageLookup {
|
||||||
|
const lookup: LanguageLookup = new LanguageLookup();
|
||||||
|
lookup.page = { size: 100, offset: 0 };
|
||||||
|
if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; }
|
||||||
|
if (ids && ids.length > 0) { lookup.ids = ids; }
|
||||||
|
lookup.isActive = [IsActive.Active];
|
||||||
|
lookup.project = {
|
||||||
|
fields: [
|
||||||
|
nameof<Language>(x => x.id),
|
||||||
|
nameof<Language>(x => x.code)
|
||||||
|
]
|
||||||
|
};
|
||||||
|
lookup.order = { items: [nameof<Language>(x => x.code)] };
|
||||||
|
if (like) { lookup.like = this.filterService.transformLike(like); }
|
||||||
|
return lookup;
|
||||||
|
}
|
||||||
|
}
|
|
@ -311,18 +311,18 @@ export class EnumUtils {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case ReferenceType.Taxonomies: return this.language.instant('TYPES.REFERENCE-TYPE.TAXONOMY');
|
case ReferenceType.Taxonomies: return this.language.instant('TYPES.REFERENCE-TYPE.TAXONOMY');
|
||||||
case ReferenceType.Licenses: return this.language.instant('TYPES.REFERENCE-TYPE.LICENCE');
|
case ReferenceType.Licenses: return this.language.instant('TYPES.REFERENCE-TYPE.LICENCE');
|
||||||
case ReferenceType.Publications: return this.language.instant('TYPES.REFERENCE-TYPE.GET');
|
case ReferenceType.Publications: return this.language.instant('TYPES.REFERENCE-TYPE.PUBLICATION');
|
||||||
case ReferenceType.Journals: return this.language.instant('TYPES.REFERENCE-TYPE.GET');
|
case ReferenceType.Journals: return this.language.instant('TYPES.REFERENCE-TYPE.JOURNAL');
|
||||||
case ReferenceType.PubRepositories: return this.language.instant('TYPES.REFERENCE-TYPE.GET');
|
case ReferenceType.PubRepositories: return this.language.instant('TYPES.REFERENCE-TYPE.PUB-REPOSITORY');
|
||||||
case ReferenceType.DataRepositories: return this.language.instant('TYPES.REFERENCE-TYPE.GET');
|
case ReferenceType.DataRepositories: return this.language.instant('TYPES.REFERENCE-TYPE.DATA-REPOSITORY');
|
||||||
case ReferenceType.Registries: return this.language.instant('TYPES.REFERENCE-TYPE.GET');
|
case ReferenceType.Registries: return this.language.instant('TYPES.REFERENCE-TYPE.REGISTRY');
|
||||||
case ReferenceType.Services: return this.language.instant('TYPES.REFERENCE-TYPE.GET');
|
case ReferenceType.Services: return this.language.instant('TYPES.REFERENCE-TYPE.SERVICE');
|
||||||
case ReferenceType.Project: return this.language.instant('TYPES.REFERENCE-TYPE.GET');
|
case ReferenceType.Project: return this.language.instant('TYPES.REFERENCE-TYPE.PROJECT');
|
||||||
case ReferenceType.Funder: return this.language.instant('TYPES.REFERENCE-TYPE.GET');
|
case ReferenceType.Funder: return this.language.instant('TYPES.REFERENCE-TYPE.FUNDER');
|
||||||
case ReferenceType.Datasets: return this.language.instant('TYPES.REFERENCE-TYPE.GET');
|
case ReferenceType.Datasets: return this.language.instant('TYPES.REFERENCE-TYPE.DATASET');
|
||||||
case ReferenceType.Organizations: return this.language.instant('TYPES.REFERENCE-TYPE.ORGANISATION');
|
case ReferenceType.Organizations: return this.language.instant('TYPES.REFERENCE-TYPE.ORGANISATION');
|
||||||
case ReferenceType.Grants: return this.language.instant('TYPES.REFERENCE-TYPE.GET');
|
case ReferenceType.Grants: return this.language.instant('TYPES.REFERENCE-TYPE.GRANT');
|
||||||
case ReferenceType.Researcher: return this.language.instant('TYPES.REFERENCE-TYPE.GET');
|
case ReferenceType.Researcher: return this.language.instant('TYPES.REFERENCE-TYPE.RESEARCHER');
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
<div class="tenant-editor">
|
||||||
|
<div class="col-md-8 offset-md-2 colums-gapped">
|
||||||
|
<div class="row align-items-center mb-4" *ngIf="formGroup">
|
||||||
|
<div class="col-auto">
|
||||||
|
<h3 *ngIf="isNew && !isClone">{{'LANGUAGE-EDITOR.NEW' | translate}}</h3>
|
||||||
|
<app-navigation-breadcrumb />
|
||||||
|
</div>
|
||||||
|
<div class="col-auto">
|
||||||
|
<button mat-button class="action-btn" (click)="cancel()" type="button">{{'LANGUAGE-EDITOR.ACTIONS.CANCEL' | translate}}</button>
|
||||||
|
</div>
|
||||||
|
<div class="col-auto" *ngIf="!isNew">
|
||||||
|
<button mat-button class="action-btn" type="button" (click)="delete()">
|
||||||
|
<mat-icon>delete</mat-icon>
|
||||||
|
{{'LANGUAGE-EDITOR.ACTIONS.DELETE' | translate}}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="col-auto" *ngIf="canSave">
|
||||||
|
<button mat-button class="action-btn" (click)="formSubmit()">
|
||||||
|
<mat-icon>save</mat-icon>
|
||||||
|
{{'LANGUAGE-EDITOR.ACTIONS.SAVE' | translate}}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form *ngIf="formGroup" (ngSubmit)="formSubmit()">
|
||||||
|
<mat-card appearance="outlined">
|
||||||
|
<mat-card-header>
|
||||||
|
<mat-card-title *ngIf="isNew">{{'LANGUAGE-EDITOR.NEW' | translate}}</mat-card-title>
|
||||||
|
</mat-card-header>
|
||||||
|
<mat-card-content>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">
|
||||||
|
<mat-form-field class="w-100">
|
||||||
|
<mat-label>{{'LANGUAGE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
|
||||||
|
<input matInput type="text" name="code" [formControl]="formGroup.get('code')" required>
|
||||||
|
<mat-error *ngIf="formGroup.get('code').hasError('required')">
|
||||||
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
<div class="col-4">
|
||||||
|
<mat-form-field class="w-100">
|
||||||
|
<mat-label>{{'LANGUAGE-EDITOR.FIELDS.PAYLOAD' | translate}}</mat-label>
|
||||||
|
<input matInput type="text" name="payload" [formControl]="formGroup.get('payload')" required>
|
||||||
|
<mat-error *ngIf="formGroup.get('payload').hasError('required')">
|
||||||
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</mat-card-content>
|
||||||
|
</mat-card>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -0,0 +1,43 @@
|
||||||
|
.tenant-editor {
|
||||||
|
margin-top: 1.3rem;
|
||||||
|
margin-left: 1em;
|
||||||
|
margin-right: 3em;
|
||||||
|
|
||||||
|
.remove {
|
||||||
|
background-color: white;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.add {
|
||||||
|
background-color: white;
|
||||||
|
color: #009700;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
::ng-deep .mat-checkbox-checked.mat-accent .mat-checkbox-background, .mat-checkbox-indeterminate.mat-accent .mat-checkbox-background {
|
||||||
|
background-color: var(--primary-color-3);
|
||||||
|
// background-color: #0070c0;
|
||||||
|
}
|
||||||
|
|
||||||
|
::ng-deep .mat-checkbox-disabled.mat-checkbox-checked .mat-checkbox-background, .mat-checkbox-disabled.mat-checkbox-indeterminate .mat-checkbox-background {
|
||||||
|
background-color: #b0b0b0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-btn {
|
||||||
|
border-radius: 30px;
|
||||||
|
background-color: var(--secondary-color);
|
||||||
|
border: 1px solid transparent;
|
||||||
|
padding-left: 2em;
|
||||||
|
padding-right: 2em;
|
||||||
|
box-shadow: 0px 3px 6px #1E202029;
|
||||||
|
|
||||||
|
transition-property: background-color, color;
|
||||||
|
transition-duration: 200ms;
|
||||||
|
transition-delay: 50ms;
|
||||||
|
transition-timing-function: ease-in-out;
|
||||||
|
&:disabled{
|
||||||
|
background-color: #CBCBCB;
|
||||||
|
color: #FFF;
|
||||||
|
border: 0px;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,186 @@
|
||||||
|
|
||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { UntypedFormGroup } from '@angular/forms';
|
||||||
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
|
||||||
|
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
|
||||||
|
// import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item';
|
||||||
|
import { DatePipe } from '@angular/common';
|
||||||
|
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
||||||
|
import { AppPermission } from '@app/core/common/enum/permission.enum';
|
||||||
|
import { Language, LanguagePersist } from '@app/core/model/language/language';
|
||||||
|
import { AuthService } from '@app/core/services/auth/auth.service';
|
||||||
|
import { LoggingService } from '@app/core/services/logging/logging-service';
|
||||||
|
import { MatomoService } from '@app/core/services/matomo/matomo-service';
|
||||||
|
import { FileUtils } from '@app/core/services/utilities/file-utils.service';
|
||||||
|
import { QueryParamsService } from '@app/core/services/utilities/query-params.service';
|
||||||
|
import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration';
|
||||||
|
import { BaseEditor } from '@common/base/base-editor';
|
||||||
|
import { FormService } from '@common/forms/form-service';
|
||||||
|
import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component';
|
||||||
|
import { HttpErrorHandlingService } from '@common/modules/errors/error-handling/http-error-handling.service';
|
||||||
|
import { FilterService } from '@common/modules/text-filter/filter-service';
|
||||||
|
import { Guid } from '@common/types/guid';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
import { map, takeUntil } from 'rxjs/operators';
|
||||||
|
import { LanguageEditorResolver } from './language-editor.resolver';
|
||||||
|
import { LanguageEditorService } from './language-editor.service';
|
||||||
|
import { LanguageEditorModel } from './language-editor.model';
|
||||||
|
import { MatChipEditedEvent, MatChipInputEvent } from '@angular/material/chips';
|
||||||
|
import { LanguageV2Service } from '@app/core/services/language/language-v2.service';
|
||||||
|
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-language-editor-component',
|
||||||
|
templateUrl: 'language-editor.component.html',
|
||||||
|
styleUrls: ['./language-editor.component.scss'],
|
||||||
|
providers: [LanguageEditorService]
|
||||||
|
})
|
||||||
|
export class LanguageEditorComponent extends BaseEditor<LanguageEditorModel, Language> implements OnInit {
|
||||||
|
|
||||||
|
isNew = true;
|
||||||
|
isDeleted = false;
|
||||||
|
formGroup: UntypedFormGroup = null;
|
||||||
|
showInactiveDetails = false;
|
||||||
|
depositCodes: string[] = [];
|
||||||
|
fileTransformersCodes: string[] = [];
|
||||||
|
|
||||||
|
protected get canDelete(): boolean {
|
||||||
|
return !this.isDeleted && !this.isNew && this.hasPermission(this.authService.permissionEnum.DeleteLanguage);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected get canSave(): boolean {
|
||||||
|
return !this.isDeleted && this.hasPermission(this.authService.permissionEnum.EditLanguage);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected get canFinalize(): boolean {
|
||||||
|
return !this.isDeleted && this.hasPermission(this.authService.permissionEnum.EditLanguage);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private hasPermission(permission: AppPermission): boolean {
|
||||||
|
return this.authService.hasPermission(permission) || this.editorModel?.permissions?.includes(permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
// BaseFormEditor injected dependencies
|
||||||
|
protected dialog: MatDialog,
|
||||||
|
protected language: TranslateService,
|
||||||
|
protected formService: FormService,
|
||||||
|
protected router: Router,
|
||||||
|
protected uiNotificationService: UiNotificationService,
|
||||||
|
protected httpErrorHandlingService: HttpErrorHandlingService,
|
||||||
|
protected filterService: FilterService,
|
||||||
|
protected datePipe: DatePipe,
|
||||||
|
protected route: ActivatedRoute,
|
||||||
|
protected queryParamsService: QueryParamsService,
|
||||||
|
// Rest dependencies. Inject any other needed deps here:
|
||||||
|
public authService: AuthService,
|
||||||
|
public enumUtils: EnumUtils,
|
||||||
|
private languageV2Service: LanguageV2Service,
|
||||||
|
private logger: LoggingService,
|
||||||
|
private languageEditorService: LanguageEditorService,
|
||||||
|
private fileUtils: FileUtils,
|
||||||
|
private matomoService: MatomoService
|
||||||
|
) {
|
||||||
|
super(dialog, language, formService, router, uiNotificationService, httpErrorHandlingService, filterService, datePipe, route, queryParamsService);
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.matomoService.trackPageView('Admin: Languages');
|
||||||
|
super.ngOnInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
getItem(itemId: Guid, successFunction: (item: Language) => void) {
|
||||||
|
this.languageV2Service.getSingle(itemId, LanguageEditorResolver.lookupFields())
|
||||||
|
.pipe(map(data => data as Language), takeUntil(this._destroyed))
|
||||||
|
.subscribe(
|
||||||
|
data => successFunction(data),
|
||||||
|
error => this.onCallbackError(error)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
prepareForm(data: Language) {
|
||||||
|
try {
|
||||||
|
this.editorModel = data ? new LanguageEditorModel().fromModel(data) : new LanguageEditorModel();
|
||||||
|
this.isDeleted = data ? data.isActive === IsActive.Inactive : false;
|
||||||
|
this.buildForm();
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error('Could not parse Language item: ' + data + error);
|
||||||
|
this.uiNotificationService.snackBarNotification(this.language.instant('COMMONS.ERRORS.DEFAULT'), SnackBarNotificationLevel.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buildForm() {
|
||||||
|
this.formGroup = this.editorModel.buildForm(null, this.isDeleted || !this.authService.hasPermission(AppPermission.EditLanguage));
|
||||||
|
this.languageEditorService.setValidationErrorModel(this.editorModel.validationErrorModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshData(): void {
|
||||||
|
this.getItem(this.editorModel.id, (data: Language) => this.prepareForm(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshOnNavigateToData(id?: Guid): void {
|
||||||
|
this.formGroup.markAsPristine();
|
||||||
|
let route = [];
|
||||||
|
|
||||||
|
if (id === null) {
|
||||||
|
route.push('../..');
|
||||||
|
} else if (this.isNew) {
|
||||||
|
route.push('../' + id);
|
||||||
|
} else {
|
||||||
|
route.push('..');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.router.navigate(route, { queryParams: { 'lookup': this.queryParamsService.serializeLookup(this.lookupParams), 'lv': ++this.lv }, replaceUrl: true, relativeTo: this.route });
|
||||||
|
}
|
||||||
|
|
||||||
|
persistEntity(onSuccess?: (response) => void): void {
|
||||||
|
const formData = this.formService.getValue(this.formGroup.value) as LanguagePersist;
|
||||||
|
|
||||||
|
this.languageV2Service.persist(formData)
|
||||||
|
.pipe(takeUntil(this._destroyed)).subscribe(
|
||||||
|
complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete),
|
||||||
|
error => this.onCallbackError(error)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
formSubmit(): void {
|
||||||
|
this.formService.touchAllFormFields(this.formGroup);
|
||||||
|
if (!this.isFormValid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.persistEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
public delete() {
|
||||||
|
const value = this.formGroup.value;
|
||||||
|
if (value.id) {
|
||||||
|
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
||||||
|
maxWidth: '300px',
|
||||||
|
data: {
|
||||||
|
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'),
|
||||||
|
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'),
|
||||||
|
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||||
|
if (result) {
|
||||||
|
this.languageV2Service.delete(value.id).pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(
|
||||||
|
complete => this.onCallbackSuccess(),
|
||||||
|
error => this.onCallbackError(error)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
clearErrorModel() {
|
||||||
|
this.editorModel.validationErrorModel.clear();
|
||||||
|
this.formService.validateAllFormFields(this.formGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
|
||||||
|
import { Language, LanguagePersist } from "@app/core/model/language/language";
|
||||||
|
import { BaseEditorModel } from "@common/base/base-form-editor-model";
|
||||||
|
import { BackendErrorValidator } from "@common/forms/validation/custom-validator";
|
||||||
|
import { ValidationErrorModel } from "@common/forms/validation/error-model/validation-error-model";
|
||||||
|
import { Validation, ValidationContext } from "@common/forms/validation/validation-context";
|
||||||
|
|
||||||
|
export class LanguageEditorModel extends BaseEditorModel implements LanguagePersist {
|
||||||
|
code: string;
|
||||||
|
payload: string;
|
||||||
|
|
||||||
|
permissions: string[];
|
||||||
|
|
||||||
|
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
|
||||||
|
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||||
|
|
||||||
|
constructor() { super(); }
|
||||||
|
|
||||||
|
public fromModel(item: Language): LanguageEditorModel {
|
||||||
|
if (item) {
|
||||||
|
super.fromModel(item);
|
||||||
|
this.code = item.code;
|
||||||
|
this.payload = item.payload;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup {
|
||||||
|
if (context == null) { context = this.createValidationContext(); }
|
||||||
|
|
||||||
|
return this.formBuilder.group({
|
||||||
|
id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators],
|
||||||
|
code: [{ value: this.code, disabled: disabled }, context.getValidation('code').validators],
|
||||||
|
payload: [{ value: this.payload, disabled: disabled }, context.getValidation('payload').validators],
|
||||||
|
hash: [{ value: this.hash, disabled: disabled }, context.getValidation('hash').validators]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
createValidationContext(): ValidationContext {
|
||||||
|
const baseContext: ValidationContext = new ValidationContext();
|
||||||
|
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||||
|
baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] });
|
||||||
|
baseValidationArray.push({ key: 'code', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'code')] });
|
||||||
|
baseValidationArray.push({ key: 'payload', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'payload')] });
|
||||||
|
baseValidationArray.push({ key: 'hash', validators: [] });
|
||||||
|
|
||||||
|
baseContext.validation = baseValidationArray;
|
||||||
|
return baseContext;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
|
||||||
|
import { Language } from '@app/core/model/language/language';
|
||||||
|
import { LanguageV2Service } from '@app/core/services/language/language-v2.service';
|
||||||
|
import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service';
|
||||||
|
import { BaseEditorResolver } from '@common/base/base-editor.resolver';
|
||||||
|
import { Guid } from '@common/types/guid';
|
||||||
|
import { takeUntil, tap } from 'rxjs/operators';
|
||||||
|
import { nameof } from 'ts-simple-nameof';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class LanguageEditorResolver extends BaseEditorResolver {
|
||||||
|
|
||||||
|
constructor(private languageV2Service: LanguageV2Service, private breadcrumbService: BreadcrumbService) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static lookupFields(): string[] {
|
||||||
|
return [
|
||||||
|
...BaseEditorResolver.lookupFields(),
|
||||||
|
nameof<Language>(x => x.id),
|
||||||
|
nameof<Language>(x => x.code),
|
||||||
|
nameof<Language>(x => x.payload),
|
||||||
|
nameof<Language>(x => x.createdAt),
|
||||||
|
nameof<Language>(x => x.updatedAt),
|
||||||
|
nameof<Language>(x => x.hash),
|
||||||
|
nameof<Language>(x => x.isActive)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
|
||||||
|
|
||||||
|
const fields = [
|
||||||
|
...LanguageEditorResolver.lookupFields()
|
||||||
|
];
|
||||||
|
const id = route.paramMap.get('id');
|
||||||
|
|
||||||
|
if (id != null) {
|
||||||
|
return this.languageV2Service.getSingle(Guid.parse(id), fields).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.code)), takeUntil(this._destroyed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { Injectable } from "@angular/core";
|
||||||
|
import { ValidationErrorModel } from "@common/forms/validation/error-model/validation-error-model";
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class LanguageEditorService {
|
||||||
|
private validationErrorModel: ValidationErrorModel;
|
||||||
|
|
||||||
|
public setValidationErrorModel(validationErrorModel: ValidationErrorModel): void {
|
||||||
|
this.validationErrorModel = validationErrorModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getValidationErrorModel(): ValidationErrorModel {
|
||||||
|
return this.validationErrorModel;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
import { DragDropModule } from '@angular/cdk/drag-drop';
|
||||||
|
import { NgModule } from "@angular/core";
|
||||||
|
import { AutoCompleteModule } from "@app/library/auto-complete/auto-complete.module";
|
||||||
|
import { UrlListingModule } from '@app/library/url-listing/url-listing.module';
|
||||||
|
import { CommonFormattingModule } from '@common/formatting/common-formatting.module';
|
||||||
|
import { CommonFormsModule } from '@common/forms/common-forms.module';
|
||||||
|
import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module';
|
||||||
|
import { HybridListingModule } from "@common/modules/hybrid-listing/hybrid-listing.module";
|
||||||
|
import { TextFilterModule } from "@common/modules/text-filter/text-filter.module";
|
||||||
|
import { UserSettingsModule } from "@common/modules/user-settings/user-settings.module";
|
||||||
|
import { CommonUiModule } from '@common/ui/common-ui.module';
|
||||||
|
import { NgxDropzoneModule } from "ngx-dropzone";
|
||||||
|
import { LanguageRoutingModule } from './language.routing';
|
||||||
|
import { LanguageEditorComponent } from './editor/language-editor.component';
|
||||||
|
import { LanguageListingComponent } from './listing/language-listing.component';
|
||||||
|
import { LanguageListingFiltersComponent } from "./listing/filters/language-listing-filters.component";
|
||||||
|
import { RichTextEditorModule } from '@app/library/rich-text-editor/rich-text-editor.module';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
CommonUiModule,
|
||||||
|
CommonFormsModule,
|
||||||
|
UrlListingModule,
|
||||||
|
ConfirmationDialogModule,
|
||||||
|
LanguageRoutingModule,
|
||||||
|
NgxDropzoneModule,
|
||||||
|
DragDropModule,
|
||||||
|
AutoCompleteModule,
|
||||||
|
HybridListingModule,
|
||||||
|
TextFilterModule,
|
||||||
|
UserSettingsModule,
|
||||||
|
CommonFormattingModule,
|
||||||
|
RichTextEditorModule
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
LanguageEditorComponent,
|
||||||
|
LanguageListingComponent,
|
||||||
|
LanguageListingFiltersComponent
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class LanguageModule { }
|
|
@ -0,0 +1,57 @@
|
||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
|
import { LanguageEditorComponent } from './editor/language-editor.component';
|
||||||
|
import { LanguageListingComponent } from './listing/language-listing.component';
|
||||||
|
import { AppPermission } from '@app/core/common/enum/permission.enum';
|
||||||
|
import { AuthGuard } from '@app/core/auth-guard.service';
|
||||||
|
import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service';
|
||||||
|
import { PendingChangesGuard } from '@common/forms/pending-form-changes/pending-form-changes-guard.service';
|
||||||
|
import { LanguageEditorResolver } from './editor/language-editor.resolver';
|
||||||
|
|
||||||
|
const routes: Routes = [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
component: LanguageListingComponent,
|
||||||
|
canActivate: [AuthGuard]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'new',
|
||||||
|
canActivate: [AuthGuard],
|
||||||
|
component: LanguageEditorComponent,
|
||||||
|
canDeactivate: [PendingChangesGuard],
|
||||||
|
data: {
|
||||||
|
authContext: {
|
||||||
|
permissions: [AppPermission.EditLanguage]
|
||||||
|
},
|
||||||
|
...BreadcrumbService.generateRouteDataConfiguration({
|
||||||
|
title: 'BREADCRUMBS.NEW-LANGUAGE'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: ':id',
|
||||||
|
canActivate: [AuthGuard],
|
||||||
|
component: LanguageEditorComponent,
|
||||||
|
canDeactivate: [PendingChangesGuard],
|
||||||
|
resolve: {
|
||||||
|
'entity': LanguageEditorResolver
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
...BreadcrumbService.generateRouteDataConfiguration({
|
||||||
|
title: 'BREADCRUMBS.EDIT-LANGUAGE'
|
||||||
|
}),
|
||||||
|
authContext: {
|
||||||
|
permissions: [AppPermission.EditLanguage]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
{ path: '**', loadChildren: () => import('@common/modules/page-not-found/page-not-found.module').then(m => m.PageNotFoundModule) },
|
||||||
|
];
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [RouterModule.forChild(routes)],
|
||||||
|
exports: [RouterModule],
|
||||||
|
providers: [LanguageEditorResolver]
|
||||||
|
})
|
||||||
|
export class LanguageRoutingModule { }
|
|
@ -0,0 +1,36 @@
|
||||||
|
<div class="d-flex align-items-center gap-1-rem">
|
||||||
|
|
||||||
|
<button mat-flat-button [matMenuTriggerFor]="filterMenu" #filterMenuTrigger="matMenuTrigger" (click)="updateFilters()" class="filter-button">
|
||||||
|
<mat-icon aria-hidden="false" [matBadgeHidden]="!appliedFilterCount" [matBadge]="appliedFilterCount" matBadgeColor="warn" matBadgeSize="small">filter_alt</mat-icon>
|
||||||
|
{{'COMMONS.LISTING-COMPONENT.SEARCH-FILTER-BTN' | translate}}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
|
||||||
|
<mat-menu #filterMenu>
|
||||||
|
<div class="p-3" (click)="$event?.stopPropagation?.()">
|
||||||
|
<div class="search-listing-filters-container">
|
||||||
|
<div class="d-flex align-items-center justify-content-between">
|
||||||
|
<h4>{{'TENANT-LISTING.FILTER.TITLE' | translate}}</h4>
|
||||||
|
<button color="accent" mat-button (click)="clearFilters()">
|
||||||
|
{{'COMMONS.LISTING-COMPONENT.CLEAR-ALL-FILTERS' | translate}}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<mat-slide-toggle labelPosition="before" [(ngModel)]="internalFilters.isActive">
|
||||||
|
{{'TENANT-LISTING.FILTER.IS-ACTIVE' | translate}}
|
||||||
|
</mat-slide-toggle>
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-end align-items-center mt-4 gap-1-rem">
|
||||||
|
<button mat-stroked-button color="primary" (click)="filterMenuTrigger?.closeMenu()">
|
||||||
|
{{'TENANT-LISTING.FILTER.CANCEL' | translate}}
|
||||||
|
</button>
|
||||||
|
<button mat-raised-button color="primary" (click)="filterMenuTrigger.closeMenu(); applyFilters();">
|
||||||
|
{{'TENANT-LISTING.FILTER.APPLY-FILTERS' | translate}}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</mat-menu>
|
||||||
|
|
||||||
|
<app-expandable-search-field [(value)]=internalFilters.like (valueChange)="onSearchTermChange($event)" />
|
||||||
|
</div>
|
|
@ -0,0 +1,21 @@
|
||||||
|
::ng-deep.mat-mdc-menu-panel {
|
||||||
|
max-width: 100% !important;
|
||||||
|
height: 100% !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
:host::ng-deep.mat-mdc-menu-content:not(:empty) {
|
||||||
|
padding-top: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.filter-button{
|
||||||
|
padding-top: .6rem;
|
||||||
|
padding-bottom: .6rem;
|
||||||
|
// .mat-icon{
|
||||||
|
// font-size: 1.5em;
|
||||||
|
// width: 1.2em;
|
||||||
|
// height: 1.2em;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
|
||||||
|
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
||||||
|
import { TenantFilter } from '@app/core/query/tenant.lookup';
|
||||||
|
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
|
||||||
|
import { BaseComponent } from '@common/base/base.component';
|
||||||
|
import { nameof } from 'ts-simple-nameof';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-language-listing-filters',
|
||||||
|
templateUrl: './language-listing-filters.component.html',
|
||||||
|
styleUrls: ['./language-listing-filters.component.scss']
|
||||||
|
})
|
||||||
|
export class LanguageListingFiltersComponent extends BaseComponent implements OnInit, OnChanges {
|
||||||
|
|
||||||
|
@Input() readonly filter: TenantFilter;
|
||||||
|
@Output() filterChange = new EventEmitter<TenantFilter>();
|
||||||
|
|
||||||
|
// * State
|
||||||
|
internalFilters: LanguageListingFilters = this._getEmptyFilters();
|
||||||
|
|
||||||
|
protected appliedFilterCount: number = 0;
|
||||||
|
constructor(
|
||||||
|
public enumUtils: EnumUtils,
|
||||||
|
) { super(); }
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
|
const filterChange = changes[nameof<LanguageListingFiltersComponent>(x => x.filter)]?.currentValue as TenantFilter;
|
||||||
|
if (filterChange) {
|
||||||
|
this.updateFilters()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
onSearchTermChange(searchTerm: string): void {
|
||||||
|
this.applyFilters()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected updateFilters(): void {
|
||||||
|
this.internalFilters = this._parseToInternalFilters(this.filter);
|
||||||
|
this.appliedFilterCount = this._computeAppliedFilters(this.internalFilters);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected applyFilters(): void {
|
||||||
|
const { isActive, like } = this.internalFilters ?? {}
|
||||||
|
this.filterChange.emit({
|
||||||
|
...this.filter,
|
||||||
|
like,
|
||||||
|
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private _parseToInternalFilters(inputFilter: TenantFilter): LanguageListingFilters {
|
||||||
|
if (!inputFilter) {
|
||||||
|
return this._getEmptyFilters();
|
||||||
|
}
|
||||||
|
|
||||||
|
let { excludedIds, ids, isActive, like } = inputFilter;
|
||||||
|
|
||||||
|
return {
|
||||||
|
isActive: (isActive ?? [])?.includes(IsActive.Active) || !isActive?.length,
|
||||||
|
like: like
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private _getEmptyFilters(): LanguageListingFilters {
|
||||||
|
return {
|
||||||
|
isActive: true,
|
||||||
|
like: null,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private _computeAppliedFilters(filters: LanguageListingFilters): number {
|
||||||
|
let count = 0;
|
||||||
|
if (filters?.isActive) {
|
||||||
|
count++
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
clearFilters() {
|
||||||
|
this.internalFilters = this._getEmptyFilters();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface LanguageListingFilters {
|
||||||
|
isActive: boolean;
|
||||||
|
like: string;
|
||||||
|
}
|
|
@ -0,0 +1,95 @@
|
||||||
|
<div class="row language-listing">
|
||||||
|
<div class="col-md-8 offset-md-2">
|
||||||
|
|
||||||
|
<div class="row mb-4 mt-3">
|
||||||
|
<div class="col">
|
||||||
|
<h4>{{'LANGUAGE-LISTING.TITLE' | translate}}</h4>
|
||||||
|
<app-navigation-breadcrumb />
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="col-auto">
|
||||||
|
<button mat-raised-button class="create-btn"
|
||||||
|
*ngIf="authService.hasPermission(authService.permissionEnum.EditLanguage)"
|
||||||
|
[routerLink]="['/languages/new']">
|
||||||
|
<mat-icon>add</mat-icon>
|
||||||
|
{{'LANGUAGE-LISTING.CREATE' | translate}}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<app-hybrid-listing [rows]="gridRows" [columns]="gridColumns" [visibleColumns]="visibleColumns"
|
||||||
|
[count]="totalElements" [offset]="currentPageNumber" [limit]="lookup.page.size"
|
||||||
|
[defaultSort]="lookup.order?.items" [externalSorting]="true" (rowActivated)="onRowActivated($event)"
|
||||||
|
(pageLoad)="alterPage($event)" (columnSort)="onColumnSort($event)"
|
||||||
|
(columnsChanged)="onColumnsChanged($event)" [listItemTemplate]="listItemTemplate">
|
||||||
|
|
||||||
|
<app-language-listing-filters hybrid-listing-filters [(filter)]="lookup"
|
||||||
|
(filterChange)="filterChanged($event)" />
|
||||||
|
|
||||||
|
<app-user-settings-picker [key]="userSettingsKey" [userPreference]="lookup"
|
||||||
|
(onSettingSelected)="changeSetting($event)" [autoSelectUserSettings]="autoSelectUserSettings"
|
||||||
|
user-preference-settings />
|
||||||
|
</app-hybrid-listing>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ng-template #listItemTemplate let-item="item" let-isColumnSelected="isColumnSelected">
|
||||||
|
|
||||||
|
|
||||||
|
<div class="d-flex align-items-center p-3 gap-1-rem">
|
||||||
|
<div class="row">
|
||||||
|
<ng-container *ngIf="isColumnSelected('name')">
|
||||||
|
<a class="buttonLinkClass" [routerLink]="'./' + item?.id" class="col-12"
|
||||||
|
(click)="$event.stopPropagation()">{{item?.name | nullifyValue}}</a>
|
||||||
|
<br />
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container *ngIf="isColumnSelected('status')">
|
||||||
|
<div class="col-auto">
|
||||||
|
<div class="status-chip"
|
||||||
|
[ngClass]="{'status-chip-finalized': item.status === descriptionTemplateTypeStatuses.Finalized, 'status-chip-draft' : item.status === descriptionTemplateTypeStatuses.Draft}">
|
||||||
|
{{enumUtils.toDescriptionTemplateTypeStatusString(item.status) | nullifyValue}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container *ngIf="isColumnSelected('createdAt')">
|
||||||
|
<span class="col-12">
|
||||||
|
{{'LANGUAGE-LISTING.FIELDS.CREATED-AT' | translate}}:
|
||||||
|
<small>
|
||||||
|
{{item?.createdAt | dateTimeFormatter : 'short' | nullifyValue}}
|
||||||
|
</small>
|
||||||
|
</span>
|
||||||
|
<br>
|
||||||
|
</ng-container>
|
||||||
|
<ng-container *ngIf="isColumnSelected('updatedAt')">
|
||||||
|
<span class="col-12">
|
||||||
|
{{'LANGUAGE-LISTING.FIELDS.UPDATED-AT' | translate}}:
|
||||||
|
<small>
|
||||||
|
{{item?.updatedAt | dateTimeFormatter : 'short' | nullifyValue}}
|
||||||
|
</small>
|
||||||
|
</span>
|
||||||
|
</ng-container>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ng-template>
|
||||||
|
|
||||||
|
<ng-template #actions let-row="row" let-item>
|
||||||
|
<div class="row" (click)="$event.stopPropagation()">
|
||||||
|
<div class="col-auto">
|
||||||
|
<button mat-icon-button [matMenuTriggerFor]="actionsMenu">
|
||||||
|
<mat-icon>more_horiz</mat-icon>
|
||||||
|
</button>
|
||||||
|
<mat-menu #actionsMenu="matMenu">
|
||||||
|
<button mat-menu-item [routerLink]="['/language/' + row.id]">
|
||||||
|
<mat-icon>edit</mat-icon>{{'LANGUAGE-LISTING.ACTIONS.EDIT' | translate}}
|
||||||
|
</button>
|
||||||
|
<button mat-menu-item (click)="deleteType(row.id)">
|
||||||
|
<mat-icon>delete</mat-icon>
|
||||||
|
{{'LANGUAGE-LISTING.ACTIONS.DELETE' | translate}}
|
||||||
|
</button>
|
||||||
|
</mat-menu>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ng-template>
|
|
@ -0,0 +1,60 @@
|
||||||
|
.language-listing {
|
||||||
|
margin-top: 1.3rem;
|
||||||
|
margin-left: 1rem;
|
||||||
|
margin-right: 2rem;
|
||||||
|
|
||||||
|
.mat-header-row{
|
||||||
|
background: #f3f5f8;
|
||||||
|
}
|
||||||
|
.mat-card {
|
||||||
|
margin: 16px 0;
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mat-row {
|
||||||
|
cursor: pointer;
|
||||||
|
min-height: 4.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
mat-row:hover {
|
||||||
|
background-color: #eef5f6;
|
||||||
|
}
|
||||||
|
.mat-fab-bottom-right {
|
||||||
|
float: right;
|
||||||
|
z-index: 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.create-btn {
|
||||||
|
border-radius: 30px;
|
||||||
|
background-color: var(--secondary-color);
|
||||||
|
padding-left: 2em;
|
||||||
|
padding-right: 2em;
|
||||||
|
// color: #000;
|
||||||
|
|
||||||
|
.button-text{
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dlt-btn {
|
||||||
|
color: rgba(0, 0, 0, 0.54);
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-chip{
|
||||||
|
|
||||||
|
border-radius: 20px;
|
||||||
|
padding-left: 1em;
|
||||||
|
padding-right: 1em;
|
||||||
|
padding-top: 0.2em;
|
||||||
|
font-size: .8em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-chip-finalized{
|
||||||
|
color: #568b5a;
|
||||||
|
background: #9dd1a1 0% 0% no-repeat padding-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-chip-draft{
|
||||||
|
color: #00c4ff;
|
||||||
|
background: #d3f5ff 0% 0% no-repeat padding-box;
|
||||||
|
}
|
|
@ -0,0 +1,164 @@
|
||||||
|
import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
|
||||||
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
||||||
|
import { Language } from '@app/core/model/language/language';
|
||||||
|
import { LanguageLookup } from '@app/core/query/language.lookup';
|
||||||
|
import { AuthService } from '@app/core/services/auth/auth.service';
|
||||||
|
import { LanguageV2Service } from '@app/core/services/language/language-v2.service';
|
||||||
|
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
|
||||||
|
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
|
||||||
|
import { QueryParamsService } from '@app/core/services/utilities/query-params.service';
|
||||||
|
import { BaseListingComponent } from '@common/base/base-listing-component';
|
||||||
|
import { PipeService } from '@common/formatting/pipe.service';
|
||||||
|
import { DataTableDateTimeFormatPipe } from '@common/formatting/pipes/date-time-format.pipe';
|
||||||
|
import { QueryResult } from '@common/model/query-result';
|
||||||
|
import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component';
|
||||||
|
import { HttpErrorHandlingService } from '@common/modules/errors/error-handling/http-error-handling.service';
|
||||||
|
import { ColumnDefinition, ColumnsChangedEvent, HybridListingComponent, PageLoadEvent } from '@common/modules/hybrid-listing/hybrid-listing.component';
|
||||||
|
import { Guid } from '@common/types/guid';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
import { nameof } from 'ts-simple-nameof';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
templateUrl: './language-listing.component.html',
|
||||||
|
styleUrls: ['./language-listing.component.scss']
|
||||||
|
})
|
||||||
|
export class LanguageListingComponent extends BaseListingComponent<Language, LanguageLookup> implements OnInit {
|
||||||
|
publish = false;
|
||||||
|
userSettingsKey = { key: 'LanguageListingUserSettings' };
|
||||||
|
propertiesAvailableForOrder: ColumnDefinition[];
|
||||||
|
|
||||||
|
// @ViewChild('LanguageStatus', { static: true }) LanguageStatus?: TemplateRef<any>;
|
||||||
|
@ViewChild('actions', { static: true }) actions?: TemplateRef<any>;
|
||||||
|
@ViewChild(HybridListingComponent, { static: true }) hybridListingComponent: HybridListingComponent;
|
||||||
|
|
||||||
|
private readonly lookupFields: string[] = [
|
||||||
|
nameof<Language>(x => x.id),
|
||||||
|
nameof<Language>(x => x.code),
|
||||||
|
nameof<Language>(x => x.updatedAt),
|
||||||
|
nameof<Language>(x => x.createdAt),
|
||||||
|
nameof<Language>(x => x.hash),
|
||||||
|
nameof<Language>(x => x.isActive)
|
||||||
|
];
|
||||||
|
|
||||||
|
rowIdentity = x => x.id;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
protected router: Router,
|
||||||
|
protected route: ActivatedRoute,
|
||||||
|
protected uiNotificationService: UiNotificationService,
|
||||||
|
protected httpErrorHandlingService: HttpErrorHandlingService,
|
||||||
|
protected queryParamsService: QueryParamsService,
|
||||||
|
private languageV2Service: LanguageV2Service,
|
||||||
|
public authService: AuthService,
|
||||||
|
private pipeService: PipeService,
|
||||||
|
public enumUtils: EnumUtils,
|
||||||
|
private language: TranslateService,
|
||||||
|
private dialog: MatDialog
|
||||||
|
) {
|
||||||
|
super(router, route, uiNotificationService, httpErrorHandlingService, queryParamsService);
|
||||||
|
// Lookup setup
|
||||||
|
// Default lookup values are defined in the user settings class.
|
||||||
|
this.lookup = this.initializeLookup();
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
super.ngOnInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected initializeLookup(): LanguageLookup {
|
||||||
|
const lookup = new LanguageLookup();
|
||||||
|
lookup.metadata = { countAll: true };
|
||||||
|
lookup.page = { offset: 0, size: this.ITEMS_PER_PAGE };
|
||||||
|
lookup.isActive = [IsActive.Active];
|
||||||
|
lookup.order = { items: [this.toDescSortField(nameof<Language>(x => x.createdAt))] };
|
||||||
|
this.updateOrderUiFields(lookup.order);
|
||||||
|
|
||||||
|
lookup.project = {
|
||||||
|
fields: this.lookupFields
|
||||||
|
};
|
||||||
|
|
||||||
|
return lookup;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected setupColumns() {
|
||||||
|
this.gridColumns.push(...[{
|
||||||
|
prop: nameof<Language>(x => x.code),
|
||||||
|
sortable: true,
|
||||||
|
languageName: 'LANGUAGE-LISTING.FIELDS.CODE'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: nameof<Language>(x => x.createdAt),
|
||||||
|
sortable: true,
|
||||||
|
languageName: 'LANGUAGE-LISTING.FIELDS.CREATED-AT',
|
||||||
|
pipe: this.pipeService.getPipe<DataTableDateTimeFormatPipe>(DataTableDateTimeFormatPipe).withFormat('short')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: nameof<Language>(x => x.updatedAt),
|
||||||
|
sortable: true,
|
||||||
|
languageName: 'LANGUAGE-LISTING.FIELDS.UPDATED-AT',
|
||||||
|
pipe: this.pipeService.getPipe<DataTableDateTimeFormatPipe>(DataTableDateTimeFormatPipe).withFormat('short')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
alwaysShown: true,
|
||||||
|
cellTemplate: this.actions,
|
||||||
|
maxWidth: 120
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
this.propertiesAvailableForOrder = this.gridColumns.filter(x => x.sortable);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Listing Component functions
|
||||||
|
//
|
||||||
|
onColumnsChanged(event: ColumnsChangedEvent) {
|
||||||
|
super.onColumnsChanged(event);
|
||||||
|
this.onColumnsChangedInternal(event.properties.map(x => x.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private onColumnsChangedInternal(columns: string[]) {
|
||||||
|
// Here are defined the projection fields that always requested from the api.
|
||||||
|
const fields = new Set(this.lookupFields);
|
||||||
|
this.gridColumns.map(x => x.prop)
|
||||||
|
.filter(x => !columns?.includes(x as string))
|
||||||
|
.forEach(item => {
|
||||||
|
fields.delete(item as string)
|
||||||
|
});
|
||||||
|
this.lookup.project = { fields: [...fields] };
|
||||||
|
this.onPageLoad({ offset: 0 } as PageLoadEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected loadListing(): Observable<QueryResult<Language>> {
|
||||||
|
return this.languageV2Service.query(this.lookup);
|
||||||
|
}
|
||||||
|
|
||||||
|
public deleteType(id: Guid) {
|
||||||
|
if (id) {
|
||||||
|
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
||||||
|
data: {
|
||||||
|
isDeleteConfirmation: true,
|
||||||
|
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'),
|
||||||
|
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'),
|
||||||
|
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||||
|
if (result) {
|
||||||
|
this.languageV2Service.delete(id).pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(
|
||||||
|
complete => this.onCallbackSuccess(),
|
||||||
|
error => this.onCallbackError(error)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onCallbackSuccess(): void {
|
||||||
|
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success);
|
||||||
|
this.ngOnInit();
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,7 +11,7 @@ import { nameof } from 'ts-simple-nameof';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ReferenceTypeEditorResolver extends BaseEditorResolver {
|
export class ReferenceTypeEditorResolver extends BaseEditorResolver {
|
||||||
|
|
||||||
constructor(private ReferenceTypeService: ReferenceTypeService, private breadcrumbService: BreadcrumbService) {
|
constructor(private referenceTypeService: ReferenceTypeService, private breadcrumbService: BreadcrumbService) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ export class ReferenceTypeEditorResolver extends BaseEditorResolver {
|
||||||
];
|
];
|
||||||
const id = route.paramMap.get('id');
|
const id = route.paramMap.get('id');
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
return this.ReferenceTypeService.getSingle(Guid.parse(id), fields).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.code)), takeUntil(this._destroyed));
|
return this.referenceTypeService.getSingle(Guid.parse(id), fields).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.code)), takeUntil(this._destroyed));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue