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