private static void addFilters()

in graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/schema/PropertyFilterUtils.java [50:213]


    private static void addFilters(final List<GraphQLInputObjectField> fieldDefinitions, final GraphQLSchemaProvider.DefinitionType propertyType, final GraphQLAnnotations graphQLAnnotations) {
        final String propertyName = PropertyNameTranslator.translateFromUnomiToGraphQL(propertyType.getName());

        if ("integer".equals(propertyType.getTypeId())) {
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_equals")
                    .type(Scalars.GraphQLInt)
                    .build());
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_lt")
                    .type(Scalars.GraphQLInt)
                    .build());
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_lte")
                    .type(Scalars.GraphQLInt)
                    .build());
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_gt")
                    .type(Scalars.GraphQLInt)
                    .build());
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_gte")
                    .type(Scalars.GraphQLInt)
                    .build());
        } else if ("long".equals(propertyType.getTypeId())) {
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_equals")
                    .type(Scalars.GraphQLLong)
                    .build());
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_lt")
                    .type(Scalars.GraphQLLong)
                    .build());
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_lte")
                    .type(Scalars.GraphQLLong)
                    .build());
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_gt")
                    .type(Scalars.GraphQLLong)
                    .build());
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_gte")
                    .type(Scalars.GraphQLLong)
                    .build());
        } else if ("float".equals(propertyType.getTypeId())) {

            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_equals")
                    .type(Scalars.GraphQLFloat)
                    .build());
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_lt")
                    .type(Scalars.GraphQLFloat)
                    .build());
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_lte")
                    .type(Scalars.GraphQLFloat)
                    .build());
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_gt")
                    .type(Scalars.GraphQLFloat)
                    .build());
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_gte")
                    .type(Scalars.GraphQLFloat)
                    .build());
        } else if ("date".equals(propertyType.getTypeId())) {
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_equals")
                    .type(DateTimeFunction.DATE_TIME_SCALAR)
                    .build());
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_lt")
                    .type(DateTimeFunction.DATE_TIME_SCALAR)
                    .build());
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_lte")
                    .type(DateTimeFunction.DATE_TIME_SCALAR)
                    .build());
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_gt")
                    .type(DateTimeFunction.DATE_TIME_SCALAR)
                    .build());
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_gte")
                    .type(DateTimeFunction.DATE_TIME_SCALAR)
                    .build());
        } else if ("boolean".equals(propertyType.getTypeId())) {
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_equals")
                    .type(Scalars.GraphQLBoolean)
                    .build());
        } else if ("id".equals(propertyType.getTypeId())) {
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_equals")
                    .type(Scalars.GraphQLString)
                    .build());
        } else if ("set".equals(propertyType.getTypeId())) {
            if (propertyType.hasSubTypes()) {
                final String typeName = StringUtils.capitalize(propertyName) + "FilterInput";

                GraphQLInputObjectType inputObjectType;
                if (!graphQLAnnotations.getContainer().getTypeRegistry().containsKey(typeName)) {
                    final GraphQLInputObjectType.Builder dynamicTypeBuilder = GraphQLInputObjectType.newInputObject()
                            .name(typeName);

                    final List<GraphQLInputObjectField> setFieldDefinitions = new ArrayList<>();

                    propertyType.getSubTypes().forEach(childPropertyType ->
                            addFilters(setFieldDefinitions, childPropertyType, graphQLAnnotations));

                    dynamicTypeBuilder.fields(setFieldDefinitions);

                    inputObjectType = dynamicTypeBuilder.build();

                    graphQLAnnotations.getContainer().getTypeRegistry().put(typeName, inputObjectType);
                } else {
                    inputObjectType = (GraphQLInputObjectType) graphQLAnnotations.getContainer().getTypeRegistry().get(typeName);
                }

                fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                        .name(propertyName)
                        .type(inputObjectType)
                        .build());
            }
        } else if ("geopoint".equals(propertyType.getTypeId())) {

            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_equals")
                    .type(GeoPointFunction.GEOPOINT_SCALAR)
                    .build());

            final String geoDistanceFilterTypeName = ReflectionUtil.resolveTypeName(CDPGeoDistanceFilterInput.class);
            final GraphQLInputType geoDistanceFilterType = (GraphQLInputObjectType) graphQLAnnotations.getContainer().getTypeRegistry().get(geoDistanceFilterTypeName);
            if (geoDistanceFilterType != null) {
                fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                        .name(propertyName + "_distance")
                        .type(geoDistanceFilterType)
                        .build());
            }
        } else {
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_equals")
                    .type(Scalars.GraphQLString)
                    .build());
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_startsWith")
                    .type(Scalars.GraphQLString)
                    .build());
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_endsWith")
                    .type(Scalars.GraphQLString)
                    .build());
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_contains")
                    .type(Scalars.GraphQLString)
                    .build());
            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
                    .name(propertyName + "_regexp")
                    .type(Scalars.GraphQLString)
                    .build());
        }
    }