add description template to description
This commit is contained in:
parent
c60e90d638
commit
e698b198e7
|
@ -80,6 +80,12 @@ public class DescriptionEntity implements DataEntity<DescriptionEntity, UUID> {
|
|||
@Column(name = "dmp", columnDefinition = "uuid", nullable = false)
|
||||
private UUID dmpId;
|
||||
|
||||
@Column(name = "description_template", columnDefinition = "uuid", nullable = false)
|
||||
private UUID descriptionTemplateId;
|
||||
|
||||
public static final String _descriptionTemplateId = "descriptionTemplateId";
|
||||
|
||||
|
||||
public static final String _dmpId = "dmpId";
|
||||
|
||||
public UUID getId() {
|
||||
|
@ -178,55 +184,17 @@ public class DescriptionEntity implements DataEntity<DescriptionEntity, UUID> {
|
|||
this.dmpId = dmpId;
|
||||
}
|
||||
|
||||
public UUID getDescriptionTemplateId() {
|
||||
return descriptionTemplateId;
|
||||
}
|
||||
|
||||
public void setDescriptionTemplateId(UUID descriptionTemplateId) {
|
||||
this.descriptionTemplateId = descriptionTemplateId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(DescriptionEntity entity) {
|
||||
// this.setUri(entity.getUri());
|
||||
// this.setDescription(entity.getDescription());
|
||||
// this.setLabel(entity.getLabel());
|
||||
// this.setProperties(entity.getProperties());
|
||||
//
|
||||
// if (entity.getDatasetDataRepositories() == null || entity.getDatasetDataRepositories().size() < 1) {
|
||||
// if (this.getDatasetDataRepositories() != null) this.getDatasetDataRepositories().removeAll(this.getDatasetDataRepositories());
|
||||
// } else {
|
||||
// if (this.getDatasetDataRepositories() != null) {
|
||||
// this.getDatasetDataRepositories().removeAll(this.getDatasetDataRepositories());
|
||||
// } else {
|
||||
// this.setDatasetDataRepositories(new HashSet<>());
|
||||
// }
|
||||
// this.getDatasetDataRepositories().addAll(entity.getDatasetDataRepositories().stream().peek(item -> item.setDataset(this)).collect(Collectors.toList()));
|
||||
// }
|
||||
//
|
||||
// if (entity.getDatasetExternalDatasets() == null || entity.getDatasetExternalDatasets().size() < 1) {
|
||||
// if (this.getDatasetExternalDatasets() != null) this.getDatasetExternalDatasets().removeAll(this.getDatasetExternalDatasets());
|
||||
// } else {
|
||||
// if (this.getDatasetExternalDatasets() != null) {
|
||||
// this.getDatasetExternalDatasets().removeAll(this.getDatasetExternalDatasets());
|
||||
// } else {
|
||||
// this.setDatasetExternalDatasets(new HashSet<>());
|
||||
// }
|
||||
// this.getDatasetExternalDatasets().addAll(entity.getDatasetExternalDatasets().stream().peek(item -> item.setDataset(this)).collect(Collectors.toList()));
|
||||
// }
|
||||
//
|
||||
// if (entity.getServices() == null || entity.getServices().size() < 1) {
|
||||
// if (this.getServices() != null) this.getServices().removeAll(this.getServices());
|
||||
// } else {
|
||||
// if (this.getServices() != null) {
|
||||
// this.getServices().removeAll(this.getServices());
|
||||
// } else {
|
||||
// this.setServices(new HashSet<>());
|
||||
// }
|
||||
// this.getServices().addAll(entity.getServices().stream().peek(item -> item.setDataset(this)).collect(Collectors.toList()));
|
||||
// }
|
||||
//
|
||||
// this.setRegistries(entity.getRegistries());
|
||||
//
|
||||
// this.setDmp(entity.getDmp());
|
||||
// this.setDmpSectionIndex(entity.getDmpSectionIndex());
|
||||
// this.setStatus(entity.getStatus());
|
||||
// this.setProfile(entity.getProfile());
|
||||
// this.setModified(new Date());
|
||||
// if (entity.getStatus().equals(Status.FINALISED.getValue())) this.setFinalizedAt(new Date());
|
||||
// if (entity.getCreator() != null) this.creator = entity.getCreator();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,10 +24,10 @@ public class DmpDescriptionTemplateEntity {
|
|||
|
||||
public static final String _dmpId = "dmpId";
|
||||
|
||||
@Column(name = "description_template", columnDefinition = "uuid", nullable = false)
|
||||
private UUID descriptionTemplateId;
|
||||
@Column(name = "description_template_group", columnDefinition = "uuid", nullable = false)
|
||||
private UUID descriptionTemplateGroupId;
|
||||
|
||||
public static final String _descriptionTemplateId = "descriptionTemplateId";
|
||||
public static final String _descriptionTemplateGroupId = "descriptionTemplateGroupId";
|
||||
|
||||
@Column(name = "section_id")
|
||||
private UUID sectionId;
|
||||
|
@ -66,12 +66,12 @@ public class DmpDescriptionTemplateEntity {
|
|||
this.dmpId = dmpId;
|
||||
}
|
||||
|
||||
public UUID getDescriptionTemplateId() {
|
||||
return descriptionTemplateId;
|
||||
public UUID getDescriptionTemplateGroupId() {
|
||||
return descriptionTemplateGroupId;
|
||||
}
|
||||
|
||||
public void setDescriptionTemplateId(UUID descriptionTemplateId) {
|
||||
this.descriptionTemplateId = descriptionTemplateId;
|
||||
public void setDescriptionTemplateGroupId(UUID descriptionTemplateGroupId) {
|
||||
this.descriptionTemplateGroupId = descriptionTemplateGroupId;
|
||||
}
|
||||
|
||||
public UUID getSectionId() {
|
||||
|
|
|
@ -127,23 +127,15 @@ public class DescriptionElasticBuilder extends BaseElasticBuilder<DescriptionEla
|
|||
return itemMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Map<UUID, NestedDescriptionTemplateElasticEntity> collectDescriptionTemplates(List<DescriptionEntity> data) throws MyApplicationException {
|
||||
if (data.isEmpty())
|
||||
return null;
|
||||
this.logger.debug("checking related - {}", DescriptionTemplate.class.getSimpleName());
|
||||
|
||||
DmpDescriptionTemplateQuery associationQuery = this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(data.stream().map(DescriptionEntity::getDmpDescriptionTemplateId).collect(Collectors.toList())).isActive(IsActive.Active);
|
||||
List<DmpDescriptionTemplateEntity> associationEntities = associationQuery.collect();
|
||||
Map<UUID, NestedDescriptionTemplateElasticEntity> itemMap;
|
||||
DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).ids(data.stream().map(DescriptionEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList()));
|
||||
itemMap = this.builderFactory.builder(NestedDescriptionTemplateElasticBuilder.class).asForeignKey(q, NestedDescriptionTemplateElasticEntity::getId);
|
||||
|
||||
DescriptionTemplateQuery query = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).ids(associationEntities.stream().map(DmpDescriptionTemplateEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList()));
|
||||
Map<UUID, NestedDescriptionTemplateElasticEntity> itemMapById = this.builderFactory.builder(NestedDescriptionTemplateElasticBuilder.class).asForeignKey(query, NestedDescriptionTemplateElasticEntity::getId);
|
||||
|
||||
Map<UUID, NestedDescriptionTemplateElasticEntity> itemMap = new HashMap<>();
|
||||
for (DmpDescriptionTemplateEntity associationEntity : associationEntities){
|
||||
itemMap.put(associationEntity.getId(), itemMapById.getOrDefault(associationEntity.getDescriptionTemplateId(), null));
|
||||
}
|
||||
return itemMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,13 +99,13 @@ public class DmpElasticBuilder extends BaseElasticBuilder<DmpElasticEntity, DmpE
|
|||
DmpDescriptionTemplateQuery associationQuery = this.queryFactory.query(DmpDescriptionTemplateQuery.class).dmpIds(data.stream().map(DmpEntity::getId).collect(Collectors.toList())).isActive(IsActive.Active);
|
||||
List<DmpDescriptionTemplateEntity> associationEntities = associationQuery.collect();
|
||||
|
||||
DescriptionTemplateQuery query = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).ids(associationEntities.stream().map(DmpDescriptionTemplateEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList()));
|
||||
DescriptionTemplateQuery query = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).groupIds(associationEntities.stream().map(DmpDescriptionTemplateEntity::getDescriptionTemplateGroupId).distinct().collect(Collectors.toList()));
|
||||
Map<UUID, NestedDescriptionTemplateElasticEntity> itemMapById = this.builderFactory.builder(NestedDescriptionTemplateElasticBuilder.class).asForeignKey(query, NestedDescriptionTemplateElasticEntity::getId);
|
||||
|
||||
Map<UUID, List<NestedDescriptionTemplateElasticEntity>> itemMap = new HashMap<>();
|
||||
for (DmpDescriptionTemplateEntity associationEntity : associationEntities){
|
||||
if (!itemMap.containsKey(associationEntity.getDmpId())) itemMap.put(associationEntity.getDmpId(), new ArrayList<>());
|
||||
NestedDescriptionTemplateElasticEntity item = itemMapById.getOrDefault(associationEntity.getDescriptionTemplateId(), null);
|
||||
NestedDescriptionTemplateElasticEntity item = itemMapById.getOrDefault(associationEntity.getDescriptionTemplateGroupId(), null);
|
||||
if (item != null) itemMap.get(associationEntity.getDmpId()).add(item);
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,10 @@ public class Description {
|
|||
|
||||
public static final String _dmpDescriptionTemplate = "dmpDescriptionTemplate";
|
||||
|
||||
private DescriptionTemplate descriptionTemplate;
|
||||
|
||||
public static final String _descriptionTemplate = "descriptionTemplate";
|
||||
|
||||
private Dmp dmp;
|
||||
|
||||
public static final String _dmp = "dmp";
|
||||
|
@ -191,4 +195,12 @@ public class Description {
|
|||
public void setDmp(Dmp dmp) {
|
||||
this.dmp = dmp;
|
||||
}
|
||||
|
||||
public DescriptionTemplate getDescriptionTemplate() {
|
||||
return descriptionTemplate;
|
||||
}
|
||||
|
||||
public void setDescriptionTemplate(DescriptionTemplate descriptionTemplate) {
|
||||
this.descriptionTemplate = descriptionTemplate;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,14 +17,23 @@ public class DmpDescriptionTemplate{
|
|||
|
||||
public static final String _dmp = "dmp";
|
||||
|
||||
private DescriptionTemplate descriptionTemplate;
|
||||
private DescriptionTemplate currentDescriptionTemplate;
|
||||
|
||||
public static final String _descriptionTemplate = "descriptionTemplate";
|
||||
public static final String _currentDescriptionTemplate = "currentDescriptionTemplate";
|
||||
|
||||
|
||||
private List<DescriptionTemplate> descriptionTemplates;
|
||||
|
||||
public static final String _descriptionTemplates = "descriptionTemplates";
|
||||
|
||||
private UUID sectionId;
|
||||
|
||||
public static final String _sectionId = "sectionId";
|
||||
|
||||
private UUID descriptionTemplateGroupId;
|
||||
|
||||
public static final String _descriptionTemplateGroupId = "descriptionTemplateGroupId";
|
||||
|
||||
private Instant createdAt;
|
||||
|
||||
public static final String _createdAt = "createdAt";
|
||||
|
@ -56,12 +65,28 @@ public class DmpDescriptionTemplate{
|
|||
this.dmp = dmp;
|
||||
}
|
||||
|
||||
public DescriptionTemplate getDescriptionTemplate() {
|
||||
return descriptionTemplate;
|
||||
public DescriptionTemplate getCurrentDescriptionTemplate() {
|
||||
return currentDescriptionTemplate;
|
||||
}
|
||||
|
||||
public void setDescriptionTemplate(DescriptionTemplate descriptionTemplate) {
|
||||
this.descriptionTemplate = descriptionTemplate;
|
||||
public void setCurrentDescriptionTemplate(DescriptionTemplate currentDescriptionTemplate) {
|
||||
this.currentDescriptionTemplate = currentDescriptionTemplate;
|
||||
}
|
||||
|
||||
public List<DescriptionTemplate> getDescriptionTemplates() {
|
||||
return descriptionTemplates;
|
||||
}
|
||||
|
||||
public void setDescriptionTemplates(List<DescriptionTemplate> descriptionTemplates) {
|
||||
this.descriptionTemplates = descriptionTemplates;
|
||||
}
|
||||
|
||||
public UUID getDescriptionTemplateGroupId() {
|
||||
return descriptionTemplateGroupId;
|
||||
}
|
||||
|
||||
public void setDescriptionTemplateGroupId(UUID descriptionTemplateGroupId) {
|
||||
this.descriptionTemplateGroupId = descriptionTemplateGroupId;
|
||||
}
|
||||
|
||||
public UUID getSectionId() {
|
||||
|
|
|
@ -39,6 +39,11 @@ public class PublicDescription {
|
|||
|
||||
public static final String _dmpDescriptionTemplate = "dmpDescriptionTemplate";
|
||||
|
||||
private PublicDescriptionTemplate descriptionTemplate;
|
||||
|
||||
public static final String _descriptionTemplate = "descriptionTemplate";
|
||||
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -104,4 +109,11 @@ public class PublicDescription {
|
|||
this.dmpDescriptionTemplate = dmpDescriptionTemplate;
|
||||
}
|
||||
|
||||
public PublicDescriptionTemplate getDescriptionTemplate() {
|
||||
return descriptionTemplate;
|
||||
}
|
||||
|
||||
public void setDescriptionTemplate(PublicDescriptionTemplate descriptionTemplate) {
|
||||
this.descriptionTemplate = descriptionTemplate;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,10 +15,6 @@ public class PublicDmpDescriptionTemplate {
|
|||
|
||||
public static final String _dmp = "dmp";
|
||||
|
||||
private PublicDescriptionTemplate descriptionTemplate;
|
||||
|
||||
public static final String _descriptionTemplate = "descriptionTemplate";
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -35,11 +31,4 @@ public class PublicDmpDescriptionTemplate {
|
|||
this.dmp = dmp;
|
||||
}
|
||||
|
||||
public PublicDescriptionTemplate getDescriptionTemplate() {
|
||||
return descriptionTemplate;
|
||||
}
|
||||
|
||||
public void setDescriptionTemplate(PublicDescriptionTemplate descriptionTemplate) {
|
||||
this.descriptionTemplate = descriptionTemplate;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,9 +62,12 @@ public class DescriptionBuilder extends BaseBuilder<Description, DescriptionEnti
|
|||
FieldSet dmpDescriptionTemplateFields = fields.extractPrefixed(this.asPrefix(Description._dmpDescriptionTemplate));
|
||||
Map<UUID, DmpDescriptionTemplate> dmpDescriptionTemplateItemsMap = this.collectDmpDescriptionTemplates(dmpDescriptionTemplateFields, data);
|
||||
|
||||
FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(Description._dmpDescriptionTemplate));
|
||||
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 descriptionReferencesFields = fields.extractPrefixed(this.asPrefix(Description._descriptionReferences));
|
||||
Map<UUID, List<DescriptionReference>> descriptionReferencesMap = this.collectDescriptionReferences(descriptionReferencesFields, data);
|
||||
|
||||
|
@ -89,6 +92,7 @@ public class DescriptionBuilder extends BaseBuilder<Description, DescriptionEnti
|
|||
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.getDescriptionTemplateId())) m.setDescriptionTemplate(descriptionTemplateItemsMap.get(d.getDescriptionTemplateId()));
|
||||
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 (!userFields.isEmpty() && userItemsMap != null && userItemsMap.containsKey(d.getCreatedById())) m.setCreatedBy(userItemsMap.get(d.getCreatedById()));
|
||||
|
@ -164,6 +168,36 @@ public class DescriptionBuilder extends BaseBuilder<Description, DescriptionEnti
|
|||
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, Dmp> collectDmps(FieldSet fields, List<DescriptionEntity> data) throws MyApplicationException {
|
||||
if (fields.isEmpty() || data.isEmpty())
|
||||
return null;
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
package eu.eudat.model.builder;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.enums.DescriptionTemplateVersionStatus;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.DmpDescriptionTemplateEntity;
|
||||
import eu.eudat.data.DmpEntity;
|
||||
import eu.eudat.model.*;
|
||||
import eu.eudat.query.DescriptionTemplateQuery;
|
||||
import eu.eudat.query.DmpQuery;
|
||||
import eu.eudat.query.DmpUserQuery;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
|
@ -53,8 +56,11 @@ public class DmpDescriptionTemplateBuilder extends BaseBuilder<DmpDescriptionTem
|
|||
if (fields == null || data == null || fields.isEmpty())
|
||||
return new ArrayList<>();
|
||||
|
||||
FieldSet templateFields = fields.extractPrefixed(this.asPrefix(DmpDescriptionTemplate._descriptionTemplate));
|
||||
Map<UUID, DescriptionTemplate> templateItemsMap = this.collectTemplates(templateFields, data);
|
||||
FieldSet templateFields = fields.extractPrefixed(this.asPrefix(DmpDescriptionTemplate._descriptionTemplates));
|
||||
Map<UUID, List<DescriptionTemplate>> templateItemsMap = this.collectDescriptionTemplates(templateFields, data);
|
||||
|
||||
FieldSet currentDescriptionTemplateFields = fields.extractPrefixed(this.asPrefix(DmpDescriptionTemplate._currentDescriptionTemplate));
|
||||
Map<UUID, DescriptionTemplate> currentDescriptionTemplateItemsMap = this.collectCurrentDescriptionTemplates(currentDescriptionTemplateFields, data);
|
||||
|
||||
FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(DmpDescriptionTemplate._dmp));
|
||||
Map<UUID, Dmp> dmpItemsMap = this.collectDmps(dmpFields, data);
|
||||
|
@ -67,7 +73,8 @@ public class DmpDescriptionTemplateBuilder extends BaseBuilder<DmpDescriptionTem
|
|||
if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._createdAt))) m.setCreatedAt(d.getCreatedAt());
|
||||
if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
|
||||
if (fields.hasField(this.asIndexer(DmpDescriptionTemplate._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
|
||||
if (!templateFields.isEmpty() && templateItemsMap != null && templateItemsMap.containsKey(d.getDescriptionTemplateId())) m.setDescriptionTemplate(templateItemsMap.get(d.getDescriptionTemplateId()));
|
||||
if (!templateFields.isEmpty() && templateItemsMap != null && templateItemsMap.containsKey(d.getDescriptionTemplateGroupId())) m.setDescriptionTemplates(templateItemsMap.get(d.getDescriptionTemplateGroupId()));
|
||||
if (!currentDescriptionTemplateFields.isEmpty() && currentDescriptionTemplateItemsMap != null && currentDescriptionTemplateItemsMap.containsKey(d.getDescriptionTemplateGroupId())) m.setCurrentDescriptionTemplate(currentDescriptionTemplateItemsMap.get(d.getDescriptionTemplateGroupId()));
|
||||
if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) m.setDmp(dmpItemsMap.get(d.getDmpId()));
|
||||
models.add(m);
|
||||
}
|
||||
|
@ -75,32 +82,6 @@ public class DmpDescriptionTemplateBuilder extends BaseBuilder<DmpDescriptionTem
|
|||
return models;
|
||||
}
|
||||
|
||||
private Map<UUID, DescriptionTemplate> collectTemplates(FieldSet fields, List<DmpDescriptionTemplateEntity> 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(DmpDescriptionTemplateEntity::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(DmpDescriptionTemplateEntity::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.values().stream().filter(Objects::nonNull).peek(x -> x.setId(null)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return itemMap;
|
||||
}
|
||||
|
||||
private Map<UUID, Dmp> collectDmps(FieldSet fields, List<DmpDescriptionTemplateEntity> data) throws MyApplicationException {
|
||||
if (fields.isEmpty() || data.isEmpty())
|
||||
|
@ -129,4 +110,50 @@ public class DmpDescriptionTemplateBuilder extends BaseBuilder<DmpDescriptionTem
|
|||
return itemMap;
|
||||
}
|
||||
|
||||
private Map<UUID, List<DescriptionTemplate>> collectDescriptionTemplates(FieldSet fields, List<DmpDescriptionTemplateEntity> data) throws MyApplicationException {
|
||||
if (fields.isEmpty() || data.isEmpty())
|
||||
return null;
|
||||
this.logger.debug("checking related - {}", DescriptionTemplate.class.getSimpleName());
|
||||
|
||||
Map<UUID, List<DescriptionTemplate>> itemMap;
|
||||
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(DescriptionTemplate._groupId);
|
||||
DescriptionTemplateQuery query = this.queryFactory.query(DescriptionTemplateQuery.class).authorize(this.authorize).groupIds(data.stream().map(DmpDescriptionTemplateEntity::getDescriptionTemplateGroupId).distinct().collect(Collectors.toList()));
|
||||
itemMap = this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(this.authorize).asMasterKey(query, clone, DescriptionTemplate::getGroupId);
|
||||
|
||||
if (!fields.hasField(DescriptionTemplate._groupId)) {
|
||||
itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getGroupId() != null).peek(x -> {
|
||||
x.setGroupId(null);
|
||||
});
|
||||
}
|
||||
|
||||
return itemMap;
|
||||
}
|
||||
|
||||
private Map<UUID, DescriptionTemplate> collectCurrentDescriptionTemplates(FieldSet fields, List<DmpDescriptionTemplateEntity> 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._groupId))) {
|
||||
itemMap = this.asEmpty(
|
||||
data.stream().map(DmpDescriptionTemplateEntity::getDescriptionTemplateGroupId).distinct().collect(Collectors.toList()),
|
||||
x -> {
|
||||
DescriptionTemplate item = new DescriptionTemplate();
|
||||
item.setGroupId(x);
|
||||
return item;
|
||||
},
|
||||
DescriptionTemplate::getGroupId);
|
||||
} else {
|
||||
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(DescriptionTemplate._id);
|
||||
DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).authorize(this.authorize).versionStatuses(DescriptionTemplateVersionStatus.Current).groupIds(data.stream().map(DmpDescriptionTemplateEntity::getDescriptionTemplateGroupId).distinct().collect(Collectors.toList()));
|
||||
itemMap = this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(this.authorize).asForeignKey(q, clone, DescriptionTemplate::getGroupId);
|
||||
}
|
||||
if (!fields.hasField(DescriptionTemplate._groupId)) {
|
||||
itemMap.values().stream().filter(Objects::nonNull).peek(x -> x.setGroupId(null)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return itemMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ package eu.eudat.model.builder;
|
|||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.DescriptionEntity;
|
||||
import eu.eudat.model.PublicDescription;
|
||||
import eu.eudat.model.PublicDmpDescriptionTemplate;
|
||||
import eu.eudat.model.*;
|
||||
import eu.eudat.query.DescriptionTemplateQuery;
|
||||
import eu.eudat.query.DmpDescriptionTemplateQuery;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
|
@ -56,6 +56,9 @@ public class PublicDescriptionBuilder extends BaseBuilder<PublicDescription, Des
|
|||
FieldSet dmpDescriptionTemplateFields = fields.extractPrefixed(this.asPrefix(PublicDescription._dmpDescriptionTemplate));
|
||||
Map<UUID, PublicDmpDescriptionTemplate> dmpDescriptionTemplateItemsMap = this.collectDmpDescriptionTemplates(dmpDescriptionTemplateFields, data);
|
||||
|
||||
FieldSet descriptionTemplateFields = fields.extractPrefixed(this.asPrefix(Description._descriptionTemplate));
|
||||
Map<UUID, PublicDescriptionTemplate> descriptionTemplateItemsMap = this.collectDescriptionTemplates(descriptionTemplateFields, data);
|
||||
|
||||
List<PublicDescription> models = new ArrayList<>();
|
||||
for (DescriptionEntity d : data) {
|
||||
PublicDescription m = new PublicDescription();
|
||||
|
@ -67,6 +70,7 @@ public class PublicDescriptionBuilder extends BaseBuilder<PublicDescription, Des
|
|||
if (fields.hasField(this.asIndexer(PublicDescription._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
|
||||
if (fields.hasField(this.asIndexer(PublicDescription._finalizedAt))) m.setFinalizedAt(d.getFinalizedAt());
|
||||
if (!dmpDescriptionTemplateFields.isEmpty() && dmpDescriptionTemplateItemsMap != null && dmpDescriptionTemplateItemsMap.containsKey(d.getDmpDescriptionTemplateId())) m.setDmpDescriptionTemplate(dmpDescriptionTemplateItemsMap.get(d.getDmpDescriptionTemplateId()));
|
||||
if (!descriptionTemplateFields.isEmpty() && descriptionTemplateItemsMap != null && descriptionTemplateItemsMap.containsKey(d.getDescriptionTemplateId())) m.setDescriptionTemplate(descriptionTemplateItemsMap.get(d.getDescriptionTemplateId()));
|
||||
models.add(m);
|
||||
}
|
||||
|
||||
|
@ -105,4 +109,34 @@ public class PublicDescriptionBuilder extends BaseBuilder<PublicDescription, Des
|
|||
return itemMap;
|
||||
}
|
||||
|
||||
private Map<UUID, PublicDescriptionTemplate> collectDescriptionTemplates(FieldSet fields, List<DescriptionEntity> data) throws MyApplicationException {
|
||||
if (fields.isEmpty() || data.isEmpty())
|
||||
return null;
|
||||
this.logger.debug("checking related - {}", PublicDescriptionTemplate.class.getSimpleName());
|
||||
|
||||
Map<UUID, PublicDescriptionTemplate> itemMap;
|
||||
if (!fields.hasOtherField(this.asIndexer(PublicDescriptionTemplate._id))) {
|
||||
itemMap = this.asEmpty(
|
||||
data.stream().map(DescriptionEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList()),
|
||||
x -> {
|
||||
PublicDescriptionTemplate item = new PublicDescriptionTemplate();
|
||||
item.setId(x);
|
||||
return item;
|
||||
},
|
||||
PublicDescriptionTemplate::getId);
|
||||
} else {
|
||||
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PublicDescriptionTemplate._id);
|
||||
DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList()));
|
||||
itemMap = this.builderFactory.builder(PublicDescriptionTemplateBuilder.class).authorize(this.authorize).asForeignKey(q, clone, PublicDescriptionTemplate::getId);
|
||||
}
|
||||
if (!fields.hasField(PublicDescriptionTemplate._id)) {
|
||||
itemMap.forEach((id, item) -> {
|
||||
if (item != null)
|
||||
item.setId(null);
|
||||
});
|
||||
}
|
||||
|
||||
return itemMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,8 +55,6 @@ public class PublicDmpDescriptionTemplateBuilder extends BaseBuilder<PublicDmpDe
|
|||
if (fields == null || data == null || fields.isEmpty())
|
||||
return new ArrayList<>();
|
||||
|
||||
FieldSet templateFields = fields.extractPrefixed(this.asPrefix(PublicDmpDescriptionTemplate._descriptionTemplate));
|
||||
Map<UUID, PublicDescriptionTemplate> templateItemsMap = this.collectTemplates(templateFields, data);
|
||||
|
||||
FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(PublicDmpDescriptionTemplate._dmp));
|
||||
Map<UUID, PublicDmp> dmpItemsMap = this.collectDmps(dmpFields, data);
|
||||
|
@ -65,7 +63,6 @@ public class PublicDmpDescriptionTemplateBuilder extends BaseBuilder<PublicDmpDe
|
|||
for (DmpDescriptionTemplateEntity d : data) {
|
||||
PublicDmpDescriptionTemplate m = new PublicDmpDescriptionTemplate();
|
||||
if (fields.hasField(this.asIndexer(PublicDmpDescriptionTemplate._id))) m.setId(d.getId());
|
||||
if (!templateFields.isEmpty() && templateItemsMap != null && templateItemsMap.containsKey(d.getDescriptionTemplateId())) m.setDescriptionTemplate(templateItemsMap.get(d.getDescriptionTemplateId()));
|
||||
if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) m.setDmp(dmpItemsMap.get(d.getDmpId()));
|
||||
models.add(m);
|
||||
}
|
||||
|
@ -73,33 +70,6 @@ public class PublicDmpDescriptionTemplateBuilder extends BaseBuilder<PublicDmpDe
|
|||
return models;
|
||||
}
|
||||
|
||||
private Map<UUID, PublicDescriptionTemplate> collectTemplates(FieldSet fields, List<DmpDescriptionTemplateEntity> data) throws MyApplicationException {
|
||||
if (fields.isEmpty() || data.isEmpty())
|
||||
return null;
|
||||
this.logger.debug("checking related - {}", PublicDescriptionTemplate.class.getSimpleName());
|
||||
|
||||
Map<UUID, PublicDescriptionTemplate> itemMap;
|
||||
if (!fields.hasOtherField(this.asIndexer(PublicDescriptionTemplate._id))) {
|
||||
itemMap = this.asEmpty(
|
||||
data.stream().map(DmpDescriptionTemplateEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList()),
|
||||
x -> {
|
||||
PublicDescriptionTemplate item = new PublicDescriptionTemplate();
|
||||
item.setId(x);
|
||||
return item;
|
||||
},
|
||||
PublicDescriptionTemplate::getId);
|
||||
} else {
|
||||
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PublicDescriptionTemplate._id);
|
||||
DescriptionTemplateQuery q = this.queryFactory.query(DescriptionTemplateQuery.class).authorize(this.authorize).ids(data.stream().map(DmpDescriptionTemplateEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList()));
|
||||
itemMap = this.builderFactory.builder(PublicDescriptionTemplateBuilder.class).authorize(this.authorize).asForeignKey(q, clone, PublicDescriptionTemplate::getId);
|
||||
}
|
||||
if (!fields.hasField(PublicDescriptionTemplate._id)) {
|
||||
itemMap.values().stream().filter(Objects::nonNull).peek(x -> x.setId(null)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return itemMap;
|
||||
}
|
||||
|
||||
private Map<UUID, PublicDmp> collectDmps(FieldSet fields, List<DmpDescriptionTemplateEntity> data) throws MyApplicationException {
|
||||
if (fields.isEmpty() || data.isEmpty())
|
||||
return null;
|
||||
|
|
|
@ -48,6 +48,9 @@ public class DescriptionCensor extends BaseCensor {
|
|||
FieldSet dmpDescriptionTemplateFields = fields.extractPrefixed(this.asIndexerPrefix(Description._dmpDescriptionTemplate));
|
||||
this.censorFactory.censor(DmpDescriptionTemplateCensor.class).censor(dmpDescriptionTemplateFields, userId);
|
||||
|
||||
FieldSet descriptionTemplateFields = fields.extractPrefixed(this.asIndexerPrefix(Description._descriptionTemplate));
|
||||
this.censorFactory.censor(DescriptionTemplateCensor.class).censor(descriptionTemplateFields, userId);
|
||||
|
||||
FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(Description._dmp));
|
||||
this.censorFactory.censor(DmpCensor.class).censor(dmpFields, userId);
|
||||
|
||||
|
|
|
@ -42,8 +42,10 @@ public class DmpDescriptionTemplateCensor extends BaseCensor{
|
|||
this.authService.authorizeForce(Permission.BrowseDescription);
|
||||
FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(DmpDescriptionTemplate._dmp));
|
||||
this.censorFactory.censor(DmpCensor.class).censor(dmpFields, userId);
|
||||
FieldSet descriptionTemplateFields = fields.extractPrefixed(this.asIndexerPrefix(DmpDescriptionTemplate._descriptionTemplate));
|
||||
this.censorFactory.censor(DescriptionTemplateCensor.class).censor(descriptionTemplateFields, userId);
|
||||
FieldSet descriptionTemplatesFields = fields.extractPrefixed(this.asIndexerPrefix(DmpDescriptionTemplate._descriptionTemplates));
|
||||
this.censorFactory.censor(DescriptionTemplateCensor.class).censor(descriptionTemplatesFields, userId);
|
||||
FieldSet currentDescriptionTemplateFields = fields.extractPrefixed(this.asIndexerPrefix(DmpDescriptionTemplate._currentDescriptionTemplate));
|
||||
this.censorFactory.censor(DescriptionTemplateCensor.class).censor(currentDescriptionTemplateFields, userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package eu.eudat.model.censorship;
|
|||
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.Description;
|
||||
import eu.eudat.model.PublicDescription;
|
||||
import eu.eudat.model.censorship.descriptionproperties.PropertyDefinitionCensor;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
|
@ -42,6 +43,9 @@ public class PublicDescriptionCensor extends BaseCensor {
|
|||
FieldSet dmpDescriptionTemplateFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDescription._dmpDescriptionTemplate));
|
||||
this.censorFactory.censor(PublicDmpDescriptionTemplateCensor.class).censor(dmpDescriptionTemplateFields);
|
||||
|
||||
FieldSet descriptionTemplateFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDescription._descriptionTemplate));
|
||||
this.censorFactory.censor(PublicDescriptionTemplateCensor.class).censor(descriptionTemplateFields);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,8 +43,6 @@ public class PublicDmpDescriptionTemplateCensor extends BaseCensor{
|
|||
this.authService.authorizeForce(Permission.PublicBrowseDescription);
|
||||
FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDmpDescriptionTemplate._dmp));
|
||||
this.censorFactory.censor(PublicDmpCensor.class).censor(dmpFields);
|
||||
FieldSet descriptionTemplateFields = fields.extractPrefixed(this.asIndexerPrefix(PublicDmpDescriptionTemplate._descriptionTemplate));
|
||||
this.censorFactory.censor(PublicDescriptionTemplateCensor.class).censor(descriptionTemplateFields);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import eu.eudat.authorization.OwnedResource;
|
|||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.UserAdditionalInfo;
|
||||
import eu.eudat.model.UserContactInfo;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.censor.CensorFactory;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
|
@ -26,10 +25,13 @@ public class UserAdditionalInfoCensor extends BaseCensor {
|
|||
|
||||
protected final AuthorizationService authService;
|
||||
|
||||
protected final CensorFactory censorFactory;
|
||||
|
||||
public UserAdditionalInfoCensor(ConventionService conventionService, AuthorizationService authService) {
|
||||
|
||||
public UserAdditionalInfoCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) {
|
||||
super(conventionService);
|
||||
this.authService = authService;
|
||||
this.censorFactory = censorFactory;
|
||||
}
|
||||
|
||||
public void censor(FieldSet fields, UUID userId) {
|
||||
|
@ -37,6 +39,9 @@ public class UserAdditionalInfoCensor extends BaseCensor {
|
|||
if (fields == null || fields.isEmpty())
|
||||
return;
|
||||
this.authService.authorizeAtLeastOneForce(userId != null ? List.of(new OwnedResource(userId)) : null, Permission.BrowseUser);
|
||||
|
||||
FieldSet descriptionReferenceFields = fields.extractPrefixed(this.asIndexerPrefix(UserAdditionalInfo._organization));
|
||||
this.censorFactory.censor(ReferenceCensor.class).censor(descriptionReferenceFields, userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ public class DescriptionTemplateDeleter implements Deleter {
|
|||
return;
|
||||
|
||||
List<UUID> ids = data.stream().map(DescriptionTemplateEntity::getId).distinct().collect(Collectors.toList());
|
||||
List<UUID> groupIds = data.stream().map(DescriptionTemplateEntity::getGroupId).distinct().collect(Collectors.toList());
|
||||
{
|
||||
logger.debug("checking related - {}", UserDescriptionTemplateEntity.class.getSimpleName());
|
||||
List<UserDescriptionTemplateEntity> items = this.queryFactory.query(UserDescriptionTemplateQuery.class).descriptionTemplateIds(ids).collect();
|
||||
|
@ -79,7 +80,7 @@ public class DescriptionTemplateDeleter implements Deleter {
|
|||
}
|
||||
{
|
||||
logger.debug("checking related - {}", DmpDescriptionTemplateEntity.class.getSimpleName());
|
||||
List<DmpDescriptionTemplateEntity> items = this.queryFactory.query(DmpDescriptionTemplateQuery.class).descriptionTemplateIds(ids).collect();
|
||||
List<DmpDescriptionTemplateEntity> items = this.queryFactory.query(DmpDescriptionTemplateQuery.class).descriptionTemplateGroupIds(groupIds).collect();
|
||||
DmpDescriptionTemplateDeleter deleter = this.deleterFactory.deleter(DmpDescriptionTemplateDeleter.class);
|
||||
deleter.delete(items);
|
||||
}
|
||||
|
|
|
@ -74,16 +74,15 @@ public class DmpEntityDepositMapper {
|
|||
model.setLabel(entity.getLabel());
|
||||
model.setDescription(entity.getDescription());
|
||||
model.setProperties(entity.getProperties());
|
||||
DescriptionTemplateEntity descriptionTemplateEntity = getDescriptionTemplate(entity.getDmpDescriptionTemplateId());
|
||||
DescriptionTemplateEntity descriptionTemplateEntity = getDescriptionTemplate(entity.getDescriptionTemplateId());
|
||||
model.setProfileDefinition(descriptionTemplateEntity.getDefinition());
|
||||
model.setFields(fromDefinitionAndProperties(descriptionTemplateEntity.getDefinition(), entity.getProperties()));
|
||||
return model;
|
||||
}
|
||||
|
||||
private DescriptionTemplateEntity getDescriptionTemplate(UUID dmpDescriptionTemplateId) {
|
||||
DmpDescriptionTemplateEntity dmpDescriptionTemplate = this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(dmpDescriptionTemplateId).isActive(IsActive.Active).first();
|
||||
private DescriptionTemplateEntity getDescriptionTemplate(UUID descriptionTemplateId) {
|
||||
DescriptionTemplateQuery descriptionTemplateQuery = this.queryFactory.query(DescriptionTemplateQuery.class);
|
||||
return descriptionTemplateQuery.ids(dmpDescriptionTemplate.getDescriptionTemplateId()).isActive(IsActive.Active).first();
|
||||
return descriptionTemplateQuery.ids(descriptionTemplateId).isActive(IsActive.Active).first();
|
||||
}
|
||||
|
||||
private List<DatasetFieldsDepositModel> fromDefinitionAndProperties(String definition, String properties){
|
||||
|
|
|
@ -33,6 +33,10 @@ public class DescriptionPersist {
|
|||
@ValidId(message = "{validation.invalidid}")
|
||||
private UUID dmpDescriptionTemplateId;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@ValidId(message = "{validation.invalidid}")
|
||||
private UUID descriptionTemplateId;
|
||||
|
||||
@ValidEnum(message = "{validation.empty}")
|
||||
private DescriptionStatus status;
|
||||
|
||||
|
@ -131,4 +135,12 @@ public class DescriptionPersist {
|
|||
public void setHash(String hash) {
|
||||
this.hash = hash;
|
||||
}
|
||||
|
||||
public UUID getDescriptionTemplateId() {
|
||||
return descriptionTemplateId;
|
||||
}
|
||||
|
||||
public void setDescriptionTemplateId(UUID descriptionTemplateId) {
|
||||
this.descriptionTemplateId = descriptionTemplateId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,33 +9,20 @@ import java.util.UUID;
|
|||
@FieldNotNullIfOtherSet(message = "{validation.hashempty}")
|
||||
public class DmpDescriptionTemplatePersist {
|
||||
|
||||
@ValidId(message = "{validation.invalidid}")
|
||||
private UUID id;
|
||||
|
||||
@ValidId(message = "{validation.invalidid}")
|
||||
@NotNull(message = "{validation.empty}")
|
||||
private UUID descriptionTemplate;
|
||||
private UUID descriptionTemplateGroupId;
|
||||
|
||||
@ValidId(message = "{validation.invalidid}")
|
||||
@NotNull(message = "{validation.empty}")
|
||||
private UUID sectionId;
|
||||
|
||||
private String hash;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
public UUID getDescriptionTemplateGroupId() {
|
||||
return descriptionTemplateGroupId;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public UUID getDescriptionTemplate() {
|
||||
return descriptionTemplate;
|
||||
}
|
||||
|
||||
public void setDescriptionTemplate(UUID descriptionTemplate) {
|
||||
this.descriptionTemplate = descriptionTemplate;
|
||||
public void setDescriptionTemplateGroupId(UUID descriptionTemplateGroupId) {
|
||||
this.descriptionTemplateGroupId = descriptionTemplateGroupId;
|
||||
}
|
||||
|
||||
public UUID getSectionId() {
|
||||
|
@ -46,12 +33,4 @@ public class DmpDescriptionTemplatePersist {
|
|||
this.sectionId = sectionId;
|
||||
}
|
||||
|
||||
public String getHash() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
public void setHash(String hash) {
|
||||
this.hash = hash;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -270,6 +270,9 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
|
|||
else if (item.match(Description._hash)) return DescriptionEntity._updatedAt;
|
||||
else if (item.match(Description._finalizedAt) || item.match(PublicDescription._finalizedAt)) return DescriptionEntity._finalizedAt;
|
||||
else if (item.prefix(Description._dmpDescriptionTemplate) || item.prefix(PublicDescription._dmpDescriptionTemplate)) return DescriptionEntity._dmpDescriptionTemplateId;
|
||||
else if (item.match(Description._dmpDescriptionTemplate) || item.match(PublicDescription._dmpDescriptionTemplate)) return DescriptionEntity._dmpDescriptionTemplateId;
|
||||
else if (item.prefix(Description._descriptionTemplate) || item.prefix(PublicDescription._descriptionTemplate)) return DescriptionEntity._descriptionTemplateId;
|
||||
else if (item.match(Description._descriptionTemplate) || item.match(PublicDescription._descriptionTemplate)) return DescriptionEntity._descriptionTemplateId;
|
||||
else if (item.prefix(Description._dmp)) return DescriptionEntity._dmpId;
|
||||
else return null;
|
||||
}
|
||||
|
@ -287,6 +290,7 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
|
|||
item.setIsActive(QueryBase.convertSafe(tuple, columns, DescriptionEntity._isActive, IsActive.class));
|
||||
item.setFinalizedAt(QueryBase.convertSafe(tuple, columns, DescriptionEntity._finalizedAt, Instant.class));
|
||||
item.setDmpDescriptionTemplateId(QueryBase.convertSafe(tuple, columns, DescriptionEntity._dmpDescriptionTemplateId, UUID.class));
|
||||
item.setDescriptionTemplateId(QueryBase.convertSafe(tuple, columns, DescriptionEntity._descriptionTemplateId, UUID.class));
|
||||
item.setDmpId(QueryBase.convertSafe(tuple, columns, DescriptionEntity._dmpId, UUID.class));
|
||||
return item;
|
||||
}
|
||||
|
|
|
@ -197,12 +197,12 @@ public class DescriptionTemplateQuery extends QueryBase<DescriptionTemplateEntit
|
|||
if (userId != null || usePublic ) {
|
||||
Subquery<UUID> dmpDescriptionTemplateSubquery = queryUtilsService.buildSubQuery(new BuildSubQueryInput<>(
|
||||
new BuildSubQueryInput.Builder<>(DmpDescriptionTemplateEntity.class, UUID.class, queryContext)
|
||||
.keyPathFunc((subQueryRoot) -> subQueryRoot.get(DmpDescriptionTemplateEntity._descriptionTemplateId))
|
||||
.keyPathFunc((subQueryRoot) -> subQueryRoot.get(DmpDescriptionTemplateEntity._descriptionTemplateGroupId))
|
||||
.filterFunc((subQueryRoot, cb) ->
|
||||
cb.in(subQueryRoot.get(DmpDescriptionTemplateEntity._dmpId)).value(queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic))
|
||||
)
|
||||
));
|
||||
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateEntity._id)).value(dmpDescriptionTemplateSubquery));
|
||||
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateEntity._groupId)).value(dmpDescriptionTemplateSubquery));
|
||||
}
|
||||
if (!predicates.isEmpty()) {
|
||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||
|
|
|
@ -36,7 +36,7 @@ public class DmpDescriptionTemplateQuery extends QueryBase<DmpDescriptionTemplat
|
|||
|
||||
private Collection<UUID> dmpIds;
|
||||
|
||||
private Collection<UUID> descriptionTemplateIds;
|
||||
private Collection<UUID> descriptionTemplateGroupIds;
|
||||
|
||||
private Collection<IsActive> isActives;
|
||||
|
||||
|
@ -105,18 +105,18 @@ public class DmpDescriptionTemplateQuery extends QueryBase<DmpDescriptionTemplat
|
|||
return this;
|
||||
}
|
||||
|
||||
public DmpDescriptionTemplateQuery descriptionTemplateIds(UUID value) {
|
||||
this.descriptionTemplateIds = List.of(value);
|
||||
public DmpDescriptionTemplateQuery descriptionTemplateGroupIds(UUID value) {
|
||||
this.descriptionTemplateGroupIds = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DmpDescriptionTemplateQuery descriptionTemplateIds(UUID... value) {
|
||||
this.descriptionTemplateIds = Arrays.asList(value);
|
||||
public DmpDescriptionTemplateQuery descriptionTemplateGroupIds(UUID... value) {
|
||||
this.descriptionTemplateGroupIds = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DmpDescriptionTemplateQuery descriptionTemplateIds(Collection<UUID> values) {
|
||||
this.descriptionTemplateIds = values;
|
||||
public DmpDescriptionTemplateQuery descriptionTemplateGroupIds(Collection<UUID> values) {
|
||||
this.descriptionTemplateGroupIds = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ public class DmpDescriptionTemplateQuery extends QueryBase<DmpDescriptionTemplat
|
|||
|
||||
@Override
|
||||
protected Boolean isFalseQuery() {
|
||||
return this.isEmpty(this.ids) || this.isEmpty(this.excludedIds) || this.isEmpty(this.isActives) || 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.descriptionTemplateGroupIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -187,9 +187,9 @@ public class DmpDescriptionTemplateQuery extends QueryBase<DmpDescriptionTemplat
|
|||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
if (this.descriptionTemplateIds != null) {
|
||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpDescriptionTemplateEntity._descriptionTemplateId));
|
||||
for (UUID item : this.descriptionTemplateIds)
|
||||
if (this.descriptionTemplateGroupIds != null) {
|
||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpDescriptionTemplateEntity._descriptionTemplateGroupId));
|
||||
for (UUID item : this.descriptionTemplateGroupIds)
|
||||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ public class DmpDescriptionTemplateQuery extends QueryBase<DmpDescriptionTemplat
|
|||
DmpDescriptionTemplateEntity item = new DmpDescriptionTemplateEntity();
|
||||
item.setId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._id, UUID.class));
|
||||
item.setDmpId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._dmpId, UUID.class));
|
||||
item.setDescriptionTemplateId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._descriptionTemplateId, UUID.class));
|
||||
item.setDescriptionTemplateGroupId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._descriptionTemplateGroupId, UUID.class));
|
||||
item.setSectionId(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._sectionId, UUID.class));
|
||||
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._createdAt, Instant.class));
|
||||
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DmpDescriptionTemplateEntity._updatedAt, Instant.class));
|
||||
|
@ -223,8 +223,13 @@ public class DmpDescriptionTemplateQuery extends QueryBase<DmpDescriptionTemplat
|
|||
protected String fieldNameOf(FieldResolver item) {
|
||||
if (item.match(DmpDescriptionTemplate._id) || item.match(PublicDmpDescriptionTemplate._id)) return DmpDescriptionTemplateEntity._id;
|
||||
else if (item.prefix(DmpDescriptionTemplate._dmp) || item.prefix(PublicDmpDescriptionTemplate._dmp)) return DmpDescriptionTemplateEntity._dmpId;
|
||||
else if (item.prefix(DmpDescriptionTemplate._descriptionTemplate) || item.prefix(PublicDmpDescriptionTemplate._descriptionTemplate)) return DmpDescriptionTemplateEntity._descriptionTemplateId;
|
||||
else if (item.match(DmpDescriptionTemplate._dmp) || item.prefix(PublicDmpDescriptionTemplate._dmp)) return DmpDescriptionTemplateEntity._dmpId;
|
||||
else if (item.prefix(DmpDescriptionTemplate._currentDescriptionTemplate)) return DmpDescriptionTemplateEntity._descriptionTemplateGroupId;
|
||||
else if (item.match(DmpDescriptionTemplate._currentDescriptionTemplate)) return DmpDescriptionTemplateEntity._descriptionTemplateGroupId;
|
||||
else if (item.prefix(DmpDescriptionTemplate._descriptionTemplates)) return DmpDescriptionTemplateEntity._descriptionTemplateGroupId;
|
||||
else if (item.match(DmpDescriptionTemplate._descriptionTemplates)) return DmpDescriptionTemplateEntity._descriptionTemplateGroupId;
|
||||
else if (item.match(DmpDescriptionTemplate._sectionId)) return DmpDescriptionTemplateEntity._sectionId;
|
||||
else if (item.match(DmpDescriptionTemplate._descriptionTemplateGroupId)) return DmpDescriptionTemplateEntity._descriptionTemplateGroupId;
|
||||
else if (item.match(DmpDescriptionTemplate._hash)) return DmpDescriptionTemplateEntity._updatedAt;
|
||||
else if (item.match(DmpDescriptionTemplate._createdAt)) return DmpDescriptionTemplateEntity._createdAt;
|
||||
else if (item.match(DmpDescriptionTemplate._updatedAt)) return DmpDescriptionTemplateEntity._updatedAt;
|
||||
|
|
|
@ -140,6 +140,8 @@ public class DescriptionServiceImpl implements DescriptionService {
|
|||
data.setProperties(this.jsonHandlingService.toJson(this.buildPropertyDefinitionEntity(model.getProperties())));
|
||||
data.setStatus(model.getStatus());
|
||||
data.setDescription(model.getDescription());
|
||||
data.setDescriptionTemplateId(model.getDescriptionTemplateId());
|
||||
data.setDmpDescriptionTemplateId(model.getDmpDescriptionTemplateId());
|
||||
data.setUpdatedAt(Instant.now());
|
||||
if (isUpdate) this.entityManager.merge(data);
|
||||
else this.entityManager.persist(data);
|
||||
|
@ -336,6 +338,7 @@ public class DescriptionServiceImpl implements DescriptionService {
|
|||
newDescription.setProperties(existing.getProperties());
|
||||
newDescription.setDmpId(dmpId);
|
||||
newDescription.setDmpDescriptionTemplateId(existing.getDmpDescriptionTemplateId());
|
||||
newDescription.setDescriptionTemplateId(existing.getDescriptionTemplateId());
|
||||
newDescription.setCreatedById(userScope.getUserId());
|
||||
newDescription.setCreatedAt(Instant.now());
|
||||
newDescription.setUpdatedAt(Instant.now());
|
||||
|
|
|
@ -20,10 +20,7 @@ import eu.eudat.event.EventBroker;
|
|||
import eu.eudat.model.Dmp;
|
||||
import eu.eudat.model.Reference;
|
||||
import eu.eudat.model.builder.DmpBuilder;
|
||||
import eu.eudat.model.deleter.DmpDeleter;
|
||||
import eu.eudat.model.deleter.DmpDescriptionTemplateDeleter;
|
||||
import eu.eudat.model.deleter.DmpReferenceDeleter;
|
||||
import eu.eudat.model.deleter.DmpUserDeleter;
|
||||
import eu.eudat.model.deleter.*;
|
||||
import eu.eudat.model.persist.*;
|
||||
import eu.eudat.model.persist.dmpproperties.DmpBlueprintValuePersist;
|
||||
import eu.eudat.model.persist.dmpproperties.DmpContactPersist;
|
||||
|
@ -130,7 +127,7 @@ public class DmpServiceImpl implements DmpService {
|
|||
|
||||
this.patchAndSaveReferences(model.getReferences(), data.getId());
|
||||
|
||||
this.patchAndSaveTemplates(model.getDescriptionTemplates(), data.getId());
|
||||
this.patchAndSaveTemplates(data.getId(), model.getDescriptionTemplates());
|
||||
|
||||
this.eventBroker.emit(new DmpTouchedEvent(data.getId()));
|
||||
|
||||
|
@ -218,7 +215,7 @@ public class DmpServiceImpl implements DmpService {
|
|||
DmpDescriptionTemplateEntity newTemplate = new DmpDescriptionTemplateEntity();
|
||||
newTemplate.setId(UUID.randomUUID());
|
||||
newTemplate.setDmpId(newDmp.getId());
|
||||
newTemplate.setDescriptionTemplateId(dmpDescriptionTemplate.getDescriptionTemplateId());
|
||||
newTemplate.setDescriptionTemplateGroupId(dmpDescriptionTemplate.getDescriptionTemplateGroupId());
|
||||
newTemplate.setSectionId(dmpDescriptionTemplate.getSectionId());
|
||||
newTemplate.setCreatedAt(Instant.now());
|
||||
newTemplate.setUpdatedAt(Instant.now());
|
||||
|
@ -306,7 +303,7 @@ public class DmpServiceImpl implements DmpService {
|
|||
DmpDescriptionTemplateEntity newTemplate = new DmpDescriptionTemplateEntity();
|
||||
newTemplate.setId(UUID.randomUUID());
|
||||
newTemplate.setDmpId(newDmp.getId());
|
||||
newTemplate.setDescriptionTemplateId(dmpDescriptionTemplate.getDescriptionTemplateId());
|
||||
newTemplate.setDescriptionTemplateGroupId(dmpDescriptionTemplate.getDescriptionTemplateGroupId());
|
||||
newTemplate.setSectionId(dmpDescriptionTemplate.getSectionId());
|
||||
newTemplate.setCreatedAt(Instant.now());
|
||||
newTemplate.setUpdatedAt(Instant.now());
|
||||
|
@ -537,39 +534,28 @@ public class DmpServiceImpl implements DmpService {
|
|||
|
||||
}
|
||||
|
||||
private void patchAndSaveTemplates(List<DmpDescriptionTemplatePersist> models, UUID dmpId) throws InvalidApplicationException {
|
||||
if (models == null || models.isEmpty())
|
||||
return;
|
||||
|
||||
List<DmpDescriptionTemplateEntity> templates = this.queryFactory.query(DmpDescriptionTemplateQuery.class).dmpIds(dmpId).collect();
|
||||
Map<UUID, List<DmpDescriptionTemplateEntity>> templatesLookup = this.conventionService.toDictionaryOfList(templates, DmpDescriptionTemplateEntity::getDmpId);
|
||||
|
||||
List<DescriptionTemplateEntity> existingTemplates;
|
||||
if (templatesLookup.containsKey(dmpId))
|
||||
existingTemplates = this.queryFactory.query(DescriptionTemplateQuery.class).ids(templatesLookup.get(dmpId).stream().map(DmpDescriptionTemplateEntity::getId).toList()).collect();
|
||||
else existingTemplates = new ArrayList<>();
|
||||
|
||||
List<UUID> updatedTemplatesIds = models.stream().map(DmpDescriptionTemplatePersist::getDescriptionTemplate).filter(this.conventionService::isValidGuid).distinct().toList();
|
||||
List<DescriptionTemplateEntity> toDelete = existingTemplates.stream().filter(x -> !updatedTemplatesIds.contains(x.getId())).toList();
|
||||
List<DmpDescriptionTemplateEntity> dmpDescriptionTemplateRecordsToDelete = this.queryFactory.query(DmpDescriptionTemplateQuery.class).descriptionTemplateIds(toDelete.stream().map(DescriptionTemplateEntity::getId).toList()).collect();
|
||||
this.deleterFactory.deleter(DmpDescriptionTemplateDeleter.class).delete(dmpDescriptionTemplateRecordsToDelete);
|
||||
|
||||
private void patchAndSaveTemplates(UUID id, List<DmpDescriptionTemplatePersist> models) throws InvalidApplicationException {
|
||||
if (models == null) models = new ArrayList<>();
|
||||
List<DmpDescriptionTemplateEntity> items = this.queryFactory.query(DmpDescriptionTemplateQuery.class).isActive(IsActive.Active).dmpIds(id).collect();
|
||||
List<UUID> updatedCreatedIds = new ArrayList<>();
|
||||
for (DmpDescriptionTemplatePersist model : models) {
|
||||
boolean shouldAdd = existingTemplates.stream().noneMatch(x -> x.getId().equals(model.getDescriptionTemplate()));
|
||||
|
||||
if (shouldAdd) {
|
||||
DmpDescriptionTemplateEntity dmpTemplate = new DmpDescriptionTemplateEntity();
|
||||
dmpTemplate.setDescriptionTemplateId(model.getDescriptionTemplate());
|
||||
dmpTemplate.setDmpId(dmpId);
|
||||
dmpTemplate.setSectionId(model.getSectionId());
|
||||
dmpTemplate.setCreatedAt(Instant.now());
|
||||
dmpTemplate.setUpdatedAt(Instant.now());
|
||||
dmpTemplate.setIsActive(IsActive.Active);
|
||||
this.entityManager.persist(dmpTemplate);
|
||||
DmpDescriptionTemplateEntity data = items.stream().filter(x -> x.getDescriptionTemplateGroupId().equals(model.getDescriptionTemplateGroupId()) && x.getSectionId().equals(model.getSectionId())).findFirst().orElse(null);
|
||||
if (data == null){
|
||||
data = new DmpDescriptionTemplateEntity();
|
||||
data.setId(UUID.randomUUID());
|
||||
data.setIsActive(IsActive.Active);
|
||||
data.setCreatedAt(Instant.now());
|
||||
data.setDmpId(id);
|
||||
data.setSectionId(model.getSectionId());
|
||||
data.setDescriptionTemplateGroupId(model.getDescriptionTemplateGroupId());
|
||||
this.entityManager.persist(data);
|
||||
}
|
||||
|
||||
updatedCreatedIds.add(data.getId());
|
||||
}
|
||||
this.entityManager.flush();
|
||||
List<DmpDescriptionTemplateEntity> toDelete = items.stream().filter(x-> updatedCreatedIds.stream().noneMatch(y-> y.equals(x.getId()))).collect(Collectors.toList());
|
||||
|
||||
this.deleterFactory.deleter(DmpDescriptionTemplateDeleter.class).delete(toDelete);
|
||||
}
|
||||
|
||||
private @NotNull DefinitionEntity buildDefinitionEntity(DefinitionPersist persist){
|
||||
|
|
|
@ -485,7 +485,7 @@ public class DataManagementPlanManager {
|
|||
|
||||
List<DescriptionEntity> descriptionEntityList = this.databaseRepository.getDatasetDao().getWithCriteria(datasetCriteria).toList().stream().filter(dataset -> dataset.getIsActive() != IsActive.Inactive).collect(Collectors.toList());
|
||||
for (DescriptionEntity descriptionEntity : descriptionEntityList) {
|
||||
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)
|
||||
if (dataManagementPlan.getProfiles().stream().filter(associatedProfile -> descriptionEntity.getDescriptionTemplateId().equals(associatedProfile.getDescriptionTemplateId())).findAny().orElse(null) == null)
|
||||
throw new Exception("Dataset Template for Dataset Description is missing from the DMP.");
|
||||
}
|
||||
if (dataManagementPlan.getStatus() == DmpStatus.Finalized.getValue() && dmp1.getStatus().equals(DmpStatus.Finalized.getValue() ))
|
||||
|
@ -1639,7 +1639,7 @@ public class DataManagementPlanManager {
|
|||
//runDatasetTemplate1.setBold(true);
|
||||
//runDatasetTemplate1.setFontSize(12);
|
||||
XWPFRun runDatasetTemplate = datasetTemplateParagraph.createRun();
|
||||
runDatasetTemplate.setText(this.queryFactory.query(DescriptionTemplateQuery.class).ids(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(datasetEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDescriptionTemplateId()).first().getLabel());
|
||||
runDatasetTemplate.setText(this.queryFactory.query(DescriptionTemplateQuery.class).ids(datasetEntity.getDescriptionTemplateId()).first().getLabel());
|
||||
runDatasetTemplate.setColor("116a78");
|
||||
//runDatasetTemplate.setBold(true);
|
||||
//runDatasetTemplate.setFontSize(12);
|
||||
|
@ -1685,7 +1685,7 @@ public class DataManagementPlanManager {
|
|||
runDatasetDescription1.setText("Description: ");
|
||||
runDatasetDescription1.setColor("000000");
|
||||
XWPFRun runDatasetDescription = datasetDescParagraph.createRun();
|
||||
runDatasetDescription.setText(this.queryFactory.query(DescriptionTemplateQuery.class).ids(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(datasetEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDescriptionTemplateId()).first().getLabel());
|
||||
runDatasetDescription.setText(this.queryFactory.query(DescriptionTemplateQuery.class).ids(datasetEntity.getDescriptionTemplateId()).first().getLabel());
|
||||
runDatasetDescription.setColor("116a78");
|
||||
//wordBuilder.addParagraphContent(datasetEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO, 0);
|
||||
|
||||
|
@ -1981,11 +1981,11 @@ public class DataManagementPlanManager {
|
|||
|
||||
Element datsetProfileElement = xmlDoc.createElement("profile-id");
|
||||
datasetElement.appendChild(datsetProfileElement);
|
||||
datsetProfileElement.setTextContent(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDescriptionTemplateId().toString());
|
||||
datsetProfileElement.setTextContent(descriptionEntity.getDescriptionTemplateId().toString());
|
||||
|
||||
Element datsetProfileLabelElement = xmlDoc.createElement("profile-label");
|
||||
datasetElement.appendChild(datsetProfileLabelElement);
|
||||
datsetProfileLabelElement.setTextContent(this.queryFactory.query(DescriptionTemplateQuery.class).ids(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDescriptionTemplateId()).first().getLabel());
|
||||
datsetProfileLabelElement.setTextContent(this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntity.getDescriptionTemplateId()).first().getLabel());
|
||||
|
||||
DatasetWizardModel datasetWizardModel = new DatasetWizardModel();
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
|
|
|
@ -315,7 +315,7 @@ public class DatasetManager {
|
|||
|
||||
// Creates the Criteria to get all version of DescriptionTemplate in question.
|
||||
DatasetProfileCriteria profileCriteria = new DatasetProfileCriteria();
|
||||
UUID profileId = this.queryFactory.query(DescriptionTemplateQuery.class).ids(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDescriptionTemplateId()).first().getGroupId();
|
||||
UUID profileId = this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDescriptionTemplateId()).first().getGroupId();
|
||||
List<UUID> uuidList = new LinkedList<>();
|
||||
uuidList.add(profileId);
|
||||
profileCriteria.setGroupIds(uuidList);
|
||||
|
@ -346,7 +346,7 @@ public class DatasetManager {
|
|||
DescriptionTemplateEntity profile = profiles.get(0);
|
||||
|
||||
// Check if the dataset is on the latest Version.
|
||||
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());
|
||||
boolean latestVersion = profile.getVersion().toString().equals(this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDescriptionTemplateId()).first().getVersion());
|
||||
dataset.setIsProfileLatestVersion(latestVersion);
|
||||
|
||||
// eu.eudat.elastic.entities.Dataset datasetElastic; //TODO
|
||||
|
@ -409,7 +409,7 @@ public class DatasetManager {
|
|||
}
|
||||
|
||||
public PagedDatasetProfile getPagedProfile(DatasetWizardModel dataset, DescriptionEntity descriptionEntityEntity) {
|
||||
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());
|
||||
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDescriptionTemplateId()).first());
|
||||
datasetprofile.setStatus(dataset.getStatus().getValue());
|
||||
if (descriptionEntityEntity.getProperties() != null) {
|
||||
JSONObject jObject = new JSONObject(descriptionEntityEntity.getProperties());
|
||||
|
@ -616,7 +616,7 @@ public class DatasetManager {
|
|||
PagedDatasetProfile pagedDatasetProfile = getPagedProfile(dataset, descriptionEntityEntity);
|
||||
visibilityRuleService.setProperties(properties);
|
||||
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
||||
File file = xmlBuilder.build(pagedDatasetProfile, this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDescriptionTemplateId(), visibilityRuleService, environment);
|
||||
File file = xmlBuilder.build(pagedDatasetProfile, descriptionEntityEntity.getDescriptionTemplateId(), visibilityRuleService, environment);
|
||||
FileEnvelope fileEnvelope = new FileEnvelope();
|
||||
fileEnvelope.setFile(file);
|
||||
String label = descriptionEntityEntity.getLabel().replaceAll("[^a-zA-Z0-9+ ]", "");
|
||||
|
@ -758,7 +758,7 @@ public class DatasetManager {
|
|||
|
||||
public String checkDatasetValidation(DescriptionEntity descriptionEntity) throws Exception {
|
||||
List<String> datasetProfileValidators = new LinkedList<>();
|
||||
DescriptionTemplateEntity profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDescriptionTemplateId());
|
||||
DescriptionTemplateEntity profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(descriptionEntity.getDescriptionTemplateId());
|
||||
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder builder = builderFactory.newDocumentBuilder();
|
||||
Document xmlDocument = builder.parse(new ByteArrayInputStream(profile.getDefinition().getBytes()));
|
||||
|
|
|
@ -57,7 +57,7 @@ public class DatasetWizardManager {
|
|||
|
||||
public void unlock(ApiContext apiContext, QueryFactory queryFactory, UUID uuid) throws DatasetWizardCannotUnlockException, InvalidApplicationException {
|
||||
DescriptionEntity descriptionEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(uuid);
|
||||
DmpEntity dmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDescriptionTemplateId());
|
||||
DmpEntity dmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(descriptionEntity.getDescriptionTemplateId());
|
||||
if(dmp.getStatus().equals(DmpStatus.Finalized)) throw new DatasetWizardCannotUnlockException("To perform this action you will need to revert DMP's finalisation");
|
||||
descriptionEntity.setStatus(DescriptionStatus.Draft);
|
||||
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(descriptionEntity);
|
||||
|
|
|
@ -414,7 +414,7 @@ public class MetricsManager {
|
|||
List<DescriptionTemplateEntity> descriptionTemplateEntities = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).withFields(Collections.singletonList("id")).toList();
|
||||
DatasetCriteria datasetCriteria = new DatasetCriteria();
|
||||
datasetCriteria.setDatasetTemplates(descriptionTemplateEntities.stream().map(DescriptionTemplateEntity::getId).collect(Collectors.toList()));
|
||||
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();
|
||||
return apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(datasetCriteria).select(root -> root.getDescriptionTemplateId()).stream().distinct().count();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class DatasetRDAMapper {
|
|||
}
|
||||
rda.setTitle(descriptionEntity.getLabel());
|
||||
rda.setDescription(descriptionEntity.getDescription());
|
||||
rda.setAdditionalProperty("template", this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDescriptionTemplateId()); //TODO
|
||||
rda.setAdditionalProperty("template", this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity.getDescriptionTemplateId())); //TODO
|
||||
try {
|
||||
JSONObject jObject = new JSONObject(descriptionEntity.getProperties());
|
||||
Map<String, Object> templateIdsToValues = jObject.toMap();
|
||||
|
|
|
@ -184,7 +184,7 @@ public class DmpRDAMapper {
|
|||
return entity;
|
||||
}
|
||||
|
||||
private DmpDescriptionTemplateEntity getProfile(String descriptionTemplateId, UUID dmpId) throws InvalidApplicationException {
|
||||
return this.queryFactory.query(DmpDescriptionTemplateQuery.class).dmpIds(dmpId).descriptionTemplateIds(UUID.fromString(descriptionTemplateId)).first();
|
||||
}
|
||||
// private DmpDescriptionTemplateEntity getProfile(String descriptionTemplateId, UUID dmpId) throws InvalidApplicationException {
|
||||
// return this.queryFactory.query(DmpDescriptionTemplateQuery.class).dmpIds(dmpId).descriptionTemplateIds(UUID.fromString(descriptionTemplateId)).first();
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -8,16 +8,14 @@ CREATE TABLE IF NOT EXISTS public."DmpDescriptionTemplate"
|
|||
(
|
||||
"id" uuid NOT NULL,
|
||||
"dmp" uuid NOT NULL,
|
||||
"description_template" uuid NOT NULL,
|
||||
"description_template_group" uuid NOT NULL,
|
||||
"section_id" uuid NOT NULL,
|
||||
"created_at" timestamp without time zone NOT NULL DEFAULT now(),
|
||||
"updated_at" timestamp without time zone NOT NULL DEFAULT now(),
|
||||
"is_active" smallint NOT NULL DEFAULT 1,
|
||||
CONSTRAINT "DmpDescriptionTemplate_pkey" PRIMARY KEY (id),
|
||||
CONSTRAINT "DmpDescriptionTemplate_dmp_fkey" FOREIGN KEY (dmp)
|
||||
REFERENCES public."Dmp" (id),
|
||||
CONSTRAINT "DmpDescriptionTemplate_description_template_fkey" FOREIGN KEY (description_template)
|
||||
REFERENCES public."DescriptionTemplate" (id)
|
||||
REFERENCES public."Dmp" (id)
|
||||
);
|
||||
|
||||
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.012', '2023-11-02 12:00:00.000000+02', now(), 'Add Dmp Description Template table (former DMPDatasetProfile).');
|
||||
|
|
|
@ -14,6 +14,9 @@ BEGIN
|
|||
|
||||
ALTER TABLE public."Description" DROP COLUMN dmp_section_index;
|
||||
|
||||
ALTER TABLE public."Description" ADD COLUMN description_template uuid NOT NULL;
|
||||
|
||||
|
||||
ALTER TABLE public."Description"
|
||||
ALTER COLUMN dmp SET NOT NULL;
|
||||
|
||||
|
@ -37,6 +40,13 @@ BEGIN
|
|||
ON DELETE NO ACTION
|
||||
NOT VALID;
|
||||
|
||||
ALTER TABLE public."Description"
|
||||
ADD FOREIGN KEY (description_template)
|
||||
REFERENCES public."DescriptionTemplate" (id) MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE NO ACTION
|
||||
NOT VALID;
|
||||
|
||||
|
||||
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.014', '2023-11-20 12:00:00.000000+02', now(), 'Sync table Description.');
|
||||
|
||||
|
|
Loading…
Reference in New Issue