description refactor
This commit is contained in:
parent
4a8c3640de
commit
0644e61962
|
@ -31,21 +31,12 @@ 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)
|
|
||||||
private UUID dmpId;
|
|
||||||
|
|
||||||
public static final String _dmpId = "dmpId";
|
|
||||||
|
|
||||||
@Column(name = "properties")
|
@Column(name = "properties")
|
||||||
private String properties;
|
private String properties;
|
||||||
|
|
||||||
public static final String _properties = "properties";
|
public static final String _properties = "properties";
|
||||||
|
|
||||||
@Column(name = "description_template", columnDefinition = "uuid", nullable = false)
|
|
||||||
private UUID descriptionTemplateId;
|
|
||||||
|
|
||||||
public static final String _descriptionTemplateId = "descriptionTemplateId";
|
|
||||||
|
|
||||||
@Column(name = "status", nullable = false)
|
@Column(name = "status", nullable = false)
|
||||||
@Convert(converter = DescriptionStatusConverter.class)
|
@Convert(converter = DescriptionStatusConverter.class)
|
||||||
private DescriptionStatus status;
|
private DescriptionStatus status;
|
||||||
|
@ -105,14 +96,6 @@ public class DescriptionEntity implements DataEntity<DescriptionEntity, UUID> {
|
||||||
this.label = label;
|
this.label = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getDmpId() {
|
|
||||||
return dmpId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDmpId(UUID dmpId) {
|
|
||||||
this.dmpId = dmpId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProperties() {
|
public String getProperties() {
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
@ -121,14 +104,6 @@ public class DescriptionEntity implements DataEntity<DescriptionEntity, UUID> {
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getDescriptionTemplateId() {
|
|
||||||
return descriptionTemplateId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescriptionTemplateId(UUID descriptionTemplateId) {
|
|
||||||
this.descriptionTemplateId = descriptionTemplateId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DescriptionStatus getStatus() {
|
public DescriptionStatus getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,14 +20,14 @@ public class DmpDescriptionTemplateEntity {
|
||||||
public static final String _id = "id";
|
public static final String _id = "id";
|
||||||
|
|
||||||
@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 = "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 = "section_id")
|
@Column(name = "section_id")
|
||||||
private UUID sectionId;
|
private UUID sectionId;
|
||||||
|
@ -58,20 +58,20 @@ public class DmpDescriptionTemplateEntity {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 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 UUID getSectionId() {
|
public UUID getSectionId() {
|
||||||
|
|
|
@ -18,17 +18,10 @@ public class Description {
|
||||||
|
|
||||||
public static final String _label = "label";
|
public static final String _label = "label";
|
||||||
|
|
||||||
private Dmp dmp;
|
|
||||||
|
|
||||||
public static final String _dmp = "dmp";
|
|
||||||
|
|
||||||
private PropertyDefinition properties;
|
private PropertyDefinition properties;
|
||||||
|
|
||||||
public static final String _properties = "properties";
|
public static final String _properties = "properties";
|
||||||
|
|
||||||
private DescriptionTemplate descriptionTemplate;
|
|
||||||
|
|
||||||
public static final String _descriptionTemplate = "descriptionTemplate";
|
|
||||||
|
|
||||||
private DescriptionStatus status;
|
private DescriptionStatus status;
|
||||||
|
|
||||||
|
@ -90,13 +83,6 @@ public class Description {
|
||||||
this.label = label;
|
this.label = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dmp getDmp() {
|
|
||||||
return dmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDmp(Dmp dmp) {
|
|
||||||
this.dmp = dmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PropertyDefinition getProperties() {
|
public PropertyDefinition getProperties() {
|
||||||
return properties;
|
return properties;
|
||||||
|
@ -170,14 +156,6 @@ public class Description {
|
||||||
this.descriptionReferences = descriptionReferences;
|
this.descriptionReferences = descriptionReferences;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DescriptionTemplate getDescriptionTemplate() {
|
|
||||||
return descriptionTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescriptionTemplate(DescriptionTemplate descriptionTemplate) {
|
|
||||||
this.descriptionTemplate = descriptionTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Instant getCreatedAt() {
|
public Instant getCreatedAt() {
|
||||||
return createdAt;
|
return createdAt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,12 +59,6 @@ public class DescriptionBuilder extends BaseBuilder<Description, DescriptionEnti
|
||||||
if (fields == null || data == null || fields.isEmpty())
|
if (fields == null || data == null || fields.isEmpty())
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
|
|
||||||
FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(Description._dmp));
|
|
||||||
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));
|
FieldSet dmpDescriptionTemplateFields = fields.extractPrefixed(this.asPrefix(Description._dmpDescriptionTemplate));
|
||||||
Map<UUID, DmpDescriptionTemplate> dmpDescriptionTemplateItemsMap = this.collectDmpDescriptionTemplates(dmpDescriptionTemplateFields, data);
|
Map<UUID, DmpDescriptionTemplate> dmpDescriptionTemplateItemsMap = this.collectDmpDescriptionTemplates(dmpDescriptionTemplateFields, data);
|
||||||
|
|
||||||
|
@ -88,9 +82,7 @@ public class DescriptionBuilder extends BaseBuilder<Description, DescriptionEnti
|
||||||
if (fields.hasField(this.asIndexer(Description._isActive))) m.setIsActive(d.getIsActive());
|
if (fields.hasField(this.asIndexer(Description._isActive))) m.setIsActive(d.getIsActive());
|
||||||
if (fields.hasField(this.asIndexer(Description._finalizedAt))) m.setFinalizedAt(d.getFinalizedAt());
|
if (fields.hasField(this.asIndexer(Description._finalizedAt))) m.setFinalizedAt(d.getFinalizedAt());
|
||||||
if (fields.hasField(this.asIndexer(Description._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
|
if (fields.hasField(this.asIndexer(Description._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
|
||||||
if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) m.setDmp(dmpItemsMap.get(d.getDmpId()));
|
if (!dmpDescriptionTemplateFields.isEmpty() && dmpDescriptionTemplateItemsMap != null && dmpDescriptionTemplateItemsMap.containsKey(d.getDmpDescriptionTemplateId())) m.setDmpDescriptionTemplate(dmpDescriptionTemplateItemsMap.get(d.getDmpDescriptionTemplateId()));
|
||||||
if (!descriptionTemplateFields.isEmpty() && descriptionTemplateItemsMap != null && descriptionTemplateItemsMap.containsKey(d.getDmpId())) m.setDescriptionTemplate(descriptionTemplateItemsMap.get(d.getDescriptionTemplateId()));
|
|
||||||
if (!dmpDescriptionTemplateFields.isEmpty() && dmpDescriptionTemplateItemsMap != null && dmpDescriptionTemplateItemsMap.containsKey(d.getDmpId())) m.setDmpDescriptionTemplate(dmpDescriptionTemplateItemsMap.get(d.getDmpDescriptionTemplateId()));
|
|
||||||
if (!descriptionReferencesFields.isEmpty() && descriptionReferencesMap != null && descriptionReferencesMap.containsKey(d.getId())) m.setDescriptionReferences(descriptionReferencesMap.get(d.getId()));
|
if (!descriptionReferencesFields.isEmpty() && descriptionReferencesMap != null && descriptionReferencesMap.containsKey(d.getId())) m.setDescriptionReferences(descriptionReferencesMap.get(d.getId()));
|
||||||
if (!descriptionTagsFields.isEmpty() && descriptionTagsMap != null && descriptionTagsMap.containsKey(d.getId())) m.setDescriptionTags(descriptionTagsMap.get(d.getId()));
|
if (!descriptionTagsFields.isEmpty() && descriptionTagsMap != null && descriptionTagsMap.containsKey(d.getId())) m.setDescriptionTags(descriptionTagsMap.get(d.getId()));
|
||||||
if (!definitionPropertiesFields.isEmpty() && d.getProperties() != null){
|
if (!definitionPropertiesFields.isEmpty() && d.getProperties() != null){
|
||||||
|
@ -105,66 +97,6 @@ public class DescriptionBuilder extends BaseBuilder<Description, DescriptionEnti
|
||||||
return models;
|
return models;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<UUID, Dmp> collectDmps(FieldSet fields, List<DescriptionEntity> data) throws MyApplicationException {
|
|
||||||
if (fields.isEmpty() || data.isEmpty())
|
|
||||||
return null;
|
|
||||||
this.logger.debug("checking related - {}", Dmp.class.getSimpleName());
|
|
||||||
|
|
||||||
Map<UUID, Dmp> itemMap;
|
|
||||||
if (!fields.hasOtherField(this.asIndexer(Dmp._id))) {
|
|
||||||
itemMap = this.asEmpty(
|
|
||||||
data.stream().map(DescriptionEntity::getDmpId).distinct().collect(Collectors.toList()),
|
|
||||||
x -> {
|
|
||||||
Dmp item = new Dmp();
|
|
||||||
item.setId(x);
|
|
||||||
return item;
|
|
||||||
},
|
|
||||||
Dmp::getId);
|
|
||||||
} else {
|
|
||||||
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Dmp._id);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
if (!fields.hasField(Dmp._id)) {
|
|
||||||
itemMap.forEach((id, item) -> {
|
|
||||||
if (item != null)
|
|
||||||
item.setId(null);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
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 {
|
private Map<UUID, DmpDescriptionTemplate> collectDmpDescriptionTemplates(FieldSet fields, List<DescriptionEntity> data) throws MyApplicationException {
|
||||||
if (fields.isEmpty() || data.isEmpty())
|
if (fields.isEmpty() || data.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -55,9 +55,6 @@ public class DmpBuilder extends BaseBuilder<Dmp, DmpEntity> {
|
||||||
|
|
||||||
List<Dmp> models = new ArrayList<>();
|
List<Dmp> models = new ArrayList<>();
|
||||||
|
|
||||||
FieldSet dmpDescriptionsFields = fields.extractPrefixed(this.asPrefix(Dmp._dmpDescriptions));
|
|
||||||
Map<UUID, List<Description>> dmpDescriptionsMap = this.collectDmpDescriptions(dmpDescriptionsFields, data);
|
|
||||||
|
|
||||||
FieldSet dmpReferencesFields = fields.extractPrefixed(this.asPrefix(Reference._dmpReferences));
|
FieldSet dmpReferencesFields = fields.extractPrefixed(this.asPrefix(Reference._dmpReferences));
|
||||||
Map<UUID, List<DmpReference>> dmpReferenceMap = this.collectDmpReferences(dmpReferencesFields, data);
|
Map<UUID, List<DmpReference>> dmpReferenceMap = this.collectDmpReferences(dmpReferencesFields, data);
|
||||||
|
|
||||||
|
@ -96,9 +93,6 @@ public class DmpBuilder extends BaseBuilder<Dmp, DmpEntity> {
|
||||||
if (fields.hasField(this.asIndexer(Dmp._hash)))
|
if (fields.hasField(this.asIndexer(Dmp._hash)))
|
||||||
m.setHash(this.hashValue(d.getUpdatedAt()));
|
m.setHash(this.hashValue(d.getUpdatedAt()));
|
||||||
|
|
||||||
if (!dmpDescriptionsFields.isEmpty() && dmpDescriptionsMap != null && dmpDescriptionsMap.containsKey(d.getId()))
|
|
||||||
m.setDmpDescriptions(dmpDescriptionsMap.get(d.getId()));
|
|
||||||
|
|
||||||
if (dmpReferenceMap != null && !dmpReferenceMap.isEmpty() && dmpReferenceMap.containsKey(d.getId()))
|
if (dmpReferenceMap != null && !dmpReferenceMap.isEmpty() && dmpReferenceMap.containsKey(d.getId()))
|
||||||
m.setDmpReferences(dmpReferenceMap.get(d.getId()));
|
m.setDmpReferences(dmpReferenceMap.get(d.getId()));
|
||||||
|
|
||||||
|
@ -109,27 +103,6 @@ public class DmpBuilder extends BaseBuilder<Dmp, DmpEntity> {
|
||||||
return models;
|
return models;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<UUID, List<Description>> collectDmpDescriptions(FieldSet fields, List<DmpEntity> data) throws MyApplicationException {
|
|
||||||
if (fields.isEmpty() || data.isEmpty())
|
|
||||||
return null;
|
|
||||||
this.logger.debug("checking related - {}", Description.class.getSimpleName());
|
|
||||||
|
|
||||||
Map<UUID, List<Description>> itemMap;
|
|
||||||
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(Description._dmp, Dmp._id));
|
|
||||||
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
|
|
||||||
itemMap = this.builderFactory.builder(DescriptionBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId());
|
|
||||||
|
|
||||||
if (!fields.hasField(this.asIndexer(Description._dmp, Dmp._id))) {
|
|
||||||
itemMap.forEach((id, dmps) -> {
|
|
||||||
dmps.forEach(description -> {
|
|
||||||
if (description != null && description.getDmp() != null)
|
|
||||||
description.getDmp().setId(null);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return itemMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<UUID, List<DmpReference>> collectDmpReferences(FieldSet fields, List<DmpEntity> datas) throws MyApplicationException {
|
private Map<UUID, List<DmpReference>> collectDmpReferences(FieldSet fields, List<DmpEntity> datas) throws MyApplicationException {
|
||||||
if (fields.isEmpty() || datas.isEmpty()) return null;
|
if (fields.isEmpty() || datas.isEmpty()) return null;
|
||||||
this.logger.debug("checking related - {}", DmpReference.class.getSimpleName());
|
this.logger.debug("checking related - {}", DmpReference.class.getSimpleName());
|
||||||
|
|
|
@ -3,11 +3,9 @@ package eu.eudat.model.builder;
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.DmpDescriptionTemplateEntity;
|
import eu.eudat.data.DmpDescriptionTemplateEntity;
|
||||||
import eu.eudat.data.DmpReferenceEntity;
|
|
||||||
import eu.eudat.model.*;
|
import eu.eudat.model.*;
|
||||||
import eu.eudat.query.DescriptionTemplateQuery;
|
import eu.eudat.query.DescriptionTemplateQuery;
|
||||||
import eu.eudat.query.DmpQuery;
|
import eu.eudat.query.DmpQuery;
|
||||||
import eu.eudat.query.ReferenceQuery;
|
|
||||||
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;
|
||||||
|
@ -72,11 +70,11 @@ public class DmpDescriptionTemplateBuilder extends BaseBuilder<DmpDescriptionTem
|
||||||
m.setCreatedAt(d.getCreatedAt());
|
m.setCreatedAt(d.getCreatedAt());
|
||||||
if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._updatedAt)))
|
if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._updatedAt)))
|
||||||
m.setUpdatedAt(d.getUpdatedAt());
|
m.setUpdatedAt(d.getUpdatedAt());
|
||||||
if (!templateFields.isEmpty() && templateItemsMap != null && templateItemsMap.containsKey(d.getDescriptionTemplate())) {
|
if (!templateFields.isEmpty() && templateItemsMap != null && templateItemsMap.containsKey(d.getDescriptionTemplateId())) {
|
||||||
m.setDescriptionTemplate(templateItemsMap.get(d.getDescriptionTemplate()));
|
m.setDescriptionTemplate(templateItemsMap.get(d.getDescriptionTemplateId()));
|
||||||
}
|
}
|
||||||
if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmp())) {
|
if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) {
|
||||||
m.setDmp(dmpItemsMap.get(d.getDmp()));
|
m.setDmp(dmpItemsMap.get(d.getDmpId()));
|
||||||
}
|
}
|
||||||
models.add(m);
|
models.add(m);
|
||||||
}
|
}
|
||||||
|
@ -92,7 +90,7 @@ public class DmpDescriptionTemplateBuilder extends BaseBuilder<DmpDescriptionTem
|
||||||
Map<UUID, DescriptionTemplate> itemMap;
|
Map<UUID, DescriptionTemplate> itemMap;
|
||||||
if (!fields.hasOtherField(this.asIndexer(DescriptionTemplate._id))) {
|
if (!fields.hasOtherField(this.asIndexer(DescriptionTemplate._id))) {
|
||||||
itemMap = this.asEmpty(
|
itemMap = this.asEmpty(
|
||||||
data.stream().map(DmpDescriptionTemplateEntity::getDescriptionTemplate).distinct().collect(Collectors.toList()),
|
data.stream().map(DmpDescriptionTemplateEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList()),
|
||||||
x -> {
|
x -> {
|
||||||
DescriptionTemplate item = new DescriptionTemplate();
|
DescriptionTemplate item = new DescriptionTemplate();
|
||||||
item.setId(x);
|
item.setId(x);
|
||||||
|
@ -101,7 +99,7 @@ public class DmpDescriptionTemplateBuilder extends BaseBuilder<DmpDescriptionTem
|
||||||
DescriptionTemplate::getId);
|
DescriptionTemplate::getId);
|
||||||
} else {
|
} else {
|
||||||
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(DescriptionTemplate._id);
|
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(DescriptionTemplate._id);
|
||||||
DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).authorize(this.authorize).ids(data.stream().map(DmpDescriptionTemplateEntity::getDescriptionTemplate).distinct().collect(Collectors.toList()));
|
DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).authorize(this.authorize).ids(data.stream().map(DmpDescriptionTemplateEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList()));
|
||||||
itemMap = this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(this.authorize).asForeignKey(q, clone, DescriptionTemplate::getId);
|
itemMap = this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(this.authorize).asForeignKey(q, clone, DescriptionTemplate::getId);
|
||||||
}
|
}
|
||||||
if (!fields.hasField(DescriptionTemplate._id)) {
|
if (!fields.hasField(DescriptionTemplate._id)) {
|
||||||
|
@ -119,7 +117,7 @@ public class DmpDescriptionTemplateBuilder extends BaseBuilder<DmpDescriptionTem
|
||||||
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(DmpDescriptionTemplateEntity::getDmp).distinct().collect(Collectors.toList()),
|
data.stream().map(DmpDescriptionTemplateEntity::getDmpId).distinct().collect(Collectors.toList()),
|
||||||
x -> {
|
x -> {
|
||||||
Dmp item = new Dmp();
|
Dmp item = new Dmp();
|
||||||
item.setId(x);
|
item.setId(x);
|
||||||
|
@ -128,7 +126,7 @@ public class DmpDescriptionTemplateBuilder extends BaseBuilder<DmpDescriptionTem
|
||||||
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(DmpDescriptionTemplateEntity::getDmp).distinct().collect(Collectors.toList()));
|
DmpQuery q = this.queryFactory.query(DmpQuery.class).authorize(this.authorize).ids(data.stream().map(DmpDescriptionTemplateEntity::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)) {
|
||||||
|
|
|
@ -39,18 +39,12 @@ public class DescriptionCensor extends BaseCensor {
|
||||||
|
|
||||||
this.authService.authorizeForce(Permission.BrowseDescription);
|
this.authService.authorizeForce(Permission.BrowseDescription);
|
||||||
|
|
||||||
FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(Description._dmp));
|
|
||||||
this.censorFactory.censor(DmpCensor.class).censor(dmpFields, userId);
|
|
||||||
|
|
||||||
FieldSet descriptionReferenceFields = fields.extractPrefixed(this.asIndexerPrefix(Description._descriptionReferences));
|
FieldSet descriptionReferenceFields = fields.extractPrefixed(this.asIndexerPrefix(Description._descriptionReferences));
|
||||||
this.censorFactory.censor(DescriptionReferenceCensor.class).censor(descriptionReferenceFields, userId);
|
this.censorFactory.censor(DescriptionReferenceCensor.class).censor(descriptionReferenceFields, userId);
|
||||||
|
|
||||||
FieldSet descriptionTagsFields = fields.extractPrefixed(this.asIndexerPrefix(Description._descriptionTags));
|
FieldSet descriptionTagsFields = fields.extractPrefixed(this.asIndexerPrefix(Description._descriptionTags));
|
||||||
this.censorFactory.censor(DescriptionTagCensor.class).censor(descriptionTagsFields, userId);
|
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));
|
FieldSet dmpDescriptionTemplateFields = fields.extractPrefixed(this.asIndexerPrefix(Description._dmpDescriptionTemplate));
|
||||||
this.censorFactory.censor(DmpDescriptionTemplateCensor.class).censor(dmpDescriptionTemplateFields, userId);
|
this.censorFactory.censor(DmpDescriptionTemplateCensor.class).censor(dmpDescriptionTemplateFields, userId);
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,8 @@ import eu.eudat.data.old.UserInfo;
|
||||||
import eu.eudat.depositinterface.models.*;
|
import eu.eudat.depositinterface.models.*;
|
||||||
import eu.eudat.query.DescriptionQuery;
|
import eu.eudat.query.DescriptionQuery;
|
||||||
import eu.eudat.query.DescriptionTemplateQuery;
|
import eu.eudat.query.DescriptionTemplateQuery;
|
||||||
|
import eu.eudat.query.DmpDescriptionTemplateQuery;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
import jakarta.persistence.criteria.*;
|
import jakarta.persistence.criteria.*;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -33,10 +35,12 @@ public class DmpEntityDepositMapper {
|
||||||
private final ObjectMapper mapper;
|
private final ObjectMapper mapper;
|
||||||
private final ApplicationContext applicationContext;
|
private final ApplicationContext applicationContext;
|
||||||
private final EntityManager entityManager;
|
private final EntityManager entityManager;
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
public DmpEntityDepositMapper(ApplicationContext applicationContext, EntityManager entityManager) {
|
public DmpEntityDepositMapper(ApplicationContext applicationContext, EntityManager entityManager, QueryFactory queryFactory) {
|
||||||
this.applicationContext = applicationContext;
|
this.applicationContext = applicationContext;
|
||||||
this.entityManager = entityManager;
|
this.entityManager = entityManager;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
|
||||||
this.mapper = new ObjectMapper();
|
this.mapper = new ObjectMapper();
|
||||||
}
|
}
|
||||||
|
@ -62,8 +66,8 @@ public class DmpEntityDepositMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<DescriptionEntity> getDescriptions(UUID dmpId) {
|
private List<DescriptionEntity> getDescriptions(UUID dmpId) {
|
||||||
DescriptionQuery descriptionQuery = this.applicationContext.getBean(DescriptionQuery.class);
|
DescriptionQuery descriptionQuery = this.queryFactory.query(DescriptionQuery.class);
|
||||||
return descriptionQuery.dmpIds(dmpId).isActive(IsActive.Active).collect();
|
return descriptionQuery.dmpDescriptionTemplateSubQuery(this.queryFactory.query(DmpDescriptionTemplateQuery.class).dmpIds(dmpId).isActive(IsActive.Active)).isActive(IsActive.Active).collect();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,15 +76,16 @@ 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.getDescriptionTemplateId());
|
DescriptionTemplateEntity descriptionTemplateEntity = getDescriptionTemplate(entity.getDmpDescriptionTemplateId());
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DescriptionTemplateEntity getDescriptionTemplate(UUID descId) {
|
private DescriptionTemplateEntity getDescriptionTemplate(UUID dmpDescriptionTemplateId) {
|
||||||
DescriptionTemplateQuery descriptionTemplateQuery = this.applicationContext.getBean(DescriptionTemplateQuery.class);
|
DmpDescriptionTemplateEntity dmpDescriptionTemplate = this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(dmpDescriptionTemplateId).isActive(IsActive.Active).first();
|
||||||
return descriptionTemplateQuery.ids(descId).isActive(IsActive.Active).first();
|
DescriptionTemplateQuery descriptionTemplateQuery = this.queryFactory.query(DescriptionTemplateQuery.class);
|
||||||
|
return descriptionTemplateQuery.ids(dmpDescriptionTemplate.getDescriptionTemplateId()).isActive(IsActive.Active).first();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<DatasetFieldsDepositModel> fromDefinitionAndProperties(String definition, String properties){
|
private List<DatasetFieldsDepositModel> fromDefinitionAndProperties(String definition, String properties){
|
||||||
|
|
|
@ -4,6 +4,8 @@ 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.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
|
import eu.eudat.data.DmpDescriptionTemplateEntity;
|
||||||
import eu.eudat.model.Description;
|
import eu.eudat.model.Description;
|
||||||
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;
|
||||||
|
@ -11,6 +13,7 @@ import gr.cite.tools.data.query.QueryContext;
|
||||||
import jakarta.persistence.Tuple;
|
import jakarta.persistence.Tuple;
|
||||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||||
import jakarta.persistence.criteria.Predicate;
|
import jakarta.persistence.criteria.Predicate;
|
||||||
|
import jakarta.persistence.criteria.Subquery;
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
@ -25,6 +28,8 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
|
||||||
private String like;
|
private String like;
|
||||||
|
|
||||||
private Collection<UUID> ids;
|
private Collection<UUID> ids;
|
||||||
|
private Collection<UUID> dmpDescriptionTemplateIds;
|
||||||
|
private DmpDescriptionTemplateQuery dmpDescriptionTemplateQuery;
|
||||||
|
|
||||||
private Collection<UUID> excludedIds;
|
private Collection<UUID> excludedIds;
|
||||||
|
|
||||||
|
@ -32,8 +37,6 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
|
||||||
|
|
||||||
private Collection<DescriptionStatus> statuses;
|
private Collection<DescriptionStatus> statuses;
|
||||||
|
|
||||||
private Collection<UUID> dmpIds;
|
|
||||||
|
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,6 +63,13 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public DescriptionQuery dmpDescriptionTemplateSubQuery(DmpDescriptionTemplateQuery subQuery) {
|
||||||
|
this.dmpDescriptionTemplateQuery = subQuery;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public DescriptionQuery excludedIds(Collection<UUID> values) {
|
public DescriptionQuery excludedIds(Collection<UUID> values) {
|
||||||
this.excludedIds = values;
|
this.excludedIds = values;
|
||||||
return this;
|
return this;
|
||||||
|
@ -105,21 +115,6 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DescriptionQuery dmpIds(UUID value) {
|
|
||||||
this.dmpIds = List.of(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DescriptionQuery dmpIds(UUID... value) {
|
|
||||||
this.dmpIds = Arrays.asList(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DescriptionQuery dmpIds(Collection<UUID> values) {
|
|
||||||
this.dmpIds = values;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DescriptionQuery authorize(EnumSet<AuthorizationFlags> values) {
|
public DescriptionQuery authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
this.authorize = values;
|
this.authorize = values;
|
||||||
return this;
|
return this;
|
||||||
|
@ -131,8 +126,7 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
|
||||||
this.isEmpty(this.ids) ||
|
this.isEmpty(this.ids) ||
|
||||||
this.isEmpty(this.isActives) ||
|
this.isEmpty(this.isActives) ||
|
||||||
this.isEmpty(this.excludedIds) ||
|
this.isEmpty(this.excludedIds) ||
|
||||||
this.isEmpty(this.statuses) ||
|
this.isEmpty(this.statuses) || this.isFalseQuery(this.dmpDescriptionTemplateQuery);
|
||||||
this.isEmpty(this.dmpIds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -144,7 +138,10 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
|
||||||
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||||
List<Predicate> predicates = new ArrayList<>();
|
List<Predicate> predicates = new ArrayList<>();
|
||||||
if (this.like != null && !this.like.isEmpty()) {
|
if (this.like != null && !this.like.isEmpty()) {
|
||||||
predicates.add(queryContext.CriteriaBuilder.like(queryContext.Root.get(DescriptionEntity._label), this.like));
|
predicates.add(queryContext.CriteriaBuilder.or(
|
||||||
|
queryContext.CriteriaBuilder.like(queryContext.Root.get(DescriptionEntity._description), this.like),
|
||||||
|
queryContext.CriteriaBuilder.like(queryContext.Root.get(DescriptionEntity._label), this.like)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
if (this.ids != null) {
|
if (this.ids != null) {
|
||||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._id));
|
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._id));
|
||||||
|
@ -170,11 +167,10 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
|
||||||
inClause.value(item);
|
inClause.value(item);
|
||||||
predicates.add(inClause);
|
predicates.add(inClause);
|
||||||
}
|
}
|
||||||
if (this.dmpIds != null) {
|
if (this.dmpDescriptionTemplateQuery != null) {
|
||||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._dmpId));
|
Subquery<DmpDescriptionTemplateEntity> subQuery = queryContext.Query.subquery(this.dmpDescriptionTemplateQuery.entityClass());
|
||||||
for (UUID item : this.dmpIds)
|
this.applySubQuery(this.dmpDescriptionTemplateQuery, queryContext.CriteriaBuilder, subQuery);
|
||||||
inClause.value(item);
|
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._dmpDescriptionTemplateId)).value(subQuery));
|
||||||
predicates.add(inClause);
|
|
||||||
}
|
}
|
||||||
if (!predicates.isEmpty()) {
|
if (!predicates.isEmpty()) {
|
||||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||||
|
@ -188,10 +184,7 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
|
||||||
protected String fieldNameOf(FieldResolver item) {
|
protected String fieldNameOf(FieldResolver item) {
|
||||||
if (item.match(Description._id)) return DescriptionEntity._id;
|
if (item.match(Description._id)) return DescriptionEntity._id;
|
||||||
else if (item.match(Description._label)) return DescriptionEntity._label;
|
else if (item.match(Description._label)) return DescriptionEntity._label;
|
||||||
else if (item.prefix(Description._dmp)) return DescriptionEntity._dmpId;
|
|
||||||
else if (item.match(Description._dmp)) return DescriptionEntity._dmpId;
|
|
||||||
else if (item.prefix(Description._properties)) return DescriptionEntity._properties;
|
else if (item.prefix(Description._properties)) return DescriptionEntity._properties;
|
||||||
else if (item.prefix(Description._descriptionTemplate)) return DescriptionEntity._descriptionTemplateId;
|
|
||||||
else if (item.match(Description._status)) return DescriptionEntity._status;
|
else if (item.match(Description._status)) return DescriptionEntity._status;
|
||||||
else if (item.match(Description._description)) return DescriptionEntity._description;
|
else if (item.match(Description._description)) return DescriptionEntity._description;
|
||||||
else if (item.match(Description._createdBy)) return DescriptionEntity._createdById;
|
else if (item.match(Description._createdBy)) return DescriptionEntity._createdById;
|
||||||
|
@ -208,9 +201,7 @@ 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.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.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.setCreatedAt(QueryBase.convertSafe(tuple, columns, DescriptionEntity._createdAt, Instant.class));
|
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DescriptionEntity._createdAt, Instant.class));
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
package eu.eudat.query;
|
package eu.eudat.query;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.DmpDescriptionTemplateEntity;
|
import eu.eudat.data.DmpDescriptionTemplateEntity;
|
||||||
import eu.eudat.data.DmpReferenceEntity;
|
|
||||||
import eu.eudat.model.DmpDescriptionTemplate;
|
import eu.eudat.model.DmpDescriptionTemplate;
|
||||||
import eu.eudat.model.DmpReference;
|
|
||||||
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;
|
||||||
|
@ -30,6 +28,10 @@ public class DmpDescriptionTemplateQuery extends QueryBase<DmpDescriptionTemplat
|
||||||
|
|
||||||
private Collection<UUID> descriptionTemplateIds;
|
private Collection<UUID> descriptionTemplateIds;
|
||||||
|
|
||||||
|
private Collection<IsActive> isActives;
|
||||||
|
|
||||||
|
private Collection<UUID> excludedIds;
|
||||||
|
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,6 +50,36 @@ public class DmpDescriptionTemplateQuery extends QueryBase<DmpDescriptionTemplat
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DmpDescriptionTemplateQuery excludedIds(Collection<UUID> values) {
|
||||||
|
this.excludedIds = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpDescriptionTemplateQuery excludedIds(UUID value) {
|
||||||
|
this.excludedIds = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpDescriptionTemplateQuery excludedIds(UUID... value) {
|
||||||
|
this.excludedIds = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpDescriptionTemplateQuery isActive(IsActive value) {
|
||||||
|
this.isActives = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpDescriptionTemplateQuery isActive(IsActive... value) {
|
||||||
|
this.isActives = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpDescriptionTemplateQuery isActive(Collection<IsActive> values) {
|
||||||
|
this.isActives = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public DmpDescriptionTemplateQuery dmpIds(UUID value) {
|
public DmpDescriptionTemplateQuery dmpIds(UUID value) {
|
||||||
this.dmpIds = List.of(value);
|
this.dmpIds = List.of(value);
|
||||||
return this;
|
return this;
|
||||||
|
@ -94,7 +126,7 @@ public class DmpDescriptionTemplateQuery extends QueryBase<DmpDescriptionTemplat
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Boolean isFalseQuery() {
|
protected Boolean isFalseQuery() {
|
||||||
return this.isEmpty(this.ids) || this.isEmpty(this.dmpIds) || this.isEmpty(this.descriptionTemplateIds);
|
return this.isEmpty(this.ids) || this.isEmpty(this.excludedIds) || this.isEmpty(this.isActives) || this.isEmpty(this.dmpIds) || this.isEmpty(this.descriptionTemplateIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -106,18 +138,30 @@ public class DmpDescriptionTemplateQuery extends QueryBase<DmpDescriptionTemplat
|
||||||
inClause.value(item);
|
inClause.value(item);
|
||||||
predicates.add(inClause);
|
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.dmpIds != null) {
|
if (this.dmpIds != null) {
|
||||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpDescriptionTemplateEntity._dmp));
|
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpDescriptionTemplateEntity._dmpId));
|
||||||
for (UUID item : this.dmpIds)
|
for (UUID item : this.dmpIds)
|
||||||
inClause.value(item);
|
inClause.value(item);
|
||||||
predicates.add(inClause);
|
predicates.add(inClause);
|
||||||
}
|
}
|
||||||
if (this.descriptionTemplateIds != null) {
|
if (this.descriptionTemplateIds != null) {
|
||||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpDescriptionTemplateEntity._descriptionTemplate));
|
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpDescriptionTemplateEntity._descriptionTemplateId));
|
||||||
for (UUID item : this.descriptionTemplateIds)
|
for (UUID item : this.descriptionTemplateIds)
|
||||||
inClause.value(item);
|
inClause.value(item);
|
||||||
predicates.add(inClause);
|
predicates.add(inClause);
|
||||||
}
|
}
|
||||||
|
if (this.isActives != null) {
|
||||||
|
CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpDescriptionTemplateEntity._isActive));
|
||||||
|
for (IsActive item : this.isActives)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
if (!predicates.isEmpty()) {
|
if (!predicates.isEmpty()) {
|
||||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||||
return queryContext.CriteriaBuilder.and(predicatesArray);
|
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||||
|
@ -130,8 +174,8 @@ public class DmpDescriptionTemplateQuery extends QueryBase<DmpDescriptionTemplat
|
||||||
protected DmpDescriptionTemplateEntity convert(Tuple tuple, Set<String> columns) {
|
protected DmpDescriptionTemplateEntity convert(Tuple tuple, Set<String> columns) {
|
||||||
DmpDescriptionTemplateEntity item = new DmpDescriptionTemplateEntity();
|
DmpDescriptionTemplateEntity item = new DmpDescriptionTemplateEntity();
|
||||||
item.setId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._id, UUID.class));
|
item.setId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._id, UUID.class));
|
||||||
item.setDmp(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._dmp, UUID.class));
|
item.setDmpId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._dmpId, UUID.class));
|
||||||
item.setDescriptionTemplate(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._descriptionTemplate, UUID.class));
|
item.setDescriptionTemplateId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._descriptionTemplateId, UUID.class));
|
||||||
item.setSectionId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._sectionId, UUID.class));
|
item.setSectionId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._sectionId, UUID.class));
|
||||||
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._createdAt, Instant.class));
|
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._createdAt, Instant.class));
|
||||||
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._updatedAt, Instant.class));
|
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._updatedAt, Instant.class));
|
||||||
|
@ -141,8 +185,8 @@ public class DmpDescriptionTemplateQuery extends QueryBase<DmpDescriptionTemplat
|
||||||
@Override
|
@Override
|
||||||
protected String fieldNameOf(FieldResolver item) {
|
protected String fieldNameOf(FieldResolver item) {
|
||||||
if (item.match(DmpDescriptionTemplate._id)) return DmpDescriptionTemplateEntity._id;
|
if (item.match(DmpDescriptionTemplate._id)) return DmpDescriptionTemplateEntity._id;
|
||||||
else if (item.prefix(DmpDescriptionTemplate._dmp)) return DmpDescriptionTemplateEntity._dmp;
|
else if (item.prefix(DmpDescriptionTemplate._dmp)) return DmpDescriptionTemplateEntity._dmpId;
|
||||||
else if (item.prefix(DmpDescriptionTemplate._descriptionTemplate)) return DmpDescriptionTemplateEntity._descriptionTemplate;
|
else if (item.prefix(DmpDescriptionTemplate._descriptionTemplate)) return DmpDescriptionTemplateEntity._descriptionTemplateId;
|
||||||
else if (item.match(DmpDescriptionTemplate._sectionId)) return DmpDescriptionTemplateEntity._sectionId;
|
else if (item.match(DmpDescriptionTemplate._sectionId)) return DmpDescriptionTemplateEntity._sectionId;
|
||||||
else if (item.match(DmpDescriptionTemplate._createdAt)) return DmpDescriptionTemplateEntity._createdAt;
|
else if (item.match(DmpDescriptionTemplate._createdAt)) return DmpDescriptionTemplateEntity._createdAt;
|
||||||
else if (item.match(DmpDescriptionTemplate._updatedAt)) return DmpDescriptionTemplateEntity._updatedAt;
|
else if (item.match(DmpDescriptionTemplate._updatedAt)) return DmpDescriptionTemplateEntity._updatedAt;
|
||||||
|
|
|
@ -3,7 +3,6 @@ package eu.eudat.query.lookup;
|
||||||
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.query.DescriptionQuery;
|
import eu.eudat.query.DescriptionQuery;
|
||||||
import eu.eudat.query.DmpQuery;
|
|
||||||
import gr.cite.tools.data.query.Lookup;
|
import gr.cite.tools.data.query.Lookup;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
|
||||||
|
@ -18,12 +17,12 @@ public class DescriptionLookup extends Lookup {
|
||||||
|
|
||||||
private List<UUID> excludedIds;
|
private List<UUID> excludedIds;
|
||||||
|
|
||||||
|
private DmpDescriptionTemplateLookup dmpDescriptionTemplateSubQuery;
|
||||||
|
|
||||||
private List<IsActive> isActive;
|
private List<IsActive> isActive;
|
||||||
|
|
||||||
private List<DescriptionStatus> statuses;
|
private List<DescriptionStatus> statuses;
|
||||||
|
|
||||||
private List<UUID> dmpIds;
|
|
||||||
|
|
||||||
public String getLike() {
|
public String getLike() {
|
||||||
return like;
|
return like;
|
||||||
}
|
}
|
||||||
|
@ -64,12 +63,12 @@ public class DescriptionLookup extends Lookup {
|
||||||
this.statuses = statuses;
|
this.statuses = statuses;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UUID> getDmpIds() {
|
public DmpDescriptionTemplateLookup getDmpDescriptionTemplateSubQuery() {
|
||||||
return dmpIds;
|
return dmpDescriptionTemplateSubQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDmpIds(List<UUID> dmpIds) {
|
public void setDmpDescriptionTemplateSubQuery(DmpDescriptionTemplateLookup dmpDescriptionTemplateSubQuery) {
|
||||||
this.dmpIds = dmpIds;
|
this.dmpDescriptionTemplateSubQuery = dmpDescriptionTemplateSubQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DescriptionQuery enrich(QueryFactory queryFactory) {
|
public DescriptionQuery enrich(QueryFactory queryFactory) {
|
||||||
|
@ -77,9 +76,9 @@ public class DescriptionLookup extends Lookup {
|
||||||
if (this.like != null) query.like(this.like);
|
if (this.like != null) query.like(this.like);
|
||||||
if (this.ids != null) query.ids(this.ids);
|
if (this.ids != null) query.ids(this.ids);
|
||||||
if (this.excludedIds != null) query.excludedIds(this.excludedIds);
|
if (this.excludedIds != null) query.excludedIds(this.excludedIds);
|
||||||
|
if (this.dmpDescriptionTemplateSubQuery != null) query.dmpDescriptionTemplateSubQuery(this.dmpDescriptionTemplateSubQuery.enrich(queryFactory));
|
||||||
if (this.isActive != null) query.isActive(this.isActive);
|
if (this.isActive != null) query.isActive(this.isActive);
|
||||||
if (this.statuses != null) query.statuses(this.statuses);
|
if (this.statuses != null) query.statuses(this.statuses);
|
||||||
if (this.dmpIds != null) query.dmpIds(this.dmpIds);
|
|
||||||
|
|
||||||
this.enrichCommon(query);
|
this.enrichCommon(query);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
package eu.eudat.query.lookup;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.query.DescriptionQuery;
|
||||||
|
import eu.eudat.query.DmpDescriptionTemplateQuery;
|
||||||
|
import gr.cite.tools.data.query.Lookup;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class DmpDescriptionTemplateLookup extends Lookup {
|
||||||
|
|
||||||
|
private List<UUID> ids;
|
||||||
|
private List<UUID> dmpIds;
|
||||||
|
private List<UUID> descriptionTemplateIds;
|
||||||
|
|
||||||
|
private List<UUID> excludedIds;
|
||||||
|
|
||||||
|
private List<IsActive> isActive;
|
||||||
|
|
||||||
|
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> getDmpIds() {
|
||||||
|
return dmpIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDmpIds(List<UUID> dmpIds) {
|
||||||
|
this.dmpIds = dmpIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UUID> getDescriptionTemplateIds() {
|
||||||
|
return descriptionTemplateIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescriptionTemplateIds(List<UUID> descriptionTemplateIds) {
|
||||||
|
this.descriptionTemplateIds = descriptionTemplateIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpDescriptionTemplateQuery enrich(QueryFactory queryFactory) {
|
||||||
|
DmpDescriptionTemplateQuery query = queryFactory.query(DmpDescriptionTemplateQuery.class);
|
||||||
|
if (this.ids != null) query.ids(this.ids);
|
||||||
|
if (this.dmpIds != null) query.ids(this.dmpIds);
|
||||||
|
if (this.descriptionTemplateIds != null) query.ids(this.descriptionTemplateIds);
|
||||||
|
if (this.excludedIds != null) query.excludedIds(this.excludedIds);
|
||||||
|
if (this.isActive != null) query.isActive(this.isActive);
|
||||||
|
|
||||||
|
this.enrichCommon(query);
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -107,9 +107,7 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
}
|
}
|
||||||
|
|
||||||
data.setLabel(model.getLabel());
|
data.setLabel(model.getLabel());
|
||||||
data.setDmpId(model.getDmp());
|
|
||||||
data.setProperties(model.getProperties());
|
data.setProperties(model.getProperties());
|
||||||
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());
|
||||||
|
|
|
@ -19,7 +19,6 @@ import eu.eudat.model.builder.DmpBuilder;
|
||||||
import eu.eudat.model.deleter.DmpDeleter;
|
import eu.eudat.model.deleter.DmpDeleter;
|
||||||
import eu.eudat.model.deleter.DmpDescriptionTemplateDeleter;
|
import eu.eudat.model.deleter.DmpDescriptionTemplateDeleter;
|
||||||
import eu.eudat.model.deleter.DmpReferenceDeleter;
|
import eu.eudat.model.deleter.DmpReferenceDeleter;
|
||||||
import eu.eudat.model.deleter.ReferenceDeleter;
|
|
||||||
import eu.eudat.model.persist.DmpDescriptionTemplatePersist;
|
import eu.eudat.model.persist.DmpDescriptionTemplatePersist;
|
||||||
import eu.eudat.model.persist.DmpPersist;
|
import eu.eudat.model.persist.DmpPersist;
|
||||||
import eu.eudat.model.persist.DmpReferencePersist;
|
import eu.eudat.model.persist.DmpReferencePersist;
|
||||||
|
@ -274,7 +273,7 @@ public class DmpServiceImpl implements DmpService {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
List<DmpDescriptionTemplateEntity> templates = this.queryFactory.query(DmpDescriptionTemplateQuery.class).dmpIds(dmpId).collect();
|
List<DmpDescriptionTemplateEntity> templates = this.queryFactory.query(DmpDescriptionTemplateQuery.class).dmpIds(dmpId).collect();
|
||||||
Map<UUID, List<DmpDescriptionTemplateEntity>> templatesLookup = this.conventionService.toDictionaryOfList(templates, DmpDescriptionTemplateEntity::getDmp);
|
Map<UUID, List<DmpDescriptionTemplateEntity>> templatesLookup = this.conventionService.toDictionaryOfList(templates, DmpDescriptionTemplateEntity::getDmpId);
|
||||||
|
|
||||||
List<DescriptionTemplateEntity> existingTemplates;
|
List<DescriptionTemplateEntity> existingTemplates;
|
||||||
if (templatesLookup.containsKey(dmpId))
|
if (templatesLookup.containsKey(dmpId))
|
||||||
|
@ -291,8 +290,8 @@ public class DmpServiceImpl implements DmpService {
|
||||||
|
|
||||||
if (shouldAdd) {
|
if (shouldAdd) {
|
||||||
DmpDescriptionTemplateEntity dmpTemplate = new DmpDescriptionTemplateEntity();
|
DmpDescriptionTemplateEntity dmpTemplate = new DmpDescriptionTemplateEntity();
|
||||||
dmpTemplate.setDescriptionTemplate(model.getDescriptionTemplate());
|
dmpTemplate.setDescriptionTemplateId(model.getDescriptionTemplate());
|
||||||
dmpTemplate.setDmp(dmpId);
|
dmpTemplate.setDmpId(dmpId);
|
||||||
dmpTemplate.setSectionId(model.getSectionId());
|
dmpTemplate.setSectionId(model.getSectionId());
|
||||||
dmpTemplate.setCreatedAt(Instant.now());
|
dmpTemplate.setCreatedAt(Instant.now());
|
||||||
dmpTemplate.setUpdatedAt(Instant.now());
|
dmpTemplate.setUpdatedAt(Instant.now());
|
||||||
|
|
|
@ -4,7 +4,6 @@ import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.data.query.items.item.dataset.DatasetWizardAutocompleteRequest;
|
|
||||||
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileWizardAutocompleteRequest;
|
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileWizardAutocompleteRequest;
|
||||||
import eu.eudat.data.query.items.table.dataset.DatasetPublicTableRequest;
|
import eu.eudat.data.query.items.table.dataset.DatasetPublicTableRequest;
|
||||||
import eu.eudat.data.query.items.table.dataset.DatasetTableRequest;
|
import eu.eudat.data.query.items.table.dataset.DatasetTableRequest;
|
||||||
|
@ -23,7 +22,6 @@ import eu.eudat.model.file.FileEnvelope;
|
||||||
import eu.eudat.utilities.pdf.PDFUtils;
|
import eu.eudat.utilities.pdf.PDFUtils;
|
||||||
import eu.eudat.models.data.dataset.DatasetOverviewModel;
|
import eu.eudat.models.data.dataset.DatasetOverviewModel;
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
||||||
import eu.eudat.models.data.datasetwizard.DataManagentPlanListingModel;
|
|
||||||
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||||
import eu.eudat.models.data.dmp.AssociatedProfile;
|
import eu.eudat.models.data.dmp.AssociatedProfile;
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
|
@ -33,6 +31,7 @@ import eu.eudat.models.data.listingmodels.DatasetListingModel;
|
||||||
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
import org.apache.poi.util.IOUtils;
|
import org.apache.poi.util.IOUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -72,10 +71,11 @@ public class Datasets extends BaseController {
|
||||||
private FileManager fileManager;
|
private FileManager fileManager;
|
||||||
private final AuthorizationService authorizationService;
|
private final AuthorizationService authorizationService;
|
||||||
private final UserScope userScope;
|
private final UserScope userScope;
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public Datasets(ApiContext apiContext, Environment environment, DatasetManager datasetManager, ConfigLoader configLoader, UserManager userManager,
|
public Datasets(ApiContext apiContext, Environment environment, DatasetManager datasetManager, ConfigLoader configLoader, UserManager userManager,
|
||||||
FileManager fileManager, AuthorizationService authorizationService, UserScope userScope) {
|
FileManager fileManager, AuthorizationService authorizationService, UserScope userScope, QueryFactory queryFactory) {
|
||||||
super(apiContext);
|
super(apiContext);
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
this.datasetManager = datasetManager;
|
this.datasetManager = datasetManager;
|
||||||
|
@ -84,6 +84,7 @@ public class Datasets extends BaseController {
|
||||||
this.fileManager = fileManager;
|
this.fileManager = fileManager;
|
||||||
this.authorizationService = authorizationService;
|
this.authorizationService = authorizationService;
|
||||||
this.userScope = userScope;
|
this.userScope = userScope;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -190,14 +191,14 @@ public class Datasets extends BaseController {
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/userDmps"}, produces = "application/json")
|
// @RequestMapping(method = RequestMethod.POST, value = {"/userDmps"}, produces = "application/json")
|
||||||
public @ResponseBody
|
// public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<List<DataManagentPlanListingModel>>> getUserDmps(@RequestBody DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest) throws IllegalAccessException, InstantiationException, InvalidApplicationException {
|
// ResponseEntity<ResponseItem<List<DataManagentPlanListingModel>>> getUserDmps(@RequestBody DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest) throws IllegalAccessException, InstantiationException, InvalidApplicationException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
//
|
||||||
List<DataManagentPlanListingModel> dataManagementPlans = DatasetWizardManager.getUserDmps(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), datasetWizardAutocompleteRequest, this.userScope);
|
// List<DataManagentPlanListingModel> dataManagementPlans = DatasetWizardManager.getUserDmps(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), datasetWizardAutocompleteRequest, this.userScope);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DataManagentPlanListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlans));
|
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DataManagentPlanListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlans));
|
||||||
}
|
// }
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/getAvailableProfiles"}, produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/getAvailableProfiles"}, produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
|
@ -229,15 +230,6 @@ public class Datasets extends BaseController {
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<PagedDatasetProfile>().status(ApiMessageCode.NO_MESSAGE).payload(pagedDatasetProfile));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<PagedDatasetProfile>().status(ApiMessageCode.NO_MESSAGE).payload(pagedDatasetProfile));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"profile/{id}"}, produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity getSingleProfileUpdate(@PathVariable String id) throws IllegalAccessException, IOException, InstantiationException, InvalidApplicationException {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AnonymousRole);
|
|
||||||
|
|
||||||
DatasetWizardModel dataset = this.datasetManager.datasetUpdateProfile(id);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetWizardModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Data Export
|
* Data Export
|
||||||
* */
|
* */
|
||||||
|
@ -312,7 +304,7 @@ public class Datasets extends BaseController {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new DatasetWizardManager().unlock(this.getApiContext(), id);
|
new DatasetWizardManager().unlock(this.getApiContext(), this.queryFactory, id);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionEntity>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Unlocked"));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionEntity>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Unlocked"));
|
||||||
} catch (DatasetWizardCannotUnlockException datasetWizardCannotUnlockException) {
|
} catch (DatasetWizardCannotUnlockException datasetWizardCannotUnlockException) {
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DescriptionEntity>().status(ApiMessageCode.ERROR_MESSAGE).message(datasetWizardCannotUnlockException.getMessage()));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DescriptionEntity>().status(ApiMessageCode.ERROR_MESSAGE).message(datasetWizardCannotUnlockException.getMessage()));
|
||||||
|
|
|
@ -4,6 +4,7 @@ import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.commons.XmlHandlingService;
|
import eu.eudat.commons.XmlHandlingService;
|
||||||
import eu.eudat.commons.enums.FieldType;
|
import eu.eudat.commons.enums.FieldType;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
||||||
|
@ -21,6 +22,7 @@ import eu.eudat.models.HintedModelFactory;
|
||||||
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.query.DescriptionTemplateQuery;
|
import eu.eudat.query.DescriptionTemplateQuery;
|
||||||
|
import eu.eudat.query.DmpDescriptionTemplateQuery;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
@ -143,7 +145,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.getDmpId());
|
DMP dmp = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().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()))
|
||||||
|
|
|
@ -47,6 +47,7 @@ import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl;
|
||||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||||
import eu.eudat.model.file.FileEnvelope;
|
import eu.eudat.model.file.FileEnvelope;
|
||||||
|
import eu.eudat.query.DmpDescriptionTemplateQuery;
|
||||||
import eu.eudat.utilities.pdf.PDFUtils;
|
import eu.eudat.utilities.pdf.PDFUtils;
|
||||||
import eu.eudat.logic.utilities.documents.types.ParagraphStyle;
|
import eu.eudat.logic.utilities.documents.types.ParagraphStyle;
|
||||||
import eu.eudat.logic.utilities.documents.word.WordBuilder;
|
import eu.eudat.logic.utilities.documents.word.WordBuilder;
|
||||||
|
@ -494,7 +495,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.getDescriptionTemplateId().equals(associatedProfile.getDescriptionTemplateId())).findAny().orElse(null) == null)
|
if (dataManagementPlan.getProfiles().stream().filter(associatedProfile -> this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().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 +918,7 @@ public class DataManagementPlanManager {
|
||||||
if (elastic != null) {
|
if (elastic != null) {
|
||||||
tags = elastic.getTags();
|
tags = elastic.getTags();
|
||||||
}
|
}
|
||||||
descriptionEntity.setDmpId(dmp.getId());
|
//descriptionEntity.setDmpId(dmp.getId()); //TODO
|
||||||
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,8 +1050,8 @@ public class DataManagementPlanManager {
|
||||||
if (elastic != null) {
|
if (elastic != null) {
|
||||||
tags = elastic.getTags();
|
tags = elastic.getTags();
|
||||||
}
|
}
|
||||||
UUID dmpId = tempDescriptionEntity.getDmpId();
|
|
||||||
//TODO
|
//TODO
|
||||||
|
//UUID dmpId = tempDescriptionEntity.getDmpId();
|
||||||
//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);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -1060,9 +1061,10 @@ public class DataManagementPlanManager {
|
||||||
.thenApplyAsync(entityDataset -> {
|
.thenApplyAsync(entityDataset -> {
|
||||||
DescriptionEntity newDescriptionEntity = new DescriptionEntity();
|
DescriptionEntity newDescriptionEntity = new DescriptionEntity();
|
||||||
newDescriptionEntity.update(entityDataset);
|
newDescriptionEntity.update(entityDataset);
|
||||||
newDescriptionEntity.setDmpId(newDmp.getId());
|
|
||||||
newDescriptionEntity.setStatus(DescriptionStatus.Saved);
|
newDescriptionEntity.setStatus(DescriptionStatus.Saved);
|
||||||
//TODO
|
//TODO
|
||||||
|
//newDescriptionEntity.setDmpId(newDmp.getId());
|
||||||
|
|
||||||
// if (newDescriptionEntity.getDatasetDataRepositories() != null) {
|
// if (newDescriptionEntity.getDatasetDataRepositories() != null) {
|
||||||
// newDescriptionEntity.setDatasetDataRepositories(newDescriptionEntity.getDatasetDataRepositories().stream().map(item -> {
|
// newDescriptionEntity.setDatasetDataRepositories(newDescriptionEntity.getDatasetDataRepositories().stream().map(item -> {
|
||||||
// DataRepository dataRepository = new DataRepository();
|
// DataRepository dataRepository = new DataRepository();
|
||||||
|
@ -1113,7 +1115,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.getDmpId());
|
dmp = this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(dataset1.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
|
||||||
} catch (InvalidApplicationException e) {
|
} catch (InvalidApplicationException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -1122,9 +1124,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.getDescriptionTemplateId());
|
datasetElastic.setTemplate(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(dataset1.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDescriptionTemplateId());
|
||||||
|
datasetElastic.setDmp(dmp.getId());
|
||||||
datasetElastic.setStatus(dataset1.getStatus().getValue());
|
datasetElastic.setStatus(dataset1.getStatus().getValue());
|
||||||
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,8 +1196,8 @@ public class DataManagementPlanManager {
|
||||||
if (elastic != null) {
|
if (elastic != null) {
|
||||||
tags = elastic.getTags();
|
tags = elastic.getTags();
|
||||||
}
|
}
|
||||||
UUID tmdmpId = dataset.getDmpId();
|
|
||||||
//TODO
|
//TODO
|
||||||
|
//UUID tmdmpId = dataset.getDmpId();
|
||||||
//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);
|
||||||
metricsManager.increaseValue(MetricNames.DATASET, 1, MetricNames.PUBLISHED);
|
metricsManager.increaseValue(MetricNames.DATASET, 1, MetricNames.PUBLISHED);
|
||||||
|
@ -1600,7 +1602,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.getDescriptionTemplateId()).first().getLabel());
|
runDatasetTemplate.setText(this.queryFactory.query(DescriptionTemplateQuery.class).ids(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(datasetEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDescriptionTemplateId()).first().getLabel());
|
||||||
runDatasetTemplate.setColor("116a78");
|
runDatasetTemplate.setColor("116a78");
|
||||||
//runDatasetTemplate.setBold(true);
|
//runDatasetTemplate.setBold(true);
|
||||||
//runDatasetTemplate.setFontSize(12);
|
//runDatasetTemplate.setFontSize(12);
|
||||||
|
@ -1646,7 +1648,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.getDescriptionTemplateId()).first().getLabel());
|
runDatasetDescription.setText(this.queryFactory.query(DescriptionTemplateQuery.class).ids(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(datasetEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().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 +1930,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.getDescriptionTemplateId().toString());
|
datsetProfileElement.setTextContent(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().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.getDescriptionTemplateId()).first().getLabel());
|
datsetProfileLabelElement.setTextContent(this.queryFactory.query(DescriptionTemplateQuery.class).ids(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDescriptionTemplateId()).first().getLabel());
|
||||||
|
|
||||||
DatasetWizardModel datasetWizardModel = new DatasetWizardModel();
|
DatasetWizardModel datasetWizardModel = new DatasetWizardModel();
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
|
@ -2234,18 +2236,18 @@ public class DataManagementPlanManager {
|
||||||
descriptionEntity.setLabel(das.getName());
|
descriptionEntity.setLabel(das.getName());
|
||||||
//TODO
|
//TODO
|
||||||
// descriptionEntity.setDmpSectionIndex(das.getDmpSectionIndex());
|
// descriptionEntity.setDmpSectionIndex(das.getDmpSectionIndex());
|
||||||
try {
|
// try {
|
||||||
descriptionEntity.setDescriptionTemplateId(das.getProfile());
|
// descriptionEntity.setDescriptionTemplateId(das.getProfile());
|
||||||
} catch (Exception ignored) {
|
// } catch (Exception ignored) {
|
||||||
descriptionEntity.setDescriptionTemplateId(associatedProfiles.get(0).getDescriptionTemplateId());
|
// descriptionEntity.setDescriptionTemplateId(associatedProfiles.get(0).getDescriptionTemplateId());
|
||||||
}
|
// }
|
||||||
|
// descriptionEntity.setDmpId(dmp.getId());
|
||||||
descriptionEntity.setProperties(objectMapper.writeValueAsString(das.getFieldImportModels()));
|
descriptionEntity.setProperties(objectMapper.writeValueAsString(das.getFieldImportModels()));
|
||||||
descriptionEntity.setStatus(DescriptionStatus.Saved);
|
descriptionEntity.setStatus(DescriptionStatus.Saved);
|
||||||
// descriptionEntity.setRegistries(new HashSet<>());
|
// descriptionEntity.setRegistries(new HashSet<>());
|
||||||
// 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.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 +2296,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.setDmpId(dmp.getId());
|
//dataset.setDmpId(dmp.getId()); //TODO
|
||||||
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,8 +2403,8 @@ public class DataManagementPlanManager {
|
||||||
if (elastic != null) {
|
if (elastic != null) {
|
||||||
tags = elastic.getTags();
|
tags = elastic.getTags();
|
||||||
}
|
}
|
||||||
UUID dmpId = dataset.getDmpId();
|
|
||||||
//TODO
|
//TODO
|
||||||
|
//UUID dmpId = dataset.getDmpId();
|
||||||
//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);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -47,7 +47,6 @@ import eu.eudat.models.data.dataset.DatasetOverviewModel;
|
||||||
import eu.eudat.models.data.datasetImport.DatasetImportField;
|
import eu.eudat.models.data.datasetImport.DatasetImportField;
|
||||||
import eu.eudat.models.data.datasetImport.DatasetImportPagedDatasetProfile;
|
import eu.eudat.models.data.datasetImport.DatasetImportPagedDatasetProfile;
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
|
|
||||||
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||||
import eu.eudat.models.data.dmp.AssociatedProfile;
|
import eu.eudat.models.data.dmp.AssociatedProfile;
|
||||||
import eu.eudat.models.data.dmp.DataManagementPlan;
|
import eu.eudat.models.data.dmp.DataManagementPlan;
|
||||||
|
@ -55,6 +54,7 @@ import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.models.data.listingmodels.DatasetListingModel;
|
import eu.eudat.models.data.listingmodels.DatasetListingModel;
|
||||||
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
||||||
import eu.eudat.query.DescriptionTemplateQuery;
|
import eu.eudat.query.DescriptionTemplateQuery;
|
||||||
|
import eu.eudat.query.DmpDescriptionTemplateQuery;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.types.MetricNames;
|
import eu.eudat.types.MetricNames;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
@ -299,7 +299,8 @@ 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.getDmpId());
|
;
|
||||||
|
DMP dmp = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().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 +310,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.getDescriptionTemplateId()).first().getGroupId();
|
UUID profileId = this.queryFactory.query(DescriptionTemplateQuery.class).ids(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().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 +341,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.getDescriptionTemplateId()).first().getVersion());
|
boolean latestVersion = profile.getVersion().toString().equals(this.queryFactory.query(DescriptionTemplateQuery.class).ids(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDescriptionTemplateId()).first().getVersion());
|
||||||
dataset.setIsProfileLatestVersion(latestVersion);
|
dataset.setIsProfileLatestVersion(latestVersion);
|
||||||
|
|
||||||
eu.eudat.elastic.entities.Dataset datasetElastic;
|
eu.eudat.elastic.entities.Dataset datasetElastic;
|
||||||
|
@ -364,7 +365,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.getDmpId());
|
DMP dmp = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getId()).isActive(IsActive.Active).first().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 +380,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.getDmpId());
|
DMP dmp = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
|
||||||
if (!isPublic && !this.userScope.isSet()) {
|
if (!isPublic && !this.userScope.isSet()) {
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
} else
|
} else
|
||||||
|
@ -400,7 +401,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.getDescriptionTemplateId()).first());
|
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(this.queryFactory.query(DescriptionTemplateQuery.class).ids(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().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 +418,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.getDmpId());
|
DMP dmpEntity = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().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 +556,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.getDmpId());
|
DMP dmp = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().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 +586,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.getDmpId());
|
DMP dmp = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().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 +599,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.getDescriptionTemplateId(), visibilityRuleService, environment);
|
File file = xmlBuilder.build(pagedDatasetProfile, this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().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 +628,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.setDmpId(dmp.getId());
|
// descriptionEntity.setDmpId(dmp.getId()); //TODO
|
||||||
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);
|
||||||
|
@ -648,14 +649,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.getDmpId());
|
DMP dmp1 = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity1.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
|
||||||
|
|
||||||
datasetWizardModel.setDmp(new DataManagementPlan().fromDataModelNoDatasets(dmp1));
|
datasetWizardModel.setDmp(new DataManagementPlan().fromDataModelNoDatasets(dmp1));
|
||||||
}
|
}
|
||||||
descriptionEntity1.setDescriptionTemplateId(datasetWizardModel.getProfile().getId());
|
// descriptionEntity1.setDescriptionTemplateId(datasetWizardModel.getProfile().getId()); //TODO
|
||||||
// datasetWizardModel.setDatasetProfileDefinition(getPagedProfile(datasetWizardModel, dataset1));
|
// datasetWizardModel.setDatasetProfileDefinition(getPagedProfile(datasetWizardModel, dataset1));
|
||||||
UUID dmpId = descriptionEntity1.getDmpId();
|
UUID dmpId = this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity1.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId();
|
||||||
DMP dmp1 = databaseRepository.getDmpDao().find(descriptionEntity1.getDmpId());
|
DMP dmp1 = databaseRepository.getDmpDao().find(dmpId);
|
||||||
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 +738,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.getDescriptionTemplateId());
|
DescriptionTemplateEntity profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().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 +760,7 @@ public class DatasetManager {
|
||||||
VisibilityRuleService visibilityRuleService = new VisibilityRuleServiceImpl();
|
VisibilityRuleService visibilityRuleService = new VisibilityRuleServiceImpl();
|
||||||
visibilityRuleService.setProperties(obj.toMap());
|
visibilityRuleService.setProperties(obj.toMap());
|
||||||
|
|
||||||
descriptionEntity.setDescriptionTemplateId(profile.getId());
|
//descriptionEntity.setDescriptionTemplateId(profile.getId()); //TODO
|
||||||
PagedDatasetProfile pagedDatasetProfile = this.getPagedProfile(new DatasetWizardModel(), descriptionEntity);
|
PagedDatasetProfile pagedDatasetProfile = this.getPagedProfile(new DatasetWizardModel(), descriptionEntity);
|
||||||
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
||||||
|
|
||||||
|
@ -1030,13 +1031,13 @@ 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.setDmpId(dmp.getId());
|
// entity.setDmpId(dmp.getId()); //TODO
|
||||||
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.setDescriptionTemplateId(profile.getId());
|
// entity.setDescriptionTemplateId(profile.getId());//TODO
|
||||||
|
|
||||||
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.setDmpDescriptionTemplateId(userInfo.getId());
|
entity.setDmpDescriptionTemplateId(userInfo.getId());
|
||||||
|
@ -1055,46 +1056,6 @@ public class DatasetManager {
|
||||||
// TODO: When tags functionality return.
|
// TODO: When tags functionality return.
|
||||||
}
|
}
|
||||||
|
|
||||||
public DatasetWizardModel datasetUpdateProfile(String id) throws InvalidApplicationException {
|
|
||||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
|
||||||
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
|
||||||
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, descriptionEntityEntity));
|
|
||||||
dataset.fromDataModel(descriptionEntityEntity);
|
|
||||||
|
|
||||||
// Creates the Criteria to get all version of DescriptionTemplate in question.
|
|
||||||
DatasetProfileCriteria profileCriteria = new DatasetProfileCriteria();
|
|
||||||
|
|
||||||
UUID profileId = this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDescriptionTemplateId()).first().getGroupId();
|
|
||||||
List<UUID> uuidList = new LinkedList<>();
|
|
||||||
uuidList.add(profileId);
|
|
||||||
profileCriteria.setGroupIds(uuidList);
|
|
||||||
|
|
||||||
// Gets the latest version of the datasetProfile.
|
|
||||||
DescriptionTemplateEntity item = databaseRepository.getDatasetProfileDao().getWithCriteria(profileCriteria).getSingle();
|
|
||||||
|
|
||||||
// Sets the latest version of dataet Profile to the Dataset in question.
|
|
||||||
dataset.setDatasetProfileDefinition(getLatestDatasetProfile(descriptionEntityEntity, item));
|
|
||||||
dataset.setProfile(new DatasetProfileOverviewModel().fromDataModel(item));
|
|
||||||
|
|
||||||
// Now at latest version.
|
|
||||||
dataset.setIsProfileLatestVersion(true);
|
|
||||||
|
|
||||||
eu.eudat.elastic.entities.Dataset datasetElastic;
|
|
||||||
try {
|
|
||||||
datasetElastic = datasetRepository.exists() ?
|
|
||||||
datasetRepository.findDocument(id) : new eu.eudat.elastic.entities.Dataset();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
logger.warn(ex.getMessage());
|
|
||||||
datasetElastic = null;
|
|
||||||
}
|
|
||||||
if (datasetElastic != null && datasetElastic.getTags() != null && !datasetElastic.getTags().isEmpty()) {
|
|
||||||
dataset.setTags(datasetElastic.getTags());
|
|
||||||
}
|
|
||||||
/*if (datasetElastic != null && datasetElastic.getLabel() != null && !datasetElastic.getLabel().isEmpty()) {
|
|
||||||
dataset.setLabel(datasetElastic.getLabel());
|
|
||||||
}*/
|
|
||||||
return dataset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PagedDatasetProfile getLatestDatasetProfile(DescriptionEntity descriptionEntityEntity, DescriptionTemplateEntity profile) {
|
public PagedDatasetProfile getLatestDatasetProfile(DescriptionEntity descriptionEntityEntity, DescriptionTemplateEntity profile) {
|
||||||
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(profile);
|
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(profile);
|
||||||
|
@ -1130,8 +1091,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.getDmpId();
|
UUID dmpId = this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(datasetEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId();
|
||||||
DMP dmp = databaseRepository.getDmpDao().find(datasetEntity.getDmpId());
|
DMP dmp = databaseRepository.getDmpDao().find(dmpId);
|
||||||
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 +1113,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.setDescriptionTemplateId(descriptionEntity.getDescriptionTemplateId());
|
// descriptionEntity.setDescriptionTemplateId(descriptionEntity.getDescriptionTemplateId()); //TODO
|
||||||
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());
|
||||||
|
|
|
@ -17,7 +17,9 @@ import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.datasetwizard.DataManagentPlanListingModel;
|
import eu.eudat.models.data.datasetwizard.DataManagentPlanListingModel;
|
||||||
import eu.eudat.models.data.dmp.AssociatedProfile;
|
import eu.eudat.models.data.dmp.AssociatedProfile;
|
||||||
import eu.eudat.models.data.dmp.DataManagementPlan;
|
import eu.eudat.models.data.dmp.DataManagementPlan;
|
||||||
|
import eu.eudat.query.DmpDescriptionTemplateQuery;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
import javax.management.InvalidApplicationException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -52,9 +54,9 @@ public class DatasetWizardManager {
|
||||||
return profiles;
|
return profiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unlock(ApiContext apiContext, UUID uuid) throws DatasetWizardCannotUnlockException, InvalidApplicationException {
|
public void unlock(ApiContext apiContext, QueryFactory queryFactory, 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.getDmpId());
|
DMP dmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDescriptionTemplateId());
|
||||||
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);
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
package eu.eudat.logic.managers;
|
package eu.eudat.logic.managers;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.DescriptionTemplateStatus;
|
import eu.eudat.commons.enums.DescriptionTemplateStatus;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.data.dao.criteria.*;
|
import eu.eudat.data.dao.criteria.*;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
|
import eu.eudat.query.DmpDescriptionTemplateQuery;
|
||||||
import eu.eudat.types.MetricNames;
|
import eu.eudat.types.MetricNames;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
import io.micrometer.prometheus.PrometheusMeterRegistry;
|
import io.micrometer.prometheus.PrometheusMeterRegistry;
|
||||||
import io.prometheus.client.Gauge;
|
import io.prometheus.client.Gauge;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -77,12 +80,14 @@ public class MetricsManager {
|
||||||
private final ApiContext apiContext;
|
private final ApiContext apiContext;
|
||||||
private final UserManager userManager;
|
private final UserManager userManager;
|
||||||
private final Environment environment;
|
private final Environment environment;
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public MetricsManager(ApiContext apiContext, UserManager userManager, Environment environment, PrometheusMeterRegistry registry) {
|
public MetricsManager(ApiContext apiContext, UserManager userManager, Environment environment, PrometheusMeterRegistry registry, QueryFactory queryFactory) {
|
||||||
this.apiContext = apiContext;
|
this.apiContext = apiContext;
|
||||||
this.userManager = userManager;
|
this.userManager = userManager;
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
registry.clear();
|
registry.clear();
|
||||||
this.gauges = Stream.of( new Object[][]{
|
this.gauges = Stream.of( new Object[][]{
|
||||||
{MetricNames.DMP, Gauge.build().name(MetricNames.DMP).help("Number of managed DMPs").labelNames("status").register(registry.getPrometheusRegistry())},
|
{MetricNames.DMP, Gauge.build().name(MetricNames.DMP).help("Number of managed DMPs").labelNames("status").register(registry.getPrometheusRegistry())},
|
||||||
|
@ -409,7 +414,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.getDescriptionTemplateId()).stream().distinct().count();
|
return apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(datasetCriteria).select(root -> this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(root.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDescriptionTemplateId()).stream().distinct().count();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,10 @@ 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.getDescriptionTemplateId() == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
//TODO
|
//TODO
|
||||||
|
// if (descriptionEntity.getDescriptionTemplateId() == null) {
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
Dataset elastic = new Dataset();
|
Dataset elastic = new Dataset();
|
||||||
// elastic.setId(descriptionEntity.getId().toString());
|
// elastic.setId(descriptionEntity.getId().toString());
|
||||||
// if (tags != null && !tags.isEmpty()) {
|
// if (tags != null && !tags.isEmpty()) {
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class DmpMapper {
|
||||||
if (dataset1 != null) {
|
if (dataset1 != null) {
|
||||||
tags = dataset1.getTags();
|
tags = dataset1.getTags();
|
||||||
}
|
}
|
||||||
dataset.setDmpId(dmp.getId());
|
//dataset.setDmpId(dmp.getId()); //TODO
|
||||||
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.setDescriptionTemplateId(profile.getId());
|
//descriptionEntity.setDescriptionTemplateId(profile.getId()); //TODO
|
||||||
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()) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.models.rda.mapper;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.elastic.criteria.DatasetCriteria;
|
import eu.eudat.elastic.criteria.DatasetCriteria;
|
||||||
|
@ -13,6 +14,8 @@ import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
|
||||||
import eu.eudat.logic.utilities.json.JsonSearcher;
|
import eu.eudat.logic.utilities.json.JsonSearcher;
|
||||||
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||||
import eu.eudat.models.rda.*;
|
import eu.eudat.models.rda.*;
|
||||||
|
import eu.eudat.query.DmpDescriptionTemplateQuery;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -35,11 +38,13 @@ public class DatasetRDAMapper {
|
||||||
|
|
||||||
private DatasetManager datasetManager;
|
private DatasetManager datasetManager;
|
||||||
private ApiContext apiContext;
|
private ApiContext apiContext;
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DatasetRDAMapper(DatasetManager datasetManager, ApiContext apiContext) {
|
public DatasetRDAMapper(DatasetManager datasetManager, ApiContext apiContext, QueryFactory queryFactory) {
|
||||||
this.datasetManager = datasetManager;
|
this.datasetManager = datasetManager;
|
||||||
this.apiContext = apiContext;
|
this.apiContext = apiContext;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
@ -51,7 +56,7 @@ public class DatasetRDAMapper {
|
||||||
}
|
}
|
||||||
rda.setTitle(descriptionEntity.getLabel());
|
rda.setTitle(descriptionEntity.getLabel());
|
||||||
rda.setDescription(descriptionEntity.getDescription());
|
rda.setDescription(descriptionEntity.getDescription());
|
||||||
rda.setAdditionalProperty("template", descriptionEntity.getDescriptionTemplateId());
|
rda.setAdditionalProperty("template", this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDescriptionTemplateId()); //TODO
|
||||||
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 +293,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.setDescriptionTemplateId(profile.getId());
|
//entity.setDescriptionTemplateId(profile.getId()); //TODO
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
logger.warn(e.getMessage(), e);
|
logger.warn(e.getMessage(), e);
|
||||||
entity.setDescriptionTemplateId(defaultProfile.getId());
|
// entity.setDescriptionTemplateId(defaultProfile.getId()); //TODO
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
|
|
Loading…
Reference in New Issue