add public models

This commit is contained in:
Efstratios Giannopoulos 2023-11-07 17:07:24 +02:00
parent 0644e61962
commit 8cd8da6d98
30 changed files with 1609 additions and 15 deletions

View File

@ -13,6 +13,15 @@ public final class Permission {
/////
//Public
public static String PublicBrowseDescription = "PublicBrowseDescription";
public static String PublicBrowseDescriptionTemplate = "BrowseDescriptionTemplate";
public static String PublicBrowseDmp = "PublicBrowseDmp";
public static String PublicBrowseDmpReference = "PublicBrowseDmpReference";
public static String PublicBrowseDmpUser = "PublicBrowseDmpUser";
public static String PublicBrowseReference = "PublicBrowseReference";
public static String PublicBrowseUser = "PublicBrowseUser";
//Language

View File

@ -0,0 +1,107 @@
package eu.eudat.model;
import eu.eudat.commons.enums.DescriptionStatus;
import java.time.Instant;
import java.util.UUID;
public class PublicDescription {
private UUID id;
public static final String _id = "id";
private String label;
public static final String _label = "label";
private DescriptionStatus status;
public static final String _status = "status";
private String description;
public static final String _description = "description";
private Instant createdAt;
public static final String _createdAt = "createdAt";
private Instant updatedAt;
public static final String _updatedAt = "updatedAt";
private Instant finalizedAt;
public static final String _finalizedAt = "finalizedAt";
private PublicDmpDescriptionTemplate dmpDescriptionTemplate;
public static final String _dmpDescriptionTemplate = "dmpDescriptionTemplate";
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public DescriptionStatus getStatus() {
return status;
}
public void setStatus(DescriptionStatus status) {
this.status = status;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Instant getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Instant updatedAt) {
this.updatedAt = updatedAt;
}
public Instant getFinalizedAt() {
return finalizedAt;
}
public void setFinalizedAt(Instant finalizedAt) {
this.finalizedAt = finalizedAt;
}
public Instant getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt;
}
public PublicDmpDescriptionTemplate getDmpDescriptionTemplate() {
return dmpDescriptionTemplate;
}
public void setDmpDescriptionTemplate(PublicDmpDescriptionTemplate dmpDescriptionTemplate) {
this.dmpDescriptionTemplate = dmpDescriptionTemplate;
}
}

View File

@ -0,0 +1,45 @@
package eu.eudat.model;
import eu.eudat.commons.enums.DescriptionTemplateStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.model.descriptiontemplatedefinition.Definition;
import java.time.Instant;
import java.util.List;
import java.util.UUID;
public class PublicDescriptionTemplate {
public final static String _id = "id";
private UUID id;
public final static String _label = "label";
private String label;
public final static String _description = "description";
private String description;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}

View File

@ -0,0 +1,108 @@
package eu.eudat.model;
import eu.eudat.commons.enums.DmpAccessType;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.IsActive;
import java.time.Instant;
import java.util.List;
import java.util.UUID;
public class PublicDmp {
private UUID id;
public static final String _id = "id";
private String label;
public static final String _label = "label";
private Short version;
public static final String _version = "version";
private String description;
public static final String _description = "description";
private Instant finalizedAt;
public static final String _finalizedAt = "finalizedAt";
private Instant publishedAt;
public static final String _publishedAt = "publishedAt";
private List<PublicDmpUser> users;
public static final String _users = "users";
private List<PublicDmpReference> dmpReferences;
public static final String _dmpReferences = "_dmpReferences";
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public Short getVersion() {
return version;
}
public void setVersion(Short version) {
this.version = version;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Instant getFinalizedAt() {
return finalizedAt;
}
public void setFinalizedAt(Instant finalizedAt) {
this.finalizedAt = finalizedAt;
}
public Instant getPublishedAt() {
return publishedAt;
}
public void setPublishedAt(Instant publishedAt) {
this.publishedAt = publishedAt;
}
public List<PublicDmpUser> getUsers() {
return users;
}
public void setUsers(List<PublicDmpUser> users) {
this.users = users;
}
public List<PublicDmpReference> getDmpReferences() {
return dmpReferences;
}
public void setDmpReferences(List<PublicDmpReference> dmpReferences) {
this.dmpReferences = dmpReferences;
}
}

View File

@ -0,0 +1,45 @@
package eu.eudat.model;
import eu.eudat.commons.enums.IsActive;
import java.time.Instant;
import java.util.UUID;
public class PublicDmpDescriptionTemplate {
private UUID id;
public static final String _id = "id";
private PublicDmp dmp;
public static final String _dmp = "dmp";
private PublicDescriptionTemplate descriptionTemplate;
public static final String _descriptionTemplate = "descriptionTemplate";
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public PublicDmp getDmp() {
return dmp;
}
public void setDmp(PublicDmp dmp) {
this.dmp = dmp;
}
public PublicDescriptionTemplate getDescriptionTemplate() {
return descriptionTemplate;
}
public void setDescriptionTemplate(PublicDescriptionTemplate descriptionTemplate) {
this.descriptionTemplate = descriptionTemplate;
}
}

View File

@ -0,0 +1,40 @@
package eu.eudat.model;
import java.time.Instant;
import java.util.UUID;
public class PublicDmpReference {
private UUID id;
public static final String _id = "id";
private PublicDmp dmp;
public static final String _dmp = "dmp";
private PublicReference reference;
public static final String _reference = "reference";
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public PublicDmp getDmp() {
return dmp;
}
public void setDmp(PublicDmp dmp) {
this.dmp = dmp;
}
public PublicReference getReference() {
return reference;
}
public void setReference(PublicReference reference) {
this.reference = reference;
}
}

View File

@ -0,0 +1,54 @@
package eu.eudat.model;
import eu.eudat.commons.enums.DmpUserRole;
import java.util.UUID;
public class PublicDmpUser {
public static final String _id = "id";
private UUID id;
public static final String _dmp = "dmp";
private PublicDmp dmp;
public static final String _user = "user";
private PublicUserInfo user;
public static final String _role = "role";
private DmpUserRole role;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public PublicDmp getDmp() {
return dmp;
}
public void setDmp(PublicDmp dmp) {
this.dmp = dmp;
}
public PublicUserInfo getUser() {
return user;
}
public void setUser(PublicUserInfo user) {
this.user = user;
}
public DmpUserRole getRole() {
return role;
}
public void setRole(DmpUserRole role) {
this.role = role;
}
}

View File

@ -0,0 +1,68 @@
package eu.eudat.model;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.enums.ReferenceSourceType;
import eu.eudat.commons.enums.ReferenceType;
import eu.eudat.model.referencedefinition.Definition;
import java.time.Instant;
import java.util.List;
import java.util.UUID;
public class PublicReference {
private UUID id;
public static final String _id = "id";
private String label;
public static final String _label = "label";
private ReferenceType type;
public static final String _type = "type";
private String description;
public static final String _description = "description";
private String reference;
public static final String _reference = "reference";
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public ReferenceType getType() {
return type;
}
public void setType(ReferenceType type) {
this.type = type;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
}

View File

@ -0,0 +1,29 @@
package eu.eudat.model;
import java.util.UUID;
public class PublicUserInfo {
public final static String _id = "id";
private UUID id;
public final static String _name = "name";
private String name = null;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@ -70,11 +70,9 @@ public class DescriptionTemplateBuilder extends BaseBuilder<DescriptionTemplate,
if (fields.hasField(this.asIndexer(DescriptionTemplate._id))) m.setId(d.getId());
if (fields.hasField(this.asIndexer(DescriptionTemplate._label))) m.setLabel(d.getLabel());
if (fields.hasField(this.asIndexer(DescriptionTemplate._description))) m.setDescription(d.getDescription());
if (fields.hasField(this.asIndexer(DescriptionTemplate._groupId))) m.setLabel(d.getLabel());
if (fields.hasField(this.asIndexer(DescriptionTemplate._version))) m.setLabel(d.getLabel());
if (fields.hasField(this.asIndexer(DescriptionTemplate._language))) m.setLabel(d.getLabel());
if (fields.hasField(this.asIndexer(DescriptionTemplate._type))) m.setLabel(d.getLabel());
if (fields.hasField(this.asIndexer(DescriptionTemplate._definition))) m.setLabel(d.getLabel());
if (fields.hasField(this.asIndexer(DescriptionTemplate._groupId))) m.setGroupId(d.getGroupId());
if (fields.hasField(this.asIndexer(DescriptionTemplate._version))) m.setVersion(d.getVersion());
if (fields.hasField(this.asIndexer(DescriptionTemplate._language))) m.setLanguage(d.getLanguage());
if (fields.hasField(this.asIndexer(DescriptionTemplate._createdAt))) m.setCreatedAt(d.getCreatedAt());
if (fields.hasField(this.asIndexer(DescriptionTemplate._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(DescriptionTemplate._isActive))) m.setIsActive(d.getIsActive());

View File

@ -55,7 +55,7 @@ public class DmpBuilder extends BaseBuilder<Dmp, DmpEntity> {
List<Dmp> models = new ArrayList<>();
FieldSet dmpReferencesFields = fields.extractPrefixed(this.asPrefix(Reference._dmpReferences));
FieldSet dmpReferencesFields = fields.extractPrefixed(this.asPrefix(Dmp._dmpReferences));
Map<UUID, List<DmpReference>> dmpReferenceMap = this.collectDmpReferences(dmpReferencesFields, data);
for (DmpEntity d : data) {

View File

@ -0,0 +1,108 @@
package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.DescriptionEntity;
import eu.eudat.model.PublicDescription;
import eu.eudat.model.PublicDmpDescriptionTemplate;
import eu.eudat.query.DmpDescriptionTemplateQuery;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.BaseFieldSet;
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.*;
import java.util.stream.Collectors;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PublicDescriptionBuilder extends BaseBuilder<PublicDescription, DescriptionEntity> {
private final QueryFactory queryFactory;
private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
public PublicDescriptionBuilder(
ConventionService conventionService,
QueryFactory queryFactory,
BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicDescriptionBuilder.class)));
this.queryFactory = queryFactory;
this.builderFactory = builderFactory;
}
public PublicDescriptionBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<PublicDescription> build(FieldSet fields, List<DescriptionEntity> 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 dmpDescriptionTemplateFields = fields.extractPrefixed(this.asPrefix(PublicDescription._dmpDescriptionTemplate));
Map<UUID, PublicDmpDescriptionTemplate> dmpDescriptionTemplateItemsMap = this.collectDmpDescriptionTemplates(dmpDescriptionTemplateFields, data);
List<PublicDescription> models = new ArrayList<>();
for (DescriptionEntity d : data) {
PublicDescription m = new PublicDescription();
if (fields.hasField(this.asIndexer(PublicDescription._id))) m.setId(d.getId());
if (fields.hasField(this.asIndexer(PublicDescription._label))) m.setLabel(d.getLabel());
if (fields.hasField(this.asIndexer(PublicDescription._status))) m.setStatus(d.getStatus());
if (fields.hasField(this.asIndexer(PublicDescription._description))) m.setDescription(d.getDescription());
if (fields.hasField(this.asIndexer(PublicDescription._createdAt))) m.setCreatedAt(d.getCreatedAt());
if (fields.hasField(this.asIndexer(PublicDescription._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(PublicDescription._finalizedAt))) m.setFinalizedAt(d.getFinalizedAt());
if (!dmpDescriptionTemplateFields.isEmpty() && dmpDescriptionTemplateItemsMap != null && dmpDescriptionTemplateItemsMap.containsKey(d.getDmpDescriptionTemplateId())) m.setDmpDescriptionTemplate(dmpDescriptionTemplateItemsMap.get(d.getDmpDescriptionTemplateId()));
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
private Map<UUID, PublicDmpDescriptionTemplate> collectDmpDescriptionTemplates(FieldSet fields, List<DescriptionEntity> data) throws MyApplicationException {
if (fields.isEmpty() || data.isEmpty())
return null;
this.logger.debug("checking related - {}", PublicDmpDescriptionTemplate.class.getSimpleName());
Map<UUID, PublicDmpDescriptionTemplate> itemMap;
if (!fields.hasOtherField(this.asIndexer(PublicDmpDescriptionTemplate._id))) {
itemMap = this.asEmpty(
data.stream().map(DescriptionEntity::getDmpDescriptionTemplateId).distinct().collect(Collectors.toList()),
x -> {
PublicDmpDescriptionTemplate item = new PublicDmpDescriptionTemplate();
item.setId(x);
return item;
},
PublicDmpDescriptionTemplate::getId);
} else {
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PublicDmpDescriptionTemplate._id);
DmpDescriptionTemplateQuery q = this.queryFactory.query(DmpDescriptionTemplateQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDmpDescriptionTemplateId).distinct().collect(Collectors.toList()));
itemMap = this.builderFactory.builder(PublicDmpDescriptionTemplateBuilder.class).authorize(this.authorize).asForeignKey(q, clone, PublicDmpDescriptionTemplate::getId);
}
if (!fields.hasField(PublicDmpDescriptionTemplate._id)) {
itemMap.forEach((id, item) -> {
if (item != null)
item.setId(null);
});
}
return itemMap;
}
}

View File

@ -0,0 +1,60 @@
package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.XmlHandlingService;
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.model.PublicDescriptionTemplate;
import eu.eudat.query.DescriptionTemplateTypeQuery;
import eu.eudat.query.UserDescriptionTemplateQuery;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.BaseFieldSet;
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.*;
import java.util.stream.Collectors;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PublicDescriptionTemplateBuilder extends BaseBuilder<PublicDescriptionTemplate, DescriptionTemplateEntity> {
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
public PublicDescriptionTemplateBuilder(
ConventionService conventionService) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicDescriptionTemplateBuilder.class)));
}
public PublicDescriptionTemplateBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<PublicDescriptionTemplate> build(FieldSet fields, List<DescriptionTemplateEntity> datas) throws MyApplicationException {
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(datas).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 || datas == null || fields.isEmpty())
return new ArrayList<>();
List<PublicDescriptionTemplate> models = new ArrayList<>();
for (DescriptionTemplateEntity d : datas) {
PublicDescriptionTemplate m = new PublicDescriptionTemplate();
if (fields.hasField(this.asIndexer(PublicDescriptionTemplate._id))) m.setId(d.getId());
if (fields.hasField(this.asIndexer(PublicDescriptionTemplate._label))) m.setLabel(d.getLabel());
if (fields.hasField(this.asIndexer(PublicDescriptionTemplate._description))) m.setDescription(d.getDescription());
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
}

View File

@ -0,0 +1,96 @@
package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.DmpEntity;
import eu.eudat.model.PublicDmp;
import eu.eudat.model.PublicDmpReference;
import eu.eudat.query.DmpReferenceQuery;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.BaseFieldSet;
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.*;
import java.util.stream.Collectors;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PublicDmpBuilder extends BaseBuilder<PublicDmp, DmpEntity> {
private final QueryFactory queryFactory;
private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
public PublicDmpBuilder(ConventionService conventionService,
QueryFactory queryFactory,
BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicDmpBuilder.class)));
this.queryFactory = queryFactory;
this.builderFactory = builderFactory;
}
public PublicDmpBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<PublicDmp> build(FieldSet fields, List<DmpEntity> 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<>();
List<PublicDmp> models = new ArrayList<>();
FieldSet dmpReferencesFields = fields.extractPrefixed(this.asPrefix(PublicDmp._dmpReferences));
Map<UUID, List<PublicDmpReference>> dmpReferenceMap = this.collectDmpReferences(dmpReferencesFields, data);
for (DmpEntity d : data) {
PublicDmp m = new PublicDmp();
if (fields.hasField(this.asIndexer(PublicDmp._id))) m.setId(d.getId());
if (fields.hasField(this.asIndexer(PublicDmp._label))) m.setLabel(d.getLabel());
if (fields.hasField(this.asIndexer(PublicDmp._version))) m.setVersion(d.getVersion());
if (fields.hasField(this.asIndexer(PublicDmp._description))) m.setDescription(d.getDescription());
if (fields.hasField(this.asIndexer(PublicDmp._finalizedAt))) m.setFinalizedAt(d.getFinalizedAt());
if (dmpReferenceMap != null && !dmpReferenceMap.isEmpty() && dmpReferenceMap.containsKey(d.getId())) m.setDmpReferences(dmpReferenceMap.get(d.getId()));
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
private Map<UUID, List<PublicDmpReference>> collectDmpReferences(FieldSet fields, List<DmpEntity> datas) throws MyApplicationException {
if (fields.isEmpty() || datas.isEmpty()) return null;
this.logger.debug("checking related - {}", PublicDmpReference.class.getSimpleName());
Map<UUID, List<PublicDmpReference>> itemMap = null;
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(PublicDmpReference._dmp, PublicDmp._id));
DmpReferenceQuery query = this.queryFactory.query(DmpReferenceQuery.class).authorize(this.authorize).dmpIds(datas.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
itemMap = this.builderFactory.builder(PublicDmpReferenceBuilder.class).authorize(this.authorize).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId());
if (!fields.hasField(this.asIndexer(PublicDmpReference._dmp, PublicDmp._id))) {
itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDmp() != null).peek(x -> {
x.getDmp().setId(null);
});
}
return itemMap;
}
}

View File

@ -0,0 +1,130 @@
package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.DmpDescriptionTemplateEntity;
import eu.eudat.model.PublicDescriptionTemplate;
import eu.eudat.model.PublicDmp;
import eu.eudat.model.PublicDmpDescriptionTemplate;
import eu.eudat.query.DescriptionTemplateQuery;
import eu.eudat.query.DmpQuery;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.BaseFieldSet;
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.*;
import java.util.stream.Collectors;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PublicDmpDescriptionTemplateBuilder extends BaseBuilder<PublicDmpDescriptionTemplate, DmpDescriptionTemplateEntity> {
private final BuilderFactory builderFactory;
private final QueryFactory queryFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
public PublicDmpDescriptionTemplateBuilder(
ConventionService conventionService,
BuilderFactory builderFactory, QueryFactory queryFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicDmpDescriptionTemplateBuilder.class)));
this.builderFactory = builderFactory;
this.queryFactory = queryFactory;
}
public PublicDmpDescriptionTemplateBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<PublicDmpDescriptionTemplate> build(FieldSet fields, List<DmpDescriptionTemplateEntity> 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 templateFields = fields.extractPrefixed(this.asPrefix(PublicDmpDescriptionTemplate._descriptionTemplate));
Map<UUID, PublicDescriptionTemplate> templateItemsMap = this.collectTemplates(templateFields, data);
FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(PublicDmpDescriptionTemplate._dmp));
Map<UUID, PublicDmp> dmpItemsMap = this.collectDmps(dmpFields, data);
List<PublicDmpDescriptionTemplate> models = new ArrayList<>();
for (DmpDescriptionTemplateEntity d : data) {
PublicDmpDescriptionTemplate m = new PublicDmpDescriptionTemplate();
if (fields.hasField(this.asIndexer(PublicDmpDescriptionTemplate._id))) m.setId(d.getId());
if (!templateFields.isEmpty() && templateItemsMap != null && templateItemsMap.containsKey(d.getDescriptionTemplateId())) m.setDescriptionTemplate(templateItemsMap.get(d.getDescriptionTemplateId()));
if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) m.setDmp(dmpItemsMap.get(d.getDmpId()));
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
private Map<UUID, PublicDescriptionTemplate> collectTemplates(FieldSet fields, List<DmpDescriptionTemplateEntity> data) throws MyApplicationException {
if (fields.isEmpty() || data.isEmpty())
return null;
this.logger.debug("checking related - {}", PublicDescriptionTemplate.class.getSimpleName());
Map<UUID, PublicDescriptionTemplate> itemMap;
if (!fields.hasOtherField(this.asIndexer(PublicDescriptionTemplate._id))) {
itemMap = this.asEmpty(
data.stream().map(DmpDescriptionTemplateEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList()),
x -> {
PublicDescriptionTemplate item = new PublicDescriptionTemplate();
item.setId(x);
return item;
},
PublicDescriptionTemplate::getId);
} else {
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PublicDescriptionTemplate._id);
DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).authorize(this.authorize).ids(data.stream().map(DmpDescriptionTemplateEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList()));
itemMap = this.builderFactory.builder(PublicDescriptionTemplateBuilder.class).authorize(this.authorize).asForeignKey(q, clone, PublicDescriptionTemplate::getId);
}
if (!fields.hasField(PublicDescriptionTemplate._id)) {
itemMap.values().stream().filter(Objects::nonNull).peek(x -> x.setId(null)).collect(Collectors.toList());
}
return itemMap;
}
private Map<UUID, PublicDmp> collectDmps(FieldSet fields, List<DmpDescriptionTemplateEntity> data) throws MyApplicationException {
if (fields.isEmpty() || data.isEmpty())
return null;
this.logger.debug("checking related - {}", PublicDmp.class.getSimpleName());
Map<UUID, PublicDmp> itemMap;
if (!fields.hasOtherField(this.asIndexer(PublicDmp._id))) {
itemMap = this.asEmpty(
data.stream().map(DmpDescriptionTemplateEntity::getDmpId).distinct().collect(Collectors.toList()),
x -> {
PublicDmp item = new PublicDmp();
item.setId(x);
return item;
},
PublicDmp::getId);
} else {
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PublicDmp._id);
DmpQuery q = this.queryFactory.query(DmpQuery.class).authorize(this.authorize).ids(data.stream().map(DmpDescriptionTemplateEntity::getDmpId).distinct().collect(Collectors.toList()));
itemMap = this.builderFactory.builder(PublicDmpBuilder.class).authorize(this.authorize).asForeignKey(q, clone, PublicDmp::getId);
}
if (!fields.hasField(PublicDmp._id)) {
itemMap.values().stream().filter(Objects::nonNull).peek(x -> x.setId(null)).collect(Collectors.toList());
}
return itemMap;
}
}

View File

@ -0,0 +1,131 @@
package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.DmpReferenceEntity;
import eu.eudat.model.PublicDmp;
import eu.eudat.model.PublicDmpReference;
import eu.eudat.model.PublicReference;
import eu.eudat.query.DmpQuery;
import eu.eudat.query.ReferenceQuery;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.BaseFieldSet;
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.*;
import java.util.stream.Collectors;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PublicDmpReferenceBuilder extends BaseBuilder<PublicDmpReference, DmpReferenceEntity> {
private final BuilderFactory builderFactory;
private final QueryFactory queryFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
public PublicDmpReferenceBuilder(
ConventionService conventionService,
BuilderFactory builderFactory, QueryFactory queryFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicDmpReferenceBuilder.class)));
this.builderFactory = builderFactory;
this.queryFactory = queryFactory;
}
public PublicDmpReferenceBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<PublicDmpReference> build(FieldSet fields, List<DmpReferenceEntity> 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(PublicDmpReference._reference));
Map<UUID, PublicReference> referenceItemsMap = this.collectReferences(referenceFields, data);
FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(PublicDmpReference._dmp));
Map<UUID, PublicDmp> dmpItemsMap = this.collectDmps(dmpFields, data);
List<PublicDmpReference> models = new ArrayList<>();
for (DmpReferenceEntity d : data) {
PublicDmpReference m = new PublicDmpReference();
if (fields.hasField(this.asIndexer(PublicDmpReference._id))) m.setId(d.getId());
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()));
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
private Map<UUID, PublicReference> collectReferences(FieldSet fields, List<DmpReferenceEntity> data) throws MyApplicationException {
if (fields.isEmpty() || data.isEmpty())
return null;
this.logger.debug("checking related - {}", PublicReference.class.getSimpleName());
Map<UUID, PublicReference> itemMap;
if (!fields.hasOtherField(this.asIndexer(PublicReference._id))) {
itemMap = this.asEmpty(
data.stream().map(DmpReferenceEntity::getReferenceId).distinct().collect(Collectors.toList()),
x -> {
PublicReference item = new PublicReference();
item.setId(x);
return item;
},
PublicReference::getId);
} else {
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PublicReference._id);
ReferenceQuery q = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).isActive(IsActive.Active).ids(data.stream().map(DmpReferenceEntity::getReferenceId).distinct().collect(Collectors.toList()));
itemMap = this.builderFactory.builder(PublicReferenceBuilder.class).authorize(this.authorize).asForeignKey(q, clone, PublicReference::getId);
}
if (!fields.hasField(PublicReference._id)) {
itemMap.values().stream().filter(Objects::nonNull).peek(x -> x.setId(null)).collect(Collectors.toList());
}
return itemMap;
}
private Map<UUID, PublicDmp> collectDmps(FieldSet fields, List<DmpReferenceEntity> data) throws MyApplicationException {
if (fields.isEmpty() || data.isEmpty())
return null;
this.logger.debug("checking related - {}", PublicDmp.class.getSimpleName());
Map<UUID, PublicDmp> itemMap;
if (!fields.hasOtherField(this.asIndexer(PublicDmp._id))) {
itemMap = this.asEmpty(
data.stream().map(DmpReferenceEntity::getDmpId).distinct().collect(Collectors.toList()),
x -> {
PublicDmp item = new PublicDmp();
item.setId(x);
return item;
},
PublicDmp::getId);
} else {
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PublicDmp._id);
DmpQuery q = this.queryFactory.query(DmpQuery.class).authorize(this.authorize).isActive(IsActive.Active).ids(data.stream().map(DmpReferenceEntity::getDmpId).distinct().collect(Collectors.toList()));
itemMap = this.builderFactory.builder(PublicDmpBuilder.class).authorize(this.authorize).asForeignKey(q, clone, PublicDmp::getId);
}
if (!fields.hasField(PublicDmp._id)) {
itemMap.values().stream().filter(Objects::nonNull).peek(x -> x.setId(null)).collect(Collectors.toList());
}
return itemMap;
}
}

View File

@ -0,0 +1,104 @@
package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.DmpUserEntity;
import eu.eudat.data.old.UserInfo;
import eu.eudat.model.PublicDmp;
import eu.eudat.model.PublicDmpUser;
import eu.eudat.model.PublicUserInfo;
import eu.eudat.query.DmpQuery;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.BaseFieldSet;
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.*;
import java.util.stream.Collectors;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PublicDmpUserBuilder extends BaseBuilder<PublicDmpUser, DmpUserEntity>{
private final BuilderFactory builderFactory;
private final QueryFactory queryFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
public PublicDmpUserBuilder(
ConventionService conventionService,
BuilderFactory builderFactory, QueryFactory queryFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicDmpUserBuilder.class)));
this.builderFactory = builderFactory;
this.queryFactory = queryFactory;
}
public PublicDmpUserBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<PublicDmpUser> build(FieldSet fields, List<DmpUserEntity> 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 userFields = fields.extractPrefixed(this.asPrefix(PublicDmpUser._user));
Map<UUID, PublicUserInfo> userItemsMap = new HashMap<>(); //TODO
FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(PublicDmpUser._dmp));
Map<UUID, PublicDmp> dmpItemsMap = this.collectDmps(dmpFields, data);
List<PublicDmpUser> models = new ArrayList<>();
for (DmpUserEntity d : data) {
PublicDmpUser m = new PublicDmpUser();
if (fields.hasField(this.asIndexer(PublicDmpUser._id))) m.setId(d.getId());
if (fields.hasField(this.asIndexer(PublicDmpUser._role))) m.setRole(d.getRole());
if (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getUser())) m.setUser(userItemsMap.get(d.getUser()));
if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmp())) m.setDmp(dmpItemsMap.get(d.getDmp()));
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
private Map<UUID, PublicDmp> collectDmps(FieldSet fields, List<DmpUserEntity> data) throws MyApplicationException {
if (fields.isEmpty() || data.isEmpty())
return null;
this.logger.debug("checking related - {}", PublicDmp.class.getSimpleName());
Map<UUID, PublicDmp> itemMap;
if (!fields.hasOtherField(this.asIndexer(PublicDmp._id))) {
itemMap = this.asEmpty(
data.stream().map(DmpUserEntity::getDmp).distinct().collect(Collectors.toList()),
x -> {
PublicDmp item = new PublicDmp();
item.setId(x);
return item;
},
PublicDmp::getId);
} else {
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PublicDmp._id);
DmpQuery q = this.queryFactory.query(DmpQuery.class).authorize(this.authorize).ids(data.stream().map(DmpUserEntity::getDmp).distinct().collect(Collectors.toList()));
itemMap = this.builderFactory.builder(PublicDmpBuilder.class).authorize(this.authorize).asForeignKey(q, clone, PublicDmp::getId);
}
if (!fields.hasField(PublicDmp._id)) {
itemMap.values().stream().filter(Objects::nonNull).peek(x -> x.setId(null)).collect(Collectors.toList());
}
return itemMap;
}
}

View File

@ -0,0 +1,56 @@
package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.ReferenceEntity;
import eu.eudat.model.PublicReference;
import gr.cite.tools.exception.MyApplicationException;
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.*;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PublicReferenceBuilder extends BaseBuilder<PublicReference, ReferenceEntity>{
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
public PublicReferenceBuilder(
ConventionService conventionService) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicReferenceBuilder.class)));
}
public PublicReferenceBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<PublicReference> build(FieldSet fields, List<ReferenceEntity> 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<>();
List<PublicReference> models = new ArrayList<>();
for (ReferenceEntity d : data) {
PublicReference m = new PublicReference();
if (fields.hasField(this.asIndexer(PublicReference._id))) m.setId(d.getId());
if (fields.hasField(this.asIndexer(PublicReference._label))) m.setLabel(d.getLabel());
if (fields.hasField(this.asIndexer(PublicReference._reference))) m.setReference(d.getReference());
if (fields.hasField(this.asIndexer(PublicReference._description))) m.setDescription(d.getDescription());
if (fields.hasField(this.asIndexer(PublicReference._type))) m.setType(d.getType());
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
}

View File

@ -2,6 +2,7 @@ package eu.eudat.model.censorship;
import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.DmpDescriptionTemplate;
import eu.eudat.model.DmpReference;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory;
@ -38,11 +39,11 @@ public class DmpDescriptionTemplateCensor extends BaseCensor{
if (fields == null || fields.isEmpty())
return;
this.authService.authorizeForce(Permission.BrowseDmpReference);
FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(DmpReference._dmp));
this.authService.authorizeForce(Permission.BrowseDescription);
FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(DmpDescriptionTemplate._dmp));
this.censorFactory.censor(DmpCensor.class).censor(dmpFields, userId);
FieldSet referenceFields = fields.extractPrefixed(this.asIndexerPrefix(DmpReference._reference));
this.censorFactory.censor(ReferenceCensor.class).censor(referenceFields, userId);
FieldSet descriptionTemplateFields = fields.extractPrefixed(this.asIndexerPrefix(DmpDescriptionTemplate._descriptionTemplate));
this.censorFactory.censor(DescriptionTemplateCensor.class).censor(descriptionTemplateFields, userId);
}
}

View File

@ -39,10 +39,10 @@ public class DmpReferenceCensor extends BaseCensor {
return;
this.authService.authorizeForce(Permission.BrowseDmpDescriptionTemplate);
FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(DmpDescriptionTemplate._dmp));
FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(DmpReference._dmp));
this.censorFactory.censor(DmpCensor.class).censor(dmpFields, userId);
FieldSet templateFields = fields.extractPrefixed(this.asIndexerPrefix(DmpDescriptionTemplate._descriptionTemplate));
this.censorFactory.censor(DescriptionTemplateCensor.class).censor(templateFields, userId);
FieldSet templateFields = fields.extractPrefixed(this.asIndexerPrefix(DmpReference._reference));
this.censorFactory.censor(ReferenceCensor.class).censor(templateFields, userId);
}
}

View File

@ -0,0 +1,47 @@
package eu.eudat.model.censorship;
import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.PublicDescription;
import eu.eudat.model.censorship.descriptionproperties.PropertyDefinitionCensor;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PublicDescriptionCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PublicDescriptionCensor.class));
protected final AuthorizationService authService;
protected final CensorFactory censorFactory;
public PublicDescriptionCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) {
super(conventionService);
this.authService = authService;
this.censorFactory = censorFactory;
}
public void censor(FieldSet fields) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorizeForce(Permission.PublicBrowseDescription);
FieldSet dmpDescriptionTemplateFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDescription._dmpDescriptionTemplate));
this.censorFactory.censor(PublicDmpDescriptionTemplateCensor.class).censor(dmpDescriptionTemplateFields);
}
}

View File

@ -0,0 +1,42 @@
package eu.eudat.model.censorship;
import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.PublicDescriptionTemplate;
import eu.eudat.model.censorship.descriptiontemplatedefinition.DefinitionCensor;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PublicDescriptionTemplateCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PublicDescriptionTemplateCensor.class));
protected final AuthorizationService authService;
protected final CensorFactory censorFactory;
public PublicDescriptionTemplateCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) {
super(conventionService);
this.authService = authService;
this.censorFactory = censorFactory;
}
public void censor(FieldSet fields) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorizeForce(Permission.PublicBrowseDescriptionTemplate);
}
}

View File

@ -0,0 +1,49 @@
package eu.eudat.model.censorship;
import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.PublicDmp;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PublicDmpCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PublicDmpCensor.class));
protected final AuthorizationService authService;
protected final CensorFactory censorFactory;
public PublicDmpCensor(ConventionService conventionService,
AuthorizationService authService,
CensorFactory censorFactory) {
super(conventionService);
this.authService = authService;
this.censorFactory = censorFactory;
}
public void censor(FieldSet fields) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (fields.isEmpty())
return;
this.authService.authorizeForce(Permission.PublicBrowseDmp);
FieldSet dmpDescriptionsFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDmp._users));
this.censorFactory.censor(PublicDmpUserCensor.class).censor(dmpDescriptionsFields);
FieldSet dmpReferencesFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDmp._dmpReferences));
this.censorFactory.censor(PublicDmpReferenceCensor.class).censor(dmpReferencesFields);
}
}

View File

@ -0,0 +1,50 @@
package eu.eudat.model.censorship;
import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.DmpDescriptionTemplate;
import eu.eudat.model.DmpReference;
import eu.eudat.model.PublicDmpDescriptionTemplate;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PublicDmpDescriptionTemplateCensor extends BaseCensor{
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PublicDmpDescriptionTemplateCensor.class));
protected final AuthorizationService authService;
protected final CensorFactory censorFactory;
public PublicDmpDescriptionTemplateCensor(ConventionService conventionService,
AuthorizationService authService,
CensorFactory censorFactory) {
super(conventionService);
this.authService = authService;
this.censorFactory = censorFactory;
}
public void censor(FieldSet fields) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorizeForce(Permission.PublicBrowseDescription);
FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDmpDescriptionTemplate._dmp));
this.censorFactory.censor(PublicDmpCensor.class).censor(dmpFields);
FieldSet descriptionTemplateFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDmpDescriptionTemplate._descriptionTemplate));
this.censorFactory.censor(PublicDescriptionTemplateCensor.class).censor(descriptionTemplateFields);
}
}

View File

@ -0,0 +1,49 @@
package eu.eudat.model.censorship;
import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.DmpDescriptionTemplate;
import eu.eudat.model.PublicDmpDescriptionTemplate;
import eu.eudat.model.PublicDmpReference;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PublicDmpReferenceCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PublicDmpReferenceCensor.class));
protected final AuthorizationService authService;
protected final CensorFactory censorFactory;
public PublicDmpReferenceCensor(ConventionService conventionService,
AuthorizationService authService,
CensorFactory censorFactory) {
super(conventionService);
this.authService = authService;
this.censorFactory = censorFactory;
}
public void censor(FieldSet fields) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorizeForce(Permission.PublicBrowseDmpReference);
FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDmpReference._dmp));
this.censorFactory.censor(PublicDmpCensor.class).censor(dmpFields);
FieldSet templateFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDmpReference._reference));
this.censorFactory.censor(PublicReferenceCensor.class).censor(templateFields);
}
}

View File

@ -0,0 +1,46 @@
package eu.eudat.model.censorship;
import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.DmpUser;
import eu.eudat.model.PublicDmpUser;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PublicDmpUserCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PublicDmpUserCensor.class));
protected final AuthorizationService authService;
protected final CensorFactory censorFactory;
public PublicDmpUserCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) {
super(conventionService);
this.authService = authService;
this.censorFactory = censorFactory;
}
public void censor(FieldSet fields) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorizeForce(Permission.PublicBrowseDmpUser);
FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDmpUser._dmp));
this.censorFactory.censor(PublicDmpCensor.class).censor(dmpFields);
FieldSet userFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDmpUser._user));
this.censorFactory.censor(PublicUserInfoCensor.class).censor(userFields);
}
}

View File

@ -0,0 +1,44 @@
package eu.eudat.model.censorship;
import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.Reference;
import eu.eudat.model.censorship.referencedefinition.DefinitionCensor;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PublicReferenceCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PublicReferenceCensor.class));
protected final AuthorizationService authService;
protected final CensorFactory censorFactory;
public PublicReferenceCensor(ConventionService conventionService,
AuthorizationService authService,
CensorFactory censorFactory) {
super(conventionService);
this.authService = authService;
this.censorFactory = censorFactory;
}
public void censor(FieldSet fields) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorizeForce(Permission.PublicBrowseReference);
}
}

View File

@ -0,0 +1,42 @@
package eu.eudat.model.censorship;
import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PublicUserInfoCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PublicUserInfoCensor.class));
protected final AuthorizationService authService;
protected final CensorFactory censorFactory;
public PublicUserInfoCensor(ConventionService conventionService,
AuthorizationService authService,
CensorFactory censorFactory) {
super(conventionService);
this.authService = authService;
this.censorFactory = censorFactory;
}
public void censor(FieldSet fields) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorizeForce(Permission.PublicBrowseUser);
}
}

View File

@ -28,9 +28,7 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
private String like;
private Collection<UUID> ids;
private Collection<UUID> dmpDescriptionTemplateIds;
private DmpDescriptionTemplateQuery dmpDescriptionTemplateQuery;
private Collection<UUID> excludedIds;
private Collection<IsActive> isActives;

View File

@ -44,6 +44,44 @@ permissions:
######
# public
PublicBrowseDescription:
roles: [ ]
clients: [ ]
allowAnonymous: true
allowAuthenticated: true
PublicBrowseDescriptionTemplate:
roles: [ ]
clients: [ ]
allowAnonymous: true
allowAuthenticated: true
PublicBrowseDmp:
roles: [ ]
clients: [ ]
allowAnonymous: true
allowAuthenticated: true
PublicBrowseDmpReference:
roles: [ ]
clients: [ ]
allowAnonymous: true
allowAuthenticated: true
PublicBrowseDmpUser:
roles: [ ]
clients: [ ]
allowAnonymous: true
allowAuthenticated: true
PublicBrowseReference:
roles: [ ]
clients: [ ]
allowAnonymous: true
allowAuthenticated: true
PublicBrowseUser:
roles: [ ]
clients: [ ]
allowAnonymous: true
allowAuthenticated: true
# Language
BrowseLanguage: