diff --git a/core/app/datasource/src/main/java/io/openk9/datasource/service/DocTypeFieldService.java b/core/app/datasource/src/main/java/io/openk9/datasource/service/DocTypeFieldService.java index cc23c2ab8..530d1af3d 100644 --- a/core/app/datasource/src/main/java/io/openk9/datasource/service/DocTypeFieldService.java +++ b/core/app/datasource/src/main/java/io/openk9/datasource/service/DocTypeFieldService.java @@ -18,6 +18,7 @@ package io.openk9.datasource.service; import io.openk9.common.graphql.util.relay.Connection; +import io.openk9.common.graphql.util.relay.GraphqlId; import io.openk9.common.util.SortBy; import io.openk9.datasource.mapper.DocTypeFieldMapper; import io.openk9.datasource.model.Analyzer; @@ -32,6 +33,10 @@ import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Path; +import javax.persistence.criteria.Predicate; import java.util.ArrayList; import java.util.Collection; import java.util.LinkedHashSet; @@ -40,9 +45,6 @@ import java.util.Set; import java.util.stream.Collectors; -; - - @ApplicationScoped public class DocTypeFieldService extends BaseK9EntityService { DocTypeFieldService(DocTypeFieldMapper mapper) { @@ -259,9 +261,32 @@ public Uni> expandDocTypeFields(Collection docTy }); - } + public Uni> findConnection( + long parentId, String after, String before, Integer first, Integer last, + String searchText, Set sortByList) { + + + CriteriaBuilder criteriaBuilder = getCriteriaBuilder(); + + CriteriaQuery query = + criteriaBuilder.createQuery(getEntityClass()); + + Path root = query.from(getEntityClass()); + + Path parentField = root.get(DocTypeField_.parentDocTypeField); + + return findConnection( + query, root, + parentId > 0 + ? criteriaBuilder.equal(parentField, parentId) + : criteriaBuilder.isNull(parentField), + getSearchFields(), + after, before, first, last, searchText, sortByList + ); + } + public Uni loadDocTypeField(Set typeFields) { return em.withTransaction(s -> {