Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
<graphql-scalars.version>21.0</graphql-scalars.version>
<graphql-dataloader.version>3.2.2</graphql-dataloader.version>
<graphql-filter.version>3.0.7</graphql-filter.version>
<pf4j.version>3.11.0</pf4j.version>
<pf4j.version>3.14.1</pf4j.version>
<asm.version>3.3.1</asm.version>
<spring.security.version>6.3.5</spring.security.version>
<elasticsearch.client.version>1.1.4</elasticsearch.client.version>
<hazelcast.version>5.6.0</hazelcast.version>
<jackson.version>2.21.1</jackson.version>
<jackson-databind.version>2.21.1</jackson-databind.version>
<jackson-annotations.version>2.21</jackson-annotations.version>
<netty.version>4.1.125.Final</netty.version>
<netty.version>4.1.132.Final</netty.version>
<tika.version>3.2.2</tika.version>
<aws.sdk.version>2.16.83</aws.sdk.version>
<snakeyaml.version>2.2</snakeyaml.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GraphQL: Filtering has been enabled for the selected entities: schemas, microschemas, tags, tag families.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Some Dependencies have been updated:
* Netty: 4.1.132.Final
* Plugin Framework for Java: 3.14.1
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void handleUpdate(InternalActionContext ac, String uuid) {
String name = microschema.getName();

if (model.getChanges().isEmpty()) {
return message(ac, "schema_update_no_difference_detected", name);
return message(ac, "schema_update_no_difference_detected");
}
HibUser user = ac.getUser();
SchemaUpdateParameters updateParams = ac.getSchemaUpdateParameters();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void handleUpdate(InternalActionContext ac, String uuid) {

// No changes -> done
if (model.getChanges().isEmpty()) {
return message(ac, "schema_update_no_difference_detected", schemaName);
return message(ac, "schema_update_no_difference_detected");
}

SchemaUpdateParameters updateParams = ac.getSchemaUpdateParameters();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1502,6 +1502,9 @@ private HibernateFilter makeParameterOperand(
} else if (actualFieldName.startsWith("USER.")) {
actualFieldName = parts[1];
maybeOwner = Optional.of("USER");
} else if (actualFieldName.startsWith("TAGFAMILY.")) {
actualFieldName = parts[1];
maybeOwner = Optional.of("TAGFAMILY");
} else if (maybeOwner.filter(o -> "USER".equals(o)).isPresent()) {
maybeOwner = joins.stream().map(j -> {
if ("USER".equals(j.getLeft().getTable())) {
Expand All @@ -1512,6 +1515,16 @@ private HibernateFilter makeParameterOperand(
return null;
}
}).filter(s -> StringUtils.isNotBlank(s)).findAny().or(() -> op.maybeGetOwner());
} else if (maybeOwner.filter(o -> "TAGFAMILY".equals(o)).isPresent()) {
maybeOwner = joins.stream().map(j -> {
if ("TAGFAMILY".equals(j.getLeft().getTable())) {
return j.getRight().getField();
} else if ("TAGFAMILY".equals(j.getRight().getTable())) {
return j.getLeft().getField();
} else {
return null;
}
}).filter(s -> StringUtils.isNotBlank(s)).findAny().or(() -> op.maybeGetOwner());
} else if (maybeOwner.filter(o -> o.endsWith("LIST")).isPresent()) {
if (op instanceof ListItemOperationOperand) {
actualFieldName = buildListFieldItemOperand((ListItemOperationOperand) op, maybeOwner, ownerAlias, paramsMap, callStack.peek().getInitiatingFilterName(), maybeBranch, maybeTopLevelFilter, maybeContainerType, callStack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,21 @@ public HibTag beforeDeletedFromDatabase(HibTag element) {
}
return element;
}

@Override
public String mapGraphQlFilterFieldName(String gqlName) {
switch (gqlName) {
case "tagFamily": return "tagFamily_dbUuid";
}
return super.mapGraphQlFilterFieldName(gqlName);
}

@Override
public String mapGraphQlSortingFieldName(String gqlName) {
switch (gqlName) {
case "tagFamily": return "TAGFAMILY.tagFamily_dbUuid";
case "TAGFAMILY.tagFamily_dbUuid": return mapGraphQlSortingFieldName("tagFamily");
}
return super.mapGraphQlSortingFieldName(gqlName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ public String getUuid() {
}

@Override
public void setUuid(String uuid) {
public AbstractResponse setUuid(String uuid) {
this.uuid = uuid;
return this;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public interface RestResponse extends RestModel {
*
* @param uuid
* Uuid to be set
* @return fluent self
*/
void setUuid(String uuid);
RestResponse setUuid(String uuid);

}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public Boolean getNoIndex() {

@Override
public SchemaResponse setNoIndex(Boolean noIndex) {
this.noIndex = noIndex;
this.noIndex = noIndex == Boolean.TRUE;
return this;
}

Expand Down Expand Up @@ -221,4 +221,9 @@ public String toString() {
return getName() + " fields: {" + fields + "}";
}

@Override
public SchemaResponse setUuid(String uuid) {
super.setUuid(uuid);
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,13 @@ protected static Stream<List<Object>> queries() {
Arrays.asList("role-user-group-query", true, false, "draft"),
Arrays.asList("group-query", true, false, "draft"),
Arrays.asList("schema-query", true, false, "draft"),
Arrays.asList("schemas-query", true, false, "draft"),
// Arrays.asList("schema-projects-query", true, false, "draft"),
Arrays.asList("microschema-query", true, false, "draft"),
Arrays.asList("microschemas-query", true, false, "draft"),
Arrays.asList("paging-query", true, false, "draft"),
Arrays.asList("tagFamily-query", true, false, "draft"),
Arrays.asList("tagfamilies-query", true, false, "draft"),
Arrays.asList("node-query", true, false, "draft"),
Arrays.asList("node-tag-query", true, false, "draft"),
Arrays.asList("nodes-query", true, false, "draft"),
Expand All @@ -196,6 +199,7 @@ protected static Stream<List<Object>> queries() {
Arrays.asList("node-field-list-path-query", true, false, "draft"),
Arrays.asList("project-query", true, false, "draft"),
Arrays.asList("tag-query", true, false, "draft"),
Arrays.asList("tags-query", true, false, "draft"),
Arrays.asList("branch-query", true, true, "draft"),
Arrays.asList("user-query", true, false, "draft"),
Arrays.asList("microschema-projects-query", true, false, "draft"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ public void testNoChangesUpdate() {

// Update the schema server side
GenericMessageResponse status = call(() -> client().updateSchema(container.getUuid(), schema));
assertThat(status).matches("schema_update_no_difference_detected");
assertThat(status).matches("schema_update_no_difference_detected", "content");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
microschemas {
elements {
uuid
isNoIndex
}
}
}
Expand Down
29 changes: 29 additions & 0 deletions tests/tests-core/src/main/resources/graphql/microschemas-query
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
microschemas (filter: {name: {oneOf: ["vcard", "whatever"]}}, sort: {name: ASCENDING}) {
# [$.data.microschemas.totalCount=1]
totalCount
elements {
# [$.data.microschemas.elements[0].name=vcard]
name
# [$.data.microschemas.elements[0].uuid=<is-uuid>]
uuid
# [$.data.microschemas.elements[0].version=<is-not-null>]
version
# [$.data.microschemas.elements[0].description=<is-not-null>]
description
# [$.data.microschemas.elements[0].isNoIndex=<is-null>]
isNoIndex
# [$.data.microschemas.elements[0].isEmpty=false]
isEmpty
# [$.data.microschemas.elements[0].fields=<is-not-null>]
fields {
name
label
required
type
noIndex
}
}
}
}
# [$.errors=<is-undefined>]
2 changes: 2 additions & 0 deletions tests/tests-core/src/main/resources/graphql/schema-query
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
name
# [$.data.folderSchema.isAutoPurge=true]
isAutoPurge
# [$.data.folderSchema.isNoIndex=<is-null>]
isNoIndex
}

schema(name:"content") {
Expand Down
31 changes: 31 additions & 0 deletions tests/tests-core/src/main/resources/graphql/schemas-query
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
schemas (filter: {name: {oneOf: ["content", "whatever"]}}, sort: {name: ASCENDING}) {
# [$.data.schemas.totalCount=1]
totalCount
elements {
# [$.data.schemas.elements[0].name=content]
name
# [$.data.schemas.elements[0].uuid=<is-uuid>]
uuid
# [$.data.schemas.elements[0].version=<is-not-null>]
version
# [$.data.schemas.elements[0].description=<is-not-null>]
description
# [$.data.schemas.elements[0].isNoIndex=<is-null>]
isNoIndex
# [$.data.schemas.elements[0].isEmpty=false]
isEmpty
# [$.data.schemas.elements[0].isAutoPurge=<is-null>]
isAutoPurge
# [$.data.schemas.elements[0].fields=<is-not-null>]
fields {
name
label
required
type
noIndex
}
}
}
}
# [$.errors=<is-undefined>]
21 changes: 21 additions & 0 deletions tests/tests-core/src/main/resources/graphql/tagfamilies-query
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
tagFamilies (filter: {name: {oneOf: ["colors", "basic", "whatever"]}}, sort: {name: DESCENDING}) {
# [$.data.tagFamilies.totalCount=2]
totalCount
elements {
# [$.data.tagFamilies.elements[0].name=colors]
name
# [$.data.tagFamilies.elements[0].uuid=<is-uuid>]
uuid
tags (sortBy: "name", sortOrder: ASCENDING) {
# [$.data.tagFamilies.elements[0].tags.totalCount=3]
totalCount
elements {
# [$.data.tagFamilies.elements[0].tags.elements[0].name=blue]
name
}
}
}
}
}
# [$.errors=<is-undefined>]
13 changes: 13 additions & 0 deletions tests/tests-core/src/main/resources/graphql/tags-query
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
tags (filter: {name: {oneOf: ["red", "jeep", "whatever"]}, tagFamily: {name: {oneOf: ["colors"]}}}, sort: {name: ASCENDING}) {
# [$.data.tags.totalCount=1]
totalCount
elements {
# [$.data.tags.elements[0].name=red]
name
# [$.data.tags.elements[0].uuid=<is-uuid>]
uuid
}
}
}
# [$.errors=<is-undefined>]
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.Optional;

import com.gentics.graphqlfilter.filter.FilterField;
import com.gentics.graphqlfilter.filter.StartMainFilter;
import com.gentics.mesh.ElementType;
import com.gentics.mesh.core.data.role.HibRole;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.gentics.mesh.graphql.filter;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import com.gentics.graphqlfilter.filter.FilterField;
import com.gentics.mesh.ElementType;
import com.gentics.mesh.core.data.tagfamily.HibTagFamily;

/**
* Filters tag families in GraphQl. This filter should be used whenever a list of tag families is returned.
*/
public class TagFamilyFilter extends EntityFilter<HibTagFamily> {

private static final ElementType ELEMENT = ElementType.TAGFAMILY;
private static final String NAME = "TagFamilyFilter";

private static TagFamilyFilter instance;

public static synchronized TagFamilyFilter filter() {
if (instance == null) {
instance = new TagFamilyFilter();
}
return instance;
}

private TagFamilyFilter() {
super(NAME, "Filters tag families", Optional.of(ELEMENT.name()));
}

@Override
protected List<FilterField<HibTagFamily, ?>> getFilters() {
String owner = ELEMENT.name();
List<FilterField<HibTagFamily, ?>> filters = new ArrayList<>();
filters.add(CommonFields.hibNameFilter(owner));
filters.add(CommonFields.hibUuidFilter(owner));
filters.addAll(CommonFields.hibUserTrackingFilter(owner));
return filters;
}

@Override
protected ElementType getEntityType() {
return ELEMENT;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.gentics.mesh.graphql.filter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;

import com.gentics.graphqlfilter.filter.DateFilter;
import com.gentics.graphqlfilter.filter.FilterField;
import com.gentics.graphqlfilter.filter.MappedFilter;
import com.gentics.graphqlfilter.filter.operation.JoinPart;
import com.gentics.mesh.ElementType;
import com.gentics.mesh.core.data.tag.HibTag;
import com.gentics.mesh.core.data.user.HibUserTracking;

import graphql.util.Pair;

/**
* Filters tags in GraphQl. This filter should be used whenever a list of tags is returned.
*/
public class TagFilter extends EntityFilter<HibTag> {

private static final ElementType ELEMENT = ElementType.TAG;
private static final String NAME = "TagFilter";

private static TagFilter instance;

public static synchronized TagFilter filter() {
if (instance == null) {
instance = new TagFilter();
}
return instance;
}

private TagFilter() {
super(NAME, "Filters tags", Optional.of(ELEMENT.name()));
}

@Override
protected List<FilterField<HibTag, ?>> getFilters() {
String owner = ELEMENT.name();
List<FilterField<HibTag, ?>> filters = new ArrayList<>();
filters.add(CommonFields.hibNameFilter(owner));
filters.add(CommonFields.hibUuidFilter(owner));
filters.addAll(CommonFields.hibUserTrackingFilter(owner));
filters.add(new MappedFilter<>(owner, "tagFamily", "Filters by creator", TagFamilyFilter.filter(), HibTag::getTagFamily, Pair.pair("tagFamily", new JoinPart(ElementType.USER.name(), "uuid"))));
return filters;
}

@Override
protected ElementType getEntityType() {
return ELEMENT;
}
}
Loading