Class SPARQL2GraphQLHelper

java.lang.Object
se.liu.ida.hefquin.engine.wrappers.graphql.utils.SPARQL2GraphQLHelper

public class SPARQL2GraphQLHelper extends Object
Provides helper functions for creating the necessary data in a GraphQL query.
  • Field Details

  • Constructor Details

  • Method Details

    • materializeAll

      public GraphQLQuery materializeAll()
      Generates a GraphQL query that fetches everything from the GraphQL endpoint.
    • addSgp

      public Set<String> addSgp(StarPattern sp, String currentPath, String sgpType)
      Recursive function used to add fields from the triple patterns in a given star pattern
    • addObjectField

      protected Set<String> addObjectField(StarPattern sp, String currentPath, String sgpType, String predicateURI)
      Helper function to add a field to the query that represents a nested object. Fields in that nested object are added recursively through addSgp
    • addEmptyObjectField

      protected String addEmptyObjectField(String currentPath, String sgpType, String predicateURI)
      Helper function to add a field to the query that represents a nested object that only needs an id field (no more recursive calls)
    • addScalarField

      protected String addScalarField(String currentPath, String predicateURI)
      Helper function to add a field to the query that represents a scalar value
    • hasVariablePredicate

      protected static boolean hasVariablePredicate(StarPattern sp)
      Helper function which checks if any triple pattern predicate in @param sp is a variable or blank node, returns true if so
    • hasNecessaryArguments

      public static boolean hasNecessaryArguments(Set<String> sgpArgumentNames, Set<String> entrypointArgumentNames)
      Check if @param sgpArgumentNames have atleast one match with @param entrypointArgumentNames
    • hasAllNecessaryArguments

      public static boolean hasAllNecessaryArguments(Set<String> sgpArgumentNames, Set<String> entrypointArgumentNames)
      Check if @param sgpArgumentNames contains all argument name from @param entrypointArgumentNames. If @param sgpArgumentNames is empty then returns false.
    • literalToJsonValue

      public static org.apache.jena.atlas.json.JsonValue literalToJsonValue(org.apache.jena.graph.impl.LiteralLabel literal)
      Helper function used to convert a LiteralLabel value to a valid jsonvalue