diff --git a/dmp-backend/core/pom.xml b/dmp-backend/core/pom.xml
index ccd2a632e..883457036 100644
--- a/dmp-backend/core/pom.xml
+++ b/dmp-backend/core/pom.xml
@@ -19,6 +19,11 @@
org.springframework.boot
spring-boot-starter-validation
+
+ org.apache.commons
+ commons-csv
+ 1.10.0
+
gr.cite
validation
diff --git a/dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java b/dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java
index cefd68566..65c223b82 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java
@@ -67,4 +67,13 @@ public class AuditableAction {
public static final EventId ReferenceType_Persist = new EventId(10002, "ReferenceType_Persist");
public static final EventId ReferenceType_Delete = new EventId(10003, "ReferenceType_Delete");
+ public static final EventId User_Query = new EventId(11000, "User_Query");
+ public static final EventId User_Lookup = new EventId(11001, "User_Lookup");
+ public static final EventId User_Persist = new EventId(11002, "User_Persist");
+ public static final EventId User_Delete = new EventId(11003, "User_Delete");
+ public static final EventId User_LookupByEmail = new EventId(11004, "User_LookupByEmail");
+ public static final EventId User_ExportCsv = new EventId(11005, "User_ExportCsv");
+ public static final EventId User_PersistRoles = new EventId(11004, "User_PersistRoles");
+
+
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java b/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java
index bd2b828c1..f4bbb3950 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java
@@ -47,6 +47,7 @@ public final class Permission {
public static String BrowseUser = "BrowseUser";
public static String EditUser = "EditUser";
public static String DeleteUser = "DeleteUser";
+ public static String ExportUsers = "ExportUsers";
//DescriptionTemplateType
public static String BrowseDescriptionTemplateType = "BrowseDescriptionTemplateType";
diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/user/AdditionalInfoEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/user/AdditionalInfoEntity.java
index fd45eb24b..fdffd0844 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/user/AdditionalInfoEntity.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/user/AdditionalInfoEntity.java
@@ -1,10 +1,14 @@
package eu.eudat.commons.types.user;
+import java.util.UUID;
+
public class AdditionalInfoEntity {
private String avatarUrl;
private String timezone;
private String culture;
private String language;
+ private String roleOrganization;
+ private UUID organizationId;
public String getAvatarUrl() {
return avatarUrl;
@@ -37,4 +41,20 @@ public class AdditionalInfoEntity {
public void setLanguage(String language) {
this.language = language;
}
+
+ public UUID getOrganizationId() {
+ return organizationId;
+ }
+
+ public void setOrganizationId(UUID organizationId) {
+ this.organizationId = organizationId;
+ }
+
+ public String getRoleOrganization() {
+ return roleOrganization;
+ }
+
+ public void setRoleOrganization(String roleOrganization) {
+ this.roleOrganization = roleOrganization;
+ }
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/DmpEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/DmpEntity.java
index 4c9e03fb0..aad5171ee 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/data/DmpEntity.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/data/DmpEntity.java
@@ -86,9 +86,9 @@ public class DmpEntity implements DataEntity {
public static final String _finalizedAt = "finalizedAt";
@Column(name = "creator")
- private UUID creator;
+ private UUID creatorId;
- public static final String _creator = "creator";
+ public static final String _creatorId = "creatorId";
@Column(name = "access_type", nullable = false)
@Convert(converter = DmpAccessTypeConverter.class)
@@ -97,9 +97,9 @@ public class DmpEntity implements DataEntity {
public static final String _accessType = "accessType";
@Column(name = "blueprint")
- private UUID blueprint;
+ private UUID blueprintId;
- public static final String _blueprint = "blueprint";
+ public static final String _blueprintId = "blueprintId";
@Column(name = "language")
private String language;
@@ -199,12 +199,12 @@ public class DmpEntity implements DataEntity {
this.finalizedAt = finalizedAt;
}
- public UUID getCreator() {
- return creator;
+ public UUID getCreatorId() {
+ return creatorId;
}
- public void setCreator(UUID creator) {
- this.creator = creator;
+ public void setCreatorId(UUID creatorId) {
+ this.creatorId = creatorId;
}
public DmpAccessType getAccessType() {
@@ -215,12 +215,12 @@ public class DmpEntity implements DataEntity {
this.accessType = accessType;
}
- public UUID getBlueprint() {
- return blueprint;
+ public UUID getBlueprintId() {
+ return blueprintId;
}
- public void setBlueprint(UUID blueprint) {
- this.blueprint = blueprint;
+ public void setBlueprintId(UUID blueprintId) {
+ this.blueprintId = blueprintId;
}
public String getLanguage() {
diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/DmpUserEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/DmpUserEntity.java
index f1ae5c75b..1ed6aa352 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/data/DmpUserEntity.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/data/DmpUserEntity.java
@@ -27,9 +27,9 @@ public class DmpUserEntity implements DataEntity {
public static final String _dmp = "dmp";
@Column(name = "user", columnDefinition = "uuid", nullable = false)
- private UUID user;
+ private UUID userId;
- public static final String _user = "user";
+ public static final String _userId = "userId";
@Column(name = "role", nullable = false)
@Convert(converter = DmpUserRoleConverter.class)
@@ -69,12 +69,12 @@ public class DmpUserEntity implements DataEntity {
this.dmp = dmp;
}
- public UUID getUser() {
- return user;
+ public UUID getUserId() {
+ return userId;
}
- public void setUser(UUID user) {
- this.user = user;
+ public void setUserId(UUID userId) {
+ this.userId = userId;
}
public DmpUserRole getRole() {
diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/ReferenceEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/ReferenceEntity.java
index f7e2cf4eb..7cc4e3926 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/data/ReferenceEntity.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/data/ReferenceEntity.java
@@ -68,8 +68,8 @@ public class ReferenceEntity {
public static final String _updatedAt = "updatedAt";
@Column(name = "created_by", columnDefinition = "uuid")
- private UUID createdBy;
- public static final String _createdBy = "createdBy";
+ private UUID createdById;
+ public static final String _createdById = "createdBy";
public UUID getId() {
return id;
@@ -167,11 +167,11 @@ public class ReferenceEntity {
this.updatedAt = updatedAt;
}
- public UUID getCreatedBy() {
- return createdBy;
+ public UUID getCreatedById() {
+ return createdById;
}
- public void setCreatedBy(UUID createdBy) {
- this.createdBy = createdBy;
+ public void setCreatedById(UUID createdById) {
+ this.createdById = createdById;
}
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/TagEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/TagEntity.java
index 4887c4207..ac260f81b 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/data/TagEntity.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/data/TagEntity.java
@@ -37,8 +37,8 @@ public class TagEntity {
public static final String _updatedAt = "updatedAt";
@Column(name = "\"created_by\"", nullable = false)
- private UUID createdBy;
- public static final String _createdBy = "createdBy";
+ private UUID createdById;
+ public static final String _createdById = "createdById";
public UUID getId() {
return id;
@@ -80,11 +80,11 @@ public class TagEntity {
this.updatedAt = updatedAt;
}
- public UUID getCreatedBy() {
- return createdBy;
+ public UUID getCreatedById() {
+ return createdById;
}
- public void setCreatedBy(UUID createdBy) {
- this.createdBy = createdBy;
+ public void setCreatedById(UUID createdById) {
+ this.createdById = createdById;
}
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/UserDescriptionTemplateEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/UserDescriptionTemplateEntity.java
index 41c56bd93..bcf09cf14 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/data/UserDescriptionTemplateEntity.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/data/UserDescriptionTemplateEntity.java
@@ -21,8 +21,8 @@ public class UserDescriptionTemplateEntity implements DataEntity dmpReferences;
public static final String _dmpReferences = "dmpReferences";
+ private String hash;
+ public final static String _hash = "hash";
+
public UUID getId() {
return id;
}
@@ -156,4 +159,20 @@ public class Reference {
public void setDmpReferences(List dmpReferences) {
this.dmpReferences = dmpReferences;
}
+
+ public User getCreatedBy() {
+ return createdBy;
+ }
+
+ public void setCreatedBy(User createdBy) {
+ this.createdBy = createdBy;
+ }
+
+ public String getHash() {
+ return hash;
+ }
+
+ public void setHash(String hash) {
+ this.hash = hash;
+ }
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/SupportiveMaterial.java b/dmp-backend/core/src/main/java/eu/eudat/model/SupportiveMaterial.java
index ca552da3b..34c77f0eb 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/SupportiveMaterial.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/SupportiveMaterial.java
@@ -30,6 +30,9 @@ public class SupportiveMaterial {
private IsActive isActive;
public static final String _isActive = "isActive";
+ private String hash;
+ public final static String _hash = "hash";
+
public UUID getId() {
return id;
}
@@ -85,4 +88,12 @@ public class SupportiveMaterial {
public void setIsActive(IsActive isActive) {
this.isActive = isActive;
}
+
+ public String getHash() {
+ return hash;
+ }
+
+ public void setHash(String hash) {
+ this.hash = hash;
+ }
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/Tag.java b/dmp-backend/core/src/main/java/eu/eudat/model/Tag.java
index 43bab127f..bea557327 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/Tag.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/Tag.java
@@ -17,7 +17,7 @@ public class Tag {
public static final String _label = "label";
- private UUID createdBy;
+ private User createdBy;
public static final String _createdBy = "createdBy";
@@ -53,11 +53,11 @@ public class Tag {
this.label = label;
}
- public UUID getCreatedBy() {
+ public User getCreatedBy() {
return createdBy;
}
- public void setCreatedBy(UUID createdBy) {
+ public void setCreatedBy(User createdBy) {
this.createdBy = createdBy;
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/UserAdditionalInfo.java b/dmp-backend/core/src/main/java/eu/eudat/model/UserAdditionalInfo.java
index c9a1d7128..5ac898b80 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/UserAdditionalInfo.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/UserAdditionalInfo.java
@@ -17,6 +17,12 @@ public class UserAdditionalInfo {
private String language;
public static final String _language = "language";
+
+ private String roleOrganization;
+ public static final String _roleOrganization = "roleOrganization";
+
+ private Reference organization;
+ public static final String _organization = "organization";
public String getAvatarUrl() {
return avatarUrl;
@@ -49,4 +55,20 @@ public class UserAdditionalInfo {
public void setLanguage(String language) {
this.language = language;
}
+
+ public String getRoleOrganization() {
+ return roleOrganization;
+ }
+
+ public void setRoleOrganization(String roleOrganization) {
+ this.roleOrganization = roleOrganization;
+ }
+
+ public Reference getOrganization() {
+ return organization;
+ }
+
+ public void setOrganization(Reference organization) {
+ this.organization = organization;
+ }
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/UserDescriptionTemplate.java b/dmp-backend/core/src/main/java/eu/eudat/model/UserDescriptionTemplate.java
index 09a345a1f..b5df816d2 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/UserDescriptionTemplate.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/UserDescriptionTemplate.java
@@ -15,9 +15,13 @@ public class UserDescriptionTemplate {
public final static String _descriptionTemplate = "descriptionTemplate";
private DescriptionTemplate descriptionTemplate;
+
public final static String _role = "role";
private UserDescriptionTemplateRole role;
+ public final static String _user = "user";
+ private User user;
+
public final static String _createdAt = "createdAt";
private Instant createdAt;
@@ -85,4 +89,12 @@ public class UserDescriptionTemplate {
public void setHash(String hash) {
this.hash = hash;
}
+
+ public User getUser() {
+ return user;
+ }
+
+ public void setUser(User user) {
+ this.user = user;
+ }
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionBuilder.java
index 5f2fe8611..e7d5d83bc 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionBuilder.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionBuilder.java
@@ -3,9 +3,9 @@ package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.JsonHandlingService;
import eu.eudat.commons.types.description.PropertyDefinitionEntity;
-import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.DescriptionEntity;
+import eu.eudat.data.UserRoleEntity;
import eu.eudat.model.*;
import eu.eudat.model.builder.descriptionpropertiesdefinition.PropertyDefinitionBuilder;
import eu.eudat.query.*;
@@ -71,6 +71,9 @@ public class DescriptionBuilder extends BaseBuilder> descriptionTagsMap = this.collectDescriptionTags(descriptionTagsFields, data);
+ FieldSet userFields = fields.extractPrefixed(this.asPrefix(Description._createdBy));
+ Map userItemsMap = this.collectUsers(userFields, data);
+
FieldSet definitionPropertiesFields = fields.extractPrefixed(this.asPrefix(Description._properties));
List models = new ArrayList<>();
for (DescriptionEntity d : data) {
@@ -79,7 +82,6 @@ public class DescriptionBuilder extends BaseBuilder collectUsers(FieldSet fields, List data) throws MyApplicationException {
+ if (fields.isEmpty() || data.isEmpty())
+ return null;
+ this.logger.debug("checking related - {}", User.class.getSimpleName());
+
+ Map itemMap;
+ if (!fields.hasOtherField(this.asIndexer(User._id))) {
+ itemMap = this.asEmpty(
+ data.stream().map(DescriptionEntity::getCreatedById).distinct().collect(Collectors.toList()),
+ x -> {
+ User item = new User();
+ item.setId(x);
+ return item;
+ },
+ User::getId);
+ } else {
+ FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(User._id);
+ UserQuery q = this.queryFactory.query(UserQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getCreatedById).distinct().collect(Collectors.toList()));
+ itemMap = this.builderFactory.builder(UserBuilder.class).authorize(this.authorize).asForeignKey(q, clone, User::getId);
+ }
+ if (!fields.hasField(User._id)) {
+ itemMap.forEach((id, item) -> {
+ if (item != null)
+ item.setId(null);
+ });
+ }
+
+ return itemMap;
+ }
+
private Map collectDmpDescriptionTemplates(FieldSet fields, List data) throws MyApplicationException {
if (fields.isEmpty() || data.isEmpty())
return null;
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionReferenceBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionReferenceBuilder.java
index 5c5b5d021..4fa6bc883 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionReferenceBuilder.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionReferenceBuilder.java
@@ -65,22 +65,13 @@ public class DescriptionReferenceBuilder extends BaseBuilder();
- FieldSet referenceFields = fields.extractPrefixed(this.asPrefix(DescriptionTag._tag));
- Map referenceItemsMap = this.collectTags(referenceFields, data);
+ FieldSet tagFields = fields.extractPrefixed(this.asPrefix(DescriptionTag._tag));
+ Map tagItemsMap = this.collectTags(tagFields, data);
FieldSet descriptionFields = fields.extractPrefixed(this.asPrefix(DescriptionTag._description));
Map descriptionItemsMap = this.collectDescriptions(descriptionFields, data);
@@ -69,7 +69,8 @@ public class DescriptionTagBuilder extends BaseBuilder {
FieldSet dmpUsersFields = fields.extractPrefixed(this.asPrefix(Dmp._dmpUsers));
Map> dmpUsersMap = this.collectDmpUsers(dmpUsersFields, data);
+ FieldSet userFields = fields.extractPrefixed(this.asPrefix(Dmp._creator));
+ Map userItemsMap = this.collectUsers(userFields, data);
+
+ FieldSet blueprintFields = fields.extractPrefixed(this.asPrefix(Dmp._blueprint));
+ Map blueprintItemsMap = this.collectDmpBlueprints(blueprintFields, data);
+
for (DmpEntity d : data) {
Dmp m = new Dmp();
if (fields.hasField(this.asIndexer(Dmp._id))) m.setId(d.getId());
@@ -76,11 +83,12 @@ public class DmpBuilder extends BaseBuilder {
if (fields.hasField(this.asIndexer(Dmp._isActive))) m.setIsActive(d.getIsActive());
if (fields.hasField(this.asIndexer(Dmp._finalizedAt))) m.setFinalizedAt(d.getFinalizedAt());
if (fields.hasField(this.asIndexer(Dmp._accessType))) m.setAccessType(d.getAccessType());
- if (fields.hasField(this.asIndexer(Dmp._blueprint))) m.setBlueprint(d.getBlueprint());
if (fields.hasField(this.asIndexer(Dmp._language))) m.setLanguage(d.getLanguage());
if (fields.hasField(this.asIndexer(Dmp._versionStatus))) m.setVersionStatus(d.getVersionStatus());
if (fields.hasField(this.asIndexer(Dmp._publicAfter))) m.setPublicAfter(d.getPublicAfter());
if (fields.hasField(this.asIndexer(Dmp._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
+ if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getCreatorId())) m.setCreator(userItemsMap.get(d.getCreatorId()));
+ if (!blueprintFields.isEmpty() && blueprintItemsMap != null && blueprintItemsMap.containsKey(d.getBlueprintId())) m.setBlueprint(blueprintItemsMap.get(d.getBlueprintId()));
if (dmpReferencesMap != null && !dmpReferencesMap.isEmpty() && dmpReferencesMap.containsKey(d.getId())) m.setDmpReferences(dmpReferencesMap.get(d.getId()));
if (dmpUsersMap != null && !dmpUsersMap.isEmpty() && dmpUsersMap.containsKey(d.getId())) m.setDmpUsers(dmpUsersMap.get(d.getId()));
@@ -108,6 +116,66 @@ public class DmpBuilder extends BaseBuilder {
return itemMap;
}
+
+ private Map collectDmpBlueprints(FieldSet fields, List data) throws MyApplicationException {
+ if (fields.isEmpty() || data.isEmpty())
+ return null;
+ this.logger.debug("checking related - {}", DmpBlueprint.class.getSimpleName());
+
+ Map itemMap;
+ if (!fields.hasOtherField(this.asIndexer(DmpBlueprint._id))) {
+ itemMap = this.asEmpty(
+ data.stream().map(DmpEntity::getBlueprintId).distinct().collect(Collectors.toList()),
+ x -> {
+ DmpBlueprint item = new DmpBlueprint();
+ item.setId(x);
+ return item;
+ },
+ DmpBlueprint::getId);
+ } else {
+ FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(DmpBlueprint._id);
+ DmpBlueprintQuery q = this.queryFactory.query(DmpBlueprintQuery.class).authorize(this.authorize).ids(data.stream().map(DmpEntity::getBlueprintId).distinct().collect(Collectors.toList()));
+ itemMap = this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(this.authorize).asForeignKey(q, clone, DmpBlueprint::getId);
+ }
+ if (!fields.hasField(DmpBlueprint._id)) {
+ itemMap.forEach((id, item) -> {
+ if (item != null)
+ item.setId(null);
+ });
+ }
+
+ return itemMap;
+ }
+
+ private Map collectUsers(FieldSet fields, List data) throws MyApplicationException {
+ if (fields.isEmpty() || data.isEmpty())
+ return null;
+ this.logger.debug("checking related - {}", User.class.getSimpleName());
+
+ Map itemMap;
+ if (!fields.hasOtherField(this.asIndexer(User._id))) {
+ itemMap = this.asEmpty(
+ data.stream().map(DmpEntity::getCreatorId).distinct().collect(Collectors.toList()),
+ x -> {
+ User item = new User();
+ item.setId(x);
+ return item;
+ },
+ User::getId);
+ } else {
+ FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(User._id);
+ UserQuery q = this.queryFactory.query(UserQuery.class).authorize(this.authorize).ids(data.stream().map(DmpEntity::getCreatorId).distinct().collect(Collectors.toList()));
+ itemMap = this.builderFactory.builder(UserBuilder.class).authorize(this.authorize).asForeignKey(q, clone, User::getId);
+ }
+ if (!fields.hasField(User._id)) {
+ itemMap.forEach((id, item) -> {
+ if (item != null)
+ item.setId(null);
+ });
+ }
+
+ return itemMap;
+ }
private Map> collectDmpUsers(FieldSet fields, List data) throws MyApplicationException {
if (fields.isEmpty() || data.isEmpty())
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpDescriptionTemplateBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpDescriptionTemplateBuilder.java
index fdae05e29..067ccdbf3 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpDescriptionTemplateBuilder.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpDescriptionTemplateBuilder.java
@@ -62,20 +62,13 @@ public class DmpDescriptionTemplateBuilder extends BaseBuilder models = new ArrayList<>();
for (DmpDescriptionTemplateEntity d : data) {
DmpDescriptionTemplate m = new DmpDescriptionTemplate();
- if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._id)))
- m.setId(d.getId());
- if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._sectionId)))
- m.setSectionId(d.getSectionId());
- if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._createdAt)))
- m.setCreatedAt(d.getCreatedAt());
- if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._updatedAt)))
- m.setUpdatedAt(d.getUpdatedAt());
- if (!templateFields.isEmpty() && templateItemsMap != null && templateItemsMap.containsKey(d.getDescriptionTemplateId())) {
- m.setDescriptionTemplate(templateItemsMap.get(d.getDescriptionTemplateId()));
- }
- if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) {
- m.setDmp(dmpItemsMap.get(d.getDmpId()));
- }
+ if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._id))) m.setId(d.getId());
+ if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._sectionId))) m.setSectionId(d.getSectionId());
+ if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._createdAt))) m.setCreatedAt(d.getCreatedAt());
+ if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
+ if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
+ if (!templateFields.isEmpty() && templateItemsMap != null && templateItemsMap.containsKey(d.getDescriptionTemplateId())) m.setDescriptionTemplate(templateItemsMap.get(d.getDescriptionTemplateId()));
+ if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) m.setDmp(dmpItemsMap.get(d.getDmpId()));
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpReferenceBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpReferenceBuilder.java
index 67f1f44d0..0c8f70963 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpReferenceBuilder.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpReferenceBuilder.java
@@ -4,6 +4,7 @@ import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.DmpReferenceEntity;
import eu.eudat.model.Dmp;
+import eu.eudat.model.DmpDescriptionTemplate;
import eu.eudat.model.DmpReference;
import eu.eudat.model.Reference;
import eu.eudat.query.DmpQuery;
@@ -64,20 +65,13 @@ public class DmpReferenceBuilder extends BaseBuilder models = new ArrayList<>();
for (DmpReferenceEntity d : data) {
DmpReference m = new DmpReference();
- if (fields.hasField(this.asIndexer(DmpReference._id)))
- m.setId(d.getId());
- if (fields.hasField(this.asIndexer(DmpReference._data)))
- m.setData(d.getData());
- if (fields.hasField(this.asIndexer(DmpReference._createdAt)))
- m.setCreatedAt(d.getCreatedAt());
- if (fields.hasField(this.asIndexer(DmpReference._updatedAt)))
- m.setUpdatedAt(d.getUpdatedAt());
- if (!referenceFields.isEmpty() && referenceItemsMap != null && referenceItemsMap.containsKey(d.getReferenceId())) {
- m.setReference(referenceItemsMap.get(d.getReferenceId()));
- }
- if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) {
- m.setDmp(dmpItemsMap.get(d.getDmpId()));
- }
+ if (fields.hasField(this.asIndexer(DmpReference._id))) m.setId(d.getId());
+ if (fields.hasField(this.asIndexer(DmpReference._data))) m.setData(d.getData());
+ if (fields.hasField(this.asIndexer(DmpReference._createdAt))) m.setCreatedAt(d.getCreatedAt());
+ if (fields.hasField(this.asIndexer(DmpReference._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
+ if (fields.hasField(this.asIndexer(DmpReference._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
+ if (!referenceFields.isEmpty() && referenceItemsMap != null && referenceItemsMap.containsKey(d.getReferenceId())) m.setReference(referenceItemsMap.get(d.getReferenceId()));
+ if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) m.setDmp(dmpItemsMap.get(d.getDmpId()));
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpUserBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpUserBuilder.java
index 270d3b622..33fc490a0 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpUserBuilder.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpUserBuilder.java
@@ -2,12 +2,11 @@ package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.convention.ConventionService;
+import eu.eudat.data.DescriptionEntity;
import eu.eudat.data.DmpUserEntity;
-import eu.eudat.data.UserEntity;
-import eu.eudat.model.Dmp;
-import eu.eudat.model.DmpUser;
-import eu.eudat.model.Reference;
+import eu.eudat.model.*;
import eu.eudat.query.DmpQuery;
+import eu.eudat.query.UserQuery;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
@@ -55,62 +54,57 @@ public class DmpUserBuilder extends BaseBuilder{
if (fields == null || data == null || fields.isEmpty())
return new ArrayList<>();
- FieldSet userFields = fields.extractPrefixed(this.asPrefix(DmpUser._user));
- Map userItemsMap = this.collectUsers(userFields, data);
-
FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(DmpUser._dmp));
Map dmpItemsMap = this.collectDmps(dmpFields, data);
+ FieldSet userFields = fields.extractPrefixed(this.asPrefix(DmpUser._user));
+ Map userItemsMap = this.collectUsers(userFields, data);
+
List models = new ArrayList<>();
for (DmpUserEntity d : data) {
DmpUser m = new DmpUser();
- if (fields.hasField(this.asIndexer(DmpUser._id)))
- m.setId(d.getId());
- if (fields.hasField(this.asIndexer(DmpUser._role)))
- m.setRole(d.getRole());
- if (fields.hasField(this.asIndexer(DmpUser._createdAt)))
- m.setCreatedAt(d.getCreatedAt());
- if (fields.hasField(this.asIndexer(DmpUser._updatedAt)))
- m.setUpdatedAt(d.getUpdatedAt());
- if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getUser())) {
- m.setUser(userItemsMap.get(d.getUser()));
- }
- if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmp())) {
- m.setDmp(dmpItemsMap.get(d.getDmp()));
- }
+ if (fields.hasField(this.asIndexer(DmpUser._id))) m.setId(d.getId());
+ if (fields.hasField(this.asIndexer(DmpUser._role))) m.setRole(d.getRole());
+ if (fields.hasField(this.asIndexer(DmpUser._createdAt))) m.setCreatedAt(d.getCreatedAt());
+ if (fields.hasField(this.asIndexer(DmpUser._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
+ if (fields.hasField(this.asIndexer(DmpReference._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
+ if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId()));
+ if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmp())) m.setDmp(dmpItemsMap.get(d.getDmp()));
+ if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId()));
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
- //TODO: Hookup user info when refactored
- private Map collectUsers(FieldSet fields, List data) throws MyApplicationException {
+ private Map collectUsers(FieldSet fields, List data) throws MyApplicationException {
if (fields.isEmpty() || data.isEmpty())
return null;
- this.logger.debug("checking related - {}", UserEntity.class.getSimpleName());
+ this.logger.debug("checking related - {}", User.class.getSimpleName());
- Map itemMap;
- if (!fields.hasOtherField(this.asIndexer("id"))) {
+ Map itemMap;
+ if (!fields.hasOtherField(this.asIndexer(User._id))) {
itemMap = this.asEmpty(
- data.stream().map(DmpUserEntity::getUser).distinct().collect(Collectors.toList()),
+ data.stream().map(DmpUserEntity::getUserId).distinct().collect(Collectors.toList()),
x -> {
- UserEntity item = new UserEntity();
+ User item = new User();
item.setId(x);
return item;
},
- UserEntity::getId);
+ User::getId);
} else {
- FieldSet clone = new BaseFieldSet(fields.getFields()).ensure("id");
-// ReferenceQuery q = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).ids(data.stream().map(DmpReferenceEntity::getReferenceId).distinct().collect(Collectors.toList()));
-// itemMap = this.builderFactory.builder(ReferenceBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Reference::getId);
+ FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(User._id);
+ UserQuery q = this.queryFactory.query(UserQuery.class).authorize(this.authorize).ids(data.stream().map(DmpUserEntity::getUserId).distinct().collect(Collectors.toList()));
+ itemMap = this.builderFactory.builder(UserBuilder.class).authorize(this.authorize).asForeignKey(q, clone, User::getId);
}
- if (!fields.hasField(Reference._id)) {
-// itemMap.values().stream().filter(Objects::nonNull).peek(x -> x.setId(null)).collect(Collectors.toList());
+ if (!fields.hasField(User._id)) {
+ itemMap.forEach((id, item) -> {
+ if (item != null)
+ item.setId(null);
+ });
}
-// return itemMap;
- return new HashMap<>();
+ return itemMap;
}
private Map collectDmps(FieldSet fields, List data) throws MyApplicationException {
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/PublicDmpUserBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/PublicDmpUserBuilder.java
index 971ff2c48..2f6029118 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/PublicDmpUserBuilder.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/PublicDmpUserBuilder.java
@@ -3,10 +3,13 @@ package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.DmpUserEntity;
+import eu.eudat.data.UserRoleEntity;
import eu.eudat.model.PublicDmp;
import eu.eudat.model.PublicDmpUser;
import eu.eudat.model.PublicUser;
+import eu.eudat.model.User;
import eu.eudat.query.DmpQuery;
+import eu.eudat.query.UserQuery;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
@@ -55,7 +58,7 @@ public class PublicDmpUserBuilder extends BaseBuilder();
FieldSet userFields = fields.extractPrefixed(this.asPrefix(PublicDmpUser._user));
- Map userItemsMap = new HashMap<>(); //TODO
+ Map userItemsMap = this.collectUsers(userFields, data);
FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(PublicDmpUser._dmp));
Map dmpItemsMap = this.collectDmps(dmpFields, data);
@@ -65,7 +68,7 @@ public class PublicDmpUserBuilder extends BaseBuilder collectUsers(FieldSet fields, List data) throws MyApplicationException {
+ if (fields.isEmpty() || data.isEmpty())
+ return null;
+ this.logger.debug("checking related - {}", User.class.getSimpleName());
+
+ Map itemMap;
+ if (!fields.hasOtherField(this.asIndexer(User._id))) {
+ itemMap = this.asEmpty(
+ data.stream().map(DmpUserEntity::getUserId).distinct().collect(Collectors.toList()),
+ x -> {
+ PublicUser item = new PublicUser();
+ item.setId(x);
+ return item;
+ },
+ PublicUser::getId);
+ } else {
+ FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(User._id);
+ UserQuery q = this.queryFactory.query(UserQuery.class).authorize(this.authorize).ids(data.stream().map(DmpUserEntity::getUserId).distinct().collect(Collectors.toList()));
+ itemMap = this.builderFactory.builder(PublicUserBuilder.class).authorize(this.authorize).asForeignKey(q, clone, PublicUser::getId);
+ }
+ if (!fields.hasField(User._id)) {
+ itemMap.forEach((id, item) -> {
+ if (item != null)
+ item.setId(null);
+ });
+ }
+
+ return itemMap;
+ }
+
private Map collectDmps(FieldSet fields, List data) throws MyApplicationException {
if (fields.isEmpty() || data.isEmpty())
return null;
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/PublicUserBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/PublicUserBuilder.java
index cbfa0f136..afabc7313 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/PublicUserBuilder.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/PublicUserBuilder.java
@@ -1,18 +1,11 @@
package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags;
-import eu.eudat.commons.JsonHandlingService;
-import eu.eudat.commons.types.user.AdditionalInfoEntity;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.UserEntity;
-import eu.eudat.model.*;
-import eu.eudat.query.UserContactInfoQuery;
-import eu.eudat.query.UserCredentialQuery;
-import eu.eudat.query.UserRoleQuery;
-import gr.cite.tools.data.builder.BuilderFactory;
-import gr.cite.tools.data.query.QueryFactory;
+import eu.eudat.model.PublicUser;
+import eu.eudat.model.User;
import gr.cite.tools.exception.MyApplicationException;
-import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
@@ -23,68 +16,37 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.*;
-import java.util.stream.Collectors;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class UserBuilder extends BaseBuilder {
-
- private final QueryFactory queryFactory;
-
- private final BuilderFactory builderFactory;
- private final JsonHandlingService jsonHandlingService;
+public class PublicUserBuilder extends BaseBuilder {
private EnumSet authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
- public UserBuilder(ConventionService conventionService,
- QueryFactory queryFactory,
- BuilderFactory builderFactory, JsonHandlingService jsonHandlingService) {
- super(conventionService, new LoggerService(LoggerFactory.getLogger(UserBuilder.class)));
- this.queryFactory = queryFactory;
- this.builderFactory = builderFactory;
- this.jsonHandlingService = jsonHandlingService;
+ public PublicUserBuilder(ConventionService conventionService
+ ) {
+ super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicUserBuilder.class)));
}
- public UserBuilder authorize(EnumSet values) {
+ public PublicUserBuilder authorize(EnumSet values) {
this.authorize = values;
return this;
}
@Override
- public List build(FieldSet fields, List data) throws MyApplicationException {
+ public List build(FieldSet fields, List 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 models = new ArrayList<>();
+ List models = new ArrayList<>();
- FieldSet contactsFields = fields.extractPrefixed(this.asPrefix(User._contacts));
- Map> contactsMap = this.collectUserContactInfos(contactsFields, data);
-
- FieldSet rolesFields = fields.extractPrefixed(this.asPrefix(User._roles));
- Map> rolesMap = this.collectUserRoles(rolesFields, data);
-
- FieldSet credentialsFields = fields.extractPrefixed(this.asPrefix(User._credentials));
- Map> credentialsMap = this.collectUserCredentials(credentialsFields, data);
-
- FieldSet additionalInfoFields = fields.extractPrefixed(this.asPrefix(User._additionalInfo));
for (UserEntity d : data) {
- User m = new User();
+ PublicUser m = new PublicUser();
if (fields.hasField(this.asIndexer(User._id))) m.setId(d.getId());
if (fields.hasField(this.asIndexer(User._name))) m.setName(d.getName());
- if (fields.hasField(this.asIndexer(User._createdAt))) m.setCreatedAt(d.getCreatedAt());
- if (fields.hasField(this.asIndexer(User._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
- if (fields.hasField(this.asIndexer(User._isActive))) m.setIsActive(d.getIsActive());
- if (fields.hasField(this.asIndexer(User._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
- if (contactsMap != null && !contactsFields.isEmpty() && contactsMap.containsKey(d.getId())) m.setContacts(contactsMap.get(d.getId()));
- if (rolesMap != null && !rolesFields.isEmpty() && rolesMap.containsKey(d.getId())) m.setRoles(rolesMap.get(d.getId()));
- if (credentialsMap != null && !credentialsFields.isEmpty() && credentialsMap.containsKey(d.getId())) m.setCredentials(credentialsMap.get(d.getId()));
- if (!additionalInfoFields.isEmpty() && d.getAdditionalInfo() != null){
- AdditionalInfoEntity definition = this.jsonHandlingService.fromJsonSafe(AdditionalInfoEntity.class, d.getAdditionalInfo());
- m.setAdditionalInfo(this.builderFactory.builder(UserAdditionalInfoBuilder.class).authorize(this.authorize).build(additionalInfoFields, definition));
- }
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
@@ -92,58 +54,4 @@ public class UserBuilder extends BaseBuilder {
return models;
}
- private Map> collectUserContactInfos(FieldSet fields, List data) throws MyApplicationException {
- if (fields.isEmpty() || data.isEmpty()) return null;
- this.logger.debug("checking related - {}", UserContactInfo.class.getSimpleName());
-
- Map> itemMap;
- FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(UserContactInfo._user, User._id));
- UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).authorize(this.authorize).userIds(data.stream().map(UserEntity::getId).distinct().collect(Collectors.toList()));
- itemMap = this.builderFactory.builder(UserContactInfoBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getUser().getId());
-
- if (!fields.hasField(this.asIndexer(UserContactInfo._user, User._id))) {
- itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getUser() != null).peek(x -> {
- x.getUser().setId(null);
- });
- }
-
- return itemMap;
- }
-
- private Map> collectUserRoles(FieldSet fields, List data) throws MyApplicationException {
- if (fields.isEmpty() || data.isEmpty()) return null;
- this.logger.debug("checking related - {}", UserRole.class.getSimpleName());
-
- Map> itemMap;
- FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(UserRole._user, User._id));
- UserRoleQuery query = this.queryFactory.query(UserRoleQuery.class).authorize(this.authorize).userIds(data.stream().map(UserEntity::getId).distinct().collect(Collectors.toList()));
- itemMap = this.builderFactory.builder(UserRoleBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getUser().getId());
-
- if (!fields.hasField(this.asIndexer(UserRole._user, User._id))) {
- itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getUser() != null).peek(x -> {
- x.getUser().setId(null);
- });
- }
-
- return itemMap;
- }
-
- private Map> collectUserCredentials(FieldSet fields, List data) throws MyApplicationException {
- if (fields.isEmpty() || data.isEmpty()) return null;
- this.logger.debug("checking related - {}", UserCredential.class.getSimpleName());
-
- Map> itemMap;
- FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(UserCredential._user, User._id));
- UserCredentialQuery query = this.queryFactory.query(UserCredentialQuery.class).authorize(this.authorize).userIds(data.stream().map(UserEntity::getId).distinct().collect(Collectors.toList()));
- itemMap = this.builderFactory.builder(UserCredentialBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getUser().getId());
-
- if (!fields.hasField(this.asIndexer(UserCredential._user, User._id))) {
- itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getUser() != null).peek(x -> {
- x.getUser().setId(null);
- });
- }
-
- return itemMap;
- }
-
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/ReferenceBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/ReferenceBuilder.java
index d329512ce..2174e6ed3 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/ReferenceBuilder.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/ReferenceBuilder.java
@@ -4,11 +4,14 @@ import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.XmlHandlingService;
import eu.eudat.commons.types.reference.DefinitionEntity;
import eu.eudat.convention.ConventionService;
+import eu.eudat.data.DescriptionEntity;
import eu.eudat.data.ReferenceEntity;
import eu.eudat.model.DmpReference;
import eu.eudat.model.Reference;
+import eu.eudat.model.User;
import eu.eudat.model.builder.referencedefinition.DefinitionBuilder;
import eu.eudat.query.DmpReferenceQuery;
+import eu.eudat.query.UserQuery;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
@@ -62,6 +65,9 @@ public class ReferenceBuilder extends BaseBuilder{
FieldSet dmpReferencesFields = fields.extractPrefixed(this.asPrefix(Reference._dmpReferences));
Map> dmpReferenceMap = this.collectDmpReferences(dmpReferencesFields, data);
+ FieldSet userFields = fields.extractPrefixed(this.asPrefix(Reference._createdBy));
+ Map userItemsMap = this.collectUsers(userFields, data);
+
List models = new ArrayList<>();
for (ReferenceEntity d : data) {
Reference m = new Reference();
@@ -70,6 +76,7 @@ public class ReferenceBuilder extends BaseBuilder{
if (fields.hasField(this.asIndexer(Reference._createdAt))) m.setCreatedAt(d.getCreatedAt());
if (fields.hasField(this.asIndexer(Reference._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(Reference._isActive))) m.setIsActive(d.getIsActive());
+ if (fields.hasField(this.asIndexer(Reference._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
if (!definitionFields.isEmpty() && d.getDefinition() != null){
DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, d.getDefinition());
m.setDefinition(this.builderFactory.builder(DefinitionBuilder.class).authorize(this.authorize).build(definitionFields, definition));
@@ -80,16 +87,44 @@ public class ReferenceBuilder extends BaseBuilder{
if (fields.hasField(this.asIndexer(Reference._source))) m.setSource(d.getSource());
if (fields.hasField(this.asIndexer(Reference._sourceType))) m.setSourceType(d.getSourceType());
if (fields.hasField(this.asIndexer(Reference._type))) m.setType(d.getType());
-// if (!userInfoFields.isEmpty() && d.getCreatedBy() != null){
-// //ToDo
-// }
- if (!dmpReferenceMap.isEmpty() && dmpReferenceMap != null && dmpReferenceMap.containsKey(d.getId())) m.setDmpReferences(dmpReferenceMap.get(d.getId()));
+ if (dmpReferenceMap != null && !dmpReferenceMap.isEmpty() && dmpReferenceMap.containsKey(d.getId())) m.setDmpReferences(dmpReferenceMap.get(d.getId()));
+ if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getCreatedById())) m.setCreatedBy(userItemsMap.get(d.getCreatedById()));
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
+ private Map collectUsers(FieldSet fields, List data) throws MyApplicationException {
+ if (fields.isEmpty() || data.isEmpty())
+ return null;
+ this.logger.debug("checking related - {}", User.class.getSimpleName());
+
+ Map itemMap;
+ if (!fields.hasOtherField(this.asIndexer(User._id))) {
+ itemMap = this.asEmpty(
+ data.stream().map(ReferenceEntity::getCreatedById).distinct().collect(Collectors.toList()),
+ x -> {
+ User item = new User();
+ item.setId(x);
+ return item;
+ },
+ User::getId);
+ } else {
+ FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(User._id);
+ UserQuery q = this.queryFactory.query(UserQuery.class).authorize(this.authorize).ids(data.stream().map(ReferenceEntity::getCreatedById).distinct().collect(Collectors.toList()));
+ itemMap = this.builderFactory.builder(UserBuilder.class).authorize(this.authorize).asForeignKey(q, clone, User::getId);
+ }
+ if (!fields.hasField(User._id)) {
+ itemMap.forEach((id, item) -> {
+ if (item != null)
+ item.setId(null);
+ });
+ }
+
+ return itemMap;
+ }
+
private Map> collectDmpReferences(FieldSet fields, List data) throws MyApplicationException {
if (fields.isEmpty() || data.isEmpty()) return null;
this.logger.debug("checking related - {}", DmpReference.class.getSimpleName());
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/SupportiveMaterialBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/SupportiveMaterialBuilder.java
index c465cd702..b4c00042b 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/SupportiveMaterialBuilder.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/SupportiveMaterialBuilder.java
@@ -4,10 +4,7 @@ import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.DmpReferenceEntity;
import eu.eudat.data.SupportiveMaterialEntity;
-import eu.eudat.model.Dmp;
-import eu.eudat.model.DmpReference;
-import eu.eudat.model.Reference;
-import eu.eudat.model.SupportiveMaterial;
+import eu.eudat.model.*;
import eu.eudat.query.DmpQuery;
import eu.eudat.query.ReferenceQuery;
import gr.cite.tools.data.builder.BuilderFactory;
@@ -65,6 +62,7 @@ public class SupportiveMaterialBuilder extends BaseBuilder{
+ private final QueryFactory queryFactory;
+
+ private final BuilderFactory builderFactory;
private EnumSet authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
public TagBuilder(
- ConventionService conventionService) {
+ ConventionService conventionService, QueryFactory queryFactory, BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(TagBuilder.class)));
+ this.queryFactory = queryFactory;
+ this.builderFactory = builderFactory;
}
public TagBuilder authorize(EnumSet values) {
@@ -40,6 +51,9 @@ public class TagBuilder extends BaseBuilder{
if (fields == null || data == null || fields.isEmpty())
return new ArrayList<>();
+ FieldSet userFields = fields.extractPrefixed(this.asPrefix(Tag._createdBy));
+ Map userItemsMap = this.collectUsers(userFields, data);
+
List models = new ArrayList<>();
for (TagEntity d : data) {
Tag m = new Tag();
@@ -48,10 +62,40 @@ public class TagBuilder extends BaseBuilder{
if (fields.hasField(this.asIndexer(Tag._createdAt))) m.setCreatedAt(d.getCreatedAt());
if (fields.hasField(this.asIndexer(Tag._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(Tag._isActive))) m.setIsActive(d.getIsActive());
- if (fields.hasField(this.asIndexer(Tag._createdBy))) m.setCreatedBy(d.getCreatedBy());
+ if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getCreatedById())) m.setCreatedBy(userItemsMap.get(d.getCreatedById()));
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
+
+ private Map collectUsers(FieldSet fields, List data) throws MyApplicationException {
+ if (fields.isEmpty() || data.isEmpty())
+ return null;
+ this.logger.debug("checking related - {}", User.class.getSimpleName());
+
+ Map itemMap;
+ if (!fields.hasOtherField(this.asIndexer(User._id))) {
+ itemMap = this.asEmpty(
+ data.stream().map(TagEntity::getCreatedById).distinct().collect(Collectors.toList()),
+ x -> {
+ User item = new User();
+ item.setId(x);
+ return item;
+ },
+ User::getId);
+ } else {
+ FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(User._id);
+ UserQuery q = this.queryFactory.query(UserQuery.class).authorize(this.authorize).ids(data.stream().map(TagEntity::getCreatedById).distinct().collect(Collectors.toList()));
+ itemMap = this.builderFactory.builder(UserBuilder.class).authorize(this.authorize).asForeignKey(q, clone, User::getId);
+ }
+ if (!fields.hasField(User._id)) {
+ itemMap.forEach((id, item) -> {
+ if (item != null)
+ item.setId(null);
+ });
+ }
+
+ return itemMap;
+ }
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/UserAdditionalInfoBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/UserAdditionalInfoBuilder.java
index c32a85c0b..b5d0cffad 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/UserAdditionalInfoBuilder.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/UserAdditionalInfoBuilder.java
@@ -1,11 +1,13 @@
package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags;
+import eu.eudat.commons.types.user.AdditionalInfoEntity;
import eu.eudat.convention.ConventionService;
-import eu.eudat.data.UserCredentialEntity;
-import eu.eudat.model.User;
-import eu.eudat.model.UserCredential;
-import eu.eudat.query.UserQuery;
+import eu.eudat.data.DescriptionReferenceEntity;
+import eu.eudat.model.DescriptionReference;
+import eu.eudat.model.Reference;
+import eu.eudat.model.UserAdditionalInfo;
+import eu.eudat.query.ReferenceQuery;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
@@ -24,46 +26,46 @@ import java.util.stream.Collectors;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class UserCredentialBuilder extends BaseBuilder {
+public class UserAdditionalInfoBuilder extends BaseBuilder {
private final BuilderFactory builderFactory;
private final QueryFactory queryFactory;
-
private EnumSet authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
- public UserCredentialBuilder(
- ConventionService conventionService,
- BuilderFactory builderFactory, QueryFactory queryFactory) {
- super(conventionService, new LoggerService(LoggerFactory.getLogger(UserCredentialBuilder.class)));
+ public UserAdditionalInfoBuilder(
+ ConventionService conventionService, BuilderFactory builderFactory, QueryFactory queryFactory) {
+ super(conventionService, new LoggerService(LoggerFactory.getLogger(UserAdditionalInfoBuilder.class)));
this.builderFactory = builderFactory;
this.queryFactory = queryFactory;
}
- public UserCredentialBuilder authorize(EnumSet values) {
+ public UserAdditionalInfoBuilder authorize(EnumSet values) {
this.authorize = values;
return this;
}
@Override
- public List build(FieldSet fields, List data) throws MyApplicationException {
+ public List build(FieldSet fields, List data) throws MyApplicationException {
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
this.logger.trace(new DataLogEntry("requested fields", fields));
if (fields == null || data == null || fields.isEmpty())
return new ArrayList<>();
- FieldSet userFields = fields.extractPrefixed(this.asPrefix(UserCredential._user));
- Map userItemsMap = this.collectUsers(userFields, data);
+ FieldSet referenceFields = fields.extractPrefixed(this.asPrefix(DescriptionReference._reference));
+ Map referenceItemsMap = this.collectReferences(referenceFields, data);
- List models = new ArrayList<>();
+ List models = new ArrayList<>();
- for (UserCredentialEntity d : data) {
- UserCredential m = new UserCredential();
- if (fields.hasField(this.asIndexer(UserCredential._id))) m.setId(d.getId());
- if (fields.hasField(this.asIndexer(UserCredential._createdAt))) m.setCreatedAt(d.getCreatedAt());
- if (fields.hasField(this.asIndexer(UserCredential._externalId))) m.setExternalId(d.getExternalId());
- if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId()));
+ for (AdditionalInfoEntity d : data) {
+ UserAdditionalInfo m = new UserAdditionalInfo();
+ if (fields.hasField(this.asIndexer(UserAdditionalInfo._language))) m.setLanguage(d.getLanguage());
+ if (fields.hasField(this.asIndexer(UserAdditionalInfo._culture))) m.setCulture(d.getCulture());
+ if (fields.hasField(this.asIndexer(UserAdditionalInfo._avatarUrl))) m.setAvatarUrl(d.getAvatarUrl());
+ if (fields.hasField(this.asIndexer(UserAdditionalInfo._timezone))) m.setTimezone(d.getTimezone());
+ if (!referenceFields.isEmpty() && referenceItemsMap != null && referenceItemsMap.containsKey(d.getOrganizationId())) m.setOrganization(referenceItemsMap.get(d.getOrganizationId()));
+ if (fields.hasField(this.asIndexer(UserAdditionalInfo._roleOrganization))) m.setRoleOrganization(d.getRoleOrganization());
models.add(m);
}
@@ -73,27 +75,29 @@ public class UserCredentialBuilder extends BaseBuilder collectUsers(FieldSet fields, List data) throws MyApplicationException {
+
+
+ private Map collectReferences(FieldSet fields, List data) throws MyApplicationException {
if (fields.isEmpty() || data.isEmpty())
return null;
- this.logger.debug("checking related - {}", User.class.getSimpleName());
+ this.logger.debug("checking related - {}", Reference.class.getSimpleName());
- Map itemMap;
- if (!fields.hasOtherField(this.asIndexer(User._id))) {
+ Map itemMap;
+ if (!fields.hasOtherField(this.asIndexer(Reference._id))) {
itemMap = this.asEmpty(
- data.stream().map(UserCredentialEntity::getUserId).distinct().collect(Collectors.toList()),
+ data.stream().map(AdditionalInfoEntity::getOrganizationId).filter(Objects::nonNull).distinct().collect(Collectors.toList()),
x -> {
- User item = new User();
+ Reference item = new Reference();
item.setId(x);
return item;
},
- User::getId);
+ Reference::getId);
} else {
- FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(User._id);
- UserQuery q = this.queryFactory.query(UserQuery.class).authorize(this.authorize).ids(data.stream().map(UserCredentialEntity::getUserId).distinct().collect(Collectors.toList()));
- itemMap = this.builderFactory.builder(UserBuilder.class).authorize(this.authorize).asForeignKey(q, clone, User::getId);
+ FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Reference._id);
+ ReferenceQuery q = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).ids(data.stream().map(AdditionalInfoEntity::getOrganizationId).filter(Objects::nonNull).distinct().collect(Collectors.toList()));
+ itemMap = this.builderFactory.builder(ReferenceBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Reference::getId);
}
- if (!fields.hasField(User._id)) {
+ if (!fields.hasField(Reference._id)) {
itemMap.forEach((id, item) -> {
if (item != null)
item.setId(null);
@@ -102,5 +106,4 @@ public class UserCredentialBuilder extends BaseBuilder {
+public class UserBuilder extends BaseBuilder {
private final QueryFactory queryFactory;
private final BuilderFactory builderFactory;
+ private final JsonHandlingService jsonHandlingService;
private EnumSet authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
- public DmpBuilder(ConventionService conventionService,
- QueryFactory queryFactory,
- BuilderFactory builderFactory) {
- super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpBuilder.class)));
+ public UserBuilder(ConventionService conventionService,
+ QueryFactory queryFactory,
+ BuilderFactory builderFactory, JsonHandlingService jsonHandlingService) {
+ super(conventionService, new LoggerService(LoggerFactory.getLogger(UserBuilder.class)));
this.queryFactory = queryFactory;
this.builderFactory = builderFactory;
+ this.jsonHandlingService = jsonHandlingService;
}
- public DmpBuilder authorize(EnumSet values) {
+ public UserBuilder authorize(EnumSet values) {
this.authorize = values;
return this;
}
@Override
- public List build(FieldSet fields, List data) throws MyApplicationException {
+ public List build(FieldSet fields, List 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 models = new ArrayList<>();
+ List models = new ArrayList<>();
- FieldSet dmpReferencesFields = fields.extractPrefixed(this.asPrefix(Dmp._dmpReferences));
- Map> dmpReferencesMap = this.collectDmpReferences(dmpReferencesFields, data);
+ FieldSet contactsFields = fields.extractPrefixed(this.asPrefix(User._contacts));
+ Map> contactsMap = this.collectUserContactInfos(contactsFields, data);
- FieldSet dmpUsersFields = fields.extractPrefixed(this.asPrefix(Dmp._dmpUsers));
- Map> dmpUsersMap = this.collectDmpUsers(dmpUsersFields, data);
+ FieldSet rolesFields = fields.extractPrefixed(this.asPrefix(User._roles));
+ Map> rolesMap = this.collectUserRoles(rolesFields, data);
- for (DmpEntity d : data) {
- Dmp m = new Dmp();
- if (fields.hasField(this.asIndexer(Dmp._id))) m.setId(d.getId());
- if (fields.hasField(this.asIndexer(Dmp._label))) m.setLabel(d.getLabel());
- if (fields.hasField(this.asIndexer(Dmp._version))) m.setVersion(d.getVersion());
- if (fields.hasField(this.asIndexer(Dmp._status))) m.setStatus(d.getStatus());
- if (fields.hasField(this.asIndexer(Dmp._properties))) m.setProperties(d.getProperties());
- if (fields.hasField(this.asIndexer(Dmp._groupId))) m.setGroupId(d.getGroupId());
- if (fields.hasField(this.asIndexer(Dmp._description))) m.setDescription(d.getDescription());
- if (fields.hasField(this.asIndexer(Dmp._createdAt))) m.setCreatedAt(d.getCreatedAt());
- if (fields.hasField(this.asIndexer(Dmp._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
- if (fields.hasField(this.asIndexer(Dmp._isActive))) m.setIsActive(d.getIsActive());
- if (fields.hasField(this.asIndexer(Dmp._finalizedAt))) m.setFinalizedAt(d.getFinalizedAt());
- if (fields.hasField(this.asIndexer(Dmp._accessType))) m.setAccessType(d.getAccessType());
- if (fields.hasField(this.asIndexer(Dmp._blueprint))) m.setBlueprint(d.getBlueprint());
- if (fields.hasField(this.asIndexer(Dmp._language))) m.setLanguage(d.getLanguage());
- if (fields.hasField(this.asIndexer(Dmp._versionStatus))) m.setVersionStatus(d.getVersionStatus());
- if (fields.hasField(this.asIndexer(Dmp._publicAfter))) m.setPublicAfter(d.getPublicAfter());
- if (fields.hasField(this.asIndexer(Dmp._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
- if (dmpReferencesMap != null && !dmpReferencesMap.isEmpty() && dmpReferencesMap.containsKey(d.getId())) m.setDmpReferences(dmpReferencesMap.get(d.getId()));
- if (dmpUsersMap != null && !dmpUsersMap.isEmpty() && dmpUsersMap.containsKey(d.getId())) m.setDmpUsers(dmpUsersMap.get(d.getId()));
+ FieldSet credentialsFields = fields.extractPrefixed(this.asPrefix(User._credentials));
+ Map> credentialsMap = this.collectUserCredentials(credentialsFields, data);
+ FieldSet additionalInfoFields = fields.extractPrefixed(this.asPrefix(User._additionalInfo));
+ for (UserEntity d : data) {
+ User m = new User();
+ if (fields.hasField(this.asIndexer(User._id))) m.setId(d.getId());
+ if (fields.hasField(this.asIndexer(User._name))) m.setName(d.getName());
+ if (fields.hasField(this.asIndexer(User._createdAt))) m.setCreatedAt(d.getCreatedAt());
+ if (fields.hasField(this.asIndexer(User._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
+ if (fields.hasField(this.asIndexer(User._isActive))) m.setIsActive(d.getIsActive());
+ if (fields.hasField(this.asIndexer(User._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
+ if (contactsMap != null && !contactsFields.isEmpty() && contactsMap.containsKey(d.getId())) m.setContacts(contactsMap.get(d.getId()));
+ if (rolesMap != null && !rolesFields.isEmpty() && rolesMap.containsKey(d.getId())) m.setRoles(rolesMap.get(d.getId()));
+ if (credentialsMap != null && !credentialsFields.isEmpty() && credentialsMap.containsKey(d.getId())) m.setCredentials(credentialsMap.get(d.getId()));
+ if (!additionalInfoFields.isEmpty() && d.getAdditionalInfo() != null){
+ AdditionalInfoEntity definition = this.jsonHandlingService.fromJsonSafe(AdditionalInfoEntity.class, d.getAdditionalInfo());
+ m.setAdditionalInfo(this.builderFactory.builder(UserAdditionalInfoBuilder.class).authorize(this.authorize).build(additionalInfoFields, definition));
+ }
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
@@ -91,37 +92,54 @@ public class DmpBuilder extends BaseBuilder {
return models;
}
- private Map> collectDmpReferences(FieldSet fields, List data) throws MyApplicationException {
+ private Map> collectUserContactInfos(FieldSet fields, List data) throws MyApplicationException {
if (fields.isEmpty() || data.isEmpty()) return null;
- this.logger.debug("checking related - {}", DmpReference.class.getSimpleName());
+ this.logger.debug("checking related - {}", UserContactInfo.class.getSimpleName());
- Map> itemMap;
- FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpReference._dmp, Dmp._id));
- DmpReferenceQuery query = this.queryFactory.query(DmpReferenceQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
- itemMap = this.builderFactory.builder(DmpReferenceBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId());
+ Map> itemMap;
+ FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(UserContactInfo._user, User._id));
+ UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).authorize(this.authorize).userIds(data.stream().map(UserEntity::getId).distinct().collect(Collectors.toList()));
+ itemMap = this.builderFactory.builder(UserContactInfoBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getUser().getId());
- if (!fields.hasField(this.asIndexer(DmpReference._dmp, Dmp._id))) {
- itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDmp() != null).peek(x -> {
- x.getDmp().setId(null);
+ if (!fields.hasField(this.asIndexer(UserContactInfo._user, User._id))) {
+ itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getUser() != null).peek(x -> {
+ x.getUser().setId(null);
});
}
return itemMap;
}
- private Map> collectDmpUsers(FieldSet fields, List data) throws MyApplicationException {
- if (fields.isEmpty() || data.isEmpty())
- return null;
- this.logger.debug("checking related - {}", DmpUser.class.getSimpleName());
+ private Map> collectUserRoles(FieldSet fields, List data) throws MyApplicationException {
+ if (fields.isEmpty() || data.isEmpty()) return null;
+ this.logger.debug("checking related - {}", UserRole.class.getSimpleName());
- Map> itemMap;
- FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpUser._dmp, Dmp._id));
- DmpUserQuery query = this.queryFactory.query(DmpUserQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
- itemMap = this.builderFactory.builder(DmpUserBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId());
+ Map> itemMap;
+ FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(UserRole._user, User._id));
+ UserRoleQuery query = this.queryFactory.query(UserRoleQuery.class).authorize(this.authorize).userIds(data.stream().map(UserEntity::getId).distinct().collect(Collectors.toList()));
+ itemMap = this.builderFactory.builder(UserRoleBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getUser().getId());
- if (!fields.hasField(this.asIndexer(DmpUser._dmp, Dmp._id))) {
- itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDmp() != null).peek(x -> {
- x.getDmp().setId(null);
+ if (!fields.hasField(this.asIndexer(UserRole._user, User._id))) {
+ itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getUser() != null).peek(x -> {
+ x.getUser().setId(null);
+ });
+ }
+
+ return itemMap;
+ }
+
+ private Map> collectUserCredentials(FieldSet fields, List data) throws MyApplicationException {
+ if (fields.isEmpty() || data.isEmpty()) return null;
+ this.logger.debug("checking related - {}", UserCredential.class.getSimpleName());
+
+ Map> itemMap;
+ FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(UserCredential._user, User._id));
+ UserCredentialQuery query = this.queryFactory.query(UserCredentialQuery.class).authorize(this.authorize).userIds(data.stream().map(UserEntity::getId).distinct().collect(Collectors.toList()));
+ itemMap = this.builderFactory.builder(UserCredentialBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getUser().getId());
+
+ if (!fields.hasField(this.asIndexer(UserCredential._user, User._id))) {
+ itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getUser() != null).peek(x -> {
+ x.getUser().setId(null);
});
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/UserContactInfoBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/UserContactInfoBuilder.java
index 5b36794a2..deff56581 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/UserContactInfoBuilder.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/UserContactInfoBuilder.java
@@ -2,12 +2,13 @@ package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.convention.ConventionService;
-import eu.eudat.data.DescriptionTagEntity;
+import eu.eudat.data.UserContactInfoEntity;
import eu.eudat.model.Description;
-import eu.eudat.model.DescriptionTag;
-import eu.eudat.model.Tag;
+import eu.eudat.model.User;
+import eu.eudat.model.UserContactInfo;
+import eu.eudat.model.User;
import eu.eudat.query.DescriptionQuery;
-import eu.eudat.query.TagQuery;
+import eu.eudat.query.UserQuery;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
@@ -26,7 +27,7 @@ import java.util.stream.Collectors;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class DescriptionTagBuilder extends BaseBuilder {
+public class UserContactInfoBuilder extends BaseBuilder {
private final BuilderFactory builderFactory;
@@ -35,42 +36,39 @@ public class DescriptionTagBuilder extends BaseBuilder authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
- public DescriptionTagBuilder(
+ public UserContactInfoBuilder(
ConventionService conventionService,
BuilderFactory builderFactory, QueryFactory queryFactory) {
- super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionTagBuilder.class)));
+ super(conventionService, new LoggerService(LoggerFactory.getLogger(UserContactInfoBuilder.class)));
this.builderFactory = builderFactory;
this.queryFactory = queryFactory;
}
- public DescriptionTagBuilder authorize(EnumSet values) {
+ public UserContactInfoBuilder authorize(EnumSet values) {
this.authorize = values;
return this;
}
@Override
- public List build(FieldSet fields, List data) throws MyApplicationException {
+ public List build(FieldSet fields, List data) throws MyApplicationException {
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
this.logger.trace(new DataLogEntry("requested fields", fields));
if (fields == null || data == null || fields.isEmpty())
return new ArrayList<>();
- FieldSet referenceFields = fields.extractPrefixed(this.asPrefix(DescriptionTag._tag));
- Map referenceItemsMap = this.collectTags(referenceFields, data);
+ FieldSet userFields = fields.extractPrefixed(this.asPrefix(UserContactInfo._user));
+ Map userItemsMap = this.collectUsers(userFields, data);
- FieldSet descriptionFields = fields.extractPrefixed(this.asPrefix(DescriptionTag._description));
- Map descriptionItemsMap = this.collectDescriptions(descriptionFields, data);
+ List models = new ArrayList<>();
- List models = new ArrayList<>();
-
- for (DescriptionTagEntity d : data) {
- DescriptionTag m = new DescriptionTag();
- if (fields.hasField(this.asIndexer(DescriptionTag._id))) m.setId(d.getId());
- if (fields.hasField(this.asIndexer(DescriptionTag._createdAt))) m.setCreatedAt(d.getCreatedAt());
- if (fields.hasField(this.asIndexer(DescriptionTag._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
- if (fields.hasField(this.asIndexer(DescriptionTag._isActive))) m.setIsActive(d.getIsActive());
- if (!referenceFields.isEmpty() && referenceItemsMap != null && referenceItemsMap.containsKey(d.getTagId())) m.setTag(referenceItemsMap.get(d.getTagId()));
- if (!descriptionFields.isEmpty() && descriptionItemsMap != null && descriptionItemsMap.containsKey(d.getDescriptionId())) m.setDescription(descriptionItemsMap.get(d.getDescriptionId()));
+ for (UserContactInfoEntity d : data) {
+ UserContactInfo m = new UserContactInfo();
+ if (fields.hasField(this.asIndexer(UserContactInfo._id))) m.setId(d.getId());
+ if (fields.hasField(this.asIndexer(UserContactInfo._createdAt))) m.setCreatedAt(d.getCreatedAt());
+ if (fields.hasField(this.asIndexer(UserContactInfo._ordinal))) m.setOrdinal(d.getOrdinal());
+ if (fields.hasField(this.asIndexer(UserContactInfo._value))) m.setValue(d.getValue());
+ if (fields.hasField(this.asIndexer(UserContactInfo._type))) m.setType(d.getType());
+ if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId()));
models.add(m);
}
@@ -80,57 +78,27 @@ public class DescriptionTagBuilder extends BaseBuilder collectDescriptions(FieldSet fields, List data) throws MyApplicationException {
+ private Map collectUsers(FieldSet fields, List data) throws MyApplicationException {
if (fields.isEmpty() || data.isEmpty())
return null;
- this.logger.debug("checking related - {}", Description.class.getSimpleName());
+ this.logger.debug("checking related - {}", User.class.getSimpleName());
- Map itemMap;
- if (!fields.hasOtherField(this.asIndexer(Tag._id))) {
+ Map itemMap;
+ if (!fields.hasOtherField(this.asIndexer(User._id))) {
itemMap = this.asEmpty(
- data.stream().map(DescriptionTagEntity::getDescriptionId).distinct().collect(Collectors.toList()),
+ data.stream().map(UserContactInfoEntity::getUserId).distinct().collect(Collectors.toList()),
x -> {
- Description item = new Description();
+ User item = new User();
item.setId(x);
return item;
},
- Description::getId);
+ User::getId);
} else {
- FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Tag._id);
- DescriptionQuery q = this.queryFactory.query(DescriptionQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionTagEntity::getDescriptionId).distinct().collect(Collectors.toList()));
- itemMap = this.builderFactory.builder(DescriptionBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Description::getId);
+ FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(User._id);
+ UserQuery q = this.queryFactory.query(UserQuery.class).authorize(this.authorize).ids(data.stream().map(UserContactInfoEntity::getUserId).distinct().collect(Collectors.toList()));
+ itemMap = this.builderFactory.builder(UserBuilder.class).authorize(this.authorize).asForeignKey(q, clone, User::getId);
}
- if (!fields.hasField(Description._id)) {
- itemMap.forEach((id, item) -> {
- if (item != null)
- item.setId(null);
- });
- }
-
- return itemMap;
- }
-
- private Map collectTags(FieldSet fields, List data) throws MyApplicationException {
- if (fields.isEmpty() || data.isEmpty())
- return null;
- this.logger.debug("checking related - {}", Tag.class.getSimpleName());
-
- Map itemMap;
- if (!fields.hasOtherField(this.asIndexer(Tag._id))) {
- itemMap = this.asEmpty(
- data.stream().map(DescriptionTagEntity::getTagId).distinct().collect(Collectors.toList()),
- x -> {
- Tag item = new Tag();
- item.setId(x);
- return item;
- },
- Tag::getId);
- } else {
- FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Tag._id);
- TagQuery q = this.queryFactory.query(TagQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionTagEntity::getTagId).distinct().collect(Collectors.toList()));
- itemMap = this.builderFactory.builder(TagBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Tag::getId);
- }
- if (!fields.hasField(Tag._id)) {
+ if (!fields.hasField(User._id)) {
itemMap.forEach((id, item) -> {
if (item != null)
item.setId(null);
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/UserCredentialBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/UserCredentialBuilder.java
index b6aab0515..c32a85c0b 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/UserCredentialBuilder.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/UserCredentialBuilder.java
@@ -5,7 +5,6 @@ import eu.eudat.convention.ConventionService;
import eu.eudat.data.UserCredentialEntity;
import eu.eudat.model.User;
import eu.eudat.model.UserCredential;
-import eu.eudat.model.UserCredential;
import eu.eudat.query.UserQuery;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/UserDescriptionTemplateBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/UserDescriptionTemplateBuilder.java
index c9357c4bb..8100cdef4 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/UserDescriptionTemplateBuilder.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/UserDescriptionTemplateBuilder.java
@@ -4,9 +4,12 @@ import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.XmlHandlingService;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.UserDescriptionTemplateEntity;
+import eu.eudat.model.Description;
import eu.eudat.model.DescriptionTemplate;
+import eu.eudat.model.User;
import eu.eudat.model.UserDescriptionTemplate;
import eu.eudat.query.DescriptionTemplateQuery;
+import eu.eudat.query.UserQuery;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
@@ -56,6 +59,8 @@ public class UserDescriptionTemplateBuilder extends BaseBuilder descriptionTemplateMap = this.collectDescriptionTemplates(descriptionTemplateFields, data);
+ FieldSet userFields = fields.extractPrefixed(this.asPrefix(Description._createdBy));
+ Map userItemsMap = this.collectUsers(userFields, data);
List models = new ArrayList<>();
for (UserDescriptionTemplateEntity d : data) {
@@ -66,13 +71,44 @@ public class UserDescriptionTemplateBuilder extends BaseBuilder collectUsers(FieldSet fields, List data) throws MyApplicationException {
+ if (fields.isEmpty() || data.isEmpty())
+ return null;
+ this.logger.debug("checking related - {}", User.class.getSimpleName());
+
+ Map itemMap;
+ if (!fields.hasOtherField(this.asIndexer(User._id))) {
+ itemMap = this.asEmpty(
+ data.stream().map(UserDescriptionTemplateEntity::getUserId).distinct().collect(Collectors.toList()),
+ x -> {
+ User item = new User();
+ item.setId(x);
+ return item;
+ },
+ User::getId);
+ } else {
+ FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(User._id);
+ UserQuery q = this.queryFactory.query(UserQuery.class).authorize(this.authorize).ids(data.stream().map(UserDescriptionTemplateEntity::getUserId).distinct().collect(Collectors.toList()));
+ itemMap = this.builderFactory.builder(UserBuilder.class).authorize(this.authorize).asForeignKey(q, clone, User::getId);
+ }
+ if (!fields.hasField(User._id)) {
+ itemMap.forEach((id, item) -> {
+ if (item != null)
+ item.setId(null);
+ });
+ }
+
+ return itemMap;
+ }
+
private Map collectDescriptionTemplates(FieldSet fields, List data) throws MyApplicationException {
if (fields.isEmpty() || data.isEmpty()) return null;
this.logger.debug("checking related - {}", DescriptionTemplate.class.getSimpleName());
@@ -80,7 +116,7 @@ public class UserDescriptionTemplateBuilder extends BaseBuilder itemMap = null;
if (!fields.hasOtherField(this.asIndexer(DescriptionTemplate._id))) {
itemMap = this.asEmpty(
- data.stream().map(UserDescriptionTemplateEntity::getDescriptionTemplate).distinct().collect(Collectors.toList()),
+ data.stream().map(UserDescriptionTemplateEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList()),
x -> {
DescriptionTemplate item = new DescriptionTemplate();
item.setId(x);
@@ -89,7 +125,7 @@ public class UserDescriptionTemplateBuilder extends BaseBuilder x.getId());
} else {
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(DescriptionTemplate._id);
- DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).ids(data.stream().map(UserDescriptionTemplateEntity::getDescriptionTemplate).distinct().collect(Collectors.toList()));
+ DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).ids(data.stream().map(UserDescriptionTemplateEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList()));
itemMap = this.builderFactory.builder(DescriptionTemplateBuilder.class).asForeignKey(q, clone, DescriptionTemplate::getId);
}
if (!fields.hasField(DescriptionTemplate._id)) {
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/UserRoleBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/UserRoleBuilder.java
index deff56581..644a84fdd 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/UserRoleBuilder.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/UserRoleBuilder.java
@@ -2,12 +2,9 @@ package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.convention.ConventionService;
-import eu.eudat.data.UserContactInfoEntity;
-import eu.eudat.model.Description;
+import eu.eudat.data.UserRoleEntity;
import eu.eudat.model.User;
-import eu.eudat.model.UserContactInfo;
-import eu.eudat.model.User;
-import eu.eudat.query.DescriptionQuery;
+import eu.eudat.model.UserRole;
import eu.eudat.query.UserQuery;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
@@ -27,7 +24,7 @@ import java.util.stream.Collectors;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class UserContactInfoBuilder extends BaseBuilder {
+public class UserRoleBuilder extends BaseBuilder {
private final BuilderFactory builderFactory;
@@ -36,38 +33,36 @@ public class UserContactInfoBuilder extends BaseBuilder authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
- public UserContactInfoBuilder(
+ public UserRoleBuilder(
ConventionService conventionService,
BuilderFactory builderFactory, QueryFactory queryFactory) {
- super(conventionService, new LoggerService(LoggerFactory.getLogger(UserContactInfoBuilder.class)));
+ super(conventionService, new LoggerService(LoggerFactory.getLogger(UserRoleBuilder.class)));
this.builderFactory = builderFactory;
this.queryFactory = queryFactory;
}
- public UserContactInfoBuilder authorize(EnumSet values) {
+ public UserRoleBuilder authorize(EnumSet values) {
this.authorize = values;
return this;
}
@Override
- public List build(FieldSet fields, List data) throws MyApplicationException {
+ public List build(FieldSet fields, List data) throws MyApplicationException {
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
this.logger.trace(new DataLogEntry("requested fields", fields));
if (fields == null || data == null || fields.isEmpty())
return new ArrayList<>();
- FieldSet userFields = fields.extractPrefixed(this.asPrefix(UserContactInfo._user));
+ FieldSet userFields = fields.extractPrefixed(this.asPrefix(UserRole._user));
Map userItemsMap = this.collectUsers(userFields, data);
- List models = new ArrayList<>();
+ List models = new ArrayList<>();
- for (UserContactInfoEntity d : data) {
- UserContactInfo m = new UserContactInfo();
- if (fields.hasField(this.asIndexer(UserContactInfo._id))) m.setId(d.getId());
- if (fields.hasField(this.asIndexer(UserContactInfo._createdAt))) m.setCreatedAt(d.getCreatedAt());
- if (fields.hasField(this.asIndexer(UserContactInfo._ordinal))) m.setOrdinal(d.getOrdinal());
- if (fields.hasField(this.asIndexer(UserContactInfo._value))) m.setValue(d.getValue());
- if (fields.hasField(this.asIndexer(UserContactInfo._type))) m.setType(d.getType());
+ for (UserRoleEntity d : data) {
+ UserRole m = new UserRole();
+ if (fields.hasField(this.asIndexer(UserRole._id))) m.setId(d.getId());
+ if (fields.hasField(this.asIndexer(UserRole._createdAt))) m.setCreatedAt(d.getCreatedAt());
+ if (fields.hasField(this.asIndexer(UserRole._role))) m.setRole(d.getRole());
if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId()));
models.add(m);
@@ -78,7 +73,7 @@ public class UserContactInfoBuilder extends BaseBuilder collectUsers(FieldSet fields, List data) throws MyApplicationException {
+ private Map collectUsers(FieldSet fields, List data) throws MyApplicationException {
if (fields.isEmpty() || data.isEmpty())
return null;
this.logger.debug("checking related - {}", User.class.getSimpleName());
@@ -86,7 +81,7 @@ public class UserContactInfoBuilder extends BaseBuilder itemMap;
if (!fields.hasOtherField(this.asIndexer(User._id))) {
itemMap = this.asEmpty(
- data.stream().map(UserContactInfoEntity::getUserId).distinct().collect(Collectors.toList()),
+ data.stream().map(UserRoleEntity::getUserId).distinct().collect(Collectors.toList()),
x -> {
User item = new User();
item.setId(x);
@@ -95,7 +90,7 @@ public class UserContactInfoBuilder extends BaseBuilder ids) throws InvalidApplicationException {
+ logger.debug(new MapLogEntry("collecting to delete").And("count", Optional.ofNullable(ids).map(List::size).orElse(0)).And("ids", ids));
+ List data = this.queryFactory.query(UserContactInfoQuery.class).ids(ids).collect();
+ logger.trace("retrieved {} items", Optional.ofNullable(data).map(List::size).orElse(0));
+ this.deleteAndSave(data);
+ }
+
+ public void deleteAndSave(List 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 data) throws InvalidApplicationException {
+ logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
+ if (data == null || data.isEmpty())
+ return;
+
+ for (UserContactInfoEntity item : data) {
+ logger.trace("deleting item {}", item.getId());
+ logger.trace("deleting item");
+ this.entityManager.remove(item);
+ logger.trace("deleted item");
+ }
+ }
+
+}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/deleter/UserCredentialDeleter.java b/dmp-backend/core/src/main/java/eu/eudat/model/deleter/UserCredentialDeleter.java
index ff11615d7..ac88df968 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/deleter/UserCredentialDeleter.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/deleter/UserCredentialDeleter.java
@@ -1,7 +1,7 @@
package eu.eudat.model.deleter;
-import eu.eudat.data.UserContactInfoEntity;
-import eu.eudat.query.UserContactInfoQuery;
+import eu.eudat.data.UserCredentialEntity;
+import eu.eudat.query.UserCredentialQuery;
import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService;
@@ -20,16 +20,16 @@ import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class UserContactInfoDeleter implements Deleter {
+public class UserCredentialDeleter implements Deleter {
- private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserContactInfoDeleter.class));
+ private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserCredentialDeleter.class));
private final EntityManager entityManager;
protected final QueryFactory queryFactory;
@Autowired
- public UserContactInfoDeleter(
+ public UserCredentialDeleter(
EntityManager entityManager,
QueryFactory queryFactory
) {
@@ -39,12 +39,12 @@ public class UserContactInfoDeleter implements Deleter {
public void deleteAndSaveByIds(List ids) throws InvalidApplicationException {
logger.debug(new MapLogEntry("collecting to delete").And("count", Optional.ofNullable(ids).map(List::size).orElse(0)).And("ids", ids));
- List data = this.queryFactory.query(UserContactInfoQuery.class).ids(ids).collect();
+ List data = this.queryFactory.query(UserCredentialQuery.class).ids(ids).collect();
logger.trace("retrieved {} items", Optional.ofNullable(data).map(List::size).orElse(0));
this.deleteAndSave(data);
}
- public void deleteAndSave(List data) throws InvalidApplicationException {
+ public void deleteAndSave(List data) throws InvalidApplicationException {
logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
this.delete(data);
logger.trace("saving changes");
@@ -52,12 +52,12 @@ public class UserContactInfoDeleter implements Deleter {
logger.trace("changes saved");
}
- public void delete(List data) throws InvalidApplicationException {
+ public void delete(List data) throws InvalidApplicationException {
logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
if (data == null || data.isEmpty())
return;
- for (UserContactInfoEntity item : data) {
+ for (UserCredentialEntity item : data) {
logger.trace("deleting item {}", item.getId());
logger.trace("deleting item");
this.entityManager.remove(item);
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/deleter/UserDeleter.java b/dmp-backend/core/src/main/java/eu/eudat/model/deleter/UserDeleter.java
index 55aa92e01..158b48dbc 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/deleter/UserDeleter.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/deleter/UserDeleter.java
@@ -1,10 +1,8 @@
package eu.eudat.model.deleter;
import eu.eudat.commons.enums.IsActive;
-import eu.eudat.data.DescriptionTagEntity;
-import eu.eudat.data.TagEntity;
-import eu.eudat.query.DescriptionTagQuery;
-import eu.eudat.query.TagQuery;
+import eu.eudat.data.*;
+import eu.eudat.query.*;
import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory;
@@ -26,9 +24,9 @@ import java.util.stream.Collectors;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class TagDeleter implements Deleter {
+public class UserDeleter implements Deleter {
- private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TagDeleter.class));
+ private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserDeleter.class));
private final EntityManager entityManager;
protected final QueryFactory queryFactory;
@@ -36,7 +34,7 @@ public class TagDeleter implements Deleter {
protected final DeleterFactory deleterFactory;
@Autowired
- public TagDeleter(
+ public UserDeleter(
EntityManager entityManager,
QueryFactory queryFactory,
DeleterFactory deleterFactory
@@ -48,12 +46,12 @@ public class TagDeleter implements Deleter {
public void deleteAndSaveByIds(List ids) throws InvalidApplicationException {
logger.debug(new MapLogEntry("collecting to delete").And("count", Optional.ofNullable(ids).map(List::size).orElse(0)).And("ids", ids));
- List data = this.queryFactory.query(TagQuery.class).ids(ids).collect();
+ List data = this.queryFactory.query(UserQuery.class).ids(ids).collect();
logger.trace("retrieved {} items", Optional.ofNullable(data).map(List::size).orElse(0));
this.deleteAndSave(data);
}
- public void deleteAndSave(List data) throws InvalidApplicationException {
+ public void deleteAndSave(List data) throws InvalidApplicationException {
logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
this.delete(data);
logger.trace("saving changes");
@@ -61,20 +59,38 @@ public class TagDeleter implements Deleter {
logger.trace("changes saved");
}
- public void delete(List data) throws InvalidApplicationException {
+ public void delete(List data) throws InvalidApplicationException {
logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
if (data == null || data.isEmpty())
return;
- List ids = data.stream().map(TagEntity::getId).distinct().collect(Collectors.toList());
+ List ids = data.stream().map(UserEntity::getId).distinct().collect(Collectors.toList());
{
- logger.debug("checking related - {}", DescriptionTagEntity.class.getSimpleName());
- List items = this.queryFactory.query(DescriptionTagQuery.class).tagIds(ids).collect();
- DescriptionTagDeleter deleter = this.deleterFactory.deleter(DescriptionTagDeleter.class);
+ logger.debug("checking related - {}", UserRoleEntity.class.getSimpleName());
+ List items = this.queryFactory.query(UserRoleQuery.class).userIds(ids).collect();
+ UserRoleDeleter deleter = this.deleterFactory.deleter(UserRoleDeleter.class);
deleter.delete(items);
}
+ {
+ logger.debug("checking related - {}", UserCredentialEntity.class.getSimpleName());
+ List items = this.queryFactory.query(UserCredentialQuery.class).userIds(ids).collect();
+ UserCredentialDeleter deleter = this.deleterFactory.deleter(UserCredentialDeleter.class);
+ deleter.delete(items);
+ }
+ {
+ logger.debug("checking related - {}", UserContactInfoEntity.class.getSimpleName());
+ List items = this.queryFactory.query(UserContactInfoQuery.class).userIds(ids).collect();
+ UserContactInfoDeleter deleter = this.deleterFactory.deleter(UserContactInfoDeleter.class);
+ deleter.delete(items);
+ }
+// {
+// logger.debug("checking related - {}", DmpUserEntity.class.getSimpleName());
+// List items = this.queryFactory.query(DmpUserQuery.class).userIds(ids).collect();
+// DmpUserDeleter deleter = this.deleterFactory.deleter(DmpUserDeleter.class);
+// deleter.delete(items);
+// }
Instant now = Instant.now();
- for (TagEntity item : data) {
+ for (UserEntity item : data) {
logger.trace("deleting item {}", item.getId());
item.setIsActive(IsActive.Inactive);
item.setUpdatedAt(now);
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/deleter/UserRoleDeleter.java b/dmp-backend/core/src/main/java/eu/eudat/model/deleter/UserRoleDeleter.java
index f3d48b989..3738e8771 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/deleter/UserRoleDeleter.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/deleter/UserRoleDeleter.java
@@ -1,11 +1,6 @@
package eu.eudat.model.deleter;
-import eu.eudat.commons.enums.IsActive;
-import eu.eudat.data.DescriptionUserEntity;
-import eu.eudat.data.UserEntity;
import eu.eudat.data.UserRoleEntity;
-import eu.eudat.query.DescriptionUserQuery;
-import eu.eudat.query.UserQuery;
import eu.eudat.query.UserRoleQuery;
import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.deleter.DeleterFactory;
@@ -28,34 +23,31 @@ import java.util.stream.Collectors;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class UserDeleter implements Deleter {
+public class UserRoleDeleter implements Deleter {
- private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserDeleter.class));
+ private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserRoleDeleter.class));
private final EntityManager entityManager;
protected final QueryFactory queryFactory;
- protected final DeleterFactory deleterFactory;
@Autowired
- public UserDeleter(
+ public UserRoleDeleter(
EntityManager entityManager,
- QueryFactory queryFactory,
- DeleterFactory deleterFactory
+ QueryFactory queryFactory
) {
this.entityManager = entityManager;
this.queryFactory = queryFactory;
- this.deleterFactory = deleterFactory;
}
public void deleteAndSaveByIds(List ids) throws InvalidApplicationException {
logger.debug(new MapLogEntry("collecting to delete").And("count", Optional.ofNullable(ids).map(List::size).orElse(0)).And("ids", ids));
- List data = this.queryFactory.query(UserQuery.class).ids(ids).collect();
+ List data = this.queryFactory.query(UserRoleQuery.class).ids(ids).collect();
logger.trace("retrieved {} items", Optional.ofNullable(data).map(List::size).orElse(0));
this.deleteAndSave(data);
}
- public void deleteAndSave(List data) throws InvalidApplicationException {
+ public void deleteAndSave(List data) throws InvalidApplicationException {
logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
this.delete(data);
logger.trace("saving changes");
@@ -63,26 +55,16 @@ public class UserDeleter implements Deleter {
logger.trace("changes saved");
}
- public void delete(List data) throws InvalidApplicationException {
+ public void delete(List data) throws InvalidApplicationException {
logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
if (data == null || data.isEmpty())
return;
- List ids = data.stream().map(UserEntity::getId).distinct().collect(Collectors.toList());
- {
- logger.debug("checking related - {}", UserRoleEntity.class.getSimpleName());
- List items = this.queryFactory.query(UserRoleQuery.class).userIds(ids).collect();
- UserRoleDeleter deleter = this.deleterFactory.deleter(UserRoleDeleter.class);
- deleter.delete(items);
- }
- Instant now = Instant.now();
- for (UserEntity item : data) {
+ for (UserRoleEntity 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");
+ logger.trace("deleting item");
+ this.entityManager.remove(item);
+ logger.trace("deleted item");
}
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/mapper/deposit/DmpEntityDepositMapper.java b/dmp-backend/core/src/main/java/eu/eudat/model/mapper/deposit/DmpEntityDepositMapper.java
index 19247f35e..79a93eb8d 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/mapper/deposit/DmpEntityDepositMapper.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/mapper/deposit/DmpEntityDepositMapper.java
@@ -7,10 +7,9 @@ import eu.eudat.commons.types.xml.XmlBuilder;
import eu.eudat.data.*;
import eu.eudat.data.UserEntity;
import eu.eudat.depositinterface.models.*;
-import eu.eudat.query.DescriptionQuery;
-import eu.eudat.query.DescriptionTemplateQuery;
-import eu.eudat.query.DmpDescriptionTemplateQuery;
-import eu.eudat.query.DmpUserQuery;
+import eu.eudat.model.UserContactInfo;
+import eu.eudat.query.*;
+import gr.cite.tools.data.query.Ordering;
import gr.cite.tools.data.query.QueryFactory;
import jakarta.persistence.EntityManager;
import org.slf4j.Logger;
@@ -148,9 +147,11 @@ public class DmpEntityDepositMapper {
private UserDMPDepositModel toUserDeposit(DmpUserEntity user) {
UserDMPDepositModel userDMPDepositModel = new UserDMPDepositModel();
userDMPDepositModel.setUser(new UserInfoDepositModel());
- UserEntity userInfo = this.entityManager.find(UserEntity.class, user.getUser());
+ UserEntity userInfo = this.entityManager.find(UserEntity.class, user.getUserId());
userDMPDepositModel.getUser().setName(userInfo.getName());
-// userDMPDepositModel.getUser().setEmail(userInfo.getEmail()); //TODO: GetEmail
+ UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(userInfo.getId());
+ query.setOrder(new Ordering().addAscending(UserContactInfo._ordinal));
+ userDMPDepositModel.getUser().setEmail(query.first().getValue());
userDMPDepositModel.setRole(user.getRole().getValue().intValue());
return userDMPDepositModel;
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/UserAdditionalInfoPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/UserAdditionalInfoPersist.java
index 246057a16..20744529e 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/UserAdditionalInfoPersist.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/UserAdditionalInfoPersist.java
@@ -1,28 +1,31 @@
-package eu.eudat.model;
+package eu.eudat.model.persist;
-import eu.eudat.commons.enums.ContactInfoType;
+import eu.eudat.commons.validation.ValidId;
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotNull;
-import java.time.Instant;
import java.util.UUID;
-public class UserAdditionalInfo {
+public class UserAdditionalInfoPersist {
+
private String avatarUrl;
- public static final String _avatarUrl = "avatarUrl";
-
+
+ @NotNull(message = "{validation.empty}")
+ @NotEmpty(message = "{validation.empty}")
private String timezone;
- public static final String _timezone = "timezone";
-
+
+ @NotNull(message = "{validation.empty}")
+ @NotEmpty(message = "{validation.empty}")
private String culture;
- public static final String _culture = "culture";
-
+
+ @NotNull(message = "{validation.empty}")
+ @NotEmpty(message = "{validation.empty}")
private String language;
- public static final String _language = "language";
private String roleOrganization;
- public static final String _roleOrganization = "roleOrganization";
- private String organization;
- public static final String _organization = "organization";
+ @ValidId(message = "{validation.invalidid}")
+ private UUID organizationId;
public String getAvatarUrl() {
return avatarUrl;
@@ -64,11 +67,11 @@ public class UserAdditionalInfo {
this.roleOrganization = roleOrganization;
}
- public String getOrganization() {
- return organization;
+ public UUID getOrganizationId() {
+ return organizationId;
}
- public void setOrganization(String organization) {
- this.organization = organization;
+ public void setOrganizationId(UUID organizationId) {
+ this.organizationId = organizationId;
}
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/UserPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/UserPersist.java
index 52aabbac7..7f37c9865 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/UserPersist.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/UserPersist.java
@@ -2,32 +2,43 @@ package eu.eudat.model.persist;
import eu.eudat.commons.enums.DescriptionTemplateTypeStatus;
+import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.validation.FieldNotNullIfOtherSet;
import eu.eudat.commons.validation.ValidEnum;
import eu.eudat.commons.validation.ValidId;
-
+import eu.eudat.data.DescriptionEntity;
import eu.eudat.data.DescriptionTemplateTypeEntity;
+import eu.eudat.data.UserEntity;
+import eu.eudat.model.UserAdditionalInfo;
+import eu.eudat.model.UserContactInfo;
+import eu.eudat.model.UserCredential;
+import eu.eudat.model.UserRole;
+import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
+
+import java.time.Instant;
+import java.util.List;
import java.util.UUID;
@FieldNotNullIfOtherSet(message = "{validation.hashempty}")
-public class DescriptionTemplateTypePersist {
+public class UserPersist {
@ValidId(message = "{validation.invalidid}")
private UUID id;
+
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
- @Size(max = DescriptionTemplateTypeEntity._nameLength, message = "{validation.largerthanmax}")
- private String name = null;
+ @Size(max = UserEntity._nameLength, message = "{validation.largerthanmax}")
+ private String name;
private String hash;
- @ValidEnum(message = "{validation.empty}")
- private DescriptionTemplateTypeStatus status;
-
+ @Valid
+ private UserAdditionalInfoPersist additionalInfo;
+
public UUID getId() {
return id;
}
@@ -52,12 +63,12 @@ public class DescriptionTemplateTypePersist {
this.hash = hash;
}
- public DescriptionTemplateTypeStatus getStatus() {
- return status;
+ public UserAdditionalInfoPersist getAdditionalInfo() {
+ return additionalInfo;
}
- public void setStatus(DescriptionTemplateTypeStatus status) {
- this.status = status;
+ public void setAdditionalInfo(UserAdditionalInfoPersist additionalInfo) {
+ this.additionalInfo = additionalInfo;
}
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/UserRolePatchPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/UserRolePatchPersist.java
index 7f37c9865..fceb1e87a 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/UserRolePatchPersist.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/UserRolePatchPersist.java
@@ -1,44 +1,31 @@
package eu.eudat.model.persist;
-import eu.eudat.commons.enums.DescriptionTemplateTypeStatus;
-import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.validation.FieldNotNullIfOtherSet;
-import eu.eudat.commons.validation.ValidEnum;
import eu.eudat.commons.validation.ValidId;
-import eu.eudat.data.DescriptionEntity;
-import eu.eudat.data.DescriptionTemplateTypeEntity;
import eu.eudat.data.UserEntity;
-import eu.eudat.model.UserAdditionalInfo;
-import eu.eudat.model.UserContactInfo;
-import eu.eudat.model.UserCredential;
-import eu.eudat.model.UserRole;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
-import java.time.Instant;
import java.util.List;
import java.util.UUID;
@FieldNotNullIfOtherSet(message = "{validation.hashempty}")
-public class UserPersist {
+public class UserRolePatchPersist {
+ @NotNull(message = "{validation.empty}")
@ValidId(message = "{validation.invalidid}")
private UUID id;
@NotNull(message = "{validation.empty}")
- @NotEmpty(message = "{validation.empty}")
- @Size(max = UserEntity._nameLength, message = "{validation.largerthanmax}")
- private String name;
+ private List roles;
+ @NotNull(message = "{validation.empty}")
private String hash;
- @Valid
- private UserAdditionalInfoPersist additionalInfo;
-
public UUID getId() {
return id;
}
@@ -47,12 +34,12 @@ public class UserPersist {
this.id = id;
}
- public String getName() {
- return name;
+ public List getRoles() {
+ return roles;
}
- public void setName(String name) {
- this.name = name;
+ public void setRoles(List roles) {
+ this.roles = roles;
}
public String getHash() {
@@ -62,13 +49,5 @@ public class UserPersist {
public void setHash(String hash) {
this.hash = hash;
}
-
- public UserAdditionalInfoPersist getAdditionalInfo() {
- return additionalInfo;
- }
-
- public void setAdditionalInfo(UserAdditionalInfoPersist additionalInfo) {
- this.additionalInfo = additionalInfo;
- }
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionQuery.java b/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionQuery.java
index 4e50cc56c..552fc54a4 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionQuery.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionQuery.java
@@ -263,6 +263,7 @@ public class DescriptionQuery extends QueryBase {
else if (item.match(Description._status) || item.match(PublicDescription._status)) return DescriptionEntity._status;
else if (item.match(Description._description) || item.match(PublicDescription._description)) return DescriptionEntity._description;
else if (item.match(Description._createdBy)) return DescriptionEntity._createdById;
+ else if (item.prefix(Description._createdBy)) return DescriptionEntity._createdById;
else if (item.match(Description._createdAt) || item.match(PublicDescription._createdAt)) return DescriptionEntity._createdAt;
else if (item.match(Description._updatedAt) || item.match(PublicDescription._updatedAt)) return DescriptionEntity._updatedAt;
else if (item.match(Description._isActive)) return DescriptionEntity._isActive;
diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionReferenceQuery.java b/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionReferenceQuery.java
index aa14a630d..cc92b1b9d 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionReferenceQuery.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionReferenceQuery.java
@@ -166,7 +166,7 @@ public class DescriptionReferenceQuery extends QueryBase 0) {
+ if (!predicates.isEmpty()) {
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
return queryContext.CriteriaBuilder.and(predicatesArray);
} else {
@@ -224,6 +224,7 @@ public class DescriptionReferenceQuery extends QueryBase {
else if (item.match(DescriptionTag._isActive)) return DescriptionTagEntity._isActive;
else if (item.match(DescriptionTag._createdAt)) return DescriptionTagEntity._createdAt;
else if (item.match(DescriptionTag._updatedAt)) return DescriptionTagEntity._updatedAt;
+ else if (item.match(DescriptionTag._hash)) return DescriptionTagEntity._updatedAt;
else return null;
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/DmpDescriptionTemplateQuery.java b/dmp-backend/core/src/main/java/eu/eudat/query/DmpDescriptionTemplateQuery.java
index cdd3f31bd..b45168275 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/query/DmpDescriptionTemplateQuery.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/query/DmpDescriptionTemplateQuery.java
@@ -225,6 +225,7 @@ public class DmpDescriptionTemplateQuery extends QueryBase {
else if (item.match(Dmp._isActive) ) return DmpEntity._isActive;
else if (item.match(Dmp._finalizedAt) || item.match(PublicDmp._finalizedAt)) return DmpEntity._finalizedAt;
else if (item.match(Dmp._accessType)) return DmpEntity._accessType;
- else if (item.match(Dmp._creator)) return DmpEntity._creator;
- else if (item.match(Dmp._blueprint)) return DmpEntity._blueprint;
+ else if (item.match(Dmp._creator)) return DmpEntity._creatorId;
+ else if (item.prefix(Dmp._creator)) return DmpEntity._blueprintId;
+ else if (item.match(Dmp._blueprint)) return DmpEntity._blueprintId;
+ else if (item.prefix(Dmp._blueprint)) return DmpEntity._blueprintId;
else if (item.match(Dmp._language)) return DmpEntity._language;
else if (item.match(Dmp._publicAfter)) return DmpEntity._publicAfter;
else if (item.match(Dmp._versionStatus)) return DmpEntity._versionStatus;
@@ -330,8 +325,8 @@ public class DmpQuery extends QueryBase {
item.setIsActive(QueryBase.convertSafe(tuple, columns, DmpEntity._isActive, IsActive.class));
item.setFinalizedAt(QueryBase.convertSafe(tuple, columns, DmpEntity._finalizedAt, Instant.class));
item.setAccessType(QueryBase.convertSafe(tuple, columns, DmpEntity._accessType, DmpAccessType.class));
- item.setCreator(QueryBase.convertSafe(tuple, columns, DmpEntity._creator, UUID.class));
- item.setBlueprint(QueryBase.convertSafe(tuple, columns, DmpEntity._blueprint, UUID.class));
+ item.setCreatorId(QueryBase.convertSafe(tuple, columns, DmpEntity._creatorId, UUID.class));
+ item.setBlueprintId(QueryBase.convertSafe(tuple, columns, DmpEntity._blueprintId, UUID.class));
item.setLanguage(QueryBase.convertSafe(tuple, columns, DmpEntity._language, String.class));
item.setPublicAfter(QueryBase.convertSafe(tuple, columns, DmpEntity._publicAfter, Instant.class));
return item;
diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/DmpReferenceQuery.java b/dmp-backend/core/src/main/java/eu/eudat/query/DmpReferenceQuery.java
index 575e4c46f..3ed7e2c14 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/query/DmpReferenceQuery.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/query/DmpReferenceQuery.java
@@ -206,6 +206,7 @@ public class DmpReferenceQuery extends QueryBase {
else if (item.match(DmpReference._data)) return DmpReferenceEntity._data;
else if (item.match(DmpReference._createdAt)) return DmpReferenceEntity._createdAt;
else if (item.match(DmpReference._updatedAt)) return DmpReferenceEntity._updatedAt;
+ else if (item.match(DmpReference._hash)) return DmpReferenceEntity._updatedAt;
else return null;
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/DmpUserQuery.java b/dmp-backend/core/src/main/java/eu/eudat/query/DmpUserQuery.java
index 60e617652..a28f0ecdc 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/query/DmpUserQuery.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/query/DmpUserQuery.java
@@ -156,7 +156,7 @@ public class DmpUserQuery extends QueryBase {
if (userId != null || usePublic ) {
predicates.add(queryContext.CriteriaBuilder.or(
usePublic ? queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpUserEntity._dmp)).value(queryUtilsService.buildPublicDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, usePublic)) : queryContext.CriteriaBuilder.or(), //Creates a false query
- userId != null ? queryContext.CriteriaBuilder.equal(queryContext.Root.get(DmpUserEntity._user), userId) : queryContext.CriteriaBuilder.or() //Creates a false query
+ userId != null ? queryContext.CriteriaBuilder.equal(queryContext.Root.get(DmpUserEntity._userId), userId) : queryContext.CriteriaBuilder.or() //Creates a false query
));
}
if (!predicates.isEmpty()) {
@@ -189,7 +189,7 @@ public class DmpUserQuery extends QueryBase {
predicates.add(inClause);
}
if (this.userIds != null) {
- CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpUserEntity._user));
+ CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpUserEntity._userId));
for (UUID item : this.userIds)
inClause.value(item);
predicates.add(inClause);
@@ -213,7 +213,7 @@ public class DmpUserQuery extends QueryBase {
DmpUserEntity item = new DmpUserEntity();
item.setId(QueryBase.convertSafe(tuple, columns, DmpUserEntity._id, UUID.class));
item.setDmp(QueryBase.convertSafe(tuple, columns, DmpUserEntity._dmp, UUID.class));
- item.setUser(QueryBase.convertSafe(tuple, columns, DmpUserEntity._user, UUID.class));
+ item.setUserId(QueryBase.convertSafe(tuple, columns, DmpUserEntity._userId, UUID.class));
item.setRole(QueryBase.convertSafe(tuple, columns, DmpUserEntity._role, DmpUserRole.class));
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DmpUserEntity._createdAt, Instant.class));
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DmpUserEntity._updatedAt, Instant.class));
@@ -224,10 +224,11 @@ public class DmpUserQuery extends QueryBase {
protected String fieldNameOf(FieldResolver item) {
if (item.match(DmpUser._id) || item.match(PublicDmpUser._id)) return DmpUserEntity._id;
else if (item.prefix(DmpUser._dmp) || item.prefix(PublicDmpUser._dmp)) return DmpUserEntity._dmp;
- else if (item.prefix(DmpUser._user) || item.prefix(PublicDmpUser._user)) return DmpUserEntity._user;
+ else if (item.prefix(DmpUser._user) || item.prefix(PublicDmpUser._user)) return DmpUserEntity._userId;
else if (item.match(DmpUser._role) || item.match(PublicDmpUser._role)) return DmpUserEntity._role;
else if (item.match(DmpUser._createdAt)) return DmpUserEntity._createdAt;
else if (item.match(DmpUser._updatedAt)) return DmpUserEntity._updatedAt;
+ else if (item.match(DmpUser._hash)) return DmpUserEntity._updatedAt;
else return null;
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/ReferenceQuery.java b/dmp-backend/core/src/main/java/eu/eudat/query/ReferenceQuery.java
index 20ceabddd..e5b3a01c2 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/query/ReferenceQuery.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/query/ReferenceQuery.java
@@ -4,13 +4,9 @@ import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.enums.ReferenceType;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.enums.ReferenceSourceType;
-import eu.eudat.commons.scope.user.UserScope;
-import eu.eudat.data.EntityDoiEntity;
import eu.eudat.data.ReferenceEntity;
-import eu.eudat.model.EntityDoi;
import eu.eudat.model.PublicReference;
import eu.eudat.model.Reference;
-import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.data.query.QueryBase;
import gr.cite.tools.data.query.QueryContext;
@@ -219,7 +215,7 @@ public class ReferenceQuery extends QueryBase {
item.setSource(QueryBase.convertSafe(tuple, columns, ReferenceEntity._source, String.class));
item.setSourceType(QueryBase.convertSafe(tuple, columns, ReferenceEntity._sourceType, ReferenceSourceType.class));
item.setType(QueryBase.convertSafe(tuple, columns, ReferenceEntity._type, ReferenceType.class));
- item.setCreatedBy(QueryBase.convertSafe(tuple, columns, ReferenceEntity._createdBy, UUID.class));
+ item.setCreatedById(QueryBase.convertSafe(tuple, columns, ReferenceEntity._createdById, UUID.class));
return item;
}
@@ -230,6 +226,7 @@ public class ReferenceQuery extends QueryBase {
else if (item.match(Reference._description) || item.match(PublicReference._description)) return ReferenceEntity._description;
else if (item.match(Reference._createdAt)) return ReferenceEntity._createdAt;
else if (item.match(Reference._updatedAt)) return ReferenceEntity._updatedAt;
+ else if (item.match(Reference._hash)) return ReferenceEntity._updatedAt;
else if (item.match(Reference._isActive)) return ReferenceEntity._isActive;
else if (item.match(Reference._definition)) return ReferenceEntity._definition;
else if (item.match(Reference._abbreviation)) return ReferenceEntity._abbreviation;
@@ -237,7 +234,7 @@ public class ReferenceQuery extends QueryBase