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