diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/UserCredentialEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/UserCredentialEntity.java index eafc129cb..8575b8ed8 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/data/UserCredentialEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/data/UserCredentialEntity.java @@ -11,7 +11,7 @@ import java.util.UUID; @Entity @Table(name = "\"UserCredential\"") -public class UserCredentialEntity implements DataEntity { +public class UserCredentialEntity { @Id @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) @@ -63,22 +63,4 @@ public class UserCredentialEntity implements DataEntity tuple, List fields, String base) { - String currentBase = base.isEmpty() ? "" : base + "."; - if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id"); - return this; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/UserEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/UserEntity.java index 0cee2ccd9..adc57a4c3 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/data/UserEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/data/UserEntity.java @@ -13,7 +13,7 @@ import java.util.*; @Entity @Table(name = "\"User\"") -public class UserEntity implements DataEntity { +public class UserEntity { @Id @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) @@ -92,25 +92,4 @@ public class UserEntity implements DataEntity { public void setUpdatedAt(Instant updatedAt) { this.updatedAt = updatedAt; } - - - - - @Override - public void update(UserEntity entity) { - this.name = entity.getName(); - this.additionalInfo = entity.getAdditionalInfo(); - } - - @Override - public UUID getKeys() { - return this.id; - } - - @Override - public UserEntity buildFromTuple(List tuple, List fields, String base) { - String currentBase = base.isEmpty() ? "" : base + "."; - if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id"); - return this; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/UserRoleEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/UserRoleEntity.java index 461f7f17a..4e414822b 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/data/UserRoleEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/data/UserRoleEntity.java @@ -12,7 +12,7 @@ import java.util.UUID; @Entity @Table(name = "\"UserRole\"") -public class UserRoleEntity implements DataEntity { +public class UserRoleEntity { @Id @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) private UUID id; @@ -65,20 +65,4 @@ public class UserRoleEntity implements DataEntity { this.createdAt = createdAt; } - @Override - public void update(UserRoleEntity entity) { - - } - - @Override - public UUID getKeys() { - return this.id; - } - - @Override - public UserRoleEntity buildFromTuple(List tuple, List fields, String base) { - String currentBase = base.isEmpty() ? "" : base + "."; - if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id"); - return this; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/old/FileUpload.java b/dmp-backend/core/src/main/java/eu/eudat/data/old/FileUpload.java index 609a62354..977855fcb 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/data/old/FileUpload.java +++ b/dmp-backend/core/src/main/java/eu/eudat/data/old/FileUpload.java @@ -122,7 +122,7 @@ public class FileUpload implements DataEntity { public FileUpload buildFromTuple(List tuple, List fields, String base) { String currentBase = base.isEmpty() ? "" : base + "."; if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id"); - this.creator = tuple.stream().map(x -> new UserEntity().buildFromTuple(tuple, fields , base.isEmpty() ? "creator" : base + "." + "creator")).collect(Collectors.toList()).get(0); +// this.creator = tuple.stream().map(x -> new UserEntity().buildFromTuple(tuple, fields , base.isEmpty() ? "creator" : base + "." + "creator")).collect(Collectors.toList()).get(0); return this; } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/old/Grant.java b/dmp-backend/core/src/main/java/eu/eudat/data/old/Grant.java index 85231dfe0..78ddc52aa 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/data/old/Grant.java +++ b/dmp-backend/core/src/main/java/eu/eudat/data/old/Grant.java @@ -292,8 +292,8 @@ public class Grant implements DataEntity { if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id"); // if (fields.contains(currentBase + "dmps")) // this.dmps = tuple.stream().map(x -> new DMP().buildFromTuple(Arrays.asList(x), fields, currentBase + "dmps")).collect(Collectors.toSet()); - if (fields.contains(currentBase + "creationUser")) - this.creationUser = tuple.stream().map(x -> new UserEntity().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0); +// if (fields.contains(currentBase + "creationUser")) +// this.creationUser = tuple.stream().map(x -> new UserEntity().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0); return this; } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/old/Project.java b/dmp-backend/core/src/main/java/eu/eudat/data/old/Project.java index b2c211140..5d765c9eb 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/data/old/Project.java +++ b/dmp-backend/core/src/main/java/eu/eudat/data/old/Project.java @@ -282,8 +282,8 @@ public class Project implements DataEntity { if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id"); // if (fields.contains(currentBase + "dmps")) // this.dmps = tuple.stream().map(x -> new DMP().buildFromTuple(Arrays.asList(x), fields, currentBase + "dmps")).collect(Collectors.toSet()); - if (fields.contains(currentBase + "creationUser")) - this.creationUser = tuple.stream().map(x -> new UserEntity().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0); +// if (fields.contains(currentBase + "creationUser")) +// this.creationUser = tuple.stream().map(x -> new UserEntity().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0); return this; } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/elastic/data/nested/NestedDescriptionTemplateElasticEntity.java b/dmp-backend/core/src/main/java/eu/eudat/elastic/data/nested/NestedDescriptionTemplateElasticEntity.java index fc2ae5a27..8ac9f49d4 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/elastic/data/nested/NestedDescriptionTemplateElasticEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/elastic/data/nested/NestedDescriptionTemplateElasticEntity.java @@ -21,8 +21,7 @@ public class NestedDescriptionTemplateElasticEntity { private String label; public final static String _label = "label"; - - + @Field(value = NestedDescriptionTemplateElasticEntity._versionStatus, type = FieldType.Short) private DescriptionTemplateVersionStatus versionStatus; public final static String _versionStatus = "versionStatus"; diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/UserInfoDao.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/UserInfoDao.java deleted file mode 100644 index 3abbc3f8c..000000000 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/UserInfoDao.java +++ /dev/null @@ -1,15 +0,0 @@ -package eu.eudat.data.dao.entities; - -import eu.eudat.data.dao.DatabaseAccessLayer; -import eu.eudat.data.dao.criteria.UserInfoCriteria; -import eu.eudat.data.UserEntity; -import eu.eudat.queryable.QueryableList; - -import java.util.UUID; - -public interface UserInfoDao extends DatabaseAccessLayer { - - QueryableList getWithCriteria(UserInfoCriteria criteria); - - QueryableList getAuthenticated(QueryableList users, UUID principalId); -} \ No newline at end of file diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/UserInfoDaoImpl.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/UserInfoDaoImpl.java deleted file mode 100644 index aa5a6b4f3..000000000 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/UserInfoDaoImpl.java +++ /dev/null @@ -1,82 +0,0 @@ -package eu.eudat.data.dao.entities; - -import eu.eudat.data.dao.DatabaseAccess; -import eu.eudat.data.dao.criteria.UserInfoCriteria; -import eu.eudat.data.dao.databaselayer.service.DatabaseService; -import eu.eudat.data.UserEntity; -import eu.eudat.queryable.QueryableList; -import eu.eudat.queryable.types.FieldSelectionType; -import eu.eudat.queryable.types.SelectionField; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Component; - -import javax.management.InvalidApplicationException; -import java.util.Arrays; -import java.util.UUID; -import java.util.concurrent.CompletableFuture; - -@Component("userInfoDao") -public class UserInfoDaoImpl extends DatabaseAccess implements UserInfoDao { - - @Autowired - public UserInfoDaoImpl(DatabaseService databaseService) { - super(databaseService); - } - - @Override - public QueryableList getWithCriteria(UserInfoCriteria criteria) { - QueryableList users = this.getDatabaseService().getQueryable(UserEntity.class); - users.where(((builder, root) -> builder.equal(root.get("userStatus"), 0))); - if (criteria.getAppRoles() != null && !criteria.getAppRoles().isEmpty()) - users.where((builder, root) -> root.join("userRoles").get("role").in(criteria.getAppRoles())); - if (criteria.getLike() != null) - users.where((builder, root) -> builder.or(builder.like(builder.upper(root.get("name")), "%" + criteria.getLike().toUpperCase() + "%"), builder.like(root.get("email"), "%" + criteria.getLike() + "%"))); - if (criteria.getEmail() != null) - users.where((builder, root) -> builder.equal(root.get("email"), criteria.getEmail())); - if (criteria.getCollaboratorLike() != null) - users.where((builder, root) -> builder.or(builder.like(builder.upper(root.get("name")), "%" + criteria.getCollaboratorLike().toUpperCase() + "%"), builder.like(root.get("email"), "%" + criteria.getCollaboratorLike() + "%"))); - return users; - } - - @Override - public QueryableList getAuthenticated(QueryableList users, UUID principalId) { - users.initSubQuery(UUID.class).where((builder, root) -> - builder.and(root.join("dmps").get("id").in( - users.subQuery((builder1, root1) -> builder1.equal(root1.get("id"), principalId), - Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmps:id")))), - builder.notEqual(root.get("id"), principalId))); - return users; - } - - @Override - public UserEntity createOrUpdate(UserEntity item) { - return this.getDatabaseService().createOrUpdate(item, UserEntity.class); - } - - @Override - public UserEntity find(UUID id) throws InvalidApplicationException { - return this.getDatabaseService().getQueryable(UserEntity.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle(); - } - - @Override - public void delete(UserEntity item) { - this.getDatabaseService().delete(item); - } - - @Override - public QueryableList asQueryable() { - return this.getDatabaseService().getQueryable(UserEntity.class); - } - - @Async - @Override - public CompletableFuture createOrUpdateAsync(UserEntity item) { - return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); - } - - @Override - public UserEntity find(UUID id, String hint) { - throw new UnsupportedOperationException(); - } -} \ No newline at end of file diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/UserRoleDao.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/UserRoleDao.java deleted file mode 100644 index 7c268cac0..000000000 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/UserRoleDao.java +++ /dev/null @@ -1,19 +0,0 @@ -package eu.eudat.data.dao.entities; - -import eu.eudat.data.dao.DatabaseAccessLayer; -import eu.eudat.data.dao.criteria.UserRoleCriteria; -import eu.eudat.data.UserEntity; -import eu.eudat.data.UserRoleEntity; -import eu.eudat.queryable.QueryableList; - -import javax.management.InvalidApplicationException; -import java.util.List; -import java.util.UUID; - - -public interface UserRoleDao extends DatabaseAccessLayer { - - QueryableList getWithCriteria(UserRoleCriteria criteria); - - List getUserRoles(UserEntity userInfo) throws InvalidApplicationException; -} diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/UserRoleDaoImpl.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/UserRoleDaoImpl.java deleted file mode 100644 index 7c0c4b158..000000000 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/UserRoleDaoImpl.java +++ /dev/null @@ -1,72 +0,0 @@ -package eu.eudat.data.dao.entities; - -import eu.eudat.data.dao.DatabaseAccess; -import eu.eudat.data.dao.criteria.UserRoleCriteria; -import eu.eudat.data.dao.databaselayer.service.DatabaseService; -import eu.eudat.data.UserEntity; -import eu.eudat.data.UserRoleEntity; -import eu.eudat.queryable.QueryableList; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Component; - -import javax.management.InvalidApplicationException; -import java.util.List; -import java.util.UUID; -import java.util.concurrent.CompletableFuture; - - -@Component("userRoleDao") -public class UserRoleDaoImpl extends DatabaseAccess implements UserRoleDao { - - @Autowired - public UserRoleDaoImpl(DatabaseService databaseService) { - super(databaseService); - } - - @Override - public UserRoleEntity createOrUpdate(UserRoleEntity item) { - return this.getDatabaseService().createOrUpdate(item, UserRoleEntity.class); - } - - @Override - public UserRoleEntity find(UUID id) throws InvalidApplicationException { - return this.getDatabaseService().getQueryable(UserRoleEntity.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingleOrDefault(); - } - - @Override - public List getUserRoles(UserEntity userInfo) throws InvalidApplicationException { - return this.getDatabaseService().getQueryable(UserRoleEntity.class).where((builder, root) -> builder.equal(root.get("userInfo"), userInfo)).toList(); - } - - @Override - public void delete(UserRoleEntity item) { - this.getDatabaseService().delete(item); - } - - @Override - public QueryableList getWithCriteria(UserRoleCriteria criteria) { - QueryableList query = this.getDatabaseService().getQueryable(UserRoleEntity.class); - if (criteria.getLike() != null) - query.where((builder, root) -> builder.equal(root.get("userInfo").get("name"), criteria.getLike())); - if (criteria.getAppRoles() != null && !criteria.getAppRoles().isEmpty()) - query.where((builder, root) -> root.get("role").in(criteria.getAppRoles())); - return query; - } - - @Override - public QueryableList asQueryable() { - return this.getDatabaseService().getQueryable(UserRoleEntity.class); - } - - @Async - @Override - public CompletableFuture createOrUpdateAsync(UserRoleEntity item) { - return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); - } - - @Override - public UserRoleEntity find(UUID id, String hint) { - throw new UnsupportedOperationException(); - } -} diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/security/CredentialDao.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/security/CredentialDao.java deleted file mode 100644 index 878692e37..000000000 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/security/CredentialDao.java +++ /dev/null @@ -1,13 +0,0 @@ -package eu.eudat.data.dao.entities.security; - -import eu.eudat.data.UserCredentialEntity; -import eu.eudat.data.dao.DatabaseAccessLayer; - -import javax.management.InvalidApplicationException; -import java.util.UUID; - - -public interface CredentialDao extends DatabaseAccessLayer { - - UserCredentialEntity getLoggedInCredentials(String username, String secret, Integer provider) throws InvalidApplicationException; -} diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/security/CredentialDaoImpl.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/security/CredentialDaoImpl.java deleted file mode 100644 index 662e6d304..000000000 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/security/CredentialDaoImpl.java +++ /dev/null @@ -1,62 +0,0 @@ -package eu.eudat.data.dao.entities.security; - -import eu.eudat.data.UserCredentialEntity; -import eu.eudat.data.dao.DatabaseAccess; -import eu.eudat.data.dao.databaselayer.service.DatabaseService; -import eu.eudat.queryable.QueryableList; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.management.InvalidApplicationException; -import java.util.UUID; -import java.util.concurrent.CompletableFuture; - - -@Component("credentialDao") -public class CredentialDaoImpl extends DatabaseAccess implements CredentialDao { - - @Autowired - public CredentialDaoImpl(DatabaseService databaseService) { - super(databaseService); - } - - @Override - public UserCredentialEntity createOrUpdate(UserCredentialEntity item) { - return this.getDatabaseService().createOrUpdate(item, UserCredentialEntity.class); - } - - @Override - public UserCredentialEntity find(UUID id) throws InvalidApplicationException { - return this.getDatabaseService().getQueryable(UserCredentialEntity.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingleOrDefault(); - } - - @Override - public UserCredentialEntity getLoggedInCredentials(String username, String secret, Integer provider) throws InvalidApplicationException { - return this.getDatabaseService().getQueryable(UserCredentialEntity.class).where(((builder, root) -> - builder.and( - builder.equal(root.get("publicValue"), username), - builder.equal(root.get("secret"), secret), - builder.equal(root.get("provider"), provider) - ))).getSingleOrDefault(); - } - - @Override - public void delete(UserCredentialEntity item) { - this.getDatabaseService().delete(item); - } - - @Override - public QueryableList asQueryable() { - return this.getDatabaseService().getQueryable(UserCredentialEntity.class); - } - - @Override - public CompletableFuture createOrUpdateAsync(UserCredentialEntity item) { - return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); - } - - @Override - public UserCredentialEntity find(UUID id, String hint) { - throw new UnsupportedOperationException(); - } -} diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/query/items/item/userinfo/UserInfoRequestItem.java b/dmp-backend/data/src/main/java/eu/eudat/data/query/items/item/userinfo/UserInfoRequestItem.java deleted file mode 100644 index 0c8f8b1a2..000000000 --- a/dmp-backend/data/src/main/java/eu/eudat/data/query/items/item/userinfo/UserInfoRequestItem.java +++ /dev/null @@ -1,21 +0,0 @@ -package eu.eudat.data.query.items.item.userinfo; - -import eu.eudat.data.dao.criteria.UserInfoCriteria; -import eu.eudat.data.UserEntity; -import eu.eudat.data.query.definition.Query; -import eu.eudat.queryable.QueryableList; - - -public class UserInfoRequestItem extends Query { - @Override - public QueryableList applyCriteria() { - QueryableList users = this.getQuery(); - if (this.getCriteria().getAppRoles() != null && !this.getCriteria().getAppRoles().isEmpty()) - users.where((builder, root) -> root.join("userRoles").get("role").in(this.getCriteria().getAppRoles())); - if (this.getCriteria().getLike() != null) - users.where((builder, root) -> builder.or(builder.like(builder.upper(root.get("name")), "%" + this.getCriteria().getLike().toUpperCase() + "%"), builder.like(root.get("email"), "%" + this.getCriteria().getLike() + "%"))); - if (this.getCriteria().getEmail() != null) - users.where((builder, root) -> builder.equal(root.get("email"), this.getCriteria().getEmail())); - return users; - } -} diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/query/items/table/userinfo/UserInfoTableRequestItem.java b/dmp-backend/data/src/main/java/eu/eudat/data/query/items/table/userinfo/UserInfoTableRequestItem.java deleted file mode 100644 index 229eeeb0d..000000000 --- a/dmp-backend/data/src/main/java/eu/eudat/data/query/items/table/userinfo/UserInfoTableRequestItem.java +++ /dev/null @@ -1,29 +0,0 @@ -package eu.eudat.data.query.items.table.userinfo; - -import eu.eudat.data.dao.criteria.UserInfoCriteria; -import eu.eudat.data.UserEntity; -import eu.eudat.data.query.definition.TableQuery; -import eu.eudat.queryable.QueryableList; - -import java.util.UUID; - - -public class UserInfoTableRequestItem extends TableQuery { - - @Override - public QueryableList applyCriteria() { - QueryableList users = this.getQuery(); - if (this.getCriteria().getAppRoles() != null && !this.getCriteria().getAppRoles().isEmpty()) - users.where((builder, root) -> root.join("userRoles").get("role").in(this.getCriteria().getAppRoles())); - if (this.getCriteria().getLike() != null) - users.where((builder, root) -> builder.or(builder.like(builder.upper(root.get("name")), "%" + this.getCriteria().getLike().toUpperCase() + "%"), builder.like(root.get("email"), "%" + this.getCriteria().getLike() + "%"))); - if (this.getCriteria().getEmail() != null) - users.where((builder, root) -> builder.equal(root.get("email"), this.getCriteria().getEmail())); - return users; - } - - @Override - public QueryableList applyPaging(QueryableList items) { - return null; - } -} diff --git a/dmp-backend/data/src/main/java/eu/eudat/query/DMPQuery.java b/dmp-backend/data/src/main/java/eu/eudat/query/DMPQuery.java index afef738d8..c2d9ba5a4 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/query/DMPQuery.java +++ b/dmp-backend/data/src/main/java/eu/eudat/query/DMPQuery.java @@ -23,7 +23,7 @@ public class DMPQuery extends Query { private String label; private int version; private GrantQuery grantQuery; - private UserQueryOld userQuery; +// private UserQueryOld userQuery; private DatasetQuery datasetQuery; private List statuses; private Date created; @@ -101,13 +101,13 @@ public class DMPQuery extends Query { this.modified = modified; } - public UserQueryOld getUserQuery() { - return userQuery; - } - - public void setUserQuery(UserQueryOld userQuery) { - this.userQuery = userQuery; - } +// public UserQueryOld getUserQuery() { +// return userQuery; +// } +// +// public void setUserQuery(UserQueryOld userQuery) { +// this.userQuery = userQuery; +// } public DatasetQuery getDatasetQuery() { return datasetQuery; @@ -129,10 +129,10 @@ public class DMPQuery extends Query { if (this.getStatuses() != null && !this.getStatuses().isEmpty()) { query.where((builder, root) -> root.get("status").in(this.getStatuses())); } - if (this.userQuery != null) { - Subquery userInfoSubQuery = this.userQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id"))); - query.where((builder, root) -> root.get("creator").get("id").in(userInfoSubQuery)); - } +// if (this.userQuery != null) { +// Subquery userInfoSubQuery = this.userQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id"))); +// query.where((builder, root) -> root.get("creator").get("id").in(userInfoSubQuery)); +// } if(this.datasetQuery != null){ Subquery datasetSubQuery = this.datasetQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:id"))); query.where((builder, root) -> root.get("id").in(datasetSubQuery )); diff --git a/dmp-backend/data/src/main/java/eu/eudat/query/DatasetProfileQuery.java b/dmp-backend/data/src/main/java/eu/eudat/query/DatasetProfileQuery.java deleted file mode 100644 index 750fbae53..000000000 --- a/dmp-backend/data/src/main/java/eu/eudat/query/DatasetProfileQuery.java +++ /dev/null @@ -1,14 +0,0 @@ -package eu.eudat.query; - -public class DatasetProfileQuery { - - private UserQueryOld userQuery; - - public UserQueryOld getUserQuery() { - return userQuery; - } - - public void setUserQuery(UserQueryOld userQuery) { - this.userQuery = userQuery; - } -} diff --git a/dmp-backend/data/src/main/java/eu/eudat/query/GrantQuery.java b/dmp-backend/data/src/main/java/eu/eudat/query/GrantQuery.java index 84ca64ab7..14f5e375b 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/query/GrantQuery.java +++ b/dmp-backend/data/src/main/java/eu/eudat/query/GrantQuery.java @@ -23,7 +23,7 @@ public class GrantQuery extends Query { private List statuses; private Date created; private Date modified; - private UserQueryOld userQuery; +// private UserQueryOld userQuery; public GrantQuery(DatabaseAccessLayer databaseAccessLayer) { super(databaseAccessLayer); @@ -81,13 +81,13 @@ public class GrantQuery extends Query { this.modified = modified; } - public UserQueryOld getUserQuery() { - return userQuery; - } - - public void setUserQuery(UserQueryOld userQuery) { - this.userQuery = userQuery; - } +// public UserQueryOld getUserQuery() { +// return userQuery; +// } +// +// public void setUserQuery(UserQueryOld userQuery) { +// this.userQuery = userQuery; +// } @Override public QueryableList getQuery() throws InvalidApplicationException { @@ -98,10 +98,10 @@ public class GrantQuery extends Query { query.where((builder, root) -> root.get("id").in(this.ids)); if (this.getStatuses() != null && !this.getStatuses().isEmpty()) query.where((builder, root) -> root.get("status").in(this.getStatuses())); - if (this.userQuery != null) { - Subquery userInfoSubQuery = this.userQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id"))); - query.where((builder, root) -> root.get("creationUser").get("id").in(userInfoSubQuery)); - } +// if (this.userQuery != null) { +// Subquery userInfoSubQuery = this.userQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id"))); +// query.where((builder, root) -> root.get("creationUser").get("id").in(userInfoSubQuery)); +// } if (!this.getSelectionFields().isEmpty() && this.getSelectionFields() != null) { query.withFields(this.getSelectionFields()); } diff --git a/dmp-backend/data/src/main/java/eu/eudat/query/LockQuery.java b/dmp-backend/data/src/main/java/eu/eudat/query/LockQuery.java index 8fb2be0df..ead721b73 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/query/LockQuery.java +++ b/dmp-backend/data/src/main/java/eu/eudat/query/LockQuery.java @@ -19,7 +19,7 @@ public class LockQuery extends Query { private UUID id; private UUID target; - private UserQueryOld userQuery; +// private UserQueryOld userQuery; private Date touchedAt; public UUID getId() { @@ -38,13 +38,13 @@ public class LockQuery extends Query { this.target = target; } - public UserQueryOld getUserQuery() { - return userQuery; - } - - public void setUserQuery(UserQueryOld userQuery) { - this.userQuery = userQuery; - } +// public UserQueryOld getUserQuery() { +// return userQuery; +// } +// +// public void setUserQuery(UserQueryOld userQuery) { +// this.userQuery = userQuery; +// } public Date getTouchedAt() { return touchedAt; @@ -71,10 +71,10 @@ public class LockQuery extends Query { if (this.target != null) { query.where(((builder, root) -> builder.equal(root.get("target"), this.target))); } - if (this.userQuery != null) { - Subquery userSubQuery = this.userQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id"))); - query.where((builder, root) -> root.get("lockedBy").get("id").in(userSubQuery)); - } +// if (this.userQuery != null) { +// Subquery userSubQuery = this.userQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id"))); +// query.where((builder, root) -> root.get("lockedBy").get("id").in(userSubQuery)); +// } return query; } } diff --git a/dmp-backend/data/src/main/java/eu/eudat/query/UserQueryOld.java b/dmp-backend/data/src/main/java/eu/eudat/query/UserQueryOld.java deleted file mode 100644 index 9720ff51f..000000000 --- a/dmp-backend/data/src/main/java/eu/eudat/query/UserQueryOld.java +++ /dev/null @@ -1,37 +0,0 @@ -package eu.eudat.query; - -import eu.eudat.data.dao.DatabaseAccessLayer; -import eu.eudat.data.UserEntity; -import eu.eudat.queryable.QueryableList; - -import java.util.List; -import java.util.UUID; - -public class UserQueryOld extends Query { - - private UUID id; - - public UUID getId() { - return id; - } - - public void setId(UUID id) { - this.id = id; - } - - public UserQueryOld(DatabaseAccessLayer databaseAccessLayer) { - super(databaseAccessLayer); - } - - public UserQueryOld(DatabaseAccessLayer databaseAccessLayer, List selectionFields) { - super(databaseAccessLayer, selectionFields); - } - - @Override - public QueryableList getQuery() { - QueryableList query = this.databaseAccessLayer.asQueryable(); - if (this.id != null) - query.where((builder, root) -> builder.equal(root.get("id"), this.id)); - return query; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/EmailMergeConfirmation.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/EmailMergeConfirmation.java index 1caf004ea..dacb1186d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/EmailMergeConfirmation.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/EmailMergeConfirmation.java @@ -5,7 +5,6 @@ import eu.eudat.exceptions.emailconfirmation.HasConfirmedEmailException; import eu.eudat.exceptions.emailconfirmation.TokenExpiredException; import eu.eudat.logic.managers.MergeEmailConfirmationManager; import eu.eudat.models.data.helpers.responses.ResponseItem; -import eu.eudat.models.data.userinfo.UserMergeRequestModel; import eu.eudat.types.ApiMessageCode; import gr.cite.commons.web.authz.service.AuthorizationService; import org.springframework.beans.factory.annotation.Autowired; @@ -48,19 +47,19 @@ public class EmailMergeConfirmation { } } - @Transactional - @RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json") - public @ResponseBody - ResponseEntity sendConfirmatioEmail(@RequestBody UserMergeRequestModel requestModel) { - this.authorizationService.authorizeForce(Permission.AuthenticatedRole); - try { - this.emailConfirmationManager.sendConfirmationEmail(requestModel.getEmail(), requestModel.getUserId(), requestModel.getProvider()); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE)); - } catch (Exception ex) { - if (ex instanceof HasConfirmedEmailException) { - return ResponseEntity.status(HttpStatus.FOUND).body(new ResponseItem().status(ApiMessageCode.WARN_MESSAGE)); - } - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE)); - } - } +// @Transactional +// @RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json") +// public @ResponseBody +// ResponseEntity sendConfirmatioEmail(@RequestBody UserMergeRequestModel requestModel) { +// this.authorizationService.authorizeForce(Permission.AuthenticatedRole); +// try { +// this.emailConfirmationManager.sendConfirmationEmail(requestModel.getEmail(), requestModel.getUserId(), requestModel.getProvider()); +// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE)); +// } catch (Exception ex) { +// if (ex instanceof HasConfirmedEmailException) { +// return ResponseEntity.status(HttpStatus.FOUND).body(new ResponseItem().status(ApiMessageCode.WARN_MESSAGE)); +// } +// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE)); +// } +// } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/EmailUnlinkConfirmation.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/EmailUnlinkConfirmation.java index dfb6cd10c..92a246dda 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/EmailUnlinkConfirmation.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/EmailUnlinkConfirmation.java @@ -5,7 +5,6 @@ import eu.eudat.exceptions.emailconfirmation.HasConfirmedEmailException; import eu.eudat.exceptions.emailconfirmation.TokenExpiredException; import eu.eudat.logic.managers.UnlinkEmailConfirmationManager; import eu.eudat.models.data.helpers.responses.ResponseItem; -import eu.eudat.models.data.userinfo.UserUnlinkRequestModel; import eu.eudat.types.ApiMessageCode; import gr.cite.commons.web.authz.service.AuthorizationService; import org.springframework.beans.factory.annotation.Autowired; @@ -48,16 +47,16 @@ public class EmailUnlinkConfirmation { } } - @Transactional - @RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json") - public @ResponseBody - ResponseEntity sendUnlinkConfirmationEmail(@RequestBody UserUnlinkRequestModel requestModel) { - this.authorizationService.authorizeForce(Permission.AuthenticatedRole); - try { - this.unlinkEmailConfirmationManager.sendConfirmationEmail(requestModel.getEmail(), requestModel.getUserId(), requestModel.getProvider()); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE)); - } catch (Exception ex) { - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).message("Could not send unlink email.")); - } - } +// @Transactional +// @RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json") +// public @ResponseBody +// ResponseEntity sendUnlinkConfirmationEmail(@RequestBody UserUnlinkRequestModel requestModel) { +// this.authorizationService.authorizeForce(Permission.AuthenticatedRole); +// try { +// this.unlinkEmailConfirmationManager.sendConfirmationEmail(requestModel.getEmail(), requestModel.getUserId(), requestModel.getProvider()); +// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE)); +// } catch (Exception ex) { +// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).message("Could not send unlink email.")); +// } +// } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/UserInvitationController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/UserInvitationController.java index 014e24bd2..dd179c592 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/UserInvitationController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/UserInvitationController.java @@ -1,12 +1,10 @@ package eu.eudat.controllers; import eu.eudat.authorization.Permission; -import eu.eudat.data.query.items.item.userinfo.UserInfoRequestItem; import eu.eudat.logic.managers.InvitationsManager; import eu.eudat.logic.services.ApiContext; import eu.eudat.models.data.helpers.responses.ResponseItem; import eu.eudat.models.data.invitation.Invitation; -import eu.eudat.models.data.userinfo.UserInfoInvitationModel; import eu.eudat.types.ApiMessageCode; import gr.cite.commons.web.authz.service.AuthorizationService; import org.springframework.beans.factory.annotation.Autowired; @@ -57,14 +55,14 @@ public class UserInvitationController extends BaseController { return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).payload(dmpId)); } - @RequestMapping(method = RequestMethod.POST, value = {"/getUsers"}, consumes = "application/json", produces = "application/json") - public @ResponseBody -// ResponseEntity>> getUsers() throws IllegalAccessException, InstantiationException { - ResponseEntity>> getUsers(@RequestBody UserInfoRequestItem userInfoRequestItem) throws IllegalAccessException, InstantiationException, InvalidApplicationException { -// List users = invitationsManager.getUsers(principal); - this.authorizationService.authorizeForce(Permission.AuthenticatedRole); - - List users = invitationsManager.getUsersWithCriteria(userInfoRequestItem); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(users)); - } +// @RequestMapping(method = RequestMethod.POST, value = {"/getUsers"}, consumes = "application/json", produces = "application/json") +// public @ResponseBody +//// ResponseEntity>> getUsers() throws IllegalAccessException, InstantiationException { +// ResponseEntity>> getUsers(@RequestBody UserInfoRequestItem userInfoRequestItem) throws IllegalAccessException, InstantiationException, InvalidApplicationException { +//// List users = invitationsManager.getUsers(principal); +// this.authorizationService.authorizeForce(Permission.AuthenticatedRole); +// +// List users = invitationsManager.getUsersWithCriteria(userInfoRequestItem); +// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(users)); +// } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/criteria/DMPCriteria.java b/dmp-backend/web/src/main/java/eu/eudat/criteria/DMPCriteria.java index 0db1cc5b5..5260be439 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/criteria/DMPCriteria.java +++ b/dmp-backend/web/src/main/java/eu/eudat/criteria/DMPCriteria.java @@ -143,7 +143,7 @@ public class DMPCriteria { DMPQuery dmpQuery = new DMPQuery(dao.getDmpDao(), fields); if (this.id != null) dmpQuery.setId(this.id.getValue()); if (this.grant != null) dmpQuery.setGrantQuery(this.grant.buildQuery(dao)); - if (this.creator != null) dmpQuery.setUserQuery(this.creator.buildQuery(dao)); +// if (this.creator != null) dmpQuery.setUserQuery(this.creator.buildQuery(dao)); if (this.dataset != null) dmpQuery.setDatasetQuery(this.dataset.buildQuery(dao)); return dmpQuery; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/criteria/GrantCriteria.java b/dmp-backend/web/src/main/java/eu/eudat/criteria/GrantCriteria.java index 2c6e0b21d..1b88e7694 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/criteria/GrantCriteria.java +++ b/dmp-backend/web/src/main/java/eu/eudat/criteria/GrantCriteria.java @@ -103,7 +103,7 @@ public class GrantCriteria { List fields = this.buildFields(""); GrantQuery query = new GrantQuery(dao.getGrantDao(), fields); query.setId(this.id.getValue()); - if (this.creator != null) query.setUserQuery(this.creator.buildQuery(dao)); +// if (this.creator != null) query.setUserQuery(this.creator.buildQuery(dao)); return query; } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/criteria/UserCriteria.java b/dmp-backend/web/src/main/java/eu/eudat/criteria/UserCriteria.java index 1fa9d281b..a6874888c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/criteria/UserCriteria.java +++ b/dmp-backend/web/src/main/java/eu/eudat/criteria/UserCriteria.java @@ -7,7 +7,8 @@ import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.databind.node.JsonNodeType; import eu.eudat.criteria.entities.Criteria; import eu.eudat.logic.services.operations.DatabaseRepository; -import eu.eudat.query.UserQueryOld; +import eu.eudat.model.User; +import eu.eudat.query.UserQuery; import java.io.IOException; import java.util.*; @@ -57,10 +58,10 @@ public class UserCriteria { return new LinkedList<>(fields); } - public UserQueryOld buildQuery(DatabaseRepository dao) { + public UserQuery buildQuery(DatabaseRepository dao) { List fields = this.buildFields(""); - UserQueryOld query = new UserQueryOld(dao.getUserInfoDao(), fields); - if (this.id != null) query.setId(this.id.getValue()); - return query; +// UserQuery query = new UserQuery(dao.getUserInfoDao(), fields); +// if (this.id != null) query.setId(this.id.getValue()); + return null; } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ContactEmailManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ContactEmailManager.java index e9ffb1cd2..d6f271d55 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ContactEmailManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ContactEmailManager.java @@ -7,6 +7,7 @@ import eu.eudat.model.UserContactInfo; import eu.eudat.models.data.ContactEmail.ContactEmailModel; import eu.eudat.models.data.ContactEmail.PublicContactEmailModel; import eu.eudat.query.UserContactInfoQuery; +import eu.eudat.query.UserQuery; import eu.eudat.service.mail.SimpleMail; import gr.cite.tools.data.query.Ordering; import gr.cite.tools.data.query.QueryFactory; @@ -34,7 +35,7 @@ public class ContactEmailManager { } public void sendContactEmail(ContactEmailModel contactEmailModel) throws MessagingException, InvalidApplicationException { - UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); + UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first(); SimpleMail mail = new SimpleMail(); UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(user.getId()); query.setOrder(new Ordering().addAscending(UserContactInfo._ordinal)); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index c88105a79..dcd400449 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -35,6 +35,7 @@ import eu.eudat.logic.services.operations.DatabaseRepository; import eu.eudat.commons.types.xml.XmlBuilder; import eu.eudat.model.file.FileEnvelope; import eu.eudat.query.DmpDescriptionTemplateQuery; +import eu.eudat.query.UserQuery; import eu.eudat.utilities.pdf.PDFUtils; import eu.eudat.logic.utilities.documents.types.ParagraphStyle; import eu.eudat.logic.utilities.documents.word.WordBuilder; @@ -55,7 +56,6 @@ import eu.eudat.models.data.helpers.common.DataTableData; import eu.eudat.models.data.listingmodels.*; import eu.eudat.models.data.project.ProjectDMPEditorModel; import eu.eudat.models.data.user.composite.PagedDatasetProfile; -import eu.eudat.models.data.userinfo.UserListingModel; import eu.eudat.query.DescriptionTemplateQuery; import eu.eudat.query.DmpBlueprintQuery; import eu.eudat.queryable.QueryableList; @@ -275,7 +275,7 @@ public class DataManagementPlanManager { QueryableList datasetItems = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(datasetCriteria) .orderBy((builder, root) -> builder.desc(root.get("modified"))); if (principal != null) { - UserEntity userInfo = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal); + UserEntity userInfo = this.queryFactory.query(UserQuery.class).ids(principal).first(); List roles = new ArrayList<>(); roles.add(0); roles.add(1); @@ -505,7 +505,7 @@ public class DataManagementPlanManager { if (newDmp.getStatus().equals(DmpStatus.Finalized)) { checkDmpValidationRules(newDmp); } - UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); + UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first(); newDmp.setCreatorId(user.getId()); DmpBlueprintEntity dmpBlueprint = this.queryFactory.query(DmpBlueprintQuery.class).ids(newDmp.getBlueprintId()).first(); @@ -582,7 +582,7 @@ public class DataManagementPlanManager { if (dataManagementPlan.getUsers() != null && !dataManagementPlan.getUsers().isEmpty()) { clearUsers(newDmp); for (UserInfoListingModel userListing : dataManagementPlan.getUsers()) { - UserEntity tempUser = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userListing.getId()); + UserEntity tempUser = this.queryFactory.query(UserQuery.class).ids(userListing.getId()).first(); assignUser(dmp, tempUser, DmpUserRole.of((short)userListing.getRole())); } } @@ -621,8 +621,8 @@ public class DataManagementPlanManager { } } - if (dataManagementPlan.getAssociatedUsers().size() == 0) - assignUser(newDmp, user); +// if (dataManagementPlan.getAssociatedUsers().size() == 0) +// assignUser(newDmp, user); UUID dmpId = newDmp.getId(); //TODO @@ -668,7 +668,7 @@ public class DataManagementPlanManager { if (tempDMP.getStatus().equals(DmpStatus.Finalized)) { checkDmpValidationRules(tempDMP); } - UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); + UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first(); DmpBlueprintEntity dmpBlueprint = this.queryFactory.query(DmpBlueprintQuery.class).ids(tempDMP.getBlueprintId()).first(); if(this.dmpBlueprintService.fieldInBlueprint(dmpBlueprint, DmpBlueprintSystemFieldType.Organizations)) { @@ -1230,7 +1230,7 @@ public class DataManagementPlanManager { // } // }); }); - UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); + UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first(); sendNotification(dmp, user, NotificationType.DMP_PUBLISH); } @@ -1316,7 +1316,7 @@ public class DataManagementPlanManager { UUID dmpId = dmp.getId(); // dmp.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList())); //TODO //this.updateIndex(dmp); //TODO - UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); + UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first(); sendNotification(dmp, user, NotificationType.DMP_FINALISED); metricsManager.decreaseValue(MetricNames.DMP, 1, MetricNames.DRAFT); metricsManager.increaseValue(MetricNames.DMP, 1, MetricNames.FINALIZED); @@ -1350,7 +1350,7 @@ public class DataManagementPlanManager { throw new Exception("User does not have the privilege to do this action."); clearUsers(dmp); for (UserInfoListingModel userListing : users) { - UserEntity tempUser = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userListing.getId()); + UserEntity tempUser = this.queryFactory.query(UserQuery.class).ids(userListing.getId()).first(); assignUser(dmp, tempUser, DmpUserRole.of((short)userListing.getRole())); } @@ -1824,14 +1824,14 @@ public class DataManagementPlanManager { Element dmpContactName = xmlDoc.createElement("name"); Element dmpContactEmail = xmlDoc.createElement("email"); if(dmp.getCreatorId() != null){ - dmpContactName.setTextContent(this.databaseRepository.getUserInfoDao().find(dmp.getCreatorId()).getName()); + dmpContactName.setTextContent(this.queryFactory.query(UserQuery.class).ids(dmp.getCreatorId()).first().getName()); //TODO dmpContactEmail.setTextContent(this.databaseRepository.getUserInfoDao().find(dmp.getCreator()).getEmail()); } else{ Iterator users = new ArrayList().iterator(); //TODO dmp.getUsers().iterator(); if(users.hasNext()){ DmpUserEntity creator = users.next(); - dmpContactName.setTextContent(this.databaseRepository.getUserInfoDao().find(creator.getUserId()).getName()); + dmpContactName.setTextContent(this.queryFactory.query(UserQuery.class).ids(creator.getUserId()).first().getName()); //TODO .setTextContent(this.databaseRepository.getUserInfoDao().find(creator.getUser()).getEmail()); } } @@ -1846,7 +1846,7 @@ public class DataManagementPlanManager { Element dmpContributorName = xmlDoc.createElement("name"); Element dmpContributorEmail= xmlDoc.createElement("email"); DmpUserEntity contributor = users.next(); - dmpContributorName.setTextContent(this.databaseRepository.getUserInfoDao().find(contributor.getUserId()).getName()); + dmpContributorName.setTextContent(this.queryFactory.query(UserQuery.class).ids(contributor.getUserId()).first().getName()); //TODO dmpContributorEmail.setTextContent(this.databaseRepository.getUserInfoDao().find(contributor.getUser()).getEmail()); dmpContributorElement.appendChild(dmpContributorName); dmpContributorElement.appendChild(dmpContributorEmail); @@ -2245,7 +2245,7 @@ public class DataManagementPlanManager { researchers.add(researcher); } - List associatedUsers = new LinkedList<>(); + //List associatedUsers = new LinkedList<>(); List dynamicFields = new LinkedList<>(); // Sets properties. @@ -2254,7 +2254,7 @@ public class DataManagementPlanManager { dm.setProfiles(associatedProfiles); dm.setOrganisations(organisations); // Sets organisations property. dm.setResearchers(researchers); // Sets researchers property. - dm.setAssociatedUsers(associatedUsers); // Sets associatedUsers property. + //dm.setAssociatedUsers(associatedUsers); // Sets associatedUsers property. dm.setDynamicFields(dynamicFields); // Sets dynamicFields property. //dm.setDefinition(dmpProfile); //ObjectMapper mapper = new ObjectMapper(); @@ -2328,7 +2328,7 @@ public class DataManagementPlanManager { for (MultipartFile file: files) { DmpEntity dmp = rdaManager.convertToEntity(new String(file.getBytes(), "UTF-8"), profiles); dmp.setLabel(file.getOriginalFilename()); - UserEntity me = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); + UserEntity me = this.queryFactory.query(UserQuery.class).ids(dmp.getCreatorId()).first(); dmp.setUpdatedAt(Instant.now()); dmp.setCreatorId(me.getId()); //TODO diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/EmailConfirmationManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/EmailConfirmationManager.java index 4664eda64..b33baca6e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/EmailConfirmationManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/EmailConfirmationManager.java @@ -1,13 +1,14 @@ package eu.eudat.logic.managers; import eu.eudat.commons.scope.user.UserScope; -import eu.eudat.data.UserCredentialEntity; import eu.eudat.data.old.EmailConfirmation; import eu.eudat.data.UserEntity; import eu.eudat.exceptions.emailconfirmation.HasConfirmedEmailException; import eu.eudat.exceptions.emailconfirmation.TokenExpiredException; import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.operations.DatabaseRepository; +import eu.eudat.query.UserQuery; +import gr.cite.tools.data.query.QueryFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -20,12 +21,14 @@ public class EmailConfirmationManager { private ApiContext apiContext; private DatabaseRepository databaseRepository; private final UserScope userScope; + private final QueryFactory queryFactory; @Autowired - public EmailConfirmationManager(ApiContext apiContext, UserScope userScope) { + public EmailConfirmationManager(ApiContext apiContext, UserScope userScope, QueryFactory queryFactory) { this.apiContext = apiContext; this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository(); this.userScope = userScope; + this.queryFactory = queryFactory; } public void confirmEmail(String token) throws TokenExpiredException, HasConfirmedEmailException, InvalidApplicationException { @@ -33,8 +36,7 @@ public class EmailConfirmationManager { .getDatabaseRepository().getLoginConfirmationEmailDao().asQueryable() .where((builder, root) -> builder.equal(root.get("token"), UUID.fromString(token))).getSingle(); - UserEntity user = databaseRepository.getUserInfoDao().asQueryable() - .where((builder, root) -> builder.equal(root.get("id"), loginConfirmationEmail.getUserId())).getSingle(); + UserEntity user = this.queryFactory.query(UserQuery.class).ids(loginConfirmationEmail.getUserId()).first(); // if (user.getEmail() != null) //TODO // throw new HasConfirmedEmailException("User already has confirmed his Email."); @@ -45,12 +47,12 @@ public class EmailConfirmationManager { loginConfirmationEmail.setIsConfirmed(true); // Checks if mail is used by another user. If it is, merges the new the old. - Long existingUsers = databaseRepository.getUserInfoDao().asQueryable().where((builder, root) -> builder.equal(root.get("email"), loginConfirmationEmail.getEmail())).count(); + Long existingUsers = this.queryFactory.query(UserQuery.class).emails(loginConfirmationEmail.getEmail()).count(); if (existingUsers > 0) { - UserCredentialEntity credential = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.equal(root.get("userId"), user.getId())).getSingle(); +// UserCredentialEntity credential = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.equal(root.get("userId"), user.getId())).getSingle(); // credential.setEmail(loginConfirmationEmail.getEmail()); //TODO - databaseRepository.getCredentialDao().createOrUpdate(credential); - UserEntity oldUser = databaseRepository.getUserInfoDao().asQueryable().where((builder, root) -> builder.equal(root.get("email"), loginConfirmationEmail.getEmail())).getSingle(); +// databaseRepository.getCredentialDao().createOrUpdate(credential); + UserEntity oldUser = this.queryFactory.query(UserQuery.class).emails(loginConfirmationEmail.getEmail()).first(); mergeNewUserToOld(user, oldUser); // expireUserToken(user); //TODO: Authn databaseRepository.getLoginConfirmationEmailDao().createOrUpdate(loginConfirmationEmail); @@ -58,9 +60,9 @@ public class EmailConfirmationManager { } // user.setEmail(loginConfirmationEmail.getEmail()); //TODO - databaseRepository.getUserInfoDao().createOrUpdate(user); - UserCredentialEntity credential = databaseRepository.getCredentialDao().asQueryable() - .where((builder, root) -> builder.equal(root.get("userId"), user.getId())).getSingle(); +// databaseRepository.getUserInfoDao().createOrUpdate(user); +// UserCredentialEntity credential = databaseRepository.getCredentialDao().asQueryable() +// .where((builder, root) -> builder.equal(root.get("userId"), user.getId())).getSingle(); // if(credential.getEmail() == null){//TODO // credential.setEmail(user.getEmail()); // databaseRepository.getCredentialDao().createOrUpdate(credential); @@ -69,7 +71,7 @@ public class EmailConfirmationManager { } public void sendConfirmationEmail(String email) throws HasConfirmedEmailException, InvalidApplicationException { - UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); + UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first(); // if (user.getEmail() != null) //TODO // throw new HasConfirmedEmailException("User already has confirmed his Email."); @@ -82,8 +84,8 @@ public class EmailConfirmationManager { } private void mergeNewUserToOld(UserEntity newUser, UserEntity oldUser) throws InvalidApplicationException { - UserCredentialEntity credential = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.equal(root.get("userId"), newUser.getId())).getSingle(); - credential.setUserId(oldUser.getId()); - databaseRepository.getCredentialDao().createOrUpdate(credential); +// UserCredentialEntity credential = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.equal(root.get("userId"), newUser.getId())).getSingle(); +// credential.setUserId(oldUser.getId()); +// databaseRepository.getCredentialDao().createOrUpdate(credential); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/InvitationsManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/InvitationsManager.java index 1b10e490a..942145cb8 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/InvitationsManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/InvitationsManager.java @@ -5,11 +5,10 @@ import eu.eudat.commons.scope.user.UserScope; import eu.eudat.data.DmpEntity; import eu.eudat.data.DmpUserEntity; import eu.eudat.data.UserEntity; -import eu.eudat.data.query.items.item.userinfo.UserInfoRequestItem; import eu.eudat.exceptions.security.UnauthorisedException; import eu.eudat.logic.services.ApiContext; +import eu.eudat.model.User; import eu.eudat.models.data.invitation.Invitation; -import eu.eudat.models.data.userinfo.UserInfoInvitationModel; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -49,8 +48,8 @@ public class InvitationsManager { item.setId(existingUser.getId()); } }); - List alreadySignedInUsers = invitation.getUsers().stream().filter(item -> item.getId() != null).collect(Collectors.toList()); - List alreadySignedInUsersEntities = alreadySignedInUsers.stream().map(UserInfoInvitationModel::toDataModel).collect(Collectors.toList()); + List alreadySignedInUsers = invitation.getUsers().stream().filter(item -> item.getId() != null).collect(Collectors.toList()); + List alreadySignedInUsersEntities = new ArrayList<>(); //alreadySignedInUsers.stream().map(User::toDataModel).collect(Collectors.toList()); List userInfoToUserDmp = new LinkedList<>(); for (UserEntity userInfo : alreadySignedInUsersEntities) { DmpUserEntity userDMP = new DmpUserEntity(); @@ -65,11 +64,11 @@ public class InvitationsManager { }*/ } DmpEntity dataManagementPlan = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(invitation.getDataManagementPlan()); - apiContext.getUtilitiesService().getInvitationService().createInvitations(apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao(), apiContext.getUtilitiesService().getMailService(), invitation.getUsers().stream().map(UserInfoInvitationModel::toDataModel).collect(Collectors.toList()), dataManagementPlan, invitation.getRole(), principalUser); +// apiContext.getUtilitiesService().getInvitationService().createInvitations(apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao(), apiContext.getUtilitiesService().getMailService(), invitation.getUsers().stream().map(UserInfoInvitationModel::toDataModel).collect(Collectors.toList()), dataManagementPlan, invitation.getRole(), principalUser); apiContext.getUtilitiesService().getInvitationService().assignToDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao(), userInfoToUserDmp, dataManagementPlan); } - public List getUsers() throws InstantiationException, IllegalAccessException, InvalidApplicationException { + public List getUsers() throws InstantiationException, IllegalAccessException, InvalidApplicationException { /*UserInfo principalUser = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId()); List users = apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().getAssociated(principalUser).stream().map(userAssociation -> { if (userAssociation.getFirstUser().getId().equals(principal.getId())) { @@ -85,28 +84,28 @@ public class InvitationsManager { // .where(((builder, root) -> builder.notEqual(root.get("isActive"), IsActive.Inactive))), this.userScope.getUserId(), Stream.of(0, 1).collect(Collectors.toList())) // .toList().stream().map(DmpEntity::getUsers).flatMap(Collection::stream).map(DmpUser::getUser) // .filter(userInfo -> !userInfo.getId().equals(this.userScope.getUserIdSafe())).filter(StreamDistinctBy.distinctByKey(UserInfo::getId)).collect(Collectors.toList()); - List userModels = users.stream().map(userInfo -> new UserInfoInvitationModel().fromDataModel(userInfo)).collect(Collectors.toList()); + List userModels = new ArrayList<>(); //users.stream().map(userInfo -> new User().fromDataModel(userInfo)).collect(Collectors.toList()); return userModels; } - public List getUsersWithCriteria(UserInfoRequestItem userInfoRequestItem) throws IllegalAccessException, InstantiationException, InvalidApplicationException { - //TODO -// List users = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao() -// .getAuthenticated(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable() -// .where(((builder, root) -> -// builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()))), this.userScope.getUserId(), Stream.of(0, 1).collect(Collectors.toList())) -// .toList().stream().map(DMP::getUsers).flatMap(Collection::stream).map(UserDMP::getUser) -// .filter(userInfo -> !userInfo.getId().equals(this.userScope.getUserIdSafe())).filter(StreamDistinctBy.distinctByKey(UserInfo::getId)) -// .filter(userInfo -> (userInfoRequestItem == null || userInfoRequestItem.getCriteria() == null || userInfoRequestItem.getCriteria().getLike() == null -// || userInfo.getName().toLowerCase().contains(userInfoRequestItem.getCriteria().getLike().toLowerCase()) -// || (userInfo.getEmail().toLowerCase().contains(userInfoRequestItem.getCriteria().getLike().toLowerCase())))) -// .collect(Collectors.toList()); -//// .where((builder, root) -> builder.like(builder.upper(root.get("name")), "%" + userInfoRequestItem.getCriteria().getLike().toUpperCase() + "%")) -// -// List userModels = users.stream().map(userInfo -> new UserInfoInvitationModel().fromDataModel(userInfo)).collect(Collectors.toList()); -// return userModels; - return new ArrayList<>(); - } +// public List getUsersWithCriteria(UserInfoRequestItem userInfoRequestItem) throws IllegalAccessException, InstantiationException, InvalidApplicationException { +// //TODO +//// List users = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao() +//// .getAuthenticated(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable() +//// .where(((builder, root) -> +//// builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()))), this.userScope.getUserId(), Stream.of(0, 1).collect(Collectors.toList())) +//// .toList().stream().map(DMP::getUsers).flatMap(Collection::stream).map(UserDMP::getUser) +//// .filter(userInfo -> !userInfo.getId().equals(this.userScope.getUserIdSafe())).filter(StreamDistinctBy.distinctByKey(UserInfo::getId)) +//// .filter(userInfo -> (userInfoRequestItem == null || userInfoRequestItem.getCriteria() == null || userInfoRequestItem.getCriteria().getLike() == null +//// || userInfo.getName().toLowerCase().contains(userInfoRequestItem.getCriteria().getLike().toLowerCase()) +//// || (userInfo.getEmail().toLowerCase().contains(userInfoRequestItem.getCriteria().getLike().toLowerCase())))) +//// .collect(Collectors.toList()); +////// .where((builder, root) -> builder.like(builder.upper(root.get("name")), "%" + userInfoRequestItem.getCriteria().getLike().toUpperCase() + "%")) +//// +//// List userModels = users.stream().map(userInfo -> new UserInfoInvitationModel().fromDataModel(userInfo)).collect(Collectors.toList()); +//// return userModels; +// return new ArrayList<>(); +// } public UUID assignUserAcceptedInvitation(UUID invitationID) throws UnauthorisedException, JAXBException, IOException, InvalidApplicationException { //TODO diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/MergeEmailConfirmationManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/MergeEmailConfirmationManager.java index e3df1a4e6..6c350c6e0 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/MergeEmailConfirmationManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/MergeEmailConfirmationManager.java @@ -2,7 +2,6 @@ package eu.eudat.logic.managers; import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.scope.user.UserScope; -import eu.eudat.data.UserCredentialEntity; import eu.eudat.data.DmpUserEntity; import eu.eudat.data.old.EmailConfirmation; import eu.eudat.data.UserEntity; @@ -11,6 +10,8 @@ import eu.eudat.exceptions.emailconfirmation.TokenExpiredException; import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.operations.DatabaseRepository; +import eu.eudat.query.UserQuery; +import gr.cite.tools.data.query.QueryFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -30,13 +31,15 @@ public class MergeEmailConfirmationManager { private DatabaseRepository databaseRepository; // private DmpRepository dmpRepository; private final UserScope userScope; + private final QueryFactory queryFactory; @Autowired - public MergeEmailConfirmationManager(ApiContext apiContext, UserScope userScope) { + public MergeEmailConfirmationManager(ApiContext apiContext, UserScope userScope, QueryFactory queryFactory) { this.apiContext = apiContext; this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository(); // this.dmpRepository = apiContext.getOperationsContext().getElasticRepository().getDmpRepository(); this.userScope = userScope; + this.queryFactory = queryFactory; } @Transactional @@ -48,14 +51,12 @@ public class MergeEmailConfirmationManager { if (loginConfirmationEmail.getExpiresAt().compareTo(new Date()) < 0) throw new TokenExpiredException("Token has expired."); - UserEntity userToBeMerged = databaseRepository.getUserInfoDao().asQueryable() - .where((builder, root) -> builder.equal(root.get("id"), loginConfirmationEmail.getUserId())).getSingle(); + UserEntity userToBeMerged = this.queryFactory.query(UserQuery.class).ids(loginConfirmationEmail.getUserId()).first(); String userToBeMergedEmail = ""; //TODO userToBeMerged.getEmail(); try { Map map = new ObjectMapper().readValue(loginConfirmationEmail.getData(), HashMap.class); UUID otherUserId = UUID.fromString((String) map.get("userId")); - UserEntity user = databaseRepository.getUserInfoDao().asQueryable() - .where((builder, root) -> builder.equal(root.get("id"), otherUserId)).getSingle(); + UserEntity user = this.queryFactory.query(UserQuery.class).ids(otherUserId).first(); // Checks if mail is used by another user. If it is, merges the new the old. mergeNewUserToOld(user, userToBeMerged, Integer.valueOf((String) map.get("provider"))); @@ -70,7 +71,7 @@ public class MergeEmailConfirmationManager { } public void sendConfirmationEmail(String email, UUID userId, Integer provider) throws HasConfirmedEmailException, InvalidApplicationException { - UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); + UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first(); //TODO // if (user.getEmail() != null && !user.getEmail().equals(email)) { // apiContext.getUtilitiesService().getConfirmationEmailService().createMergeConfirmationEmail( @@ -85,9 +86,9 @@ public class MergeEmailConfirmationManager { @Transactional private void mergeNewUserToOld(UserEntity newUser, UserEntity oldUser, Integer provider) throws InvalidApplicationException { - UserCredentialEntity credential = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.and(builder.equal(root.get("userId"), oldUser.getId()), builder.equal(root.get("provider"), provider))).getSingle(); - credential.setUserId(newUser.getId()); - databaseRepository.getCredentialDao().createOrUpdate(credential); +// UserCredentialEntity credential = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.and(builder.equal(root.get("userId"), oldUser.getId()), builder.equal(root.get("provider"), provider))).getSingle(); +// credential.setUserId(newUser.getId()); +// databaseRepository.getCredentialDao().createOrUpdate(credential); List userDmps = databaseRepository.getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("user"), oldUser)).toList(); userDmps.forEach(userDmp -> { userDmp.setUserId(newUser.getId()); @@ -129,12 +130,12 @@ public class MergeEmailConfirmationManager { // } oldUser.setIsActive(IsActive.Inactive); //TODO oldUser.setEmail(null); - List credentials = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.equal(root.get("userId"), oldUser.getId())).toList(); - credentials.forEach(cred -> { - if (cred.getId() != credential.getId()) { - databaseRepository.getCredentialDao().delete(cred); - } - }); - databaseRepository.getUserInfoDao().createOrUpdate(oldUser); +// List credentials = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.equal(root.get("userId"), oldUser.getId())).toList(); +// credentials.forEach(cred -> { +// if (cred.getId() != credential.getId()) { +// databaseRepository.getCredentialDao().delete(cred); +// } +// }); +// databaseRepository.getUserInfoDao().createOrUpdate(oldUser); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/NotificationManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/NotificationManager.java index 7ccac814a..85fd36e4f 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/NotificationManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/NotificationManager.java @@ -6,8 +6,10 @@ import eu.eudat.data.UserEntity; import eu.eudat.commons.enums.old.notification.ActiveStatus; import eu.eudat.commons.enums.old.notification.NotifyState; import eu.eudat.logic.services.ApiContext; +import eu.eudat.query.UserQuery; import eu.eudat.service.mail.MailService; import eu.eudat.service.mail.SimpleMail; +import gr.cite.tools.data.query.QueryFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -26,12 +28,14 @@ public class NotificationManager { private ApiContext apiContext; private Environment environment; private MailService mailService; + private final QueryFactory queryFactory; @Autowired - public NotificationManager(ApiContext apiContext, Environment environment, MailService mailService) { + public NotificationManager(ApiContext apiContext, Environment environment, MailService mailService, QueryFactory queryFactory) { this.apiContext = apiContext; this.environment = environment; this.mailService = mailService; + this.queryFactory = queryFactory; } @Transactional @@ -52,7 +56,7 @@ public class NotificationManager { notification.setUpdatedAt(new Date()); try { Map data = new ObjectMapper().readValue(notification.getData(), HashMap.class); - UserEntity userInfo = this.apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(UUID.fromString(data.get("userId"))); + UserEntity userInfo = this.queryFactory.query(UserQuery.class).ids(UUID.fromString(data.get("userId"))).first(); String subjectTemplate = ""; String contentTemplate = ""; diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/QuickWizardManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/QuickWizardManager.java index ea313e396..9e8d41e70 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/QuickWizardManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/QuickWizardManager.java @@ -9,6 +9,8 @@ import eu.eudat.data.old.*; import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.operations.DatabaseRepository; import eu.eudat.models.data.dmp.DataManagementPlan; +import eu.eudat.query.UserQuery; +import gr.cite.tools.data.query.QueryFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -22,13 +24,16 @@ public class QuickWizardManager { private ApiContext apiContext; private DatabaseRepository databaseRepository; private DatasetManager datasetManager; + + private final QueryFactory queryFactory; private final UserScope userScope; @Autowired - public QuickWizardManager(ApiContext apiContext, DatasetManager datasetManager, UserScope userScope) { + public QuickWizardManager(ApiContext apiContext, DatasetManager datasetManager, QueryFactory queryFactory, UserScope userScope) { this.apiContext = apiContext; this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository(); this.datasetManager = datasetManager; + this.queryFactory = queryFactory; this.userScope = userScope; } @@ -40,13 +45,13 @@ public class QuickWizardManager { public Grant createOrUpdate(eu.eudat.models.data.grant.Grant grant) throws ParseException, IOException, InvalidApplicationException { Grant grantEntity = grant.toDataModel(); grantEntity.setType(Grant.GrantType.INTERNAL.getValue()); - grantEntity.setCreationUser(databaseRepository.getUserInfoDao().find(this.userScope.getUserId())); + grantEntity.setCreationUser(this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first()); return databaseRepository.getGrantDao().createOrUpdate(grantEntity); } public Project createOrUpdate(eu.eudat.models.data.project.Project project) throws InvalidApplicationException { Project projectEntity = project.toDataModel(); - projectEntity.setCreationUser(databaseRepository.getUserInfoDao().find(this.userScope.getUserId())); + projectEntity.setCreationUser(this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first()); return databaseRepository.getProjectDao().createOrUpdate(projectEntity); } @@ -56,7 +61,7 @@ public class QuickWizardManager { //TODO //newDmp.getGrant().setFunder(funderEntity); } - UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); + UserEntity user = this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first(); createFunderIfItDoesntExist(newDmp, user); createGrantIfItDoesntExist(newDmp, user); //TODO @@ -69,8 +74,8 @@ public class QuickWizardManager { //TODO //apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(newDmp.getGrant()); DmpEntity dmpret = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp); - if (dataManagementPlan.getAssociatedUsers().size() == 0) - assignUser(newDmp, user, apiContext); +// if (dataManagementPlan.getAssociatedUsers().size() == 0) +// assignUser(newDmp, user, apiContext); // this.updateIndex(dmpret); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ResearcherManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ResearcherManager.java index 9a24752e6..769d5d8c1 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ResearcherManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ResearcherManager.java @@ -11,8 +11,10 @@ import eu.eudat.data.query.items.item.researcher.ResearcherCriteriaRequest; import eu.eudat.logic.proxy.config.exceptions.HugeResultSet; import eu.eudat.logic.proxy.config.exceptions.NoURLFound; import eu.eudat.logic.proxy.fetching.RemoteFetcher; +import eu.eudat.query.UserQuery; import eu.eudat.queryable.QueryableList; import eu.eudat.logic.services.ApiContext; +import gr.cite.tools.data.query.QueryFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -31,18 +33,20 @@ public class ResearcherManager { private RemoteFetcher remoteFetcher; private ConfigLoader configLoader; private final UserScope userScope; + private final QueryFactory queryFactory; @Autowired - public ResearcherManager(ApiContext apiContext, ConfigLoader configLoader, UserScope userScope) { + public ResearcherManager(ApiContext apiContext, ConfigLoader configLoader, UserScope userScope, QueryFactory queryFactory) { this.apiContext = apiContext; this.remoteFetcher = apiContext.getOperationsContext().getRemoteFetcher(); this.configLoader = configLoader; this.userScope = userScope; + this.queryFactory = queryFactory; } public Researcher create(eu.eudat.models.data.researcher.Researcher researcher) throws Exception { Researcher researcherEntity = researcher.toDataModel(); - researcherEntity.setCreationUser(apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId())); + researcherEntity.setCreationUser(this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first()); return apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().createOrUpdate(researcherEntity); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/UnlinkEmailConfirmationManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/UnlinkEmailConfirmationManager.java index bf42959f6..37e66cf3b 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/UnlinkEmailConfirmationManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/UnlinkEmailConfirmationManager.java @@ -11,6 +11,7 @@ import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.operations.DatabaseRepository; import eu.eudat.model.UserContactInfo; import eu.eudat.query.UserContactInfoQuery; +import eu.eudat.query.UserQuery; import gr.cite.tools.data.query.Ordering; import gr.cite.tools.data.query.QueryFactory; import org.slf4j.Logger; @@ -71,15 +72,15 @@ public class UnlinkEmailConfirmationManager { @Transactional private void unlinkUser(String emailTobeUnlinked, Integer provider) throws InvalidApplicationException { - UserCredentialEntity credential = databaseRepository.getCredentialDao().asQueryable() - .where((builder, root) -> builder.and(builder.equal(root.get("email"), emailTobeUnlinked), builder.equal(root.get("provider"), provider))).getSingle(); - if(credential != null) { - databaseRepository.getCredentialDao().delete(credential); - } +// UserCredentialEntity credential = databaseRepository.getCredentialDao().asQueryable() +// .where((builder, root) -> builder.and(builder.equal(root.get("email"), emailTobeUnlinked), builder.equal(root.get("provider"), provider))).getSingle(); +// if(credential != null) { +// databaseRepository.getCredentialDao().delete(credential); +// } } public void sendConfirmationEmail(String email, UUID userId, Integer provider) throws InvalidApplicationException { - UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userId); + UserEntity user = this.queryFactory.query(UserQuery.class).ids(userId).first(); UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(user.getId()); query.setOrder(new Ordering().addAscending(UserContactInfo._ordinal)); if (query.first().getValue() != null && !query.first().getValue().equals(email)) { diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/UserManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/UserManager.java index bf836d44a..73cdf98a9 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/UserManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/UserManager.java @@ -1,49 +1,27 @@ package eu.eudat.logic.managers; -import com.fasterxml.jackson.databind.ObjectMapper; -import eu.eudat.authorization.Permission; import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity; -import eu.eudat.data.UserCredentialEntity; -import eu.eudat.data.DmpEntity; -import eu.eudat.data.dao.criteria.DataManagementPlanCriteria; -import eu.eudat.data.dao.entities.UserInfoDao; -import eu.eudat.data.DescriptionTemplateEntity; -import eu.eudat.data.UserEntity; -import eu.eudat.data.UserRoleEntity; -import eu.eudat.data.query.items.table.userinfo.UserInfoTableRequestItem; -import eu.eudat.logic.builders.entity.UserRoleBuilder; -import eu.eudat.logic.builders.model.models.DataTableDataBuilder; -import eu.eudat.logic.services.ApiContext; import eu.eudat.commons.types.xml.XmlBuilder; -import eu.eudat.models.HintedModelFactory; -import eu.eudat.models.data.dmp.DataManagementPlan; -import eu.eudat.models.data.helpers.common.DataTableData; -import eu.eudat.models.data.userinfo.UserCredential; -import eu.eudat.models.data.userinfo.UserListingModel; -import eu.eudat.models.data.userinfo.UserProfile; +import eu.eudat.data.DescriptionTemplateEntity; +import eu.eudat.data.UserCredentialEntity; +import eu.eudat.data.UserEntity; +import eu.eudat.logic.services.ApiContext; import eu.eudat.query.UserCredentialQuery; -import eu.eudat.queryable.QueryableList; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.query.QueryFactory; -import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; import org.w3c.dom.Document; import org.w3c.dom.Element; import javax.management.InvalidApplicationException; -import java.io.*; -import java.nio.file.Files; -import java.util.*; -import java.util.stream.Collectors; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; @Component public class UserManager { @@ -75,125 +53,125 @@ public class UserManager { return datasetprofile; } - public DataTableData getPaged(UserInfoTableRequestItem userInfoTableRequestItem) throws Exception { - QueryableList users = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().getWithCriteria(userInfoTableRequestItem.getCriteria()).withHint(HintedModelFactory.getHint(UserListingModel.class)); - QueryableList pagedUsers = PaginationManager.applyPaging(users, userInfoTableRequestItem); - - List modelUsers = pagedUsers.select(item -> new UserListingModel().fromDataModel(item)); - return apiContext.getOperationsContext().getBuilderFactory().getBuilder(DataTableDataBuilder.class).totalCount(users.count()).data(modelUsers).build(); - } +// public DataTableData getPaged(UserInfoTableRequestItem userInfoTableRequestItem) throws Exception { +// QueryableList users = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().getWithCriteria(userInfoTableRequestItem.getCriteria()).withHint(HintedModelFactory.getHint(UserListingModel.class)); +// QueryableList pagedUsers = PaginationManager.applyPaging(users, userInfoTableRequestItem); +// +// List modelUsers = pagedUsers.select(item -> new UserListingModel().fromDataModel(item)); +// return apiContext.getOperationsContext().getBuilderFactory().getBuilder(DataTableDataBuilder.class).totalCount(users.count()).data(modelUsers).build(); +// } - public List getCredentials(UUID userId) throws InvalidApplicationException { - List results = new ArrayList<>(); - UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userId); - List credentials = this.queryFactory.query(UserCredentialQuery.class).userIds(user.getId()).collect(); - credentials.forEach(credential -> { - UserCredential userCredential = new UserCredential(); - results.add(userCredential); - }); - return results; - } +// public List getCredentials(UUID userId) throws InvalidApplicationException { +// List results = new ArrayList<>(); +// UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userId); +// List credentials = this.queryFactory.query(UserCredentialQuery.class).userIds(user.getId()).collect(); +// credentials.forEach(credential -> { +// UserCredential userCredential = new UserCredential(); +// results.add(userCredential); +// }); +// return results; +// } - public UserProfile getSingle(UUID userId) throws Exception { - UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userId); - UserProfile profile = new UserProfile().fromDataModel(user); - List roles = new LinkedList<>(); - DataManagementPlanCriteria criteria = new DataManagementPlanCriteria(); - criteria.setAllVersions(false); - QueryableList items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria); - List dmps = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getAuthenticated(items, userId, roles).take(5).toList(); - profile.setAssociatedDmps(dmps.stream().map(x -> new DataManagementPlan().fromDataModel(x)).collect(Collectors.toList())); - return profile; - } +// public UserProfile getSingle(UUID userId) throws Exception { +// UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userId); +// UserProfile profile = new UserProfile().fromDataModel(user); +// List roles = new LinkedList<>(); +// DataManagementPlanCriteria criteria = new DataManagementPlanCriteria(); +// criteria.setAllVersions(false); +// QueryableList items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria); +// List dmps = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getAuthenticated(items, userId, roles).take(5).toList(); +// profile.setAssociatedDmps(dmps.stream().map(x -> new DataManagementPlan().fromDataModel(x)).collect(Collectors.toList())); +// return profile; +// } - public void editRoles(UserListingModel user) throws InvalidApplicationException { - UserEntity userInfo = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(user.getId()); - //userInfo.getUserRoles().stream().forEach(item -> apiContext.getOperationsContext().getDatabaseRepository().getUserRoleDao().delete(item)); //TODO - for (String role : user.getAppRoles()) { - UserRoleEntity userRole = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserRoleBuilder.class).role(role).userInfo(userInfo).build(); - apiContext.getOperationsContext().getDatabaseRepository().getUserRoleDao().createOrUpdate(userRole); - } - } +// public void editRoles(UserListingModel user) throws InvalidApplicationException { +// UserEntity userInfo = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(user.getId()); +// //userInfo.getUserRoles().stream().forEach(item -> apiContext.getOperationsContext().getDatabaseRepository().getUserRoleDao().delete(item)); //TODO +// for (String role : user.getAppRoles()) { +// UserRoleEntity userRole = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserRoleBuilder.class).role(role).userInfo(userInfo).build(); +// apiContext.getOperationsContext().getDatabaseRepository().getUserRoleDao().createOrUpdate(userRole); +// } +// } - public void updateSettings(Map settings) throws IOException, InvalidApplicationException { - UserEntity userInfo = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); - apiContext.getOperationsContext().getDatabaseRepository().detachEntity(userInfo); - HashMap result = - new ObjectMapper().readValue(userInfo.getAdditionalInfo(), HashMap.class); - userInfo.setName(settings.entrySet().stream().filter(entry -> entry.getKey().equals("name")).filter(Objects::nonNull).map(entry -> entry.getValue().toString()).findFirst().orElse(userInfo.getName())); - settings.remove("name"); - result.putAll(settings); - userInfo.setAdditionalInfo(new JSONObject(result).toString()); - apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao() - .createOrUpdate(userInfo); - } - - public DataTableData getCollaboratorsPaged(UserInfoTableRequestItem userInfoTableRequestItem) throws Exception { - UserInfoDao userInfoDao = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao(); - QueryableList users = userInfoDao.getWithCriteria(userInfoTableRequestItem.getCriteria()); - - List colaborators = userInfoDao.getAuthenticated(users, this.userScope.getUserId()) - .withHint(HintedModelFactory.getHint(UserListingModel.class)) - .select(colaborator -> new UserListingModel().fromDataModel(colaborator)); - - DataTableData dataTableData = new DataTableData<>(); - dataTableData.setData(colaborators); - dataTableData.setTotalCount((long) colaborators.size()); - return dataTableData; - } - - public ResponseEntity exportToCsv() throws IOException, InvalidApplicationException { - - this.authorizationService.authorizeForce(Permission.AdminRole); - - List users = this.apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().asQueryable().toList(); - StringBuilder resultBuilder = new StringBuilder(); - resultBuilder.append("User Id").append(",").append("User Name").append(",").append("User Email").append("\n"); - users.stream().forEach(user -> resultBuilder.append(user.getId().toString()).append(",") - .append(user.getName()).append(",") -//TODO .append(user.getEmail()).append("\n") - ); - String result = resultBuilder.toString(); - String fileName = "Users_dump";//dmp.getLabel(); - fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", ""); - String uuid = UUID.randomUUID().toString(); - File file = new File(this.environment.getProperty("temp.temp") + uuid + ".csv"); - OutputStream output = new FileOutputStream(file); - try { -// mapper.writeValue(file, rdaExportModel); - output.write(result.getBytes()); - output.flush(); - output.close(); - } catch (IOException e) { - logger.error(e.getMessage(), e); - } - - InputStream resource = new FileInputStream(file); - HttpHeaders responseHeaders = new HttpHeaders(); - responseHeaders.setContentLength(file.length()); - responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM); - responseHeaders.set("Content-Disposition", "attachment;filename=" + fileName + ".csv"); - responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition"); - responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type"); - - byte[] content = org.apache.poi.util.IOUtils.toByteArray(resource); - resource.close(); - Files.deleteIfExists(file.toPath()); - return new ResponseEntity<>(content, responseHeaders, HttpStatus.OK); - } - - public UserProfile getFromEmail(String email) throws InvalidApplicationException { - UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().asQueryable().where((builder, root) -> builder.equal(root.get("email"), email)).getSingle(); - return new UserProfile().fromDataModel(user); - } - - public Long countActiveUsers(){ //TODO: Authn - return 0L; - //return apiContext.getOperationsContext().getDatabaseRepository().getUserTokenDao().asQueryable().where(((builder, root) -> builder.greaterThan(root.get("expiresAt"), new Date()))).count(); - } - - public Long countAllUsers() throws InvalidApplicationException { - return apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().asQueryable().count(); - } +// public void updateSettings(Map settings) throws IOException, InvalidApplicationException { +// UserEntity userInfo = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); +// apiContext.getOperationsContext().getDatabaseRepository().detachEntity(userInfo); +// HashMap result = +// new ObjectMapper().readValue(userInfo.getAdditionalInfo(), HashMap.class); +// userInfo.setName(settings.entrySet().stream().filter(entry -> entry.getKey().equals("name")).filter(Objects::nonNull).map(entry -> entry.getValue().toString()).findFirst().orElse(userInfo.getName())); +// settings.remove("name"); +// result.putAll(settings); +// userInfo.setAdditionalInfo(new JSONObject(result).toString()); +// apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao() +// .createOrUpdate(userInfo); +// } +// +// public DataTableData getCollaboratorsPaged(UserInfoTableRequestItem userInfoTableRequestItem) throws Exception { +// UserInfoDao userInfoDao = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao(); +// QueryableList users = userInfoDao.getWithCriteria(userInfoTableRequestItem.getCriteria()); +// +// List colaborators = userInfoDao.getAuthenticated(users, this.userScope.getUserId()) +// .withHint(HintedModelFactory.getHint(UserListingModel.class)) +// .select(colaborator -> new UserListingModel().fromDataModel(colaborator)); +// +// DataTableData dataTableData = new DataTableData<>(); +// dataTableData.setData(colaborators); +// dataTableData.setTotalCount((long) colaborators.size()); +// return dataTableData; +// } +// +// public ResponseEntity exportToCsv() throws IOException, InvalidApplicationException { +// +// this.authorizationService.authorizeForce(Permission.AdminRole); +// +// List users = this.apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().asQueryable().toList(); +// StringBuilder resultBuilder = new StringBuilder(); +// resultBuilder.append("User Id").append(",").append("User Name").append(",").append("User Email").append("\n"); +// users.stream().forEach(user -> resultBuilder.append(user.getId().toString()).append(",") +// .append(user.getName()).append(",") +////TODO .append(user.getEmail()).append("\n") +// ); +// String result = resultBuilder.toString(); +// String fileName = "Users_dump";//dmp.getLabel(); +// fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", ""); +// String uuid = UUID.randomUUID().toString(); +// File file = new File(this.environment.getProperty("temp.temp") + uuid + ".csv"); +// OutputStream output = new FileOutputStream(file); +// try { +//// mapper.writeValue(file, rdaExportModel); +// output.write(result.getBytes()); +// output.flush(); +// output.close(); +// } catch (IOException e) { +// logger.error(e.getMessage(), e); +// } +// +// InputStream resource = new FileInputStream(file); +// HttpHeaders responseHeaders = new HttpHeaders(); +// responseHeaders.setContentLength(file.length()); +// responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM); +// responseHeaders.set("Content-Disposition", "attachment;filename=" + fileName + ".csv"); +// responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition"); +// responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type"); +// +// byte[] content = org.apache.poi.util.IOUtils.toByteArray(resource); +// resource.close(); +// Files.deleteIfExists(file.toPath()); +// return new ResponseEntity<>(content, responseHeaders, HttpStatus.OK); +// } +// +// public UserProfile getFromEmail(String email) throws InvalidApplicationException { +// UserEntity user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().asQueryable().where((builder, root) -> builder.equal(root.get("email"), email)).getSingle(); +// return new UserProfile().fromDataModel(user); +// } +// +// public Long countActiveUsers(){ //TODO: Authn +// return 0L; +// //return apiContext.getOperationsContext().getDatabaseRepository().getUserTokenDao().asQueryable().where(((builder, root) -> builder.greaterThan(root.get("expiresAt"), new Date()))).count(); +// } +// +// public Long countAllUsers() throws InvalidApplicationException { +// return apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().asQueryable().count(); +// } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/services/operations/DatabaseRepository.java b/dmp-backend/web/src/main/java/eu/eudat/logic/services/operations/DatabaseRepository.java index 382b0a481..f34d34e2a 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/services/operations/DatabaseRepository.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/services/operations/DatabaseRepository.java @@ -1,7 +1,6 @@ package eu.eudat.logic.services.operations; import eu.eudat.data.dao.entities.*; -import eu.eudat.data.dao.entities.security.CredentialDao; public interface DatabaseRepository { @@ -25,14 +24,8 @@ public interface DatabaseRepository { ServiceDao getServiceDao(); - UserInfoDao getUserInfoDao(); - - UserRoleDao getUserRoleDao(); - InvitationDao getInvitationDao(); - CredentialDao getCredentialDao(); - ExternalDatasetDao getExternalDatasetDao(); UserDatasetProfileDao getUserDatasetProfileDao(); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/services/operations/DatabaseRepositoryImpl.java b/dmp-backend/web/src/main/java/eu/eudat/logic/services/operations/DatabaseRepositoryImpl.java index 1369f35b2..640653026 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/services/operations/DatabaseRepositoryImpl.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/services/operations/DatabaseRepositoryImpl.java @@ -1,7 +1,6 @@ package eu.eudat.logic.services.operations; import eu.eudat.data.dao.entities.*; -import eu.eudat.data.dao.entities.security.CredentialDao; import jakarta.persistence.EntityManager; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -29,16 +28,10 @@ public class DatabaseRepositoryImpl implements DatabaseRepository { private ServiceDao serviceDao; - private UserInfoDao userInfoDao; - private InvitationDao invitationDao; - private CredentialDao credentialDao; - private ExternalDatasetDao externalDatasetDao; - private UserRoleDao userRoleDao; - private UserDatasetProfileDao userDatasetProfileDao; private UserDmpDao userDmpDao; @@ -110,10 +103,6 @@ public class DatabaseRepositoryImpl implements DatabaseRepository { } @Autowired - private void setUserInfoDao(UserInfoDao userInfoDao) { - this.userInfoDao = userInfoDao; - } - @Override public DataRepositoryDao getDataRepositoryDao() { return dataRepositoryDao; @@ -164,11 +153,6 @@ public class DatabaseRepositoryImpl implements DatabaseRepository { return serviceDao; } - @Override - public UserInfoDao getUserInfoDao() { - return userInfoDao; - } - @Override public InvitationDao getInvitationDao() { return invitationDao; @@ -179,16 +163,6 @@ public class DatabaseRepositoryImpl implements DatabaseRepository { this.invitationDao = invitationDao; } - @Override - public CredentialDao getCredentialDao() { - return credentialDao; - } - - @Autowired - public void setCredentialDao(CredentialDao credentialDao) { - this.credentialDao = credentialDao; - } - @Override public ExternalDatasetDao getExternalDatasetDao() { return externalDatasetDao; @@ -199,16 +173,6 @@ public class DatabaseRepositoryImpl implements DatabaseRepository { this.externalDatasetDao = externalDatasetDao; } - @Override - public UserRoleDao getUserRoleDao() { - return userRoleDao; - } - - @Autowired - public void setUserRoleDao(UserRoleDao userRoleDao) { - this.userRoleDao = userRoleDao; - } - @Autowired public void setEntityManager(EntityManager entityManager) { this.entityManager = entityManager; diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java index 6a31886d4..5eb05b7e1 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java @@ -16,7 +16,6 @@ import eu.eudat.models.data.helpermodels.Tuple; import eu.eudat.models.data.listingmodels.UserInfoListingModel; import eu.eudat.models.data.grant.Grant; import eu.eudat.models.data.project.Project; -import eu.eudat.models.data.userinfo.UserListingModel; import net.minidev.json.JSONObject; import java.util.*; @@ -36,9 +35,7 @@ public class DataManagementPlan implements DataModel organisations; private List researchers; - private List associatedUsers; private List extraFields; - private eu.eudat.models.data.userinfo.UserInfo creator; private Date modified; private Date created; private List dynamicFields; @@ -78,13 +75,6 @@ public class DataManagementPlan implements DataModel getAssociatedUsers() { - return associatedUsers; - } - public void setAssociatedUsers(List associatedUsers) { - this.associatedUsers = associatedUsers; - } - public int getVersion() { return version; } @@ -120,13 +110,6 @@ public class DataManagementPlan implements DataModel getProfiles() { return profiles; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanEditorModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanEditorModel.java index 7908ca5bb..d21a12d56 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanEditorModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanEditorModel.java @@ -1,23 +1,19 @@ package eu.eudat.models.data.dmp; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import eu.eudat.data.DmpBlueprintEntity; import eu.eudat.data.DmpEntity; -import eu.eudat.data.old.*; import eu.eudat.models.DataModel; import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue; import eu.eudat.models.data.funder.FunderDMPEditorModel; +import eu.eudat.models.data.grant.GrantDMPEditorModel; import eu.eudat.models.data.helpermodels.Tuple; import eu.eudat.models.data.listingmodels.UserInfoListingModel; -import eu.eudat.models.data.grant.GrantDMPEditorModel; import eu.eudat.models.data.project.ProjectDMPEditorModel; -import eu.eudat.models.data.userinfo.UserListingModel; -import net.minidev.json.JSONObject; -import java.util.*; -import java.util.stream.Collectors; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.UUID; public class DataManagementPlanEditorModel implements DataModel { private UUID id; @@ -33,9 +29,7 @@ public class DataManagementPlanEditorModel implements DataModel organisations; private List researchers; - private List associatedUsers; private List extraFields; - private eu.eudat.models.data.userinfo.UserInfo creator; private Date modified; private Date created; private List dynamicFields; @@ -74,16 +68,6 @@ public class DataManagementPlanEditorModel implements DataModel getAssociatedUsers() { - return associatedUsers; - } - public void setAssociatedUsers(List associatedUsers) { - this.associatedUsers = associatedUsers; - } - - public int getVersion() { - return version; - } public void setVersion(int version) { this.version = version; } @@ -116,13 +100,6 @@ public class DataManagementPlanEditorModel implements DataModel getProfiles() { return profiles; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanNewVersionModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanNewVersionModel.java index acc41f13d..0b83a8f83 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanNewVersionModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanNewVersionModel.java @@ -11,8 +11,6 @@ import eu.eudat.models.data.dataset.Dataset; import eu.eudat.models.data.funder.FunderDMPEditorModel; import eu.eudat.models.data.grant.GrantDMPEditorModel; import eu.eudat.models.data.project.ProjectDMPEditorModel; -import eu.eudat.models.data.userinfo.UserInfo; -import eu.eudat.models.data.userinfo.UserListingModel; import net.minidev.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,9 +35,6 @@ public class DataManagementPlanNewVersionModel implements DataModel organisations; private List researchers; - private List associatedUsers; - private eu.eudat.models.data.userinfo.UserInfo creator; - private Date created; private List datasets; private ProjectDMPEditorModel project; private FunderDMPEditorModel funder; @@ -115,27 +110,6 @@ public class DataManagementPlanNewVersionModel implements DataModel getAssociatedUsers() { - return associatedUsers; - } - public void setAssociatedUsers(List associatedUsers) { - this.associatedUsers = associatedUsers; - } - - public UserInfo getCreator() { - return creator; - } - public void setCreator(UserInfo creator) { - this.creator = creator; - } - - public Date getCreated() { - return created; - } - public void setCreated(Date created) { - this.created = created; - } - public List getDatasets() { return datasets; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/invitation/Invitation.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/invitation/Invitation.java index 1e3746cee..1f61973df 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/invitation/Invitation.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/invitation/Invitation.java @@ -1,6 +1,6 @@ package eu.eudat.models.data.invitation; -import eu.eudat.models.data.userinfo.UserInfoInvitationModel; +import eu.eudat.model.User; import java.util.List; import java.util.UUID; @@ -8,7 +8,7 @@ import java.util.UUID; public class Invitation { private UUID dataManagementPlan; - private List users; + private List users; private Integer role; public UUID getDataManagementPlan() { @@ -19,11 +19,11 @@ public class Invitation { this.dataManagementPlan = dataManagementPlan; } - public List getUsers() { + public List getUsers() { return users; } - public void setUsers(List users) { + public void setUsers(List users) { this.users = users; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/lock/Lock.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/lock/Lock.java index 46d8e5e9c..1ab6afa73 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/lock/Lock.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/lock/Lock.java @@ -1,7 +1,7 @@ package eu.eudat.models.data.lock; +import eu.eudat.model.User; import eu.eudat.models.DataModel; -import eu.eudat.models.data.userinfo.UserInfo; import java.util.Date; import java.util.UUID; @@ -9,7 +9,7 @@ import java.util.UUID; public class Lock implements DataModel { private UUID id; private UUID target; - private UserInfo lockedBy; + private User lockedBy; private Date lockedAt; private Date touchedAt; @@ -29,14 +29,6 @@ public class Lock implements DataModel { this.target = target; } - public UserInfo getLockedBy() { - return lockedBy; - } - - public void setLockedBy(UserInfo lockedBy) { - this.lockedBy = lockedBy; - } - public Date getLockedAt() { return lockedAt; } @@ -57,7 +49,7 @@ public class Lock implements DataModel { public Lock fromDataModel(eu.eudat.data.old.Lock entity) { this.id = entity.getId(); this.target = entity.getTarget(); - this.lockedBy = new UserInfo().fromDataModel(entity.getLockedBy()); +// this.lockedBy = new UserInfo().fromDataModel(entity.getLockedBy()); this.lockedAt = entity.getLockedAt(); this.touchedAt = entity.getTouchedAt(); return this; @@ -70,7 +62,7 @@ public class Lock implements DataModel { entity.setTarget(this.getTarget()); entity.setLockedAt(this.getLockedAt()); entity.setTouchedAt(this.getTouchedAt()); - entity.setLockedBy(this.getLockedBy().toDataModel()); +// entity.setLockedBy(this.getLockedBy().toDataModel()); return entity; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/notiication/Notification.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/notiication/Notification.java index 44897e010..ecb099360 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/notiication/Notification.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/notiication/Notification.java @@ -4,8 +4,8 @@ import eu.eudat.commons.enums.old.notification.ActiveStatus; import eu.eudat.commons.enums.old.notification.ContactType; import eu.eudat.commons.enums.old.notification.NotificationType; import eu.eudat.commons.enums.old.notification.NotifyState; +import eu.eudat.model.User; import eu.eudat.models.DataModel; -import eu.eudat.models.data.userinfo.UserInfo; import java.util.Date; import java.util.UUID; @@ -13,7 +13,7 @@ import java.util.UUID; public class Notification implements DataModel { private UUID id; - private UserInfo userId; + private User userId; private ActiveStatus isActive; private NotificationType type; private ContactType contactTypeHint; @@ -33,11 +33,11 @@ public class Notification implements DataModel user = new LinkedList<>(); - eu.eudat.models.data.userinfo.UserInfo userInfo = new eu.eudat.models.data.userinfo.UserInfo(); + List user = new LinkedList<>(); + User userInfo = new User(); userInfo.setId(userScope.getUserId()); - dataManagementPlanEntity.setAssociatedUsers(user); +// dataManagementPlanEntity.setAssociatedUsers(user); dataManagementPlanEntity.setExtraProperties(new HashMap<>()); dataManagementPlanEntity.getExtraProperties().put("language", this.language); dataManagementPlanEntity.getExtraProperties().put("visible", false); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserCredential.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserCredential.java deleted file mode 100644 index 93f3a1fa3..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserCredential.java +++ /dev/null @@ -1,21 +0,0 @@ -package eu.eudat.models.data.userinfo; - -import eu.eudat.commons.enums.ProviderType; - -public class UserCredential { - private String email; - private ProviderType provider; - public String getEmail() { - return email; - } - public void setEmail(String email) { - this.email = email; - } - public ProviderType getProvider() { - return provider; - } - public void setProvider(ProviderType provider) { - this.provider = provider; - } - -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserInfo.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserInfo.java deleted file mode 100644 index 9dbe36f56..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserInfo.java +++ /dev/null @@ -1,74 +0,0 @@ -package eu.eudat.models.data.userinfo; - -import eu.eudat.data.UserEntity; -import eu.eudat.models.DataModel; - -import java.time.Instant; -import java.util.UUID; - -public class UserInfo implements DataModel { - private UUID id; - - - private String name = null; - - private Instant created = null; - - // private String additionalinfo; - - public UUID getId() { - return id; - } - - public void setId(UUID id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Instant getCreated() { - return created; - } - - public void setCreated(Instant created) { - this.created = created; - } - - - /*public String getAdditionalinfo() { - return additionalinfo; - } - - public void setAdditionalinfo(String additionalinfo) { - this.additionalinfo = additionalinfo; - }*/ - - @Override - public UserInfo fromDataModel(UserEntity entity) { - this.name = entity.getName(); - this.id = entity.getId(); - return this; - } - - @Override - public UserEntity toDataModel() { - UserEntity entity = new UserEntity(); - entity.setId(this.getId()); - entity.setName(this.getName()); - //entity.setAdditionalinfo(this.getAdditionalinfo()); - entity.setCreatedAt(this.getCreated()); -// entity.setVerified_email(this.getVerified_email()); - return entity; - } - - @Override - public String getHint() { - return null; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserInfoInvitationModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserInfoInvitationModel.java deleted file mode 100644 index 544d63668..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserInfoInvitationModel.java +++ /dev/null @@ -1,48 +0,0 @@ -package eu.eudat.models.data.userinfo; - -import eu.eudat.data.UserEntity; -import eu.eudat.models.DataModel; - -import java.util.UUID; - - -public class UserInfoInvitationModel implements DataModel { - private UUID id; - private String name; - - public UUID getId() { - return id; - } - - public void setId(UUID id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public UserInfoInvitationModel fromDataModel(UserEntity entity) { - this.id = entity.getId(); - this.name = entity.getName(); - return this; - } - - @Override - public UserEntity toDataModel() { - UserEntity userInfo = new UserEntity(); - userInfo.setId(this.id); - userInfo.setName(this.name); - return userInfo; - } - - @Override - public String getHint() { - return null; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserListingModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserListingModel.java deleted file mode 100644 index 707c6cd1f..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserListingModel.java +++ /dev/null @@ -1,98 +0,0 @@ -package eu.eudat.models.data.userinfo; - -import eu.eudat.data.UserEntity; -import eu.eudat.models.DataModel; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.time.Instant; -import java.util.*; - - -public class UserListingModel implements DataModel { - private static final Logger logger = LoggerFactory.getLogger(UserListingModel.class); - - private UUID id; - private String name; - private Instant created; - //private String additionalinfo; - private List appRoles; - private String avatarUrl; - - public UUID getId() { - return id; - } - public void setId(UUID id) { - this.id = id; - } - - - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - public Instant getCreated() { - return created; - } - public void setCreated(Instant created) { - this.created = created; - } - - /*public String getAdditionalinfo() { - return additionalinfo; - } - public void setAdditionalinfo(String additionalinfo) { - this.additionalinfo = additionalinfo; - }*/ - - public List getAppRoles() { - return appRoles; - } - public void setAppRoles(List appRoles) { - this.appRoles = appRoles; - } - - public String getAvatarUrl() { - return avatarUrl; - } - public void setAvatarUrl(String avatarUrl) { - this.avatarUrl = avatarUrl; - } - @Override - public UserListingModel fromDataModel(UserEntity entity) { - this.id = entity.getId(); - this.name = entity.getName(); - this.created = entity.getCreatedAt(); - // this.additionalinfo = entity.getAdditionalinfo(); - //TODO -// this.appRoles = entity.getUserRoles().stream().map(item -> item.getRole()).collect(Collectors.toList()); -// if (entity.getAdditionalinfo() != null) { -// try { -// Map additionalInfo = new ObjectMapper().readValue(entity.getAdditionalinfo(), HashMap.class); -// this.avatarUrl = (String) additionalInfo.get("avatarUrl"); -// } catch (IOException e) { -// logger.error(e.getMessage(), e); -// } -// } - return this; - } - - @Override - public UserEntity toDataModel() throws Exception { - UserEntity userInfo = new UserEntity(); - userInfo.setId(this.id); - userInfo.setName(this.name); - userInfo.setCreatedAt(this.created); - // userInfo.setAdditionalinfo(this.additionalinfo); - - return userInfo; - } - - @Override - public String getHint() { - return "userInfo"; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserMergeRequestModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserMergeRequestModel.java deleted file mode 100644 index 5a60b5b2b..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserMergeRequestModel.java +++ /dev/null @@ -1,29 +0,0 @@ -package eu.eudat.models.data.userinfo; - -import java.util.UUID; - -public class UserMergeRequestModel { - private UUID userId; - private String email; - private Integer provider; - public UUID getUserId() { - return userId; - } - public void setUserId(UUID userId) { - this.userId = userId; - } - public String getEmail() { - return email; - } - public void setEmail(String email) { - this.email = email; - } - - public Integer getProvider() { - return provider; - } - - public void setProvider(Integer provider) { - this.provider = provider; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserProfile.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserProfile.java deleted file mode 100644 index 50f971863..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserProfile.java +++ /dev/null @@ -1,142 +0,0 @@ -package eu.eudat.models.data.userinfo; - -import com.fasterxml.jackson.databind.ObjectMapper; -import eu.eudat.data.UserEntity; -import eu.eudat.models.DataModel; -import eu.eudat.models.data.dmp.DataManagementPlan; -import eu.eudat.models.data.dmp.Organisation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.util.*; - -/** - * Created by ikalyvas on 8/24/2018. - */ -public class UserProfile implements DataModel { - private static final Logger logger = LoggerFactory.getLogger(UserProfile.class); - - private UUID id; - private String name; - private List associatedDmps; - private Map language; - private String timezone; - private Map culture; - private String avatarUrl; - private Organisation organization; - private String roleOrganization; - - public UUID getId() { - return id; - } - - public void setId(UUID id) { - this.id = id; - } - - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - /*public String getAdditionalinfo() { - return additionalinfo; - } - - public void setAdditionalinfo(String additionalinfo) { - this.additionalinfo = additionalinfo; - }*/ - - public List getAssociatedDmps() { - return associatedDmps; - } - - public void setAssociatedDmps(List associatedDmps) { - this.associatedDmps = associatedDmps; - } - - - public Map getLanguage() { - return language; - } - - public void setLanguage(Map language) { - this.language = language; - } - - public String getTimezone() { - return timezone; - } - - public void setTimezone(String timezone) { - this.timezone = timezone; - } - - public Map getCulture() { - return culture; - } - - public void setCulture(Map culture) { - this.culture = culture; - } - - public String getAvatarUrl() { - return avatarUrl; - } - - public void setAvatarUrl(String avatarUrl) { - this.avatarUrl = avatarUrl; - } - - - - public Organisation getOrganization() { - return organization; - } - - public void setOrganization(Organisation organization) { - this.organization = organization; - } - - public String getRoleOrganization() { - return roleOrganization; - } - - public void setRoleOrganization(String roleOrganization) { - this.roleOrganization = roleOrganization; - } - - @Override - public UserProfile fromDataModel(UserEntity entity) { - this.id = entity.getId(); - this.name = entity.getName(); - //this.additionalinfo = entity.getAdditionalinfo(); - try { - Map additionalInfo = new ObjectMapper().readValue(entity.getAdditionalInfo(), HashMap.class); - this.language = (Map)additionalInfo.get("language"); - this.culture = (Map) additionalInfo.get("culture"); - this.timezone = (String) additionalInfo.get("timezone"); - this.avatarUrl = (String) additionalInfo.get("avatarUrl"); - this.organization = Organisation.fromMap((HashMap) additionalInfo.get("organization")); - this.roleOrganization = (String) additionalInfo.get("roleOrganization"); - } catch (IOException e) { - logger.error(e.getMessage(), e); - } - return this; - } - - @Override - public UserEntity toDataModel() throws Exception { - return null; - } - - @Override - public String getHint() { - return null; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserUnlinkRequestModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserUnlinkRequestModel.java deleted file mode 100644 index 5ce0b0c77..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserUnlinkRequestModel.java +++ /dev/null @@ -1,30 +0,0 @@ -package eu.eudat.models.data.userinfo; - -import java.util.UUID; - -public class UserUnlinkRequestModel { - private UUID userId; - private String email; - private Integer provider; - - public UUID getUserId() { - return userId; - } - public void setUserId(UUID userId) { - this.userId = userId; - } - - public String getEmail() { - return email; - } - public void setEmail(String email) { - this.email = email; - } - - public Integer getProvider() { - return provider; - } - public void setProvider(Integer provider) { - this.provider = provider; - } -}