add status and inactive

This commit is contained in:
Efstratios Giannopoulos 2023-10-17 17:48:02 +03:00
parent b3a73a50aa
commit 43f77a4497
18 changed files with 181 additions and 123 deletions

View File

@ -1,43 +1,28 @@
package eu.eudat.commons.enums; package eu.eudat.commons.enums;
public enum DescriptionTemplateTypeStatus { import eu.eudat.data.converters.enums.DatabaseEnum;
SAVED((short) 0), FINALIZED((short) 1), DELETED((short) 99); import java.util.Map;
private final short value; public enum DescriptionTemplateTypeStatus implements DatabaseEnum<Short> {
DescriptionTemplateTypeStatus(short value) { Draft((short) 0),
Finalized((short) 1);
private final Short value;
DescriptionTemplateTypeStatus(Short value) {
this.value = value; this.value = value;
} }
public short getValue() { public Short getValue() {
return value; return value;
} }
public static DescriptionTemplateTypeStatus fromInteger(int value) { private static final Map<Short, DescriptionTemplateTypeStatus> map = EnumUtils.getEnumValueMap(DescriptionTemplateTypeStatus.class);
switch (value) {
case 0:
return SAVED;
case 1:
return FINALIZED;
case 99:
return DELETED;
default:
throw new RuntimeException("Unsupported Description Template Type Status");
}
}
public static DescriptionTemplateTypeStatus fromLabel(String value) { public static DescriptionTemplateTypeStatus of(Short i) {
switch (value) { return map.get(i);
case "SAVED":
return SAVED;
case "FINALISED":
return FINALIZED;
case "DELETED":
return DELETED;
default:
throw new RuntimeException("Unsupported Description Template Type Status");
}
} }
} }

View File

@ -0,0 +1,28 @@
package eu.eudat.commons.enums;
import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum IsActive implements DatabaseEnum<Short> {
Inactive((short)0),
Active( (short)1);
private final Short value;
IsActive(Short value) {
this.value = value;
}
public Short getValue() {
return value;
}
private static final Map<Short, IsActive> map = EnumUtils.getEnumValueMap(IsActive.class);
public static IsActive of(Short i) {
return map.get(i);
}
}

View File

@ -1,29 +0,0 @@
package eu.eudat.commons.enums;
import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.HashMap;
import java.util.Map;
public enum Status implements DatabaseEnum<Integer> {
Inactive(0),
Active( 1);
private final Integer value;
Status(Integer value) {
this.value = value;
}
public Integer getValue() {
return value;
}
private static final Map<Integer, Status> map = EnumUtils.getEnumValueMap(Status.class);
public static Status of(Integer i) {
return map.get(i);
}
}

View File

@ -1,11 +1,11 @@
package eu.eudat.data; package eu.eudat.data;
import eu.eudat.commons.enums.ProviderType; import eu.eudat.commons.enums.ProviderType;
import eu.eudat.commons.enums.Status; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.DateToUTCConverter; import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.converters.enums.ProviderTypeConverter; import eu.eudat.data.converters.enums.ProviderTypeConverter;
import eu.eudat.data.converters.enums.StatusConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
import eu.eudat.data.helpers.EntityBinder; import eu.eudat.data.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import jakarta.persistence.*; import jakarta.persistence.*;
@ -33,9 +33,9 @@ public class CredentialEntity implements DataEntity<CredentialEntity, UUID> {
public final static String _userId = "userId"; public final static String _userId = "userId";
@Column(name = "\"Status\"", nullable = false) @Column(name = "\"Status\"", nullable = false)
@Convert(converter = StatusConverter.class) @Convert(converter = IsActiveConverter.class)
private Status status; private IsActive isActive;
public final static String _status = "status"; public final static String _isActive = "isActive";
@Column(name = "\"Provider\"", nullable = false) @Column(name = "\"Provider\"", nullable = false)
@Convert(converter = ProviderTypeConverter.class) @Convert(converter = ProviderTypeConverter.class)
@ -84,12 +84,12 @@ public class CredentialEntity implements DataEntity<CredentialEntity, UUID> {
this.userId = userId; this.userId = userId;
} }
public Status getStatus() { public IsActive getIsActive() {
return status; return isActive;
} }
public void setStatus(Status status) { public void setIsActive(IsActive isActive) {
this.status = status; this.isActive = isActive;
} }
public ProviderType getProvider() { public ProviderType getProvider() {
@ -165,7 +165,7 @@ public class CredentialEntity implements DataEntity<CredentialEntity, UUID> {
@Override @Override
public void update(CredentialEntity entity) { public void update(CredentialEntity entity) {
this.status = entity.status; this.isActive = entity.isActive;
this.publicValue = entity.getPublicValue(); this.publicValue = entity.getPublicValue();
this.email = entity.getEmail(); this.email = entity.getEmail();
this.secret = entity.getSecret(); this.secret = entity.getSecret();

View File

@ -1,8 +1,10 @@
package eu.eudat.data; package eu.eudat.data;
import eu.eudat.commons.enums.Status; import eu.eudat.commons.enums.DescriptionTemplateTypeStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.enums.DescriptionTemplateTypeStatusConverter;
import eu.eudat.data.converters.enums.IsActiveConverter;
import jakarta.persistence.*; import jakarta.persistence.*;
import org.hibernate.annotations.GenericGenerator;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;
@ -28,11 +30,16 @@ public class DescriptionTemplateTypeEntity {
private Instant updatedAt; private Instant updatedAt;
public final static String _updatedAt = "updatedAt"; public final static String _updatedAt = "updatedAt";
@Column(name = "is_active", length = 100, nullable = false) @Column(name = "is_active", nullable = false)
@Enumerated(EnumType.STRING) @Convert(converter = IsActiveConverter.class)
private Status isActive; private IsActive isActive;
public final static String _isActive = "isActive"; public final static String _isActive = "isActive";
@Column(name = "status", nullable = false)
@Convert(converter = DescriptionTemplateTypeStatusConverter.class)
private DescriptionTemplateTypeStatus status;
public final static String _status = "status";
public UUID getId() { public UUID getId() {
return id; return id;
@ -66,11 +73,19 @@ public class DescriptionTemplateTypeEntity {
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
public Status getIsActive() { public IsActive getIsActive() {
return isActive; return isActive;
} }
public void setIsActive(Status isActive) { public void setIsActive(IsActive isActive) {
this.isActive = isActive; this.isActive = isActive;
} }
public DescriptionTemplateTypeStatus getStatus() {
return status;
}
public void setStatus(DescriptionTemplateTypeStatus status) {
this.status = status;
}
} }

View File

@ -0,0 +1,12 @@
package eu.eudat.data.converters.enums;
import eu.eudat.commons.enums.DescriptionTemplateTypeStatus;
import eu.eudat.commons.enums.IsActive;
import jakarta.persistence.Converter;
@Converter
public class DescriptionTemplateTypeStatusConverter extends DatabaseEnumConverter<DescriptionTemplateTypeStatus, Short> {
public DescriptionTemplateTypeStatus of(Short i) {
return DescriptionTemplateTypeStatus.of(i);
}
}

View File

@ -0,0 +1,11 @@
package eu.eudat.data.converters.enums;
import eu.eudat.commons.enums.IsActive;
import jakarta.persistence.Converter;
@Converter
public class IsActiveConverter extends DatabaseEnumConverter<IsActive, Short> {
public IsActive of(Short i) {
return IsActive.of(i);
}
}

View File

@ -1,15 +0,0 @@
package eu.eudat.data.converters.enums;
import eu.eudat.commons.enums.ProviderType;
import eu.eudat.commons.enums.Status;
import jakarta.persistence.Converter;
import java.util.HashMap;
import java.util.Map;
@Converter
public class StatusConverter extends DatabaseEnumConverter<Status, Integer> {
public Status of(Integer i) {
return Status.of(i);
}
}

View File

@ -1,9 +1,9 @@
package eu.eudat.model; package eu.eudat.model;
import eu.eudat.commons.enums.Status; import eu.eudat.commons.enums.DescriptionTemplateTypeStatus;
import eu.eudat.commons.enums.IsActive;
import java.time.Instant; import java.time.Instant;
import java.util.List;
import java.util.UUID; import java.util.UUID;
public class DescriptionTemplateType { public class DescriptionTemplateType {
@ -21,7 +21,10 @@ public class DescriptionTemplateType {
private Instant updatedAt; private Instant updatedAt;
public final static String _isActive = "isActive"; public final static String _isActive = "isActive";
private Status isActive; private IsActive isActive;
public final static String _status = "status";
private DescriptionTemplateTypeStatus status;
public final static String _hash = "hash"; public final static String _hash = "hash";
private String hash; private String hash;
@ -58,14 +61,22 @@ public class DescriptionTemplateType {
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
public Status getIsActive() { public IsActive getIsActive() {
return isActive; return isActive;
} }
public void setIsActive(Status isActive) { public void setIsActive(IsActive isActive) {
this.isActive = isActive; this.isActive = isActive;
} }
public DescriptionTemplateTypeStatus getStatus() {
return status;
}
public void setStatus(DescriptionTemplateTypeStatus status) {
this.status = status;
}
public String getHash() { public String getHash() {
return hash; return hash;
} }

View File

@ -52,6 +52,7 @@ public class DescriptionTemplateTypeBuilder extends BaseBuilder<DescriptionTempl
if (fields.hasField(this.asIndexer(DescriptionTemplateType._createdAt))) m.setCreatedAt(d.getCreatedAt()); if (fields.hasField(this.asIndexer(DescriptionTemplateType._createdAt))) m.setCreatedAt(d.getCreatedAt());
if (fields.hasField(this.asIndexer(DescriptionTemplateType._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); if (fields.hasField(this.asIndexer(DescriptionTemplateType._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(DescriptionTemplateType._isActive))) m.setIsActive(d.getIsActive()); if (fields.hasField(this.asIndexer(DescriptionTemplateType._isActive))) m.setIsActive(d.getIsActive());
if (fields.hasField(this.asIndexer(DescriptionTemplateType._status))) m.setStatus(d.getStatus());
if (fields.hasField(this.asIndexer(DescriptionTemplateType._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); if (fields.hasField(this.asIndexer(DescriptionTemplateType._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
models.add(m); models.add(m);
} }

View File

@ -1,6 +1,6 @@
package eu.eudat.model.deleter; package eu.eudat.model.deleter;
import eu.eudat.commons.enums.Status; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.DescriptionTemplateTypeEntity; import eu.eudat.data.DescriptionTemplateTypeEntity;
import eu.eudat.query.DescriptionTemplateTypeQuery; import eu.eudat.query.DescriptionTemplateTypeQuery;
import gr.cite.tools.data.deleter.Deleter; import gr.cite.tools.data.deleter.Deleter;
@ -20,7 +20,6 @@ import java.time.Instant;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
@ -66,7 +65,7 @@ public class DescriptionTemplateTypeDeleter implements Deleter {
for (DescriptionTemplateTypeEntity item : data) { for (DescriptionTemplateTypeEntity item : data) {
logger.trace("deleting item {}", item.getId()); logger.trace("deleting item {}", item.getId());
item.setIsActive(Status.Inactive); item.setIsActive(IsActive.Inactive);
item.setUpdatedAt(now); item.setUpdatedAt(now);
logger.trace("updating item"); logger.trace("updating item");
this.entityManager.merge(item); this.entityManager.merge(item);

View File

@ -1,6 +1,7 @@
package eu.eudat.model.persist; package eu.eudat.model.persist;
import eu.eudat.commons.enums.DescriptionTemplateTypeStatus;
import eu.eudat.commons.validation.FieldNotNullIfOtherSet; import eu.eudat.commons.validation.FieldNotNullIfOtherSet;
import eu.eudat.commons.validation.ValidId; import eu.eudat.commons.validation.ValidId;
@ -21,7 +22,10 @@ public class DescriptionTemplateTypePersist {
private String name; private String name;
private String hash; private String hash;
@NotNull(message = "{validation.empty}")
private DescriptionTemplateTypeStatus status;
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -45,5 +49,13 @@ public class DescriptionTemplateTypePersist {
public void setHash(String hash) { public void setHash(String hash) {
this.hash = hash; this.hash = hash;
} }
public DescriptionTemplateTypeStatus getStatus() {
return status;
}
public void setStatus(DescriptionTemplateTypeStatus status) {
this.status = status;
}
} }

View File

@ -98,7 +98,7 @@ public class CredentialQuery extends QueryBase<CredentialEntity> {
} }
if (this.statuses != null) { if (this.statuses != null) {
CriteriaBuilder.In<Short> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(CredentialEntity._status)); CriteriaBuilder.In<Short> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(CredentialEntity._isActive));
for (Short item : this.statuses) for (Short item : this.statuses)
inClause.value(item); inClause.value(item);
predicates.add(inClause); predicates.add(inClause);

View File

@ -1,7 +1,8 @@
package eu.eudat.query; package eu.eudat.query;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.enums.Status; import eu.eudat.commons.enums.DescriptionTemplateTypeStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.DescriptionTemplateTypeEntity; import eu.eudat.data.DescriptionTemplateTypeEntity;
import eu.eudat.model.DescriptionTemplateType; import eu.eudat.model.DescriptionTemplateType;
@ -25,7 +26,8 @@ public class DescriptionTemplateTypeQuery extends QueryBase<DescriptionTemplateT
private String like; private String like;
private Collection<UUID> ids; private Collection<UUID> ids;
private Collection<Status> isActives; private Collection<IsActive> isActives;
private Collection<DescriptionTemplateTypeStatus> statuses;
private Collection<UUID> excludedIds; private Collection<UUID> excludedIds;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@ -49,21 +51,36 @@ public class DescriptionTemplateTypeQuery extends QueryBase<DescriptionTemplateT
return this; return this;
} }
public DescriptionTemplateTypeQuery isActive(Status value) { public DescriptionTemplateTypeQuery isActive(IsActive value) {
this.isActives = List.of(value); this.isActives = List.of(value);
return this; return this;
} }
public DescriptionTemplateTypeQuery isActive(Status... value) { public DescriptionTemplateTypeQuery isActive(IsActive... value) {
this.isActives = Arrays.asList(value); this.isActives = Arrays.asList(value);
return this; return this;
} }
public DescriptionTemplateTypeQuery isActive(Collection<Status> values) { public DescriptionTemplateTypeQuery isActive(Collection<IsActive> values) {
this.isActives = values; this.isActives = values;
return this; return this;
} }
public DescriptionTemplateTypeQuery statuses(DescriptionTemplateTypeStatus value) {
this.statuses = List.of(value);
return this;
}
public DescriptionTemplateTypeQuery statuses(DescriptionTemplateTypeStatus... value) {
this.statuses = Arrays.asList(value);
return this;
}
public DescriptionTemplateTypeQuery statuses(Collection<DescriptionTemplateTypeStatus> values) {
this.statuses = values;
return this;
}
public DescriptionTemplateTypeQuery excludedIds(Collection<UUID> values) { public DescriptionTemplateTypeQuery excludedIds(Collection<UUID> values) {
this.excludedIds = values; this.excludedIds = values;
return this; return this;
@ -102,7 +119,7 @@ public class DescriptionTemplateTypeQuery extends QueryBase<DescriptionTemplateT
@Override @Override
protected Boolean isFalseQuery() { protected Boolean isFalseQuery() {
return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.excludedIds); return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.excludedIds) || this.isEmpty(this.statuses);
} }
@Override @Override
@ -117,8 +134,14 @@ public class DescriptionTemplateTypeQuery extends QueryBase<DescriptionTemplateT
predicates.add(queryContext.CriteriaBuilder.like(queryContext.Root.get(DescriptionTemplateTypeEntity._name), this.like)); predicates.add(queryContext.CriteriaBuilder.like(queryContext.Root.get(DescriptionTemplateTypeEntity._name), this.like));
} }
if (this.isActives != null) { if (this.isActives != null) {
CriteriaBuilder.In<Status> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateTypeEntity._isActive)); CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateTypeEntity._isActive));
for (Status item : this.isActives) inClause.value(item); for (IsActive item : this.isActives) inClause.value(item);
predicates.add(inClause);
}
if (this.statuses != null) {
CriteriaBuilder.In<DescriptionTemplateTypeStatus> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateTypeEntity._status));
for (DescriptionTemplateTypeStatus item : this.statuses) inClause.value(item);
predicates.add(inClause); predicates.add(inClause);
} }
if (this.excludedIds != null) { if (this.excludedIds != null) {
@ -141,7 +164,8 @@ public class DescriptionTemplateTypeQuery extends QueryBase<DescriptionTemplateT
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));
item.setIsActive(QueryBase.convertSafe(tuple, columns, DescriptionTemplateTypeEntity._isActive, Status.class)); item.setIsActive(QueryBase.convertSafe(tuple, columns, DescriptionTemplateTypeEntity._isActive, IsActive.class));
item.setStatus(QueryBase.convertSafe(tuple, columns, DescriptionTemplateTypeEntity._status, DescriptionTemplateTypeStatus.class));
return item; return item;
} }
@ -152,6 +176,7 @@ public class DescriptionTemplateTypeQuery extends QueryBase<DescriptionTemplateT
else if (item.match(DescriptionTemplateType._createdAt)) return DescriptionTemplateType._createdAt; else if (item.match(DescriptionTemplateType._createdAt)) return DescriptionTemplateType._createdAt;
else if (item.match(DescriptionTemplateType._updatedAt)) return DescriptionTemplateType._updatedAt; else if (item.match(DescriptionTemplateType._updatedAt)) return DescriptionTemplateType._updatedAt;
else if (item.match(DescriptionTemplateType._isActive)) return DescriptionTemplateType._isActive; else if (item.match(DescriptionTemplateType._isActive)) return DescriptionTemplateType._isActive;
else if (item.match(DescriptionTemplateType._status)) return DescriptionTemplateType._status;
else return null; else return null;
} }

View File

@ -1,6 +1,7 @@
package eu.eudat.query.lookup; package eu.eudat.query.lookup;
import eu.eudat.commons.enums.Status; import eu.eudat.commons.enums.DescriptionTemplateTypeStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.query.DescriptionTemplateTypeQuery; import eu.eudat.query.DescriptionTemplateTypeQuery;
import gr.cite.tools.data.query.Lookup; import gr.cite.tools.data.query.Lookup;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
@ -11,7 +12,8 @@ import java.util.UUID;
public class DescriptionTemplateTypeLookup extends Lookup { public class DescriptionTemplateTypeLookup extends Lookup {
private String like; private String like;
private List<Status> isActive; private List<IsActive> isActive;
private List<DescriptionTemplateTypeStatus> statuses;
private List<UUID> ids; private List<UUID> ids;
private List<UUID> excludedIds; private List<UUID> excludedIds;
@ -23,11 +25,11 @@ public class DescriptionTemplateTypeLookup extends Lookup {
this.like = like; this.like = like;
} }
public List<Status> getIsActive() { public List<IsActive> getIsActive() {
return isActive; return isActive;
} }
public void setIsActive(List<Status> isActive) { public void setIsActive(List<IsActive> isActive) {
this.isActive = isActive; this.isActive = isActive;
} }
@ -51,6 +53,7 @@ public class DescriptionTemplateTypeLookup extends Lookup {
DescriptionTemplateTypeQuery query = queryFactory.query(DescriptionTemplateTypeQuery.class); DescriptionTemplateTypeQuery query = queryFactory.query(DescriptionTemplateTypeQuery.class);
if (this.like != null) query.like(this.like); if (this.like != null) query.like(this.like);
if (this.isActive != null) query.isActive(this.isActive); if (this.isActive != null) query.isActive(this.isActive);
if (this.statuses != null) query.statuses(this.statuses);
if (this.ids != null) query.ids(this.ids); if (this.ids != null) query.ids(this.ids);
if (this.excludedIds != null) query.excludedIds(this.excludedIds); if (this.excludedIds != null) query.excludedIds(this.excludedIds);

View File

@ -3,7 +3,7 @@ package eu.eudat.service;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission; import eu.eudat.authorization.Permission;
import eu.eudat.commons.JsonHandlingService; import eu.eudat.commons.JsonHandlingService;
import eu.eudat.commons.enums.Status; import eu.eudat.commons.enums.IsActive;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.DescriptionTemplateTypeEntity; import eu.eudat.data.DescriptionTemplateTypeEntity;
import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.errorcode.ErrorThesaurusProperties;
@ -13,7 +13,6 @@ import eu.eudat.model.DescriptionTemplateType;
import eu.eudat.model.builder.DescriptionTemplateTypeBuilder; import eu.eudat.model.builder.DescriptionTemplateTypeBuilder;
import eu.eudat.model.deleter.DescriptionTemplateTypeDeleter; import eu.eudat.model.deleter.DescriptionTemplateTypeDeleter;
import eu.eudat.model.persist.DescriptionTemplateTypePersist; import eu.eudat.model.persist.DescriptionTemplateTypePersist;
import eu.eudat.query.DescriptionTemplateTypeQuery;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.deleter.DeleterFactory;
@ -93,11 +92,12 @@ public class DescriptionTemplateTypeServiceImpl implements DescriptionTemplateTy
} else { } else {
data = new DescriptionTemplateTypeEntity(); data = new DescriptionTemplateTypeEntity();
data.setId(UUID.randomUUID()); data.setId(UUID.randomUUID());
data.setIsActive(Status.Active); data.setIsActive(IsActive.Active);
data.setCreatedAt(Instant.now()); data.setCreatedAt(Instant.now());
} }
data.setName(model.getName()); data.setName(model.getName());
data.setStatus(model.getStatus());
data.setUpdatedAt(Instant.now()); data.setUpdatedAt(Instant.now());
if (isUpdate) this.entityManager.merge(data); if (isUpdate) this.entityManager.merge(data);
else this.entityManager.persist(data); else this.entityManager.persist(data);

View File

@ -2,7 +2,7 @@ package eu.eudat.interceptors;
import eu.eudat.commons.enums.ProviderType; import eu.eudat.commons.enums.ProviderType;
import eu.eudat.commons.enums.Status; import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.CredentialEntity; import eu.eudat.data.CredentialEntity;
import eu.eudat.data.entities.UserInfo; import eu.eudat.data.entities.UserInfo;
@ -100,7 +100,7 @@ public class UserInterceptor implements WebRequestInterceptor {
credentialQuery.where( credentialQuery.where(
credentialCriteriaBuilder.and( credentialCriteriaBuilder.and(
credentialCriteriaBuilder.equal(credentialRoot.get(CredentialEntity._externalId), subjectId), credentialCriteriaBuilder.equal(credentialRoot.get(CredentialEntity._externalId), subjectId),
credentialCriteriaBuilder.equal(credentialRoot.get(CredentialEntity._status), Status.Active), credentialCriteriaBuilder.equal(credentialRoot.get(CredentialEntity._isActive), IsActive.Active),
credentialCriteriaBuilder.equal(credentialRoot.get(CredentialEntity._provider), ProviderType.Keycloack) credentialCriteriaBuilder.equal(credentialRoot.get(CredentialEntity._provider), ProviderType.Keycloack)
)); ));
@ -202,7 +202,7 @@ public class UserInterceptor implements WebRequestInterceptor {
credentialEntity.setSecret(subjectId); credentialEntity.setSecret(subjectId);
credentialEntity.setCreationTime(new Date()); credentialEntity.setCreationTime(new Date());
credentialEntity.setLastUpdateTime(new Date()); credentialEntity.setLastUpdateTime(new Date());
credentialEntity.setStatus(Status.Active); credentialEntity.setIsActive(IsActive.Active);
credentialEntity.setProvider(ProviderType.Keycloack);//TODO: Authn credentialEntity.setProvider(ProviderType.Keycloack);//TODO: Authn
credentialEntity.setExternalId(subjectId); credentialEntity.setExternalId(subjectId);
credentialEntity.setEmail(email); credentialEntity.setEmail(email);

View File

@ -1,7 +1,7 @@
package eu.eudat.logic.builders.entity; package eu.eudat.logic.builders.entity;
import eu.eudat.commons.enums.ProviderType; import eu.eudat.commons.enums.ProviderType;
import eu.eudat.commons.enums.Status; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.CredentialEntity; import eu.eudat.data.CredentialEntity;
import eu.eudat.logic.builders.Builder; import eu.eudat.logic.builders.Builder;
import eu.eudat.data.entities.UserInfo; import eu.eudat.data.entities.UserInfo;
@ -18,7 +18,7 @@ public class CredentialBuilder extends Builder<CredentialEntity> {
private UserInfo userInfo; private UserInfo userInfo;
private Status status; private IsActive isActive;
private ProviderType provider; private ProviderType provider;
@ -44,8 +44,8 @@ public class CredentialBuilder extends Builder<CredentialEntity> {
return this; return this;
} }
public CredentialBuilder status(Status status) { public CredentialBuilder status(IsActive isActive) {
this.status = status; this.isActive = isActive;
return this; return this;
} }
@ -86,7 +86,7 @@ public class CredentialBuilder extends Builder<CredentialEntity> {
public CredentialEntity build() { public CredentialEntity build() {
CredentialEntity credential = new CredentialEntity(); CredentialEntity credential = new CredentialEntity();
credential.setStatus(status); credential.setIsActive(isActive);
credential.setLastUpdateTime(lastUpdateTime); credential.setLastUpdateTime(lastUpdateTime);
credential.setCreationTime(creationTime); credential.setCreationTime(creationTime);
credential.setProvider(provider); credential.setProvider(provider);