user refactor
This commit is contained in:
parent
dec8f6354c
commit
a97976296b
|
@ -3,6 +3,6 @@ package eu.eudat.authorization;
|
|||
import java.util.EnumSet;
|
||||
|
||||
public enum AuthorizationFlags {
|
||||
None, Permission, DmpAssociated, Public;
|
||||
public static final EnumSet<AuthorizationFlags> OwnerOrPermissionOrMemberOrPublic = EnumSet.of(DmpAssociated, Permission, Public);
|
||||
None, Permission, DmpAssociated, Public, Owner;
|
||||
public static final EnumSet<AuthorizationFlags> OwnerOrDmpAssociatedOrPermissionOrPublic = EnumSet.of(DmpAssociated, Permission, Public, Owner);
|
||||
}
|
||||
|
|
|
@ -41,6 +41,13 @@ public final class Permission {
|
|||
public static String ImportDescriptionTemplate = "ImportDescriptionTemplate";
|
||||
public static String ExportDescriptionTemplate = "ExportDescriptionTemplate";
|
||||
|
||||
|
||||
|
||||
//User
|
||||
public static String BrowseUser = "BrowseUser";
|
||||
public static String EditUser = "EditUser";
|
||||
public static String DeleteUser = "DeleteUser";
|
||||
|
||||
//DescriptionTemplateType
|
||||
public static String BrowseDescriptionTemplateType = "BrowseDescriptionTemplateType";
|
||||
public static String EditDescriptionTemplateType = "EditDescriptionTemplateType";
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package eu.eudat.commons.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import eu.eudat.data.converters.enums.DatabaseEnum;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public enum ContactInfoType implements DatabaseEnum<Short> {
|
||||
|
||||
Email((short) 0);
|
||||
|
||||
private final Short value;
|
||||
|
||||
ContactInfoType(Short value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public Short getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
private static final Map<Short, ContactInfoType> map = EnumUtils.getEnumValueMap(ContactInfoType.class);
|
||||
|
||||
public static ContactInfoType of(Short i) {
|
||||
return map.get(i);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package eu.eudat.commons.lock;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
@Service
|
||||
public class LockByKeyManager {
|
||||
|
||||
private static class LockWrapper {
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
private final AtomicInteger numberOfThreadsInQueue = new AtomicInteger(1);
|
||||
|
||||
private LockWrapper addThreadInQueue() {
|
||||
numberOfThreadsInQueue.incrementAndGet();
|
||||
return this;
|
||||
}
|
||||
|
||||
private int removeThreadFromQueue() {
|
||||
return numberOfThreadsInQueue.decrementAndGet();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static ConcurrentHashMap<String, LockWrapper> locks = new ConcurrentHashMap<String, LockWrapper>();
|
||||
|
||||
public void lock(String key) {
|
||||
LockWrapper lockWrapper = locks.compute(key, (k, v) -> v == null ? new LockWrapper() : v.addThreadInQueue());
|
||||
lockWrapper.lock.lock();
|
||||
}
|
||||
|
||||
public boolean tryLock(String key, long timeout, TimeUnit unit) throws InterruptedException {
|
||||
LockWrapper lockWrapper = null;
|
||||
try {
|
||||
lockWrapper = locks.compute(key, (k, v) -> v == null ? new LockWrapper() : v.addThreadInQueue());
|
||||
return lockWrapper.lock.tryLock(timeout, unit);
|
||||
} catch (Exception ex){
|
||||
if (lockWrapper != null && lockWrapper.removeThreadFromQueue() == 0) {
|
||||
// NB : We pass in the specific value to remove to handle the case where another thread would queue right before the removal
|
||||
locks.remove(key, lockWrapper);
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
public void unlock(String key) {
|
||||
LockWrapper lockWrapper = locks.get(key);
|
||||
lockWrapper.lock.unlock();
|
||||
if (lockWrapper.removeThreadFromQueue() == 0) {
|
||||
// NB : We pass in the specific value to remove to handle the case where another thread would queue right before the removal
|
||||
locks.remove(key, lockWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package eu.eudat.commons.types.user;
|
||||
|
||||
public class AdditionalInfoEntity {
|
||||
private String avatarUrl;
|
||||
private String timezone;
|
||||
private String culture;
|
||||
private String language;
|
||||
|
||||
public String getAvatarUrl() {
|
||||
return avatarUrl;
|
||||
}
|
||||
|
||||
public void setAvatarUrl(String avatarUrl) {
|
||||
this.avatarUrl = avatarUrl;
|
||||
}
|
||||
|
||||
public String getTimezone() {
|
||||
return timezone;
|
||||
}
|
||||
|
||||
public void setTimezone(String timezone) {
|
||||
this.timezone = timezone;
|
||||
}
|
||||
|
||||
public String getCulture() {
|
||||
return culture;
|
||||
}
|
||||
|
||||
public void setCulture(String culture) {
|
||||
this.culture = culture;
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
}
|
|
@ -1,186 +0,0 @@
|
|||
package eu.eudat.data;
|
||||
|
||||
import eu.eudat.commons.enums.ProviderType;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.data.converters.DateToUTCConverter;
|
||||
|
||||
import eu.eudat.data.converters.enums.ProviderTypeConverter;
|
||||
import eu.eudat.data.converters.enums.IsActiveConverter;
|
||||
import eu.eudat.data.old.helpers.EntityBinder;
|
||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
||||
import jakarta.persistence.*;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"Credential\"")
|
||||
//@NamedEntityGraphs({
|
||||
// @NamedEntityGraph(
|
||||
// name = "credentialUserInfo",
|
||||
// attributeNodes = {@NamedAttributeNode("userInfo")})
|
||||
//})
|
||||
public class CredentialEntity implements DataEntity<CredentialEntity, UUID> {
|
||||
|
||||
@Id
|
||||
@Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||
private UUID id;
|
||||
public final static String _id = "id";
|
||||
|
||||
@Column(name = "\"UserId\"", columnDefinition = "uuid", nullable = false)
|
||||
private UUID userId;
|
||||
public final static String _userId = "userId";
|
||||
|
||||
@Column(name = "\"Status\"", nullable = false)
|
||||
@Convert(converter = IsActiveConverter.class)
|
||||
private IsActive isActive;
|
||||
public final static String _isActive = "isActive";
|
||||
|
||||
@Column(name = "\"Provider\"", nullable = false)
|
||||
@Convert(converter = ProviderTypeConverter.class)
|
||||
private ProviderType provider;
|
||||
public final static String _provider = "provider";
|
||||
|
||||
@Column(name = "\"Public\"", nullable = false)
|
||||
private String publicValue;
|
||||
public final static String _publicValue = "public";
|
||||
|
||||
@Column(name = "\"Email\"")
|
||||
private String email;
|
||||
public final static String _email = "email";
|
||||
|
||||
@Column(name = "\"Secret\"", nullable = false)
|
||||
private String secret;
|
||||
public final static String _secret = "secret";
|
||||
|
||||
@Column(name = "\"CreationTime\"", nullable = false)
|
||||
@Convert(converter = DateToUTCConverter.class)
|
||||
private Date creationTime;
|
||||
public final static String _creationTime = "creationTime";
|
||||
|
||||
@Column(name = "\"LastUpdateTime\"", nullable = false)
|
||||
@Convert(converter = DateToUTCConverter.class)
|
||||
private Date lastUpdateTime;
|
||||
public final static String _lastUpdateTime = "lastUpdateTime";
|
||||
|
||||
@Column(name = "\"ExternalId\"", nullable = false)
|
||||
private String externalId;
|
||||
public final static String _externalId = "externalId";
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public UUID getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(UUID userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public IsActive getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(IsActive isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
public ProviderType getProvider() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
public void setProvider(ProviderType provider) {
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
public String getPublicValue() {
|
||||
return publicValue;
|
||||
}
|
||||
|
||||
public void setPublicValue(String publicValue) {
|
||||
this.publicValue = publicValue;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getSecret() {
|
||||
return secret;
|
||||
}
|
||||
|
||||
public void setSecret(String secret) {
|
||||
this.secret = secret;
|
||||
}
|
||||
|
||||
public Date getCreationTime() {
|
||||
return creationTime;
|
||||
}
|
||||
|
||||
public void setCreationTime(Date creationTime) {
|
||||
this.creationTime = creationTime;
|
||||
}
|
||||
|
||||
public Date getLastUpdateTime() {
|
||||
return lastUpdateTime;
|
||||
}
|
||||
|
||||
public void setLastUpdateTime(Date lastUpdateTime) {
|
||||
this.lastUpdateTime = lastUpdateTime;
|
||||
}
|
||||
|
||||
public String getExternalId() {
|
||||
return externalId;
|
||||
}
|
||||
|
||||
public void setExternalId(String externalId) {
|
||||
this.externalId = externalId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
CredentialEntity that = (CredentialEntity) o;
|
||||
|
||||
return provider.getValue() == that.provider.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return provider.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(CredentialEntity entity) {
|
||||
this.isActive = entity.isActive;
|
||||
this.publicValue = entity.getPublicValue();
|
||||
this.email = entity.getEmail();
|
||||
this.secret = entity.getSecret();
|
||||
this.lastUpdateTime = new Date();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CredentialEntity 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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
package eu.eudat.data;
|
||||
|
||||
import eu.eudat.commons.enums.ContactInfoType;
|
||||
import eu.eudat.commons.enums.DescriptionStatus;
|
||||
import eu.eudat.data.converters.enums.ContactInfoTypeConverter;
|
||||
import eu.eudat.data.converters.enums.DescriptionStatusConverter;
|
||||
import eu.eudat.data.old.helpers.EntityBinder;
|
||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"UserContactInfo\"")
|
||||
public class UserContactInfoEntity {
|
||||
@Id
|
||||
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
|
||||
private UUID id;
|
||||
public static final String _id = "id";
|
||||
|
||||
@Column(name = "\"user\"", nullable = false)
|
||||
private UUID userId;
|
||||
public static final String _userId = "userId";
|
||||
|
||||
@Column(name = "\"ordinal\"", nullable = false)
|
||||
private Integer ordinal;
|
||||
public static final String _ordinal = "ordinal";
|
||||
|
||||
@Column(name = "type", nullable = false)
|
||||
@Convert(converter = ContactInfoTypeConverter.class)
|
||||
private ContactInfoType type;
|
||||
public static final String _type = "type";
|
||||
|
||||
@Column(name = "value", length = UserContactInfoEntity._valueLength, nullable = false)
|
||||
private String value;
|
||||
public static final int _valueLength = 512;
|
||||
|
||||
public static final String _value = "value";
|
||||
|
||||
@Column(name = "created_at", nullable = false)
|
||||
private Instant createdAt;
|
||||
|
||||
public static final String _createdAt = "createdAt";
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public UUID getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(UUID userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Instant getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Instant createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public ContactInfoType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(ContactInfoType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Integer getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
public void setOrdinal(Integer ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package eu.eudat.data;
|
||||
|
||||
import eu.eudat.data.old.helpers.EntityBinder;
|
||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"UserCredential\"")
|
||||
public class UserCredentialEntity implements DataEntity<UserCredentialEntity, UUID> {
|
||||
|
||||
@Id
|
||||
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
|
||||
private UUID id;
|
||||
public final static String _id = "id";
|
||||
|
||||
@Column(name = "\"user\"", columnDefinition = "uuid", nullable = false)
|
||||
private UUID userId;
|
||||
public final static String _userId = "userId";
|
||||
|
||||
@Column(name = "\"external_id\"", length = UserCredentialEntity._externalIdLength, nullable = false)
|
||||
private String externalId;
|
||||
public final static String _externalId = "externalId";
|
||||
public final static int _externalIdLength = 512;
|
||||
|
||||
@Column(name = "created_at", nullable = false)
|
||||
private Instant createdAt;
|
||||
|
||||
public static final String _createdAt = "createdAt";
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public UUID getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(UUID userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getExternalId() {
|
||||
return externalId;
|
||||
}
|
||||
|
||||
public void setExternalId(String externalId) {
|
||||
this.externalId = externalId;
|
||||
}
|
||||
|
||||
public Instant getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
package eu.eudat.data;
|
||||
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.data.converters.enums.IsActiveConverter;
|
||||
import eu.eudat.data.old.helpers.EntityBinder;
|
||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"User\"")
|
||||
public class UserEntity implements DataEntity<UserEntity, UUID> {
|
||||
|
||||
@Id
|
||||
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
|
||||
private UUID id;
|
||||
public final static String _id = "id";
|
||||
|
||||
@Column(name = "name", length = UserEntity._nameLength, nullable = true)
|
||||
private String name = null;
|
||||
public final static String _name = "name";
|
||||
public final static int _nameLength = 250;
|
||||
|
||||
|
||||
@Column(name = "created_at", nullable = false)
|
||||
private Instant createdAt;
|
||||
|
||||
public static final String _createdAt = "createdAt";
|
||||
|
||||
@Column(name = "updated_at", nullable = false)
|
||||
private Instant updatedAt;
|
||||
|
||||
public static final String _updatedAt = "updatedAt";
|
||||
|
||||
@Column(name = "is_active", nullable = false)
|
||||
@Convert(converter = IsActiveConverter.class)
|
||||
private IsActive isActive;
|
||||
public static final String _isActive = "isActive";
|
||||
|
||||
@Column(name = "additional_info", nullable = true)
|
||||
private String additionalInfo;
|
||||
public final static String _additionalInfo = "additionalInfo";
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Instant getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Instant createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
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 IsActive getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(IsActive isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
public Instant getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package eu.eudat.data;
|
||||
|
||||
import eu.eudat.data.old.helpers.EntityBinder;
|
||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"UserRole\"")
|
||||
public class UserRoleEntity implements DataEntity<UserRoleEntity, UUID> {
|
||||
@Id
|
||||
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
|
||||
private UUID id;
|
||||
public static final String _id = "id";
|
||||
|
||||
@Column(name = "\"role\"", length = UserRoleEntity._roleLength, nullable = false)
|
||||
private String role;
|
||||
public static final String _role = "role";
|
||||
public static final int _roleLength = 512;
|
||||
|
||||
@Column(name = "\"user\"", nullable = false)
|
||||
private UUID userId;
|
||||
public static final String _userId = "userId";
|
||||
|
||||
|
||||
@Column(name = "created_at", nullable = false)
|
||||
private Instant createdAt;
|
||||
|
||||
public static final String _createdAt = "createdAt";
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public UUID getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(UUID userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Instant getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Instant createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(UserRoleEntity entity) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserRoleEntity buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
||||
String currentBase = base.isEmpty() ? "" : base + ".";
|
||||
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package eu.eudat.data.converters.enums;
|
||||
|
||||
import eu.eudat.commons.enums.ContactInfoType;
|
||||
import eu.eudat.commons.enums.DescriptionStatus;
|
||||
import jakarta.persistence.Converter;
|
||||
|
||||
@Converter
|
||||
public class ContactInfoTypeConverter extends DatabaseEnumConverter<ContactInfoType, Short>{
|
||||
protected ContactInfoType of(Short i) {
|
||||
return ContactInfoType.of(i);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package eu.eudat.data.old;
|
||||
|
||||
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.data.old.helpers.EntityBinder;
|
||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
||||
|
||||
|
@ -44,7 +45,7 @@ public class DataRepository implements Serializable, DataEntity<DataRepository,
|
|||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "\"CreationUser\"")
|
||||
private UserInfo creationUser;
|
||||
private UserEntity creationUser;
|
||||
|
||||
|
||||
public Short getStatus() {
|
||||
|
@ -110,10 +111,10 @@ public class DataRepository implements Serializable, DataEntity<DataRepository,
|
|||
this.definition = definition;
|
||||
}
|
||||
|
||||
public UserInfo getCreationUser() {
|
||||
public UserEntity getCreationUser() {
|
||||
return creationUser;
|
||||
}
|
||||
public void setCreationUser(UserInfo creationUser) {
|
||||
public void setCreationUser(UserEntity creationUser) {
|
||||
this.creationUser = creationUser;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.eudat.data.old;
|
||||
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.data.converters.DateToUTCConverter;
|
||||
import eu.eudat.data.old.helpers.EntityBinder;
|
||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
||||
|
@ -37,7 +38,7 @@ public class ExternalDataset implements DataEntity<ExternalDataset,UUID> {
|
|||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "\"CreationUser\"", nullable = true)
|
||||
private UserInfo creationUser;
|
||||
private UserEntity creationUser;
|
||||
|
||||
|
||||
public UUID getId() {
|
||||
|
@ -82,10 +83,10 @@ public class ExternalDataset implements DataEntity<ExternalDataset,UUID> {
|
|||
this.modified = modified;
|
||||
}
|
||||
|
||||
public UserInfo getCreationUser() {
|
||||
public UserEntity getCreationUser() {
|
||||
return creationUser;
|
||||
}
|
||||
public void setCreationUser(UserInfo creationUser) {
|
||||
public void setCreationUser(UserEntity creationUser) {
|
||||
this.creationUser = creationUser;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.eudat.data.old;
|
||||
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.data.converters.DateToUTCConverter;
|
||||
import eu.eudat.data.old.helpers.EntityBinder;
|
||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
||||
|
@ -43,7 +44,7 @@ public class FileUpload implements DataEntity<FileUpload, UUID> {
|
|||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "\"Creator\"")
|
||||
private UserInfo creator;
|
||||
private UserEntity creator;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
|
@ -94,10 +95,10 @@ public class FileUpload implements DataEntity<FileUpload, UUID> {
|
|||
this.isDeleted = isDeleted;
|
||||
}
|
||||
|
||||
public UserInfo getCreator() {
|
||||
public UserEntity getCreator() {
|
||||
return creator;
|
||||
}
|
||||
public void setCreator(UserInfo creator) {
|
||||
public void setCreator(UserEntity creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
|
@ -121,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 UserInfo().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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.eudat.data.old;
|
||||
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
@ -92,7 +93,7 @@ public class Funder implements DataEntity<Funder, UUID> {
|
|||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "\"CreationUser\"", nullable = true)
|
||||
private UserInfo creationUser;
|
||||
private UserEntity creationUser;
|
||||
|
||||
|
||||
public UUID getId() {
|
||||
|
@ -151,10 +152,10 @@ public class Funder implements DataEntity<Funder, UUID> {
|
|||
this.type = type;
|
||||
}
|
||||
|
||||
public UserInfo getCreationUser() {
|
||||
public UserEntity getCreationUser() {
|
||||
return creationUser;
|
||||
}
|
||||
public void setCreationUser(UserInfo creationUser) {
|
||||
public void setCreationUser(UserEntity creationUser) {
|
||||
this.creationUser = creationUser;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.eudat.data.old;
|
||||
|
||||
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.data.converters.DateToUTCConverter;
|
||||
import eu.eudat.data.old.helpers.EntityBinder;
|
||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
||||
|
@ -116,7 +117,7 @@ public class Grant implements DataEntity<Grant, UUID> {
|
|||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "\"CreationUser\"", nullable = true)
|
||||
private UserInfo creationUser;
|
||||
private UserEntity creationUser;
|
||||
|
||||
@Column(name = "\"Created\"")
|
||||
private Date created = null;
|
||||
|
@ -236,10 +237,10 @@ public class Grant implements DataEntity<Grant, UUID> {
|
|||
// this.dmps = dmps;
|
||||
// }
|
||||
|
||||
public UserInfo getCreationUser() {
|
||||
public UserEntity getCreationUser() {
|
||||
return creationUser;
|
||||
}
|
||||
public void setCreationUser(UserInfo creationUser) {
|
||||
public void setCreationUser(UserEntity creationUser) {
|
||||
this.creationUser = creationUser;
|
||||
}
|
||||
|
||||
|
@ -292,7 +293,7 @@ public class Grant implements DataEntity<Grant, UUID> {
|
|||
// 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 UserInfo().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0);
|
||||
this.creationUser = tuple.stream().map(x -> new UserEntity().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.eudat.data.old;
|
||||
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.data.old.helpers.EntityBinder;
|
||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
||||
|
||||
|
@ -22,7 +23,7 @@ public class Invitation implements DataEntity<Invitation, UUID> {
|
|||
|
||||
@OneToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "\"CreationUser\"", nullable = false)
|
||||
private UserInfo user;
|
||||
private UserEntity user;
|
||||
|
||||
// @OneToOne(fetch = FetchType.EAGER)
|
||||
// @JoinColumn(name = "\"Dmp\"", nullable = false)
|
||||
|
@ -53,11 +54,11 @@ public class Invitation implements DataEntity<Invitation, UUID> {
|
|||
this.invitationEmail = invitationEmail;
|
||||
}
|
||||
|
||||
public UserInfo getUser() {
|
||||
public UserEntity getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(UserInfo user) {
|
||||
public void setUser(UserEntity user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.eudat.data.old;
|
||||
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.data.converters.DateToUTCConverter;
|
||||
import eu.eudat.data.old.helpers.EntityBinder;
|
||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
||||
|
@ -23,7 +24,7 @@ public class Lock implements DataEntity<Lock, UUID> {
|
|||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "\"LockedBy\"", nullable = false)
|
||||
private UserInfo lockedBy;
|
||||
private UserEntity lockedBy;
|
||||
|
||||
@Column(name = "\"LockedAt\"")
|
||||
@Convert(converter = DateToUTCConverter.class)
|
||||
|
@ -50,11 +51,11 @@ public class Lock implements DataEntity<Lock, UUID> {
|
|||
this.target = target;
|
||||
}
|
||||
|
||||
public UserInfo getLockedBy() {
|
||||
public UserEntity getLockedBy() {
|
||||
return lockedBy;
|
||||
}
|
||||
|
||||
public void setLockedBy(UserInfo lockedBy) {
|
||||
public void setLockedBy(UserEntity lockedBy) {
|
||||
this.lockedBy = lockedBy;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ 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.data.UserEntity;
|
||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
@ -22,7 +23,7 @@ public class Notification implements DataEntity<Notification, UUID> {
|
|||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "\"UserId\"")
|
||||
private UserInfo userId;
|
||||
private UserEntity userId;
|
||||
|
||||
@Enumerated
|
||||
@Column(name = "\"IsActive\"", nullable = false)
|
||||
|
@ -67,11 +68,11 @@ public class Notification implements DataEntity<Notification, UUID> {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
public UserInfo getUserId() {
|
||||
public UserEntity getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(UserInfo userId) {
|
||||
public void setUserId(UserEntity userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.eudat.data.old;
|
||||
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.data.converters.DateToUTCConverter;
|
||||
import eu.eudat.data.old.helpers.EntityBinder;
|
||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
||||
|
@ -101,7 +102,7 @@ public class Project implements DataEntity<Project, UUID> {
|
|||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "\"CreationUser\"", nullable = true)
|
||||
private UserInfo creationUser;
|
||||
private UserEntity creationUser;
|
||||
|
||||
@Column(name = "\"Created\"")
|
||||
private Date created = null;
|
||||
|
@ -194,10 +195,10 @@ public class Project implements DataEntity<Project, UUID> {
|
|||
this.status = status;
|
||||
}
|
||||
|
||||
public UserInfo getCreationUser() {
|
||||
public UserEntity getCreationUser() {
|
||||
return creationUser;
|
||||
}
|
||||
public void setCreationUser(UserInfo creationUser) {
|
||||
public void setCreationUser(UserEntity creationUser) {
|
||||
this.creationUser = creationUser;
|
||||
}
|
||||
|
||||
|
@ -282,7 +283,7 @@ public class Project implements DataEntity<Project, UUID> {
|
|||
// 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 UserInfo().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0);
|
||||
this.creationUser = tuple.stream().map(x -> new UserEntity().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package eu.eudat.data.old;
|
|||
|
||||
|
||||
import eu.eudat.data.DescriptionEntity;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.data.converters.DateToUTCConverter;
|
||||
import eu.eudat.data.old.helpers.EntityBinder;
|
||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
||||
|
@ -52,7 +53,7 @@ public class Registry implements DataEntity<Registry, UUID> {
|
|||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "\"CreationUser\"", nullable = true)
|
||||
private UserInfo creationUser;
|
||||
private UserEntity creationUser;
|
||||
|
||||
|
||||
public Short getStatus() {
|
||||
|
@ -125,10 +126,10 @@ public class Registry implements DataEntity<Registry, UUID> {
|
|||
this.descriptionEntities = descriptionEntities;
|
||||
}
|
||||
|
||||
public UserInfo getCreationUser() {
|
||||
public UserEntity getCreationUser() {
|
||||
return creationUser;
|
||||
}
|
||||
public void setCreationUser(UserInfo creationUser) {
|
||||
public void setCreationUser(UserEntity creationUser) {
|
||||
this.creationUser = creationUser;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.eudat.data.old;
|
||||
|
||||
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.data.converters.DateToUTCConverter;
|
||||
import eu.eudat.data.old.helpers.EntityBinder;
|
||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
||||
|
@ -8,7 +9,6 @@ import eu.eudat.data.old.queryableentity.DataEntity;
|
|||
import jakarta.persistence.*;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class Researcher implements DataEntity<Researcher, UUID> {
|
|||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "\"CreationUser\"", nullable = true)
|
||||
private UserInfo creationUser;
|
||||
private UserEntity creationUser;
|
||||
|
||||
public Short getStatus() {
|
||||
return status;
|
||||
|
@ -130,10 +130,10 @@ public class Researcher implements DataEntity<Researcher, UUID> {
|
|||
// this.dMPs = dMPs;
|
||||
// }
|
||||
|
||||
public UserInfo getCreationUser() {
|
||||
public UserEntity getCreationUser() {
|
||||
return creationUser;
|
||||
}
|
||||
public void setCreationUser(UserInfo creationUser) {
|
||||
public void setCreationUser(UserEntity creationUser) {
|
||||
this.creationUser = creationUser;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.eudat.data.old;
|
||||
|
||||
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.data.converters.DateToUTCConverter;
|
||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
||||
|
||||
|
@ -46,7 +47,7 @@ public class Service implements DataEntity<Service, UUID> {
|
|||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "\"CreationUser\"", nullable = true)
|
||||
private UserInfo creationUser;
|
||||
private UserEntity creationUser;
|
||||
|
||||
|
||||
public Short getStatus() {
|
||||
|
@ -112,10 +113,10 @@ public class Service implements DataEntity<Service, UUID> {
|
|||
this.definition = definition;
|
||||
}
|
||||
|
||||
public UserInfo getCreationUser() {
|
||||
public UserEntity getCreationUser() {
|
||||
return creationUser;
|
||||
}
|
||||
public void setCreationUser(UserInfo creationUser) {
|
||||
public void setCreationUser(UserEntity creationUser) {
|
||||
this.creationUser = creationUser;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,230 +0,0 @@
|
|||
package eu.eudat.data.old;
|
||||
|
||||
import eu.eudat.data.CredentialEntity;
|
||||
import eu.eudat.data.converters.DateToUTCConverter;
|
||||
import eu.eudat.data.old.helpers.EntityBinder;
|
||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"UserInfo\"")
|
||||
@NamedEntityGraphs({
|
||||
@NamedEntityGraph(
|
||||
name = "userInfo",
|
||||
attributeNodes = {@NamedAttributeNode("userRoles"), @NamedAttributeNode("additionalinfo")}),
|
||||
})
|
||||
public class UserInfo implements DataEntity<UserInfo, UUID> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||
private UUID id;
|
||||
public final static String _id = "id";
|
||||
|
||||
|
||||
@Column(name = "email")
|
||||
private String email = null;
|
||||
public final static String _email = "email";
|
||||
|
||||
@Column(name = "authorization_level", nullable = false)
|
||||
private Short authorization_level; //0 admin, 1 user
|
||||
public final static String _authorization_level = "authorization_level";
|
||||
|
||||
@Column(name = "usertype", nullable = false)
|
||||
private Short usertype; // 0 internal, 1 external
|
||||
public final static String _usertype = "usertype";
|
||||
|
||||
@Column(name = "userstatus", nullable = false)
|
||||
private Short userStatus; // 0 active, 1 inactive
|
||||
public final static String _userStatus = "userStatus";
|
||||
|
||||
@Column(name = "verified_email", nullable = true)
|
||||
private Boolean verified_email = null;
|
||||
public final static String _verified_email = "verified_email";
|
||||
|
||||
@Column(name = "name", nullable = true)
|
||||
private String name = null;
|
||||
public final static String _name = "name";
|
||||
|
||||
|
||||
@Column(name = "created", nullable = false)
|
||||
@Convert(converter = DateToUTCConverter.class)
|
||||
private Date created = null;
|
||||
public final static String _created = "created";
|
||||
|
||||
|
||||
@Column(name = "lastloggedin", nullable = true)
|
||||
@Convert(converter = DateToUTCConverter.class)
|
||||
private Date lastloggedin = null;
|
||||
public final static String _lastloggedin = "lastloggedin";
|
||||
|
||||
|
||||
@Column(name = "additionalinfo", nullable = true)
|
||||
private String additionalinfo;
|
||||
public final static String _additionalinfo = "additionalinfo";
|
||||
|
||||
// @OneToMany(fetch = FetchType.LAZY)
|
||||
// @JoinTable(name = "\"UserDMP\"",
|
||||
// joinColumns = {@JoinColumn(name = "usr", referencedColumnName = "id")},
|
||||
// inverseJoinColumns = {@JoinColumn(name = "dmp", referencedColumnName = "\"ID\"")}
|
||||
// )
|
||||
// private Set<DMP> dmps;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "Id")
|
||||
private Set<CredentialEntity> credentialEntities = new HashSet<>();
|
||||
|
||||
@OneToMany(mappedBy = "userInfo", fetch = FetchType.LAZY)
|
||||
private Set<UserRole> userRoles = new HashSet<>();
|
||||
|
||||
@OneToMany(mappedBy = "lockedBy", fetch = FetchType.LAZY)
|
||||
private Set<Lock> locks = new HashSet<>();
|
||||
|
||||
@OneToMany(mappedBy = "userId", fetch = FetchType.LAZY)
|
||||
private Set<Notification> notifications = new HashSet<>();
|
||||
|
||||
// public Set<DMP> getDmps() {
|
||||
// return dmps;
|
||||
// }
|
||||
//
|
||||
// public void setDmps(Set<DMP> dmps) {
|
||||
// this.dmps = dmps;
|
||||
// }
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public Date getLastloggedin() {
|
||||
return lastloggedin;
|
||||
}
|
||||
|
||||
public void setLastloggedin(Date lastloggedin) {
|
||||
this.lastloggedin = lastloggedin;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public Short getAuthorization_level() {
|
||||
return authorization_level;
|
||||
}
|
||||
|
||||
public void setAuthorization_level(Short authorization_level) {
|
||||
this.authorization_level = authorization_level;
|
||||
}
|
||||
|
||||
public Short getUsertype() {
|
||||
return usertype;
|
||||
}
|
||||
|
||||
public void setUsertype(Short usertype) {
|
||||
this.usertype = usertype;
|
||||
}
|
||||
|
||||
public Boolean getVerified_email() {
|
||||
return verified_email;
|
||||
}
|
||||
|
||||
public void setVerified_email(Boolean verified_email) {
|
||||
this.verified_email = verified_email;
|
||||
}
|
||||
|
||||
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 Set<CredentialEntity> getCredentials() {
|
||||
return credentialEntities;
|
||||
}
|
||||
|
||||
public void setCredentials(Set<CredentialEntity> credentialEntities) {
|
||||
this.credentialEntities = credentialEntities;
|
||||
}
|
||||
|
||||
public Set<UserRole> getUserRoles() {
|
||||
return userRoles;
|
||||
}
|
||||
|
||||
public void setUserRoles(Set<UserRole> userRoles) {
|
||||
this.userRoles = userRoles;
|
||||
}
|
||||
|
||||
public Set<Lock> getLocks() {
|
||||
return locks;
|
||||
}
|
||||
|
||||
public void setLocks(Set<Lock> locks) {
|
||||
this.locks = locks;
|
||||
}
|
||||
|
||||
public Set<Notification> getNotifications() {
|
||||
return notifications;
|
||||
}
|
||||
|
||||
public void setNotifications(Set<Notification> notifications) {
|
||||
this.notifications = notifications;
|
||||
}
|
||||
|
||||
public Short getUserStatus() {
|
||||
return userStatus;
|
||||
}
|
||||
|
||||
public void setUserStatus(Short userStatus) {
|
||||
this.userStatus = userStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(UserInfo entity) {
|
||||
this.name = entity.getName();
|
||||
this.email = entity.getEmail();
|
||||
this.additionalinfo = entity.getAdditionalinfo();
|
||||
this.lastloggedin = entity.getLastloggedin();
|
||||
this.userRoles = entity.getUserRoles();
|
||||
this.userStatus = entity.getUserStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserInfo 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;
|
||||
}
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
package eu.eudat.data.old;
|
||||
|
||||
import eu.eudat.data.old.helpers.EntityBinder;
|
||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"UserRole\"")
|
||||
public class UserRole implements DataEntity<UserRole, UUID> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||
private UUID id;
|
||||
|
||||
@Column(name = "\"Role\"", nullable = false)
|
||||
private int role;
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "\"UserId\"", nullable = false)
|
||||
private UserInfo userInfo;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(int role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public UserInfo getUserInfo() {
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
public void setUserInfo(UserInfo userInfo) {
|
||||
this.userInfo = userInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(UserRole entity) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserRole 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;
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ package eu.eudat.model;
|
|||
import eu.eudat.commons.enums.DmpUserRole;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.data.converters.enums.IsActiveConverter;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.time.Instant;
|
||||
|
@ -20,7 +20,7 @@ public class DmpUser {
|
|||
public static final String _dmp = "dmp";
|
||||
|
||||
@Column(name = "user", columnDefinition = "uuid", nullable = false)
|
||||
private UserInfo user;
|
||||
private UserEntity user;
|
||||
|
||||
public static final String _user = "user";
|
||||
|
||||
|
@ -60,11 +60,11 @@ public class DmpUser {
|
|||
this.dmp = dmp;
|
||||
}
|
||||
|
||||
public UserInfo getUser() {
|
||||
public UserEntity getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(UserInfo user) {
|
||||
public void setUser(UserEntity user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ public class PublicDmpUser {
|
|||
|
||||
|
||||
public static final String _user = "user";
|
||||
private PublicUserInfo user;
|
||||
private PublicUser user;
|
||||
|
||||
|
||||
public static final String _role = "role";
|
||||
|
@ -36,11 +36,11 @@ public class PublicDmpUser {
|
|||
this.dmp = dmp;
|
||||
}
|
||||
|
||||
public PublicUserInfo getUser() {
|
||||
public PublicUser getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(PublicUserInfo user) {
|
||||
public void setUser(PublicUser user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package eu.eudat.model;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PublicUserInfo {
|
||||
public class PublicUser {
|
||||
|
||||
public final static String _id = "id";
|
||||
private UUID id;
|
|
@ -0,0 +1,129 @@
|
|||
package eu.eudat.model;
|
||||
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.enums.UserSettingsType;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class User {
|
||||
|
||||
private UUID id;
|
||||
public static final String _id = "id";
|
||||
|
||||
private String name;
|
||||
public static final String _name = "name";
|
||||
|
||||
private Instant createdAt;
|
||||
|
||||
public static final String _createdAt = "createdAt";
|
||||
|
||||
private Instant updatedAt;
|
||||
|
||||
public static final String _updatedAt = "updatedAt";
|
||||
|
||||
private IsActive isActive;
|
||||
|
||||
public static final String _isActive = "isActive";
|
||||
|
||||
private String hash;
|
||||
|
||||
public static final String _hash = "hash";
|
||||
|
||||
private UserAdditionalInfo additionalInfo;
|
||||
|
||||
public static final String _additionalInfo = "additionalInfo";
|
||||
|
||||
private List<UserContactInfo> contacts;
|
||||
|
||||
public static final String _contacts = "contacts";
|
||||
|
||||
private List<UserRole> roles;
|
||||
|
||||
public static final String _roles = "roles";
|
||||
|
||||
private List<UserCredential> credentials;
|
||||
|
||||
public static final String _credentials = "credentials";
|
||||
|
||||
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 getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Instant createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Instant getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Instant updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public IsActive getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(IsActive isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
public String getHash() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
public void setHash(String hash) {
|
||||
this.hash = hash;
|
||||
}
|
||||
|
||||
public UserAdditionalInfo getAdditionalInfo() {
|
||||
return additionalInfo;
|
||||
}
|
||||
|
||||
public void setAdditionalInfo(UserAdditionalInfo additionalInfo) {
|
||||
this.additionalInfo = additionalInfo;
|
||||
}
|
||||
|
||||
public List<UserContactInfo> getContacts() {
|
||||
return contacts;
|
||||
}
|
||||
|
||||
public void setContacts(List<UserContactInfo> contacts) {
|
||||
this.contacts = contacts;
|
||||
}
|
||||
|
||||
public List<UserRole> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(List<UserRole> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
public List<UserCredential> getCredentials() {
|
||||
return credentials;
|
||||
}
|
||||
|
||||
public void setCredentials(List<UserCredential> credentials) {
|
||||
this.credentials = credentials;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package eu.eudat.model;
|
||||
|
||||
import eu.eudat.commons.enums.ContactInfoType;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UserAdditionalInfo {
|
||||
private String avatarUrl;
|
||||
public static final String _avatarUrl = "avatarUrl";
|
||||
|
||||
private String timezone;
|
||||
public static final String _timezone = "timezone";
|
||||
|
||||
private String culture;
|
||||
public static final String _culture = "culture";
|
||||
|
||||
private String language;
|
||||
public static final String _language = "language";
|
||||
|
||||
public String getAvatarUrl() {
|
||||
return avatarUrl;
|
||||
}
|
||||
|
||||
public void setAvatarUrl(String avatarUrl) {
|
||||
this.avatarUrl = avatarUrl;
|
||||
}
|
||||
|
||||
public String getTimezone() {
|
||||
return timezone;
|
||||
}
|
||||
|
||||
public void setTimezone(String timezone) {
|
||||
this.timezone = timezone;
|
||||
}
|
||||
|
||||
public String getCulture() {
|
||||
return culture;
|
||||
}
|
||||
|
||||
public void setCulture(String culture) {
|
||||
this.culture = culture;
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package eu.eudat.model;
|
||||
|
||||
import eu.eudat.commons.enums.ContactInfoType;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UserContactInfo {
|
||||
private UUID id;
|
||||
public static final String _id = "id";
|
||||
|
||||
private String value;
|
||||
public static final String _value = "value";
|
||||
|
||||
private ContactInfoType type;
|
||||
public static final String _type = "type";
|
||||
|
||||
private int ordinal;
|
||||
public static final String _ordinal = "ordinal";
|
||||
|
||||
private User user;
|
||||
public static final String _user = "user";
|
||||
|
||||
private Instant createdAt;
|
||||
|
||||
public static final String _createdAt = "createdAt";
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public ContactInfoType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(ContactInfoType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
public void setOrdinal(int ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public Instant getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Instant createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package eu.eudat.model;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UserCredential {
|
||||
private UUID id;
|
||||
public static final String _id = "id";
|
||||
|
||||
private String externalId;
|
||||
public static final String _externalId = "externalId";
|
||||
|
||||
private User user;
|
||||
public static final String _user = "user";
|
||||
|
||||
private Instant createdAt;
|
||||
|
||||
public static final String _createdAt = "createdAt";
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getExternalId() {
|
||||
return externalId;
|
||||
}
|
||||
|
||||
public void setExternalId(String externalId) {
|
||||
this.externalId = externalId;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public Instant getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Instant createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package eu.eudat.model;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UserRole {
|
||||
private UUID id;
|
||||
public static final String _id = "id";
|
||||
|
||||
private String role;
|
||||
public static final String _role = "role";
|
||||
|
||||
private User user;
|
||||
public static final String _user = "user";
|
||||
|
||||
private Instant createdAt;
|
||||
|
||||
public static final String _createdAt = "createdAt";
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public Instant getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Instant createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ package eu.eudat.model.builder;
|
|||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.DmpUserEntity;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.model.Dmp;
|
||||
import eu.eudat.model.DmpUser;
|
||||
import eu.eudat.model.Reference;
|
||||
|
@ -56,7 +56,7 @@ public class DmpUserBuilder extends BaseBuilder<DmpUser, DmpUserEntity>{
|
|||
return new ArrayList<>();
|
||||
|
||||
FieldSet userFields = fields.extractPrefixed(this.asPrefix(DmpUser._user));
|
||||
Map<UUID, UserInfo> userItemsMap = this.collectUsers(userFields, data);
|
||||
Map<UUID, UserEntity> userItemsMap = this.collectUsers(userFields, data);
|
||||
|
||||
FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(DmpUser._dmp));
|
||||
Map<UUID, Dmp> dmpItemsMap = this.collectDmps(dmpFields, data);
|
||||
|
@ -85,21 +85,21 @@ public class DmpUserBuilder extends BaseBuilder<DmpUser, DmpUserEntity>{
|
|||
}
|
||||
|
||||
//TODO: Hookup user info when refactored
|
||||
private Map<UUID, UserInfo> collectUsers(FieldSet fields, List<DmpUserEntity> data) throws MyApplicationException {
|
||||
private Map<UUID, UserEntity> collectUsers(FieldSet fields, List<DmpUserEntity> data) throws MyApplicationException {
|
||||
if (fields.isEmpty() || data.isEmpty())
|
||||
return null;
|
||||
this.logger.debug("checking related - {}", UserInfo.class.getSimpleName());
|
||||
this.logger.debug("checking related - {}", UserEntity.class.getSimpleName());
|
||||
|
||||
Map<UUID, UserInfo> itemMap;
|
||||
Map<UUID, UserEntity> itemMap;
|
||||
if (!fields.hasOtherField(this.asIndexer("id"))) {
|
||||
itemMap = this.asEmpty(
|
||||
data.stream().map(DmpUserEntity::getUser).distinct().collect(Collectors.toList()),
|
||||
x -> {
|
||||
UserInfo item = new UserInfo();
|
||||
UserEntity item = new UserEntity();
|
||||
item.setId(x);
|
||||
return item;
|
||||
},
|
||||
UserInfo::getId);
|
||||
UserEntity::getId);
|
||||
} else {
|
||||
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure("id");
|
||||
// ReferenceQuery q = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).ids(data.stream().map(DmpReferenceEntity::getReferenceId).distinct().collect(Collectors.toList()));
|
||||
|
|
|
@ -3,10 +3,9 @@ package eu.eudat.model.builder;
|
|||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.DmpUserEntity;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.model.PublicDmp;
|
||||
import eu.eudat.model.PublicDmpUser;
|
||||
import eu.eudat.model.PublicUserInfo;
|
||||
import eu.eudat.model.PublicUser;
|
||||
import eu.eudat.query.DmpQuery;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
|
@ -56,7 +55,7 @@ public class PublicDmpUserBuilder extends BaseBuilder<PublicDmpUser, DmpUserEnti
|
|||
return new ArrayList<>();
|
||||
|
||||
FieldSet userFields = fields.extractPrefixed(this.asPrefix(PublicDmpUser._user));
|
||||
Map<UUID, PublicUserInfo> userItemsMap = new HashMap<>(); //TODO
|
||||
Map<UUID, PublicUser> userItemsMap = new HashMap<>(); //TODO
|
||||
|
||||
FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(PublicDmpUser._dmp));
|
||||
Map<UUID, PublicDmp> dmpItemsMap = this.collectDmps(dmpFields, data);
|
||||
|
|
|
@ -2,7 +2,6 @@ package eu.eudat.model.censorship;
|
|||
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.DmpUser;
|
||||
import eu.eudat.model.PublicDmpUser;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.censor.CensorFactory;
|
||||
|
@ -14,8 +13,6 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
|||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class PublicDmpUserCensor extends BaseCensor {
|
||||
|
@ -40,7 +37,7 @@ public class PublicDmpUserCensor extends BaseCensor {
|
|||
FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDmpUser._dmp));
|
||||
this.censorFactory.censor(PublicDmpCensor.class).censor(dmpFields);
|
||||
FieldSet userFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDmpUser._user));
|
||||
this.censorFactory.censor(PublicUserInfoCensor.class).censor(userFields);
|
||||
this.censorFactory.censor(PublicUserCensor.class).censor(userFields);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,20 +12,18 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
|||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class PublicUserInfoCensor extends BaseCensor {
|
||||
public class PublicUserCensor extends BaseCensor {
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PublicUserInfoCensor.class));
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PublicUserCensor.class));
|
||||
|
||||
protected final AuthorizationService authService;
|
||||
protected final CensorFactory censorFactory;
|
||||
|
||||
public PublicUserInfoCensor(ConventionService conventionService,
|
||||
AuthorizationService authService,
|
||||
CensorFactory censorFactory) {
|
||||
public PublicUserCensor(ConventionService conventionService,
|
||||
AuthorizationService authService,
|
||||
CensorFactory censorFactory) {
|
||||
super(conventionService);
|
||||
this.authService = authService;
|
||||
this.censorFactory = censorFactory;
|
|
@ -0,0 +1,42 @@
|
|||
package eu.eudat.model.censorship;
|
||||
|
||||
import eu.eudat.authorization.OwnedResource;
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.UserAdditionalInfo;
|
||||
import eu.eudat.model.UserContactInfo;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.censor.CensorFactory;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.DataLogEntry;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class UserAdditionalInfoCensor extends BaseCensor {
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserAdditionalInfoCensor.class));
|
||||
|
||||
protected final AuthorizationService authService;
|
||||
|
||||
|
||||
public UserAdditionalInfoCensor(ConventionService conventionService, AuthorizationService authService) {
|
||||
super(conventionService);
|
||||
this.authService = authService;
|
||||
}
|
||||
|
||||
public void censor(FieldSet fields, UUID userId) {
|
||||
logger.debug(new DataLogEntry("censoring fields", fields));
|
||||
if (fields == null || fields.isEmpty())
|
||||
return;
|
||||
this.authService.authorizeAtLeastOneForce(userId != null ? List.of(new OwnedResource(userId)) : null, Permission.BrowseUser);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package eu.eudat.model.censorship;
|
||||
|
||||
import eu.eudat.authorization.OwnedResource;
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.Description;
|
||||
import eu.eudat.model.User;
|
||||
import eu.eudat.model.UserContactInfo;
|
||||
import eu.eudat.model.censorship.descriptionproperties.PropertyDefinitionCensor;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.censor.CensorFactory;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.DataLogEntry;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class UserCensor extends BaseCensor {
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserCensor.class));
|
||||
|
||||
protected final AuthorizationService authService;
|
||||
|
||||
protected final CensorFactory censorFactory;
|
||||
|
||||
public UserCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) {
|
||||
super(conventionService);
|
||||
this.authService = authService;
|
||||
this.censorFactory = censorFactory;
|
||||
}
|
||||
|
||||
public void censor(FieldSet fields, UUID userId) {
|
||||
logger.debug(new DataLogEntry("censoring fields", fields));
|
||||
if (fields == null || fields.isEmpty())
|
||||
return;
|
||||
this.authService.authorizeAtLeastOneForce(userId != null ? List.of(new OwnedResource(userId)) : null, Permission.BrowseUser);
|
||||
|
||||
FieldSet rolesFields = fields.extractPrefixed(this.asIndexerPrefix(User._roles));
|
||||
this.censorFactory.censor(UserRoleCensor.class).censor(rolesFields, userId);
|
||||
|
||||
FieldSet contactsFields = fields.extractPrefixed(this.asIndexerPrefix(User._contacts));
|
||||
this.censorFactory.censor(UserContactInfoCensor.class).censor(contactsFields, userId);
|
||||
|
||||
FieldSet credentialsFields = fields.extractPrefixed(this.asIndexerPrefix(User._credentials));
|
||||
this.censorFactory.censor(UserCredentialCensor.class).censor(credentialsFields, userId);
|
||||
|
||||
FieldSet additionalInfoFields = fields.extractPrefixed(this.asIndexerPrefix(User._additionalInfo));
|
||||
this.censorFactory.censor(UserAdditionalInfoCensor.class).censor(additionalInfoFields, userId);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package eu.eudat.model.censorship;
|
||||
|
||||
import eu.eudat.authorization.OwnedResource;
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.UserContactInfo;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.censor.CensorFactory;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.DataLogEntry;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class UserContactInfoCensor extends BaseCensor {
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserContactInfoCensor.class));
|
||||
|
||||
protected final AuthorizationService authService;
|
||||
|
||||
protected final CensorFactory censorFactory;
|
||||
|
||||
public UserContactInfoCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) {
|
||||
super(conventionService);
|
||||
this.authService = authService;
|
||||
this.censorFactory = censorFactory;
|
||||
}
|
||||
|
||||
public void censor(FieldSet fields, UUID userId) {
|
||||
logger.debug(new DataLogEntry("censoring fields", fields));
|
||||
if (fields == null || fields.isEmpty())
|
||||
return;
|
||||
this.authService.authorizeAtLeastOneForce(userId != null ? List.of(new OwnedResource(userId)) : null, Permission.BrowseUser);
|
||||
|
||||
FieldSet descriptionReferenceFields = fields.extractPrefixed(this.asIndexerPrefix(UserContactInfo._user));
|
||||
this.censorFactory.censor(DescriptionReferenceCensor.class).censor(descriptionReferenceFields, userId);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package eu.eudat.model.censorship;
|
||||
|
||||
import eu.eudat.authorization.OwnedResource;
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.UserCredential;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.censor.CensorFactory;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.DataLogEntry;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class UserCredentialCensor extends BaseCensor {
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserCredentialCensor.class));
|
||||
|
||||
protected final AuthorizationService authService;
|
||||
|
||||
protected final CensorFactory censorFactory;
|
||||
|
||||
public UserCredentialCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) {
|
||||
super(conventionService);
|
||||
this.authService = authService;
|
||||
this.censorFactory = censorFactory;
|
||||
}
|
||||
|
||||
public void censor(FieldSet fields, UUID userId) {
|
||||
logger.debug(new DataLogEntry("censoring fields", fields));
|
||||
if (fields == null || fields.isEmpty())
|
||||
return;
|
||||
this.authService.authorizeAtLeastOneForce(userId != null ? List.of(new OwnedResource(userId)) : null, Permission.BrowseUser);
|
||||
|
||||
FieldSet descriptionReferenceFields = fields.extractPrefixed(this.asIndexerPrefix(UserCredential._user));
|
||||
this.censorFactory.censor(DescriptionReferenceCensor.class).censor(descriptionReferenceFields, userId);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package eu.eudat.model.censorship;
|
||||
|
||||
import eu.eudat.authorization.OwnedResource;
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.Description;
|
||||
import eu.eudat.model.censorship.descriptionproperties.PropertyDefinitionCensor;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.censor.CensorFactory;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.DataLogEntry;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
import eu.eudat.model.UserRole;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class UserRoleCensor extends BaseCensor {
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserRoleCensor.class));
|
||||
|
||||
protected final AuthorizationService authService;
|
||||
|
||||
protected final CensorFactory censorFactory;
|
||||
|
||||
public UserRoleCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) {
|
||||
super(conventionService);
|
||||
this.authService = authService;
|
||||
this.censorFactory = censorFactory;
|
||||
}
|
||||
|
||||
public void censor(FieldSet fields, UUID userId) {
|
||||
logger.debug(new DataLogEntry("censoring fields", fields));
|
||||
if (fields == null || fields.isEmpty())
|
||||
return;
|
||||
this.authService.authorizeAtLeastOneForce(userId != null ? List.of(new OwnedResource(userId)) : null, Permission.BrowseUser);
|
||||
|
||||
FieldSet descriptionReferenceFields = fields.extractPrefixed(this.asIndexerPrefix(UserRole._user));
|
||||
this.censorFactory.censor(DescriptionReferenceCensor.class).censor(descriptionReferenceFields, userId);
|
||||
}
|
||||
|
||||
}
|
|
@ -4,7 +4,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
|||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import eu.eudat.data.DescriptionEntity;
|
||||
import eu.eudat.data.DmpEntity;
|
||||
import eu.eudat.data.DmpUserEntity;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.data.old.*;
|
||||
import eu.eudat.depositinterface.models.*;
|
||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||
|
@ -22,7 +22,6 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DMPToDepositMapper {
|
||||
|
||||
|
@ -127,10 +126,10 @@ public class DMPToDepositMapper {
|
|||
// return deposit;
|
||||
// }
|
||||
|
||||
private static UserInfoDepositModel fromUserInfo(UserInfo entity){
|
||||
private static UserInfoDepositModel fromUserInfo(UserEntity entity){
|
||||
UserInfoDepositModel deposit = new UserInfoDepositModel();
|
||||
deposit.setName(entity.getName());
|
||||
deposit.setEmail(entity.getEmail());
|
||||
//deposit.setEmail(entity.getEmail());//TODO: GetEmail
|
||||
return deposit;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||
import eu.eudat.data.*;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.depositinterface.models.*;
|
||||
import eu.eudat.query.DescriptionQuery;
|
||||
import eu.eudat.query.DescriptionTemplateQuery;
|
||||
|
@ -13,7 +13,6 @@ import eu.eudat.query.DmpDescriptionTemplateQuery;
|
|||
import eu.eudat.query.DmpUserQuery;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.criteria.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
@ -149,9 +148,9 @@ public class DmpEntityDepositMapper {
|
|||
private UserDMPDepositModel toUserDeposit(DmpUserEntity user) {
|
||||
UserDMPDepositModel userDMPDepositModel = new UserDMPDepositModel();
|
||||
userDMPDepositModel.setUser(new UserInfoDepositModel());
|
||||
UserInfo userInfo = this.entityManager.find(UserInfo.class, user.getUser());
|
||||
UserEntity userInfo = this.entityManager.find(UserEntity.class, user.getUser());
|
||||
userDMPDepositModel.getUser().setName(userInfo.getName());
|
||||
userDMPDepositModel.getUser().setEmail(userInfo.getEmail());
|
||||
// userDMPDepositModel.getUser().setEmail(userInfo.getEmail()); //TODO: GetEmail
|
||||
userDMPDepositModel.setRole(user.getRole().getValue().intValue());
|
||||
|
||||
return userDMPDepositModel;
|
||||
|
|
|
@ -1,125 +0,0 @@
|
|||
package eu.eudat.query;
|
||||
|
||||
import eu.eudat.data.CredentialEntity;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
import gr.cite.tools.data.query.QueryBase;
|
||||
import gr.cite.tools.data.query.QueryContext;
|
||||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class CredentialQuery extends QueryBase<CredentialEntity> {
|
||||
|
||||
private Collection<UUID> ids;
|
||||
|
||||
private Collection<UUID> userIds;
|
||||
|
||||
private Collection<Short> statuses;
|
||||
|
||||
public CredentialQuery ids(UUID value) {
|
||||
this.ids = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CredentialQuery ids(UUID... value) {
|
||||
this.ids = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CredentialQuery ids(List<UUID> value) {
|
||||
this.ids = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public CredentialQuery userIds(UUID value) {
|
||||
this.userIds = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CredentialQuery userIds(UUID... value) {
|
||||
this.userIds = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CredentialQuery userIds(List<UUID> value) {
|
||||
this.userIds = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CredentialQuery statuses(Short value) {
|
||||
this.statuses = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CredentialQuery statuses(Short... value) {
|
||||
this.statuses = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CredentialQuery statuses(List<Short> value) {
|
||||
this.statuses = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean isFalseQuery() {
|
||||
return this.isEmpty(this.ids) || this.isEmpty(this.userIds) || this.isEmpty(this.statuses);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<CredentialEntity> entityClass() {
|
||||
return CredentialEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
|
||||
if (this.ids != null) {
|
||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(CredentialEntity._id));
|
||||
for (UUID item : this.ids)
|
||||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
|
||||
if (this.userIds != null) {
|
||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(CredentialEntity._userId));
|
||||
for (UUID item : this.userIds)
|
||||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
|
||||
if (this.statuses != null) {
|
||||
CriteriaBuilder.In<Short> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(CredentialEntity._isActive));
|
||||
for (Short item : this.statuses)
|
||||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
|
||||
if (!predicates.isEmpty()) {
|
||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||
} else {
|
||||
return queryContext.CriteriaBuilder.and();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String fieldNameOf(FieldResolver item) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CredentialEntity convert(Tuple tuple, Set<String> columns) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -266,6 +266,7 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
|
|||
else if (item.match(Description._createdAt) || item.match(PublicDescription._createdAt)) return DescriptionEntity._createdAt;
|
||||
else if (item.match(Description._updatedAt) || item.match(PublicDescription._updatedAt)) return DescriptionEntity._updatedAt;
|
||||
else if (item.match(Description._isActive)) return DescriptionEntity._isActive;
|
||||
else if (item.match(Description._hash)) return DescriptionEntity._updatedAt;
|
||||
else if (item.match(Description._finalizedAt) || item.match(PublicDescription._finalizedAt)) return DescriptionEntity._finalizedAt;
|
||||
else if (item.prefix(Description._dmpDescriptionTemplate) || item.prefix(PublicDescription._dmpDescriptionTemplate)) return DescriptionEntity._dmpDescriptionTemplateId;
|
||||
else if (item.prefix(Description._dmp)) return DescriptionEntity._dmpId;
|
||||
|
|
|
@ -303,6 +303,7 @@ public class DescriptionTemplateQuery extends QueryBase<DescriptionTemplateEntit
|
|||
else if (item.prefix(DescriptionTemplate._type)) return DescriptionTemplateEntity._typeId;
|
||||
else if (item.match(DescriptionTemplate._createdAt)) return DescriptionTemplateEntity._createdAt;
|
||||
else if (item.match(DescriptionTemplate._updatedAt)) return DescriptionTemplateEntity._updatedAt;
|
||||
else if (item.match(DescriptionTemplate._hash)) return DescriptionTemplateEntity._updatedAt;
|
||||
else if (item.match(DescriptionTemplate._isActive)) return DescriptionTemplateEntity._isActive;
|
||||
else if (item.match(DescriptionTemplate._status)) return DescriptionTemplateEntity._status;
|
||||
else if (item.match(DescriptionTemplate._versionStatus)) return DescriptionTemplateEntity._versionStatus;
|
||||
|
|
|
@ -4,7 +4,9 @@ import eu.eudat.authorization.AuthorizationFlags;
|
|||
import eu.eudat.commons.enums.DescriptionTemplateTypeStatus;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.data.DescriptionTemplateEntity;
|
||||
import eu.eudat.data.DescriptionTemplateTypeEntity;
|
||||
import eu.eudat.model.DescriptionTemplate;
|
||||
import eu.eudat.model.DescriptionTemplateType;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
|
@ -177,6 +179,7 @@ public class DescriptionTemplateTypeQuery extends QueryBase<DescriptionTemplateT
|
|||
else if (item.match(DescriptionTemplateType._name)) return DescriptionTemplateTypeEntity._name;
|
||||
else if (item.match(DescriptionTemplateType._createdAt)) return DescriptionTemplateTypeEntity._createdAt;
|
||||
else if (item.match(DescriptionTemplateType._updatedAt)) return DescriptionTemplateTypeEntity._updatedAt;
|
||||
else if (item.match(DescriptionTemplateType._hash)) return DescriptionTemplateTypeEntity._updatedAt;
|
||||
else if (item.match(DescriptionTemplateType._isActive)) return DescriptionTemplateTypeEntity._isActive;
|
||||
else if (item.match(DescriptionTemplateType._status)) return DescriptionTemplateTypeEntity._status;
|
||||
else return null;
|
||||
|
|
|
@ -4,7 +4,9 @@ import eu.eudat.authorization.AuthorizationFlags;
|
|||
import eu.eudat.commons.enums.DmpBlueprintStatus;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.data.DescriptionTemplateEntity;
|
||||
import eu.eudat.data.DmpBlueprintEntity;
|
||||
import eu.eudat.model.DescriptionTemplateType;
|
||||
import eu.eudat.model.DmpBlueprint;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
|
@ -182,6 +184,7 @@ public class DmpBlueprintQuery extends QueryBase<DmpBlueprintEntity> {
|
|||
else if (item.prefix(DmpBlueprint._definition)) return DmpBlueprintEntity._definition;
|
||||
else if (item.match(DmpBlueprint._createdAt)) return DmpBlueprintEntity._createdAt;
|
||||
else if (item.match(DmpBlueprint._updatedAt)) return DmpBlueprintEntity._updatedAt;
|
||||
else if (item.match(DmpBlueprint._hash)) return DmpBlueprintEntity._updatedAt;
|
||||
else if (item.match(DmpBlueprint._isActive)) return DmpBlueprintEntity._isActive;
|
||||
else if (item.match(DmpBlueprint._status)) return DmpBlueprintEntity._status;
|
||||
else return null;
|
||||
|
|
|
@ -5,9 +5,11 @@ import eu.eudat.authorization.Permission;
|
|||
import eu.eudat.commons.enums.DmpAccessType;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.data.DescriptionTemplateEntity;
|
||||
import eu.eudat.data.DmpDescriptionTemplateEntity;
|
||||
import eu.eudat.data.DmpEntity;
|
||||
import eu.eudat.data.DmpUserEntity;
|
||||
import eu.eudat.model.DmpBlueprint;
|
||||
import eu.eudat.model.DmpDescriptionTemplate;
|
||||
import eu.eudat.model.PublicDmpDescriptionTemplate;
|
||||
import eu.eudat.query.utils.QueryUtilsService;
|
||||
|
|
|
@ -302,6 +302,7 @@ public class DmpQuery extends QueryBase<DmpEntity> {
|
|||
else if (item.match(Dmp._description) || item.match(PublicDmp._description)) return DmpEntity._description;
|
||||
else if (item.match(Dmp._createdAt)) return DmpEntity._createdAt;
|
||||
else if (item.match(Dmp._updatedAt)) return DmpEntity._updatedAt;
|
||||
else if (item.match(Dmp._hash)) return DmpEntity._updatedAt;
|
||||
else if (item.match(Dmp._isActive) ) return DmpEntity._isActive;
|
||||
else if (item.match(Dmp._finalizedAt) || item.match(PublicDmp._finalizedAt)) return DmpEntity._finalizedAt;
|
||||
else if (item.match(Dmp._accessType)) return DmpEntity._accessType;
|
||||
|
|
|
@ -4,7 +4,9 @@ import eu.eudat.authorization.AuthorizationFlags;
|
|||
import eu.eudat.commons.enums.EntityType;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.data.DmpEntity;
|
||||
import eu.eudat.data.EntityDoiEntity;
|
||||
import eu.eudat.model.Dmp;
|
||||
import eu.eudat.model.EntityDoi;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
|
@ -235,6 +237,7 @@ public class EntityDoiQuery extends QueryBase<EntityDoiEntity> {
|
|||
return EntityDoiEntity._createdAt;
|
||||
else if (item.match(EntityDoi._updatedAt))
|
||||
return EntityDoiEntity._updatedAt;
|
||||
else if (item.match(EntityDoi._hash)) return EntityDoiEntity._updatedAt;
|
||||
else if (item.match(EntityDoi._isActive))
|
||||
return EntityDoiEntity._isActive;
|
||||
else
|
||||
|
|
|
@ -5,7 +5,9 @@ import eu.eudat.commons.enums.ReferenceType;
|
|||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.enums.ReferenceSourceType;
|
||||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.data.EntityDoiEntity;
|
||||
import eu.eudat.data.ReferenceEntity;
|
||||
import eu.eudat.model.EntityDoi;
|
||||
import eu.eudat.model.PublicReference;
|
||||
import eu.eudat.model.Reference;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
|
|
|
@ -192,6 +192,7 @@ public class TagQuery extends QueryBase<TagEntity> {
|
|||
else if (item.match(Tag._createdBy)) return TagEntity._createdBy;
|
||||
else if (item.match(Tag._createdAt)) return TagEntity._createdAt;
|
||||
else if (item.match(Tag._updatedAt)) return TagEntity._updatedAt;
|
||||
else if (item.match(Tag._hash)) return TagEntity._updatedAt;
|
||||
else if (item.match(Tag._isActive)) return TagEntity._isActive;
|
||||
else return null;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,236 @@
|
|||
package eu.eudat.query;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.commons.enums.ContactInfoType;
|
||||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.data.UserContactInfoEntity;
|
||||
import eu.eudat.model.UserContactInfo;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
import gr.cite.tools.data.query.QueryBase;
|
||||
import gr.cite.tools.data.query.QueryContext;
|
||||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class UserContactInfoQuery extends QueryBase<UserContactInfoEntity> {
|
||||
private Collection<UUID> ids;
|
||||
private Collection<UUID> excludedIds;
|
||||
private Collection<UUID> excludedUserIds;
|
||||
private Collection<UUID> userIds;
|
||||
private Collection<String> values;
|
||||
private Collection<ContactInfoType> types;
|
||||
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
private final UserScope userScope;
|
||||
private final AuthorizationService authService;
|
||||
public UserContactInfoQuery(UserScope userScope, AuthorizationService authService) {
|
||||
this.userScope = userScope;
|
||||
this.authService = authService;
|
||||
}
|
||||
|
||||
public UserContactInfoQuery ids(UUID value) {
|
||||
this.ids = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserContactInfoQuery ids(UUID... value) {
|
||||
this.ids = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserContactInfoQuery ids(Collection<UUID> values) {
|
||||
this.ids = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserContactInfoQuery excludedIds(Collection<UUID> values) {
|
||||
this.excludedIds = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserContactInfoQuery excludedIds(UUID value) {
|
||||
this.excludedIds = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserContactInfoQuery excludedIds(UUID... value) {
|
||||
this.excludedIds = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserContactInfoQuery excludedUserIds(Collection<UUID> values) {
|
||||
this.excludedUserIds = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserContactInfoQuery excludedUserIds(UUID value) {
|
||||
this.excludedUserIds = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserContactInfoQuery excludedUserIds(UUID... value) {
|
||||
this.excludedUserIds = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserContactInfoQuery userIds(UUID value) {
|
||||
this.userIds = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserContactInfoQuery userIds(UUID... value) {
|
||||
this.userIds = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserContactInfoQuery userIds(Collection<UUID> values) {
|
||||
this.userIds = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserContactInfoQuery values(String value) {
|
||||
this.values = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserContactInfoQuery values(String... value) {
|
||||
this.values = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserContactInfoQuery values(Collection<String> values) {
|
||||
this.values = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserContactInfoQuery types(ContactInfoType value) {
|
||||
this.types = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserContactInfoQuery types(ContactInfoType... value) {
|
||||
this.types = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserContactInfoQuery types(Collection<ContactInfoType> values) {
|
||||
this.types = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserContactInfoQuery authorize(EnumSet<AuthorizationFlags> values) {
|
||||
this.authorize = values;
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
protected Boolean isFalseQuery() {
|
||||
return
|
||||
this.isEmpty(this.ids) ||
|
||||
this.isEmpty(this.userIds) ||
|
||||
this.isEmpty(this.excludedIds) ||
|
||||
this.isEmpty(this.values) ||
|
||||
this.isEmpty(this.excludedIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<UserContactInfoEntity> entityClass() {
|
||||
return UserContactInfoEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <X, Y> Predicate applyAuthZ(QueryContext<X, Y> queryContext) {
|
||||
if (this.authorize.contains(AuthorizationFlags.None)) return null;
|
||||
if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseUser)) return null;
|
||||
UUID userId;
|
||||
if (this.authorize.contains(AuthorizationFlags.Owner)) userId = this.userScope.getUserIdSafe();
|
||||
else userId = null;
|
||||
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
if (userId != null) {
|
||||
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._userId)).value(userId));
|
||||
}
|
||||
if (!predicates.isEmpty()) {
|
||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||
} else {
|
||||
return queryContext.CriteriaBuilder.or(); //Creates a false query
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
if (this.ids != null) {
|
||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._id));
|
||||
for (UUID item : this.ids)
|
||||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
if (this.userIds != null) {
|
||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._userId));
|
||||
for (UUID item : this.userIds)
|
||||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
if (this.excludedIds != null) {
|
||||
CriteriaBuilder.In<UUID> notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._id));
|
||||
for (UUID item : this.excludedIds)
|
||||
notInClause.value(item);
|
||||
predicates.add(notInClause.not());
|
||||
}
|
||||
if (this.excludedUserIds != null) {
|
||||
CriteriaBuilder.In<UUID> notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._userId));
|
||||
for (UUID item : this.excludedUserIds)
|
||||
notInClause.value(item);
|
||||
predicates.add(notInClause.not());
|
||||
}
|
||||
if (this.values != null) {
|
||||
CriteriaBuilder.In<String> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._value));
|
||||
for (String item : this.values)
|
||||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
if (!predicates.isEmpty()) {
|
||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String fieldNameOf(FieldResolver item) {
|
||||
if (item.match(UserContactInfo._id)) return UserContactInfoEntity._id;
|
||||
else if (item.match(UserContactInfo._value)) return UserContactInfoEntity._value;
|
||||
else if (item.match(UserContactInfo._ordinal)) return UserContactInfoEntity._ordinal;
|
||||
else if (item.prefix(UserContactInfo._user)) return UserContactInfoEntity._userId;
|
||||
else if (item.match(UserContactInfo._user)) return UserContactInfoEntity._userId;
|
||||
else if (item.prefix(UserContactInfo._type)) return UserContactInfoEntity._type;
|
||||
else if (item.match(UserContactInfo._createdAt) ) return UserContactInfoEntity._createdAt;
|
||||
else return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UserContactInfoEntity convert(Tuple tuple, Set<String> columns) {
|
||||
UserContactInfoEntity item = new UserContactInfoEntity();
|
||||
item.setId(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._id, UUID.class));
|
||||
item.setValue(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._value, String.class));
|
||||
item.setType(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._type, ContactInfoType.class));
|
||||
item.setOrdinal(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._ordinal, Integer.class));
|
||||
item.setUserId(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._userId, UUID.class));
|
||||
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._createdAt, Instant.class));
|
||||
return item;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,193 @@
|
|||
package eu.eudat.query;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.data.UserCredentialEntity;
|
||||
import eu.eudat.model.UserCredential;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
import gr.cite.tools.data.query.QueryBase;
|
||||
import gr.cite.tools.data.query.QueryContext;
|
||||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class UserCredentialQuery extends QueryBase<UserCredentialEntity> {
|
||||
private Collection<UUID> ids;
|
||||
private Collection<UUID> excludedIds;
|
||||
private Collection<UUID> userIds;
|
||||
private Collection<String> externalIds;
|
||||
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
private final UserScope userScope;
|
||||
private final AuthorizationService authService;
|
||||
public UserCredentialQuery(UserScope userScope, AuthorizationService authService) {
|
||||
this.userScope = userScope;
|
||||
this.authService = authService;
|
||||
}
|
||||
|
||||
public UserCredentialQuery ids(UUID value) {
|
||||
this.ids = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserCredentialQuery ids(UUID... value) {
|
||||
this.ids = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserCredentialQuery ids(Collection<UUID> values) {
|
||||
this.ids = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserCredentialQuery excludedIds(Collection<UUID> values) {
|
||||
this.excludedIds = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserCredentialQuery excludedIds(UUID value) {
|
||||
this.excludedIds = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserCredentialQuery excludedIds(UUID... value) {
|
||||
this.excludedIds = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserCredentialQuery userIds(UUID value) {
|
||||
this.userIds = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserCredentialQuery userIds(UUID... value) {
|
||||
this.userIds = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserCredentialQuery userIds(Collection<UUID> values) {
|
||||
this.userIds = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserCredentialQuery externalIds(String value) {
|
||||
this.externalIds = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserCredentialQuery externalIds(String... value) {
|
||||
this.externalIds = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserCredentialQuery externalIds(Collection<String> values) {
|
||||
this.externalIds = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserCredentialQuery authorize(EnumSet<AuthorizationFlags> values) {
|
||||
this.authorize = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean isFalseQuery() {
|
||||
return
|
||||
this.isEmpty(this.ids) ||
|
||||
this.isEmpty(this.userIds) ||
|
||||
this.isEmpty(this.externalIds) ||
|
||||
this.isEmpty(this.excludedIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<UserCredentialEntity> entityClass() {
|
||||
return UserCredentialEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <X, Y> Predicate applyAuthZ(QueryContext<X, Y> queryContext) {
|
||||
if (this.authorize.contains(AuthorizationFlags.None)) return null;
|
||||
if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseUser)) return null;
|
||||
UUID userId;
|
||||
if (this.authorize.contains(AuthorizationFlags.Owner)) userId = this.userScope.getUserIdSafe();
|
||||
else userId = null;
|
||||
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
if (userId != null) {
|
||||
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(UserCredentialEntity._userId)).value(userId));
|
||||
}
|
||||
if (!predicates.isEmpty()) {
|
||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||
} else {
|
||||
return queryContext.CriteriaBuilder.or(); //Creates a false query
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
if (this.ids != null) {
|
||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserCredentialEntity._id));
|
||||
for (UUID item : this.ids)
|
||||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
if (this.userIds != null) {
|
||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserCredentialEntity._userId));
|
||||
for (UUID item : this.userIds)
|
||||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
if (this.excludedIds != null) {
|
||||
CriteriaBuilder.In<UUID> notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserCredentialEntity._id));
|
||||
for (UUID item : this.excludedIds)
|
||||
notInClause.value(item);
|
||||
predicates.add(notInClause.not());
|
||||
}
|
||||
if (this.externalIds != null) {
|
||||
CriteriaBuilder.In<String> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserCredentialEntity._externalId));
|
||||
for (String item : this.externalIds)
|
||||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
if (!predicates.isEmpty()) {
|
||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String fieldNameOf(FieldResolver item) {
|
||||
if (item.match(UserCredential._id)) return UserCredentialEntity._id;
|
||||
else if (item.match(UserCredential._externalId)) return UserCredentialEntity._externalId;
|
||||
else if (item.prefix(UserCredential._user)) return UserCredentialEntity._userId;
|
||||
else if (item.match(UserCredential._user)) return UserCredentialEntity._userId;
|
||||
else if (item.match(UserCredential._createdAt) ) return UserCredentialEntity._createdAt;
|
||||
else return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UserCredentialEntity convert(Tuple tuple, Set<String> columns) {
|
||||
UserCredentialEntity item = new UserCredentialEntity();
|
||||
item.setId(QueryBase.convertSafe(tuple, columns, UserCredentialEntity._id, UUID.class));
|
||||
item.setExternalId(QueryBase.convertSafe(tuple, columns, UserCredentialEntity._externalId, String.class));
|
||||
item.setUserId(QueryBase.convertSafe(tuple, columns, UserCredentialEntity._userId, UUID.class));
|
||||
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, UserCredentialEntity._createdAt, Instant.class));
|
||||
return item;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,188 @@
|
|||
package eu.eudat.query;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.data.DmpEntity;
|
||||
import eu.eudat.model.User;
|
||||
import eu.eudat.model.PublicUser;
|
||||
import eu.eudat.query.utils.QueryUtilsService;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
import gr.cite.tools.data.query.QueryBase;
|
||||
import gr.cite.tools.data.query.QueryContext;
|
||||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import jakarta.persistence.criteria.Subquery;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class UserQuery extends QueryBase<UserEntity> {
|
||||
private String like;
|
||||
private Collection<UUID> ids;
|
||||
private Collection<UUID> excludedIds;
|
||||
private Collection<IsActive> isActives;
|
||||
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
private final UserScope userScope;
|
||||
private final AuthorizationService authService;
|
||||
public UserQuery(UserScope userScope, AuthorizationService authService) {
|
||||
this.userScope = userScope;
|
||||
this.authService = authService;
|
||||
}
|
||||
|
||||
public UserQuery like(String value) {
|
||||
this.like = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserQuery ids(UUID value) {
|
||||
this.ids = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserQuery ids(UUID... value) {
|
||||
this.ids = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserQuery ids(Collection<UUID> values) {
|
||||
this.ids = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserQuery excludedIds(Collection<UUID> values) {
|
||||
this.excludedIds = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserQuery excludedIds(UUID value) {
|
||||
this.excludedIds = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserQuery excludedIds(UUID... value) {
|
||||
this.excludedIds = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserQuery isActive(IsActive value) {
|
||||
this.isActives = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserQuery isActive(IsActive... value) {
|
||||
this.isActives = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserQuery isActive(Collection<IsActive> values) {
|
||||
this.isActives = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserQuery authorize(EnumSet<AuthorizationFlags> values) {
|
||||
this.authorize = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean isFalseQuery() {
|
||||
return
|
||||
this.isEmpty(this.ids) ||
|
||||
this.isEmpty(this.isActives) ||
|
||||
this.isEmpty(this.excludedIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<UserEntity> entityClass() {
|
||||
return UserEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <X, Y> Predicate applyAuthZ(QueryContext<X, Y> queryContext) {
|
||||
if (this.authorize.contains(AuthorizationFlags.None)) return null;
|
||||
if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseUser)) return null;
|
||||
UUID userId;
|
||||
if (this.authorize.contains(AuthorizationFlags.Owner)) userId = this.userScope.getUserIdSafe();
|
||||
else userId = null;
|
||||
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
if (userId != null) {
|
||||
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(UserEntity._id)).value(userId));
|
||||
}
|
||||
if (!predicates.isEmpty()) {
|
||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||
} else {
|
||||
return queryContext.CriteriaBuilder.or(); //Creates a false query
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
if (this.like != null && !this.like.isEmpty()) {
|
||||
predicates.add(queryContext.CriteriaBuilder.like(queryContext.Root.get(UserEntity._name), this.like));
|
||||
}
|
||||
if (this.ids != null) {
|
||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserEntity._id));
|
||||
for (UUID item : this.ids)
|
||||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
if (this.excludedIds != null) {
|
||||
CriteriaBuilder.In<UUID> notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserEntity._id));
|
||||
for (UUID item : this.excludedIds)
|
||||
notInClause.value(item);
|
||||
predicates.add(notInClause.not());
|
||||
}
|
||||
if (this.isActives != null) {
|
||||
CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserEntity._isActive));
|
||||
for (IsActive item : this.isActives)
|
||||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
if (!predicates.isEmpty()) {
|
||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String fieldNameOf(FieldResolver item) {
|
||||
if (item.match(User._id) || item.match(PublicUser._id)) return UserEntity._id;
|
||||
else if (item.match(User._name) || item.match(PublicUser._name)) return UserEntity._name;
|
||||
else if (item.prefix(User._additionalInfo)) return UserEntity._additionalInfo;
|
||||
else if (item.match(User._createdAt) ) return UserEntity._createdAt;
|
||||
else if (item.match(User._updatedAt)) return UserEntity._updatedAt;
|
||||
else if (item.match(User._hash)) return UserEntity._updatedAt;
|
||||
else if (item.match(User._isActive)) return UserEntity._isActive;
|
||||
else return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UserEntity convert(Tuple tuple, Set<String> columns) {
|
||||
UserEntity item = new UserEntity();
|
||||
item.setId(QueryBase.convertSafe(tuple, columns, UserEntity._id, UUID.class));
|
||||
item.setName(QueryBase.convertSafe(tuple, columns, UserEntity._name, String.class));
|
||||
item.setAdditionalInfo(QueryBase.convertSafe(tuple, columns, UserEntity._additionalInfo, String.class));
|
||||
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, UserEntity._createdAt, Instant.class));
|
||||
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, UserEntity._updatedAt, Instant.class));
|
||||
item.setIsActive(QueryBase.convertSafe(tuple, columns, UserEntity._isActive, IsActive.class));
|
||||
return item;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,192 @@
|
|||
package eu.eudat.query;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.data.UserRoleEntity;
|
||||
import eu.eudat.model.UserRole;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
import gr.cite.tools.data.query.QueryBase;
|
||||
import gr.cite.tools.data.query.QueryContext;
|
||||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class UserRoleQuery extends QueryBase<UserRoleEntity> {
|
||||
private Collection<UUID> ids;
|
||||
private Collection<UUID> excludedIds;
|
||||
private Collection<UUID> userIds;
|
||||
private Collection<String> roles;
|
||||
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
private final UserScope userScope;
|
||||
private final AuthorizationService authService;
|
||||
public UserRoleQuery(UserScope userScope, AuthorizationService authService) {
|
||||
this.userScope = userScope;
|
||||
this.authService = authService;
|
||||
}
|
||||
|
||||
public UserRoleQuery ids(UUID value) {
|
||||
this.ids = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserRoleQuery ids(UUID... value) {
|
||||
this.ids = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserRoleQuery ids(Collection<UUID> values) {
|
||||
this.ids = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserRoleQuery excludedIds(Collection<UUID> values) {
|
||||
this.excludedIds = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserRoleQuery excludedIds(UUID value) {
|
||||
this.excludedIds = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserRoleQuery excludedIds(UUID... value) {
|
||||
this.excludedIds = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserRoleQuery userIds(UUID value) {
|
||||
this.userIds = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserRoleQuery userIds(UUID... value) {
|
||||
this.userIds = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserRoleQuery userIds(Collection<UUID> values) {
|
||||
this.userIds = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserRoleQuery roles(String value) {
|
||||
this.roles = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserRoleQuery roles(String... value) {
|
||||
this.roles = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserRoleQuery roles(Collection<String> values) {
|
||||
this.roles = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserRoleQuery authorize(EnumSet<AuthorizationFlags> values) {
|
||||
this.authorize = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean isFalseQuery() {
|
||||
return
|
||||
this.isEmpty(this.ids) ||
|
||||
this.isEmpty(this.userIds) ||
|
||||
this.isEmpty(this.roles) ||
|
||||
this.isEmpty(this.excludedIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<UserRoleEntity> entityClass() {
|
||||
return UserRoleEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <X, Y> Predicate applyAuthZ(QueryContext<X, Y> queryContext) {
|
||||
if (this.authorize.contains(AuthorizationFlags.None)) return null;
|
||||
if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseUser)) return null;
|
||||
UUID userId;
|
||||
if (this.authorize.contains(AuthorizationFlags.Owner)) userId = this.userScope.getUserIdSafe();
|
||||
else userId = null;
|
||||
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
if (userId != null) {
|
||||
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(UserRoleEntity._userId)).value(userId));
|
||||
}
|
||||
if (!predicates.isEmpty()) {
|
||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||
} else {
|
||||
return queryContext.CriteriaBuilder.or(); //Creates a false query
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
if (this.ids != null) {
|
||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserRoleEntity._id));
|
||||
for (UUID item : this.ids)
|
||||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
if (this.userIds != null) {
|
||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserRoleEntity._userId));
|
||||
for (UUID item : this.userIds)
|
||||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
if (this.excludedIds != null) {
|
||||
CriteriaBuilder.In<UUID> notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserRoleEntity._id));
|
||||
for (UUID item : this.excludedIds)
|
||||
notInClause.value(item);
|
||||
predicates.add(notInClause.not());
|
||||
}
|
||||
if (this.roles != null) {
|
||||
CriteriaBuilder.In<String> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserRoleEntity._role));
|
||||
for (String item : this.roles)
|
||||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
if (!predicates.isEmpty()) {
|
||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String fieldNameOf(FieldResolver item) {
|
||||
if (item.match(UserRole._id)) return UserRoleEntity._id;
|
||||
else if (item.match(UserRole._role)) return UserRoleEntity._role;
|
||||
else if (item.prefix(UserRole._user)) return UserRoleEntity._userId;
|
||||
else if (item.match(UserRole._createdAt) ) return UserRoleEntity._createdAt;
|
||||
else return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UserRoleEntity convert(Tuple tuple, Set<String> columns) {
|
||||
UserRoleEntity item = new UserRoleEntity();
|
||||
item.setId(QueryBase.convertSafe(tuple, columns, UserRoleEntity._id, UUID.class));
|
||||
item.setRole(QueryBase.convertSafe(tuple, columns, UserRoleEntity._role, String.class));
|
||||
item.setUserId(QueryBase.convertSafe(tuple, columns, UserRoleEntity._userId, UUID.class));
|
||||
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, UserRoleEntity._createdAt, Instant.class));
|
||||
return item;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package eu.eudat.query.lookup;
|
||||
|
||||
import eu.eudat.commons.enums.ContactInfoType;
|
||||
import eu.eudat.query.UserContactInfoQuery;
|
||||
import gr.cite.tools.data.query.Lookup;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UserContantInfoLookup extends Lookup {
|
||||
private List<UUID> ids;
|
||||
private List<UUID> excludedIds;
|
||||
private List<UUID> userIds;
|
||||
private List<String> values;
|
||||
private List<ContactInfoType> types;
|
||||
|
||||
|
||||
public List<UUID> getIds() {
|
||||
return ids;
|
||||
}
|
||||
|
||||
public void setIds(List<UUID> ids) {
|
||||
this.ids = ids;
|
||||
}
|
||||
|
||||
public List<UUID> getExcludedIds() {
|
||||
return excludedIds;
|
||||
}
|
||||
|
||||
public void setExcludedIds(List<UUID> excludedIds) {
|
||||
this.excludedIds = excludedIds;
|
||||
}
|
||||
|
||||
public List<UUID> getUserIds() {
|
||||
return userIds;
|
||||
}
|
||||
|
||||
public void setUserIds(List<UUID> userIds) {
|
||||
this.userIds = userIds;
|
||||
}
|
||||
|
||||
public List<String> getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public void setValues(List<String> values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
public List<ContactInfoType> getTypes() {
|
||||
return types;
|
||||
}
|
||||
|
||||
public void setTypes(List<ContactInfoType> types) {
|
||||
this.types = types;
|
||||
}
|
||||
|
||||
public UserContactInfoQuery enrich(QueryFactory queryFactory) {
|
||||
UserContactInfoQuery query = queryFactory.query(UserContactInfoQuery.class);
|
||||
if (this.ids != null) query.ids(this.ids);
|
||||
if (this.excludedIds != null) query.excludedIds(this.excludedIds);
|
||||
if (this.userIds != null) query.userIds(this.userIds);
|
||||
if (this.values != null) query.values(this.values);
|
||||
if (this.types != null) query.types(this.types);
|
||||
|
||||
this.enrichCommon(query);
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package eu.eudat.query.lookup;
|
||||
|
||||
import eu.eudat.query.UserCredentialQuery;
|
||||
import eu.eudat.query.UserRoleQuery;
|
||||
import gr.cite.tools.data.query.Lookup;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UserCredentialLookup extends Lookup {
|
||||
private List<UUID> ids;
|
||||
|
||||
private List<UUID> excludedIds;
|
||||
private List<UUID> userIds;
|
||||
private List<String> externalIds;
|
||||
|
||||
|
||||
public List<UUID> getIds() {
|
||||
return ids;
|
||||
}
|
||||
|
||||
public void setIds(List<UUID> ids) {
|
||||
this.ids = ids;
|
||||
}
|
||||
|
||||
public List<UUID> getExcludedIds() {
|
||||
return excludedIds;
|
||||
}
|
||||
|
||||
public void setExcludedIds(List<UUID> excludedIds) {
|
||||
this.excludedIds = excludedIds;
|
||||
}
|
||||
|
||||
public List<UUID> getUserIds() {
|
||||
return userIds;
|
||||
}
|
||||
|
||||
public void setUserIds(List<UUID> userIds) {
|
||||
this.userIds = userIds;
|
||||
}
|
||||
|
||||
public List<String> getExternalIds() {
|
||||
return externalIds;
|
||||
}
|
||||
|
||||
public void setExternalIds(List<String> externalIds) {
|
||||
this.externalIds = externalIds;
|
||||
}
|
||||
|
||||
public UserCredentialQuery enrich(QueryFactory queryFactory) {
|
||||
UserCredentialQuery query = queryFactory.query(UserCredentialQuery.class);
|
||||
if (this.ids != null) query.ids(this.ids);
|
||||
if (this.excludedIds != null) query.excludedIds(this.excludedIds);
|
||||
if (this.userIds != null) query.userIds(this.userIds);
|
||||
if (this.externalIds != null) query.externalIds(this.externalIds);
|
||||
|
||||
this.enrichCommon(query);
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package eu.eudat.query.lookup;
|
||||
|
||||
import eu.eudat.commons.enums.DescriptionStatus;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.elastic.query.DescriptionElasticQuery;
|
||||
import eu.eudat.elastic.query.InnerObjectDmpElasticQuery;
|
||||
import eu.eudat.query.DescriptionQuery;
|
||||
import eu.eudat.query.UserQuery;
|
||||
import gr.cite.tools.data.query.Lookup;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UserLookup extends Lookup {
|
||||
|
||||
private String like;
|
||||
|
||||
private List<UUID> ids;
|
||||
|
||||
private List<UUID> excludedIds;
|
||||
private List<IsActive> isActive;
|
||||
|
||||
public String getLike() {
|
||||
return like;
|
||||
}
|
||||
|
||||
public void setLike(String like) {
|
||||
this.like = like;
|
||||
}
|
||||
|
||||
public List<UUID> getIds() {
|
||||
return ids;
|
||||
}
|
||||
|
||||
public void setIds(List<UUID> ids) {
|
||||
this.ids = ids;
|
||||
}
|
||||
|
||||
public List<UUID> getExcludedIds() {
|
||||
return excludedIds;
|
||||
}
|
||||
|
||||
public void setExcludedIds(List<UUID> excludedIds) {
|
||||
this.excludedIds = excludedIds;
|
||||
}
|
||||
|
||||
public List<IsActive> getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(List<IsActive> isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
public UserQuery enrich(QueryFactory queryFactory) {
|
||||
UserQuery query = queryFactory.query(UserQuery.class);
|
||||
if (this.like != null) query.like(this.like);
|
||||
if (this.ids != null) query.ids(this.ids);
|
||||
if (this.excludedIds != null) query.excludedIds(this.excludedIds);
|
||||
if (this.isActive != null) query.isActive(this.isActive);
|
||||
|
||||
this.enrichCommon(query);
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package eu.eudat.query.lookup;
|
||||
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.query.UserQuery;
|
||||
import eu.eudat.query.UserRoleQuery;
|
||||
import gr.cite.tools.data.query.Lookup;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UserRoleLookup extends Lookup {
|
||||
private List<UUID> ids;
|
||||
|
||||
private List<UUID> excludedIds;
|
||||
private List<UUID> userIds;
|
||||
private List<String> roles;
|
||||
|
||||
|
||||
public List<UUID> getIds() {
|
||||
return ids;
|
||||
}
|
||||
|
||||
public void setIds(List<UUID> ids) {
|
||||
this.ids = ids;
|
||||
}
|
||||
|
||||
public List<UUID> getExcludedIds() {
|
||||
return excludedIds;
|
||||
}
|
||||
|
||||
public void setExcludedIds(List<UUID> excludedIds) {
|
||||
this.excludedIds = excludedIds;
|
||||
}
|
||||
|
||||
public List<UUID> getUserIds() {
|
||||
return userIds;
|
||||
}
|
||||
|
||||
public void setUserIds(List<UUID> userIds) {
|
||||
this.userIds = userIds;
|
||||
}
|
||||
|
||||
public List<String> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(List<String> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
public UserRoleQuery enrich(QueryFactory queryFactory) {
|
||||
UserRoleQuery query = queryFactory.query(UserRoleQuery.class);
|
||||
if (this.ids != null) query.ids(this.ids);
|
||||
if (this.excludedIds != null) query.excludedIds(this.excludedIds);
|
||||
if (this.userIds != null) query.userIds(this.userIds);
|
||||
if (this.roles != null) query.roles(this.roles);
|
||||
|
||||
this.enrichCommon(query);
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
}
|
|
@ -149,7 +149,7 @@ public class DescriptionServiceImpl implements DescriptionService {
|
|||
this.entityManager.flush();
|
||||
|
||||
this.eventBroker.emit(new DescriptionTouchedEvent(data.getId()));
|
||||
return this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.OwnerOrPermissionOrMemberOrPublic).build(BaseFieldSet.build(fields, Description._id), data);
|
||||
return this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, Description._id), data);
|
||||
}
|
||||
|
||||
private @NotNull PropertyDefinitionEntity buildPropertyDefinitionEntity(PropertyDefinitionPersist persist){
|
||||
|
|
|
@ -14,7 +14,7 @@ import eu.eudat.commons.types.descriptiontemplate.importexport.*;
|
|||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.DescriptionTemplateEntity;
|
||||
import eu.eudat.data.UserDescriptionTemplateEntity;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
||||
import eu.eudat.model.DescriptionTemplate;
|
||||
import eu.eudat.model.builder.DescriptionTemplateBuilder;
|
||||
|
@ -39,7 +39,6 @@ import eu.eudat.service.responseutils.ResponseUtilsService;
|
|||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||
import gr.cite.tools.data.query.Ordering;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.exception.MyForbiddenException;
|
||||
|
@ -175,7 +174,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
|||
|
||||
this.entityManager.flush();
|
||||
|
||||
return this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrPermissionOrMemberOrPublic).build(BaseFieldSet.build(fields, DescriptionTemplate._id), data);
|
||||
return this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, DescriptionTemplate._id), data);
|
||||
}
|
||||
|
||||
private void persistUsers(UUID id, List<UserDescriptionTemplatePersist> users) throws InvalidApplicationException {
|
||||
|
@ -203,7 +202,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
|||
}
|
||||
private void sendJoinMail(UserDescriptionTemplateEntity userDatasetProfile) {
|
||||
SimpleMail mail = new SimpleMail();
|
||||
UserInfo user = this.entityManager.find(UserInfo.class, userDatasetProfile.getUser());
|
||||
UserEntity user = this.entityManager.find(UserEntity.class, userDatasetProfile.getUser());
|
||||
DescriptionTemplateEntity descriptionTemplate = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).ids(userDatasetProfile.getDescriptionTemplate()).first();
|
||||
|
||||
mail.setSubject(environment.getProperty("admin.mail.subject").replace( "{templateName}", descriptionTemplate.getLabel()));
|
||||
|
@ -213,7 +212,8 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
|||
content = content.replace("{host}", this.environment.getProperty("dmp.domain"));
|
||||
content = content.replace("{templateID}", descriptionTemplate.getId().toString());
|
||||
mail.setContent(content);
|
||||
mail.setTo(user.getEmail());
|
||||
//TODO: GetEmail
|
||||
// mail.setTo(user.getEmail());
|
||||
try {
|
||||
this.mailService.sendSimpleMail(mail);
|
||||
} catch (Exception ex) {
|
||||
|
@ -382,8 +382,8 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
|||
|
||||
this.authorizationService.authorizeForce(Permission.CloneDescriptionTemplate);
|
||||
|
||||
DescriptionTemplateQuery query = this.queryFactory.query(DescriptionTemplateQuery.class).authorize(AuthorizationFlags.OwnerOrPermissionOrMemberOrPublic).ids(id);
|
||||
DescriptionTemplate model = this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrPermissionOrMemberOrPublic).build(fields, query.firstAs(fields));
|
||||
DescriptionTemplateQuery query = this.queryFactory.query(DescriptionTemplateQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(id);
|
||||
DescriptionTemplate model = this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fields, query.firstAs(fields));
|
||||
if (model == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
|
||||
model.setLabel(model.getLabel() + " new ");
|
||||
|
@ -495,7 +495,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
|||
|
||||
this.entityManager.flush();
|
||||
|
||||
return this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrPermissionOrMemberOrPublic).build(BaseFieldSet.build(fields, DescriptionTemplate._id), data);
|
||||
return this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, DescriptionTemplate._id), data);
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
|
|
@ -106,7 +106,7 @@ public class DescriptionTemplateTypeServiceImpl implements DescriptionTemplateTy
|
|||
this.entityManager.flush();
|
||||
|
||||
this.eventBroker.emit(new DescriptionTemplateTypeTouchedEvent(data.getId()));
|
||||
return this.builderFactory.builder(DescriptionTemplateTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrPermissionOrMemberOrPublic).build(BaseFieldSet.build(fields, DescriptionTemplateType._id), data);
|
||||
return this.builderFactory.builder(DescriptionTemplateTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, DescriptionTemplateType._id), data);
|
||||
}
|
||||
|
||||
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
|
||||
|
|
|
@ -29,7 +29,6 @@ import eu.eudat.service.description.DescriptionService;
|
|||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||
import gr.cite.tools.data.query.Ordering;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.exception.MyForbiddenException;
|
||||
|
@ -38,7 +37,6 @@ import gr.cite.tools.exception.MyValidationException;
|
|||
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import gr.cite.tools.logging.MapLogEntry;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.xml.bind.JAXBException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -130,7 +128,7 @@ public class DmpServiceImpl implements DmpService {
|
|||
|
||||
this.eventBroker.emit(new DmpTouchedEvent(data.getId()));
|
||||
|
||||
return this.builderFactory.builder(DmpBuilder.class).authorize(AuthorizationFlags.OwnerOrPermissionOrMemberOrPublic).build(BaseFieldSet.build(fields, Dmp._id, Dmp._hash), data);
|
||||
return this.builderFactory.builder(DmpBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, Dmp._id, Dmp._hash), data);
|
||||
}
|
||||
|
||||
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException, IOException {
|
||||
|
@ -241,7 +239,7 @@ public class DmpServiceImpl implements DmpService {
|
|||
public Dmp buildClone(CloneDmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException {
|
||||
this.authorizationService.authorizeForce(Permission.CloneDmp);
|
||||
|
||||
DmpEntity existingDmpEntity = this.queryFactory.query(DmpQuery.class).authorize(AuthorizationFlags.OwnerOrPermissionOrMemberOrPublic).ids(model.getId()).firstAs(fields);
|
||||
DmpEntity existingDmpEntity = this.queryFactory.query(DmpQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(model.getId()).firstAs(fields);
|
||||
if (!this.conventionService.isValidGuid(model.getId()) || existingDmpEntity == null)
|
||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
|||
|
||||
this.entityManager.flush();
|
||||
|
||||
return this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.OwnerOrPermissionOrMemberOrPublic).build(BaseFieldSet.build(fields, DmpBlueprint._id), data);
|
||||
return this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, DmpBlueprint._id), data);
|
||||
}
|
||||
|
||||
private @NotNull DefinitionEntity buildDefinitionEntity(DefinitionPersist persist){
|
||||
|
@ -260,8 +260,8 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
|||
|
||||
this.authorizationService.authorizeForce(Permission.CloneDmpBlueprint);
|
||||
|
||||
DmpBlueprintQuery query = this.queryFactory.query(DmpBlueprintQuery.class).authorize(AuthorizationFlags.OwnerOrPermissionOrMemberOrPublic).ids(id);
|
||||
DmpBlueprint model = this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.OwnerOrPermissionOrMemberOrPublic).build(fields, query.firstAs(fields));
|
||||
DmpBlueprintQuery query = this.queryFactory.query(DmpBlueprintQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(id);
|
||||
DmpBlueprint model = this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fields, query.firstAs(fields));
|
||||
if (model == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
|
||||
model.setLabel(model.getLabel() + " new ");
|
||||
|
|
|
@ -109,7 +109,7 @@ public class EntityDoiServiceImpl implements EntityDoiService {
|
|||
this.entityManager.flush();
|
||||
|
||||
this.eventBroker.emit(new EntityDoiTouchedEvent(data.getId()));
|
||||
return this.builderFactory.builder(EntityDoiBuilder.class).authorize(AuthorizationFlags.OwnerOrPermissionOrMemberOrPublic).build(BaseFieldSet.build(fields, EntityDoi._id), data);
|
||||
return this.builderFactory.builder(EntityDoiBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, EntityDoi._id), data);
|
||||
}
|
||||
|
||||
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
|
||||
|
|
|
@ -100,7 +100,7 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
|
|||
|
||||
this.entityManager.flush();
|
||||
|
||||
return this.builderFactory.builder(ReferenceTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrPermissionOrMemberOrPublic).build(BaseFieldSet.build(fields, ReferenceType._id), data);
|
||||
return this.builderFactory.builder(ReferenceTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, ReferenceType._id), data);
|
||||
}
|
||||
|
||||
private @NotNull ReferenceTypeDefinitionEntity buildDefinitionEntity(ReferenceTypeDefinitionPersist persist){
|
||||
|
|
|
@ -128,7 +128,7 @@ public class SupportiveMaterialServiceImpl implements SupportiveMaterialService{
|
|||
if (d == null)
|
||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), SupportiveMaterial.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
} else {
|
||||
List<SupportiveMaterialEntity> data = this.queryFactory.query(SupportiveMaterialQuery.class).authorize(AuthorizationFlags.OwnerOrPermissionOrMemberOrPublic).languageCodes(model.getLanguageCode()).types(model.getType()).collect();
|
||||
List<SupportiveMaterialEntity> data = this.queryFactory.query(SupportiveMaterialQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).languageCodes(model.getLanguageCode()).types(model.getType()).collect();
|
||||
|
||||
if(data != null && !data.isEmpty()){
|
||||
throw new MyApplicationException("Could not create a new Data with same type and lang code !");
|
||||
|
@ -150,7 +150,7 @@ public class SupportiveMaterialServiceImpl implements SupportiveMaterialService{
|
|||
|
||||
this.entityManager.flush();
|
||||
|
||||
return this.builderFactory.builder(SupportiveMaterialBuilder.class).authorize(AuthorizationFlags.OwnerOrPermissionOrMemberOrPublic).build(BaseFieldSet.build(fields, SupportiveMaterial._id), d);
|
||||
return this.builderFactory.builder(SupportiveMaterialBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, SupportiveMaterial._id), d);
|
||||
}
|
||||
|
||||
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
|
||||
|
|
|
@ -96,7 +96,7 @@ public class UserSettingsServiceImpl implements UserSettingsService {
|
|||
|
||||
this.entityManager.flush();
|
||||
|
||||
return this.builderFactory.builder(UserSettingsBuilder.class).authorize(AuthorizationFlags.OwnerOrPermissionOrMemberOrPublic).build(BaseFieldSet.build(fields, UserSettings._id, UserSettings._key), data);
|
||||
return this.builderFactory.builder(UserSettingsBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, UserSettings._id, UserSettings._key), data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,16 +2,16 @@ package eu.eudat.data.dao.criteria;
|
|||
|
||||
|
||||
import eu.eudat.data.DmpEntity;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
|
||||
public class DatasetWizardUserDmpCriteria extends Criteria<DmpEntity> {
|
||||
private UserInfo userInfo;
|
||||
private UserEntity userInfo;
|
||||
|
||||
public UserInfo getUserInfo() {
|
||||
public UserEntity getUserInfo() {
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
public void setUserInfo(UserInfo userInfo) {
|
||||
public void setUserInfo(UserEntity userInfo) {
|
||||
this.userInfo = userInfo;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.old.Lock;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
@ -9,7 +9,7 @@ import java.util.UUID;
|
|||
public class LockCriteria extends Criteria<Lock> {
|
||||
|
||||
private UUID target;
|
||||
private UserInfo lockedBy;
|
||||
private UserEntity lockedBy;
|
||||
private Date touchedAt;
|
||||
|
||||
public UUID getTarget() {
|
||||
|
@ -20,11 +20,11 @@ public class LockCriteria extends Criteria<Lock> {
|
|||
this.target = target;
|
||||
}
|
||||
|
||||
public UserInfo getLockedBy() {
|
||||
public UserEntity getLockedBy() {
|
||||
return lockedBy;
|
||||
}
|
||||
|
||||
public void setLockedBy(UserInfo lockedBy) {
|
||||
public void setLockedBy(UserEntity lockedBy) {
|
||||
this.lockedBy = lockedBy;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class UserInfoCriteria extends Criteria<UserInfo> {
|
||||
public class UserInfoCriteria extends Criteria<UserEntity> {
|
||||
private String email;
|
||||
private List<Integer> appRoles;
|
||||
private String collaboratorLike;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.old.UserRole;
|
||||
import eu.eudat.data.UserRoleEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/1/2018.
|
||||
*/
|
||||
public class UserRoleCriteria extends Criteria<UserRole> {
|
||||
public class UserRoleCriteria extends Criteria<UserRoleEntity> {
|
||||
private List<Integer> appRoles;
|
||||
|
||||
public List<Integer> getAppRoles() {
|
||||
|
|
|
@ -4,7 +4,7 @@ import eu.eudat.data.DmpEntity;
|
|||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
||||
import eu.eudat.data.dao.criteria.DatasetWizardUserDmpCriteria;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -14,7 +14,7 @@ public interface DMPDao extends DatabaseAccessLayer<DmpEntity, UUID> {
|
|||
|
||||
QueryableList<DmpEntity> getWithCriteria(DataManagementPlanCriteria criteria);
|
||||
|
||||
QueryableList<DmpEntity> getUserDmps(DatasetWizardUserDmpCriteria datasetWizardAutocompleteRequest, UserInfo userInfo);
|
||||
QueryableList<DmpEntity> getUserDmps(DatasetWizardUserDmpCriteria datasetWizardAutocompleteRequest, UserEntity userInfo);
|
||||
|
||||
QueryableList<DmpEntity> getAuthenticated(QueryableList<DmpEntity> query, UUID principalId, List<Integer> roles);
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import eu.eudat.data.dao.DatabaseAccess;
|
|||
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
||||
import eu.eudat.data.dao.criteria.DatasetWizardUserDmpCriteria;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.queryable.types.FieldSelectionType;
|
||||
import eu.eudat.queryable.types.SelectionField;
|
||||
|
@ -123,7 +123,7 @@ public class DMPDaoImpl extends DatabaseAccess<DmpEntity> implements DMPDao {
|
|||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DmpEntity> getUserDmps(DatasetWizardUserDmpCriteria datasetWizardUserDmpCriteria, UserInfo userInfo) {
|
||||
public QueryableList<DmpEntity> getUserDmps(DatasetWizardUserDmpCriteria datasetWizardUserDmpCriteria, UserEntity userInfo) {
|
||||
QueryableList<DmpEntity> query = getDatabaseService().getQueryable(DmpEntity.class).where((builder, root) -> builder.or(builder.equal(root.get("creator"), userInfo), builder.isMember(userInfo, root.get("users"))));
|
||||
if (datasetWizardUserDmpCriteria.getLike() != null && !datasetWizardUserDmpCriteria.getLike().isEmpty()) {
|
||||
query.where((builder, root) -> builder.like(root.get("label"), "%" + datasetWizardUserDmpCriteria.getLike() + "%"));
|
||||
|
|
|
@ -3,7 +3,7 @@ package eu.eudat.data.dao.entities;
|
|||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.dao.criteria.DatasetCriteria;
|
||||
import eu.eudat.data.DescriptionEntity;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import javax.management.InvalidApplicationException;
|
||||
|
@ -16,7 +16,7 @@ public interface DatasetDao extends DatabaseAccessLayer<DescriptionEntity, UUID>
|
|||
|
||||
QueryableList<DescriptionEntity> filterFromElastic(DatasetCriteria criteria, List<UUID> ids);
|
||||
|
||||
QueryableList<DescriptionEntity> getAuthenticated(QueryableList<DescriptionEntity> query, UserInfo principal, List<Integer> roles);
|
||||
QueryableList<DescriptionEntity> getAuthenticated(QueryableList<DescriptionEntity> query, UserEntity principal, List<Integer> roles);
|
||||
|
||||
DescriptionEntity isPublicDataset(UUID id) throws InvalidApplicationException;
|
||||
|
||||
|
|
|
@ -2,12 +2,11 @@ package eu.eudat.data.dao.entities;
|
|||
|
||||
import eu.eudat.commons.enums.DescriptionStatus;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.data.DmpEntity;
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.criteria.DatasetCriteria;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.DescriptionEntity;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.queryable.types.FieldSelectionType;
|
||||
import eu.eudat.queryable.types.SelectionField;
|
||||
|
@ -123,7 +122,7 @@ public class DatasetDaoImpl extends DatabaseAccess<DescriptionEntity> implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DescriptionEntity> getAuthenticated(QueryableList<DescriptionEntity> query, UserInfo principal, List<Integer> roles) {
|
||||
public QueryableList<DescriptionEntity> getAuthenticated(QueryableList<DescriptionEntity> query, UserEntity principal, List<Integer> roles) {
|
||||
if (roles != null && !roles.isEmpty()) {
|
||||
query.where((builder, root) -> {
|
||||
Join userJoin = root.join("dmp", JoinType.LEFT).join("users", JoinType.LEFT);
|
||||
|
|
|
@ -3,7 +3,7 @@ package eu.eudat.data.dao.entities;
|
|||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.dao.criteria.FunderCriteria;
|
||||
import eu.eudat.data.old.Funder;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -12,5 +12,5 @@ public interface FunderDao extends DatabaseAccessLayer<Funder, UUID> {
|
|||
|
||||
QueryableList<Funder> getWithCritetia(FunderCriteria criteria);
|
||||
|
||||
QueryableList<Funder> getAuthenticated(QueryableList<Funder> query, UserInfo principal);
|
||||
QueryableList<Funder> getAuthenticated(QueryableList<Funder> query, UserEntity principal);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import eu.eudat.data.dao.DatabaseAccess;
|
|||
import eu.eudat.data.dao.criteria.FunderCriteria;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.old.Funder;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -39,7 +39,7 @@ public class FunderDaoImpl extends DatabaseAccess<Funder> implements FunderDao {
|
|||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Funder> getAuthenticated(QueryableList<Funder> query, UserInfo principal) {
|
||||
public QueryableList<Funder> getAuthenticated(QueryableList<Funder> query, UserEntity principal) {
|
||||
query.where((builder, root) -> builder.equal(root.get("creationUser"), principal));
|
||||
return query;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package eu.eudat.data.dao.entities;
|
|||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.dao.criteria.GrantCriteria;
|
||||
import eu.eudat.data.old.Grant;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -12,6 +12,6 @@ public interface GrantDao extends DatabaseAccessLayer<Grant, UUID> {
|
|||
|
||||
QueryableList<Grant> getWithCriteria(GrantCriteria criteria);
|
||||
|
||||
QueryableList<Grant> getAuthenticated(QueryableList<Grant> query, UserInfo principal);
|
||||
QueryableList<Grant> getAuthenticated(QueryableList<Grant> query, UserEntity principal);
|
||||
|
||||
}
|
|
@ -6,7 +6,7 @@ import eu.eudat.data.dao.DatabaseAccess;
|
|||
import eu.eudat.data.dao.criteria.GrantCriteria;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.old.Grant;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.types.grant.GrantStateType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -86,7 +86,7 @@ public class GrantDaoImpl extends DatabaseAccess<Grant> implements GrantDao {
|
|||
return this.getDatabaseService().getQueryable(Grant.class);
|
||||
}
|
||||
|
||||
public QueryableList<Grant> getAuthenticated(QueryableList<Grant> query, UserInfo principal) {
|
||||
public QueryableList<Grant> getAuthenticated(QueryableList<Grant> query, UserEntity principal) {
|
||||
query.where((builder, root) -> builder.equal(root.get("creationUser").get("id"), principal.getId())).distinct();
|
||||
return query;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package eu.eudat.data.dao.entities;
|
|||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.dao.criteria.OrganisationCriteria;
|
||||
import eu.eudat.data.old.Organisation;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -11,6 +11,6 @@ import java.util.UUID;
|
|||
public interface OrganisationDao extends DatabaseAccessLayer<Organisation, UUID> {
|
||||
|
||||
QueryableList<Organisation> getWithCriteria(OrganisationCriteria criteria);
|
||||
QueryableList<Organisation> getAuthenticated(QueryableList<Organisation> query, UserInfo principal);
|
||||
QueryableList<Organisation> getAuthenticated(QueryableList<Organisation> query, UserEntity principal);
|
||||
|
||||
}
|
|
@ -6,7 +6,7 @@ import eu.eudat.data.dao.DatabaseAccess;
|
|||
import eu.eudat.data.dao.criteria.OrganisationCriteria;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.old.Organisation;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
@ -75,7 +75,7 @@ public class OrganisationDaoImpl extends DatabaseAccess<Organisation> implements
|
|||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
public QueryableList<Organisation> getAuthenticated(QueryableList<Organisation> query, UserInfo principal) {
|
||||
public QueryableList<Organisation> getAuthenticated(QueryableList<Organisation> query, UserEntity principal) {
|
||||
query.where((builder, root) -> builder.equal(root.join("dmps").join("users").get("user"), principal));
|
||||
return query;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package eu.eudat.data.dao.entities;
|
|||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.dao.criteria.ProjectCriteria;
|
||||
import eu.eudat.data.old.Project;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -12,5 +12,5 @@ public interface ProjectDao extends DatabaseAccessLayer<Project, UUID> {
|
|||
|
||||
QueryableList<Project> getWithCritetia(ProjectCriteria criteria);
|
||||
|
||||
QueryableList<Project> getAuthenticated(QueryableList<Project> query, UserInfo principal);
|
||||
QueryableList<Project> getAuthenticated(QueryableList<Project> query, UserEntity principal);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import eu.eudat.data.dao.DatabaseAccess;
|
|||
import eu.eudat.data.dao.criteria.ProjectCriteria;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.old.Project;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class ProjectDaoImpl extends DatabaseAccess<Project> implements ProjectDa
|
|||
return query;
|
||||
}
|
||||
|
||||
public QueryableList<Project> getAuthenticated(QueryableList<Project> query, UserInfo principal) {
|
||||
public QueryableList<Project> getAuthenticated(QueryableList<Project> query, UserEntity principal) {
|
||||
query.where((builder, root) -> builder.or(builder.equal(root.get("creationUser"), principal), builder.equal(root.join("dmps", JoinType.LEFT).join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), principal.getId()))).distinct();
|
||||
return query;
|
||||
}
|
||||
|
|
|
@ -2,14 +2,14 @@ package eu.eudat.data.dao.entities;
|
|||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.dao.criteria.UserInfoCriteria;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface UserInfoDao extends DatabaseAccessLayer<UserInfo, UUID> {
|
||||
public interface UserInfoDao extends DatabaseAccessLayer<UserEntity, UUID> {
|
||||
|
||||
QueryableList<UserInfo> getWithCriteria(UserInfoCriteria criteria);
|
||||
QueryableList<UserEntity> getWithCriteria(UserInfoCriteria criteria);
|
||||
|
||||
QueryableList<UserInfo> getAuthenticated(QueryableList<UserInfo> users, UUID principalId);
|
||||
QueryableList<UserEntity> getAuthenticated(QueryableList<UserEntity> users, UUID principalId);
|
||||
}
|
|
@ -3,7 +3,7 @@ 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.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.queryable.types.FieldSelectionType;
|
||||
import eu.eudat.queryable.types.SelectionField;
|
||||
|
@ -17,16 +17,16 @@ import java.util.UUID;
|
|||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component("userInfoDao")
|
||||
public class UserInfoDaoImpl extends DatabaseAccess<UserInfo> implements UserInfoDao {
|
||||
public class UserInfoDaoImpl extends DatabaseAccess<UserEntity> implements UserInfoDao {
|
||||
|
||||
@Autowired
|
||||
public UserInfoDaoImpl(DatabaseService<UserInfo> databaseService) {
|
||||
public UserInfoDaoImpl(DatabaseService<UserEntity> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<UserInfo> getWithCriteria(UserInfoCriteria criteria) {
|
||||
QueryableList<UserInfo> users = this.getDatabaseService().getQueryable(UserInfo.class);
|
||||
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()));
|
||||
|
@ -40,7 +40,7 @@ public class UserInfoDaoImpl extends DatabaseAccess<UserInfo> implements UserInf
|
|||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<UserInfo> getAuthenticated(QueryableList<UserInfo> users, UUID principalId) {
|
||||
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),
|
||||
|
@ -50,33 +50,33 @@ public class UserInfoDaoImpl extends DatabaseAccess<UserInfo> implements UserInf
|
|||
}
|
||||
|
||||
@Override
|
||||
public UserInfo createOrUpdate(UserInfo item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, UserInfo.class);
|
||||
public UserEntity createOrUpdate(UserEntity item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, UserEntity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserInfo find(UUID id) throws InvalidApplicationException {
|
||||
return this.getDatabaseService().getQueryable(UserInfo.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
||||
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(UserInfo item) {
|
||||
public void delete(UserEntity item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<UserInfo> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(UserInfo.class);
|
||||
public QueryableList<UserEntity> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(UserEntity.class);
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public CompletableFuture<UserInfo> createOrUpdateAsync(UserInfo item) {
|
||||
public CompletableFuture<UserEntity> createOrUpdateAsync(UserEntity item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserInfo find(UUID id, String hint) {
|
||||
public UserEntity find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
|
@ -2,8 +2,8 @@ package eu.eudat.data.dao.entities;
|
|||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.dao.criteria.UserRoleCriteria;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.old.UserRole;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.data.UserRoleEntity;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import javax.management.InvalidApplicationException;
|
||||
|
@ -11,9 +11,9 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
|
||||
|
||||
public interface UserRoleDao extends DatabaseAccessLayer<UserRole, UUID> {
|
||||
public interface UserRoleDao extends DatabaseAccessLayer<UserRoleEntity, UUID> {
|
||||
|
||||
QueryableList<UserRole> getWithCriteria(UserRoleCriteria criteria);
|
||||
QueryableList<UserRoleEntity> getWithCriteria(UserRoleCriteria criteria);
|
||||
|
||||
List<UserRole> getUserRoles(UserInfo userInfo) throws InvalidApplicationException;
|
||||
List<UserRoleEntity> getUserRoles(UserEntity userInfo) throws InvalidApplicationException;
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ 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.old.UserInfo;
|
||||
import eu.eudat.data.old.UserRole;
|
||||
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;
|
||||
|
@ -17,36 +17,36 @@ import java.util.concurrent.CompletableFuture;
|
|||
|
||||
|
||||
@Component("userRoleDao")
|
||||
public class UserRoleDaoImpl extends DatabaseAccess<UserRole> implements UserRoleDao {
|
||||
public class UserRoleDaoImpl extends DatabaseAccess<UserRoleEntity> implements UserRoleDao {
|
||||
|
||||
@Autowired
|
||||
public UserRoleDaoImpl(DatabaseService<UserRole> databaseService) {
|
||||
public UserRoleDaoImpl(DatabaseService<UserRoleEntity> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserRole createOrUpdate(UserRole item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, UserRole.class);
|
||||
public UserRoleEntity createOrUpdate(UserRoleEntity item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, UserRoleEntity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserRole find(UUID id) throws InvalidApplicationException {
|
||||
return this.getDatabaseService().getQueryable(UserRole.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingleOrDefault();
|
||||
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<UserRole> getUserRoles(UserInfo userInfo) throws InvalidApplicationException {
|
||||
return this.getDatabaseService().getQueryable(UserRole.class).where((builder, root) -> builder.equal(root.get("userInfo"), userInfo)).toList();
|
||||
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(UserRole item) {
|
||||
public void delete(UserRoleEntity item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<UserRole> getWithCriteria(UserRoleCriteria criteria) {
|
||||
QueryableList<UserRole> query = this.getDatabaseService().getQueryable(UserRole.class);
|
||||
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())
|
||||
|
@ -55,18 +55,18 @@ public class UserRoleDaoImpl extends DatabaseAccess<UserRole> implements UserRol
|
|||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<UserRole> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(UserRole.class);
|
||||
public QueryableList<UserRoleEntity> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(UserRoleEntity.class);
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public CompletableFuture<UserRole> createOrUpdateAsync(UserRole item) {
|
||||
public CompletableFuture<UserRoleEntity> createOrUpdateAsync(UserRoleEntity item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserRole find(UUID id, String hint) {
|
||||
public UserRoleEntity find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package eu.eudat.data.dao.entities.security;
|
||||
|
||||
import eu.eudat.data.CredentialEntity;
|
||||
import eu.eudat.data.UserCredentialEntity;
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
|
||||
import javax.management.InvalidApplicationException;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
public interface CredentialDao extends DatabaseAccessLayer<CredentialEntity, UUID> {
|
||||
public interface CredentialDao extends DatabaseAccessLayer<UserCredentialEntity, UUID> {
|
||||
|
||||
CredentialEntity getLoggedInCredentials(String username, String secret, Integer provider) throws InvalidApplicationException;
|
||||
UserCredentialEntity getLoggedInCredentials(String username, String secret, Integer provider) throws InvalidApplicationException;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package eu.eudat.data.dao.entities.security;
|
||||
|
||||
import eu.eudat.data.CredentialEntity;
|
||||
import eu.eudat.data.UserCredentialEntity;
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
@ -13,26 +13,26 @@ import java.util.concurrent.CompletableFuture;
|
|||
|
||||
|
||||
@Component("credentialDao")
|
||||
public class CredentialDaoImpl extends DatabaseAccess<CredentialEntity> implements CredentialDao {
|
||||
public class CredentialDaoImpl extends DatabaseAccess<UserCredentialEntity> implements CredentialDao {
|
||||
|
||||
@Autowired
|
||||
public CredentialDaoImpl(DatabaseService<CredentialEntity> databaseService) {
|
||||
public CredentialDaoImpl(DatabaseService<UserCredentialEntity> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CredentialEntity createOrUpdate(CredentialEntity item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, CredentialEntity.class);
|
||||
public UserCredentialEntity createOrUpdate(UserCredentialEntity item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, UserCredentialEntity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CredentialEntity find(UUID id) throws InvalidApplicationException {
|
||||
return this.getDatabaseService().getQueryable(CredentialEntity.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingleOrDefault();
|
||||
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 CredentialEntity getLoggedInCredentials(String username, String secret, Integer provider) throws InvalidApplicationException {
|
||||
return this.getDatabaseService().getQueryable(CredentialEntity.class).where(((builder, root) ->
|
||||
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),
|
||||
|
@ -41,22 +41,22 @@ public class CredentialDaoImpl extends DatabaseAccess<CredentialEntity> implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public void delete(CredentialEntity item) {
|
||||
public void delete(UserCredentialEntity item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<CredentialEntity> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(CredentialEntity.class);
|
||||
public QueryableList<UserCredentialEntity> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(UserCredentialEntity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CredentialEntity> createOrUpdateAsync(CredentialEntity item) {
|
||||
public CompletableFuture<UserCredentialEntity> createOrUpdateAsync(UserCredentialEntity item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CredentialEntity find(UUID id, String hint) {
|
||||
public UserCredentialEntity find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package eu.eudat.data.query.items.item.userinfo;
|
||||
|
||||
import eu.eudat.data.dao.criteria.UserInfoCriteria;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.data.query.definition.Query;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
|
||||
public class UserInfoRequestItem extends Query<UserInfoCriteria, UserInfo> {
|
||||
public class UserInfoRequestItem extends Query<UserInfoCriteria, UserEntity> {
|
||||
@Override
|
||||
public QueryableList<UserInfo> applyCriteria() {
|
||||
QueryableList<UserInfo> users = this.getQuery();
|
||||
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)
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
package eu.eudat.data.query.items.table.userinfo;
|
||||
|
||||
import eu.eudat.data.dao.criteria.UserInfoCriteria;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
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, UserInfo, UUID> {
|
||||
public class UserInfoTableRequestItem extends TableQuery<UserInfoCriteria, UserEntity, UUID> {
|
||||
|
||||
@Override
|
||||
public QueryableList<UserInfo> applyCriteria() {
|
||||
QueryableList<UserInfo> users = this.getQuery();
|
||||
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)
|
||||
|
@ -23,7 +23,7 @@ public class UserInfoTableRequestItem extends TableQuery<UserInfoCriteria, UserI
|
|||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<UserInfo> applyPaging(QueryableList<UserInfo> items) {
|
||||
public QueryableList<UserEntity> applyPaging(QueryableList<UserEntity> items) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import eu.eudat.data.DmpEntity;
|
|||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.DescriptionEntity;
|
||||
import eu.eudat.data.old.Grant;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.queryable.types.FieldSelectionType;
|
||||
import eu.eudat.queryable.types.SelectionField;
|
||||
|
@ -23,7 +23,7 @@ public class DMPQuery extends Query<DmpEntity, UUID> {
|
|||
private String label;
|
||||
private int version;
|
||||
private GrantQuery grantQuery;
|
||||
private UserQuery userQuery;
|
||||
private UserQueryOld userQuery;
|
||||
private DatasetQuery datasetQuery;
|
||||
private List<Integer> statuses;
|
||||
private Date created;
|
||||
|
@ -101,11 +101,11 @@ public class DMPQuery extends Query<DmpEntity, UUID> {
|
|||
this.modified = modified;
|
||||
}
|
||||
|
||||
public UserQuery getUserQuery() {
|
||||
public UserQueryOld getUserQuery() {
|
||||
return userQuery;
|
||||
}
|
||||
|
||||
public void setUserQuery(UserQuery userQuery) {
|
||||
public void setUserQuery(UserQueryOld userQuery) {
|
||||
this.userQuery = userQuery;
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ public class DMPQuery extends Query<DmpEntity, UUID> {
|
|||
query.where((builder, root) -> root.get("status").in(this.getStatuses()));
|
||||
}
|
||||
if (this.userQuery != null) {
|
||||
Subquery<UserInfo> userInfoSubQuery = this.userQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")));
|
||||
Subquery<UserEntity> userInfoSubQuery = this.userQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")));
|
||||
query.where((builder, root) -> root.get("creator").get("id").in(userInfoSubQuery));
|
||||
}
|
||||
if(this.datasetQuery != null){
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
package eu.eudat.query;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class DatasetProfileQuery {
|
||||
|
||||
private UserQuery userQuery;
|
||||
private UserQueryOld userQuery;
|
||||
|
||||
public UserQuery getUserQuery() {
|
||||
public UserQueryOld getUserQuery() {
|
||||
return userQuery;
|
||||
}
|
||||
|
||||
public void setUserQuery(UserQuery userQuery) {
|
||||
public void setUserQuery(UserQueryOld userQuery) {
|
||||
this.userQuery = userQuery;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package eu.eudat.query;
|
|||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.old.Grant;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.queryable.types.FieldSelectionType;
|
||||
import eu.eudat.queryable.types.SelectionField;
|
||||
|
@ -23,7 +23,7 @@ public class GrantQuery extends Query<Grant, UUID> {
|
|||
private List<Integer> statuses;
|
||||
private Date created;
|
||||
private Date modified;
|
||||
private UserQuery userQuery;
|
||||
private UserQueryOld userQuery;
|
||||
|
||||
public GrantQuery(DatabaseAccessLayer<Grant, UUID> databaseAccessLayer) {
|
||||
super(databaseAccessLayer);
|
||||
|
@ -81,11 +81,11 @@ public class GrantQuery extends Query<Grant, UUID> {
|
|||
this.modified = modified;
|
||||
}
|
||||
|
||||
public UserQuery getUserQuery() {
|
||||
public UserQueryOld getUserQuery() {
|
||||
return userQuery;
|
||||
}
|
||||
|
||||
public void setUserQuery(UserQuery userQuery) {
|
||||
public void setUserQuery(UserQueryOld userQuery) {
|
||||
this.userQuery = userQuery;
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ public class GrantQuery extends Query<Grant, UUID> {
|
|||
if (this.getStatuses() != null && !this.getStatuses().isEmpty())
|
||||
query.where((builder, root) -> root.get("status").in(this.getStatuses()));
|
||||
if (this.userQuery != null) {
|
||||
Subquery<UserInfo> userInfoSubQuery = this.userQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")));
|
||||
Subquery<UserEntity> userInfoSubQuery = this.userQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")));
|
||||
query.where((builder, root) -> root.get("creationUser").get("id").in(userInfoSubQuery));
|
||||
}
|
||||
if (!this.getSelectionFields().isEmpty() && this.getSelectionFields() != null) {
|
||||
|
|
|
@ -2,7 +2,7 @@ package eu.eudat.query;
|
|||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.old.Lock;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.queryable.types.FieldSelectionType;
|
||||
import eu.eudat.queryable.types.SelectionField;
|
||||
|
@ -19,7 +19,7 @@ public class LockQuery extends Query<Lock, UUID> {
|
|||
|
||||
private UUID id;
|
||||
private UUID target;
|
||||
private UserQuery userQuery;
|
||||
private UserQueryOld userQuery;
|
||||
private Date touchedAt;
|
||||
|
||||
public UUID getId() {
|
||||
|
@ -38,11 +38,11 @@ public class LockQuery extends Query<Lock, UUID> {
|
|||
this.target = target;
|
||||
}
|
||||
|
||||
public UserQuery getUserQuery() {
|
||||
public UserQueryOld getUserQuery() {
|
||||
return userQuery;
|
||||
}
|
||||
|
||||
public void setUserQuery(UserQuery userQuery) {
|
||||
public void setUserQuery(UserQueryOld userQuery) {
|
||||
this.userQuery = userQuery;
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class LockQuery extends Query<Lock, UUID> {
|
|||
query.where(((builder, root) -> builder.equal(root.get("target"), this.target)));
|
||||
}
|
||||
if (this.userQuery != null) {
|
||||
Subquery<UserInfo> userSubQuery = this.userQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")));
|
||||
Subquery<UserEntity> userSubQuery = this.userQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")));
|
||||
query.where((builder, root) -> root.get("lockedBy").get("id").in(userSubQuery));
|
||||
}
|
||||
return query;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package eu.eudat.query;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.old.UserInfo;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UserQuery extends Query<UserInfo, UUID> {
|
||||
public class UserQueryOld extends Query<UserEntity, UUID> {
|
||||
|
||||
private UUID id;
|
||||
|
||||
|
@ -19,17 +19,17 @@ public class UserQuery extends Query<UserInfo, UUID> {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
public UserQuery(DatabaseAccessLayer<UserInfo, UUID> databaseAccessLayer) {
|
||||
public UserQueryOld(DatabaseAccessLayer<UserEntity, UUID> databaseAccessLayer) {
|
||||
super(databaseAccessLayer);
|
||||
}
|
||||
|
||||
public UserQuery(DatabaseAccessLayer<UserInfo, UUID> databaseAccessLayer, List<String> selectionFields) {
|
||||
public UserQueryOld(DatabaseAccessLayer<UserEntity, UUID> databaseAccessLayer, List<String> selectionFields) {
|
||||
super(databaseAccessLayer, selectionFields);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<UserInfo> getQuery() {
|
||||
QueryableList<UserInfo> query = this.databaseAccessLayer.asQueryable();
|
||||
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;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue