description refactor
This commit is contained in:
parent
05f73889be
commit
1469e22185
|
@ -81,6 +81,11 @@ public final class Permission {
|
||||||
public static String EditReference = "EditReference";
|
public static String EditReference = "EditReference";
|
||||||
public static String DeleteReference = "DeleteReference";
|
public static String DeleteReference = "DeleteReference";
|
||||||
|
|
||||||
|
//Tag
|
||||||
|
public static String BrowseTag = "BrowseTag";
|
||||||
|
public static String EditTag = "EditTag";
|
||||||
|
public static String DeleteTag = "DeleteTag";
|
||||||
|
|
||||||
//DmpReference
|
//DmpReference
|
||||||
public static String BrowseDmpReference = "BrowseDmpReference";
|
public static String BrowseDmpReference = "BrowseDmpReference";
|
||||||
public static String EditDmpReference = "EditDmpReference";
|
public static String EditDmpReference = "EditDmpReference";
|
||||||
|
|
|
@ -32,9 +32,9 @@ public class DescriptionEntity implements DataEntity<DescriptionEntity, UUID> {
|
||||||
public static final String _label = "label";
|
public static final String _label = "label";
|
||||||
|
|
||||||
@Column(name = "dmp", columnDefinition = "uuid", nullable = false)
|
@Column(name = "dmp", columnDefinition = "uuid", nullable = false)
|
||||||
private UUID dmp;
|
private UUID dmpId;
|
||||||
|
|
||||||
public static final String _dmp = "dmp";
|
public static final String _dmpId = "dmpId";
|
||||||
|
|
||||||
@Column(name = "properties")
|
@Column(name = "properties")
|
||||||
private String properties;
|
private String properties;
|
||||||
|
@ -42,9 +42,9 @@ public class DescriptionEntity implements DataEntity<DescriptionEntity, UUID> {
|
||||||
public static final String _properties = "properties";
|
public static final String _properties = "properties";
|
||||||
|
|
||||||
@Column(name = "description_template", columnDefinition = "uuid", nullable = false)
|
@Column(name = "description_template", columnDefinition = "uuid", nullable = false)
|
||||||
private UUID descriptionTemplate;
|
private UUID descriptionTemplateId;
|
||||||
|
|
||||||
public static final String _descriptionTemplate = "descriptionTemplate";
|
public static final String _descriptionTemplateId = "descriptionTemplateId";
|
||||||
|
|
||||||
@Column(name = "status", nullable = false)
|
@Column(name = "status", nullable = false)
|
||||||
@Convert(converter = DescriptionStatusConverter.class)
|
@Convert(converter = DescriptionStatusConverter.class)
|
||||||
|
@ -80,14 +80,14 @@ public class DescriptionEntity implements DataEntity<DescriptionEntity, UUID> {
|
||||||
public static final String _finalizedAt = "finalizedAt";
|
public static final String _finalizedAt = "finalizedAt";
|
||||||
|
|
||||||
@Column(name = "created_by", columnDefinition = "uuid", nullable = false)
|
@Column(name = "created_by", columnDefinition = "uuid", nullable = false)
|
||||||
private UUID createdBy;
|
private UUID createdById;
|
||||||
|
|
||||||
public static final String _createdBy = "createdBy";
|
public static final String _createdById = "createdById";
|
||||||
|
|
||||||
@Column(name = "dmp_description_template", columnDefinition = "uuid", nullable = false)
|
@Column(name = "dmp_description_template", columnDefinition = "uuid", nullable = false)
|
||||||
private UUID dmpDescriptionTemplate;
|
private UUID dmpDescriptionTemplateId;
|
||||||
|
|
||||||
public static final String _dmpDescriptionTemplate = "dmpDescriptionTemplate";
|
public static final String _dmpDescriptionTemplateId = "dmpDescriptionTemplateId";
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -105,12 +105,12 @@ public class DescriptionEntity implements DataEntity<DescriptionEntity, UUID> {
|
||||||
this.label = label;
|
this.label = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getDmp() {
|
public UUID getDmpId() {
|
||||||
return dmp;
|
return dmpId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDmp(UUID dmp) {
|
public void setDmpId(UUID dmpId) {
|
||||||
this.dmp = dmp;
|
this.dmpId = dmpId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProperties() {
|
public String getProperties() {
|
||||||
|
@ -121,12 +121,12 @@ public class DescriptionEntity implements DataEntity<DescriptionEntity, UUID> {
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getDescriptionTemplate() {
|
public UUID getDescriptionTemplateId() {
|
||||||
return descriptionTemplate;
|
return descriptionTemplateId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescriptionTemplate(UUID descriptionTemplate) {
|
public void setDescriptionTemplateId(UUID descriptionTemplateId) {
|
||||||
this.descriptionTemplate = descriptionTemplate;
|
this.descriptionTemplateId = descriptionTemplateId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DescriptionStatus getStatus() {
|
public DescriptionStatus getStatus() {
|
||||||
|
@ -177,20 +177,20 @@ public class DescriptionEntity implements DataEntity<DescriptionEntity, UUID> {
|
||||||
this.finalizedAt = finalizedAt;
|
this.finalizedAt = finalizedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getCreatedBy() {
|
public UUID getCreatedById() {
|
||||||
return createdBy;
|
return createdById;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCreatedBy(UUID createdBy) {
|
public void setCreatedById(UUID createdById) {
|
||||||
this.createdBy = createdBy;
|
this.createdById = createdById;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getDmpDescriptionTemplate() {
|
public UUID getDmpDescriptionTemplateId() {
|
||||||
return dmpDescriptionTemplate;
|
return dmpDescriptionTemplateId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDmpDescriptionTemplate(UUID dmpDescriptionTemplate) {
|
public void setDmpDescriptionTemplateId(UUID dmpDescriptionTemplateId) {
|
||||||
this.dmpDescriptionTemplate = dmpDescriptionTemplate;
|
this.dmpDescriptionTemplateId = dmpDescriptionTemplateId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -19,14 +19,14 @@ public class DescriptionTagEntity {
|
||||||
public static final String _id = "id";
|
public static final String _id = "id";
|
||||||
|
|
||||||
@Column(name = "description", columnDefinition = "uuid", nullable = false)
|
@Column(name = "description", columnDefinition = "uuid", nullable = false)
|
||||||
private UUID description;
|
private UUID descriptionId;
|
||||||
|
|
||||||
public static final String _description = "description";
|
public static final String _descriptionId = "descriptionId";
|
||||||
|
|
||||||
@Column(name = "tag", columnDefinition = "uuid", nullable = false)
|
@Column(name = "tag", columnDefinition = "uuid", nullable = false)
|
||||||
private UUID tag;
|
private UUID tagId;
|
||||||
|
|
||||||
public static final String _tag = "tag";
|
public static final String _tagId = "tagId";
|
||||||
|
|
||||||
@Column(name = "created_at")
|
@Column(name = "created_at")
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
@Convert(converter = DateToUTCConverter.class)
|
||||||
|
@ -54,20 +54,20 @@ public class DescriptionTagEntity {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getDescription() {
|
public UUID getDescriptionId() {
|
||||||
return description;
|
return descriptionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(UUID description) {
|
public void setDescriptionId(UUID descriptionId) {
|
||||||
this.description = description;
|
this.descriptionId = descriptionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getTag() {
|
public UUID getTagId() {
|
||||||
return tag;
|
return tagId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTag(UUID tag) {
|
public void setTagId(UUID tagId) {
|
||||||
this.tag = tag;
|
this.tagId = tagId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Instant getCreatedAt() {
|
public Instant getCreatedAt() {
|
||||||
|
|
|
@ -67,8 +67,8 @@ public class DescriptionTemplateEntity implements DataEntity<DescriptionTemplate
|
||||||
public static final String _language = "language";
|
public static final String _language = "language";
|
||||||
|
|
||||||
@Column(name = "\"type\"", nullable = false)
|
@Column(name = "\"type\"", nullable = false)
|
||||||
private UUID type;
|
private UUID typeId;
|
||||||
public static final String _type = "type";
|
public static final String _typeId = "typeId";
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
|
@ -141,12 +141,12 @@ public class DescriptionTemplateEntity implements DataEntity<DescriptionTemplate
|
||||||
this.updatedAt = updatedAt;
|
this.updatedAt = updatedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getType() {
|
public UUID getTypeId() {
|
||||||
return type;
|
return typeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(UUID type) {
|
public void setTypeId(UUID typeId) {
|
||||||
this.type = type;
|
this.typeId = typeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class Description {
|
||||||
|
|
||||||
public static final String _descriptionTags = "descriptionTags";
|
public static final String _descriptionTags = "descriptionTags";
|
||||||
|
|
||||||
private UUID dmpDescriptionTemplate;
|
private DmpDescriptionTemplate dmpDescriptionTemplate;
|
||||||
|
|
||||||
public static final String _dmpDescriptionTemplate = "dmpDescriptionTemplate";
|
public static final String _dmpDescriptionTemplate = "dmpDescriptionTemplate";
|
||||||
|
|
||||||
|
@ -186,11 +186,11 @@ public class Description {
|
||||||
this.createdAt = createdAt;
|
this.createdAt = createdAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getDmpDescriptionTemplate() {
|
public DmpDescriptionTemplate getDmpDescriptionTemplate() {
|
||||||
return dmpDescriptionTemplate;
|
return dmpDescriptionTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDmpDescriptionTemplate(UUID dmpDescriptionTemplate) {
|
public void setDmpDescriptionTemplate(DmpDescriptionTemplate dmpDescriptionTemplate) {
|
||||||
this.dmpDescriptionTemplate = dmpDescriptionTemplate;
|
this.dmpDescriptionTemplate = dmpDescriptionTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package eu.eudat.model.builder;
|
package eu.eudat.model.builder;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.JsonHandlingService;
|
||||||
|
import eu.eudat.commons.types.description.PropertyDefinitionEntity;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.model.Description;
|
import eu.eudat.model.*;
|
||||||
import eu.eudat.model.DescriptionReference;
|
import eu.eudat.model.builder.descriptionpropertiesdefinition.PropertyDefinitionBuilder;
|
||||||
import eu.eudat.model.Dmp;
|
import eu.eudat.query.*;
|
||||||
import eu.eudat.model.DmpReference;
|
|
||||||
import eu.eudat.query.DescriptionReferenceQuery;
|
|
||||||
import eu.eudat.query.DmpQuery;
|
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
@ -32,6 +32,7 @@ public class DescriptionBuilder extends BaseBuilder<Description, DescriptionEnti
|
||||||
private final QueryFactory queryFactory;
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
|
private final JsonHandlingService jsonHandlingService;
|
||||||
|
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@ -39,10 +40,11 @@ public class DescriptionBuilder extends BaseBuilder<Description, DescriptionEnti
|
||||||
public DescriptionBuilder(
|
public DescriptionBuilder(
|
||||||
ConventionService conventionService,
|
ConventionService conventionService,
|
||||||
QueryFactory queryFactory,
|
QueryFactory queryFactory,
|
||||||
BuilderFactory builderFactory) {
|
BuilderFactory builderFactory, JsonHandlingService jsonHandlingService) {
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionBuilder.class)));
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionBuilder.class)));
|
||||||
this.queryFactory = queryFactory;
|
this.queryFactory = queryFactory;
|
||||||
this.builderFactory = builderFactory;
|
this.builderFactory = builderFactory;
|
||||||
|
this.jsonHandlingService = jsonHandlingService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DescriptionBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
public DescriptionBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
@ -60,43 +62,41 @@ public class DescriptionBuilder extends BaseBuilder<Description, DescriptionEnti
|
||||||
FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(Description._dmp));
|
FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(Description._dmp));
|
||||||
Map<UUID, Dmp> dmpItemsMap = this.collectDmps(dmpFields, data);
|
Map<UUID, Dmp> dmpItemsMap = this.collectDmps(dmpFields, data);
|
||||||
|
|
||||||
|
FieldSet descriptionTemplateFields = fields.extractPrefixed(this.asPrefix(Description._descriptionTemplate));
|
||||||
|
Map<UUID, DescriptionTemplate> descriptionTemplateItemsMap = this.collectDescriptionTemplates(descriptionTemplateFields, data);
|
||||||
|
|
||||||
|
FieldSet dmpDescriptionTemplateFields = fields.extractPrefixed(this.asPrefix(Description._dmpDescriptionTemplate));
|
||||||
|
Map<UUID, DmpDescriptionTemplate> dmpDescriptionTemplateItemsMap = this.collectDmpDescriptionTemplates(dmpDescriptionTemplateFields, data);
|
||||||
|
|
||||||
FieldSet descriptionReferencesFields = fields.extractPrefixed(this.asPrefix(Description._descriptionReferences));
|
FieldSet descriptionReferencesFields = fields.extractPrefixed(this.asPrefix(Description._descriptionReferences));
|
||||||
Map<UUID, List<DescriptionReference>> descriptionReferencesMap = this.collectDescriptionReferences(descriptionReferencesFields, data);
|
Map<UUID, List<DescriptionReference>> descriptionReferencesMap = this.collectDescriptionReferences(descriptionReferencesFields, data);
|
||||||
|
|
||||||
|
FieldSet descriptionTagsFields = fields.extractPrefixed(this.asPrefix(Description._descriptionTags));
|
||||||
|
Map<UUID, List<DescriptionTag>> descriptionTagsMap = this.collectDescriptionTags(descriptionTagsFields, data);
|
||||||
|
|
||||||
|
FieldSet definitionPropertiesFields = fields.extractPrefixed(this.asPrefix(Description._properties));
|
||||||
List<Description> models = new ArrayList<>();
|
List<Description> models = new ArrayList<>();
|
||||||
for (DescriptionEntity d : data) {
|
for (DescriptionEntity d : data) {
|
||||||
Description m = new Description();
|
Description m = new Description();
|
||||||
if (fields.hasField(this.asIndexer(Description._id)))
|
if (fields.hasField(this.asIndexer(Description._id))) m.setId(d.getId());
|
||||||
m.setId(d.getId());
|
if (fields.hasField(this.asIndexer(Description._label))) m.setLabel(d.getLabel());
|
||||||
if (fields.hasField(this.asIndexer(Description._label)))
|
if (fields.hasField(this.asIndexer(Description._status))) m.setStatus(d.getStatus());
|
||||||
m.setLabel(d.getLabel());
|
if (fields.hasField(this.asIndexer(Description._description))) m.setDescription(d.getDescription());
|
||||||
// if (fields.hasField(this.asIndexer(Description._properties)))
|
if (fields.hasField(this.asIndexer(Description._createdBy))) m.setCreatedBy(d.getCreatedById());
|
||||||
// m.setProperties(d.getProperties());
|
if (fields.hasField(this.asIndexer(Description._createdAt))) m.setCreatedAt(d.getCreatedAt());
|
||||||
// if (fields.hasField(this.asIndexer(Description._profile)))
|
if (fields.hasField(this.asIndexer(Description._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
|
||||||
// m.setProfile(d.getDescriptionTemplate());
|
if (fields.hasField(this.asIndexer(Description._isActive))) m.setIsActive(d.getIsActive());
|
||||||
if (fields.hasField(this.asIndexer(Description._status)))
|
if (fields.hasField(this.asIndexer(Description._finalizedAt))) m.setFinalizedAt(d.getFinalizedAt());
|
||||||
m.setStatus(d.getStatus());
|
if (fields.hasField(this.asIndexer(Description._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
|
||||||
if (fields.hasField(this.asIndexer(Description._description)))
|
if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) m.setDmp(dmpItemsMap.get(d.getDmpId()));
|
||||||
m.setDescription(d.getDescription());
|
if (!descriptionTemplateFields.isEmpty() && descriptionTemplateItemsMap != null && descriptionTemplateItemsMap.containsKey(d.getDmpId())) m.setDescriptionTemplate(descriptionTemplateItemsMap.get(d.getDescriptionTemplateId()));
|
||||||
// if (fields.hasField(this.asIndexer(Description._creator)))
|
if (!dmpDescriptionTemplateFields.isEmpty() && dmpDescriptionTemplateItemsMap != null && dmpDescriptionTemplateItemsMap.containsKey(d.getDmpId())) m.setDmpDescriptionTemplate(dmpDescriptionTemplateItemsMap.get(d.getDmpDescriptionTemplateId()));
|
||||||
// m.setCreatedBy(d.getDmpDescriptionTemplate());
|
if (!descriptionReferencesFields.isEmpty() && descriptionReferencesMap != null && descriptionReferencesMap.containsKey(d.getId())) m.setDescriptionReferences(descriptionReferencesMap.get(d.getId()));
|
||||||
// if (fields.hasField(this.asIndexer(Description._createdAt)))
|
if (!descriptionTagsFields.isEmpty() && descriptionTagsMap != null && descriptionTagsMap.containsKey(d.getId())) m.setDescriptionTags(descriptionTagsMap.get(d.getId()));
|
||||||
// m.setCreatedAt(d.getCreatedAt());
|
if (!definitionPropertiesFields.isEmpty() && d.getProperties() != null){
|
||||||
if (fields.hasField(this.asIndexer(Description._updatedAt)))
|
PropertyDefinitionEntity propertyDefinition = this.jsonHandlingService.fromJsonSafe(PropertyDefinitionEntity.class, d.getProperties());
|
||||||
m.setUpdatedAt(d.getUpdatedAt());
|
m.setProperties(this.builderFactory.builder(PropertyDefinitionBuilder.class).authorize(this.authorize).build(definitionPropertiesFields, propertyDefinition));
|
||||||
if (fields.hasField(this.asIndexer(Description._isActive)))
|
}
|
||||||
m.setIsActive(d.getIsActive());
|
|
||||||
if (fields.hasField(this.asIndexer(Description._finalizedAt)))
|
|
||||||
m.setFinalizedAt(d.getFinalizedAt());
|
|
||||||
if (fields.hasField(this.asIndexer(Description._hash)))
|
|
||||||
m.setHash(this.hashValue(d.getUpdatedAt()));
|
|
||||||
|
|
||||||
if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmp()))
|
|
||||||
m.setDmp(dmpItemsMap.get(d.getDmp()));
|
|
||||||
|
|
||||||
if (!descriptionReferencesFields.isEmpty() && descriptionReferencesMap != null && descriptionReferencesMap.containsKey(d.getId()))
|
|
||||||
m.setDescriptionReferences(descriptionReferencesMap.get(d.getId()));
|
|
||||||
|
|
||||||
models.add(m);
|
models.add(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ public class DescriptionBuilder extends BaseBuilder<Description, DescriptionEnti
|
||||||
Map<UUID, Dmp> itemMap;
|
Map<UUID, Dmp> itemMap;
|
||||||
if (!fields.hasOtherField(this.asIndexer(Dmp._id))) {
|
if (!fields.hasOtherField(this.asIndexer(Dmp._id))) {
|
||||||
itemMap = this.asEmpty(
|
itemMap = this.asEmpty(
|
||||||
data.stream().map(DescriptionEntity::getDmp).distinct().collect(Collectors.toList()),
|
data.stream().map(DescriptionEntity::getDmpId).distinct().collect(Collectors.toList()),
|
||||||
x -> {
|
x -> {
|
||||||
Dmp item = new Dmp();
|
Dmp item = new Dmp();
|
||||||
item.setId(x);
|
item.setId(x);
|
||||||
|
@ -122,7 +122,7 @@ public class DescriptionBuilder extends BaseBuilder<Description, DescriptionEnti
|
||||||
Dmp::getId);
|
Dmp::getId);
|
||||||
} else {
|
} else {
|
||||||
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Dmp._id);
|
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Dmp._id);
|
||||||
DmpQuery q = this.queryFactory.query(DmpQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDmp).distinct().collect(Collectors.toList()));
|
DmpQuery q = this.queryFactory.query(DmpQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDmpId).distinct().collect(Collectors.toList()));
|
||||||
itemMap = this.builderFactory.builder(DmpBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Dmp::getId);
|
itemMap = this.builderFactory.builder(DmpBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Dmp::getId);
|
||||||
}
|
}
|
||||||
if (!fields.hasField(Dmp._id)) {
|
if (!fields.hasField(Dmp._id)) {
|
||||||
|
@ -135,6 +135,66 @@ public class DescriptionBuilder extends BaseBuilder<Description, DescriptionEnti
|
||||||
return itemMap;
|
return itemMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<UUID, DescriptionTemplate> collectDescriptionTemplates(FieldSet fields, List<DescriptionEntity> data) throws MyApplicationException {
|
||||||
|
if (fields.isEmpty() || data.isEmpty())
|
||||||
|
return null;
|
||||||
|
this.logger.debug("checking related - {}", DescriptionTemplate.class.getSimpleName());
|
||||||
|
|
||||||
|
Map<UUID, DescriptionTemplate> itemMap;
|
||||||
|
if (!fields.hasOtherField(this.asIndexer(DescriptionTemplate._id))) {
|
||||||
|
itemMap = this.asEmpty(
|
||||||
|
data.stream().map(DescriptionEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList()),
|
||||||
|
x -> {
|
||||||
|
DescriptionTemplate item = new DescriptionTemplate();
|
||||||
|
item.setId(x);
|
||||||
|
return item;
|
||||||
|
},
|
||||||
|
DescriptionTemplate::getId);
|
||||||
|
} else {
|
||||||
|
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(DescriptionTemplate._id);
|
||||||
|
DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList()));
|
||||||
|
itemMap = this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(this.authorize).asForeignKey(q, clone, DescriptionTemplate::getId);
|
||||||
|
}
|
||||||
|
if (!fields.hasField(DescriptionTemplate._id)) {
|
||||||
|
itemMap.forEach((id, item) -> {
|
||||||
|
if (item != null)
|
||||||
|
item.setId(null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<UUID, DmpDescriptionTemplate> collectDmpDescriptionTemplates(FieldSet fields, List<DescriptionEntity> data) throws MyApplicationException {
|
||||||
|
if (fields.isEmpty() || data.isEmpty())
|
||||||
|
return null;
|
||||||
|
this.logger.debug("checking related - {}", DmpDescriptionTemplate.class.getSimpleName());
|
||||||
|
|
||||||
|
Map<UUID, DmpDescriptionTemplate> itemMap;
|
||||||
|
if (!fields.hasOtherField(this.asIndexer(DmpDescriptionTemplate._id))) {
|
||||||
|
itemMap = this.asEmpty(
|
||||||
|
data.stream().map(DescriptionEntity::getDmpDescriptionTemplateId).distinct().collect(Collectors.toList()),
|
||||||
|
x -> {
|
||||||
|
DmpDescriptionTemplate item = new DmpDescriptionTemplate();
|
||||||
|
item.setId(x);
|
||||||
|
return item;
|
||||||
|
},
|
||||||
|
DmpDescriptionTemplate::getId);
|
||||||
|
} else {
|
||||||
|
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(DmpDescriptionTemplate._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(DmpDescriptionTemplateBuilder.class).authorize(this.authorize).asForeignKey(q, clone, DmpDescriptionTemplate::getId);
|
||||||
|
}
|
||||||
|
if (!fields.hasField(DmpDescriptionTemplate._id)) {
|
||||||
|
itemMap.forEach((id, item) -> {
|
||||||
|
if (item != null)
|
||||||
|
item.setId(null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
private Map<UUID, List<DescriptionReference>> collectDescriptionReferences(FieldSet fields, List<DescriptionEntity> data) throws MyApplicationException {
|
private Map<UUID, List<DescriptionReference>> collectDescriptionReferences(FieldSet fields, List<DescriptionEntity> data) throws MyApplicationException {
|
||||||
if (fields.isEmpty() || data.isEmpty()) return null;
|
if (fields.isEmpty() || data.isEmpty()) return null;
|
||||||
this.logger.debug("checking related - {}", DescriptionReference.class.getSimpleName());
|
this.logger.debug("checking related - {}", DescriptionReference.class.getSimpleName());
|
||||||
|
@ -144,7 +204,25 @@ public class DescriptionBuilder extends BaseBuilder<Description, DescriptionEnti
|
||||||
DescriptionReferenceQuery query = this.queryFactory.query(DescriptionReferenceQuery.class).authorize(this.authorize).descriptionIds(data.stream().map(DescriptionEntity::getId).distinct().collect(Collectors.toList()));
|
DescriptionReferenceQuery query = this.queryFactory.query(DescriptionReferenceQuery.class).authorize(this.authorize).descriptionIds(data.stream().map(DescriptionEntity::getId).distinct().collect(Collectors.toList()));
|
||||||
itemMap = this.builderFactory.builder(DescriptionReferenceBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDescription().getId());
|
itemMap = this.builderFactory.builder(DescriptionReferenceBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDescription().getId());
|
||||||
|
|
||||||
if (!fields.hasField(this.asIndexer(DmpReference._dmp, Dmp._id))) {
|
if (!fields.hasField(this.asIndexer(DescriptionReference._description, Description._id))) {
|
||||||
|
itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDescription() != null).peek(x -> {
|
||||||
|
x.getDescription().setId(null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<UUID, List<DescriptionTag>> collectDescriptionTags(FieldSet fields, List<DescriptionEntity> data) throws MyApplicationException {
|
||||||
|
if (fields.isEmpty() || data.isEmpty()) return null;
|
||||||
|
this.logger.debug("checking related - {}", DescriptionTag.class.getSimpleName());
|
||||||
|
|
||||||
|
Map<UUID, List<DescriptionTag>> itemMap;
|
||||||
|
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DescriptionTag._description, Description._id));
|
||||||
|
DescriptionTagQuery query = this.queryFactory.query(DescriptionTagQuery.class).authorize(this.authorize).descriptionIds(data.stream().map(DescriptionEntity::getId).distinct().collect(Collectors.toList()));
|
||||||
|
itemMap = this.builderFactory.builder(DescriptionTagBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDescription().getId());
|
||||||
|
|
||||||
|
if (!fields.hasField(this.asIndexer(DescriptionTag._description, Description._id))) {
|
||||||
itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDescription() != null).peek(x -> {
|
itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDescription() != null).peek(x -> {
|
||||||
x.getDescription().setId(null);
|
x.getDescription().setId(null);
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,143 @@
|
||||||
|
package eu.eudat.model.builder;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.data.DescriptionTagEntity;
|
||||||
|
import eu.eudat.model.Description;
|
||||||
|
import eu.eudat.model.DescriptionTag;
|
||||||
|
import eu.eudat.model.Tag;
|
||||||
|
import eu.eudat.query.DescriptionQuery;
|
||||||
|
import eu.eudat.query.TagQuery;
|
||||||
|
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 DescriptionTagBuilder extends BaseBuilder<DescriptionTag, DescriptionTagEntity> {
|
||||||
|
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public DescriptionTagBuilder(
|
||||||
|
ConventionService conventionService,
|
||||||
|
BuilderFactory builderFactory, QueryFactory queryFactory) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionTagBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionTagBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DescriptionTag> build(FieldSet fields, List<DescriptionTagEntity> 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(DescriptionTag._tag));
|
||||||
|
Map<UUID, Tag> referenceItemsMap = this.collectTags(referenceFields, data);
|
||||||
|
|
||||||
|
FieldSet descriptionFields = fields.extractPrefixed(this.asPrefix(DescriptionTag._description));
|
||||||
|
Map<UUID, Description> descriptionItemsMap = this.collectDescriptions(descriptionFields, data);
|
||||||
|
|
||||||
|
List<DescriptionTag> models = new ArrayList<>();
|
||||||
|
|
||||||
|
for (DescriptionTagEntity d : data) {
|
||||||
|
DescriptionTag m = new DescriptionTag();
|
||||||
|
if (fields.hasField(this.asIndexer(DescriptionTag._id))) m.setId(d.getId());
|
||||||
|
if (fields.hasField(this.asIndexer(DescriptionTag._createdAt))) m.setCreatedAt(d.getCreatedAt());
|
||||||
|
if (fields.hasField(this.asIndexer(DescriptionTag._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
|
||||||
|
if (fields.hasField(this.asIndexer(DescriptionTag._isActive))) m.setIsActive(d.getIsActive());
|
||||||
|
if (!referenceFields.isEmpty() && referenceItemsMap != null && referenceItemsMap.containsKey(d.getTagId())) m.setTag(referenceItemsMap.get(d.getTagId()));
|
||||||
|
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<UUID, Description> collectDescriptions(FieldSet fields, List<DescriptionTagEntity> data) throws MyApplicationException {
|
||||||
|
if (fields.isEmpty() || data.isEmpty())
|
||||||
|
return null;
|
||||||
|
this.logger.debug("checking related - {}", Description.class.getSimpleName());
|
||||||
|
|
||||||
|
Map<UUID, Description> itemMap;
|
||||||
|
if (!fields.hasOtherField(this.asIndexer(Tag._id))) {
|
||||||
|
itemMap = this.asEmpty(
|
||||||
|
data.stream().map(DescriptionTagEntity::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(Tag._id);
|
||||||
|
DescriptionQuery q = this.queryFactory.query(DescriptionQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionTagEntity::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<UUID, Tag> collectTags(FieldSet fields, List<DescriptionTagEntity> data) throws MyApplicationException {
|
||||||
|
if (fields.isEmpty() || data.isEmpty())
|
||||||
|
return null;
|
||||||
|
this.logger.debug("checking related - {}", Tag.class.getSimpleName());
|
||||||
|
|
||||||
|
Map<UUID, Tag> itemMap;
|
||||||
|
if (!fields.hasOtherField(this.asIndexer(Tag._id))) {
|
||||||
|
itemMap = this.asEmpty(
|
||||||
|
data.stream().map(DescriptionTagEntity::getTagId).distinct().collect(Collectors.toList()),
|
||||||
|
x -> {
|
||||||
|
Tag item = new Tag();
|
||||||
|
item.setId(x);
|
||||||
|
return item;
|
||||||
|
},
|
||||||
|
Tag::getId);
|
||||||
|
} else {
|
||||||
|
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Tag._id);
|
||||||
|
TagQuery q = this.queryFactory.query(TagQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionTagEntity::getTagId).distinct().collect(Collectors.toList()));
|
||||||
|
itemMap = this.builderFactory.builder(TagBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Tag::getId);
|
||||||
|
}
|
||||||
|
if (!fields.hasField(Tag._id)) {
|
||||||
|
itemMap.forEach((id, item) -> {
|
||||||
|
if (item != null)
|
||||||
|
item.setId(null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -85,7 +85,7 @@ public class DescriptionTemplateBuilder extends BaseBuilder<DescriptionTemplate,
|
||||||
m.setDefinition(this.builderFactory.builder(DefinitionBuilder.class).authorize(this.authorize).build(definitionFields, definition));
|
m.setDefinition(this.builderFactory.builder(DefinitionBuilder.class).authorize(this.authorize).build(definitionFields, definition));
|
||||||
}
|
}
|
||||||
if (!usersFields.isEmpty() && usersMap != null && usersMap.containsKey(d.getId())) m.setUsers(usersMap.get(d.getId()));
|
if (!usersFields.isEmpty() && usersMap != null && usersMap.containsKey(d.getId())) m.setUsers(usersMap.get(d.getId()));
|
||||||
if (!descriptionTemplateTypeFields.isEmpty() && descriptionTemplateTypeMap != null && descriptionTemplateTypeMap.containsKey(d.getType())) m.setType(descriptionTemplateTypeMap.get(d.getType()));
|
if (!descriptionTemplateTypeFields.isEmpty() && descriptionTemplateTypeMap != null && descriptionTemplateTypeMap.containsKey(d.getTypeId())) m.setType(descriptionTemplateTypeMap.get(d.getTypeId()));
|
||||||
models.add(m);
|
models.add(m);
|
||||||
}
|
}
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
@ -99,7 +99,7 @@ public class DescriptionTemplateBuilder extends BaseBuilder<DescriptionTemplate,
|
||||||
Map<UUID, DescriptionTemplateType> itemMap = null;
|
Map<UUID, DescriptionTemplateType> itemMap = null;
|
||||||
if (!fields.hasOtherField(this.asIndexer(DescriptionTemplateType._id))) {
|
if (!fields.hasOtherField(this.asIndexer(DescriptionTemplateType._id))) {
|
||||||
itemMap = this.asEmpty(
|
itemMap = this.asEmpty(
|
||||||
datas.stream().map(DescriptionTemplateEntity::getType).distinct().collect(Collectors.toList()),
|
datas.stream().map(DescriptionTemplateEntity::getTypeId).distinct().collect(Collectors.toList()),
|
||||||
x -> {
|
x -> {
|
||||||
DescriptionTemplateType item = new DescriptionTemplateType();
|
DescriptionTemplateType item = new DescriptionTemplateType();
|
||||||
item.setId(x);
|
item.setId(x);
|
||||||
|
@ -108,7 +108,7 @@ public class DescriptionTemplateBuilder extends BaseBuilder<DescriptionTemplate,
|
||||||
x -> x.getId());
|
x -> x.getId());
|
||||||
} else {
|
} else {
|
||||||
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(DescriptionTemplateType._id);
|
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(DescriptionTemplateType._id);
|
||||||
DescriptionTemplateTypeQuery q = this.queryFactory.query(DescriptionTemplateTypeQuery.class).ids(datas.stream().map(DescriptionTemplateEntity::getType).distinct().collect(Collectors.toList()));
|
DescriptionTemplateTypeQuery q = this.queryFactory.query(DescriptionTemplateTypeQuery.class).ids(datas.stream().map(DescriptionTemplateEntity::getTypeId).distinct().collect(Collectors.toList()));
|
||||||
itemMap = this.builderFactory.builder(DescriptionTemplateTypeBuilder.class).asForeignKey(q, clone, DescriptionTemplateType::getId);
|
itemMap = this.builderFactory.builder(DescriptionTemplateTypeBuilder.class).asForeignKey(q, clone, DescriptionTemplateType::getId);
|
||||||
}
|
}
|
||||||
if (!fields.hasField(DescriptionTemplateType._id)) {
|
if (!fields.hasField(DescriptionTemplateType._id)) {
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
package eu.eudat.model.builder;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.data.TagEntity;
|
||||||
|
import eu.eudat.model.Tag;
|
||||||
|
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 TagBuilder extends BaseBuilder<Tag, TagEntity>{
|
||||||
|
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public TagBuilder(
|
||||||
|
ConventionService conventionService) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(TagBuilder.class)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public TagBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Tag> build(FieldSet fields, List<TagEntity> 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<Tag> models = new ArrayList<>();
|
||||||
|
for (TagEntity d : data) {
|
||||||
|
Tag m = new Tag();
|
||||||
|
if (fields.hasField(this.asIndexer(Tag._id))) m.setId(d.getId());
|
||||||
|
if (fields.hasField(this.asIndexer(Tag._label))) m.setLabel(d.getLabel());
|
||||||
|
if (fields.hasField(this.asIndexer(Tag._createdAt))) m.setCreatedAt(d.getCreatedAt());
|
||||||
|
if (fields.hasField(this.asIndexer(Tag._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
|
||||||
|
if (fields.hasField(this.asIndexer(Tag._isActive))) m.setIsActive(d.getIsActive());
|
||||||
|
if (fields.hasField(this.asIndexer(Tag._createdBy))) m.setCreatedBy(d.getCreatedBy());
|
||||||
|
models.add(m);
|
||||||
|
}
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
package eu.eudat.model.builder.descriptionpropertiesdefinition;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.types.description.FieldEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.builder.BaseBuilder;
|
||||||
|
import eu.eudat.model.descriptionproperties.Field;
|
||||||
|
import eu.eudat.service.fielddatahelper.FieldDataHelperServiceProvider;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
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("descriptionpropertiesdefinitionFieldbuilder")
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class FieldBuilder extends BaseBuilder<Field, FieldEntity> {
|
||||||
|
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private final FieldDataHelperServiceProvider fieldDataHelperServiceProvider;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public FieldBuilder(
|
||||||
|
ConventionService conventionService, BuilderFactory builderFactory, FieldDataHelperServiceProvider fieldDataHelperServiceProvider) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(FieldBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
this.fieldDataHelperServiceProvider = fieldDataHelperServiceProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FieldBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Field> build(FieldSet fields, List<FieldEntity> 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<Field> models = new ArrayList<>();
|
||||||
|
for (FieldEntity d : data) {
|
||||||
|
Field m = new Field();
|
||||||
|
if (fields.hasField(this.asIndexer(Field._key))) m.setKey(d.getKey());
|
||||||
|
if (fields.hasField(this.asIndexer(Field._value))) m.setValue(d.getValue());
|
||||||
|
|
||||||
|
models.add(m);
|
||||||
|
}
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
package eu.eudat.model.builder.descriptionpropertiesdefinition;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.types.description.PropertyDefinitionEntity;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.builder.BaseBuilder;
|
||||||
|
import eu.eudat.model.descriptiontemplatedefinition.Definition;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
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 eu.eudat.model.descriptionproperties.PropertyDefinition;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Component("descriptionpropertiesdefinitionbuilder")
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class PropertyDefinitionBuilder extends BaseBuilder<PropertyDefinition, PropertyDefinitionEntity> {
|
||||||
|
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public PropertyDefinitionBuilder(
|
||||||
|
ConventionService conventionService, BuilderFactory builderFactory) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(PropertyDefinitionBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertyDefinitionBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PropertyDefinition> build(FieldSet fields, List<PropertyDefinitionEntity> 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<>();
|
||||||
|
|
||||||
|
//Not Bulk Build because is XML no interaction with db
|
||||||
|
FieldSet fieldsFields = fields.extractPrefixed(this.asPrefix(PropertyDefinition._fields));
|
||||||
|
|
||||||
|
List<PropertyDefinition> models = new ArrayList<>();
|
||||||
|
for (PropertyDefinitionEntity d : data) {
|
||||||
|
PropertyDefinition m = new PropertyDefinition();
|
||||||
|
if (!fieldsFields.isEmpty() && d.getFields() != null) m.setFields(this.builderFactory.builder(FieldBuilder.class).authorize(this.authorize).build(fieldsFields, d.getFields()));
|
||||||
|
models.add(m);
|
||||||
|
}
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package eu.eudat.model.censorship;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.model.Description;
|
import eu.eudat.model.Description;
|
||||||
|
import eu.eudat.model.censorship.descriptionproperties.PropertyDefinitionCensor;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
import gr.cite.tools.data.censor.CensorFactory;
|
import gr.cite.tools.data.censor.CensorFactory;
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
@ -40,6 +41,25 @@ public class DescriptionCensor extends BaseCensor {
|
||||||
|
|
||||||
FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(Description._dmp));
|
FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(Description._dmp));
|
||||||
this.censorFactory.censor(DmpCensor.class).censor(dmpFields, userId);
|
this.censorFactory.censor(DmpCensor.class).censor(dmpFields, userId);
|
||||||
|
|
||||||
|
FieldSet descriptionReferenceFields = fields.extractPrefixed(this.asIndexerPrefix(Description._descriptionReferences));
|
||||||
|
this.censorFactory.censor(DescriptionReferenceCensor.class).censor(descriptionReferenceFields, userId);
|
||||||
|
|
||||||
|
FieldSet descriptionTagsFields = fields.extractPrefixed(this.asIndexerPrefix(Description._descriptionTags));
|
||||||
|
this.censorFactory.censor(DescriptionTagCensor.class).censor(descriptionTagsFields, userId);
|
||||||
|
|
||||||
|
FieldSet descriptionTemplateFields = fields.extractPrefixed(this.asIndexerPrefix(Description._descriptionTemplate));
|
||||||
|
this.censorFactory.censor(DescriptionTemplateCensor.class).censor(descriptionTemplateFields, userId);
|
||||||
|
|
||||||
|
FieldSet dmpDescriptionTemplateFields = fields.extractPrefixed(this.asIndexerPrefix(Description._dmpDescriptionTemplate));
|
||||||
|
this.censorFactory.censor(DmpDescriptionTemplateCensor.class).censor(dmpDescriptionTemplateFields, userId);
|
||||||
|
|
||||||
|
FieldSet propertiesFields = fields.extractPrefixed(this.asIndexerPrefix(Description._properties));
|
||||||
|
this.censorFactory.censor(PropertyDefinitionCensor.class).censor(propertiesFields, userId);
|
||||||
|
|
||||||
|
//ToDo
|
||||||
|
// FieldSet createdByFields = fields.extractPrefixed(this.asIndexerPrefix(Description._createdBy));
|
||||||
|
// this.censorFactory.censor(UserInfo.class).censor(createdByFields, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
package eu.eudat.model.censorship;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.Permission;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.DescriptionReference;
|
||||||
|
import eu.eudat.model.DescriptionTag;
|
||||||
|
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 DescriptionTagCensor extends BaseCensor {
|
||||||
|
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTagCensor.class));
|
||||||
|
|
||||||
|
protected final AuthorizationService authService;
|
||||||
|
|
||||||
|
protected final CensorFactory censorFactory;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public DescriptionTagCensor(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(DescriptionTag._description));
|
||||||
|
this.censorFactory.censor(DescriptionCensor.class).censor(descriptionFields, userId);
|
||||||
|
FieldSet tagFields = fields.extractPrefixed(this.asIndexerPrefix(DescriptionTag._tag));
|
||||||
|
this.censorFactory.censor(TagCensor.class).censor(tagFields, userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
package eu.eudat.model.censorship;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.Permission;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.Reference;
|
||||||
|
import eu.eudat.model.Tag;
|
||||||
|
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 TagCensor extends BaseCensor {
|
||||||
|
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TagCensor.class));
|
||||||
|
|
||||||
|
protected final AuthorizationService authService;
|
||||||
|
protected final CensorFactory censorFactory;
|
||||||
|
|
||||||
|
public TagCensor(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.BrowseTag);
|
||||||
|
//ToDo
|
||||||
|
// FieldSet createdByFields = fields.extractPrefixed(this.asIndexerPrefix(Tag._createdBy));
|
||||||
|
// this.censorFactory.censor(UserInfo.class).censor(createdByFields, userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package eu.eudat.model.censorship.descriptionproperties;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.Permission;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.censorship.BaseCensor;
|
||||||
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
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("descriptionpropertiesfieldcensor")
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class FieldCensor extends BaseCensor {
|
||||||
|
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(FieldCensor.class));
|
||||||
|
|
||||||
|
protected final AuthorizationService authService;
|
||||||
|
|
||||||
|
public FieldCensor(ConventionService conventionService,
|
||||||
|
AuthorizationService authService) {
|
||||||
|
super(conventionService);
|
||||||
|
this.authService = authService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void censor(FieldSet fields, UUID userId) {
|
||||||
|
logger.debug(new DataLogEntry("censoring fields", fields));
|
||||||
|
if (fields == null || fields.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.authService.authorizeForce(Permission.BrowseDescription);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package eu.eudat.model.censorship.descriptionproperties;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.Permission;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.Description;
|
||||||
|
import eu.eudat.model.censorship.BaseCensor;
|
||||||
|
import eu.eudat.model.censorship.dmpblueprintdefinition.SectionCensor;
|
||||||
|
import eu.eudat.model.descriptionproperties.PropertyDefinition;
|
||||||
|
import eu.eudat.model.dmpblueprintdefinition.Definition;
|
||||||
|
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("descriptionpropertiescensor")
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class PropertyDefinitionCensor extends BaseCensor {
|
||||||
|
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PropertyDefinitionCensor.class));
|
||||||
|
|
||||||
|
protected final AuthorizationService authService;
|
||||||
|
protected final CensorFactory censorFactory;
|
||||||
|
|
||||||
|
public PropertyDefinitionCensor(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.BrowseDescription);
|
||||||
|
FieldSet fieldFields = fields.extractPrefixed(this.asIndexerPrefix(PropertyDefinition._fields));
|
||||||
|
this.censorFactory.censor(FieldCensor.class).censor(fieldFields, userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,7 +2,13 @@ package eu.eudat.model.deleter;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
|
import eu.eudat.data.DescriptionReferenceEntity;
|
||||||
|
import eu.eudat.data.DescriptionTagEntity;
|
||||||
|
import eu.eudat.data.UserDescriptionTemplateEntity;
|
||||||
import eu.eudat.query.DescriptionQuery;
|
import eu.eudat.query.DescriptionQuery;
|
||||||
|
import eu.eudat.query.DescriptionReferenceQuery;
|
||||||
|
import eu.eudat.query.DescriptionTagQuery;
|
||||||
|
import eu.eudat.query.UserDescriptionTemplateQuery;
|
||||||
import gr.cite.tools.data.deleter.Deleter;
|
import gr.cite.tools.data.deleter.Deleter;
|
||||||
import gr.cite.tools.data.deleter.DeleterFactory;
|
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
@ -20,6 +26,7 @@ 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)
|
||||||
|
@ -59,14 +66,28 @@ public class DescriptionDeleter implements Deleter {
|
||||||
logger.trace("changes saved");
|
logger.trace("changes saved");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(List<DescriptionEntity> data) throws InvalidApplicationException {
|
public void delete(List<DescriptionEntity> datas) throws InvalidApplicationException {
|
||||||
logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
|
logger.debug("will delete {} items", Optional.ofNullable(datas).map(List::size).orElse(0));
|
||||||
if (data == null || data.isEmpty())
|
if (datas == null || datas.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Instant now = Instant.now();
|
Instant now = Instant.now();
|
||||||
|
|
||||||
for (DescriptionEntity item : data) {
|
List<UUID> ids = datas.stream().map(DescriptionEntity::getId).distinct().collect(Collectors.toList());
|
||||||
|
{
|
||||||
|
logger.debug("checking related - {}", DescriptionReferenceEntity.class.getSimpleName());
|
||||||
|
List<DescriptionReferenceEntity> items = this.queryFactory.query(DescriptionReferenceQuery.class).descriptionIds(ids).collect();
|
||||||
|
DescriptionReferenceDeleter deleter = this.deleterFactory.deleter(DescriptionReferenceDeleter.class);
|
||||||
|
deleter.delete(items);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
logger.debug("checking related - {}", DescriptionTagEntity.class.getSimpleName());
|
||||||
|
List<DescriptionTagEntity> items = this.queryFactory.query(DescriptionTagQuery.class).descriptionIds(ids).collect();
|
||||||
|
DescriptionTagDeleter deleter = this.deleterFactory.deleter(DescriptionTagDeleter.class);
|
||||||
|
deleter.delete(items);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (DescriptionEntity item : datas) {
|
||||||
logger.trace("deleting item {}", item.getId());
|
logger.trace("deleting item {}", item.getId());
|
||||||
item.setIsActive(IsActive.Inactive);
|
item.setIsActive(IsActive.Inactive);
|
||||||
item.setUpdatedAt(now);
|
item.setUpdatedAt(now);
|
||||||
|
|
|
@ -0,0 +1,79 @@
|
||||||
|
package eu.eudat.model.deleter;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.data.DescriptionTagEntity;
|
||||||
|
import eu.eudat.query.DescriptionTagQuery;
|
||||||
|
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 DescriptionTagDeleter implements Deleter {
|
||||||
|
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTagDeleter.class));
|
||||||
|
|
||||||
|
private final EntityManager entityManager;
|
||||||
|
|
||||||
|
protected final QueryFactory queryFactory;
|
||||||
|
|
||||||
|
protected final DeleterFactory deleterFactory;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public DescriptionTagDeleter(
|
||||||
|
EntityManager entityManager,
|
||||||
|
QueryFactory queryFactory,
|
||||||
|
DeleterFactory deleterFactory
|
||||||
|
) {
|
||||||
|
this.entityManager = entityManager;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
this.deleterFactory = deleterFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteAndSaveByIds(List<UUID> ids) throws InvalidApplicationException {
|
||||||
|
logger.debug(new MapLogEntry("collecting to delete").And("count", Optional.ofNullable(ids).map(List::size).orElse(0)).And("ids", ids));
|
||||||
|
List<DescriptionTagEntity> data = this.queryFactory.query(DescriptionTagQuery.class).ids(ids).collect();
|
||||||
|
logger.trace("retrieved {} items", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
this.deleteAndSave(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteAndSave(List<DescriptionTagEntity> 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<DescriptionTagEntity> 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 (DescriptionTagEntity 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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package eu.eudat.model.deleter;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.data.UserDescriptionTemplateEntity;
|
import eu.eudat.data.UserDescriptionTemplateEntity;
|
||||||
|
import eu.eudat.query.DescriptionQuery;
|
||||||
import eu.eudat.query.DescriptionTemplateQuery;
|
import eu.eudat.query.DescriptionTemplateQuery;
|
||||||
import eu.eudat.query.UserDescriptionTemplateQuery;
|
import eu.eudat.query.UserDescriptionTemplateQuery;
|
||||||
import gr.cite.tools.data.deleter.Deleter;
|
import gr.cite.tools.data.deleter.Deleter;
|
||||||
|
@ -67,7 +68,7 @@ public class DescriptionTemplateDeleter implements Deleter {
|
||||||
if (datas == null || datas.isEmpty())
|
if (datas == null || datas.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
List<UUID> ids = datas.stream().map(x -> x.getId()).distinct().collect(Collectors.toList());
|
List<UUID> ids = datas.stream().map(DescriptionTemplateEntity::getId).distinct().collect(Collectors.toList());
|
||||||
{
|
{
|
||||||
logger.debug("checking related - {}", UserDescriptionTemplateEntity.class.getSimpleName());
|
logger.debug("checking related - {}", UserDescriptionTemplateEntity.class.getSimpleName());
|
||||||
List<UserDescriptionTemplateEntity> items = this.queryFactory.query(UserDescriptionTemplateQuery.class).descriptionTemplateIds(ids).collect();
|
List<UserDescriptionTemplateEntity> items = this.queryFactory.query(UserDescriptionTemplateQuery.class).descriptionTemplateIds(ids).collect();
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
package eu.eudat.model.deleter;
|
package eu.eudat.model.deleter;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.data.DescriptionTagEntity;
|
||||||
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.data.DescriptionTemplateTypeEntity;
|
import eu.eudat.data.DescriptionTemplateTypeEntity;
|
||||||
|
import eu.eudat.data.ReferenceEntity;
|
||||||
|
import eu.eudat.query.DescriptionTagQuery;
|
||||||
|
import eu.eudat.query.DescriptionTemplateQuery;
|
||||||
import eu.eudat.query.DescriptionTemplateTypeQuery;
|
import eu.eudat.query.DescriptionTemplateTypeQuery;
|
||||||
import gr.cite.tools.data.deleter.Deleter;
|
import gr.cite.tools.data.deleter.Deleter;
|
||||||
import gr.cite.tools.data.deleter.DeleterFactory;
|
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||||
|
@ -20,6 +25,7 @@ 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)
|
||||||
|
@ -59,14 +65,22 @@ public class DescriptionTemplateTypeDeleter implements Deleter {
|
||||||
logger.trace("changes saved");
|
logger.trace("changes saved");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(List<DescriptionTemplateTypeEntity> data) throws InvalidApplicationException {
|
public void delete(List<DescriptionTemplateTypeEntity> datas) throws InvalidApplicationException {
|
||||||
logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
|
logger.debug("will delete {} items", Optional.ofNullable(datas).map(List::size).orElse(0));
|
||||||
if (data == null || data.isEmpty())
|
if (datas == null || datas.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
List<UUID> ids = datas.stream().map(DescriptionTemplateTypeEntity::getId).distinct().collect(Collectors.toList());
|
||||||
|
{
|
||||||
|
logger.debug("checking related - {}", DescriptionTemplateEntity.class.getSimpleName());
|
||||||
|
List<DescriptionTemplateEntity> items = this.queryFactory.query(DescriptionTemplateQuery.class).typeIds(ids).collect();
|
||||||
|
DescriptionTemplateDeleter deleter = this.deleterFactory.deleter(DescriptionTemplateDeleter.class);
|
||||||
|
deleter.delete(items);
|
||||||
|
}
|
||||||
|
|
||||||
Instant now = Instant.now();
|
Instant now = Instant.now();
|
||||||
|
|
||||||
for (DescriptionTemplateTypeEntity item : data) {
|
for (DescriptionTemplateTypeEntity item : datas) {
|
||||||
logger.trace("deleting item {}", item.getId());
|
logger.trace("deleting item {}", item.getId());
|
||||||
item.setIsActive(IsActive.Inactive);
|
item.setIsActive(IsActive.Inactive);
|
||||||
item.setUpdatedAt(now);
|
item.setUpdatedAt(now);
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package eu.eudat.model.deleter;
|
package eu.eudat.model.deleter;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.data.DescriptionReferenceEntity;
|
||||||
import eu.eudat.data.DmpEntity;
|
import eu.eudat.data.DmpEntity;
|
||||||
|
import eu.eudat.query.DescriptionReferenceQuery;
|
||||||
import eu.eudat.query.DmpQuery;
|
import eu.eudat.query.DmpQuery;
|
||||||
|
import eu.eudat.query.DmpReferenceQuery;
|
||||||
import gr.cite.tools.data.deleter.Deleter;
|
import gr.cite.tools.data.deleter.Deleter;
|
||||||
import gr.cite.tools.data.deleter.DeleterFactory;
|
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
package eu.eudat.model.deleter;
|
package eu.eudat.model.deleter;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.data.DescriptionReferenceEntity;
|
||||||
|
import eu.eudat.data.DmpReferenceEntity;
|
||||||
import eu.eudat.data.ReferenceEntity;
|
import eu.eudat.data.ReferenceEntity;
|
||||||
|
import eu.eudat.data.TagEntity;
|
||||||
|
import eu.eudat.query.DescriptionReferenceQuery;
|
||||||
|
import eu.eudat.query.DmpReferenceQuery;
|
||||||
import eu.eudat.query.ReferenceQuery;
|
import eu.eudat.query.ReferenceQuery;
|
||||||
import gr.cite.tools.data.deleter.Deleter;
|
import gr.cite.tools.data.deleter.Deleter;
|
||||||
import gr.cite.tools.data.deleter.DeleterFactory;
|
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||||
|
@ -20,6 +25,7 @@ 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)
|
||||||
|
@ -58,14 +64,27 @@ public class ReferenceDeleter implements Deleter {
|
||||||
logger.trace("changes saved");
|
logger.trace("changes saved");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(List<ReferenceEntity> data) throws InvalidApplicationException {
|
public void delete(List<ReferenceEntity> datas) throws InvalidApplicationException {
|
||||||
logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
|
logger.debug("will delete {} items", Optional.ofNullable(datas).map(List::size).orElse(0));
|
||||||
if (data == null || data.isEmpty())
|
if (datas == null || datas.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
List<UUID> ids = datas.stream().map(ReferenceEntity::getId).distinct().collect(Collectors.toList());
|
||||||
|
{
|
||||||
|
logger.debug("checking related - {}", DescriptionReferenceEntity.class.getSimpleName());
|
||||||
|
List<DescriptionReferenceEntity> items = this.queryFactory.query(DescriptionReferenceQuery.class).referenceIds(ids).collect();
|
||||||
|
DescriptionReferenceDeleter deleter = this.deleterFactory.deleter(DescriptionReferenceDeleter.class);
|
||||||
|
deleter.delete(items);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
logger.debug("checking related - {}", DmpReferenceEntity.class.getSimpleName());
|
||||||
|
List<DmpReferenceEntity> items = this.queryFactory.query(DmpReferenceQuery.class).referenceIds(ids).collect();
|
||||||
|
DmpReferenceDeleter deleter = this.deleterFactory.deleter(DmpReferenceDeleter.class);
|
||||||
|
deleter.delete(items);
|
||||||
|
}
|
||||||
Instant now = Instant.now();
|
Instant now = Instant.now();
|
||||||
|
|
||||||
for (ReferenceEntity item : data) {
|
for (ReferenceEntity item : datas) {
|
||||||
logger.trace("deleting item {}", item.getId());
|
logger.trace("deleting item {}", item.getId());
|
||||||
item.setIsActive(IsActive.Inactive);
|
item.setIsActive(IsActive.Inactive);
|
||||||
item.setUpdatedAt(now);
|
item.setUpdatedAt(now);
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
package eu.eudat.model.deleter;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.data.DescriptionEntity;
|
||||||
|
import eu.eudat.data.DescriptionTagEntity;
|
||||||
|
import eu.eudat.data.TagEntity;
|
||||||
|
import eu.eudat.query.DescriptionTagQuery;
|
||||||
|
import eu.eudat.query.TagQuery;
|
||||||
|
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;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class TagDeleter implements Deleter {
|
||||||
|
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TagDeleter.class));
|
||||||
|
private final EntityManager entityManager;
|
||||||
|
|
||||||
|
protected final QueryFactory queryFactory;
|
||||||
|
|
||||||
|
protected final DeleterFactory deleterFactory;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public TagDeleter(
|
||||||
|
EntityManager entityManager,
|
||||||
|
QueryFactory queryFactory,
|
||||||
|
DeleterFactory deleterFactory
|
||||||
|
) {
|
||||||
|
this.entityManager = entityManager;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
this.deleterFactory = deleterFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteAndSaveByIds(List<UUID> ids) throws InvalidApplicationException {
|
||||||
|
logger.debug(new MapLogEntry("collecting to delete").And("count", Optional.ofNullable(ids).map(List::size).orElse(0)).And("ids", ids));
|
||||||
|
List<TagEntity> data = this.queryFactory.query(TagQuery.class).ids(ids).collect();
|
||||||
|
logger.trace("retrieved {} items", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
this.deleteAndSave(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteAndSave(List<TagEntity> 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<TagEntity> datas) throws InvalidApplicationException {
|
||||||
|
logger.debug("will delete {} items", Optional.ofNullable(datas).map(List::size).orElse(0));
|
||||||
|
if (datas == null || datas.isEmpty())
|
||||||
|
return;
|
||||||
|
List<UUID> ids = datas.stream().map(TagEntity::getId).distinct().collect(Collectors.toList());
|
||||||
|
{
|
||||||
|
logger.debug("checking related - {}", DescriptionTagEntity.class.getSimpleName());
|
||||||
|
List<DescriptionTagEntity> items = this.queryFactory.query(DescriptionTagQuery.class).tagIds(ids).collect();
|
||||||
|
DescriptionTagDeleter deleter = this.deleterFactory.deleter(DescriptionTagDeleter.class);
|
||||||
|
deleter.delete(items);
|
||||||
|
}
|
||||||
|
Instant now = Instant.now();
|
||||||
|
|
||||||
|
for (TagEntity item : datas) {
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,18 +3,18 @@ package eu.eudat.model.descriptionproperties;
|
||||||
|
|
||||||
public class Field {
|
public class Field {
|
||||||
|
|
||||||
public final static String _id = "id";
|
public final static String _key = "key";
|
||||||
private String id;
|
private String key;
|
||||||
|
|
||||||
public final static String _value = "value";
|
public final static String _value = "value";
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
public String getId() {
|
public String getKey() {
|
||||||
return id;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id) {
|
public void setKey(String key) {
|
||||||
this.id = id;
|
this.key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
|
|
|
@ -7,4 +7,11 @@ public class PropertyDefinition {
|
||||||
public final static String _fields = "fields";
|
public final static String _fields = "fields";
|
||||||
private List<Field> fields;
|
private List<Field> fields;
|
||||||
|
|
||||||
|
public List<Field> getFields() {
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFields(List<Field> fields) {
|
||||||
|
this.fields = fields;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class DmpEntityDepositMapper {
|
||||||
model.setLabel(entity.getLabel());
|
model.setLabel(entity.getLabel());
|
||||||
model.setDescription(entity.getDescription());
|
model.setDescription(entity.getDescription());
|
||||||
model.setProperties(entity.getProperties());
|
model.setProperties(entity.getProperties());
|
||||||
DescriptionTemplateEntity descriptionTemplateEntity = getDescriptionTemplate(entity.getDescriptionTemplate());
|
DescriptionTemplateEntity descriptionTemplateEntity = getDescriptionTemplate(entity.getDescriptionTemplateId());
|
||||||
model.setProfileDefinition(descriptionTemplateEntity.getDefinition());
|
model.setProfileDefinition(descriptionTemplateEntity.getDefinition());
|
||||||
model.setFields(fromDefinitionAndProperties(descriptionTemplateEntity.getDefinition(), entity.getProperties()));
|
model.setFields(fromDefinitionAndProperties(descriptionTemplateEntity.getDefinition(), entity.getProperties()));
|
||||||
return model;
|
return model;
|
||||||
|
|
|
@ -3,10 +3,8 @@ package eu.eudat.query;
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.commons.enums.DescriptionStatus;
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.model.Description;
|
import eu.eudat.model.Description;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
||||||
import gr.cite.tools.data.query.FieldResolver;
|
import gr.cite.tools.data.query.FieldResolver;
|
||||||
import gr.cite.tools.data.query.QueryBase;
|
import gr.cite.tools.data.query.QueryBase;
|
||||||
import gr.cite.tools.data.query.QueryContext;
|
import gr.cite.tools.data.query.QueryContext;
|
||||||
|
@ -38,13 +36,8 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
|
||||||
|
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
private final UserScope userScope;
|
|
||||||
|
|
||||||
private final AuthorizationService authService;
|
public DescriptionQuery() {
|
||||||
|
|
||||||
public DescriptionQuery(UserScope userScope, AuthorizationService authService) {
|
|
||||||
this.userScope = userScope;
|
|
||||||
this.authService = authService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DescriptionQuery like(String value) {
|
public DescriptionQuery like(String value) {
|
||||||
|
@ -178,7 +171,7 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
|
||||||
predicates.add(inClause);
|
predicates.add(inClause);
|
||||||
}
|
}
|
||||||
if (this.dmpIds != null) {
|
if (this.dmpIds != null) {
|
||||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._dmp));
|
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._dmpId));
|
||||||
for (UUID item : this.dmpIds)
|
for (UUID item : this.dmpIds)
|
||||||
inClause.value(item);
|
inClause.value(item);
|
||||||
predicates.add(inClause);
|
predicates.add(inClause);
|
||||||
|
@ -193,36 +186,21 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String fieldNameOf(FieldResolver item) {
|
protected String fieldNameOf(FieldResolver item) {
|
||||||
if (item.match(Description._id))
|
if (item.match(Description._id)) return DescriptionEntity._id;
|
||||||
return DescriptionEntity._id;
|
else if (item.match(Description._label)) return DescriptionEntity._label;
|
||||||
else if (item.match(Description._label))
|
else if (item.prefix(Description._dmp)) return DescriptionEntity._dmpId;
|
||||||
return DescriptionEntity._label;
|
else if (item.match(Description._dmp)) return DescriptionEntity._dmpId;
|
||||||
else if (item.prefix(Description._dmp))
|
else if (item.prefix(Description._properties)) return DescriptionEntity._properties;
|
||||||
return DescriptionEntity._dmp;
|
else if (item.prefix(Description._descriptionTemplate)) return DescriptionEntity._descriptionTemplateId;
|
||||||
else if (item.match(Description._dmp))
|
else if (item.match(Description._status)) return DescriptionEntity._status;
|
||||||
return DescriptionEntity._dmp;
|
else if (item.match(Description._description)) return DescriptionEntity._description;
|
||||||
else if (item.prefix(Description._properties))
|
else if (item.match(Description._createdBy)) return DescriptionEntity._createdById;
|
||||||
return DescriptionEntity._properties;
|
else if (item.match(Description._createdAt)) return DescriptionEntity._createdAt;
|
||||||
else if (item.prefix(Description._descriptionTemplate))
|
else if (item.match(Description._updatedAt)) return DescriptionEntity._updatedAt;
|
||||||
return DescriptionEntity._descriptionTemplate;
|
else if (item.match(Description._isActive)) return DescriptionEntity._isActive;
|
||||||
else if (item.match(Description._status))
|
else if (item.match(Description._finalizedAt)) return DescriptionEntity._finalizedAt;
|
||||||
return DescriptionEntity._status;
|
else if (item.match(Description._dmpDescriptionTemplate)) return DescriptionEntity._dmpDescriptionTemplateId;
|
||||||
else if (item.match(Description._description))
|
else return null;
|
||||||
return DescriptionEntity._description;
|
|
||||||
else if (item.match(Description._createdBy))
|
|
||||||
return DescriptionEntity._createdBy;
|
|
||||||
else if (item.match(Description._createdAt))
|
|
||||||
return DescriptionEntity._createdAt;
|
|
||||||
else if (item.match(Description._updatedAt))
|
|
||||||
return DescriptionEntity._updatedAt;
|
|
||||||
else if (item.match(Description._isActive))
|
|
||||||
return DescriptionEntity._isActive;
|
|
||||||
else if (item.match(Description._finalizedAt))
|
|
||||||
return DescriptionEntity._finalizedAt;
|
|
||||||
else if (item.match(Description._dmpDescriptionTemplate))
|
|
||||||
return DescriptionEntity._dmpDescriptionTemplate;
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -230,17 +208,16 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
|
||||||
DescriptionEntity item = new DescriptionEntity();
|
DescriptionEntity item = new DescriptionEntity();
|
||||||
item.setId(QueryBase.convertSafe(tuple, columns, DescriptionEntity._id, UUID.class));
|
item.setId(QueryBase.convertSafe(tuple, columns, DescriptionEntity._id, UUID.class));
|
||||||
item.setLabel(QueryBase.convertSafe(tuple, columns, DescriptionEntity._label, String.class));
|
item.setLabel(QueryBase.convertSafe(tuple, columns, DescriptionEntity._label, String.class));
|
||||||
item.setDmp(QueryBase.convertSafe(tuple, columns, DescriptionEntity._dmp, UUID.class));
|
item.setDmpId(QueryBase.convertSafe(tuple, columns, DescriptionEntity._dmpId, UUID.class));
|
||||||
item.setProperties(QueryBase.convertSafe(tuple, columns, DescriptionEntity._properties, String.class));
|
item.setProperties(QueryBase.convertSafe(tuple, columns, DescriptionEntity._properties, String.class));
|
||||||
item.setDescriptionTemplate(QueryBase.convertSafe(tuple, columns, DescriptionEntity._descriptionTemplate, UUID.class));
|
item.setDescriptionTemplateId(QueryBase.convertSafe(tuple, columns, DescriptionEntity._descriptionTemplateId, UUID.class));
|
||||||
item.setStatus(QueryBase.convertSafe(tuple, columns, DescriptionEntity._status, DescriptionStatus.class));
|
item.setStatus(QueryBase.convertSafe(tuple, columns, DescriptionEntity._status, DescriptionStatus.class));
|
||||||
item.setDescription(QueryBase.convertSafe(tuple, columns, DescriptionEntity._description, String.class));
|
item.setDescription(QueryBase.convertSafe(tuple, columns, DescriptionEntity._description, String.class));
|
||||||
item.setDmpDescriptionTemplate(QueryBase.convertSafe(tuple, columns, DescriptionEntity._createdBy, UUID.class));
|
|
||||||
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DescriptionEntity._createdAt, Instant.class));
|
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DescriptionEntity._createdAt, Instant.class));
|
||||||
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DescriptionEntity._updatedAt, Instant.class));
|
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DescriptionEntity._updatedAt, Instant.class));
|
||||||
item.setIsActive(QueryBase.convertSafe(tuple, columns, DescriptionEntity._isActive, IsActive.class));
|
item.setIsActive(QueryBase.convertSafe(tuple, columns, DescriptionEntity._isActive, IsActive.class));
|
||||||
item.setFinalizedAt(QueryBase.convertSafe(tuple, columns, DescriptionEntity._finalizedAt, Instant.class));
|
item.setFinalizedAt(QueryBase.convertSafe(tuple, columns, DescriptionEntity._finalizedAt, Instant.class));
|
||||||
item.setDmpDescriptionTemplate(QueryBase.convertSafe(tuple, columns, DescriptionEntity._dmpDescriptionTemplate, UUID.class));
|
item.setDmpDescriptionTemplateId(QueryBase.convertSafe(tuple, columns, DescriptionEntity._dmpDescriptionTemplateId, UUID.class));
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,13 +35,7 @@ public class DescriptionReferenceQuery extends QueryBase<DescriptionReferenceEnt
|
||||||
|
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
private final UserScope userScope;
|
public DescriptionReferenceQuery() {
|
||||||
|
|
||||||
private final AuthorizationService authService;
|
|
||||||
|
|
||||||
public DescriptionReferenceQuery(UserScope userScope, AuthorizationService authService) {
|
|
||||||
this.userScope = userScope;
|
|
||||||
this.authService = authService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DescriptionReferenceQuery ids(UUID value) {
|
public DescriptionReferenceQuery ids(UUID value) {
|
||||||
|
@ -182,24 +176,15 @@ public class DescriptionReferenceQuery extends QueryBase<DescriptionReferenceEnt
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String fieldNameOf(FieldResolver item) {
|
protected String fieldNameOf(FieldResolver item) {
|
||||||
if (item.match(DescriptionReference._id))
|
if (item.match(DescriptionReference._id)) return DescriptionReferenceEntity._id;
|
||||||
return DescriptionReferenceEntity._id;
|
if (item.match(DescriptionReference._description)) return DescriptionReferenceEntity._descriptionId;
|
||||||
if (item.match(DescriptionReference._description))
|
else if (item.prefix(DescriptionReference._description)) return DescriptionReferenceEntity._descriptionId;
|
||||||
return DescriptionReferenceEntity._descriptionId;
|
else if (item.match(DescriptionReference._reference)) return DescriptionReferenceEntity._referenceId;
|
||||||
else if (item.prefix(DescriptionReference._description))
|
else if (item.prefix(DescriptionReference._reference)) return DescriptionReferenceEntity._referenceId;
|
||||||
return DescriptionReferenceEntity._descriptionId;
|
else if (item.match(DescriptionReference._createdAt)) return DescriptionReferenceEntity._createdAt;
|
||||||
else if (item.match(DescriptionReference._reference))
|
else if (item.match(DescriptionReference._updatedAt)) return DescriptionReferenceEntity._updatedAt;
|
||||||
return DescriptionReferenceEntity._referenceId;
|
else if (item.match(DescriptionReference._isActive)) return DescriptionReferenceEntity._isActive;
|
||||||
else if (item.prefix(DescriptionReference._reference))
|
else return null;
|
||||||
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
|
@Override
|
||||||
|
|
|
@ -0,0 +1,196 @@
|
||||||
|
package eu.eudat.query;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.data.DescriptionEntity;
|
||||||
|
import eu.eudat.data.DescriptionTagEntity;
|
||||||
|
import eu.eudat.model.DescriptionTag;
|
||||||
|
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 DescriptionTagQuery extends QueryBase<DescriptionTagEntity> {
|
||||||
|
|
||||||
|
private Collection<UUID> ids;
|
||||||
|
|
||||||
|
private Collection<UUID> tagIds;
|
||||||
|
|
||||||
|
private Collection<UUID> excludedIds;
|
||||||
|
|
||||||
|
private Collection<UUID> descriptionIds;
|
||||||
|
|
||||||
|
private Collection<IsActive> isActives;
|
||||||
|
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
|
||||||
|
public DescriptionTagQuery ids(UUID value) {
|
||||||
|
this.ids = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionTagQuery ids(UUID... value) {
|
||||||
|
this.ids = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionTagQuery ids(Collection<UUID> values) {
|
||||||
|
this.ids = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionTagQuery excludedIds(Collection<UUID> values) {
|
||||||
|
this.excludedIds = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionTagQuery excludedIds(UUID value) {
|
||||||
|
this.excludedIds = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionTagQuery excludedIds(UUID... value) {
|
||||||
|
this.excludedIds = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionTagQuery isActive(IsActive value) {
|
||||||
|
this.isActives = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionTagQuery isActive(IsActive... value) {
|
||||||
|
this.isActives = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionTagQuery isActive(Collection<IsActive> values) {
|
||||||
|
this.isActives = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionTagQuery tagIds(UUID value) {
|
||||||
|
this.tagIds = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionTagQuery tagIds(UUID... value) {
|
||||||
|
this.tagIds = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionTagQuery tagIds(Collection<UUID> values) {
|
||||||
|
this.tagIds = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionTagQuery descriptionIds(UUID value) {
|
||||||
|
this.descriptionIds = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionTagQuery descriptionIds(UUID... value) {
|
||||||
|
this.descriptionIds = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionTagQuery descriptionIds(Collection<UUID> values) {
|
||||||
|
this.descriptionIds = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionTagQuery authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionTagQuery(
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<DescriptionTagEntity> entityClass() {
|
||||||
|
return DescriptionTagEntity.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean isFalseQuery() {
|
||||||
|
return this.isEmpty(this.ids) || this.isEmpty(this.excludedIds) || this.isEmpty(this.isActives) ||this.isEmpty(this.tagIds) || this.isEmpty(this.descriptionIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||||
|
List<Predicate> predicates = new ArrayList<>();
|
||||||
|
if (this.ids != null) {
|
||||||
|
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTagEntity._id));
|
||||||
|
for (UUID item : this.ids)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
|
if (this.excludedIds != null) {
|
||||||
|
CriteriaBuilder.In<UUID> notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._id));
|
||||||
|
for (UUID item : this.excludedIds)
|
||||||
|
notInClause.value(item);
|
||||||
|
predicates.add(notInClause.not());
|
||||||
|
}
|
||||||
|
if (this.tagIds != null) {
|
||||||
|
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTagEntity._tagId));
|
||||||
|
for (UUID item : this.tagIds)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
|
if (this.descriptionIds != null) {
|
||||||
|
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTagEntity._descriptionId));
|
||||||
|
for (UUID item : this.descriptionIds)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
|
if (this.isActives != null) {
|
||||||
|
CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTagEntity._isActive));
|
||||||
|
for (IsActive item : this.isActives)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
|
if (!predicates.isEmpty()) {
|
||||||
|
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||||
|
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected DescriptionTagEntity convert(Tuple tuple, Set<String> columns) {
|
||||||
|
DescriptionTagEntity item = new DescriptionTagEntity();
|
||||||
|
item.setId(QueryBase.convertSafe(tuple, columns, DescriptionTagEntity._id, UUID.class));
|
||||||
|
item.setTagId(QueryBase.convertSafe(tuple, columns, DescriptionTagEntity._tagId, UUID.class));
|
||||||
|
item.setDescriptionId(QueryBase.convertSafe(tuple, columns, DescriptionTagEntity._descriptionId, UUID.class));
|
||||||
|
item.setIsActive(QueryBase.convertSafe(tuple, columns, DescriptionTagEntity._isActive, IsActive.class));
|
||||||
|
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DescriptionTagEntity._createdAt, Instant.class));
|
||||||
|
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DescriptionTagEntity._updatedAt, Instant.class));
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String fieldNameOf(FieldResolver item) {
|
||||||
|
if (item.match(DescriptionTag._id)) return DescriptionTagEntity._id;
|
||||||
|
else if (item.prefix(DescriptionTag._tag)) return DescriptionTagEntity._tagId;
|
||||||
|
else if (item.prefix(DescriptionTag._description)) return DescriptionTagEntity._descriptionId;
|
||||||
|
else if (item.match(DescriptionTag._isActive)) return DescriptionTagEntity._isActive;
|
||||||
|
else if (item.match(DescriptionTag._createdAt)) return DescriptionTagEntity._createdAt;
|
||||||
|
else if (item.match(DescriptionTag._updatedAt)) return DescriptionTagEntity._updatedAt;
|
||||||
|
else return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,10 +3,8 @@ package eu.eudat.query;
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.commons.enums.DescriptionTemplateStatus;
|
import eu.eudat.commons.enums.DescriptionTemplateStatus;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.model.DescriptionTemplate;
|
import eu.eudat.model.DescriptionTemplate;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
||||||
import gr.cite.tools.data.query.FieldResolver;
|
import gr.cite.tools.data.query.FieldResolver;
|
||||||
import gr.cite.tools.data.query.QueryBase;
|
import gr.cite.tools.data.query.QueryBase;
|
||||||
import gr.cite.tools.data.query.QueryContext;
|
import gr.cite.tools.data.query.QueryContext;
|
||||||
|
@ -140,13 +138,9 @@ public class DescriptionTemplateQuery extends QueryBase<DescriptionTemplateEntit
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final AuthorizationService authService;
|
|
||||||
|
|
||||||
public DescriptionTemplateQuery(
|
public DescriptionTemplateQuery(
|
||||||
UserScope userScope,
|
|
||||||
AuthorizationService authService
|
|
||||||
) {
|
) {
|
||||||
this.authService = authService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -169,7 +163,7 @@ public class DescriptionTemplateQuery extends QueryBase<DescriptionTemplateEntit
|
||||||
predicates.add(inClause);
|
predicates.add(inClause);
|
||||||
}
|
}
|
||||||
if (this.typeIds != null) {
|
if (this.typeIds != null) {
|
||||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateEntity._type));
|
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateEntity._typeId));
|
||||||
for (UUID item : this.typeIds)
|
for (UUID item : this.typeIds)
|
||||||
inClause.value(item);
|
inClause.value(item);
|
||||||
predicates.add(inClause);
|
predicates.add(inClause);
|
||||||
|
@ -222,7 +216,7 @@ public class DescriptionTemplateQuery extends QueryBase<DescriptionTemplateEntit
|
||||||
item.setGroupId(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._groupId, UUID.class));
|
item.setGroupId(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._groupId, UUID.class));
|
||||||
item.setVersion(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._version, Short.class));
|
item.setVersion(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._version, Short.class));
|
||||||
item.setLanguage(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._language, String.class));
|
item.setLanguage(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._language, String.class));
|
||||||
item.setType(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._type, UUID.class));
|
item.setTypeId(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._typeId, UUID.class));
|
||||||
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._createdAt, Instant.class));
|
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._createdAt, Instant.class));
|
||||||
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._updatedAt, Instant.class));
|
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._updatedAt, Instant.class));
|
||||||
item.setIsActive(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._isActive, IsActive.class));
|
item.setIsActive(QueryBase.convertSafe(tuple, columns, DescriptionTemplateEntity._isActive, IsActive.class));
|
||||||
|
@ -240,7 +234,7 @@ public class DescriptionTemplateQuery extends QueryBase<DescriptionTemplateEntit
|
||||||
else if (item.match(DescriptionTemplate._groupId)) return DescriptionTemplateEntity._groupId;
|
else if (item.match(DescriptionTemplate._groupId)) return DescriptionTemplateEntity._groupId;
|
||||||
else if (item.match(DescriptionTemplate._version)) return DescriptionTemplateEntity._version;
|
else if (item.match(DescriptionTemplate._version)) return DescriptionTemplateEntity._version;
|
||||||
else if (item.match(DescriptionTemplate._language)) return DescriptionTemplateEntity._language;
|
else if (item.match(DescriptionTemplate._language)) return DescriptionTemplateEntity._language;
|
||||||
else if (item.prefix(DescriptionTemplate._type)) return DescriptionTemplateEntity._type;
|
else if (item.prefix(DescriptionTemplate._type)) return DescriptionTemplateEntity._typeId;
|
||||||
else if (item.match(DescriptionTemplate._createdAt)) return DescriptionTemplateEntity._createdAt;
|
else if (item.match(DescriptionTemplate._createdAt)) return DescriptionTemplateEntity._createdAt;
|
||||||
else if (item.match(DescriptionTemplate._updatedAt)) return DescriptionTemplateEntity._updatedAt;
|
else if (item.match(DescriptionTemplate._updatedAt)) return DescriptionTemplateEntity._updatedAt;
|
||||||
else if (item.match(DescriptionTemplate._isActive)) return DescriptionTemplateEntity._isActive;
|
else if (item.match(DescriptionTemplate._isActive)) return DescriptionTemplateEntity._isActive;
|
||||||
|
|
|
@ -106,16 +106,8 @@ public class DescriptionTemplateTypeQuery extends QueryBase<DescriptionTemplateT
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final UserScope userScope;
|
|
||||||
|
|
||||||
private final AuthorizationService authService;
|
|
||||||
|
|
||||||
public DescriptionTemplateTypeQuery(
|
public DescriptionTemplateTypeQuery(
|
||||||
UserScope userScope,
|
|
||||||
AuthorizationService authService
|
|
||||||
) {
|
) {
|
||||||
this.userScope = userScope;
|
|
||||||
this.authService = authService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -106,16 +106,10 @@ public class DmpBlueprintQuery extends QueryBase<DmpBlueprintEntity> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final UserScope userScope;
|
|
||||||
|
|
||||||
private final AuthorizationService authService;
|
|
||||||
|
|
||||||
public DmpBlueprintQuery(
|
public DmpBlueprintQuery(
|
||||||
UserScope userScope,
|
UserScope userScope,
|
||||||
AuthorizationService authService
|
AuthorizationService authService
|
||||||
) {
|
) {
|
||||||
this.userScope = userScope;
|
|
||||||
this.authService = authService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -83,16 +83,8 @@ public class DmpDescriptionTemplateQuery extends QueryBase<DmpDescriptionTemplat
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final UserScope userScope;
|
|
||||||
|
|
||||||
private final AuthorizationService authService;
|
|
||||||
|
|
||||||
public DmpDescriptionTemplateQuery(
|
public DmpDescriptionTemplateQuery(
|
||||||
UserScope userScope,
|
|
||||||
AuthorizationService authService
|
|
||||||
) {
|
) {
|
||||||
this.userScope = userScope;
|
|
||||||
this.authService = authService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -124,16 +124,8 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final UserScope userScope;
|
|
||||||
|
|
||||||
private final AuthorizationService authService;
|
|
||||||
|
|
||||||
public ReferenceQuery(
|
public ReferenceQuery(
|
||||||
UserScope userScope,
|
|
||||||
AuthorizationService authService
|
|
||||||
) {
|
) {
|
||||||
this.userScope = userScope;
|
|
||||||
this.authService = authService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,188 @@
|
||||||
|
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.TagEntity;
|
||||||
|
import eu.eudat.model.Tag;
|
||||||
|
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 TagQuery extends QueryBase<TagEntity> {
|
||||||
|
|
||||||
|
private String like;
|
||||||
|
|
||||||
|
private Collection<UUID> ids;
|
||||||
|
|
||||||
|
private Collection<UUID> excludedIds;
|
||||||
|
|
||||||
|
private Collection<IsActive> isActives;
|
||||||
|
|
||||||
|
private Collection<UUID> createdByIds;
|
||||||
|
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
public TagQuery() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public TagQuery like(String value) {
|
||||||
|
this.like = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TagQuery ids(UUID value) {
|
||||||
|
this.ids = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TagQuery ids(UUID... value) {
|
||||||
|
this.ids = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TagQuery ids(Collection<UUID> values) {
|
||||||
|
this.ids = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TagQuery excludedIds(Collection<UUID> values) {
|
||||||
|
this.excludedIds = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TagQuery excludedIds(UUID value) {
|
||||||
|
this.excludedIds = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TagQuery excludedIds(UUID... value) {
|
||||||
|
this.excludedIds = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TagQuery isActive(IsActive value) {
|
||||||
|
this.isActives = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TagQuery isActive(IsActive... value) {
|
||||||
|
this.isActives = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TagQuery isActive(Collection<IsActive> values) {
|
||||||
|
this.isActives = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TagQuery createdByIds(UUID value) {
|
||||||
|
this.createdByIds = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TagQuery createdByIds(UUID... value) {
|
||||||
|
this.createdByIds = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TagQuery createdByIds(Collection<UUID> values) {
|
||||||
|
this.createdByIds = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TagQuery authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean isFalseQuery() {
|
||||||
|
return
|
||||||
|
this.isEmpty(this.ids) ||
|
||||||
|
this.isEmpty(this.isActives) ||
|
||||||
|
this.isEmpty(this.excludedIds) ||
|
||||||
|
this.isEmpty(this.createdByIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<TagEntity> entityClass() {
|
||||||
|
return TagEntity.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||||
|
List<Predicate> predicates = new ArrayList<>();
|
||||||
|
if (this.like != null && !this.like.isEmpty()) {
|
||||||
|
predicates.add(queryContext.CriteriaBuilder.like(queryContext.Root.get(TagEntity._label), this.like));
|
||||||
|
}
|
||||||
|
if (this.ids != null) {
|
||||||
|
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(TagEntity._id));
|
||||||
|
for (UUID item : this.ids)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
|
if (this.excludedIds != null) {
|
||||||
|
CriteriaBuilder.In<UUID> notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(TagEntity._id));
|
||||||
|
for (UUID item : this.excludedIds)
|
||||||
|
notInClause.value(item);
|
||||||
|
predicates.add(notInClause.not());
|
||||||
|
}
|
||||||
|
if (this.isActives != null) {
|
||||||
|
CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(TagEntity._isActive));
|
||||||
|
for (IsActive item : this.isActives)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
|
if (this.createdByIds != null) {
|
||||||
|
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(TagEntity._createdBy));
|
||||||
|
for (UUID item : this.createdByIds)
|
||||||
|
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(Tag._id)) return TagEntity._id;
|
||||||
|
else if (item.match(Tag._label)) return TagEntity._label;
|
||||||
|
else if (item.prefix(Tag._createdBy)) return TagEntity._createdBy;
|
||||||
|
else if (item.match(Tag._createdBy)) return TagEntity._createdBy;
|
||||||
|
else if (item.match(Tag._createdBy)) return TagEntity._createdBy;
|
||||||
|
else if (item.match(Tag._createdAt)) return TagEntity._createdAt;
|
||||||
|
else if (item.match(Tag._updatedAt)) return TagEntity._updatedAt;
|
||||||
|
else if (item.match(Tag._isActive)) return TagEntity._isActive;
|
||||||
|
else return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected TagEntity convert(Tuple tuple, Set<String> columns) {
|
||||||
|
TagEntity item = new TagEntity();
|
||||||
|
item.setId(QueryBase.convertSafe(tuple, columns, TagEntity._id, UUID.class));
|
||||||
|
item.setLabel(QueryBase.convertSafe(tuple, columns, TagEntity._label, String.class));
|
||||||
|
item.setCreatedBy(QueryBase.convertSafe(tuple, columns, TagEntity._createdBy, UUID.class));
|
||||||
|
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, TagEntity._createdAt, Instant.class));
|
||||||
|
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, TagEntity._updatedAt, Instant.class));
|
||||||
|
item.setIsActive(QueryBase.convertSafe(tuple, columns, TagEntity._isActive, IsActive.class));
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -127,13 +127,9 @@ public class UserDescriptionTemplateQuery extends QueryBase<UserDescriptionTempl
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final AuthorizationService authService;
|
|
||||||
|
|
||||||
public UserDescriptionTemplateQuery(
|
public UserDescriptionTemplateQuery(
|
||||||
UserScope userScope,
|
|
||||||
AuthorizationService authService
|
|
||||||
) {
|
) {
|
||||||
this.authService = authService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
package eu.eudat.query.lookup;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.query.DescriptionTagQuery;
|
||||||
|
import gr.cite.tools.data.query.Lookup;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class DescriptionTagLookup extends Lookup {
|
||||||
|
|
||||||
|
private Collection<UUID> ids;
|
||||||
|
|
||||||
|
private Collection<UUID> excludedIds;
|
||||||
|
|
||||||
|
private Collection<IsActive> isActives;
|
||||||
|
|
||||||
|
private Collection<UUID> descriptionIds;
|
||||||
|
|
||||||
|
private Collection<UUID> tagIds;
|
||||||
|
|
||||||
|
public Collection<UUID> getIds() {
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIds(Collection<UUID> ids) {
|
||||||
|
this.ids = ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<UUID> getExcludedIds() {
|
||||||
|
return excludedIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExcludedIds(Collection<UUID> excludedIds) {
|
||||||
|
this.excludedIds = excludedIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<IsActive> getIsActives() {
|
||||||
|
return isActives;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsActives(Collection<IsActive> isActives) {
|
||||||
|
this.isActives = isActives;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<UUID> getDescriptionIds() {
|
||||||
|
return descriptionIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescriptionIds(Collection<UUID> descriptionIds) {
|
||||||
|
this.descriptionIds = descriptionIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<UUID> getTagIds() {
|
||||||
|
return tagIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTagIds(Collection<UUID> referenceIds) {
|
||||||
|
this.tagIds = referenceIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionTagQuery enrich(QueryFactory queryFactory) {
|
||||||
|
DescriptionTagQuery query = queryFactory.query(DescriptionTagQuery.class);
|
||||||
|
if (this.ids != null) query.ids(this.ids);
|
||||||
|
if (this.excludedIds != null) query.excludedIds(this.excludedIds);
|
||||||
|
if (this.isActives != null) query.isActive(this.isActives);
|
||||||
|
if (this.descriptionIds != null) query.descriptionIds(this.descriptionIds);
|
||||||
|
if (this.tagIds != null) query.tagIds(this.tagIds);
|
||||||
|
|
||||||
|
this.enrichCommon(query);
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
package eu.eudat.query.lookup;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.query.TagQuery;
|
||||||
|
import gr.cite.tools.data.query.Lookup;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class TagLookup extends Lookup {
|
||||||
|
|
||||||
|
private String like;
|
||||||
|
|
||||||
|
private List<UUID> ids;
|
||||||
|
|
||||||
|
private List<UUID> excludedIds;
|
||||||
|
|
||||||
|
private List<IsActive> isActive;
|
||||||
|
|
||||||
|
private List<UUID> createdByIds;
|
||||||
|
|
||||||
|
public String getLike() {
|
||||||
|
return like;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLike(String like) {
|
||||||
|
this.like = like;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UUID> getIds() {
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIds(List<UUID> ids) {
|
||||||
|
this.ids = ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UUID> getExcludedIds() {
|
||||||
|
return excludedIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExcludedIds(List<UUID> excludedIds) {
|
||||||
|
this.excludedIds = excludedIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<IsActive> getIsActive() {
|
||||||
|
return isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsActive(List<IsActive> isActive) {
|
||||||
|
this.isActive = isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UUID> getCreatedByIds() {
|
||||||
|
return createdByIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedByIds(List<UUID> createdByIds) {
|
||||||
|
this.createdByIds = createdByIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TagQuery enrich(QueryFactory queryFactory) {
|
||||||
|
TagQuery query = queryFactory.query(TagQuery.class);
|
||||||
|
if (this.like != null) query.like(this.like);
|
||||||
|
if (this.ids != null) query.ids(this.ids);
|
||||||
|
if (this.excludedIds != null) query.excludedIds(this.excludedIds);
|
||||||
|
if (this.isActive != null) query.isActive(this.isActive);
|
||||||
|
if (this.createdByIds != null) query.createdByIds(this.createdByIds);
|
||||||
|
|
||||||
|
this.enrichCommon(query);
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -107,9 +107,9 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
}
|
}
|
||||||
|
|
||||||
data.setLabel(model.getLabel());
|
data.setLabel(model.getLabel());
|
||||||
data.setDmp(model.getDmp());
|
data.setDmpId(model.getDmp());
|
||||||
data.setProperties(model.getProperties());
|
data.setProperties(model.getProperties());
|
||||||
data.setDescriptionTemplate(model.getProfile());
|
data.setDescriptionTemplateId(model.getProfile());
|
||||||
data.setStatus(model.getStatus());
|
data.setStatus(model.getStatus());
|
||||||
data.setDescription(model.getDescription());
|
data.setDescription(model.getDescription());
|
||||||
data.setUpdatedAt(Instant.now());
|
data.setUpdatedAt(Instant.now());
|
||||||
|
|
|
@ -162,7 +162,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
|
|
||||||
data.setDescription(model.getDescription());
|
data.setDescription(model.getDescription());
|
||||||
data.setLabel(model.getLabel());
|
data.setLabel(model.getLabel());
|
||||||
data.setType(model.getType());
|
data.setTypeId(model.getType());
|
||||||
data.setLanguage(model.getLanguage());
|
data.setLanguage(model.getLanguage());
|
||||||
data.setStatus(model.getStatus());
|
data.setStatus(model.getStatus());
|
||||||
data.setUpdatedAt(Instant.now());
|
data.setUpdatedAt(Instant.now());
|
||||||
|
@ -478,7 +478,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
data.setVersion((short)(oldDescriptionTemplateEntity.getVersion() + 1));
|
data.setVersion((short)(oldDescriptionTemplateEntity.getVersion() + 1));
|
||||||
data.setDescription(model.getDescription());
|
data.setDescription(model.getDescription());
|
||||||
data.setLabel(model.getLabel());
|
data.setLabel(model.getLabel());
|
||||||
data.setType(model.getType());
|
data.setTypeId(model.getType());
|
||||||
data.setLanguage(model.getLanguage());
|
data.setLanguage(model.getLanguage());
|
||||||
data.setStatus(model.getStatus());
|
data.setStatus(model.getStatus());
|
||||||
data.setDefinition(this.xmlHandlingService.toXml(this.buildDefinitionEntity(model.getDefinition())));
|
data.setDefinition(this.xmlHandlingService.toXml(this.buildDefinitionEntity(model.getDefinition())));
|
||||||
|
@ -671,7 +671,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
|
|
||||||
private DescriptionTemplateImportExport definitionXmlToExport(DescriptionTemplateEntity data, DefinitionEntity entity){
|
private DescriptionTemplateImportExport definitionXmlToExport(DescriptionTemplateEntity data, DefinitionEntity entity){
|
||||||
DescriptionTemplateImportExport xml = new DescriptionTemplateImportExport();
|
DescriptionTemplateImportExport xml = new DescriptionTemplateImportExport();
|
||||||
xml.setType(data.getType());
|
xml.setType(data.getTypeId());
|
||||||
xml.setLanguage(data.getLanguage());
|
xml.setLanguage(data.getLanguage());
|
||||||
xml.setDescription(data.getDescription());
|
xml.setDescription(data.getDescription());
|
||||||
List<PageImportExport> pagesDatasetEntity = new LinkedList<>();
|
List<PageImportExport> pagesDatasetEntity = new LinkedList<>();
|
||||||
|
|
|
@ -143,7 +143,7 @@ public class FileController {
|
||||||
throw new NoSuchElementException("No dataset with id " + fileUpload.getEntityId() + " found. This dataset was related to the file with id " + id);
|
throw new NoSuchElementException("No dataset with id " + fileUpload.getEntityId() + " found. This dataset was related to the file with id " + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
DMP dmp = databaseRepository.getDmpDao().find(descriptionEntityEntity.getDmp());
|
DMP dmp = databaseRepository.getDmpDao().find(descriptionEntityEntity.getDmpId());
|
||||||
|
|
||||||
if (!dmp.isPublic() && dmp.getUsers()
|
if (!dmp.isPublic() && dmp.getUsers()
|
||||||
.stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
.stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class DatasetProfileBuilder extends Builder<DescriptionTemplateEntity> {
|
||||||
descriptionTemplateEntity.setUpdatedAt(modified);
|
descriptionTemplateEntity.setUpdatedAt(modified);
|
||||||
descriptionTemplateEntity.setLabel(label);
|
descriptionTemplateEntity.setLabel(label);
|
||||||
descriptionTemplateEntity.setLanguage(language);
|
descriptionTemplateEntity.setLanguage(language);
|
||||||
descriptionTemplateEntity.setType(type);
|
descriptionTemplateEntity.setTypeId(type);
|
||||||
return descriptionTemplateEntity;
|
return descriptionTemplateEntity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -494,7 +494,7 @@ public class DataManagementPlanManager {
|
||||||
}
|
}
|
||||||
List<DescriptionEntity> descriptionEntityList = dmp1.getDataset().stream().filter(dataset -> dataset.getIsActive() != IsActive.Inactive).collect(Collectors.toList());
|
List<DescriptionEntity> descriptionEntityList = dmp1.getDataset().stream().filter(dataset -> dataset.getIsActive() != IsActive.Inactive).collect(Collectors.toList());
|
||||||
for (DescriptionEntity descriptionEntity : descriptionEntityList) {
|
for (DescriptionEntity descriptionEntity : descriptionEntityList) {
|
||||||
if (dataManagementPlan.getProfiles().stream().filter(associatedProfile -> descriptionEntity.getDescriptionTemplate().equals(associatedProfile.getDescriptionTemplateId())).findAny().orElse(null) == null)
|
if (dataManagementPlan.getProfiles().stream().filter(associatedProfile -> descriptionEntity.getDescriptionTemplateId().equals(associatedProfile.getDescriptionTemplateId())).findAny().orElse(null) == null)
|
||||||
throw new Exception("Dataset Template for Dataset Description is missing from the DMP.");
|
throw new Exception("Dataset Template for Dataset Description is missing from the DMP.");
|
||||||
}
|
}
|
||||||
if (dataManagementPlan.getStatus() == (int) DMP.DMPStatus.FINALISED.getValue() && dmp1.getStatus().equals(DMP.DMPStatus.FINALISED.getValue()))
|
if (dataManagementPlan.getStatus() == (int) DMP.DMPStatus.FINALISED.getValue() && dmp1.getStatus().equals(DMP.DMPStatus.FINALISED.getValue()))
|
||||||
|
@ -917,7 +917,7 @@ public class DataManagementPlanManager {
|
||||||
if (elastic != null) {
|
if (elastic != null) {
|
||||||
tags = elastic.getTags();
|
tags = elastic.getTags();
|
||||||
}
|
}
|
||||||
descriptionEntity.setDmp(dmp.getId());
|
descriptionEntity.setDmpId(dmp.getId());
|
||||||
this.datasetManager.updateTags(descriptionEntity, tags);
|
this.datasetManager.updateTags(descriptionEntity, tags);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
|
@ -1049,7 +1049,7 @@ public class DataManagementPlanManager {
|
||||||
if (elastic != null) {
|
if (elastic != null) {
|
||||||
tags = elastic.getTags();
|
tags = elastic.getTags();
|
||||||
}
|
}
|
||||||
UUID dmpId = tempDescriptionEntity.getDmp();
|
UUID dmpId = tempDescriptionEntity.getDmpId();
|
||||||
//TODO
|
//TODO
|
||||||
//tempDescriptionEntity.getDmp().setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
|
//tempDescriptionEntity.getDmp().setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
|
||||||
this.datasetManager.updateTags(tempDescriptionEntity, tags);
|
this.datasetManager.updateTags(tempDescriptionEntity, tags);
|
||||||
|
@ -1060,7 +1060,7 @@ public class DataManagementPlanManager {
|
||||||
.thenApplyAsync(entityDataset -> {
|
.thenApplyAsync(entityDataset -> {
|
||||||
DescriptionEntity newDescriptionEntity = new DescriptionEntity();
|
DescriptionEntity newDescriptionEntity = new DescriptionEntity();
|
||||||
newDescriptionEntity.update(entityDataset);
|
newDescriptionEntity.update(entityDataset);
|
||||||
newDescriptionEntity.setDmp(newDmp.getId());
|
newDescriptionEntity.setDmpId(newDmp.getId());
|
||||||
newDescriptionEntity.setStatus(DescriptionStatus.Saved);
|
newDescriptionEntity.setStatus(DescriptionStatus.Saved);
|
||||||
//TODO
|
//TODO
|
||||||
// if (newDescriptionEntity.getDatasetDataRepositories() != null) {
|
// if (newDescriptionEntity.getDatasetDataRepositories() != null) {
|
||||||
|
@ -1113,7 +1113,7 @@ public class DataManagementPlanManager {
|
||||||
futures.add(datasetDao.createOrUpdateAsync(item).whenComplete(((dataset1, throwable) -> {
|
futures.add(datasetDao.createOrUpdateAsync(item).whenComplete(((dataset1, throwable) -> {
|
||||||
DMP dmp = null;
|
DMP dmp = null;
|
||||||
try {
|
try {
|
||||||
dmp = this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(dataset1.getDmp());
|
dmp = this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(dataset1.getDmpId());
|
||||||
} catch (InvalidApplicationException e) {
|
} catch (InvalidApplicationException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -1122,9 +1122,9 @@ public class DataManagementPlanManager {
|
||||||
datasetElastic.setId(dataset1.getId().toString());
|
datasetElastic.setId(dataset1.getId().toString());
|
||||||
datasetElastic.setLabel(dataset1.getLabel());
|
datasetElastic.setLabel(dataset1.getLabel());
|
||||||
datasetElastic.setDescription(dataset1.getDescription());
|
datasetElastic.setDescription(dataset1.getDescription());
|
||||||
datasetElastic.setTemplate(dataset1.getDescriptionTemplate());
|
datasetElastic.setTemplate(dataset1.getDescriptionTemplateId());
|
||||||
datasetElastic.setStatus(dataset1.getStatus().getValue());
|
datasetElastic.setStatus(dataset1.getStatus().getValue());
|
||||||
datasetElastic.setDmp(dataset1.getDmp());
|
datasetElastic.setDmp(dataset1.getDmpId());
|
||||||
datasetElastic.setGroup(dmp.getGroupId());
|
datasetElastic.setGroup(dmp.getGroupId());
|
||||||
if(this.dmpBlueprintService.fieldInBlueprint(dmp.getProfile(), DmpBlueprintSystemFieldType.Grant)) {
|
if(this.dmpBlueprintService.fieldInBlueprint(dmp.getProfile(), DmpBlueprintSystemFieldType.Grant)) {
|
||||||
datasetElastic.setGrant(dmp.getGrant().getId());
|
datasetElastic.setGrant(dmp.getGrant().getId());
|
||||||
|
@ -1194,7 +1194,7 @@ public class DataManagementPlanManager {
|
||||||
if (elastic != null) {
|
if (elastic != null) {
|
||||||
tags = elastic.getTags();
|
tags = elastic.getTags();
|
||||||
}
|
}
|
||||||
UUID tmdmpId = dataset.getDmp();
|
UUID tmdmpId = dataset.getDmpId();
|
||||||
//TODO
|
//TODO
|
||||||
//dataset.getDmp().setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), tmdmpId)).toList()));
|
//dataset.getDmp().setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), tmdmpId)).toList()));
|
||||||
this.datasetManager.updateTags(dataset, tags);
|
this.datasetManager.updateTags(dataset, tags);
|
||||||
|
@ -1600,7 +1600,7 @@ public class DataManagementPlanManager {
|
||||||
//runDatasetTemplate1.setBold(true);
|
//runDatasetTemplate1.setBold(true);
|
||||||
//runDatasetTemplate1.setFontSize(12);
|
//runDatasetTemplate1.setFontSize(12);
|
||||||
XWPFRun runDatasetTemplate = datasetTemplateParagraph.createRun();
|
XWPFRun runDatasetTemplate = datasetTemplateParagraph.createRun();
|
||||||
runDatasetTemplate.setText(this.queryFactory.query(DescriptionTemplateQuery.class).ids(datasetEntity.getDescriptionTemplate()).first().getLabel());
|
runDatasetTemplate.setText(this.queryFactory.query(DescriptionTemplateQuery.class).ids(datasetEntity.getDescriptionTemplateId()).first().getLabel());
|
||||||
runDatasetTemplate.setColor("116a78");
|
runDatasetTemplate.setColor("116a78");
|
||||||
//runDatasetTemplate.setBold(true);
|
//runDatasetTemplate.setBold(true);
|
||||||
//runDatasetTemplate.setFontSize(12);
|
//runDatasetTemplate.setFontSize(12);
|
||||||
|
@ -1646,7 +1646,7 @@ public class DataManagementPlanManager {
|
||||||
runDatasetDescription1.setText("Description: ");
|
runDatasetDescription1.setText("Description: ");
|
||||||
runDatasetDescription1.setColor("000000");
|
runDatasetDescription1.setColor("000000");
|
||||||
XWPFRun runDatasetDescription = datasetDescParagraph.createRun();
|
XWPFRun runDatasetDescription = datasetDescParagraph.createRun();
|
||||||
runDatasetDescription.setText(this.queryFactory.query(DescriptionTemplateQuery.class).ids(datasetEntity.getDescriptionTemplate()).first().getLabel());
|
runDatasetDescription.setText(this.queryFactory.query(DescriptionTemplateQuery.class).ids(datasetEntity.getDescriptionTemplateId()).first().getLabel());
|
||||||
runDatasetDescription.setColor("116a78");
|
runDatasetDescription.setColor("116a78");
|
||||||
//wordBuilder.addParagraphContent(datasetEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO, 0);
|
//wordBuilder.addParagraphContent(datasetEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO, 0);
|
||||||
|
|
||||||
|
@ -1928,11 +1928,11 @@ public class DataManagementPlanManager {
|
||||||
|
|
||||||
Element datsetProfileElement = xmlDoc.createElement("profile-id");
|
Element datsetProfileElement = xmlDoc.createElement("profile-id");
|
||||||
datasetElement.appendChild(datsetProfileElement);
|
datasetElement.appendChild(datsetProfileElement);
|
||||||
datsetProfileElement.setTextContent(descriptionEntity.getDescriptionTemplate().toString());
|
datsetProfileElement.setTextContent(descriptionEntity.getDescriptionTemplateId().toString());
|
||||||
|
|
||||||
Element datsetProfileLabelElement = xmlDoc.createElement("profile-label");
|
Element datsetProfileLabelElement = xmlDoc.createElement("profile-label");
|
||||||
datasetElement.appendChild(datsetProfileLabelElement);
|
datasetElement.appendChild(datsetProfileLabelElement);
|
||||||
datsetProfileLabelElement.setTextContent(this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntity.getDescriptionTemplate()).first().getLabel());
|
datsetProfileLabelElement.setTextContent(this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntity.getDescriptionTemplateId()).first().getLabel());
|
||||||
|
|
||||||
DatasetWizardModel datasetWizardModel = new DatasetWizardModel();
|
DatasetWizardModel datasetWizardModel = new DatasetWizardModel();
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
|
@ -2235,9 +2235,9 @@ public class DataManagementPlanManager {
|
||||||
//TODO
|
//TODO
|
||||||
// descriptionEntity.setDmpSectionIndex(das.getDmpSectionIndex());
|
// descriptionEntity.setDmpSectionIndex(das.getDmpSectionIndex());
|
||||||
try {
|
try {
|
||||||
descriptionEntity.setDescriptionTemplate(das.getProfile());
|
descriptionEntity.setDescriptionTemplateId(das.getProfile());
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
descriptionEntity.setDescriptionTemplate(associatedProfiles.get(0).getDescriptionTemplateId());
|
descriptionEntity.setDescriptionTemplateId(associatedProfiles.get(0).getDescriptionTemplateId());
|
||||||
}
|
}
|
||||||
descriptionEntity.setProperties(objectMapper.writeValueAsString(das.getFieldImportModels()));
|
descriptionEntity.setProperties(objectMapper.writeValueAsString(das.getFieldImportModels()));
|
||||||
descriptionEntity.setStatus(DescriptionStatus.Saved);
|
descriptionEntity.setStatus(DescriptionStatus.Saved);
|
||||||
|
@ -2245,7 +2245,7 @@ public class DataManagementPlanManager {
|
||||||
// descriptionEntity.setDatasetDataRepositories(new HashSet<>());
|
// descriptionEntity.setDatasetDataRepositories(new HashSet<>());
|
||||||
// descriptionEntity.setServices(new HashSet<>());
|
// descriptionEntity.setServices(new HashSet<>());
|
||||||
// descriptionEntity.setDatasetExternalDatasets(new HashSet<>());
|
// descriptionEntity.setDatasetExternalDatasets(new HashSet<>());
|
||||||
descriptionEntity.setDmp(dmp.getId());
|
descriptionEntity.setDmpId(dmp.getId());
|
||||||
DatasetWizardModel datasetWizard = new DatasetWizardModel();
|
DatasetWizardModel datasetWizard = new DatasetWizardModel();
|
||||||
datasetWizard.setDatasetProfileDefinition(this.datasetManager.getPagedProfile(datasetWizard, descriptionEntity));
|
datasetWizard.setDatasetProfileDefinition(this.datasetManager.getPagedProfile(datasetWizard, descriptionEntity));
|
||||||
datasetWizard.fromDataModel(descriptionEntity);
|
datasetWizard.fromDataModel(descriptionEntity);
|
||||||
|
@ -2294,7 +2294,7 @@ public class DataManagementPlanManager {
|
||||||
dataset.setStatus(DescriptionStatus.Saved);
|
dataset.setStatus(DescriptionStatus.Saved);
|
||||||
dataset.setCreatedAt(Instant.now());
|
dataset.setCreatedAt(Instant.now());
|
||||||
dataset.setUpdatedAt(Instant.now());
|
dataset.setUpdatedAt(Instant.now());
|
||||||
dataset.setDmp(dmp.getId());
|
dataset.setDmpId(dmp.getId());
|
||||||
dataset = databaseRepository.getDatasetDao().createOrUpdate(dataset);
|
dataset = databaseRepository.getDatasetDao().createOrUpdate(dataset);
|
||||||
// dataset.setRegistries(new HashSet<>());
|
// dataset.setRegistries(new HashSet<>());
|
||||||
// dataset.setDatasetDataRepositories(new HashSet<>());
|
// dataset.setDatasetDataRepositories(new HashSet<>());
|
||||||
|
@ -2401,7 +2401,7 @@ public class DataManagementPlanManager {
|
||||||
if (elastic != null) {
|
if (elastic != null) {
|
||||||
tags = elastic.getTags();
|
tags = elastic.getTags();
|
||||||
}
|
}
|
||||||
UUID dmpId = dataset.getDmp();
|
UUID dmpId = dataset.getDmpId();
|
||||||
//TODO
|
//TODO
|
||||||
//dataset.getDmp().setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
|
//dataset.getDmp().setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
|
||||||
this.datasetManager.updateTags(dataset, tags);
|
this.datasetManager.updateTags(dataset, tags);
|
||||||
|
|
|
@ -299,7 +299,7 @@ public class DatasetManager {
|
||||||
public DatasetWizardModel getSingle(String id) throws InvalidApplicationException {
|
public DatasetWizardModel getSingle(String id) throws InvalidApplicationException {
|
||||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||||
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
||||||
DMP dmp = databaseRepository.getDmpDao().find(descriptionEntityEntity.getDmp());
|
DMP dmp = databaseRepository.getDmpDao().find(descriptionEntityEntity.getDmpId());
|
||||||
if (dmp.getUsers()
|
if (dmp.getUsers()
|
||||||
.stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
.stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
||||||
.collect(Collectors.toList()).size() == 0 && !dmp.isPublic())
|
.collect(Collectors.toList()).size() == 0 && !dmp.isPublic())
|
||||||
|
@ -309,7 +309,7 @@ public class DatasetManager {
|
||||||
|
|
||||||
// Creates the Criteria to get all version of DescriptionTemplate in question.
|
// Creates the Criteria to get all version of DescriptionTemplate in question.
|
||||||
DatasetProfileCriteria profileCriteria = new DatasetProfileCriteria();
|
DatasetProfileCriteria profileCriteria = new DatasetProfileCriteria();
|
||||||
UUID profileId = this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDescriptionTemplate()).first().getGroupId();
|
UUID profileId = this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDescriptionTemplateId()).first().getGroupId();
|
||||||
List<UUID> uuidList = new LinkedList<>();
|
List<UUID> uuidList = new LinkedList<>();
|
||||||
uuidList.add(profileId);
|
uuidList.add(profileId);
|
||||||
profileCriteria.setGroupIds(uuidList);
|
profileCriteria.setGroupIds(uuidList);
|
||||||
|
@ -340,7 +340,7 @@ public class DatasetManager {
|
||||||
DescriptionTemplateEntity profile = profiles.get(0);
|
DescriptionTemplateEntity profile = profiles.get(0);
|
||||||
|
|
||||||
// Check if the dataset is on the latest Version.
|
// Check if the dataset is on the latest Version.
|
||||||
boolean latestVersion = profile.getVersion().toString().equals(this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDescriptionTemplate()).first().getVersion());
|
boolean latestVersion = profile.getVersion().toString().equals(this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDescriptionTemplateId()).first().getVersion());
|
||||||
dataset.setIsProfileLatestVersion(latestVersion);
|
dataset.setIsProfileLatestVersion(latestVersion);
|
||||||
|
|
||||||
eu.eudat.elastic.entities.Dataset datasetElastic;
|
eu.eudat.elastic.entities.Dataset datasetElastic;
|
||||||
|
@ -364,7 +364,7 @@ public class DatasetManager {
|
||||||
public DatasetWizardModel getSinglePublic(String id) throws Exception {
|
public DatasetWizardModel getSinglePublic(String id) throws Exception {
|
||||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||||
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().isPublicDataset(UUID.fromString(id));
|
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().isPublicDataset(UUID.fromString(id));
|
||||||
DMP dmp = databaseRepository.getDmpDao().find(descriptionEntityEntity.getDmp());
|
DMP dmp = databaseRepository.getDmpDao().find(descriptionEntityEntity.getDmpId());
|
||||||
if (descriptionEntityEntity != null && descriptionEntityEntity.getStatus() == DescriptionStatus.Finalized && dmp.getStatus() == 1) {
|
if (descriptionEntityEntity != null && descriptionEntityEntity.getStatus() == DescriptionStatus.Finalized && dmp.getStatus() == 1) {
|
||||||
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, descriptionEntityEntity));
|
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, descriptionEntityEntity));
|
||||||
dataset.fromDataModel(descriptionEntityEntity);
|
dataset.fromDataModel(descriptionEntityEntity);
|
||||||
|
@ -379,7 +379,7 @@ public class DatasetManager {
|
||||||
if (descriptionEntityEntity.getIsActive() == IsActive.Inactive) {
|
if (descriptionEntityEntity.getIsActive() == IsActive.Inactive) {
|
||||||
throw new Exception("Dataset is deleted.");
|
throw new Exception("Dataset is deleted.");
|
||||||
}
|
}
|
||||||
DMP dmp = databaseRepository.getDmpDao().find(descriptionEntityEntity.getDmp());
|
DMP dmp = databaseRepository.getDmpDao().find(descriptionEntityEntity.getDmpId());
|
||||||
if (!isPublic && !this.userScope.isSet()) {
|
if (!isPublic && !this.userScope.isSet()) {
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
} else
|
} else
|
||||||
|
@ -400,7 +400,7 @@ public class DatasetManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PagedDatasetProfile getPagedProfile(DatasetWizardModel dataset, DescriptionEntity descriptionEntityEntity) {
|
public PagedDatasetProfile getPagedProfile(DatasetWizardModel dataset, DescriptionEntity descriptionEntityEntity) {
|
||||||
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDescriptionTemplate()).first());
|
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDescriptionTemplateId()).first());
|
||||||
datasetprofile.setStatus(dataset.getStatus().getValue());
|
datasetprofile.setStatus(dataset.getStatus().getValue());
|
||||||
if (descriptionEntityEntity.getProperties() != null) {
|
if (descriptionEntityEntity.getProperties() != null) {
|
||||||
JSONObject jObject = new JSONObject(descriptionEntityEntity.getProperties());
|
JSONObject jObject = new JSONObject(descriptionEntityEntity.getProperties());
|
||||||
|
@ -417,7 +417,7 @@ public class DatasetManager {
|
||||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||||
XWPFDocument document = configLoader.getDatasetDocument();
|
XWPFDocument document = configLoader.getDatasetDocument();
|
||||||
|
|
||||||
DMP dmpEntity = databaseRepository.getDmpDao().find(descriptionEntityEntity.getDmp());
|
DMP dmpEntity = databaseRepository.getDmpDao().find(descriptionEntityEntity.getDmpId());
|
||||||
if (!dmpEntity.isPublic() && dmpEntity.getUsers().stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId())).collect(Collectors.toList()).size() == 0)
|
if (!dmpEntity.isPublic() && dmpEntity.getUsers().stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId())).collect(Collectors.toList()).size() == 0)
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
|
|
||||||
|
@ -555,7 +555,7 @@ public class DatasetManager {
|
||||||
|
|
||||||
public FileEnvelope getWordDocumentFile(ConfigLoader configLoader, String id, VisibilityRuleService visibilityRuleService) throws IOException, InvalidApplicationException {
|
public FileEnvelope getWordDocumentFile(ConfigLoader configLoader, String id, VisibilityRuleService visibilityRuleService) throws IOException, InvalidApplicationException {
|
||||||
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
||||||
DMP dmp = databaseRepository.getDmpDao().find(descriptionEntityEntity.getDmp());
|
DMP dmp = databaseRepository.getDmpDao().find(descriptionEntityEntity.getDmpId());
|
||||||
if (!dmp.isPublic() && dmp.getUsers()
|
if (!dmp.isPublic() && dmp.getUsers()
|
||||||
.stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
.stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
||||||
.collect(Collectors.toList()).size() == 0)
|
.collect(Collectors.toList()).size() == 0)
|
||||||
|
@ -585,7 +585,7 @@ public class DatasetManager {
|
||||||
ExportXmlBuilder xmlBuilder = new ExportXmlBuilder();
|
ExportXmlBuilder xmlBuilder = new ExportXmlBuilder();
|
||||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||||
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
||||||
DMP dmp = databaseRepository.getDmpDao().find(descriptionEntityEntity.getDmp());
|
DMP dmp = databaseRepository.getDmpDao().find(descriptionEntityEntity.getDmpId());
|
||||||
if (!dmp.isPublic() && dmp.getUsers()
|
if (!dmp.isPublic() && dmp.getUsers()
|
||||||
.stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
.stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
||||||
.collect(Collectors.toList()).size() == 0)
|
.collect(Collectors.toList()).size() == 0)
|
||||||
|
@ -598,7 +598,7 @@ public class DatasetManager {
|
||||||
PagedDatasetProfile pagedDatasetProfile = getPagedProfile(dataset, descriptionEntityEntity);
|
PagedDatasetProfile pagedDatasetProfile = getPagedProfile(dataset, descriptionEntityEntity);
|
||||||
visibilityRuleService.setProperties(properties);
|
visibilityRuleService.setProperties(properties);
|
||||||
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
||||||
File file = xmlBuilder.build(pagedDatasetProfile, descriptionEntityEntity.getDescriptionTemplate(), visibilityRuleService, environment);
|
File file = xmlBuilder.build(pagedDatasetProfile, descriptionEntityEntity.getDescriptionTemplateId(), visibilityRuleService, environment);
|
||||||
FileEnvelope fileEnvelope = new FileEnvelope();
|
FileEnvelope fileEnvelope = new FileEnvelope();
|
||||||
fileEnvelope.setFile(file);
|
fileEnvelope.setFile(file);
|
||||||
String label = descriptionEntityEntity.getLabel().replaceAll("[^a-zA-Z0-9+ ]", "");
|
String label = descriptionEntityEntity.getLabel().replaceAll("[^a-zA-Z0-9+ ]", "");
|
||||||
|
@ -627,7 +627,7 @@ public class DatasetManager {
|
||||||
if (dmp.getStatus().equals(DMP.DMPStatus.FINALISED.getValue()) && datasetWizardModel.getId() != null)
|
if (dmp.getStatus().equals(DMP.DMPStatus.FINALISED.getValue()) && datasetWizardModel.getId() != null)
|
||||||
throw new Exception("DMP is finalized, therefore Dataset cannot be edited.");
|
throw new Exception("DMP is finalized, therefore Dataset cannot be edited.");
|
||||||
DescriptionEntity descriptionEntity = datasetWizardModel.toDataModel();
|
DescriptionEntity descriptionEntity = datasetWizardModel.toDataModel();
|
||||||
descriptionEntity.setDmp(dmp.getId());
|
descriptionEntity.setDmpId(dmp.getId());
|
||||||
descriptionEntity.setProperties(propertiesModelToString(datasetWizardModel.getDatasetProfileDefinition()));
|
descriptionEntity.setProperties(propertiesModelToString(datasetWizardModel.getDatasetProfileDefinition()));
|
||||||
if (this.apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().getClient() != null) {
|
if (this.apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().getClient() != null) {
|
||||||
this.getTagsFromProfile(datasetWizardModel, descriptionEntity);
|
this.getTagsFromProfile(datasetWizardModel, descriptionEntity);
|
||||||
|
@ -639,7 +639,7 @@ public class DatasetManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UserInfo userInfo = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(this.userScope.getUserId()).build();
|
UserInfo userInfo = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(this.userScope.getUserId()).build();
|
||||||
descriptionEntity.setDmpDescriptionTemplate(userInfo.getId());
|
descriptionEntity.setDmpDescriptionTemplateId(userInfo.getId());
|
||||||
|
|
||||||
createDataRepositoriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao(), descriptionEntity);
|
createDataRepositoriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao(), descriptionEntity);
|
||||||
createExternalDatasetsIfTheyDontExist(descriptionEntity);
|
createExternalDatasetsIfTheyDontExist(descriptionEntity);
|
||||||
|
@ -648,14 +648,14 @@ public class DatasetManager {
|
||||||
DescriptionEntity descriptionEntity1 = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(descriptionEntity);
|
DescriptionEntity descriptionEntity1 = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(descriptionEntity);
|
||||||
datasetWizardModel.setId(descriptionEntity1.getId());
|
datasetWizardModel.setId(descriptionEntity1.getId());
|
||||||
if (datasetWizardModel.getDmp().getGrant() == null) {
|
if (datasetWizardModel.getDmp().getGrant() == null) {
|
||||||
DMP dmp1 = databaseRepository.getDmpDao().find(descriptionEntity1.getDmp());
|
DMP dmp1 = databaseRepository.getDmpDao().find(descriptionEntity1.getDmpId());
|
||||||
|
|
||||||
datasetWizardModel.setDmp(new DataManagementPlan().fromDataModelNoDatasets(dmp1));
|
datasetWizardModel.setDmp(new DataManagementPlan().fromDataModelNoDatasets(dmp1));
|
||||||
}
|
}
|
||||||
descriptionEntity1.setDescriptionTemplate(datasetWizardModel.getProfile().getId());
|
descriptionEntity1.setDescriptionTemplateId(datasetWizardModel.getProfile().getId());
|
||||||
// datasetWizardModel.setDatasetProfileDefinition(getPagedProfile(datasetWizardModel, dataset1));
|
// datasetWizardModel.setDatasetProfileDefinition(getPagedProfile(datasetWizardModel, dataset1));
|
||||||
UUID dmpId = descriptionEntity1.getDmp();
|
UUID dmpId = descriptionEntity1.getDmpId();
|
||||||
DMP dmp1 = databaseRepository.getDmpDao().find(descriptionEntity1.getDmp());
|
DMP dmp1 = databaseRepository.getDmpDao().find(descriptionEntity1.getDmpId());
|
||||||
dmp1.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
|
dmp1.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
|
||||||
updateTags(descriptionEntity1, datasetWizardModel.getTags());
|
updateTags(descriptionEntity1, datasetWizardModel.getTags());
|
||||||
if (sendNotification) {
|
if (sendNotification) {
|
||||||
|
@ -737,7 +737,7 @@ public class DatasetManager {
|
||||||
|
|
||||||
public String checkDatasetValidation(DescriptionEntity descriptionEntity) throws Exception {
|
public String checkDatasetValidation(DescriptionEntity descriptionEntity) throws Exception {
|
||||||
List<String> datasetProfileValidators = new LinkedList<>();
|
List<String> datasetProfileValidators = new LinkedList<>();
|
||||||
DescriptionTemplateEntity profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(descriptionEntity.getDescriptionTemplate());
|
DescriptionTemplateEntity profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(descriptionEntity.getDescriptionTemplateId());
|
||||||
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
|
||||||
DocumentBuilder builder = builderFactory.newDocumentBuilder();
|
DocumentBuilder builder = builderFactory.newDocumentBuilder();
|
||||||
Document xmlDocument = builder.parse(new ByteArrayInputStream(profile.getDefinition().getBytes()));
|
Document xmlDocument = builder.parse(new ByteArrayInputStream(profile.getDefinition().getBytes()));
|
||||||
|
@ -759,7 +759,7 @@ public class DatasetManager {
|
||||||
VisibilityRuleService visibilityRuleService = new VisibilityRuleServiceImpl();
|
VisibilityRuleService visibilityRuleService = new VisibilityRuleServiceImpl();
|
||||||
visibilityRuleService.setProperties(obj.toMap());
|
visibilityRuleService.setProperties(obj.toMap());
|
||||||
|
|
||||||
descriptionEntity.setDescriptionTemplate(profile.getId());
|
descriptionEntity.setDescriptionTemplateId(profile.getId());
|
||||||
PagedDatasetProfile pagedDatasetProfile = this.getPagedProfile(new DatasetWizardModel(), descriptionEntity);
|
PagedDatasetProfile pagedDatasetProfile = this.getPagedProfile(new DatasetWizardModel(), descriptionEntity);
|
||||||
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
||||||
|
|
||||||
|
@ -1030,16 +1030,16 @@ public class DatasetManager {
|
||||||
entity.setLabel(importFile.getOriginalFilename());
|
entity.setLabel(importFile.getOriginalFilename());
|
||||||
DMP dmp = new DMP();
|
DMP dmp = new DMP();
|
||||||
dmp.setId(UUID.fromString(dmpId));
|
dmp.setId(UUID.fromString(dmpId));
|
||||||
entity.setDmp(dmp.getId());
|
entity.setDmpId(dmp.getId());
|
||||||
entity.setStatus(DescriptionStatus.Saved);
|
entity.setStatus(DescriptionStatus.Saved);
|
||||||
entity.setCreatedAt(Instant.now());
|
entity.setCreatedAt(Instant.now());
|
||||||
entity.setUpdatedAt(Instant.now());
|
entity.setUpdatedAt(Instant.now());
|
||||||
DescriptionTemplateEntity profile = new DescriptionTemplateEntity();
|
DescriptionTemplateEntity profile = new DescriptionTemplateEntity();
|
||||||
profile.setId(UUID.fromString(datasetProfileId));
|
profile.setId(UUID.fromString(datasetProfileId));
|
||||||
entity.setDescriptionTemplate(profile.getId());
|
entity.setDescriptionTemplateId(profile.getId());
|
||||||
|
|
||||||
UserInfo userInfo = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(this.userScope.getUserId()).build();
|
UserInfo userInfo = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(this.userScope.getUserId()).build();
|
||||||
entity.setDmpDescriptionTemplate(userInfo.getId());
|
entity.setDmpDescriptionTemplateId(userInfo.getId());
|
||||||
|
|
||||||
updateTagsXmlImportDataset(apiContext.getOperationsContext().getElasticRepository().getDatasetRepository(), entity);
|
updateTagsXmlImportDataset(apiContext.getOperationsContext().getElasticRepository().getDatasetRepository(), entity);
|
||||||
createRegistriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao(), entity);
|
createRegistriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao(), entity);
|
||||||
|
@ -1064,7 +1064,7 @@ public class DatasetManager {
|
||||||
// Creates the Criteria to get all version of DescriptionTemplate in question.
|
// Creates the Criteria to get all version of DescriptionTemplate in question.
|
||||||
DatasetProfileCriteria profileCriteria = new DatasetProfileCriteria();
|
DatasetProfileCriteria profileCriteria = new DatasetProfileCriteria();
|
||||||
|
|
||||||
UUID profileId = this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDescriptionTemplate()).first().getGroupId();
|
UUID profileId = this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDescriptionTemplateId()).first().getGroupId();
|
||||||
List<UUID> uuidList = new LinkedList<>();
|
List<UUID> uuidList = new LinkedList<>();
|
||||||
uuidList.add(profileId);
|
uuidList.add(profileId);
|
||||||
profileCriteria.setGroupIds(uuidList);
|
profileCriteria.setGroupIds(uuidList);
|
||||||
|
@ -1130,8 +1130,8 @@ public class DatasetManager {
|
||||||
descriptionEntityEntities.forEach(datasetEntity -> {
|
descriptionEntityEntities.forEach(datasetEntity -> {
|
||||||
try {
|
try {
|
||||||
eu.eudat.elastic.entities.Dataset dataset = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(datasetEntity.getId().toString());
|
eu.eudat.elastic.entities.Dataset dataset = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(datasetEntity.getId().toString());
|
||||||
UUID dmpId = datasetEntity.getDmp();
|
UUID dmpId = datasetEntity.getDmpId();
|
||||||
DMP dmp = databaseRepository.getDmpDao().find(datasetEntity.getDmp());
|
DMP dmp = databaseRepository.getDmpDao().find(datasetEntity.getDmpId());
|
||||||
dmp.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
|
dmp.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
|
||||||
updateTags(datasetEntity, dataset != null ? dataset.getTags() : null);
|
updateTags(datasetEntity, dataset != null ? dataset.getTags() : null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -1152,7 +1152,7 @@ public class DatasetManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getTagsFromProfile(DatasetWizardModel wizardModel, DescriptionEntity descriptionEntity) throws IOException, InvalidApplicationException {
|
public void getTagsFromProfile(DatasetWizardModel wizardModel, DescriptionEntity descriptionEntity) throws IOException, InvalidApplicationException {
|
||||||
descriptionEntity.setDescriptionTemplate(descriptionEntity.getDescriptionTemplate());
|
descriptionEntity.setDescriptionTemplateId(descriptionEntity.getDescriptionTemplateId());
|
||||||
wizardModel.setDatasetProfileDefinition(this.getPagedProfile(wizardModel, descriptionEntity));
|
wizardModel.setDatasetProfileDefinition(this.getPagedProfile(wizardModel, descriptionEntity));
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
String json = mapper.writeValueAsString(wizardModel.getDatasetProfileDefinition());
|
String json = mapper.writeValueAsString(wizardModel.getDatasetProfileDefinition());
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class DatasetWizardManager {
|
||||||
|
|
||||||
public void unlock(ApiContext apiContext, UUID uuid) throws DatasetWizardCannotUnlockException, InvalidApplicationException {
|
public void unlock(ApiContext apiContext, UUID uuid) throws DatasetWizardCannotUnlockException, InvalidApplicationException {
|
||||||
DescriptionEntity descriptionEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(uuid);
|
DescriptionEntity descriptionEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(uuid);
|
||||||
DMP dmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(descriptionEntity.getDmp());
|
DMP dmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(descriptionEntity.getDmpId());
|
||||||
if(dmp.getStatus() == DMP.DMPStatus.FINALISED.getValue()) throw new DatasetWizardCannotUnlockException("To perform this action you will need to revert DMP's finalisation");
|
if(dmp.getStatus() == DMP.DMPStatus.FINALISED.getValue()) throw new DatasetWizardCannotUnlockException("To perform this action you will need to revert DMP's finalisation");
|
||||||
descriptionEntity.setStatus(DescriptionStatus.Saved);
|
descriptionEntity.setStatus(DescriptionStatus.Saved);
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(descriptionEntity);
|
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(descriptionEntity);
|
||||||
|
|
|
@ -19,9 +19,6 @@ import jakarta.transaction.Transactional;
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
import javax.management.InvalidApplicationException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
@ -412,7 +409,7 @@ public class MetricsManager {
|
||||||
List<DescriptionTemplateEntity> descriptionTemplateEntities = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).withFields(Collections.singletonList("id")).toList();
|
List<DescriptionTemplateEntity> descriptionTemplateEntities = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).withFields(Collections.singletonList("id")).toList();
|
||||||
DatasetCriteria datasetCriteria = new DatasetCriteria();
|
DatasetCriteria datasetCriteria = new DatasetCriteria();
|
||||||
datasetCriteria.setDatasetTemplates(descriptionTemplateEntities.stream().map(DescriptionTemplateEntity::getId).collect(Collectors.toList()));
|
datasetCriteria.setDatasetTemplates(descriptionTemplateEntities.stream().map(DescriptionTemplateEntity::getId).collect(Collectors.toList()));
|
||||||
return apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(datasetCriteria).select(root -> root.getDescriptionTemplate()).stream().distinct().count();
|
return apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(datasetCriteria).select(root -> root.getDescriptionTemplateId()).stream().distinct().count();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class DatasetMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dataset toElastic(DescriptionEntity descriptionEntity, List<Tag> tags) throws Exception {
|
public Dataset toElastic(DescriptionEntity descriptionEntity, List<Tag> tags) throws Exception {
|
||||||
if (descriptionEntity.getDescriptionTemplate() == null) {
|
if (descriptionEntity.getDescriptionTemplateId() == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
//TODO
|
//TODO
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class DmpMapper {
|
||||||
if (dataset1 != null) {
|
if (dataset1 != null) {
|
||||||
tags = dataset1.getTags();
|
tags = dataset1.getTags();
|
||||||
}
|
}
|
||||||
dataset.setDmp(dmp.getId());
|
dataset.setDmpId(dmp.getId());
|
||||||
return datasetMapper.toElastic(dataset, tags);
|
return datasetMapper.toElastic(dataset, tags);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class PrefillingMapper {
|
||||||
DatasetWizardModel datasetWizardModel = new DatasetWizardModel();
|
DatasetWizardModel datasetWizardModel = new DatasetWizardModel();
|
||||||
datasetWizardModel.setProfile(new DatasetProfileOverviewModel().fromDataModel(profile));
|
datasetWizardModel.setProfile(new DatasetProfileOverviewModel().fromDataModel(profile));
|
||||||
DescriptionEntity descriptionEntity = new DescriptionEntity();
|
DescriptionEntity descriptionEntity = new DescriptionEntity();
|
||||||
descriptionEntity.setDescriptionTemplate(profile.getId());
|
descriptionEntity.setDescriptionTemplateId(profile.getId());
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
JsonNode parentNode = mapper.readTree(mapper.writeValueAsString(datasetManager.getPagedProfile(datasetWizardModel, descriptionEntity)));
|
JsonNode parentNode = mapper.readTree(mapper.writeValueAsString(datasetManager.getPagedProfile(datasetWizardModel, descriptionEntity)));
|
||||||
for (DefaultPrefillingMapping prefillingMapping: prefillingGet.getMappings()) {
|
for (DefaultPrefillingMapping prefillingMapping: prefillingGet.getMappings()) {
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class DatasetRDAMapper {
|
||||||
}
|
}
|
||||||
rda.setTitle(descriptionEntity.getLabel());
|
rda.setTitle(descriptionEntity.getLabel());
|
||||||
rda.setDescription(descriptionEntity.getDescription());
|
rda.setDescription(descriptionEntity.getDescription());
|
||||||
rda.setAdditionalProperty("template", descriptionEntity.getDescriptionTemplate());
|
rda.setAdditionalProperty("template", descriptionEntity.getDescriptionTemplateId());
|
||||||
try {
|
try {
|
||||||
JSONObject jObject = new JSONObject(descriptionEntity.getProperties());
|
JSONObject jObject = new JSONObject(descriptionEntity.getProperties());
|
||||||
Map<String, Object> templateIdsToValues = jObject.toMap();
|
Map<String, Object> templateIdsToValues = jObject.toMap();
|
||||||
|
@ -288,10 +288,10 @@ public class DatasetRDAMapper {
|
||||||
entity.setDescription(rda.getDescription());
|
entity.setDescription(rda.getDescription());
|
||||||
try {
|
try {
|
||||||
DescriptionTemplateEntity profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(rda.getAdditionalProperties().get("template").toString()));
|
DescriptionTemplateEntity profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(rda.getAdditionalProperties().get("template").toString()));
|
||||||
entity.setDescriptionTemplate(profile.getId());
|
entity.setDescriptionTemplateId(profile.getId());
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
logger.warn(e.getMessage(), e);
|
logger.warn(e.getMessage(), e);
|
||||||
entity.setDescriptionTemplate(defaultProfile.getId());
|
entity.setDescriptionTemplateId(defaultProfile.getId());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
|
|
|
@ -88,6 +88,27 @@ permissions:
|
||||||
clients: [ ]
|
clients: [ ]
|
||||||
allowAnonymous: false
|
allowAnonymous: false
|
||||||
allowAuthenticated: false
|
allowAuthenticated: false
|
||||||
|
|
||||||
|
# Tag
|
||||||
|
BrowseTag:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
EditTag:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
DeleteTag:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
claims: [ ]
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
# DescriptionTemplateType
|
# DescriptionTemplateType
|
||||||
BrowseDescriptionTemplateType:
|
BrowseDescriptionTemplateType:
|
||||||
roles:
|
roles:
|
||||||
|
|
Loading…
Reference in New Issue