Class JSON2SolutionGraphConverterImpl

java.lang.Object
se.liu.ida.hefquin.engine.wrappers.graphql.impl.JSON2SolutionGraphConverterImpl
All Implemented Interfaces:
JSON2SolutionGraphConverter

public class JSON2SolutionGraphConverterImpl extends Object implements JSON2SolutionGraphConverter
An implementation of the JSON2SolutionMappings approach
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final GraphQL2RDFConfiguration
     
    protected final GraphQLSchema
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.apache.jena.rdf.model.Literal
    jsonPrimitiveToLiteral(org.apache.jena.atlas.json.JsonValue primitive, String graphqlTypeName, String graphqlFieldName, org.apache.jena.rdf.model.Model model)
    Utility function used to create a Literal from a json value @param primitive usable by @param model.
    protected org.apache.jena.rdf.model.Resource
    parseJSON(org.apache.jena.atlas.json.JsonObject root, Map<org.apache.jena.atlas.lib.PairOfSameType<String>,org.apache.jena.rdf.model.Resource> blankNodes, org.apache.jena.rdf.model.Model solutionGraph)
    Parses through a JsonObject recursively and expands @param blankNodes and @param solutionGraph.
    org.apache.jena.rdf.model.Model
    translateJSON(org.apache.jena.atlas.json.JsonObject jsonObj)
    Translates a JSON object (obtained as a response to a GraphQL request) into a solution graph (model) containing triples created by parsing the JSON object.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • translateJSON

      public org.apache.jena.rdf.model.Model translateJSON(org.apache.jena.atlas.json.JsonObject jsonObj) throws org.apache.jena.atlas.json.io.parserjavacc.javacc.ParseException, org.apache.jena.atlas.json.JsonException
      Description copied from interface: JSON2SolutionGraphConverter
      Translates a JSON object (obtained as a response to a GraphQL request) into a solution graph (model) containing triples created by parsing the JSON object.
      Specified by:
      translateJSON in interface JSON2SolutionGraphConverter
      Throws:
      org.apache.jena.atlas.json.io.parserjavacc.javacc.ParseException - if the JSON structure for whatever reason isn't valid, thus making it un-parsable.
      org.apache.jena.atlas.json.JsonException
    • parseJSON

      protected org.apache.jena.rdf.model.Resource parseJSON(org.apache.jena.atlas.json.JsonObject root, Map<org.apache.jena.atlas.lib.PairOfSameType<String>,org.apache.jena.rdf.model.Resource> blankNodes, org.apache.jena.rdf.model.Model solutionGraph) throws org.apache.jena.atlas.json.io.parserjavacc.javacc.ParseException, org.apache.jena.atlas.json.JsonException
      Parses through a JsonObject recursively and expands @param blankNodes and @param solutionGraph.
      Returns:
      a Resource in order to create a triple with the parent and the child resource.
      Throws:
      org.apache.jena.atlas.json.io.parserjavacc.javacc.ParseException - if the json object does not contain a valid "id" key.
      org.apache.jena.atlas.json.JsonException
    • jsonPrimitiveToLiteral

      protected org.apache.jena.rdf.model.Literal jsonPrimitiveToLiteral(org.apache.jena.atlas.json.JsonValue primitive, String graphqlTypeName, String graphqlFieldName, org.apache.jena.rdf.model.Model model)
      Utility function used to create a Literal from a json value @param primitive usable by @param model. @param graphqlTypeName and @param graphqlFieldName are used to fetch value type data from the GraphQL endpoint to ensure that the correct XML datatype is used when creating the literal.