bug fix
This commit is contained in:
parent
6e767f1e5e
commit
f8251aaf43
|
@ -36,6 +36,7 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
|
|||
private Collection<ReferenceType> referenceTypes;
|
||||
|
||||
private Collection<String> references;
|
||||
private Collection<String> sources;
|
||||
|
||||
private Collection<UUID> excludedIds;
|
||||
|
||||
|
@ -111,6 +112,21 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
|
|||
return this;
|
||||
}
|
||||
|
||||
public ReferenceQuery sources(String value) {
|
||||
this.sources = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReferenceQuery sources(String... value) {
|
||||
this.sources = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReferenceQuery sources(Collection<String> values) {
|
||||
this.sources = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReferenceQuery excludedIds(Collection<UUID> values) {
|
||||
this.excludedIds = values;
|
||||
return this;
|
||||
|
@ -177,7 +193,7 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
|
|||
|
||||
@Override
|
||||
protected Boolean isFalseQuery() {
|
||||
return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.excludedIds) || this.isEmpty(this.referenceTypes) || this.isEmpty(this.referenceSourceTypes)|| this.isFalseQuery(this.dmpReferenceQuery);
|
||||
return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.sources) ||this.isEmpty(this.excludedIds) || this.isEmpty(this.referenceTypes) || this.isEmpty(this.referenceSourceTypes)|| this.isFalseQuery(this.dmpReferenceQuery);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -219,6 +235,12 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
|
|||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
if (this.sources != null) {
|
||||
CriteriaBuilder.In<String> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(ReferenceEntity._source));
|
||||
for (String item : this.sources)
|
||||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
if (this.excludedIds != null) {
|
||||
CriteriaBuilder.In<UUID> notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(ReferenceEntity._id));
|
||||
for (UUID item : this.excludedIds)
|
||||
|
|
|
@ -509,12 +509,13 @@ public class DescriptionServiceImpl implements DescriptionService {
|
|||
referenceEntity = this.entityManager.find(ReferenceEntity.class, referencePersist.getId());
|
||||
if (referenceEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{referencePersist.getId(), Reference.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
} else {
|
||||
referenceEntity = this.queryFactory.query(ReferenceQuery.class).sourceTypes(referencePersist.getSourceType()).references(referencePersist.getReference()).first();
|
||||
referenceEntity = this.queryFactory.query(ReferenceQuery.class).sourceTypes(referencePersist.getSourceType()).sources(referencePersist.getSource()).isActive(IsActive.Active).references(referencePersist.getReference()).first();
|
||||
if (referenceEntity == null){
|
||||
referenceEntity = new ReferenceEntity();
|
||||
referenceEntity.setId(UUID.randomUUID());
|
||||
referenceEntity.setIsActive(IsActive.Active);
|
||||
referenceEntity.setCreatedAt(Instant.now());
|
||||
referenceEntity.setType(referencePersist.getType());
|
||||
|
||||
referenceEntity.setDefinition(this.xmlHandlingService.toXmlSafe(this.buildDefinitionEntity(referencePersist.getDefinition())));
|
||||
referenceEntity.setUpdatedAt(Instant.now());
|
||||
|
|
|
@ -647,12 +647,13 @@ public class DmpServiceImpl implements DmpService {
|
|||
referenceEntity = this.entityManager.find(ReferenceEntity.class, referencePersist.getId());
|
||||
if (referenceEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{referencePersist.getId(), Reference.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
} else {
|
||||
referenceEntity = this.queryFactory.query(ReferenceQuery.class).sourceTypes(referencePersist.getSourceType()).references(referencePersist.getReference()).first();
|
||||
referenceEntity = this.queryFactory.query(ReferenceQuery.class).sourceTypes(referencePersist.getSourceType()).sources(referencePersist.getSource()).isActive(IsActive.Active).references(referencePersist.getReference()).first();
|
||||
if (referenceEntity == null){
|
||||
referenceEntity = new ReferenceEntity();
|
||||
referenceEntity.setId(UUID.randomUUID());
|
||||
referenceEntity.setIsActive(IsActive.Active);
|
||||
referenceEntity.setCreatedAt(Instant.now());
|
||||
referenceEntity.setType(referencePersist.getType());
|
||||
|
||||
referenceEntity.setDefinition(this.xmlHandlingService.toXmlSafe(this.buildDefinitionEntity(referencePersist.getDefinition())));
|
||||
referenceEntity.setUpdatedAt(Instant.now());
|
||||
|
|
Loading…
Reference in New Issue