Class GraphQlSchemaGenerator

java.lang.Object
org.aksw.jenax.graphql.schema.generator.GraphQlSchemaGenerator

public class GraphQlSchemaGenerator extends Object
Limitations:
  • Splitting a type does not preserve its property order. (As properties are moved to a base class)
  • Field Details

    • UNTYPED

      public static final org.apache.jena.graph.Node UNTYPED
      Node for the pseudo-class of untyped instances - i.e. all instances that have to rdf:type property.
    • EMPTY

      public static final org.apache.jena.graph.Node EMPTY
    • TYPE_SCALAR

      public static final graphql.language.Type TYPE_SCALAR
    • shortNameMgr

      protected org.aksw.jenax.arq.util.prefix.ShortNameMgr shortNameMgr
    • datasetMetadata

      protected DatasetMetadata datasetMetadata
    • classMap

      protected Map<org.apache.jena.graph.Node,GraphQlSchemaGenerator.ClassInfo> classMap
    • unionClassToName

      protected Map<Set<org.apache.jena.graph.Node>,org.apache.jena.graph.Node> unionClassToName
    • exclusionTypeMap

      protected Map<GraphQlSchemaGenerator.ExclusionType,org.apache.jena.graph.Node> exclusionTypeMap
    • propertiesToStructuralClass

      protected Map<Set<GraphQlSchemaGenerator.PropertyInfo>,org.apache.jena.graph.Node> propertiesToStructuralClass
      Artificial classes referred to by their properties.
  • Constructor Details

    • GraphQlSchemaGenerator

      public GraphQlSchemaGenerator()
  • Method Details

    • summarize

      public static List<GraphQlSchemaGenerator.TypeInfo> summarize(org.aksw.jenax.dataaccess.sparql.datasource.RDFDataSource dataSource)
    • process

      public graphql.language.Document process(List<GraphQlSchemaGenerator.TypeInfo> list)
    • makeUnionTypeProperty

      protected void makeUnionTypeProperty(GraphQlSchemaGenerator.PropertyInfo pi)
    • init

      protected void init(List<GraphQlSchemaGenerator.TypeInfo> list)
    • registerClass

      protected void registerClass(GraphQlSchemaGenerator.ClassInfo classInfo)
    • toName

      public String toName(org.apache.jena.graph.Node node)
    • sanitize

      public static String sanitize(String name)
    • convert

      protected graphql.language.Document convert()
    • subsumes

      public boolean subsumes(org.apache.jena.graph.Node parent, org.apache.jena.graph.Node child)
    • normalize

      public Set<org.apache.jena.graph.Node> normalize(Set<org.apache.jena.graph.Node> types)
      create a new node set that is free of subsumed types.
    • materialize

      Move all properties of super types directly to this class.
    • convertType

      protected graphql.language.Definition convertType(GraphQlSchemaGenerator.ClassInfo classInfo)
    • toURI

      public static String toURI(org.apache.jena.graph.Node node)
    • convertProperty

      protected graphql.language.FieldDefinition convertProperty(GraphQlSchemaGenerator.PropertyInfo propertyInfo)
    • createUnionType

      protected org.apache.jena.graph.Node createUnionType(Set<org.apache.jena.graph.Node> types)
      Creates a union type for the given types. Thereby conflicting properties are resolved by possibly splitting the involved type definitions into common non-conflicting types. originalType := commonNonConflictingType UNION originalRemainingType resolvedType := commonNonConflictingType UNION newlyIntroducedType
    • getEmptyType

      protected org.apache.jena.graph.Node getEmptyType()
    • getOrCreateUnionType

      protected org.apache.jena.graph.Node getOrCreateUnionType(Set<org.apache.jena.graph.Node> superTypes)
    • getOrCreateStructuralType

      protected org.apache.jena.graph.Node getOrCreateStructuralType(Map<org.apache.jena.graph.Node,GraphQlSchemaGenerator.PropertyInfo> propertyMap)
    • getTypes

      public Stream<org.apache.jena.graph.Node> getTypes(org.apache.jena.graph.Node node)
    • severProperty

      protected org.apache.jena.graph.Node severProperty(org.apache.jena.graph.Node cls, Set<org.apache.jena.graph.Node> exclusions)
      Given a class with property p, create a new class b without p. A then becomes b union p. Returns the new class without the property. This is a transitive operation that traverses all super classes and severs the properties from them. Returns the severed class name.
    • allocateClassName

      protected org.apache.jena.graph.Node allocateClassName()
    • allocateExclusionClassNameFromType

      protected org.apache.jena.graph.Node allocateExclusionClassNameFromType(org.apache.jena.graph.Node baseName, Set<org.apache.jena.graph.Node> exclusionProperties)
      Allocate a name based on the remaining properties.
    • allocateExclusionClassName

      protected org.apache.jena.graph.Node allocateExclusionClassName(org.apache.jena.graph.Node baseName, Set<org.apache.jena.graph.Node> exclusionProperties)
    • allocateExclusionClassNameFromStructure

      protected org.apache.jena.graph.Node allocateExclusionClassNameFromStructure(org.apache.jena.graph.Node baseName, Set<org.apache.jena.graph.Node> exclusionProperties)
    • allocateExclusionClassNameFromStructureOld

      protected org.apache.jena.graph.Node allocateExclusionClassNameFromStructureOld(org.apache.jena.graph.Node baseName, Set<org.apache.jena.graph.Node> exclusionProperties)
      Allocate a name based on the base class name and the set of excluded properties.
    • createPropertyMap

      protected Map<org.apache.jena.graph.Node,GraphQlSchemaGenerator.PropertyInfo> createPropertyMap(org.apache.jena.graph.Node type)
      Collect all properties of the given type and all its super types.
    • normalize

      protected void normalize(Map<org.apache.jena.graph.Node,GraphQlSchemaGenerator.PropertyInfo> propertyMap)
    • normalize

      protected void normalize(GraphQlSchemaGenerator.PropertyInfo pi)
    • createPropertyMap

      protected Map<org.apache.jena.graph.Node,GraphQlSchemaGenerator.PropertyInfo> createPropertyMap(Set<org.apache.jena.graph.Node> types)
      Compute the set of properties and the union of all mentioned types for the given classes.
    • collectPropertyMap

      protected void collectPropertyMap(Set<org.apache.jena.graph.Node> types, Map<org.apache.jena.graph.Node,GraphQlSchemaGenerator.PropertyInfo> result)
    • collectPropertyMap

      protected void collectPropertyMap(org.apache.jena.graph.Node type, Map<org.apache.jena.graph.Node,GraphQlSchemaGenerator.PropertyInfo> result)
    • setDatasetMetadata

      public GraphQlSchemaGenerator setDatasetMetadata(DatasetMetadata datasetMetadata)