From 60ca51fe006b2429663e4a6b8d53868ceee6b20d Mon Sep 17 00:00:00 2001 From: Thomas Georgios Giannos Date: Fri, 27 Oct 2023 11:59:37 +0300 Subject: [PATCH] Adding DescriptionReference entity stack (former Dataset*** entities) --- .../eu/eudat/authorization/Permission.java | 4 + .../data/DescriptionReferenceEntity.java | 110 +++++++++ .../main/java/eu/eudat/data/DmpEntity.java | 4 - .../eu/eudat/model/DescriptionReference.java | 94 ++++++++ .../model/builder/DescriptionBuilder.java | 2 + .../builder/DescriptionReferenceBuilder.java | 155 ++++++++++++ .../DescriptionReferenceCensor.java | 50 ++++ .../deleter/DescriptionReferenceDeleter.java | 79 +++++++ .../query/DescriptionReferenceQuery.java | 220 ++++++++++++++++++ .../src/main/resources/config/permissions.yml | 21 ++ 10 files changed, 735 insertions(+), 4 deletions(-) create mode 100644 dmp-backend/core/src/main/java/eu/eudat/data/DescriptionReferenceEntity.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/DescriptionReference.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionReferenceBuilder.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/censorship/DescriptionReferenceCensor.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/deleter/DescriptionReferenceDeleter.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/query/DescriptionReferenceQuery.java diff --git a/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java b/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java index e6ba36ad8..94b38623f 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java +++ b/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java @@ -72,5 +72,9 @@ public final class Permission { public static String EditDmpReference = "EditDmpReference"; public static String DeleteDmpReference = "DeleteDmpReference"; + public static String BrowseDescriptionReference = "BrowseDescriptionReference"; + public static String EditDescriptionReference = "EditDescriptionReference"; + public static String DeleteDescriptionReference = "DeleteDescriptionReference"; + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionReferenceEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionReferenceEntity.java new file mode 100644 index 000000000..b471fdcbe --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionReferenceEntity.java @@ -0,0 +1,110 @@ +package eu.eudat.data; + +import eu.eudat.commons.enums.IsActive; +import eu.eudat.data.converters.DateToUTCConverter; +import eu.eudat.data.converters.enums.IsActiveConverter; +import jakarta.persistence.*; + +import java.time.Instant; +import java.util.UUID; + +//@Entity +//@Table(name = "\"DescriptionReference\"") +public class DescriptionReferenceEntity { + + @Id + @Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)") + private UUID id; + + public static final String _id = "id"; + + @Column(name = "data") + private String data; + + public static final String _data = "data"; + + @Column(name = "description_id", columnDefinition = "uuid", nullable = false) + private UUID descriptionId; + + public static final String _descriptionId = "descriptionId"; + + @Column(name = "reference_id", columnDefinition = "uuid", nullable = false) + private UUID referenceId; + + public static final String _referenceId = "referenceId"; + + @Column(name = "created_at") + @Convert(converter = DateToUTCConverter.class) + private Instant createdAt; + + public static final String _createdAt = "createdAt"; + + @Column(name = "updated_at") + @Convert(converter = DateToUTCConverter.class) + private Instant updatedAt; + + public static final String _updatedAt = "updatedAt"; + + @Column(name = "is_active", nullable = false) + @Convert(converter = IsActiveConverter.class) + private IsActive isActive; + + public static final String _isActive = "isActive"; + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public String getData() { + return data; + } + + public void setData(String data) { + this.data = data; + } + + public UUID getDescriptionId() { + return descriptionId; + } + + public void setDescriptionId(UUID descriptionId) { + this.descriptionId = descriptionId; + } + + public UUID getReferenceId() { + return referenceId; + } + + public void setReferenceId(UUID referenceId) { + this.referenceId = referenceId; + } + + public Instant getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Instant createdAt) { + this.createdAt = createdAt; + } + + public Instant getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Instant updatedAt) { + this.updatedAt = updatedAt; + } + + public IsActive getIsActive() { + return isActive; + } + + public void setIsActive(IsActive isActive) { + this.isActive = isActive; + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/DmpEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/DmpEntity.java index ffd97ecc4..b67455f62 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/data/DmpEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/data/DmpEntity.java @@ -97,10 +97,6 @@ public class DmpEntity { public static final String _publishedAt = "publishedAt"; - //TODO: (thgiannos) Handle using the DMPEntity builder -// @OneToMany(mappedBy = "dmp", fetch = FetchType.LAZY) -// private Set dataset; - // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "\"Grant\"") //TODO: (thgiannos) Previously 'Grant' diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/DescriptionReference.java b/dmp-backend/core/src/main/java/eu/eudat/model/DescriptionReference.java new file mode 100644 index 000000000..d06304b1b --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/DescriptionReference.java @@ -0,0 +1,94 @@ +package eu.eudat.model; + +import eu.eudat.commons.enums.IsActive; + +import java.time.Instant; +import java.util.UUID; + +public class DescriptionReference { + + private UUID id; + + public static final String _id = "id"; + + private String data; + + public static final String _data = "data"; + + private Description description; + + public static final String _description = "description"; + + private Reference reference; + + public static final String _reference = "reference"; + + private Instant createdAt; + + public static final String _createdAt = "createdAt"; + + private Instant updatedAt; + + public static final String _updatedAt = "updatedAt"; + + private IsActive isActive; + + public static final String _isActive = "isActive"; + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public String getData() { + return data; + } + + public void setData(String data) { + this.data = data; + } + + public Description getDescription() { + return description; + } + + public void setDescription(Description description) { + this.description = description; + } + + public Reference getReference() { + return reference; + } + + public void setReference(Reference reference) { + this.reference = reference; + } + + public Instant getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Instant createdAt) { + this.createdAt = createdAt; + } + + public Instant getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Instant updatedAt) { + this.updatedAt = updatedAt; + } + + public IsActive getIsActive() { + return isActive; + } + + public void setIsActive(IsActive isActive) { + this.isActive = isActive; + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionBuilder.java index 9ef64a834..ec6ef5508 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionBuilder.java @@ -96,7 +96,9 @@ public class DescriptionBuilder extends BaseBuilder { + + private final BuilderFactory builderFactory; + + private final QueryFactory queryFactory; + + private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); + + @Autowired + public DescriptionReferenceBuilder( + ConventionService conventionService, + BuilderFactory builderFactory, QueryFactory queryFactory) { + super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpReferenceBuilder.class))); + this.builderFactory = builderFactory; + this.queryFactory = queryFactory; + } + + public DescriptionReferenceBuilder authorize(EnumSet values) { + this.authorize = values; + return this; + } + + @Override + public List build(FieldSet fields, List 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.trace(new DataLogEntry("requested fields", fields)); + if (fields == null || data == null || fields.isEmpty()) + return new ArrayList<>(); + + FieldSet referenceFields = fields.extractPrefixed(this.asPrefix(DescriptionReference._reference)); + Map referenceItemsMap = this.collectReferences(referenceFields, data); + + FieldSet descriptionFields = fields.extractPrefixed(this.asPrefix(DescriptionReference._description)); + Map descriptionItemsMap = this.collectDescriptions(descriptionFields, data); + + List models = new ArrayList<>(); + + for (DescriptionReferenceEntity d : data) { + DescriptionReference m = new DescriptionReference(); + if (fields.hasField(this.asIndexer(DescriptionReference._id))) + m.setId(d.getId()); + if (fields.hasField(this.asIndexer(DescriptionReference._data))) + m.setData(d.getData()); + if (fields.hasField(this.asIndexer(DescriptionReference._createdAt))) + m.setCreatedAt(d.getCreatedAt()); + if (fields.hasField(this.asIndexer(DescriptionReference._updatedAt))) + m.setUpdatedAt(d.getUpdatedAt()); + if (fields.hasField(this.asIndexer(DescriptionReference._isActive))) + m.setIsActive(d.getIsActive()); + + 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())); + } + + models.add(m); + } + + this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); + + return models; + } + + private Map collectDescriptions(FieldSet fields, List data) throws MyApplicationException { + if (fields.isEmpty() || data.isEmpty()) + return null; + this.logger.debug("checking related - {}", Description.class.getSimpleName()); + + Map itemMap; + if (!fields.hasOtherField(this.asIndexer(Reference._id))) { + itemMap = this.asEmpty( + data.stream().map(DescriptionReferenceEntity::getDescriptionId).distinct().collect(Collectors.toList()), + x -> { + Description item = new Description(); + item.setId(x); + return item; + }, + Description::getId); + } else { + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Reference._id); + DescriptionQuery q = this.queryFactory.query(DescriptionQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionReferenceEntity::getDescriptionId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(DescriptionBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Description::getId); + } + if (!fields.hasField(Description._id)) { + itemMap.forEach((id, item) -> { + if (item != null) + item.setId(null); + }); + } + + return itemMap; + } + + private Map collectReferences(FieldSet fields, List data) throws MyApplicationException { + if (fields.isEmpty() || data.isEmpty()) + return null; + this.logger.debug("checking related - {}", Reference.class.getSimpleName()); + + Map itemMap; + if (!fields.hasOtherField(this.asIndexer(Reference._id))) { + itemMap = this.asEmpty( + data.stream().map(DescriptionReferenceEntity::getReferenceId).distinct().collect(Collectors.toList()), + x -> { + Reference item = new Reference(); + item.setId(x); + return item; + }, + Reference::getId); + } else { + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Reference._id); + ReferenceQuery q = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionReferenceEntity::getReferenceId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(ReferenceBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Reference::getId); + } + if (!fields.hasField(Reference._id)) { + itemMap.forEach((id, item) -> { + if (item != null) + item.setId(null); + }); + } + + return itemMap; + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/DescriptionReferenceCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/DescriptionReferenceCensor.java new file mode 100644 index 000000000..eabf97fe6 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/DescriptionReferenceCensor.java @@ -0,0 +1,50 @@ +package eu.eudat.model.censorship; + +import eu.eudat.authorization.Permission; +import eu.eudat.convention.ConventionService; +import eu.eudat.model.DescriptionReference; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.data.censor.CensorFactory; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.DataLogEntry; +import gr.cite.tools.logging.LoggerService; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.UUID; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class DescriptionReferenceCensor extends BaseCensor { + + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionReferenceCensor.class)); + + protected final AuthorizationService authService; + + protected final CensorFactory censorFactory; + + @Autowired + public DescriptionReferenceCensor(ConventionService conventionService, + AuthorizationService authService, + CensorFactory censorFactory) { + super(conventionService); + this.authService = authService; + this.censorFactory = censorFactory; + } + + public void censor(FieldSet fields, UUID userId) { + logger.debug(new DataLogEntry("censoring fields", fields)); + if (fields == null || fields.isEmpty()) + return; + + this.authService.authorizeForce(Permission.BrowseDescriptionReference); + FieldSet descriptionFields = fields.extractPrefixed(this.asIndexerPrefix(DescriptionReference._description)); + this.censorFactory.censor(DescriptionCensor.class).censor(descriptionFields, userId); + FieldSet referenceFields = fields.extractPrefixed(this.asIndexerPrefix(DescriptionReference._reference)); + this.censorFactory.censor(ReferenceCensor.class).censor(referenceFields, userId); + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/deleter/DescriptionReferenceDeleter.java b/dmp-backend/core/src/main/java/eu/eudat/model/deleter/DescriptionReferenceDeleter.java new file mode 100644 index 000000000..50752b336 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/deleter/DescriptionReferenceDeleter.java @@ -0,0 +1,79 @@ +package eu.eudat.model.deleter; + +import eu.eudat.commons.enums.IsActive; +import eu.eudat.data.DescriptionReferenceEntity; +import eu.eudat.query.DescriptionReferenceQuery; +import gr.cite.tools.data.deleter.Deleter; +import gr.cite.tools.data.deleter.DeleterFactory; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.logging.LoggerService; +import gr.cite.tools.logging.MapLogEntry; +import jakarta.persistence.EntityManager; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import javax.management.InvalidApplicationException; +import java.time.Instant; +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class DescriptionReferenceDeleter implements Deleter { + + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionReferenceDeleter.class)); + + private final EntityManager entityManager; + + protected final QueryFactory queryFactory; + + protected final DeleterFactory deleterFactory; + + @Autowired + public DescriptionReferenceDeleter( + EntityManager entityManager, + QueryFactory queryFactory, + DeleterFactory deleterFactory + ) { + this.entityManager = entityManager; + this.queryFactory = queryFactory; + this.deleterFactory = deleterFactory; + } + + public void deleteAndSaveByIds(List ids) throws InvalidApplicationException { + logger.debug(new MapLogEntry("collecting to delete").And("count", Optional.ofNullable(ids).map(List::size).orElse(0)).And("ids", ids)); + List data = this.queryFactory.query(DescriptionReferenceQuery.class).ids(ids).collect(); + logger.trace("retrieved {} items", Optional.ofNullable(data).map(List::size).orElse(0)); + this.deleteAndSave(data); + } + + public void deleteAndSave(List data) throws InvalidApplicationException { + logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0)); + this.delete(data); + logger.trace("saving changes"); + this.entityManager.flush(); + logger.trace("changes saved"); + } + + public void delete(List data) throws InvalidApplicationException { + logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0)); + if (data == null || data.isEmpty()) + return; + + Instant now = Instant.now(); + + for (DescriptionReferenceEntity item : data) { + logger.trace("deleting item {}", item.getId()); + item.setIsActive(IsActive.Inactive); + item.setUpdatedAt(now); + logger.trace("updating item"); + this.entityManager.merge(item); + logger.trace("updated item"); + } + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionReferenceQuery.java b/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionReferenceQuery.java new file mode 100644 index 000000000..83d64142f --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionReferenceQuery.java @@ -0,0 +1,220 @@ +package eu.eudat.query; + +import eu.eudat.authorization.AuthorizationFlags; +import eu.eudat.commons.enums.IsActive; +import eu.eudat.commons.scope.user.UserScope; +import eu.eudat.data.DescriptionReferenceEntity; +import eu.eudat.model.DescriptionReference; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.data.query.FieldResolver; +import gr.cite.tools.data.query.QueryBase; +import gr.cite.tools.data.query.QueryContext; +import jakarta.persistence.Tuple; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Predicate; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.time.Instant; +import java.util.*; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class DescriptionReferenceQuery extends QueryBase { + + private Collection ids; + + private Collection excludedIds; + + private Collection isActives; + + private Collection descriptionIds; + + private Collection referenceIds; + + private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); + + private final UserScope userScope; + + private final AuthorizationService authService; + + public DescriptionReferenceQuery(UserScope userScope, AuthorizationService authService) { + this.userScope = userScope; + this.authService = authService; + } + + public DescriptionReferenceQuery ids(UUID value) { + this.ids = List.of(value); + return this; + } + + public DescriptionReferenceQuery ids(UUID... value) { + this.ids = Arrays.asList(value); + return this; + } + + public DescriptionReferenceQuery ids(Collection values) { + this.ids = values; + return this; + } + + public DescriptionReferenceQuery excludedIds(Collection values) { + this.excludedIds = values; + return this; + } + + public DescriptionReferenceQuery excludedIds(UUID value) { + this.excludedIds = List.of(value); + return this; + } + + public DescriptionReferenceQuery excludedIds(UUID... value) { + this.excludedIds = Arrays.asList(value); + return this; + } + + public DescriptionReferenceQuery isActive(IsActive value) { + this.isActives = List.of(value); + return this; + } + + public DescriptionReferenceQuery isActive(IsActive... value) { + this.isActives = Arrays.asList(value); + return this; + } + + public DescriptionReferenceQuery isActive(Collection values) { + this.isActives = values; + return this; + } + + public DescriptionReferenceQuery descriptionIds(UUID value) { + this.descriptionIds = List.of(value); + return this; + } + + public DescriptionReferenceQuery descriptionIds(UUID... value) { + this.descriptionIds = Arrays.asList(value); + return this; + } + + public DescriptionReferenceQuery descriptionIds(Collection values) { + this.descriptionIds = values; + return this; + } + + public DescriptionReferenceQuery referenceIds(UUID value) { + this.referenceIds = List.of(value); + return this; + } + + public DescriptionReferenceQuery referenceIds(UUID... value) { + this.referenceIds = Arrays.asList(value); + return this; + } + + public DescriptionReferenceQuery referenceIds(Collection values) { + this.referenceIds = values; + return this; + } + + public DescriptionReferenceQuery authorize(EnumSet values) { + this.authorize = values; + return this; + } + + @Override + protected Boolean isFalseQuery() { + return + this.isEmpty(this.ids) || + this.isEmpty(this.isActives) || + this.isEmpty(this.excludedIds) || + this.isEmpty(this.descriptionIds) || + this.isEmpty(this.referenceIds); + } + + @Override + protected Class entityClass() { + return DescriptionReferenceEntity.class; + } + + @Override + protected Predicate applyFilters(QueryContext queryContext) { + List predicates = new ArrayList<>(); + if (this.ids != null) { + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionReferenceEntity._id)); + for (UUID item : this.ids) + inClause.value(item); + predicates.add(inClause); + } + if (this.excludedIds != null) { + CriteriaBuilder.In notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionReferenceEntity._id)); + for (UUID item : this.excludedIds) + notInClause.value(item); + predicates.add(notInClause.not()); + } + if (this.isActives != null) { + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionReferenceEntity._isActive)); + for (IsActive item : this.isActives) + inClause.value(item); + predicates.add(inClause); + } + if (this.descriptionIds != null) { + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionReferenceEntity._descriptionId)); + for (UUID item : this.descriptionIds) + inClause.value(item); + predicates.add(inClause); + } + if (this.referenceIds != null) { + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionReferenceEntity._referenceId)); + for (UUID item : this.referenceIds) + inClause.value(item); + predicates.add(inClause); + } + if (!predicates.isEmpty()) { + Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); + return queryContext.CriteriaBuilder.and(predicatesArray); + } else { + return null; + } + } + + @Override + protected String fieldNameOf(FieldResolver item) { + if (item.match(DescriptionReference._id)) + return DescriptionReferenceEntity._id; + if (item.match(DescriptionReference._data)) + return DescriptionReferenceEntity._data; + if (item.match(DescriptionReference._description)) + return DescriptionReferenceEntity._descriptionId; + else if (item.prefix(DescriptionReference._description)) + return DescriptionReferenceEntity._descriptionId; + else if (item.match(DescriptionReference._reference)) + return DescriptionReferenceEntity._referenceId; + else if (item.prefix(DescriptionReference._reference)) + return DescriptionReferenceEntity._referenceId; + else if (item.match(DescriptionReference._createdAt)) + return DescriptionReferenceEntity._createdAt; + else if (item.match(DescriptionReference._updatedAt)) + return DescriptionReferenceEntity._updatedAt; + else if (item.match(DescriptionReference._isActive)) + return DescriptionReferenceEntity._isActive; + else + return null; + } + + @Override + protected DescriptionReferenceEntity convert(Tuple tuple, Set columns) { + DescriptionReferenceEntity item = new DescriptionReferenceEntity(); + item.setId(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._id, UUID.class)); + item.setData(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._data, String.class)); + item.setDescriptionId(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._descriptionId, UUID.class)); + item.setReferenceId(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._referenceId, UUID.class)); + item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._createdAt, Instant.class)); + item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._updatedAt, Instant.class)); + item.setIsActive(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._isActive, IsActive.class)); + return item; + } + +} diff --git a/dmp-backend/web/src/main/resources/config/permissions.yml b/dmp-backend/web/src/main/resources/config/permissions.yml index 52fa74adc..a1ed7f18b 100644 --- a/dmp-backend/web/src/main/resources/config/permissions.yml +++ b/dmp-backend/web/src/main/resources/config/permissions.yml @@ -237,3 +237,24 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false + + # DescriptionReference Permissions + BrowseDescriptionReference: + roles: + - Admin + clients: [ ] + allowAnonymous: false + allowAuthenticated: false + EditDescriptionReference: + roles: + - Admin + clients: [ ] + allowAnonymous: false + allowAuthenticated: false + DeleteDescriptionReference: + roles: + - Admin + claims: [ ] + clients: [ ] + allowAnonymous: false + allowAuthenticated: false