Add belongsToCurrentTenant to builders

This commit is contained in:
Efstratios Giannopoulos 2024-04-03 13:22:22 +03:00
parent 87bd9e5b24
commit 424d18526b
81 changed files with 517 additions and 183 deletions

View File

@ -4,6 +4,7 @@ import eu.eudat.authorization.Permission;
import eu.eudat.commons.scope.tenant.TenantScope; import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.commons.scope.tenant.TenantScoped; import eu.eudat.commons.scope.tenant.TenantScoped;
import eu.eudat.data.tenant.TenantScopedBaseEntity; import eu.eudat.data.tenant.TenantScopedBaseEntity;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.commons.web.oidc.principal.CurrentPrincipalResolver; import gr.cite.commons.web.oidc.principal.CurrentPrincipalResolver;
import gr.cite.commons.web.oidc.principal.extractor.ClaimExtractor; import gr.cite.commons.web.oidc.principal.extractor.ClaimExtractor;
@ -24,9 +25,11 @@ public class TenantEntityManager {
@PersistenceContext @PersistenceContext
private EntityManager entityManager; private EntityManager entityManager;
private final TenantScope tenantScope; private final TenantScope tenantScope;
private final ErrorThesaurusProperties errors;
public TenantEntityManager(TenantScope tenantScope) { public TenantEntityManager(TenantScope tenantScope, ErrorThesaurusProperties errors) {
this.tenantScope = tenantScope; this.tenantScope = tenantScope;
this.errors = errors;
} }
@ -37,9 +40,9 @@ public class TenantEntityManager {
public <T> T merge(T entity) throws InvalidApplicationException { public <T> T merge(T entity) throws InvalidApplicationException {
if (tenantScope.isMultitenant() && (entity instanceof TenantScoped tenantScopedEntity)) { if (tenantScope.isMultitenant() && (entity instanceof TenantScoped tenantScopedEntity)) {
if (!tenantScope.isDefaultTenant()) { if (!tenantScope.isDefaultTenant()) {
if (tenantScopedEntity.getTenantId() == null || !tenantScopedEntity.getTenantId().equals(tenantScope.getTenant())) throw new MyForbiddenException("tenant tampering"); if (tenantScopedEntity.getTenantId() == null || !tenantScopedEntity.getTenantId().equals(tenantScope.getTenant())) throw new MyForbiddenException(this.errors.getTenantTampering().getCode(), this.errors.getTenantTampering().getMessage());
} else if (tenantScopedEntity.getTenantId() != null) { } else if (tenantScopedEntity.getTenantId() != null) {
throw new MyForbiddenException("tenant tampering"); throw new MyForbiddenException(this.errors.getTenantTampering().getCode(), this.errors.getTenantTampering().getMessage());
} }
} }
return this.entityManager.merge(entity); return this.entityManager.merge(entity);
@ -48,9 +51,9 @@ public class TenantEntityManager {
public void remove(Object entity) throws InvalidApplicationException { public void remove(Object entity) throws InvalidApplicationException {
if (tenantScope.isMultitenant() && (entity instanceof TenantScoped tenantScopedEntity)) { if (tenantScope.isMultitenant() && (entity instanceof TenantScoped tenantScopedEntity)) {
if (!tenantScope.isDefaultTenant()) { if (!tenantScope.isDefaultTenant()) {
if (tenantScopedEntity.getTenantId() == null || !tenantScopedEntity.getTenantId().equals(tenantScope.getTenant())) throw new MyForbiddenException("tenant tampering"); if (tenantScopedEntity.getTenantId() == null || !tenantScopedEntity.getTenantId().equals(tenantScope.getTenant())) throw new MyForbiddenException(this.errors.getTenantTampering().getCode(), this.errors.getTenantTampering().getMessage());
} else if (tenantScopedEntity.getTenantId() != null) { } else if (tenantScopedEntity.getTenantId() != null) {
throw new MyForbiddenException("tenant tampering"); throw new MyForbiddenException(this.errors.getTenantTampering().getCode(), this.errors.getTenantTampering().getMessage());
} }
} }
this.entityManager.remove(entity); this.entityManager.remove(entity);

View File

@ -3,7 +3,9 @@ package eu.eudat.data.tenant;
import eu.eudat.commons.scope.tenant.TenantScope; import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.commons.scope.tenant.TenantScoped; import eu.eudat.commons.scope.tenant.TenantScoped;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import gr.cite.tools.exception.MyForbiddenException; import gr.cite.tools.exception.MyForbiddenException;
import gr.cite.tools.exception.MyValidationException;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import jakarta.persistence.PrePersist; import jakarta.persistence.PrePersist;
import jakarta.persistence.PreRemove; import jakarta.persistence.PreRemove;
@ -19,11 +21,15 @@ public class TenantListener {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TenantListener.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TenantListener.class));
private final TenantScope tenantScope; private final TenantScope tenantScope;
private final ErrorThesaurusProperties errors;
@Autowired @Autowired
public TenantListener( public TenantListener(
TenantScope tenantScope TenantScope tenantScope, ErrorThesaurusProperties errors
) { ) {
this.tenantScope = tenantScope; this.tenantScope = tenantScope;
this.errors = errors;
} }
@PrePersist @PrePersist
@ -31,7 +37,7 @@ public class TenantListener {
if (tenantScope.isMultitenant()) { if (tenantScope.isMultitenant()) {
if (entity.getTenantId() != null && (this.tenantScope.isDefaultTenant() || entity.getTenantId().compareTo(tenantScope.getTenant()) != 0)) { if (entity.getTenantId() != null && (this.tenantScope.isDefaultTenant() || entity.getTenantId().compareTo(tenantScope.getTenant()) != 0)) {
logger.error("somebody tried to set not login tenant"); logger.error("somebody tried to set not login tenant");
throw new MyForbiddenException("tenant tampering"); throw new MyForbiddenException(this.errors.getTenantTampering().getCode(), this.errors.getTenantTampering().getMessage());
} }
if (!tenantScope.isDefaultTenant()) { if (!tenantScope.isDefaultTenant()) {
final UUID tenantId = tenantScope.getTenant(); final UUID tenantId = tenantScope.getTenant();
@ -49,11 +55,11 @@ public class TenantListener {
if (!tenantScope.isDefaultTenant()) { if (!tenantScope.isDefaultTenant()) {
if (entity.getTenantId() == null) { if (entity.getTenantId() == null) {
logger.error("somebody tried to set null tenant"); logger.error("somebody tried to set null tenant");
throw new MyForbiddenException("tenant tampering"); throw new MyForbiddenException(this.errors.getTenantTampering().getCode(), this.errors.getTenantTampering().getMessage());
} }
if (entity.getTenantId().compareTo(tenantScope.getTenant()) != 0) { if (entity.getTenantId().compareTo(tenantScope.getTenant()) != 0) {
logger.error("somebody tried to change an entries tenant"); logger.error("somebody tried to change an entries tenant");
throw new MyForbiddenException("tenant tampering"); throw new MyForbiddenException(this.errors.getTenantTampering().getCode(), this.errors.getTenantTampering().getMessage());
} }
final UUID tenantId = tenantScope.getTenant(); final UUID tenantId = tenantScope.getTenant();
@ -61,13 +67,13 @@ public class TenantListener {
} else { } else {
if (entity.getTenantId() != null) { if (entity.getTenantId() != null) {
logger.error("somebody tried to set null tenant"); logger.error("somebody tried to set null tenant");
throw new MyForbiddenException("tenant tampering"); throw new MyForbiddenException(this.errors.getTenantTampering().getCode(), this.errors.getTenantTampering().getMessage());
} }
} }
} else { } else {
if (entity.getTenantId() != null && (!this.tenantScope.isDefaultTenant() ||entity.getTenantId().compareTo(tenantScope.getTenant()) != 0)) { if (entity.getTenantId() != null && (!this.tenantScope.isDefaultTenant() ||entity.getTenantId().compareTo(tenantScope.getTenant()) != 0)) {
logger.error("somebody tried to change an entries tenant"); logger.error("somebody tried to change an entries tenant");
throw new MyForbiddenException("tenant tampering"); throw new MyForbiddenException(this.errors.getTenantTampering().getCode(), this.errors.getTenantTampering().getMessage());
} }
} }

View File

@ -164,4 +164,14 @@ public class ErrorThesaurusProperties {
public void setTenantNotAllowed(ErrorDescription tenantNotAllowed) { public void setTenantNotAllowed(ErrorDescription tenantNotAllowed) {
this.tenantNotAllowed = tenantNotAllowed; this.tenantNotAllowed = tenantNotAllowed;
} }
private ErrorDescription tenantTampering;
public ErrorDescription getTenantTampering() {
return tenantTampering;
}
public void setTenantTampering(ErrorDescription tenantTampering) {
this.tenantTampering = tenantTampering;
}
} }

View File

@ -49,12 +49,12 @@ public class ActionConfirmation {
private IsActive isActive; private IsActive isActive;
public static final String _isActive = "isActive"; public static final String _isActive = "isActive";
private Tenant tenant;
public static final String _tenant = "tenant";
private String hash; private String hash;
public static final String _hash = "hash"; public static final String _hash = "hash";
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -103,14 +103,6 @@ public class ActionConfirmation {
this.createdBy = createdBy; this.createdBy = createdBy;
} }
public Tenant getTenant() {
return tenant;
}
public void setTenant(Tenant tenant) {
this.tenant = tenant;
}
public Instant getCreatedAt() { public Instant getCreatedAt() {
return createdAt; return createdAt;
} }
@ -143,6 +135,14 @@ public class ActionConfirmation {
this.hash = hash; this.hash = hash;
} }
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
public MergeAccountConfirmation getMergeAccountConfirmation() { public MergeAccountConfirmation getMergeAccountConfirmation() {
return mergeAccountConfirmation; return mergeAccountConfirmation;
} }

View File

@ -78,6 +78,9 @@ public class Description {
public static final String _dmp = "dmp"; public static final String _dmp = "dmp";
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -214,4 +217,12 @@ public class Description {
public void setAuthorizationFlags(List<String> authorizationFlags) { public void setAuthorizationFlags(List<String> authorizationFlags) {
this.authorizationFlags = authorizationFlags; this.authorizationFlags = authorizationFlags;
} }
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
} }

View File

@ -40,6 +40,9 @@ public class DescriptionReference {
private DescriptionReferenceData data; private DescriptionReferenceData data;
public static final String _data = "data"; public static final String _data = "data";
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -103,4 +106,12 @@ public class DescriptionReference {
public void setHash(String hash) { public void setHash(String hash) {
this.hash = hash; this.hash = hash;
} }
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
} }

View File

@ -35,6 +35,9 @@ public class DescriptionTag {
public static final String _hash = "hash"; public static final String _hash = "hash";
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -90,4 +93,12 @@ public class DescriptionTag {
public void setHash(String hash) { public void setHash(String hash) {
this.hash = hash; this.hash = hash;
} }
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
} }

View File

@ -57,6 +57,9 @@ public class DescriptionTemplate {
public final static String _hash = "hash"; public final static String _hash = "hash";
private String hash; private String hash;
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -176,4 +179,12 @@ public class DescriptionTemplate {
public void setVersionStatus(DescriptionTemplateVersionStatus versionStatus) { public void setVersionStatus(DescriptionTemplateVersionStatus versionStatus) {
this.versionStatus = versionStatus; this.versionStatus = versionStatus;
} }
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
} }

View File

@ -33,6 +33,9 @@ public class DescriptionTemplateType {
public final static String _hash = "hash"; public final static String _hash = "hash";
private String hash; private String hash;
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -96,4 +99,12 @@ public class DescriptionTemplateType {
public void setDefinition(Definition definition) { public void setDefinition(Definition definition) {
this.definition = definition; this.definition = definition;
} }
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
} }

View File

@ -87,6 +87,10 @@ public class Dmp {
private List<String> authorizationFlags; private List<String> authorizationFlags;
public static final String _authorizationFlags = "authorizationFlags"; public static final String _authorizationFlags = "authorizationFlags";
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -286,4 +290,12 @@ public class Dmp {
public void setAuthorizationFlags(List<String> authorizationFlags) { public void setAuthorizationFlags(List<String> authorizationFlags) {
this.authorizationFlags = authorizationFlags; this.authorizationFlags = authorizationFlags;
} }
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
} }

View File

@ -54,6 +54,9 @@ public class DmpBlueprint {
public static final String _hash = "hash"; public static final String _hash = "hash";
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -142,7 +145,11 @@ public class DmpBlueprint {
this.hash = hash; this.hash = hash;
} }
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
} }

View File

@ -48,6 +48,9 @@ public class DmpDescriptionTemplate{
public final static String _hash = "hash"; public final static String _hash = "hash";
private String hash; private String hash;
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -127,4 +130,12 @@ public class DmpDescriptionTemplate{
public void setHash(String hash) { public void setHash(String hash) {
this.hash = hash; this.hash = hash;
} }
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
} }

View File

@ -30,6 +30,9 @@ public class DmpReference {
public final static String _hash = "hash"; public final static String _hash = "hash";
private String hash; private String hash;
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
private DmpReferenceData data; private DmpReferenceData data;
public static final String _data = "data"; public static final String _data = "data";
@ -88,4 +91,12 @@ public class DmpReference {
public DmpReferenceData getData() { public DmpReferenceData getData() {
return data; return data;
} }
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
} }

View File

@ -44,6 +44,9 @@ public class DmpUser {
private IsActive isActive; private IsActive isActive;
public static final String _isActive = "isActive"; public static final String _isActive = "isActive";
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -115,4 +118,12 @@ public class DmpUser {
public void setHash(String hash) { public void setHash(String hash) {
this.hash = hash; this.hash = hash;
} }
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
} }

View File

@ -45,6 +45,9 @@ public class EntityDoi {
public static final String _hash = "hash"; public static final String _hash = "hash";
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -116,4 +119,12 @@ public class EntityDoi {
public void setHash(String hash) { public void setHash(String hash) {
this.hash = hash; this.hash = hash;
} }
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
} }

View File

@ -31,6 +31,9 @@ public class Language {
private String hash; private String hash;
public final static String _hash = "hash"; public final static String _hash = "hash";
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -94,4 +97,12 @@ public class Language {
public void setHash(String hash) { public void setHash(String hash) {
this.hash = hash; this.hash = hash;
} }
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
} }

View File

@ -25,13 +25,13 @@ public class Lock {
private Instant touchedAt; private Instant touchedAt;
public static final String _touchedAt = "touchedAt"; public static final String _touchedAt = "touchedAt";
private Tenant tenant;
public static final String _tenant = "tenant";
private String hash; private String hash;
public static final String _hash = "hash"; public static final String _hash = "hash";
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -80,14 +80,6 @@ public class Lock {
this.touchedAt = touchedAt; this.touchedAt = touchedAt;
} }
public Tenant getTenant() {
return tenant;
}
public void setTenant(Tenant tenant) {
this.tenant = tenant;
}
public String getHash() { public String getHash() {
return hash; return hash;
} }
@ -95,4 +87,12 @@ public class Lock {
public void setHash(String hash) { public void setHash(String hash) {
this.hash = hash; this.hash = hash;
} }
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
} }

View File

@ -29,6 +29,9 @@ public class PrefillingSource {
public final static String _hash = "hash"; public final static String _hash = "hash";
private String hash; private String hash;
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -84,4 +87,12 @@ public class PrefillingSource {
public void setHash(String hash) { public void setHash(String hash) {
this.hash = hash; this.hash = hash;
} }
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
} }

View File

@ -55,6 +55,9 @@ public class Reference {
private String hash; private String hash;
public final static String _hash = "hash"; public final static String _hash = "hash";
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -174,4 +177,12 @@ public class Reference {
public void setHash(String hash) { public void setHash(String hash) {
this.hash = hash; this.hash = hash;
} }
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
} }

View File

@ -32,6 +32,9 @@ public class ReferenceType {
public final static String _hash = "hash"; public final static String _hash = "hash";
private String hash; private String hash;
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -95,4 +98,12 @@ public class ReferenceType {
public void setHash(String hash) { public void setHash(String hash) {
this.hash = hash; this.hash = hash;
} }
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
} }

View File

@ -40,6 +40,9 @@ public class StorageFile {
private User owner; private User owner;
public final static String _owner = "owner"; public final static String _owner = "owner";
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -127,4 +130,12 @@ public class StorageFile {
public void setOwner(User owner) { public void setOwner(User owner) {
this.owner = owner; this.owner = owner;
} }
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
} }

View File

@ -33,6 +33,9 @@ public class SupportiveMaterial {
private String hash; private String hash;
public final static String _hash = "hash"; public final static String _hash = "hash";
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -96,4 +99,12 @@ public class SupportiveMaterial {
public void setHash(String hash) { public void setHash(String hash) {
this.hash = hash; this.hash = hash;
} }
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
} }

View File

@ -37,6 +37,9 @@ public class Tag {
public static final String _hash = "hash"; public static final String _hash = "hash";
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -92,4 +95,12 @@ public class Tag {
public void setHash(String hash) { public void setHash(String hash) {
this.hash = hash; this.hash = hash;
} }
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
} }

View File

@ -28,6 +28,9 @@ public class TenantUser {
private String hash; private String hash;
public final static String _hash = "hash"; public final static String _hash = "hash";
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -83,4 +86,12 @@ public class TenantUser {
public void setHash(String hash) { public void setHash(String hash) {
this.hash = hash; this.hash = hash;
} }
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
} }

View File

@ -34,6 +34,9 @@ public class UserDescriptionTemplate {
public final static String _hash = "hash"; public final static String _hash = "hash";
private String hash; private String hash;
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -97,4 +100,12 @@ public class UserDescriptionTemplate {
public void setUser(User user) { public void setUser(User user) {
this.user = user; this.user = user;
} }
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
} }

View File

@ -17,6 +17,9 @@ public class UserRole {
public static final String _createdAt = "createdAt"; public static final String _createdAt = "createdAt";
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -48,5 +51,13 @@ public class UserRole {
public void setCreatedAt(Instant createdAt) { public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt; this.createdAt = createdAt;
} }
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
} }

View File

@ -31,6 +31,9 @@ public class UserSettings {
private String hash; private String hash;
public static final String _hash = "hash"; public static final String _hash = "hash";
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -94,4 +97,12 @@ public class UserSettings {
public void setValue(String value) { public void setValue(String value) {
this.value = value; this.value = value;
} }
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
} }

View File

@ -3,11 +3,13 @@ package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.XmlHandlingService; import eu.eudat.commons.XmlHandlingService;
import eu.eudat.commons.enums.ActionConfirmationType; import eu.eudat.commons.enums.ActionConfirmationType;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.commons.types.actionconfirmation.DmpInvitationEntity; import eu.eudat.commons.types.actionconfirmation.DmpInvitationEntity;
import eu.eudat.commons.types.actionconfirmation.MergeAccountConfirmationEntity; import eu.eudat.commons.types.actionconfirmation.MergeAccountConfirmationEntity;
import eu.eudat.commons.types.actionconfirmation.RemoveCredentialRequestEntity; import eu.eudat.commons.types.actionconfirmation.RemoveCredentialRequestEntity;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.ActionConfirmationEntity; import eu.eudat.data.ActionConfirmationEntity;
import eu.eudat.data.tenant.TenantScopedBaseEntity;
import eu.eudat.model.ActionConfirmation; import eu.eudat.model.ActionConfirmation;
import eu.eudat.model.Tenant; import eu.eudat.model.Tenant;
import eu.eudat.model.User; import eu.eudat.model.User;
@ -29,6 +31,7 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.management.InvalidApplicationException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -38,20 +41,23 @@ public class ActionConfirmationBuilder extends BaseBuilder<ActionConfirmation, A
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
private final TenantScope tenantScope;
private final XmlHandlingService xmlHandlingService; private final XmlHandlingService xmlHandlingService;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired @Autowired
public ActionConfirmationBuilder(ConventionService conventionService, BuilderFactory builderFactory, QueryFactory queryFactory, XmlHandlingService xmlHandlingService) { public ActionConfirmationBuilder(ConventionService conventionService, BuilderFactory builderFactory, QueryFactory queryFactory, TenantScope tenantScope, XmlHandlingService xmlHandlingService) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(ActionConfirmationBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(ActionConfirmationBuilder.class)));
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
this.xmlHandlingService = xmlHandlingService; this.tenantScope = tenantScope;
this.xmlHandlingService = xmlHandlingService;
} }
public ActionConfirmationBuilder authorize(EnumSet<AuthorizationFlags> values){ public ActionConfirmationBuilder authorize(EnumSet<AuthorizationFlags> values){
this.authorize = values; this.authorize = values;
return this; return this;
} }
@Override @Override
public List<ActionConfirmation> build(FieldSet fields, List<ActionConfirmationEntity> data) throws MyApplicationException { public List<ActionConfirmation> build(FieldSet fields, List<ActionConfirmationEntity> data) throws MyApplicationException {
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0),Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size) .orElse(0)); this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0),Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size) .orElse(0));
@ -65,9 +71,6 @@ public class ActionConfirmationBuilder extends BaseBuilder<ActionConfirmation, A
FieldSet userFields = fields.extractPrefixed(this.asPrefix(ActionConfirmation._createdBy)); FieldSet userFields = fields.extractPrefixed(this.asPrefix(ActionConfirmation._createdBy));
Map<UUID, User> userMap = this.collectUsers(userFields, data); Map<UUID, User> userMap = this.collectUsers(userFields, data);
FieldSet tenantFields = fields.extractPrefixed(this.asPrefix(ActionConfirmation._tenant));
Map<UUID, Tenant> tenantMap = this.collectTenants(tenantFields, data);
List<ActionConfirmation> models = new ArrayList<>(); List<ActionConfirmation> models = new ArrayList<>();
for(ActionConfirmationEntity d : data){ for(ActionConfirmationEntity d : data){
ActionConfirmation m = new ActionConfirmation(); ActionConfirmation m = new ActionConfirmation();
@ -76,6 +79,7 @@ public class ActionConfirmationBuilder extends BaseBuilder<ActionConfirmation, A
if(fields.hasField(this.asIndexer(ActionConfirmation._status))) m.setStatus(d.getStatus()); if(fields.hasField(this.asIndexer(ActionConfirmation._status))) m.setStatus(d.getStatus());
if(fields.hasField(this.asIndexer(ActionConfirmation._isActive))) m.setIsActive(d.getIsActive()); if(fields.hasField(this.asIndexer(ActionConfirmation._isActive))) m.setIsActive(d.getIsActive());
if(fields.hasField(this.asIndexer(ActionConfirmation._expiresAt))) m.setExpiresAt(d.getExpiresAt()); if(fields.hasField(this.asIndexer(ActionConfirmation._expiresAt))) m.setExpiresAt(d.getExpiresAt());
if (fields.hasField(this.asIndexer(ActionConfirmation._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope));
if (!removeCredentialRequestFields.isEmpty() && d.getData() != null){ if (!removeCredentialRequestFields.isEmpty() && d.getData() != null){
switch (d.getType()) switch (d.getType())
{ {
@ -96,7 +100,6 @@ public class ActionConfirmationBuilder extends BaseBuilder<ActionConfirmation, A
} }
if (!userFields.isEmpty() && userMap != null && userMap.containsKey(d.getCreatedById())) m.setCreatedBy(userMap.get(d.getCreatedById())); if (!userFields.isEmpty() && userMap != null && userMap.containsKey(d.getCreatedById())) m.setCreatedBy(userMap.get(d.getCreatedById()));
if (!tenantFields.isEmpty() && tenantMap != null && tenantMap.containsKey(d.getTenantId())) m.setTenant(tenantMap.get(d.getTenantId()));
if(fields.hasField(this.asIndexer(ActionConfirmation._createdAt))) m.setCreatedAt(d.getCreatedAt()); if(fields.hasField(this.asIndexer(ActionConfirmation._createdAt))) m.setCreatedAt(d.getCreatedAt());
if(fields.hasField(this.asIndexer(ActionConfirmation._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); if(fields.hasField(this.asIndexer(ActionConfirmation._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if(fields.hasField(this.asIndexer(ActionConfirmation._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); if(fields.hasField(this.asIndexer(ActionConfirmation._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
@ -136,32 +139,4 @@ public class ActionConfirmationBuilder extends BaseBuilder<ActionConfirmation, A
return itemMap; return itemMap;
} }
private Map<UUID, Tenant> collectTenants(FieldSet fields, List<ActionConfirmationEntity> datas) throws MyApplicationException {
if (fields.isEmpty() || datas.isEmpty()) return null;
this.logger.debug("checking related - {}", Tenant.class.getSimpleName());
Map<UUID, Tenant> itemMap = null;
if (!fields.hasOtherField(this.asIndexer(Tenant._id))) {
itemMap = this.asEmpty(
datas.stream().map(x -> x.getTenantId()).distinct().collect(Collectors.toList()),
x -> {
Tenant item = new Tenant();
item.setId(x);
return item;
},
x -> x.getId());
} else {
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Tenant._id);
TenantQuery q = this.queryFactory.query(TenantQuery.class).authorize(this.authorize).ids(datas.stream().map(x -> x.getTenantId()).distinct().collect(Collectors.toList()));
itemMap = this.builderFactory.builder(TenantBuilder.class).authorize(this.authorize).asForeignKey(q, clone, x -> x.getId());
}
if (!fields.hasField(Tenant._id)) {
itemMap.values().stream().filter(x -> x != null).map(x -> {
x.setId(null);
return x;
}).collect(Collectors.toList());
}
return itemMap;
}
} }

View File

@ -3,7 +3,9 @@ package eu.eudat.model.builder;
import eu.eudat.authorization.AffiliatedResource; import eu.eudat.authorization.AffiliatedResource;
import eu.eudat.authorization.Permission; import eu.eudat.authorization.Permission;
import eu.eudat.authorization.PermissionNameProvider; import eu.eudat.authorization.PermissionNameProvider;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.tenant.TenantScopedBaseEntity;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.builder.Builder; import gr.cite.tools.data.builder.Builder;
import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryBase;
@ -11,6 +13,7 @@ import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import javax.management.InvalidApplicationException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.time.Instant; import java.time.Instant;
@ -121,5 +124,17 @@ public abstract class BaseBuilder<M, D> implements Builder {
return allowed; return allowed;
} }
protected boolean getBelongsToCurrentTenant(TenantScopedBaseEntity entity, TenantScope tenantScope){
if (!tenantScope.isSet()) return true;
try {
if (entity.getTenantId() == null && tenantScope.getTenant() == null) return true;
if (entity.getTenantId() == null || tenantScope.getTenant() == null) return false;
return entity.getTenantId().equals(tenantScope.getTenant());
} catch (InvalidApplicationException e) {
return false;
}
}
} }

View File

@ -5,6 +5,7 @@ import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.authorizationcontentresolver.AuthorizationContentResolver; import eu.eudat.authorization.authorizationcontentresolver.AuthorizationContentResolver;
import eu.eudat.commons.JsonHandlingService; import eu.eudat.commons.JsonHandlingService;
import eu.eudat.commons.XmlHandlingService; import eu.eudat.commons.XmlHandlingService;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.commons.types.description.PropertyDefinitionEntity; import eu.eudat.commons.types.description.PropertyDefinitionEntity;
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity; import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
@ -43,6 +44,7 @@ public class DescriptionBuilder extends BaseBuilder<Description, DescriptionEnti
private final XmlHandlingService xmlHandlingService; private final XmlHandlingService xmlHandlingService;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
private final AuthorizationContentResolver authorizationContentResolver; private final AuthorizationContentResolver authorizationContentResolver;
private final TenantScope tenantScope;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@ -50,7 +52,7 @@ public class DescriptionBuilder extends BaseBuilder<Description, DescriptionEnti
public DescriptionBuilder( public DescriptionBuilder(
ConventionService conventionService, ConventionService conventionService,
QueryFactory queryFactory, QueryFactory queryFactory,
BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService, AuthorizationService authorizationService, AuthorizationContentResolver authorizationContentResolver) { BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService, AuthorizationService authorizationService, AuthorizationContentResolver authorizationContentResolver, TenantScope tenantScope) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionBuilder.class)));
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
@ -58,6 +60,7 @@ public class DescriptionBuilder extends BaseBuilder<Description, DescriptionEnti
this.xmlHandlingService = xmlHandlingService; this.xmlHandlingService = xmlHandlingService;
this.authorizationService = authorizationService; this.authorizationService = authorizationService;
this.authorizationContentResolver = authorizationContentResolver; this.authorizationContentResolver = authorizationContentResolver;
this.tenantScope = tenantScope;
} }
public DescriptionBuilder authorize(EnumSet<AuthorizationFlags> values) { public DescriptionBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -109,6 +112,7 @@ public class DescriptionBuilder extends BaseBuilder<Description, DescriptionEnti
if (fields.hasField(this.asIndexer(Description._isActive))) m.setIsActive(d.getIsActive()); if (fields.hasField(this.asIndexer(Description._isActive))) m.setIsActive(d.getIsActive());
if (fields.hasField(this.asIndexer(Description._finalizedAt))) m.setFinalizedAt(d.getFinalizedAt()); if (fields.hasField(this.asIndexer(Description._finalizedAt))) m.setFinalizedAt(d.getFinalizedAt());
if (fields.hasField(this.asIndexer(Description._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); if (fields.hasField(this.asIndexer(Description._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
if (fields.hasField(this.asIndexer(Description._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope));
if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) m.setDmp(dmpItemsMap.get(d.getDmpId())); if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) m.setDmp(dmpItemsMap.get(d.getDmpId()));
if (!dmpDescriptionTemplateFields.isEmpty() && dmpDescriptionTemplateItemsMap != null && dmpDescriptionTemplateItemsMap.containsKey(d.getDmpDescriptionTemplateId())) m.setDmpDescriptionTemplate(dmpDescriptionTemplateItemsMap.get(d.getDmpDescriptionTemplateId())); if (!dmpDescriptionTemplateFields.isEmpty() && dmpDescriptionTemplateItemsMap != null && dmpDescriptionTemplateItemsMap.containsKey(d.getDmpDescriptionTemplateId())) m.setDmpDescriptionTemplate(dmpDescriptionTemplateItemsMap.get(d.getDmpDescriptionTemplateId()));
if (!descriptionTemplateFields.isEmpty() && descriptionTemplateItemsMap != null && descriptionTemplateItemsMap.containsKey(d.getDescriptionTemplateId())) m.setDescriptionTemplate(descriptionTemplateItemsMap.get(d.getDescriptionTemplateId())); if (!descriptionTemplateFields.isEmpty() && descriptionTemplateItemsMap != null && descriptionTemplateItemsMap.containsKey(d.getDescriptionTemplateId())) m.setDescriptionTemplate(descriptionTemplateItemsMap.get(d.getDescriptionTemplateId()));

View File

@ -2,6 +2,7 @@ package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.JsonHandlingService; import eu.eudat.commons.JsonHandlingService;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.commons.types.descriptionreference.DescriptionReferenceDataEntity; import eu.eudat.commons.types.descriptionreference.DescriptionReferenceDataEntity;
import eu.eudat.commons.types.dmpreference.DmpReferenceDataEntity; import eu.eudat.commons.types.dmpreference.DmpReferenceDataEntity;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
@ -40,15 +41,17 @@ public class DescriptionReferenceBuilder extends BaseBuilder<DescriptionReferenc
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
private final JsonHandlingService jsonHandlingService; private final JsonHandlingService jsonHandlingService;
private final TenantScope tenantScope;
@Autowired @Autowired
public DescriptionReferenceBuilder( public DescriptionReferenceBuilder(
ConventionService conventionService, ConventionService conventionService,
BuilderFactory builderFactory, QueryFactory queryFactory, JsonHandlingService jsonHandlingService) { BuilderFactory builderFactory, QueryFactory queryFactory, JsonHandlingService jsonHandlingService, TenantScope tenantScope) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionReferenceBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionReferenceBuilder.class)));
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
this.jsonHandlingService = jsonHandlingService; this.jsonHandlingService = jsonHandlingService;
this.tenantScope = tenantScope;
} }
public DescriptionReferenceBuilder authorize(EnumSet<AuthorizationFlags> values) { public DescriptionReferenceBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -79,6 +82,7 @@ public class DescriptionReferenceBuilder extends BaseBuilder<DescriptionReferenc
if (fields.hasField(this.asIndexer(DescriptionReference._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); if (fields.hasField(this.asIndexer(DescriptionReference._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(DescriptionReference._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); if (fields.hasField(this.asIndexer(DescriptionReference._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
if (fields.hasField(this.asIndexer(DescriptionReference._isActive))) m.setIsActive(d.getIsActive()); if (fields.hasField(this.asIndexer(DescriptionReference._isActive))) m.setIsActive(d.getIsActive());
if (fields.hasField(this.asIndexer(DescriptionReference._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope));
if (!referenceFields.isEmpty() && referenceItemsMap != null && referenceItemsMap.containsKey(d.getReferenceId())) m.setReference(referenceItemsMap.get(d.getReferenceId())); if (!referenceFields.isEmpty() && referenceItemsMap != null && referenceItemsMap.containsKey(d.getReferenceId())) m.setReference(referenceItemsMap.get(d.getReferenceId()));
if (!descriptionFields.isEmpty() && descriptionItemsMap != null && descriptionItemsMap.containsKey(d.getDescriptionId())) m.setDescription(descriptionItemsMap.get(d.getDescriptionId())); if (!descriptionFields.isEmpty() && descriptionItemsMap != null && descriptionItemsMap.containsKey(d.getDescriptionId())) m.setDescription(descriptionItemsMap.get(d.getDescriptionId()));
if (!dataFields.isEmpty() && d.getData() != null){ if (!dataFields.isEmpty() && d.getData() != null){

View File

@ -1,6 +1,7 @@
package eu.eudat.model.builder; package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.DescriptionTagEntity; import eu.eudat.data.DescriptionTagEntity;
import eu.eudat.model.Description; import eu.eudat.model.Description;
@ -31,16 +32,18 @@ public class DescriptionTagBuilder extends BaseBuilder<DescriptionTag, Descripti
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
private final TenantScope tenantScope;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired @Autowired
public DescriptionTagBuilder( public DescriptionTagBuilder(
ConventionService conventionService, ConventionService conventionService,
BuilderFactory builderFactory, QueryFactory queryFactory) { BuilderFactory builderFactory, QueryFactory queryFactory, TenantScope tenantScope) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionTagBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionTagBuilder.class)));
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
this.tenantScope = tenantScope;
} }
public DescriptionTagBuilder authorize(EnumSet<AuthorizationFlags> values) { public DescriptionTagBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -70,6 +73,7 @@ public class DescriptionTagBuilder extends BaseBuilder<DescriptionTag, Descripti
if (fields.hasField(this.asIndexer(DescriptionTag._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); if (fields.hasField(this.asIndexer(DescriptionTag._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(DescriptionTag._isActive))) m.setIsActive(d.getIsActive()); if (fields.hasField(this.asIndexer(DescriptionTag._isActive))) m.setIsActive(d.getIsActive());
if (fields.hasField(this.asIndexer(DescriptionTag._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); if (fields.hasField(this.asIndexer(DescriptionTag._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
if (fields.hasField(this.asIndexer(DescriptionTag._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope));
if (!tagFields.isEmpty() && tagItemsMap != null && tagItemsMap.containsKey(d.getTagId())) m.setTag(tagItemsMap.get(d.getTagId())); if (!tagFields.isEmpty() && tagItemsMap != null && tagItemsMap.containsKey(d.getTagId())) m.setTag(tagItemsMap.get(d.getTagId()));
if (!descriptionFields.isEmpty() && descriptionItemsMap != null && descriptionItemsMap.containsKey(d.getDescriptionId())) m.setDescription(descriptionItemsMap.get(d.getDescriptionId())); if (!descriptionFields.isEmpty() && descriptionItemsMap != null && descriptionItemsMap.containsKey(d.getDescriptionId())) m.setDescription(descriptionItemsMap.get(d.getDescriptionId()));

View File

@ -2,6 +2,7 @@ package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.XmlHandlingService; import eu.eudat.commons.XmlHandlingService;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity; import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.DescriptionTemplateEntity; import eu.eudat.data.DescriptionTemplateEntity;
@ -38,14 +39,16 @@ public class DescriptionTemplateBuilder extends BaseBuilder<DescriptionTemplate,
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private final XmlHandlingService xmlHandlingService; private final XmlHandlingService xmlHandlingService;
private final TenantScope tenantScope;
@Autowired @Autowired
public DescriptionTemplateBuilder( public DescriptionTemplateBuilder(
ConventionService conventionService, QueryFactory queryFactory, BuilderFactory builderFactory, XmlHandlingService xmlHandlingService) { ConventionService conventionService, QueryFactory queryFactory, BuilderFactory builderFactory, XmlHandlingService xmlHandlingService, TenantScope tenantScope) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionTemplateBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionTemplateBuilder.class)));
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.xmlHandlingService = xmlHandlingService; this.xmlHandlingService = xmlHandlingService;
this.tenantScope = tenantScope;
} }
public DescriptionTemplateBuilder authorize(EnumSet<AuthorizationFlags> values) { public DescriptionTemplateBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -94,6 +97,7 @@ public class DescriptionTemplateBuilder extends BaseBuilder<DescriptionTemplate,
m.setStatus(d.getStatus()); m.setStatus(d.getStatus());
if (fields.hasField(this.asIndexer(DescriptionTemplate._hash))) if (fields.hasField(this.asIndexer(DescriptionTemplate._hash)))
m.setHash(this.hashValue(d.getUpdatedAt())); m.setHash(this.hashValue(d.getUpdatedAt()));
if (fields.hasField(this.asIndexer(DescriptionTemplate._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope));
if (!definitionFields.isEmpty() && d.getDefinition() != null) { if (!definitionFields.isEmpty() && d.getDefinition() != null) {
DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, d.getDefinition()); DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, d.getDefinition());
m.setDefinition(this.builderFactory.builder(DefinitionBuilder.class).authorize(this.authorize).build(definitionFields, definition)); m.setDefinition(this.builderFactory.builder(DefinitionBuilder.class).authorize(this.authorize).build(definitionFields, definition));

View File

@ -1,6 +1,7 @@
package eu.eudat.model.builder; package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.DescriptionTemplateTypeEntity; import eu.eudat.data.DescriptionTemplateTypeEntity;
import eu.eudat.model.DescriptionTemplateType; import eu.eudat.model.DescriptionTemplateType;
@ -20,12 +21,14 @@ import java.util.*;
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class DescriptionTemplateTypeBuilder extends BaseBuilder<DescriptionTemplateType, DescriptionTemplateTypeEntity> { public class DescriptionTemplateTypeBuilder extends BaseBuilder<DescriptionTemplateType, DescriptionTemplateTypeEntity> {
private final TenantScope tenantScope;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired @Autowired
public DescriptionTemplateTypeBuilder( public DescriptionTemplateTypeBuilder(
ConventionService conventionService) { ConventionService conventionService, TenantScope tenantScope) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionTemplateTypeBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionTemplateTypeBuilder.class)));
this.tenantScope = tenantScope;
} }
public DescriptionTemplateTypeBuilder authorize(EnumSet<AuthorizationFlags> values) { public DescriptionTemplateTypeBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -57,6 +60,7 @@ public class DescriptionTemplateTypeBuilder extends BaseBuilder<DescriptionTempl
m.setStatus(d.getStatus()); m.setStatus(d.getStatus());
if (fields.hasField(this.asIndexer(DescriptionTemplateType._hash))) if (fields.hasField(this.asIndexer(DescriptionTemplateType._hash)))
m.setHash(this.hashValue(d.getUpdatedAt())); m.setHash(this.hashValue(d.getUpdatedAt()));
if (fields.hasField(this.asIndexer(DescriptionTemplateType._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope));
models.add(m); models.add(m);
} }
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));

View File

@ -2,6 +2,7 @@ package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.XmlHandlingService; import eu.eudat.commons.XmlHandlingService;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.commons.types.dmpblueprint.DefinitionEntity; import eu.eudat.commons.types.dmpblueprint.DefinitionEntity;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.DmpBlueprintEntity; import eu.eudat.data.DmpBlueprintEntity;
@ -27,16 +28,18 @@ public class DmpBlueprintBuilder extends BaseBuilder<DmpBlueprint, DmpBlueprintE
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private final XmlHandlingService xmlHandlingService; private final XmlHandlingService xmlHandlingService;
private final TenantScope tenantScope;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired @Autowired
public DmpBlueprintBuilder( public DmpBlueprintBuilder(
ConventionService conventionService, ConventionService conventionService,
BuilderFactory builderFactory, XmlHandlingService xmlHandlingService) { BuilderFactory builderFactory, XmlHandlingService xmlHandlingService, TenantScope tenantScope) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpBlueprintBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpBlueprintBuilder.class)));
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.xmlHandlingService = xmlHandlingService; this.xmlHandlingService = xmlHandlingService;
this.tenantScope = tenantScope;
} }
public DmpBlueprintBuilder authorize(EnumSet<AuthorizationFlags> values) { public DmpBlueprintBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -75,6 +78,7 @@ public class DmpBlueprintBuilder extends BaseBuilder<DmpBlueprint, DmpBlueprintE
m.setIsActive(d.getIsActive()); m.setIsActive(d.getIsActive());
if (fields.hasField(this.asIndexer(DmpBlueprint._hash))) if (fields.hasField(this.asIndexer(DmpBlueprint._hash)))
m.setHash(this.hashValue(d.getUpdatedAt())); m.setHash(this.hashValue(d.getUpdatedAt()));
if (fields.hasField(this.asIndexer(DmpBlueprint._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope));
if (!definitionFields.isEmpty() && d.getDefinition() != null) { if (!definitionFields.isEmpty() && d.getDefinition() != null) {
DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, d.getDefinition()); DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, d.getDefinition());
m.setDefinition(this.builderFactory.builder(DefinitionBuilder.class).authorize(this.authorize).build(definitionFields, definition)); m.setDefinition(this.builderFactory.builder(DefinitionBuilder.class).authorize(this.authorize).build(definitionFields, definition));

View File

@ -5,6 +5,7 @@ import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.authorizationcontentresolver.AuthorizationContentResolver; import eu.eudat.authorization.authorizationcontentresolver.AuthorizationContentResolver;
import eu.eudat.commons.JsonHandlingService; import eu.eudat.commons.JsonHandlingService;
import eu.eudat.commons.enums.EntityType; import eu.eudat.commons.enums.EntityType;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.commons.types.dmp.DmpPropertiesEntity; import eu.eudat.commons.types.dmp.DmpPropertiesEntity;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.DmpEntity; import eu.eudat.data.DmpEntity;
@ -38,19 +39,21 @@ public class DmpBuilder extends BaseBuilder<Dmp, DmpEntity> {
private final JsonHandlingService jsonHandlingService; private final JsonHandlingService jsonHandlingService;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
private final AuthorizationContentResolver authorizationContentResolver; private final AuthorizationContentResolver authorizationContentResolver;
private final TenantScope tenantScope;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired @Autowired
public DmpBuilder(ConventionService conventionService, public DmpBuilder(ConventionService conventionService,
QueryFactory queryFactory, QueryFactory queryFactory,
BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, AuthorizationService authorizationService, AuthorizationContentResolver authorizationContentResolver) { BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, AuthorizationService authorizationService, AuthorizationContentResolver authorizationContentResolver, TenantScope tenantScope) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpBuilder.class)));
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.jsonHandlingService = jsonHandlingService; this.jsonHandlingService = jsonHandlingService;
this.authorizationService = authorizationService; this.authorizationService = authorizationService;
this.authorizationContentResolver = authorizationContentResolver; this.authorizationContentResolver = authorizationContentResolver;
this.tenantScope = tenantScope;
} }
public DmpBuilder authorize(EnumSet<AuthorizationFlags> values) { public DmpBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -109,6 +112,7 @@ public class DmpBuilder extends BaseBuilder<Dmp, DmpEntity> {
if (fields.hasField(this.asIndexer(Dmp._versionStatus))) m.setVersionStatus(d.getVersionStatus()); if (fields.hasField(this.asIndexer(Dmp._versionStatus))) m.setVersionStatus(d.getVersionStatus());
if (fields.hasField(this.asIndexer(Dmp._publicAfter))) m.setPublicAfter(d.getPublicAfter()); if (fields.hasField(this.asIndexer(Dmp._publicAfter))) m.setPublicAfter(d.getPublicAfter());
if (fields.hasField(this.asIndexer(Dmp._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); if (fields.hasField(this.asIndexer(Dmp._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
if (fields.hasField(this.asIndexer(Dmp._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope));
if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getCreatorId())) m.setCreator(userItemsMap.get(d.getCreatorId())); if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getCreatorId())) m.setCreator(userItemsMap.get(d.getCreatorId()));
if (!blueprintFields.isEmpty() && blueprintItemsMap != null && blueprintItemsMap.containsKey(d.getBlueprintId())) m.setBlueprint(blueprintItemsMap.get(d.getBlueprintId())); if (!blueprintFields.isEmpty() && blueprintItemsMap != null && blueprintItemsMap.containsKey(d.getBlueprintId())) m.setBlueprint(blueprintItemsMap.get(d.getBlueprintId()));
if (entityDoisMap != null && !entityDoisMap.isEmpty() && entityDoisMap.containsKey(d.getId())) m.setEntityDois(entityDoisMap.get(d.getId())); if (entityDoisMap != null && !entityDoisMap.isEmpty() && entityDoisMap.containsKey(d.getId())) m.setEntityDois(entityDoisMap.get(d.getId()));

View File

@ -2,6 +2,7 @@ package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.enums.DescriptionTemplateVersionStatus; import eu.eudat.commons.enums.DescriptionTemplateVersionStatus;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.DmpDescriptionTemplateEntity; import eu.eudat.data.DmpDescriptionTemplateEntity;
import eu.eudat.data.DmpEntity; import eu.eudat.data.DmpEntity;
@ -32,16 +33,18 @@ public class DmpDescriptionTemplateBuilder extends BaseBuilder<DmpDescriptionTem
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
private final TenantScope tenantScope;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired @Autowired
public DmpDescriptionTemplateBuilder( public DmpDescriptionTemplateBuilder(
ConventionService conventionService, ConventionService conventionService,
BuilderFactory builderFactory, QueryFactory queryFactory) { BuilderFactory builderFactory, QueryFactory queryFactory, TenantScope tenantScope) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpDescriptionTemplateBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpDescriptionTemplateBuilder.class)));
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
this.tenantScope = tenantScope;
} }
public DmpDescriptionTemplateBuilder authorize(EnumSet<AuthorizationFlags> values) { public DmpDescriptionTemplateBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -75,6 +78,7 @@ public class DmpDescriptionTemplateBuilder extends BaseBuilder<DmpDescriptionTem
if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._isActive))) m.setIsActive(d.getIsActive()); if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._isActive))) m.setIsActive(d.getIsActive());
if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
if (fields.hasField(this.asIndexer(DescriptionTemplateType._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope));
if (!templateFields.isEmpty() && templateItemsMap != null && templateItemsMap.containsKey(d.getDescriptionTemplateGroupId())) m.setDescriptionTemplates(templateItemsMap.get(d.getDescriptionTemplateGroupId())); if (!templateFields.isEmpty() && templateItemsMap != null && templateItemsMap.containsKey(d.getDescriptionTemplateGroupId())) m.setDescriptionTemplates(templateItemsMap.get(d.getDescriptionTemplateGroupId()));
if (!currentDescriptionTemplateFields.isEmpty() && currentDescriptionTemplateItemsMap != null && currentDescriptionTemplateItemsMap.containsKey(d.getDescriptionTemplateGroupId())) m.setCurrentDescriptionTemplate(currentDescriptionTemplateItemsMap.get(d.getDescriptionTemplateGroupId())); if (!currentDescriptionTemplateFields.isEmpty() && currentDescriptionTemplateItemsMap != null && currentDescriptionTemplateItemsMap.containsKey(d.getDescriptionTemplateGroupId())) m.setCurrentDescriptionTemplate(currentDescriptionTemplateItemsMap.get(d.getDescriptionTemplateGroupId()));
if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) m.setDmp(dmpItemsMap.get(d.getDmpId())); if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) m.setDmp(dmpItemsMap.get(d.getDmpId()));

View File

@ -2,6 +2,7 @@ package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.JsonHandlingService; import eu.eudat.commons.JsonHandlingService;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.commons.types.description.PropertyDefinitionEntity; import eu.eudat.commons.types.description.PropertyDefinitionEntity;
import eu.eudat.commons.types.dmpreference.DmpReferenceDataEntity; import eu.eudat.commons.types.dmpreference.DmpReferenceDataEntity;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
@ -38,17 +39,19 @@ public class DmpReferenceBuilder extends BaseBuilder<DmpReference, DmpReferenceE
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
private final JsonHandlingService jsonHandlingService; private final JsonHandlingService jsonHandlingService;
private final TenantScope tenantScope;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired @Autowired
public DmpReferenceBuilder( public DmpReferenceBuilder(
ConventionService conventionService, ConventionService conventionService,
BuilderFactory builderFactory, QueryFactory queryFactory, JsonHandlingService jsonHandlingService) { BuilderFactory builderFactory, QueryFactory queryFactory, JsonHandlingService jsonHandlingService, TenantScope tenantScope) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpReferenceBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpReferenceBuilder.class)));
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
this.jsonHandlingService = jsonHandlingService; this.jsonHandlingService = jsonHandlingService;
this.tenantScope = tenantScope;
} }
public DmpReferenceBuilder authorize(EnumSet<AuthorizationFlags> values) { public DmpReferenceBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -78,6 +81,7 @@ public class DmpReferenceBuilder extends BaseBuilder<DmpReference, DmpReferenceE
if (fields.hasField(this.asIndexer(DmpReference._createdAt))) m.setCreatedAt(d.getCreatedAt()); if (fields.hasField(this.asIndexer(DmpReference._createdAt))) m.setCreatedAt(d.getCreatedAt());
if (fields.hasField(this.asIndexer(DmpReference._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); if (fields.hasField(this.asIndexer(DmpReference._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(DmpReference._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); if (fields.hasField(this.asIndexer(DmpReference._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
if (fields.hasField(this.asIndexer(DmpReference._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope));
if (!referenceFields.isEmpty() && referenceItemsMap != null && referenceItemsMap.containsKey(d.getReferenceId())) m.setReference(referenceItemsMap.get(d.getReferenceId())); if (!referenceFields.isEmpty() && referenceItemsMap != null && referenceItemsMap.containsKey(d.getReferenceId())) m.setReference(referenceItemsMap.get(d.getReferenceId()));
if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) m.setDmp(dmpItemsMap.get(d.getDmpId())); if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) m.setDmp(dmpItemsMap.get(d.getDmpId()));
if (!dataFields.isEmpty() && d.getData() != null){ if (!dataFields.isEmpty() && d.getData() != null){

View File

@ -1,6 +1,7 @@
package eu.eudat.model.builder; package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.DmpUserEntity; import eu.eudat.data.DmpUserEntity;
import eu.eudat.model.*; import eu.eudat.model.*;
@ -29,16 +30,18 @@ public class DmpUserBuilder extends BaseBuilder<DmpUser, DmpUserEntity>{
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
private final TenantScope tenantScope;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired @Autowired
public DmpUserBuilder( public DmpUserBuilder(
ConventionService conventionService, ConventionService conventionService,
BuilderFactory builderFactory, QueryFactory queryFactory) { BuilderFactory builderFactory, QueryFactory queryFactory, TenantScope tenantScope) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpUserBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpUserBuilder.class)));
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
this.tenantScope = tenantScope;
} }
public DmpUserBuilder authorize(EnumSet<AuthorizationFlags> values) { public DmpUserBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -68,7 +71,8 @@ public class DmpUserBuilder extends BaseBuilder<DmpUser, DmpUserEntity>{
if (fields.hasField(this.asIndexer(DmpUser._createdAt))) m.setCreatedAt(d.getCreatedAt()); if (fields.hasField(this.asIndexer(DmpUser._createdAt))) m.setCreatedAt(d.getCreatedAt());
if (fields.hasField(this.asIndexer(DmpUser._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); if (fields.hasField(this.asIndexer(DmpUser._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(DmpUser._isActive))) m.setIsActive(d.getIsActive()); if (fields.hasField(this.asIndexer(DmpUser._isActive))) m.setIsActive(d.getIsActive());
if (fields.hasField(this.asIndexer(DmpReference._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); if (fields.hasField(this.asIndexer(DmpUser._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
if (fields.hasField(this.asIndexer(DmpUser._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope));
if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId())); if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId()));
if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) m.setDmp(dmpItemsMap.get(d.getDmpId())); if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) m.setDmp(dmpItemsMap.get(d.getDmpId()));
if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId())); if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId()));

View File

@ -1,6 +1,7 @@
package eu.eudat.model.builder; package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.EntityDoiEntity; import eu.eudat.data.EntityDoiEntity;
import eu.eudat.model.EntityDoi; import eu.eudat.model.EntityDoi;
@ -20,12 +21,14 @@ import java.util.*;
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class EntityDoiBuilder extends BaseBuilder<EntityDoi, EntityDoiEntity> { public class EntityDoiBuilder extends BaseBuilder<EntityDoi, EntityDoiEntity> {
private final TenantScope tenantScope;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired @Autowired
public EntityDoiBuilder( public EntityDoiBuilder(
ConventionService conventionService) { ConventionService conventionService, TenantScope tenantScope) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(EntityDoiBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(EntityDoiBuilder.class)));
this.tenantScope = tenantScope;
} }
public EntityDoiBuilder authorize(EnumSet<AuthorizationFlags> values) { public EntityDoiBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -61,6 +64,7 @@ public class EntityDoiBuilder extends BaseBuilder<EntityDoi, EntityDoiEntity> {
m.setIsActive(d.getIsActive()); m.setIsActive(d.getIsActive());
if (fields.hasField(this.asIndexer(EntityDoi._hash))) if (fields.hasField(this.asIndexer(EntityDoi._hash)))
m.setHash(hashValue(d.getUpdatedAt())); m.setHash(hashValue(d.getUpdatedAt()));
if (fields.hasField(this.asIndexer(EntityDoi._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope));
models.add(m); models.add(m);
} }
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));

View File

@ -2,6 +2,7 @@ package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.XmlHandlingService; import eu.eudat.commons.XmlHandlingService;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.LanguageEntity; import eu.eudat.data.LanguageEntity;
import eu.eudat.model.Language; import eu.eudat.model.Language;
@ -22,13 +23,15 @@ import java.util.*;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class LanguageBuilder extends BaseBuilder<Language, LanguageEntity>{ public class LanguageBuilder extends BaseBuilder<Language, LanguageEntity>{
private final TenantScope tenantScope;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired @Autowired
public LanguageBuilder( public LanguageBuilder(
ConventionService conventionService, ConventionService conventionService,
BuilderFactory builderFactory, QueryFactory queryFactory, XmlHandlingService xmlHandlingService) { BuilderFactory builderFactory, QueryFactory queryFactory, XmlHandlingService xmlHandlingService, TenantScope tenantScope) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(LanguageBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(LanguageBuilder.class)));
this.tenantScope = tenantScope;
} }
public LanguageBuilder authorize(EnumSet<AuthorizationFlags> values) { public LanguageBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -54,6 +57,7 @@ public class LanguageBuilder extends BaseBuilder<Language, LanguageEntity>{
if (fields.hasField(this.asIndexer(Language._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); if (fields.hasField(this.asIndexer(Language._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(Language._isActive))) m.setIsActive(d.getIsActive()); if (fields.hasField(this.asIndexer(Language._isActive))) m.setIsActive(d.getIsActive());
if (fields.hasField(this.asIndexer(Language._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); if (fields.hasField(this.asIndexer(Language._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
if (fields.hasField(this.asIndexer(Language._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope));
models.add(m); models.add(m);
} }
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));

View File

@ -2,6 +2,7 @@ package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.XmlHandlingService; import eu.eudat.commons.XmlHandlingService;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.LockEntity; import eu.eudat.data.LockEntity;
import eu.eudat.model.Lock; import eu.eudat.model.Lock;
@ -30,18 +31,18 @@ import java.util.stream.Collectors;
public class LockBuilder extends BaseBuilder<Lock, LockEntity>{ public class LockBuilder extends BaseBuilder<Lock, LockEntity>{
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private final TenantScope tenantScope;
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
private final XmlHandlingService xmlHandlingService;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired @Autowired
public LockBuilder( public LockBuilder(
ConventionService conventionService, ConventionService conventionService,
BuilderFactory builderFactory, QueryFactory queryFactory, XmlHandlingService xmlHandlingService) { BuilderFactory builderFactory, TenantScope tenantScope, QueryFactory queryFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(LockBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(LockBuilder.class)));
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.queryFactory = queryFactory; this.tenantScope = tenantScope;
this.xmlHandlingService = xmlHandlingService; this.queryFactory = queryFactory;
} }
public LockBuilder authorize(EnumSet<AuthorizationFlags> values) { public LockBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -59,9 +60,6 @@ public class LockBuilder extends BaseBuilder<Lock, LockEntity>{
FieldSet userFields = fields.extractPrefixed(this.asPrefix(Lock._lockedBy)); FieldSet userFields = fields.extractPrefixed(this.asPrefix(Lock._lockedBy));
Map<UUID, User> userMap = this.collectUsers(userFields, data); Map<UUID, User> userMap = this.collectUsers(userFields, data);
FieldSet tenantFields = fields.extractPrefixed(this.asPrefix(Lock._tenant));
Map<UUID, Tenant> tenantMap = this.collectTenants(tenantFields, data);
List<Lock> models = new ArrayList<>(); List<Lock> models = new ArrayList<>();
for (LockEntity d : data) { for (LockEntity d : data) {
Lock m = new Lock(); Lock m = new Lock();
@ -71,8 +69,8 @@ public class LockBuilder extends BaseBuilder<Lock, LockEntity>{
if (fields.hasField(this.asIndexer(Lock._lockedAt))) m.setLockedAt(d.getLockedAt()); if (fields.hasField(this.asIndexer(Lock._lockedAt))) m.setLockedAt(d.getLockedAt());
if (fields.hasField(this.asIndexer(Lock._touchedAt))) m.setTouchedAt(d.getTouchedAt()); if (fields.hasField(this.asIndexer(Lock._touchedAt))) m.setTouchedAt(d.getTouchedAt());
if (fields.hasField(this.asIndexer(Lock._hash))) m.setHash(this.hashValue(d.getTouchedAt())); if (fields.hasField(this.asIndexer(Lock._hash))) m.setHash(this.hashValue(d.getTouchedAt()));
if (fields.hasField(this.asIndexer(Lock._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope));
if (!userFields.isEmpty() && userMap != null && userMap.containsKey(d.getLockedBy())) m.setLockedBy(userMap.get(d.getLockedBy())); if (!userFields.isEmpty() && userMap != null && userMap.containsKey(d.getLockedBy())) m.setLockedBy(userMap.get(d.getLockedBy()));
if (!tenantFields.isEmpty() && tenantMap != null && tenantMap.containsKey(d.getTenantId())) m.setTenant(tenantMap.get(d.getTenantId()));
models.add(m); models.add(m);
} }
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
@ -108,33 +106,4 @@ public class LockBuilder extends BaseBuilder<Lock, LockEntity>{
return itemMap; return itemMap;
} }
private Map<UUID, Tenant> collectTenants(FieldSet fields, List<LockEntity> datas) throws MyApplicationException {
if (fields.isEmpty() || datas.isEmpty()) return null;
this.logger.debug("checking related - {}", Tenant.class.getSimpleName());
Map<UUID, Tenant> itemMap = null;
if (!fields.hasOtherField(this.asIndexer(Tenant._id))) {
itemMap = this.asEmpty(
datas.stream().map(x -> x.getTenantId()).distinct().collect(Collectors.toList()),
x -> {
Tenant item = new Tenant();
item.setId(x);
return item;
},
x -> x.getId());
} else {
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Tenant._id);
TenantQuery q = this.queryFactory.query(TenantQuery.class).authorize(this.authorize).ids(datas.stream().map(x -> x.getTenantId()).distinct().collect(Collectors.toList()));
itemMap = this.builderFactory.builder(TenantBuilder.class).authorize(this.authorize).asForeignKey(q, clone, x -> x.getId());
}
if (!fields.hasField(Tenant._id)) {
itemMap.values().stream().filter(x -> x != null).map(x -> {
x.setId(null);
return x;
}).collect(Collectors.toList());
}
return itemMap;
}
} }

View File

@ -2,6 +2,7 @@ package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.XmlHandlingService; import eu.eudat.commons.XmlHandlingService;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.commons.types.prefillingsource.PrefillingSourceDefinitionEntity; import eu.eudat.commons.types.prefillingsource.PrefillingSourceDefinitionEntity;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.PrefillingSourceEntity; import eu.eudat.data.PrefillingSourceEntity;
@ -26,17 +27,17 @@ import java.util.*;
public class PrefillingSourceBuilder extends BaseBuilder<PrefillingSource, PrefillingSourceEntity>{ public class PrefillingSourceBuilder extends BaseBuilder<PrefillingSource, PrefillingSourceEntity>{
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private final QueryFactory queryFactory;
private final XmlHandlingService xmlHandlingService; private final XmlHandlingService xmlHandlingService;
private final TenantScope tenantScope;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired @Autowired
public PrefillingSourceBuilder( public PrefillingSourceBuilder(
ConventionService conventionService, ConventionService conventionService,
BuilderFactory builderFactory, QueryFactory queryFactory, XmlHandlingService xmlHandlingService) { BuilderFactory builderFactory, XmlHandlingService xmlHandlingService, TenantScope tenantScope) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(PrefillingSourceBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(PrefillingSourceBuilder.class)));
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.queryFactory = queryFactory; this.tenantScope = tenantScope;
this.xmlHandlingService = xmlHandlingService; this.xmlHandlingService = xmlHandlingService;
} }
@ -66,6 +67,7 @@ public class PrefillingSourceBuilder extends BaseBuilder<PrefillingSource, Prefi
if (fields.hasField(this.asIndexer(PrefillingSource._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); if (fields.hasField(this.asIndexer(PrefillingSource._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(PrefillingSource._isActive))) m.setIsActive(d.getIsActive()); if (fields.hasField(this.asIndexer(PrefillingSource._isActive))) m.setIsActive(d.getIsActive());
if (fields.hasField(this.asIndexer(PrefillingSource._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); if (fields.hasField(this.asIndexer(PrefillingSource._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
if (fields.hasField(this.asIndexer(PrefillingSource._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope));
models.add(m); models.add(m);
} }

View File

@ -2,6 +2,7 @@ package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.XmlHandlingService; import eu.eudat.commons.XmlHandlingService;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.commons.types.reference.DefinitionEntity; import eu.eudat.commons.types.reference.DefinitionEntity;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.DescriptionEntity; import eu.eudat.data.DescriptionEntity;
@ -37,16 +38,18 @@ public class ReferenceBuilder extends BaseBuilder<Reference, ReferenceEntity>{
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
private final XmlHandlingService xmlHandlingService; private final XmlHandlingService xmlHandlingService;
private final TenantScope tenantScope;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired @Autowired
public ReferenceBuilder( public ReferenceBuilder(
ConventionService conventionService, ConventionService conventionService,
BuilderFactory builderFactory, QueryFactory queryFactory, XmlHandlingService xmlHandlingService) { BuilderFactory builderFactory, QueryFactory queryFactory, XmlHandlingService xmlHandlingService, TenantScope tenantScope) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceBuilder.class)));
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
this.xmlHandlingService = xmlHandlingService; this.xmlHandlingService = xmlHandlingService;
this.tenantScope = tenantScope;
} }
public ReferenceBuilder authorize(EnumSet<AuthorizationFlags> values) { public ReferenceBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -94,6 +97,7 @@ public class ReferenceBuilder extends BaseBuilder<Reference, ReferenceEntity>{
if (!typeFields.isEmpty() && typeItemsMap != null && typeItemsMap.containsKey(d.getTypeId())) m.setType(typeItemsMap.get(d.getTypeId())); if (!typeFields.isEmpty() && typeItemsMap != null && typeItemsMap.containsKey(d.getTypeId())) m.setType(typeItemsMap.get(d.getTypeId()));
if (dmpReferenceMap != null && !dmpReferenceMap.isEmpty() && dmpReferenceMap.containsKey(d.getId())) m.setDmpReferences(dmpReferenceMap.get(d.getId())); if (dmpReferenceMap != null && !dmpReferenceMap.isEmpty() && dmpReferenceMap.containsKey(d.getId())) m.setDmpReferences(dmpReferenceMap.get(d.getId()));
if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getCreatedById())) m.setCreatedBy(userItemsMap.get(d.getCreatedById())); if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getCreatedById())) m.setCreatedBy(userItemsMap.get(d.getCreatedById()));
if (fields.hasField(this.asIndexer(Reference._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope));
models.add(m); models.add(m);
} }
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));

View File

@ -2,6 +2,7 @@ package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.XmlHandlingService; import eu.eudat.commons.XmlHandlingService;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.commons.types.referencetype.ReferenceTypeDefinitionEntity; import eu.eudat.commons.types.referencetype.ReferenceTypeDefinitionEntity;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.ReferenceTypeEntity; import eu.eudat.data.ReferenceTypeEntity;
@ -26,17 +27,17 @@ import java.util.*;
public class ReferenceTypeBuilder extends BaseBuilder<ReferenceType, ReferenceTypeEntity>{ public class ReferenceTypeBuilder extends BaseBuilder<ReferenceType, ReferenceTypeEntity>{
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private final QueryFactory queryFactory;
private final XmlHandlingService xmlHandlingService; private final XmlHandlingService xmlHandlingService;
private final TenantScope tenantScope;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired @Autowired
public ReferenceTypeBuilder( public ReferenceTypeBuilder(
ConventionService conventionService, ConventionService conventionService,
BuilderFactory builderFactory, QueryFactory queryFactory, XmlHandlingService xmlHandlingService) { BuilderFactory builderFactory, XmlHandlingService xmlHandlingService, TenantScope tenantScope) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeBuilder.class)));
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.queryFactory = queryFactory; this.tenantScope = tenantScope;
this.xmlHandlingService = xmlHandlingService; this.xmlHandlingService = xmlHandlingService;
} }
@ -64,6 +65,7 @@ public class ReferenceTypeBuilder extends BaseBuilder<ReferenceType, ReferenceTy
if (fields.hasField(this.asIndexer(ReferenceType._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); if (fields.hasField(this.asIndexer(ReferenceType._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(ReferenceType._isActive))) m.setIsActive(d.getIsActive()); if (fields.hasField(this.asIndexer(ReferenceType._isActive))) m.setIsActive(d.getIsActive());
if (fields.hasField(this.asIndexer(ReferenceType._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); if (fields.hasField(this.asIndexer(ReferenceType._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
if (fields.hasField(this.asIndexer(ReferenceType._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope));
if (!definitionFields.isEmpty() && d.getDefinition() != null){ if (!definitionFields.isEmpty() && d.getDefinition() != null){
ReferenceTypeDefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(ReferenceTypeDefinitionEntity.class, d.getDefinition()); ReferenceTypeDefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(ReferenceTypeDefinitionEntity.class, d.getDefinition());
m.setDefinition(this.builderFactory.builder(ReferenceTypeDefinitionBuilder.class).authorize(this.authorize).build(definitionFields, definition)); m.setDefinition(this.builderFactory.builder(ReferenceTypeDefinitionBuilder.class).authorize(this.authorize).build(definitionFields, definition));

View File

@ -1,6 +1,7 @@
package eu.eudat.model.builder; package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.StorageFileEntity; import eu.eudat.data.StorageFileEntity;
import eu.eudat.model.*; import eu.eudat.model.*;
@ -28,17 +29,19 @@ public class StorageFileBuilder extends BaseBuilder<StorageFile, StorageFileEnti
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private final TenantScope tenantScope;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired @Autowired
public StorageFileBuilder( public StorageFileBuilder(
ConventionService conventionService, ConventionService conventionService,
QueryFactory queryFactory, QueryFactory queryFactory,
BuilderFactory builderFactory) { BuilderFactory builderFactory, TenantScope tenantScope) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(StorageFileBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(StorageFileBuilder.class)));
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.tenantScope = tenantScope;
} }
public StorageFileBuilder authorize(EnumSet<AuthorizationFlags> values) { public StorageFileBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -69,6 +72,7 @@ public class StorageFileBuilder extends BaseBuilder<StorageFile, StorageFileEnti
if (fields.hasField(this.asIndexer(StorageFile._purgeAt))) m.setPurgeAt(d.getPurgeAt()); if (fields.hasField(this.asIndexer(StorageFile._purgeAt))) m.setPurgeAt(d.getPurgeAt());
if (fields.hasField(this.asIndexer(StorageFile._purgedAt))) m.setPurgedAt(d.getPurgedAt()); if (fields.hasField(this.asIndexer(StorageFile._purgedAt))) m.setPurgedAt(d.getPurgedAt());
if (fields.hasField(this.asIndexer(StorageFile._fullName))) m.setFullName(d.getName() + (d.getExtension().startsWith(".") ? "" : ".") + d.getExtension()); if (fields.hasField(this.asIndexer(StorageFile._fullName))) m.setFullName(d.getName() + (d.getExtension().startsWith(".") ? "" : ".") + d.getExtension());
if (fields.hasField(this.asIndexer(StorageFile._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope));
if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getOwnerId())) m.setOwner(userItemsMap.get(d.getOwnerId())); if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getOwnerId())) m.setOwner(userItemsMap.get(d.getOwnerId()));
models.add(m); models.add(m);
} }

View File

@ -1,6 +1,7 @@
package eu.eudat.model.builder; package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.DmpReferenceEntity; import eu.eudat.data.DmpReferenceEntity;
import eu.eudat.data.SupportiveMaterialEntity; import eu.eudat.data.SupportiveMaterialEntity;
@ -27,17 +28,14 @@ import java.util.stream.Collectors;
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class SupportiveMaterialBuilder extends BaseBuilder<SupportiveMaterial, SupportiveMaterialEntity>{ public class SupportiveMaterialBuilder extends BaseBuilder<SupportiveMaterial, SupportiveMaterialEntity>{
private final BuilderFactory builderFactory; private final TenantScope tenantScope;
private final QueryFactory queryFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired @Autowired
public SupportiveMaterialBuilder( public SupportiveMaterialBuilder(
ConventionService conventionService, ConventionService conventionService, TenantScope tenantScope) {
BuilderFactory builderFactory, QueryFactory queryFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(SupportiveMaterialBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(SupportiveMaterialBuilder.class)));
this.builderFactory = builderFactory; this.tenantScope = tenantScope;
this.queryFactory = queryFactory;
} }
public SupportiveMaterialBuilder authorize(EnumSet<AuthorizationFlags> values) { public SupportiveMaterialBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -63,6 +61,7 @@ public class SupportiveMaterialBuilder extends BaseBuilder<SupportiveMaterial, S
if (fields.hasField(this.asIndexer(SupportiveMaterial._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); if (fields.hasField(this.asIndexer(SupportiveMaterial._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(SupportiveMaterial._isActive))) m.setIsActive(d.getIsActive()); if (fields.hasField(this.asIndexer(SupportiveMaterial._isActive))) m.setIsActive(d.getIsActive());
if (fields.hasField(this.asIndexer(SupportiveMaterial._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); if (fields.hasField(this.asIndexer(SupportiveMaterial._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
if (fields.hasField(this.asIndexer(SupportiveMaterial._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope));
models.add(m); models.add(m);
} }
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));

View File

@ -1,6 +1,7 @@
package eu.eudat.model.builder; package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.TagEntity; import eu.eudat.data.TagEntity;
import eu.eudat.model.Tag; import eu.eudat.model.Tag;
@ -27,16 +28,17 @@ import java.util.stream.Collectors;
public class TagBuilder extends BaseBuilder<Tag, TagEntity>{ public class TagBuilder extends BaseBuilder<Tag, TagEntity>{
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private final TenantScope tenantScope;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired @Autowired
public TagBuilder( public TagBuilder(
ConventionService conventionService, QueryFactory queryFactory, BuilderFactory builderFactory) { ConventionService conventionService, QueryFactory queryFactory, BuilderFactory builderFactory, TenantScope tenantScope) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(TagBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(TagBuilder.class)));
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.tenantScope = tenantScope;
} }
public TagBuilder authorize(EnumSet<AuthorizationFlags> values) { public TagBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -63,6 +65,7 @@ public class TagBuilder extends BaseBuilder<Tag, TagEntity>{
if (fields.hasField(this.asIndexer(Tag._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); if (fields.hasField(this.asIndexer(Tag._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(Tag._isActive))) m.setIsActive(d.getIsActive()); if (fields.hasField(this.asIndexer(Tag._isActive))) m.setIsActive(d.getIsActive());
if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getCreatedById())) m.setCreatedBy(userItemsMap.get(d.getCreatedById())); if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getCreatedById())) m.setCreatedBy(userItemsMap.get(d.getCreatedById()));
if (fields.hasField(this.asIndexer(Tag._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope));
models.add(m); models.add(m);
} }
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));

View File

@ -1,6 +1,7 @@
package eu.eudat.model.builder; package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.TenantUserEntity; import eu.eudat.data.TenantUserEntity;
import eu.eudat.model.Tenant; import eu.eudat.model.Tenant;
@ -30,6 +31,7 @@ public class TenantUserBuilder extends BaseBuilder<TenantUser, TenantUserEntity>
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
private final TenantScope tenantScope;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@ -37,11 +39,12 @@ public class TenantUserBuilder extends BaseBuilder<TenantUser, TenantUserEntity>
public TenantUserBuilder( public TenantUserBuilder(
ConventionService conventionService, ConventionService conventionService,
BuilderFactory builderFactory, BuilderFactory builderFactory,
QueryFactory queryFactory QueryFactory queryFactory, TenantScope tenantScope
) { ) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(TenantUserBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(TenantUserBuilder.class)));
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
this.tenantScope = tenantScope;
} }
public TenantUserBuilder authorize(EnumSet<AuthorizationFlags> values) { public TenantUserBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -70,6 +73,7 @@ public class TenantUserBuilder extends BaseBuilder<TenantUser, TenantUserEntity>
if (fields.hasField(this.asIndexer(TenantUser._createdAt))) m.setCreatedAt(d.getCreatedAt()); if (fields.hasField(this.asIndexer(TenantUser._createdAt))) m.setCreatedAt(d.getCreatedAt());
if (fields.hasField(this.asIndexer(TenantUser._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); if (fields.hasField(this.asIndexer(TenantUser._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(TenantUser._isActive))) m.setIsActive(d.getIsActive()); if (fields.hasField(this.asIndexer(TenantUser._isActive))) m.setIsActive(d.getIsActive());
if (fields.hasField(this.asIndexer(TenantUser._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope));
if (!userFields.isEmpty() && userMap != null && userMap.containsKey(d.getUserId())) m.setUser(userMap.get(d.getUserId())); if (!userFields.isEmpty() && userMap != null && userMap.containsKey(d.getUserId())) m.setUser(userMap.get(d.getUserId()));
if (!tenantFields.isEmpty() && tenantMap != null && tenantMap.containsKey(d.getTenantId())) m.setTenant(tenantMap.get(d.getTenantId())); if (!tenantFields.isEmpty() && tenantMap != null && tenantMap.containsKey(d.getTenantId())) m.setTenant(tenantMap.get(d.getTenantId()));
models.add(m); models.add(m);

View File

@ -2,6 +2,7 @@ package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.XmlHandlingService; import eu.eudat.commons.XmlHandlingService;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.UserDescriptionTemplateEntity; import eu.eudat.data.UserDescriptionTemplateEntity;
import eu.eudat.model.Description; import eu.eudat.model.Description;
@ -33,15 +34,15 @@ public class UserDescriptionTemplateBuilder extends BaseBuilder<UserDescriptionT
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private final XmlHandlingService xmlHandlingService; private final TenantScope tenantScope;
@Autowired @Autowired
public UserDescriptionTemplateBuilder( public UserDescriptionTemplateBuilder(
ConventionService conventionService, QueryFactory queryFactory, BuilderFactory builderFactory, XmlHandlingService xmlHandlingService) { ConventionService conventionService, QueryFactory queryFactory, BuilderFactory builderFactory, TenantScope tenantScope) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(UserDescriptionTemplateBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(UserDescriptionTemplateBuilder.class)));
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.xmlHandlingService = xmlHandlingService; this.tenantScope = tenantScope;
} }
public UserDescriptionTemplateBuilder authorize(EnumSet<AuthorizationFlags> values) { public UserDescriptionTemplateBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -71,6 +72,7 @@ public class UserDescriptionTemplateBuilder extends BaseBuilder<UserDescriptionT
if (fields.hasField(this.asIndexer(UserDescriptionTemplate._isActive))) m.setIsActive(d.getIsActive()); if (fields.hasField(this.asIndexer(UserDescriptionTemplate._isActive))) m.setIsActive(d.getIsActive());
if (fields.hasField(this.asIndexer(UserDescriptionTemplate._role))) m.setRole(d.getRole()); if (fields.hasField(this.asIndexer(UserDescriptionTemplate._role))) m.setRole(d.getRole());
if (fields.hasField(this.asIndexer(UserDescriptionTemplate._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); if (fields.hasField(this.asIndexer(UserDescriptionTemplate._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
if (fields.hasField(this.asIndexer(UserDescriptionTemplate._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope));
if (!descriptionTemplateFields.isEmpty() && descriptionTemplateMap != null && descriptionTemplateMap.containsKey(d.getDescriptionTemplateId())) m.setDescriptionTemplate(descriptionTemplateMap.get(d.getDescriptionTemplateId())); if (!descriptionTemplateFields.isEmpty() && descriptionTemplateMap != null && descriptionTemplateMap.containsKey(d.getDescriptionTemplateId())) m.setDescriptionTemplate(descriptionTemplateMap.get(d.getDescriptionTemplateId()));
if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId())); if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId()));
models.add(m); models.add(m);

View File

@ -1,6 +1,7 @@
package eu.eudat.model.builder; package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.UserRoleEntity; import eu.eudat.data.UserRoleEntity;
import eu.eudat.model.User; import eu.eudat.model.User;
@ -29,16 +30,18 @@ public class UserRoleBuilder extends BaseBuilder<UserRole, UserRoleEntity> {
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
private final TenantScope tenantScope;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired @Autowired
public UserRoleBuilder( public UserRoleBuilder(
ConventionService conventionService, ConventionService conventionService,
BuilderFactory builderFactory, QueryFactory queryFactory) { BuilderFactory builderFactory, QueryFactory queryFactory, TenantScope tenantScope) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(UserRoleBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(UserRoleBuilder.class)));
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
this.tenantScope = tenantScope;
} }
public UserRoleBuilder authorize(EnumSet<AuthorizationFlags> values) { public UserRoleBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -63,6 +66,7 @@ public class UserRoleBuilder extends BaseBuilder<UserRole, UserRoleEntity> {
if (fields.hasField(this.asIndexer(UserRole._id))) m.setId(d.getId()); if (fields.hasField(this.asIndexer(UserRole._id))) m.setId(d.getId());
if (fields.hasField(this.asIndexer(UserRole._createdAt))) m.setCreatedAt(d.getCreatedAt()); if (fields.hasField(this.asIndexer(UserRole._createdAt))) m.setCreatedAt(d.getCreatedAt());
if (fields.hasField(this.asIndexer(UserRole._role))) m.setRole(d.getRole()); if (fields.hasField(this.asIndexer(UserRole._role))) m.setRole(d.getRole());
if (fields.hasField(this.asIndexer(UserRole._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope));
if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId())); if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId()));
models.add(m); models.add(m);

View File

@ -1,6 +1,7 @@
package eu.eudat.model.builder; package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.scope.tenant.TenantScope;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.UserSettingsEntity; import eu.eudat.data.UserSettingsEntity;
import eu.eudat.model.UserSettings; import eu.eudat.model.UserSettings;
@ -22,15 +23,13 @@ import java.util.*;
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class UserSettingsBuilder extends BaseBuilder<UserSettings, UserSettingsEntity> { public class UserSettingsBuilder extends BaseBuilder<UserSettings, UserSettingsEntity> {
private final BuilderFactory builderFactory; private final TenantScope tenantScope;
private final QueryFactory queryFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
public UserSettingsBuilder(ConventionService conventionService, BuilderFactory builderFactory, QueryFactory queryFactory) { public UserSettingsBuilder(ConventionService conventionService, TenantScope tenantScope) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(UserSettingsBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(UserSettingsBuilder.class)));
this.builderFactory = builderFactory; this.tenantScope = tenantScope;
this.queryFactory = queryFactory;
} }
public UserSettingsBuilder authorize(EnumSet<AuthorizationFlags> values) { public UserSettingsBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -55,6 +54,7 @@ public class UserSettingsBuilder extends BaseBuilder<UserSettings, UserSettingsE
if (fields.hasField(this.asIndexer(UserSettings._entityId))) m.setEntityId(d.getEntityId()); if (fields.hasField(this.asIndexer(UserSettings._entityId))) m.setEntityId(d.getEntityId());
if (fields.hasField(this.asIndexer(UserSettings._createdAt))) m.setCreatedAt(d.getCreatedAt()); if (fields.hasField(this.asIndexer(UserSettings._createdAt))) m.setCreatedAt(d.getCreatedAt());
if (fields.hasField(this.asIndexer(UserSettings._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); if (fields.hasField(this.asIndexer(UserSettings._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(UserSettings._belongsToCurrentTenant))) m.setBelongsToCurrentTenant(this.getBelongsToCurrentTenant(d, this.tenantScope));
if (fields.hasField(this.asIndexer(UserSettings._hash))) m.setHash(this.hashValue(Instant.ofEpochMilli(d.getUpdatedAt().toEpochMilli()))); if (fields.hasField(this.asIndexer(UserSettings._hash))) m.setHash(this.hashValue(Instant.ofEpochMilli(d.getUpdatedAt().toEpochMilli())));
models.add(m); models.add(m);
} }

View File

@ -22,14 +22,12 @@ import java.util.*;
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class DmpInvitationBuilder extends BaseBuilder<DmpInvitation, DmpInvitationEntity> { public class DmpInvitationBuilder extends BaseBuilder<DmpInvitation, DmpInvitationEntity> {
private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired @Autowired
public DmpInvitationBuilder( public DmpInvitationBuilder(
ConventionService conventionService, BuilderFactory builderFactory) { ConventionService conventionService) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpInvitationBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpInvitationBuilder.class)));
this.builderFactory = builderFactory;
} }
public DmpInvitationBuilder authorize(EnumSet<AuthorizationFlags> values) { public DmpInvitationBuilder authorize(EnumSet<AuthorizationFlags> values) {

View File

@ -43,8 +43,6 @@ public class LockCensor extends BaseCensor {
logger.debug(new DataLogEntry("censoring fields", fields)); logger.debug(new DataLogEntry("censoring fields", fields));
if (this.isEmpty(fields)) return; if (this.isEmpty(fields)) return;
this.authService.authorizeAtLeastOneForce(userId != null ? List.of(new OwnedResource(userId)) : null, Permission.BrowseLock); this.authService.authorizeAtLeastOneForce(userId != null ? List.of(new OwnedResource(userId)) : null, Permission.BrowseLock);
FieldSet tenantFields = fields.extractPrefixed(this.asIndexerPrefix(Lock._tenant));
this.censorFactory.censor(TenantCensor.class).censor(tenantFields, null);
FieldSet userFields = fields.extractPrefixed(this.asIndexerPrefix(Lock._lockedBy)); FieldSet userFields = fields.extractPrefixed(this.asIndexerPrefix(Lock._lockedBy));
this.censorFactory.censor(UserCensor.class).censor(userFields, userId); this.censorFactory.censor(UserCensor.class).censor(userFields, userId);
} }

View File

@ -244,11 +244,11 @@ public class ActionConfirmationQuery extends QueryBase<ActionConfirmationEntity>
else if (item.prefix(ActionConfirmation._dmpInvitation)) return ActionConfirmationEntity._data; else if (item.prefix(ActionConfirmation._dmpInvitation)) return ActionConfirmationEntity._data;
else if (item.prefix(ActionConfirmation._createdBy)) return ActionConfirmationEntity._createdById; else if (item.prefix(ActionConfirmation._createdBy)) return ActionConfirmationEntity._createdById;
else if (item.match(ActionConfirmation._createdBy)) return ActionConfirmationEntity._createdById; else if (item.match(ActionConfirmation._createdBy)) return ActionConfirmationEntity._createdById;
else if (item.prefix(ActionConfirmation._tenant)) return ActionConfirmationEntity._tenantId;
else if (item.match(ActionConfirmation._createdAt)) return ActionConfirmationEntity._createdAt; else if (item.match(ActionConfirmation._createdAt)) return ActionConfirmationEntity._createdAt;
else if (item.match(ActionConfirmation._updatedAt)) return ActionConfirmationEntity._updatedAt; else if (item.match(ActionConfirmation._updatedAt)) return ActionConfirmationEntity._updatedAt;
else if (item.match(ActionConfirmation._hash)) return ActionConfirmationEntity._updatedAt; else if (item.match(ActionConfirmation._hash)) return ActionConfirmationEntity._updatedAt;
else if (item.match(ActionConfirmation._isActive)) return ActionConfirmationEntity._isActive; else if (item.match(ActionConfirmation._isActive)) return ActionConfirmationEntity._isActive;
else if (item.match(ActionConfirmation._belongsToCurrentTenant)) return ActionConfirmationEntity._tenantId;
else return null; else return null;
} }
@ -256,6 +256,7 @@ public class ActionConfirmationQuery extends QueryBase<ActionConfirmationEntity>
protected ActionConfirmationEntity convert(Tuple tuple, Set<String> columns) { protected ActionConfirmationEntity convert(Tuple tuple, Set<String> columns) {
ActionConfirmationEntity item = new ActionConfirmationEntity(); ActionConfirmationEntity item = new ActionConfirmationEntity();
item.setId(QueryBase.convertSafe(tuple, columns, ActionConfirmationEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, ActionConfirmationEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, ActionConfirmationEntity._tenantId, UUID.class));
item.setType(QueryBase.convertSafe(tuple, columns, ActionConfirmationEntity._type, ActionConfirmationType.class)); item.setType(QueryBase.convertSafe(tuple, columns, ActionConfirmationEntity._type, ActionConfirmationType.class));
item.setStatus(QueryBase.convertSafe(tuple, columns, ActionConfirmationEntity._status, ActionConfirmationStatus.class)); item.setStatus(QueryBase.convertSafe(tuple, columns, ActionConfirmationEntity._status, ActionConfirmationStatus.class));
item.setToken(QueryBase.convertSafe(tuple, columns, ActionConfirmationEntity._token, String.class)); item.setToken(QueryBase.convertSafe(tuple, columns, ActionConfirmationEntity._token, String.class));

View File

@ -315,6 +315,7 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
else if (item.match(Description._descriptionTemplate) || item.match(PublicDescription._descriptionTemplate)) return DescriptionEntity._descriptionTemplateId; else if (item.match(Description._descriptionTemplate) || item.match(PublicDescription._descriptionTemplate)) return DescriptionEntity._descriptionTemplateId;
else if (item.prefix(Description._dmp)) return DescriptionEntity._dmpId; else if (item.prefix(Description._dmp)) return DescriptionEntity._dmpId;
else if (item.match(Description._dmp)) return DescriptionEntity._dmpId; else if (item.match(Description._dmp)) return DescriptionEntity._dmpId;
else if (item.match(Description._belongsToCurrentTenant)) return DescriptionEntity._tenantId;
else return null; else return null;
} }
@ -322,6 +323,7 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
protected DescriptionEntity convert(Tuple tuple, Set<String> columns) { protected DescriptionEntity convert(Tuple tuple, Set<String> columns) {
DescriptionEntity item = new DescriptionEntity(); DescriptionEntity item = new DescriptionEntity();
item.setId(QueryBase.convertSafe(tuple, columns, DescriptionEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, DescriptionEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, DescriptionEntity._tenantId, UUID.class));
item.setLabel(QueryBase.convertSafe(tuple, columns, DescriptionEntity._label, String.class)); item.setLabel(QueryBase.convertSafe(tuple, columns, DescriptionEntity._label, String.class));
item.setProperties(QueryBase.convertSafe(tuple, columns, DescriptionEntity._properties, String.class)); item.setProperties(QueryBase.convertSafe(tuple, columns, DescriptionEntity._properties, String.class));
item.setStatus(QueryBase.convertSafe(tuple, columns, DescriptionEntity._status, DescriptionStatus.class)); item.setStatus(QueryBase.convertSafe(tuple, columns, DescriptionEntity._status, DescriptionStatus.class));

View File

@ -221,6 +221,7 @@ public class DescriptionReferenceQuery extends QueryBase<DescriptionReferenceEnt
else if (item.prefix(DescriptionReference._data)) return DescriptionReferenceEntity._data; else if (item.prefix(DescriptionReference._data)) return DescriptionReferenceEntity._data;
else if (item.match(DescriptionReference._hash)) return DescriptionReferenceEntity._updatedAt; else if (item.match(DescriptionReference._hash)) return DescriptionReferenceEntity._updatedAt;
else if (item.match(DescriptionReference._isActive)) return DescriptionReferenceEntity._isActive; else if (item.match(DescriptionReference._isActive)) return DescriptionReferenceEntity._isActive;
else if (item.match(DescriptionReference._belongsToCurrentTenant)) return DescriptionReferenceEntity._tenantId;
else return null; else return null;
} }
@ -228,6 +229,7 @@ public class DescriptionReferenceQuery extends QueryBase<DescriptionReferenceEnt
protected DescriptionReferenceEntity convert(Tuple tuple, Set<String> columns) { protected DescriptionReferenceEntity convert(Tuple tuple, Set<String> columns) {
DescriptionReferenceEntity item = new DescriptionReferenceEntity(); DescriptionReferenceEntity item = new DescriptionReferenceEntity();
item.setId(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._tenantId, UUID.class));
item.setDescriptionId(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._descriptionId, UUID.class)); item.setDescriptionId(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._descriptionId, UUID.class));
item.setReferenceId(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._referenceId, UUID.class)); item.setReferenceId(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._referenceId, UUID.class));
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._createdAt, Instant.class)); item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._createdAt, Instant.class));

View File

@ -189,6 +189,7 @@ public class DescriptionTagQuery extends QueryBase<DescriptionTagEntity> {
protected DescriptionTagEntity convert(Tuple tuple, Set<String> columns) { protected DescriptionTagEntity convert(Tuple tuple, Set<String> columns) {
DescriptionTagEntity item = new DescriptionTagEntity(); DescriptionTagEntity item = new DescriptionTagEntity();
item.setId(QueryBase.convertSafe(tuple, columns, DescriptionTagEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, DescriptionTagEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, DescriptionTagEntity._tenantId, UUID.class));
item.setTagId(QueryBase.convertSafe(tuple, columns, DescriptionTagEntity._tagId, UUID.class)); item.setTagId(QueryBase.convertSafe(tuple, columns, DescriptionTagEntity._tagId, UUID.class));
item.setDescriptionId(QueryBase.convertSafe(tuple, columns, DescriptionTagEntity._descriptionId, UUID.class)); item.setDescriptionId(QueryBase.convertSafe(tuple, columns, DescriptionTagEntity._descriptionId, UUID.class));
item.setIsActive(QueryBase.convertSafe(tuple, columns, DescriptionTagEntity._isActive, IsActive.class)); item.setIsActive(QueryBase.convertSafe(tuple, columns, DescriptionTagEntity._isActive, IsActive.class));
@ -206,6 +207,7 @@ public class DescriptionTagQuery extends QueryBase<DescriptionTagEntity> {
else if (item.match(DescriptionTag._createdAt)) return DescriptionTagEntity._createdAt; else if (item.match(DescriptionTag._createdAt)) return DescriptionTagEntity._createdAt;
else if (item.match(DescriptionTag._updatedAt)) return DescriptionTagEntity._updatedAt; else if (item.match(DescriptionTag._updatedAt)) return DescriptionTagEntity._updatedAt;
else if (item.match(DescriptionTag._hash)) return DescriptionTagEntity._updatedAt; else if (item.match(DescriptionTag._hash)) return DescriptionTagEntity._updatedAt;
else if (item.match(DescriptionTag._belongsToCurrentTenant)) return DescriptionTagEntity._tenantId;
else return null; else return null;
} }

View File

@ -326,6 +326,7 @@ public class DescriptionTemplateQuery extends QueryBase<DescriptionTemplateEntit
protected DescriptionTemplateEntity convert(Tuple tuple, Set<String> columns) { protected DescriptionTemplateEntity convert(Tuple tuple, Set<String> columns) {
DescriptionTemplateEntity item = new DescriptionTemplateEntity(); DescriptionTemplateEntity item = new DescriptionTemplateEntity();
item.setId(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._tenantId, UUID.class));
item.setLabel(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._label, String.class)); item.setLabel(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._label, String.class));
item.setDefinition(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._definition, String.class)); item.setDefinition(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._definition, String.class));
item.setDescription(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._description, String.class)); item.setDescription(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._description, String.class));
@ -375,6 +376,8 @@ public class DescriptionTemplateQuery extends QueryBase<DescriptionTemplateEntit
return DescriptionTemplateEntity._status; return DescriptionTemplateEntity._status;
else if (item.match(DescriptionTemplate._versionStatus)) else if (item.match(DescriptionTemplate._versionStatus))
return DescriptionTemplateEntity._versionStatus; return DescriptionTemplateEntity._versionStatus;
else if (item.match(DescriptionTemplate._belongsToCurrentTenant))
return DescriptionTemplateEntity._tenantId;
else else
return null; return null;
} }

View File

@ -165,6 +165,7 @@ public class DescriptionTemplateTypeQuery extends QueryBase<DescriptionTemplateT
protected DescriptionTemplateTypeEntity convert(Tuple tuple, Set<String> columns) { protected DescriptionTemplateTypeEntity convert(Tuple tuple, Set<String> columns) {
DescriptionTemplateTypeEntity item = new DescriptionTemplateTypeEntity(); DescriptionTemplateTypeEntity item = new DescriptionTemplateTypeEntity();
item.setId(QueryBase.convertSafe(tuple, columns, DescriptionTemplateTypeEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, DescriptionTemplateTypeEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, DescriptionTemplateTypeEntity._tenantId, UUID.class));
item.setName(QueryBase.convertSafe(tuple, columns, DescriptionTemplateTypeEntity._name, String.class)); item.setName(QueryBase.convertSafe(tuple, columns, DescriptionTemplateTypeEntity._name, String.class));
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DescriptionTemplateTypeEntity._createdAt, Instant.class)); item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DescriptionTemplateTypeEntity._createdAt, Instant.class));
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DescriptionTemplateTypeEntity._updatedAt, Instant.class)); item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DescriptionTemplateTypeEntity._updatedAt, Instant.class));
@ -182,6 +183,7 @@ public class DescriptionTemplateTypeQuery extends QueryBase<DescriptionTemplateT
else if (item.match(DescriptionTemplateType._hash)) 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._isActive)) return DescriptionTemplateTypeEntity._isActive;
else if (item.match(DescriptionTemplateType._status)) return DescriptionTemplateTypeEntity._status; else if (item.match(DescriptionTemplateType._status)) return DescriptionTemplateTypeEntity._status;
else if (item.match(DescriptionTemplateType._belongsToCurrentTenant)) return DescriptionTemplateTypeEntity._tenantId;
else return null; else return null;
} }

View File

@ -243,6 +243,7 @@ public class DmpBlueprintQuery extends QueryBase<DmpBlueprintEntity> {
protected DmpBlueprintEntity convert(Tuple tuple, Set<String> columns) { protected DmpBlueprintEntity convert(Tuple tuple, Set<String> columns) {
DmpBlueprintEntity item = new DmpBlueprintEntity(); DmpBlueprintEntity item = new DmpBlueprintEntity();
item.setId(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._tenantId, UUID.class));
item.setLabel(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._label, String.class)); item.setLabel(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._label, String.class));
item.setDefinition(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._definition, String.class)); item.setDefinition(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._definition, String.class));
item.setStatus(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._status, DmpBlueprintStatus.class)); item.setStatus(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._status, DmpBlueprintStatus.class));
@ -281,6 +282,8 @@ public class DmpBlueprintQuery extends QueryBase<DmpBlueprintEntity> {
return DmpBlueprintEntity._isActive; return DmpBlueprintEntity._isActive;
else if (item.match(DmpBlueprint._hash)) else if (item.match(DmpBlueprint._hash))
return DmpBlueprintEntity._updatedAt; return DmpBlueprintEntity._updatedAt;
else if (item.match(DmpBlueprint._belongsToCurrentTenant))
return DmpBlueprintEntity._tenantId;
else else
return null; return null;
} }

View File

@ -234,6 +234,7 @@ public class DmpDescriptionTemplateQuery extends QueryBase<DmpDescriptionTemplat
protected DmpDescriptionTemplateEntity convert(Tuple tuple, Set<String> columns) { protected DmpDescriptionTemplateEntity convert(Tuple tuple, Set<String> columns) {
DmpDescriptionTemplateEntity item = new DmpDescriptionTemplateEntity(); DmpDescriptionTemplateEntity item = new DmpDescriptionTemplateEntity();
item.setId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._tenantId, UUID.class));
item.setDmpId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._dmpId, UUID.class)); item.setDmpId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._dmpId, UUID.class));
item.setDescriptionTemplateGroupId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._descriptionTemplateGroupId, UUID.class)); item.setDescriptionTemplateGroupId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._descriptionTemplateGroupId, UUID.class));
item.setSectionId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._sectionId, UUID.class)); item.setSectionId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._sectionId, UUID.class));
@ -258,6 +259,7 @@ public class DmpDescriptionTemplateQuery extends QueryBase<DmpDescriptionTemplat
else if (item.match(DmpDescriptionTemplate._createdAt)) return DmpDescriptionTemplateEntity._createdAt; else if (item.match(DmpDescriptionTemplate._createdAt)) return DmpDescriptionTemplateEntity._createdAt;
else if (item.match(DmpDescriptionTemplate._updatedAt)) return DmpDescriptionTemplateEntity._updatedAt; else if (item.match(DmpDescriptionTemplate._updatedAt)) return DmpDescriptionTemplateEntity._updatedAt;
else if (item.match(DmpDescriptionTemplate._isActive)) return DmpDescriptionTemplateEntity._isActive; else if (item.match(DmpDescriptionTemplate._isActive)) return DmpDescriptionTemplateEntity._isActive;
else if (item.match(DmpDescriptionTemplate._belongsToCurrentTenant)) return DmpDescriptionTemplateEntity._tenantId;
else return null; else return null;
} }

View File

@ -353,6 +353,7 @@ public class DmpQuery extends QueryBase<DmpEntity> {
else if (item.match(Dmp._language)) return DmpEntity._language; else if (item.match(Dmp._language)) return DmpEntity._language;
else if (item.match(Dmp._publicAfter)) return DmpEntity._publicAfter; else if (item.match(Dmp._publicAfter)) return DmpEntity._publicAfter;
else if (item.match(Dmp._versionStatus)) return DmpEntity._versionStatus; else if (item.match(Dmp._versionStatus)) return DmpEntity._versionStatus;
else if (item.match(Dmp._belongsToCurrentTenant)) return DmpEntity._tenantId;
else return null; else return null;
} }
@ -360,6 +361,7 @@ public class DmpQuery extends QueryBase<DmpEntity> {
protected DmpEntity convert(Tuple tuple, Set<String> columns) { protected DmpEntity convert(Tuple tuple, Set<String> columns) {
DmpEntity item = new DmpEntity(); DmpEntity item = new DmpEntity();
item.setId(QueryBase.convertSafe(tuple, columns, DmpEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, DmpEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, DmpEntity._tenantId, UUID.class));
item.setLabel(QueryBase.convertSafe(tuple, columns, DmpEntity._label, String.class)); item.setLabel(QueryBase.convertSafe(tuple, columns, DmpEntity._label, String.class));
item.setVersion(QueryBase.convertSafe(tuple, columns, DmpEntity._version, Short.class)); item.setVersion(QueryBase.convertSafe(tuple, columns, DmpEntity._version, Short.class));
item.setStatus(QueryBase.convertSafe(tuple, columns, DmpEntity._status, DmpStatus.class)); item.setStatus(QueryBase.convertSafe(tuple, columns, DmpEntity._status, DmpStatus.class));

View File

@ -208,6 +208,7 @@ public class DmpReferenceQuery extends QueryBase<DmpReferenceEntity> {
protected DmpReferenceEntity convert(Tuple tuple, Set<String> columns) { protected DmpReferenceEntity convert(Tuple tuple, Set<String> columns) {
DmpReferenceEntity item = new DmpReferenceEntity(); DmpReferenceEntity item = new DmpReferenceEntity();
item.setId(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._tenantId, UUID.class));
item.setDmpId(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._dmpId, UUID.class)); item.setDmpId(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._dmpId, UUID.class));
item.setReferenceId(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._referenceId, UUID.class)); item.setReferenceId(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._referenceId, UUID.class));
item.setData(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._data, String.class)); item.setData(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._data, String.class));
@ -229,6 +230,7 @@ public class DmpReferenceQuery extends QueryBase<DmpReferenceEntity> {
else if (item.match(DmpReference._createdAt)) return DmpReferenceEntity._createdAt; else if (item.match(DmpReference._createdAt)) return DmpReferenceEntity._createdAt;
else if (item.match(DmpReference._updatedAt)) return DmpReferenceEntity._updatedAt; else if (item.match(DmpReference._updatedAt)) return DmpReferenceEntity._updatedAt;
else if (item.match(DmpReference._hash)) return DmpReferenceEntity._updatedAt; else if (item.match(DmpReference._hash)) return DmpReferenceEntity._updatedAt;
else if (item.match(DmpReference._belongsToCurrentTenant)) return DmpReferenceEntity._tenantId;
else return null; else return null;
} }

View File

@ -277,6 +277,7 @@ public class DmpUserQuery extends QueryBase<DmpUserEntity> {
protected DmpUserEntity convert(Tuple tuple, Set<String> columns) { protected DmpUserEntity convert(Tuple tuple, Set<String> columns) {
DmpUserEntity item = new DmpUserEntity(); DmpUserEntity item = new DmpUserEntity();
item.setId(QueryBase.convertSafe(tuple, columns, DmpUserEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, DmpUserEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, DmpUserEntity._tenantId, UUID.class));
item.setDmpId(QueryBase.convertSafe(tuple, columns, DmpUserEntity._dmpId, UUID.class)); item.setDmpId(QueryBase.convertSafe(tuple, columns, DmpUserEntity._dmpId, UUID.class));
item.setUserId(QueryBase.convertSafe(tuple, columns, DmpUserEntity._userId, UUID.class)); item.setUserId(QueryBase.convertSafe(tuple, columns, DmpUserEntity._userId, UUID.class));
item.setSectionId(QueryBase.convertSafe(tuple, columns, DmpUserEntity._sectionId, UUID.class)); item.setSectionId(QueryBase.convertSafe(tuple, columns, DmpUserEntity._sectionId, UUID.class));
@ -300,6 +301,7 @@ public class DmpUserQuery extends QueryBase<DmpUserEntity> {
else if (item.match(DmpUser._hash)) return DmpUserEntity._updatedAt; else if (item.match(DmpUser._hash)) return DmpUserEntity._updatedAt;
else if (item.match(DmpUser._dmp)) return DmpUserEntity._dmpId; else if (item.match(DmpUser._dmp)) return DmpUserEntity._dmpId;
else if (item.match(DmpUser._user)) return DmpUserEntity._userId; else if (item.match(DmpUser._user)) return DmpUserEntity._userId;
else if (item.match(DmpUser._belongsToCurrentTenant)) return DmpUserEntity._tenantId;
else return null; else return null;
} }

View File

@ -259,6 +259,7 @@ public class EntityDoiQuery extends QueryBase<EntityDoiEntity> {
protected EntityDoiEntity convert(Tuple tuple, Set<String> columns) { protected EntityDoiEntity convert(Tuple tuple, Set<String> columns) {
EntityDoiEntity item = new EntityDoiEntity(); EntityDoiEntity item = new EntityDoiEntity();
item.setId(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._tenantId, UUID.class));
item.setDoi(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._doi, String.class)); item.setDoi(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._doi, String.class));
item.setRepositoryId(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._repositoryId, String.class)); item.setRepositoryId(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._repositoryId, String.class));
item.setEntityId(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._entityId, UUID.class)); item.setEntityId(QueryBase.convertSafe(tuple, columns, EntityDoiEntity._entityId, UUID.class));
@ -288,6 +289,8 @@ public class EntityDoiQuery extends QueryBase<EntityDoiEntity> {
else if (item.match(EntityDoi._hash)) return EntityDoiEntity._updatedAt; else if (item.match(EntityDoi._hash)) return EntityDoiEntity._updatedAt;
else if (item.match(EntityDoi._isActive)) else if (item.match(EntityDoi._isActive))
return EntityDoiEntity._isActive; return EntityDoiEntity._isActive;
else if (item.match(EntityDoi._belongsToCurrentTenant))
return EntityDoiEntity._tenantId;
else else
return null; return null;
} }

View File

@ -159,6 +159,7 @@ public class LanguageQuery extends QueryBase<LanguageEntity> {
protected LanguageEntity convert(Tuple tuple, Set<String> columns) { protected LanguageEntity convert(Tuple tuple, Set<String> columns) {
LanguageEntity item = new LanguageEntity(); LanguageEntity item = new LanguageEntity();
item.setId(QueryBase.convertSafe(tuple, columns, LanguageEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, LanguageEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, LanguageEntity._tenantId, UUID.class));
item.setCode(QueryBase.convertSafe(tuple, columns, LanguageEntity._code, String.class)); item.setCode(QueryBase.convertSafe(tuple, columns, LanguageEntity._code, String.class));
item.setPayload(QueryBase.convertSafe(tuple, columns, LanguageEntity._payload, String.class)); item.setPayload(QueryBase.convertSafe(tuple, columns, LanguageEntity._payload, String.class));
item.setOrdinal(QueryBase.convertSafe(tuple, columns, LanguageEntity._ordinal, Integer.class)); item.setOrdinal(QueryBase.convertSafe(tuple, columns, LanguageEntity._ordinal, Integer.class));
@ -178,6 +179,7 @@ public class LanguageQuery extends QueryBase<LanguageEntity> {
else if (item.match(Language._updatedAt)) return LanguageEntity._updatedAt; else if (item.match(Language._updatedAt)) return LanguageEntity._updatedAt;
else if (item.match(Language._hash)) return LanguageEntity._updatedAt; else if (item.match(Language._hash)) return LanguageEntity._updatedAt;
else if (item.match(Language._isActive)) return LanguageEntity._isActive; else if (item.match(Language._isActive)) return LanguageEntity._isActive;
else if (item.match(Language._belongsToCurrentTenant)) return LanguageEntity._tenantId;
else return null; else return null;
} }

View File

@ -211,6 +211,7 @@ public class LockQuery extends QueryBase<LockEntity> {
protected LockEntity convert(Tuple tuple, Set<String> columns) { protected LockEntity convert(Tuple tuple, Set<String> columns) {
LockEntity item = new LockEntity(); LockEntity item = new LockEntity();
item.setId(QueryBase.convertSafe(tuple, columns, LockEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, LockEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, LockEntity._tenantId, UUID.class));
item.setTarget(QueryBase.convertSafe(tuple, columns, LockEntity._target, UUID.class)); item.setTarget(QueryBase.convertSafe(tuple, columns, LockEntity._target, UUID.class));
item.setTargetType(QueryBase.convertSafe(tuple, columns, LockEntity._targetType, LockTargetType.class)); item.setTargetType(QueryBase.convertSafe(tuple, columns, LockEntity._targetType, LockTargetType.class));
item.setLockedBy(QueryBase.convertSafe(tuple, columns, LockEntity._lockedBy, UUID.class)); item.setLockedBy(QueryBase.convertSafe(tuple, columns, LockEntity._lockedBy, UUID.class));
@ -228,8 +229,8 @@ public class LockQuery extends QueryBase<LockEntity> {
else if (item.prefix(Lock._lockedBy)) return LockEntity._lockedBy; else if (item.prefix(Lock._lockedBy)) return LockEntity._lockedBy;
else if (item.match(Lock._lockedAt)) return LockEntity._lockedAt; else if (item.match(Lock._lockedAt)) return LockEntity._lockedAt;
else if (item.match(Lock._touchedAt)) return LockEntity._touchedAt; else if (item.match(Lock._touchedAt)) return LockEntity._touchedAt;
else if (item.prefix(Lock._tenant)) return LockEntity._tenantId;
else if (item.match(Lock._hash)) return LockEntity._lockedAt; else if (item.match(Lock._hash)) return LockEntity._lockedAt;
else if (item.match(Lock._belongsToCurrentTenant)) return LockEntity._tenantId;
else return null; else return null;
} }

View File

@ -137,6 +137,7 @@ public class PrefillingSourceQuery extends QueryBase<PrefillingSourceEntity> {
protected PrefillingSourceEntity convert(Tuple tuple, Set<String> columns) { protected PrefillingSourceEntity convert(Tuple tuple, Set<String> columns) {
PrefillingSourceEntity item = new PrefillingSourceEntity(); PrefillingSourceEntity item = new PrefillingSourceEntity();
item.setId(QueryBase.convertSafe(tuple, columns, PrefillingSourceEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, PrefillingSourceEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, PrefillingSourceEntity._tenantId, UUID.class));
item.setLabel(QueryBase.convertSafe(tuple, columns, PrefillingSourceEntity._label, String.class)); item.setLabel(QueryBase.convertSafe(tuple, columns, PrefillingSourceEntity._label, String.class));
item.setDefinition(QueryBase.convertSafe(tuple, columns, PrefillingSourceEntity._definition, String.class)); item.setDefinition(QueryBase.convertSafe(tuple, columns, PrefillingSourceEntity._definition, String.class));
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, PrefillingSourceEntity._createdAt, Instant.class)); item.setCreatedAt(QueryBase.convertSafe(tuple, columns, PrefillingSourceEntity._createdAt, Instant.class));
@ -154,6 +155,7 @@ public class PrefillingSourceQuery extends QueryBase<PrefillingSourceEntity> {
else if (item.match(PrefillingSource._updatedAt)) return PrefillingSourceEntity._updatedAt; else if (item.match(PrefillingSource._updatedAt)) return PrefillingSourceEntity._updatedAt;
else if (item.match(PrefillingSource._hash)) return PrefillingSourceEntity._updatedAt; else if (item.match(PrefillingSource._hash)) return PrefillingSourceEntity._updatedAt;
else if (item.match(PrefillingSource._isActive)) return PrefillingSourceEntity._isActive; else if (item.match(PrefillingSource._isActive)) return PrefillingSourceEntity._isActive;
else if (item.match(PrefillingSource._belongsToCurrentTenant)) return PrefillingSourceEntity._tenantId;
else return null; else return null;
} }

View File

@ -293,6 +293,7 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
protected ReferenceEntity convert(Tuple tuple, Set<String> columns) { protected ReferenceEntity convert(Tuple tuple, Set<String> columns) {
ReferenceEntity item = new ReferenceEntity(); ReferenceEntity item = new ReferenceEntity();
item.setId(QueryBase.convertSafe(tuple, columns, ReferenceEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, ReferenceEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, ReferenceEntity._tenantId, UUID.class));
item.setLabel(QueryBase.convertSafe(tuple, columns, ReferenceEntity._label, String.class)); item.setLabel(QueryBase.convertSafe(tuple, columns, ReferenceEntity._label, String.class));
item.setDescription(QueryBase.convertSafe(tuple, columns, ReferenceEntity._description, String.class)); item.setDescription(QueryBase.convertSafe(tuple, columns, ReferenceEntity._description, String.class));
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, ReferenceEntity._createdAt, Instant.class)); item.setCreatedAt(QueryBase.convertSafe(tuple, columns, ReferenceEntity._createdAt, Instant.class));
@ -325,6 +326,7 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
else if (item.match(Reference._type) || item.match(PublicReference._type)) return ReferenceEntity._typeId; else if (item.match(Reference._type) || item.match(PublicReference._type)) return ReferenceEntity._typeId;
else if (item.prefix(Reference._type) || item.prefix(PublicReference._type)) return ReferenceEntity._typeId; else if (item.prefix(Reference._type) || item.prefix(PublicReference._type)) return ReferenceEntity._typeId;
else if (item.prefix(Reference._createdBy)) return ReferenceEntity._createdById; else if (item.prefix(Reference._createdBy)) return ReferenceEntity._createdById;
else if (item.prefix(Reference._belongsToCurrentTenant)) return ReferenceEntity._tenantId;
else return null; else return null;
} }

View File

@ -165,6 +165,7 @@ public class ReferenceTypeQuery extends QueryBase<ReferenceTypeEntity> {
protected ReferenceTypeEntity convert(Tuple tuple, Set<String> columns) { protected ReferenceTypeEntity convert(Tuple tuple, Set<String> columns) {
ReferenceTypeEntity item = new ReferenceTypeEntity(); ReferenceTypeEntity item = new ReferenceTypeEntity();
item.setId(QueryBase.convertSafe(tuple, columns, ReferenceTypeEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, ReferenceTypeEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, ReferenceTypeEntity._tenantId, UUID.class));
item.setName(QueryBase.convertSafe(tuple, columns, ReferenceTypeEntity._name, String.class)); item.setName(QueryBase.convertSafe(tuple, columns, ReferenceTypeEntity._name, String.class));
item.setCode(QueryBase.convertSafe(tuple, columns, ReferenceTypeEntity._code, String.class)); item.setCode(QueryBase.convertSafe(tuple, columns, ReferenceTypeEntity._code, String.class));
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, ReferenceTypeEntity._createdAt, Instant.class)); item.setCreatedAt(QueryBase.convertSafe(tuple, columns, ReferenceTypeEntity._createdAt, Instant.class));
@ -185,6 +186,7 @@ public class ReferenceTypeQuery extends QueryBase<ReferenceTypeEntity> {
else if (item.match(ReferenceType._isActive)) return ReferenceTypeEntity._isActive; else if (item.match(ReferenceType._isActive)) return ReferenceTypeEntity._isActive;
else if (item.match(ReferenceType._definition)) return ReferenceTypeEntity._definition; else if (item.match(ReferenceType._definition)) return ReferenceTypeEntity._definition;
else if (item.prefix(ReferenceType._definition)) return ReferenceTypeEntity._definition; else if (item.prefix(ReferenceType._definition)) return ReferenceTypeEntity._definition;
else if (item.match(ReferenceType._belongsToCurrentTenant)) return ReferenceTypeEntity._tenantId;
else return null; else return null;
} }

View File

@ -207,6 +207,7 @@ public class StorageFileQuery extends QueryBase<StorageFileEntity> {
else if (item.match(StorageFile._purgedAt)) return StorageFileEntity._purgedAt; else if (item.match(StorageFile._purgedAt)) return StorageFileEntity._purgedAt;
else if (item.match(StorageFile._owner)) return StorageFileEntity._ownerId; else if (item.match(StorageFile._owner)) return StorageFileEntity._ownerId;
else if (item.prefix(StorageFile._owner)) return StorageFileEntity._ownerId; else if (item.prefix(StorageFile._owner)) return StorageFileEntity._ownerId;
else if (item.match(StorageFile._belongsToCurrentTenant)) return StorageFileEntity._tenantId;
else return null; else return null;
} }
@ -214,6 +215,7 @@ public class StorageFileQuery extends QueryBase<StorageFileEntity> {
protected StorageFileEntity convert(Tuple tuple, Set<String> columns) { protected StorageFileEntity convert(Tuple tuple, Set<String> columns) {
StorageFileEntity item = new StorageFileEntity(); StorageFileEntity item = new StorageFileEntity();
item.setId(QueryBase.convertSafe(tuple, columns, StorageFileEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, StorageFileEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, StorageFileEntity._tenantId, UUID.class));
item.setName(QueryBase.convertSafe(tuple, columns, StorageFileEntity._name, String.class)); item.setName(QueryBase.convertSafe(tuple, columns, StorageFileEntity._name, String.class));
item.setFileRef(QueryBase.convertSafe(tuple, columns, StorageFileEntity._fileRef, String.class)); item.setFileRef(QueryBase.convertSafe(tuple, columns, StorageFileEntity._fileRef, String.class));
item.setExtension(QueryBase.convertSafe(tuple, columns, StorageFileEntity._extension, String.class)); item.setExtension(QueryBase.convertSafe(tuple, columns, StorageFileEntity._extension, String.class));

View File

@ -188,6 +188,7 @@ public class SupportiveMaterialQuery extends QueryBase<SupportiveMaterialEntity>
protected SupportiveMaterialEntity convert(Tuple tuple, Set<String> columns) { protected SupportiveMaterialEntity convert(Tuple tuple, Set<String> columns) {
SupportiveMaterialEntity item = new SupportiveMaterialEntity(); SupportiveMaterialEntity item = new SupportiveMaterialEntity();
item.setId(QueryBase.convertSafe(tuple, columns, SupportiveMaterialEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, SupportiveMaterialEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, SupportiveMaterialEntity._tenantId, UUID.class));
item.setType(QueryBase.convertSafe(tuple, columns, SupportiveMaterialEntity._type, SupportiveMaterialFieldType.class)); item.setType(QueryBase.convertSafe(tuple, columns, SupportiveMaterialEntity._type, SupportiveMaterialFieldType.class));
item.setLanguageCode(QueryBase.convertSafe(tuple, columns, SupportiveMaterialEntity._languageCode, String.class)); item.setLanguageCode(QueryBase.convertSafe(tuple, columns, SupportiveMaterialEntity._languageCode, String.class));
item.setPayload(QueryBase.convertSafe(tuple, columns, SupportiveMaterialEntity._payload, String.class)); item.setPayload(QueryBase.convertSafe(tuple, columns, SupportiveMaterialEntity._payload, String.class));
@ -207,6 +208,7 @@ public class SupportiveMaterialQuery extends QueryBase<SupportiveMaterialEntity>
else if (item.match(SupportiveMaterial._updatedAt)) return SupportiveMaterialEntity._updatedAt; else if (item.match(SupportiveMaterial._updatedAt)) return SupportiveMaterialEntity._updatedAt;
else if (item.match(SupportiveMaterial._hash)) return SupportiveMaterialEntity._updatedAt; else if (item.match(SupportiveMaterial._hash)) return SupportiveMaterialEntity._updatedAt;
else if (item.match(SupportiveMaterial._isActive)) return SupportiveMaterialEntity._isActive; else if (item.match(SupportiveMaterial._isActive)) return SupportiveMaterialEntity._isActive;
else if (item.match(SupportiveMaterial._belongsToCurrentTenant)) return SupportiveMaterialEntity._tenantId;
else return null; else return null;
} }

View File

@ -260,6 +260,7 @@ public class TagQuery extends QueryBase<TagEntity> {
else if (item.match(Tag._updatedAt)) return TagEntity._updatedAt; else if (item.match(Tag._updatedAt)) return TagEntity._updatedAt;
else if (item.match(Tag._hash)) return TagEntity._updatedAt; else if (item.match(Tag._hash)) return TagEntity._updatedAt;
else if (item.match(Tag._isActive)) return TagEntity._isActive; else if (item.match(Tag._isActive)) return TagEntity._isActive;
else if (item.match(Tag._belongsToCurrentTenant)) return TagEntity._tenantId;
else return null; else return null;
} }
@ -267,6 +268,7 @@ public class TagQuery extends QueryBase<TagEntity> {
protected TagEntity convert(Tuple tuple, Set<String> columns) { protected TagEntity convert(Tuple tuple, Set<String> columns) {
TagEntity item = new TagEntity(); TagEntity item = new TagEntity();
item.setId(QueryBase.convertSafe(tuple, columns, TagEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, TagEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, TagEntity._tenantId, UUID.class));
item.setLabel(QueryBase.convertSafe(tuple, columns, TagEntity._label, String.class)); item.setLabel(QueryBase.convertSafe(tuple, columns, TagEntity._label, String.class));
item.setCreatedById(QueryBase.convertSafe(tuple, columns, TagEntity._createdById, UUID.class)); item.setCreatedById(QueryBase.convertSafe(tuple, columns, TagEntity._createdById, UUID.class));
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, TagEntity._createdAt, Instant.class)); item.setCreatedAt(QueryBase.convertSafe(tuple, columns, TagEntity._createdAt, Instant.class));

View File

@ -135,7 +135,7 @@ public class TenantUserQuery extends QueryBase<TenantUserEntity> {
if (ownerId != null) { if (ownerId != null) {
predicates.add(queryContext.CriteriaBuilder.equal(queryContext.Root.get(TenantUserEntity._userId), ownerId)); predicates.add(queryContext.CriteriaBuilder.equal(queryContext.Root.get(TenantUserEntity._userId), ownerId));
} }
if (predicates.size() > 0) { if (!predicates.isEmpty()) {
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
return queryContext.CriteriaBuilder.and(predicatesArray); return queryContext.CriteriaBuilder.and(predicatesArray);
} else { } else {
@ -182,6 +182,7 @@ public class TenantUserQuery extends QueryBase<TenantUserEntity> {
protected TenantUserEntity convert(Tuple tuple, Set<String> columns) { protected TenantUserEntity convert(Tuple tuple, Set<String> columns) {
TenantUserEntity item = new TenantUserEntity(); TenantUserEntity item = new TenantUserEntity();
item.setId(QueryBase.convertSafe(tuple, columns, TenantUserEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, TenantUserEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, TenantUserEntity._tenantId, UUID.class));
item.setUserId(QueryBase.convertSafe(tuple, columns, TenantUserEntity._userId, UUID.class)); item.setUserId(QueryBase.convertSafe(tuple, columns, TenantUserEntity._userId, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, TenantUserEntity._tenantId, UUID.class)); item.setTenantId(QueryBase.convertSafe(tuple, columns, TenantUserEntity._tenantId, UUID.class));
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, TenantUserEntity._createdAt, Instant.class)); item.setCreatedAt(QueryBase.convertSafe(tuple, columns, TenantUserEntity._createdAt, Instant.class));
@ -201,6 +202,7 @@ public class TenantUserQuery extends QueryBase<TenantUserEntity> {
else if (item.match(TenantUser._hash)) return TenantUserEntity._updatedAt; else if (item.match(TenantUser._hash)) return TenantUserEntity._updatedAt;
else if (item.match(TenantUser._user, UserEntity._id)) return TenantUserEntity._userId; else if (item.match(TenantUser._user, UserEntity._id)) return TenantUserEntity._userId;
else if (item.prefix(TenantUser._user)) return TenantUserEntity._userId; else if (item.prefix(TenantUser._user)) return TenantUserEntity._userId;
else if (item.match(TenantUser._belongsToCurrentTenant)) return TenantUserEntity._tenantId;
else return null; else return null;
} }
} }

View File

@ -192,6 +192,7 @@ public class UserDescriptionTemplateQuery extends QueryBase<UserDescriptionTempl
protected UserDescriptionTemplateEntity convert(Tuple tuple, Set<String> columns) { protected UserDescriptionTemplateEntity convert(Tuple tuple, Set<String> columns) {
UserDescriptionTemplateEntity item = new UserDescriptionTemplateEntity(); UserDescriptionTemplateEntity item = new UserDescriptionTemplateEntity();
item.setId(QueryBase.convertSafe(tuple, columns, UserDescriptionTemplateEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, UserDescriptionTemplateEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, UserDescriptionTemplateEntity._tenantId, UUID.class));
item.setUserId(QueryBase.convertSafe(tuple, columns, UserDescriptionTemplateEntity._userId, UUID.class)); item.setUserId(QueryBase.convertSafe(tuple, columns, UserDescriptionTemplateEntity._userId, UUID.class));
item.setDescriptionTemplateId(QueryBase.convertSafe(tuple, columns, UserDescriptionTemplateEntity._descriptionTemplateId, UUID.class)); item.setDescriptionTemplateId(QueryBase.convertSafe(tuple, columns, UserDescriptionTemplateEntity._descriptionTemplateId, UUID.class));
item.setRole(QueryBase.convertSafe(tuple, columns, UserDescriptionTemplateEntity._role, UserDescriptionTemplateRole.class)); item.setRole(QueryBase.convertSafe(tuple, columns, UserDescriptionTemplateEntity._role, UserDescriptionTemplateRole.class));
@ -213,6 +214,7 @@ public class UserDescriptionTemplateQuery extends QueryBase<UserDescriptionTempl
else if (item.match(UserDescriptionTemplate._updatedAt)) return UserDescriptionTemplateEntity._updatedAt; else if (item.match(UserDescriptionTemplate._updatedAt)) return UserDescriptionTemplateEntity._updatedAt;
else if (item.match(UserDescriptionTemplate._hash)) return UserDescriptionTemplateEntity._updatedAt; else if (item.match(UserDescriptionTemplate._hash)) return UserDescriptionTemplateEntity._updatedAt;
else if (item.match(UserDescriptionTemplate._isActive)) return UserDescriptionTemplateEntity._isActive; else if (item.match(UserDescriptionTemplate._isActive)) return UserDescriptionTemplateEntity._isActive;
else if (item.match(UserDescriptionTemplate._belongsToCurrentTenant)) return UserDescriptionTemplateEntity._tenantId;
else return null; else return null;
} }

View File

@ -177,6 +177,7 @@ public class UserRoleQuery extends QueryBase<UserRoleEntity> {
else if (item.prefix(UserRole._user)) return UserRoleEntity._userId; else if (item.prefix(UserRole._user)) return UserRoleEntity._userId;
else if (item.match(UserRole._user)) return UserRoleEntity._userId; else if (item.match(UserRole._user)) return UserRoleEntity._userId;
else if (item.match(UserRole._createdAt) ) return UserRoleEntity._createdAt; else if (item.match(UserRole._createdAt) ) return UserRoleEntity._createdAt;
else if (item.match(UserRole._belongsToCurrentTenant) ) return UserRoleEntity._tenantId;
else return null; else return null;
} }
@ -184,6 +185,7 @@ public class UserRoleQuery extends QueryBase<UserRoleEntity> {
protected UserRoleEntity convert(Tuple tuple, Set<String> columns) { protected UserRoleEntity convert(Tuple tuple, Set<String> columns) {
UserRoleEntity item = new UserRoleEntity(); UserRoleEntity item = new UserRoleEntity();
item.setId(QueryBase.convertSafe(tuple, columns, UserRoleEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, UserRoleEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, UserRoleEntity._tenantId, UUID.class));
item.setRole(QueryBase.convertSafe(tuple, columns, UserRoleEntity._role, String.class)); item.setRole(QueryBase.convertSafe(tuple, columns, UserRoleEntity._role, String.class));
item.setUserId(QueryBase.convertSafe(tuple, columns, UserRoleEntity._userId, UUID.class)); item.setUserId(QueryBase.convertSafe(tuple, columns, UserRoleEntity._userId, UUID.class));
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, UserRoleEntity._createdAt, Instant.class)); item.setCreatedAt(QueryBase.convertSafe(tuple, columns, UserRoleEntity._createdAt, Instant.class));

View File

@ -151,7 +151,7 @@ public class UserSettingsQuery extends QueryBase<UserSettingsEntity> {
if (ownerId != null) { if (ownerId != null) {
predicates.add(queryContext.CriteriaBuilder.equal(queryContext.Root.get(UserSettingsEntity._entityId), ownerId)); predicates.add(queryContext.CriteriaBuilder.equal(queryContext.Root.get(UserSettingsEntity._entityId), ownerId));
} }
if (predicates.size() > 0) { if (!predicates.isEmpty()) {
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
return queryContext.CriteriaBuilder.and(predicatesArray); return queryContext.CriteriaBuilder.and(predicatesArray);
} else { } else {
@ -198,7 +198,7 @@ public class UserSettingsQuery extends QueryBase<UserSettingsEntity> {
} }
if (predicates.size() > 0) { if (!predicates.isEmpty()) {
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
return queryContext.CriteriaBuilder.and(predicatesArray); return queryContext.CriteriaBuilder.and(predicatesArray);
} else { } else {
@ -216,6 +216,7 @@ public class UserSettingsQuery extends QueryBase<UserSettingsEntity> {
else if (item.match(UserSettings._createdAt)) return UserSettingsEntity._createdAt; else if (item.match(UserSettings._createdAt)) return UserSettingsEntity._createdAt;
else if (item.match(UserSettings._updatedAt)) return UserSettingsEntity._updatedAt; else if (item.match(UserSettings._updatedAt)) return UserSettingsEntity._updatedAt;
else if (item.match(UserSettings._hash)) return UserSettingsEntity._updatedAt; else if (item.match(UserSettings._hash)) return UserSettingsEntity._updatedAt;
else if (item.match(UserSettings._belongsToCurrentTenant)) return UserSettingsEntity._tenantId;
else return null; else return null;
} }
@ -223,6 +224,7 @@ public class UserSettingsQuery extends QueryBase<UserSettingsEntity> {
protected UserSettingsEntity convert(Tuple tuple, Set<String> columns) { protected UserSettingsEntity convert(Tuple tuple, Set<String> columns) {
UserSettingsEntity item = new UserSettingsEntity(); UserSettingsEntity item = new UserSettingsEntity();
item.setId(QueryBase.convertSafe(tuple, columns, UserSettingsEntity._id, UUID.class)); item.setId(QueryBase.convertSafe(tuple, columns, UserSettingsEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, UserSettingsEntity._tenantId, UUID.class));
item.setEntityId(QueryBase.convertSafe(tuple, columns, UserSettingsEntity._entityId, UUID.class)); item.setEntityId(QueryBase.convertSafe(tuple, columns, UserSettingsEntity._entityId, UUID.class));
item.setKey(QueryBase.convertSafe(tuple, columns, UserSettingsEntity._key, String.class)); item.setKey(QueryBase.convertSafe(tuple, columns, UserSettingsEntity._key, String.class));
item.setValue(QueryBase.convertSafe(tuple, columns, UserSettingsEntity._value, String.class)); item.setValue(QueryBase.convertSafe(tuple, columns, UserSettingsEntity._value, String.class));

View File

@ -1,4 +1,4 @@
package eu.eudat.repository; package eu.eudat.service.transformer;
import eu.eudat.commonmodels.models.FileEnvelopeModel; import eu.eudat.commonmodels.models.FileEnvelopeModel;
import eu.eudat.commonmodels.models.description.DescriptionModel; import eu.eudat.commonmodels.models.description.DescriptionModel;
@ -6,17 +6,15 @@ import eu.eudat.commonmodels.models.dmp.DmpModel;
import eu.eudat.file.transformer.interfaces.FileTransformerClient; import eu.eudat.file.transformer.interfaces.FileTransformerClient;
import eu.eudat.file.transformer.interfaces.FileTransformerConfiguration; import eu.eudat.file.transformer.interfaces.FileTransformerConfiguration;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
public class TransformerRepository implements FileTransformerClient { public class FileTransformerRepository implements FileTransformerClient {
private final WebClient transformerClient; private final WebClient transformerClient;
public TransformerRepository(WebClient transformerClient) { public FileTransformerRepository(WebClient transformerClient) {
this.transformerClient = transformerClient; this.transformerClient = transformerClient;
} }

View File

@ -15,7 +15,6 @@ import eu.eudat.model.file.RepositoryFileFormat;
import eu.eudat.model.file.TransformerCacheModel; import eu.eudat.model.file.TransformerCacheModel;
import eu.eudat.query.DescriptionQuery; import eu.eudat.query.DescriptionQuery;
import eu.eudat.query.DmpQuery; import eu.eudat.query.DmpQuery;
import eu.eudat.repository.TransformerRepository;
import eu.eudat.service.storage.StorageFileService; import eu.eudat.service.storage.StorageFileService;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeCacheService; import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeCacheService;
@ -42,7 +41,7 @@ public class FileTransformerServiceImpl implements FileTransformerService {
private static final Logger logger = LoggerFactory.getLogger(FileTransformerServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(FileTransformerServiceImpl.class);
private final FileTransformerProperties fileTransformerProperties; private final FileTransformerProperties fileTransformerProperties;
private final Map<String, TransformerRepository> clients; private final Map<String, FileTransformerRepository> clients;
private final TokenExchangeCacheService tokenExchangeCacheService; private final TokenExchangeCacheService tokenExchangeCacheService;
private final FileTransformerConfigurationCache fileTransformerConfigurationCache; private final FileTransformerConfigurationCache fileTransformerConfigurationCache;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
@ -65,7 +64,7 @@ public class FileTransformerServiceImpl implements FileTransformerService {
this.clients = new HashMap<>(); this.clients = new HashMap<>();
} }
private TransformerRepository getRepository(String repoId) { private FileTransformerRepository getRepository(String repoId) {
if (this.clients.containsKey(repoId)) return this.clients.get(repoId); if (this.clients.containsKey(repoId)) return this.clients.get(repoId);
//GK: It's register time //GK: It's register time
@ -75,7 +74,7 @@ public class FileTransformerServiceImpl implements FileTransformerService {
TokenExchangeModel tokenExchangeModel = new TokenExchangeModel(host + "_" + source.getClientId(), source.getIssuerUrl(), source.getClientId(), source.getClientSecret(), source.getScope()); TokenExchangeModel tokenExchangeModel = new TokenExchangeModel(host + "_" + source.getClientId(), source.getIssuerUrl(), source.getClientId(), source.getClientSecret(), source.getScope());
TokenExchangeFilterFunction tokenExchangeFilterFunction = new TokenExchangeFilterFunction(this.tokenExchangeCacheService, tokenExchangeModel); TokenExchangeFilterFunction tokenExchangeFilterFunction = new TokenExchangeFilterFunction(this.tokenExchangeCacheService, tokenExchangeModel);
TransformerRepository repository = new TransformerRepository(WebClient.builder().baseUrl(source.getUrl() + "/api/file-transformer").filters(exchangeFilterFunctions -> { FileTransformerRepository repository = new FileTransformerRepository(WebClient.builder().baseUrl(source.getUrl() + "/api/file-transformer").filters(exchangeFilterFunctions -> {
exchangeFilterFunctions.add(tokenExchangeFilterFunction); exchangeFilterFunctions.add(tokenExchangeFilterFunction);
exchangeFilterFunctions.add(logRequest()); exchangeFilterFunctions.add(logRequest());
}).build()); }).build());
@ -103,7 +102,7 @@ public class FileTransformerServiceImpl implements FileTransformerService {
if (configs == null) { if (configs == null) {
List<FileTransformerConfiguration> configurations = new ArrayList<>(); List<FileTransformerConfiguration> configurations = new ArrayList<>();
//GK: So much for lazy loading //GK: So much for lazy loading
List<TransformerRepository> repositories = fileTransformerProperties.getSources().stream().map(depositSource -> getRepository(depositSource.getTransformerId())).toList(); List<FileTransformerRepository> repositories = fileTransformerProperties.getSources().stream().map(depositSource -> getRepository(depositSource.getTransformerId())).toList();
repositories = new ArrayList<>(repositories); repositories = new ArrayList<>(repositories);
repositories.forEach((client) -> { repositories.forEach((client) -> {
@ -128,8 +127,8 @@ public class FileTransformerServiceImpl implements FileTransformerService {
public eu.eudat.model.file.FileEnvelope exportDmp(UUID dmpId, String repositoryId, String format) { public eu.eudat.model.file.FileEnvelope exportDmp(UUID dmpId, String repositoryId, String format) {
this.authorizationService.authorize(Permission.EditDmp); this.authorizationService.authorize(Permission.EditDmp);
//GK: First get the right client //GK: First get the right client
TransformerRepository repository = getRepository(repositoryId); FileTransformerRepository repository = getRepository(repositoryId);
if (repository == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{format, TransformerRepository.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (repository == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{format, FileTransformerRepository.class.getSimpleName()}, LocaleContextHolder.getLocale()));
//GK: Second get the Target Data Management Plan //GK: Second get the Target Data Management Plan
DmpQuery query = this.queryFactory.query(DmpQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(dmpId); DmpQuery query = this.queryFactory.query(DmpQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(dmpId);
DmpModel dmpFileTransformerModel = this.builderFactory.builder(DmpCommonModelBuilder.class).useSharedStorage(repository.getConfiguration().isUseSharedStorage()).setRepositoryId(repository.getConfiguration().getFileTransformerId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(query.first()); DmpModel dmpFileTransformerModel = this.builderFactory.builder(DmpCommonModelBuilder.class).useSharedStorage(repository.getConfiguration().isUseSharedStorage()).setRepositoryId(repository.getConfiguration().getFileTransformerId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(query.first());
@ -148,8 +147,8 @@ public class FileTransformerServiceImpl implements FileTransformerService {
public eu.eudat.model.file.FileEnvelope exportDescription(UUID descriptionId, String repositoryId, String format) { public eu.eudat.model.file.FileEnvelope exportDescription(UUID descriptionId, String repositoryId, String format) {
this.authorizationService.authorize(Permission.EditDmp); this.authorizationService.authorize(Permission.EditDmp);
//GK: First get the right client //GK: First get the right client
TransformerRepository repository = getRepository(repositoryId); FileTransformerRepository repository = getRepository(repositoryId);
if (repository == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{format, TransformerRepository.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (repository == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{format, FileTransformerRepository.class.getSimpleName()}, LocaleContextHolder.getLocale()));
//GK: Second get the Target Data Management Plan //GK: Second get the Target Data Management Plan
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(descriptionId); DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(descriptionId);

View File

@ -56,3 +56,6 @@ error-thesaurus:
dmp-description-template-can-not-remove: dmp-description-template-can-not-remove:
code: 122 code: 122
message: Can not remove description template that is already in use. message: Can not remove description template that is already in use.
tenant-tampering:
code: 123
message: Tenant tampering