export and import xml description tags
This commit is contained in:
parent
1b47a9d6ec
commit
a05885c8a9
|
@ -26,6 +26,10 @@ public class DescriptionImportExport {
|
||||||
@XmlElement(name = "sectionId")
|
@XmlElement(name = "sectionId")
|
||||||
private UUID sectionId;
|
private UUID sectionId;
|
||||||
|
|
||||||
|
@XmlElementWrapper(name = "tags")
|
||||||
|
@XmlElement(name = "tag")
|
||||||
|
private List<String> tags;
|
||||||
|
|
||||||
@XmlElement(name = "descriptionTemplate")
|
@XmlElement(name = "descriptionTemplate")
|
||||||
private DescriptionTemplateImportExport descriptionTemplate;
|
private DescriptionTemplateImportExport descriptionTemplate;
|
||||||
|
|
||||||
|
@ -99,5 +103,13 @@ public class DescriptionImportExport {
|
||||||
public void setProperties(DescriptionPropertyDefinitionImportExport properties) {
|
public void setProperties(DescriptionPropertyDefinitionImportExport properties) {
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getTags() {
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTags(List<String> tags) {
|
||||||
|
this.tags = tags;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,8 @@ public class TagQuery extends QueryBase<TagEntity> {
|
||||||
|
|
||||||
private Collection<UUID> createdByIds;
|
private Collection<UUID> createdByIds;
|
||||||
|
|
||||||
|
private DescriptionTagQuery descriptionTagQuery;
|
||||||
|
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
private final UserScope userScope;
|
private final UserScope userScope;
|
||||||
|
@ -146,6 +148,11 @@ public class TagQuery extends QueryBase<TagEntity> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TagQuery descriptionTagSubQuery(DescriptionTagQuery subQuery) {
|
||||||
|
this.descriptionTagQuery = subQuery;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public TagQuery authorize(EnumSet<AuthorizationFlags> values) {
|
public TagQuery authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
this.authorize = values;
|
this.authorize = values;
|
||||||
return this;
|
return this;
|
||||||
|
@ -169,7 +176,8 @@ public class TagQuery extends QueryBase<TagEntity> {
|
||||||
this.isEmpty(this.tags) ||
|
this.isEmpty(this.tags) ||
|
||||||
this.isEmpty(this.excludedTags) ||
|
this.isEmpty(this.excludedTags) ||
|
||||||
this.isEmpty(this.excludedIds) ||
|
this.isEmpty(this.excludedIds) ||
|
||||||
this.isEmpty(this.createdByIds);
|
this.isEmpty(this.createdByIds) ||
|
||||||
|
this.isFalseQuery(this.descriptionTagQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -250,6 +258,10 @@ public class TagQuery extends QueryBase<TagEntity> {
|
||||||
inClause.value(item);
|
inClause.value(item);
|
||||||
predicates.add(inClause);
|
predicates.add(inClause);
|
||||||
}
|
}
|
||||||
|
if (this.descriptionTagQuery != null) {
|
||||||
|
QueryContext<DescriptionTagEntity, UUID> subQuery = this.applySubQuery(this.descriptionTagQuery, queryContext, UUID.class, descriptionTagEntityRoot -> descriptionTagEntityRoot.get(DescriptionTagEntity._tagId));
|
||||||
|
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(TagEntity._id)).value(subQuery.Query));
|
||||||
|
}
|
||||||
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);
|
||||||
|
|
|
@ -1102,6 +1102,13 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().ids(data.getDmpDescriptionTemplateId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).isActive(IsActive.Active).first();
|
DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().ids(data.getDmpDescriptionTemplateId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).isActive(IsActive.Active).first();
|
||||||
if (dmpDescriptionTemplateEntity != null) xml.setSectionId(dmpDescriptionTemplateEntity.getSectionId());
|
if (dmpDescriptionTemplateEntity != null) xml.setSectionId(dmpDescriptionTemplateEntity.getSectionId());
|
||||||
|
|
||||||
|
DescriptionTagQuery descriptionTagQuery = new DescriptionTagQuery();
|
||||||
|
descriptionTagQuery.descriptionIds(data.getId());
|
||||||
|
descriptionTagQuery.isActive(IsActive.Active);
|
||||||
|
|
||||||
|
List<TagEntity> tagsEntities = this.queryFactory.query(TagQuery.class).disableTracking().descriptionTagSubQuery(descriptionTagQuery).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).isActive(IsActive.Active).collect();
|
||||||
|
if (!this.conventionService.isListNullOrEmpty(tagsEntities)) xml.setTags(tagsEntities.stream().map(x -> x.getLabel()).collect(Collectors.toList()));
|
||||||
|
|
||||||
DescriptionTemplateEntity descriptionTemplateEntity = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().ids(data.getDescriptionTemplateId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).isActive(IsActive.Active).first();
|
DescriptionTemplateEntity descriptionTemplateEntity = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().ids(data.getDescriptionTemplateId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).isActive(IsActive.Active).first();
|
||||||
if (descriptionTemplateEntity != null) {
|
if (descriptionTemplateEntity != null) {
|
||||||
xml.setDescriptionTemplate(this.descriptionTemplateService.exportXmlEntity(descriptionTemplateEntity.getId(), true));
|
xml.setDescriptionTemplate(this.descriptionTemplateService.exportXmlEntity(descriptionTemplateEntity.getId(), true));
|
||||||
|
@ -1254,6 +1261,7 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
if (dmpDescriptionTemplate != null) persist.setDmpDescriptionTemplateId(dmpDescriptionTemplate.getId());
|
if (dmpDescriptionTemplate != null) persist.setDmpDescriptionTemplateId(dmpDescriptionTemplate.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
persist.setTags(descriptionXml.getTags());
|
||||||
|
|
||||||
persist.setProperties(this.xmlToPropertyDefinitionToPersist(descriptionXml));
|
persist.setProperties(this.xmlToPropertyDefinitionToPersist(descriptionXml));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue