From abd548c2a0f0c5b5ceb75e2cf2dba3ccdbeeef15 Mon Sep 17 00:00:00 2001 From: Iddan Aaronsohn Date: Fri, 13 Dec 2019 13:29:13 +0200 Subject: [PATCH] linkedql: Correct type handling in client --- .../generate_linkedql_client.go | 7 +- internal/linkedql/schema/schema.go | 19 +- linkedql.json | 747 ++++++++++-------- owl/owl.go | 2 +- query/linkedql/client/client.go | 12 +- 5 files changed, 457 insertions(+), 330 deletions(-) diff --git a/cmd/generate_linkedql_client/generate_linkedql_client.go b/cmd/generate_linkedql_client/generate_linkedql_client.go index b0caac6cc..59079bc18 100644 --- a/cmd/generate_linkedql_client/generate_linkedql_client.go +++ b/cmd/generate_linkedql_client/generate_linkedql_client.go @@ -23,7 +23,9 @@ import ( const schemaFile = "linkedql.json" const outputFilePath = "query/linkedql/client/client.go" +var stepIRI = quad.IRI("http://cayley.io/linkedql#Step") var pathStepIRI = quad.IRI("http://cayley.io/linkedql#PathStep") +var iteratorStepIRI = quad.IRI("http://cayley.io/linkedql#IteratorStep") func main() { ctx := context.TODO() @@ -33,7 +35,7 @@ func main() { panic(err) } - stepClass, err := owl.GetClass(ctx, qs, pathStepIRI) + stepClass, err := owl.GetClass(ctx, qs, stepIRI) if err != nil { panic(err) @@ -43,6 +45,9 @@ func main() { var decls []ast.Decl for _, stepSubClass := range stepSubClasses { + if stepSubClass.Identifier == pathStepIRI || stepSubClass.Identifier == iteratorStepIRI { + continue + } stepSubClassDecls, err := stepSubClassToDecls(stepSubClass) if err != nil { panic(err) diff --git a/internal/linkedql/schema/schema.go b/internal/linkedql/schema/schema.go index b7868ebe1..c12e9c0a6 100644 --- a/internal/linkedql/schema/schema.go +++ b/internal/linkedql/schema/schema.go @@ -250,6 +250,23 @@ func (g *generator) Generate() []byte { Range: rng, }) } + graph := []interface{}{ + map[string]string{ + "@id": "linkedql:Step", + "@type": "owl:Class", + }, + map[string]interface{}{ + "@id": "linkedql:PathStep", + "@type": "owl:Class", + "rdfs:subClassOf": map[string]string{"@id": "linkedql:Step"}, + }, + map[string]interface{}{ + "@id": "linkedql:IteratorStep", + "@type": "owl:Class", + "rdfs:subClassOf": map[string]string{"@id": "linkedql:Step"}, + }, + } + graph = append(graph, g.out...) data, err := json.Marshal(map[string]interface{}{ "@context": map[string]interface{}{ "rdf": map[string]string{"@id": "http://www.w3.org/1999/02/22-rdf-syntax-ns#"}, @@ -258,7 +275,7 @@ func (g *generator) Generate() []byte { "xsd": map[string]string{"@id": "http://www.w3.org/2001/XMLSchema#"}, "linkedql": map[string]string{"@id": "http://cayley.io/linkedql#"}, }, - "@graph": g.out, + "@graph": graph, }) if err != nil { panic(err) diff --git a/linkedql.json b/linkedql.json index db07f5113..74a4cd838 100644 --- a/linkedql.json +++ b/linkedql.json @@ -18,41 +18,57 @@ }, "@graph": [ { - "@id": "linkedql:Back", + "@id": "linkedql:Step", + "@type": "owl:Class" + }, + { + "@id": "linkedql:PathStep", + "@type": "owl:Class", + "rdfs:subClassOf": { + "@id": "linkedql:Step" + } + }, + { + "@id": "linkedql:IteratorStep", + "@type": "owl:Class", + "rdfs:subClassOf": { + "@id": "linkedql:Step" + } + }, + { + "@id": "linkedql:Is", "@type": "rdfs:Class", - "rdfs:comment": "resolves to the values of the previous the step or the values assigned to name in a former step.", + "rdfs:comment": "resolves to all the values resolved by the from step which are included in provided values.", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" }, { - "@id": "_:n7908088290697276681", - "@type": "owl:Restriction", - "owl:cardinality": 1, - "owl:onProperty": { - "@id": "linkedql:from" - } + "@id": "linkedql:IteratorStep" }, { - "@id": "_:n5997096025876839690", + "@id": "_:n3613043289672097141", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { - "@id": "linkedql:name" + "@id": "linkedql:from" } } ] }, { - "@id": "linkedql:As", + "@id": "linkedql:FollowReverse", "@type": "rdfs:Class", - "rdfs:comment": "assigns the resolved values of the from step to a given name. The name can be used with the Select and Documents steps to retreive the values or to return to the values in further steps with the Back step. It resolves to the values of the from step.", + "rdfs:comment": "is the same as follow but follows the chain in the reverse direction. Flips View and ViewReverse where appropriate, the net result being a virtual predicate followed in the reverse direction. Starts at the end of the morphism and follows it backwards (with appropriate flipped directions) to the g.M() location.", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" }, { - "@id": "_:n7988485489972284209", + "@id": "linkedql:IteratorStep" + }, + { + "@id": "_:n9083091194127967913", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { @@ -60,105 +76,114 @@ } }, { - "@id": "_:n7567688478636418594", + "@id": "_:n8063055307955585418", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { - "@id": "linkedql:name" + "@id": "linkedql:followed" } } ] }, { - "@id": "linkedql:Vertex", + "@id": "linkedql:Labels", "@type": "rdfs:Class", - "rdfs:comment": "resolves to all the existing objects and primitive values in the graph. If provided with values resolves to a sublist of all the existing values in the graph.", + "rdfs:comment": "gets the list of inbound and outbound quad labels", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" + }, + { + "@id": "linkedql:IteratorStep" + }, + { + "@id": "_:n8459855700265692209", + "@type": "owl:Restriction", + "owl:cardinality": 1, + "owl:onProperty": { + "@id": "linkedql:from" + } } ] }, { - "@id": "linkedql:ReversePropertyNamesAs", + "@id": "linkedql:Unique", "@type": "rdfs:Class", - "rdfs:comment": "tags the list of predicates that are pointing in to a node.", + "rdfs:comment": "removes duplicate values from the path.", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" }, { - "@id": "_:n8383648757660417451", - "@type": "owl:Restriction", - "owl:cardinality": 1, - "owl:onProperty": { - "@id": "linkedql:from" - } + "@id": "linkedql:IteratorStep" }, { - "@id": "_:n6926458250230044772", + "@id": "_:n2710973548941612352", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { - "@id": "linkedql:tag" + "@id": "linkedql:from" } } ] }, { - "@id": "linkedql:Value", + "@id": "linkedql:Vertex", "@type": "rdfs:Class", - "rdfs:comment": "Value returns a single value matched in the query", + "rdfs:comment": "resolves to all the existing objects and primitive values in the graph. If provided with values resolves to a sublist of all the existing values in the graph.", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" }, { - "@id": "_:n1841094452838461572", - "@type": "owl:Restriction", - "owl:cardinality": 1, - "owl:onProperty": { - "@id": "linkedql:from" - } + "@id": "linkedql:IteratorStep" } ] }, { - "@id": "linkedql:Follow", + "@id": "linkedql:Placeholder", "@type": "rdfs:Class", - "rdfs:comment": "is the way to use a path prepared with Morphism. Applies the path chain on the morphism object to the current path. Starts as if at the g.M() and follows through the morphism path.", + "rdfs:comment": "is like Vertex but resolves to the values in the context it is placed in. It should only be used where a PathStep is expected and can't be resolved on its own.", + "rdfs:subClassOf": [ + { + "@id": "linkedql:PathStep" + } + ] + }, + { + "@id": "linkedql:Count", + "@type": "rdfs:Class", + "rdfs:comment": "resolves to the number of the resolved values of the from step", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" }, { - "@id": "_:n2005093628341939828", - "@type": "owl:Restriction", - "owl:cardinality": 1, - "owl:onProperty": { - "@id": "linkedql:from" - } + "@id": "linkedql:IteratorStep" }, { - "@id": "_:n5104241301475361160", + "@id": "_:n3236938820904012665", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { - "@id": "linkedql:followed" + "@id": "linkedql:from" } } ] }, { - "@id": "linkedql:FollowReverse", + "@id": "linkedql:Skip", "@type": "rdfs:Class", - "rdfs:comment": "is the same as follow but follows the chain in the reverse direction. Flips View and ViewReverse where appropriate, the net result being a virtual predicate followed in the reverse direction. Starts at the end of the morphism and follows it backwards (with appropriate flipped directions) to the g.M() location.", + "rdfs:comment": "skips a number of nodes for current path.", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" }, { - "@id": "_:n4584588397207050072", + "@id": "linkedql:IteratorStep" + }, + { + "@id": "_:n8331721404640161545", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { @@ -166,25 +191,28 @@ } }, { - "@id": "_:n4166975175965651772", + "@id": "_:n5928433611785803765", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { - "@id": "linkedql:followed" + "@id": "linkedql:offset" } } ] }, { - "@id": "linkedql:In", + "@id": "linkedql:Back", "@type": "rdfs:Class", - "rdfs:comment": "aliases for ViewReverse", + "rdfs:comment": "resolves to the values of the previous the step or the values assigned to name in a former step.", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" }, { - "@id": "_:n1870897588368680998", + "@id": "linkedql:IteratorStep" + }, + { + "@id": "_:n7318884210772532587", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { @@ -192,25 +220,28 @@ } }, { - "@id": "_:n3607726901418144227", + "@id": "_:n5159571487667235037", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { - "@id": "linkedql:properties" + "@id": "linkedql:name" } } ] }, { - "@id": "linkedql:ReversePropertyNames", + "@id": "linkedql:Properties", "@type": "rdfs:Class", - "rdfs:comment": "gets the list of predicates that are pointing in to a node.", + "rdfs:comment": "adds tags for all properties of the current entity", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" }, { - "@id": "_:n3903726778461453772", + "@id": "linkedql:IteratorStep" + }, + { + "@id": "_:n9018236344034770769", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { @@ -220,15 +251,18 @@ ] }, { - "@id": "linkedql:Labels", + "@id": "linkedql:PropertyNames", "@type": "rdfs:Class", - "rdfs:comment": "gets the list of inbound and outbound quad labels", + "rdfs:comment": "gets the list of predicates that are pointing out from a node.", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" }, { - "@id": "_:n2891927322902708841", + "@id": "linkedql:IteratorStep" + }, + { + "@id": "_:n4445626993086337411", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { @@ -238,20 +272,31 @@ ] }, { - "@id": "linkedql:Properties", + "@id": "linkedql:ReversePropertyNamesAs", "@type": "rdfs:Class", - "rdfs:comment": "adds tags for all properties of the current entity", + "rdfs:comment": "tags the list of predicates that are pointing in to a node.", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" }, { - "@id": "_:n6424233792414955944", + "@id": "linkedql:IteratorStep" + }, + { + "@id": "_:n8112324779916985026", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { "@id": "linkedql:from" } + }, + { + "@id": "_:n5338493051676230997", + "@type": "owl:Restriction", + "owl:cardinality": 1, + "owl:onProperty": { + "@id": "linkedql:tag" + } } ] }, @@ -264,7 +309,10 @@ "@id": "linkedql:PathStep" }, { - "@id": "_:n4418208634829485365", + "@id": "linkedql:IteratorStep" + }, + { + "@id": "_:n5768812609992315503", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { @@ -272,7 +320,7 @@ } }, { - "@id": "_:n201410601521517206", + "@id": "_:n8287472848602919900", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { @@ -282,15 +330,18 @@ ] }, { - "@id": "linkedql:Difference", + "@id": "linkedql:ReverseProperties", "@type": "rdfs:Class", - "rdfs:comment": "resolves to all the values resolved by the from step different then the values resolved by the provided steps. Caution: it might be slow to execute.", + "rdfs:comment": "gets all the properties the current entity / value is referenced at", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" }, { - "@id": "_:n3223642664820787682", + "@id": "linkedql:IteratorStep" + }, + { + "@id": "_:n443301574217807823", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { @@ -300,27 +351,37 @@ ] }, { - "@id": "linkedql:Has", + "@id": "linkedql:Select", "@type": "rdfs:Class", - "rdfs:comment": "filters all paths which are, at this point, on the subject for the given predicate and object, but do not follow the path, merely filter the possible paths. Usually useful for starting with all nodes, or limiting to a subset depending on some predicate/value pair.", + "rdfs:comment": "Select returns flat records of tags matched in the query", "rdfs:subClassOf": [ { - "@id": "linkedql:PathStep" + "@id": "linkedql:IteratorStep" }, { - "@id": "_:n2349392202041882821", + "@id": "_:n8116377088366467444", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { "@id": "linkedql:from" } + } + ] + }, + { + "@id": "linkedql:Value", + "@type": "rdfs:Class", + "rdfs:comment": "Value returns a single value matched in the query", + "rdfs:subClassOf": [ + { + "@id": "linkedql:IteratorStep" }, { - "@id": "_:n13257026593940279", + "@id": "_:n1211474119861900589", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { - "@id": "linkedql:property" + "@id": "linkedql:from" } } ] @@ -334,7 +395,10 @@ "@id": "linkedql:PathStep" }, { - "@id": "_:n9128900241535060479", + "@id": "linkedql:IteratorStep" + }, + { + "@id": "_:n793190407192836422", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { @@ -342,7 +406,7 @@ } }, { - "@id": "_:n2741547127402511673", + "@id": "_:n7208921910592501003", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { @@ -352,15 +416,18 @@ ] }, { - "@id": "linkedql:ViewBoth", + "@id": "linkedql:In", "@type": "rdfs:Class", - "rdfs:comment": "is like View but resolves to both the object values and references to the values of the given properties in via. It is the equivalent for the Union of View and ViewReverse of the same property.", + "rdfs:comment": "aliases for ViewReverse", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" }, { - "@id": "_:n8502434772150270123", + "@id": "linkedql:IteratorStep" + }, + { + "@id": "_:n8239793418546475073", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { @@ -368,7 +435,7 @@ } }, { - "@id": "_:n5585646283882161042", + "@id": "_:n4982870279148793564", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { @@ -378,15 +445,18 @@ ] }, { - "@id": "linkedql:Is", + "@id": "linkedql:Order", "@type": "rdfs:Class", - "rdfs:comment": "resolves to all the values resolved by the from step which are included in provided values.", + "rdfs:comment": "sorts the results in ascending order according to the current entity / value", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" }, { - "@id": "_:n3090803183809953074", + "@id": "linkedql:IteratorStep" + }, + { + "@id": "_:n4658869256845579334", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { @@ -396,15 +466,39 @@ ] }, { - "@id": "linkedql:Limit", + "@id": "linkedql:ReversePropertyNames", "@type": "rdfs:Class", - "rdfs:comment": "limits a number of nodes for current path.", + "rdfs:comment": "gets the list of predicates that are pointing in to a node.", + "rdfs:subClassOf": [ + { + "@id": "linkedql:PathStep" + }, + { + "@id": "linkedql:IteratorStep" + }, + { + "@id": "_:n2234785206717184905", + "@type": "owl:Restriction", + "owl:cardinality": 1, + "owl:onProperty": { + "@id": "linkedql:from" + } + } + ] + }, + { + "@id": "linkedql:ViewBoth", + "@type": "rdfs:Class", + "rdfs:comment": "is like View but resolves to both the object values and references to the values of the given properties in via. It is the equivalent for the Union of View and ViewReverse of the same property.", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" }, { - "@id": "_:n853618359657221356", + "@id": "linkedql:IteratorStep" + }, + { + "@id": "_:n1375394481257745149", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { @@ -412,25 +506,28 @@ } }, { - "@id": "_:n3741714749040882736", + "@id": "_:n8456254640763031822", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { - "@id": "linkedql:limit" + "@id": "linkedql:properties" } } ] }, { - "@id": "linkedql:ReverseProperties", + "@id": "linkedql:Difference", "@type": "rdfs:Class", - "rdfs:comment": "gets all the properties the current entity / value is referenced at", + "rdfs:comment": "resolves to all the values resolved by the from step different then the values resolved by the provided steps. Caution: it might be slow to execute.", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" }, { - "@id": "_:n4533390537095304805", + "@id": "linkedql:IteratorStep" + }, + { + "@id": "_:n3325168672420575460", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { @@ -440,15 +537,15 @@ ] }, { - "@id": "linkedql:Select", + "@id": "linkedql:SelectFirst", "@type": "rdfs:Class", - "rdfs:comment": "Select returns flat records of tags matched in the query", + "rdfs:comment": "Like Select but only returns the first result", "rdfs:subClassOf": [ { - "@id": "linkedql:PathStep" + "@id": "linkedql:IteratorStep" }, { - "@id": "_:n9181657233381629788", + "@id": "_:n3390240884242909143", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { @@ -458,15 +555,18 @@ ] }, { - "@id": "linkedql:View", + "@id": "linkedql:As", "@type": "rdfs:Class", - "rdfs:comment": "resolves to the values of the given property or properties in via of the current objects. If via is a path it's resolved values will be used as properties.", + "rdfs:comment": "assigns the resolved values of the from step to a given name. The name can be used with the Select and Documents steps to retrieve the values or to return to the values in further steps with the Back step. It resolves to the values of the from step.", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" }, { - "@id": "_:n5824746053480877069", + "@id": "linkedql:IteratorStep" + }, + { + "@id": "_:n2526633157694802657", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { @@ -474,25 +574,28 @@ } }, { - "@id": "_:n6461519520038761833", + "@id": "_:n3429357401325124988", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { - "@id": "linkedql:properties" + "@id": "linkedql:name" } } ] }, { - "@id": "linkedql:Out", + "@id": "linkedql:Filter", "@type": "rdfs:Class", - "rdfs:comment": "aliases for View", + "rdfs:comment": "applies constraints to a set of nodes. Can be used to filter values by range or match strings.", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" }, { - "@id": "_:n8047248095020601737", + "@id": "linkedql:IteratorStep" + }, + { + "@id": "_:n4690243504327224094", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { @@ -500,53 +603,57 @@ } }, { - "@id": "_:n5222948747445626408", + "@id": "_:n739931276592480213", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { - "@id": "linkedql:properties" + "@id": "linkedql:filter" } } ] }, { - "@id": "linkedql:Placeholder", + "@id": "linkedql:Has", "@type": "rdfs:Class", - "rdfs:comment": "is like Vertex but resolves to the values in the context it is placed in. It should only be used where a PathStep is expected and can't be resolved on its own.", + "rdfs:comment": "filters all paths which are, at this point, on the subject for the given predicate and object, but do not follow the path, merely filter the possible paths. Usually useful for starting with all nodes, or limiting to a subset depending on some predicate/value pair.", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" - } - ] - }, - { - "@id": "linkedql:Count", - "@type": "rdfs:Class", - "rdfs:comment": "resolves to the number of the resolved values of the from step", - "rdfs:subClassOf": [ + }, { - "@id": "linkedql:PathStep" + "@id": "linkedql:IteratorStep" }, { - "@id": "_:n8390472748902891963", + "@id": "_:n4325294036727421714", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { "@id": "linkedql:from" } + }, + { + "@id": "_:n632449057788695932", + "@type": "owl:Restriction", + "owl:cardinality": 1, + "owl:onProperty": { + "@id": "linkedql:property" + } } ] }, { - "@id": "linkedql:Filter", + "@id": "linkedql:ViewReverse", "@type": "rdfs:Class", - "rdfs:comment": "applies constraints to a set of nodes. Can be used to filter values by range or match strings.", + "rdfs:comment": "is the inverse of View. Starting with the nodes in `path` on the object, follow the quads with predicates defined by `predicatePath` to their subjects.", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" }, { - "@id": "_:n1646447114406524394", + "@id": "linkedql:IteratorStep" + }, + { + "@id": "_:n1202338489403740068", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { @@ -554,25 +661,28 @@ } }, { - "@id": "_:n8967834957155453826", + "@id": "_:n8462290765396416742", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { - "@id": "linkedql:filter" + "@id": "linkedql:properties" } } ] }, { - "@id": "linkedql:Skip", + "@id": "linkedql:Limit", "@type": "rdfs:Class", - "rdfs:comment": "skips a number of nodes for current path.", + "rdfs:comment": "limits a number of nodes for current path.", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" }, { - "@id": "_:n4098750636493779506", + "@id": "linkedql:IteratorStep" + }, + { + "@id": "_:n8154336094443820555", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { @@ -580,11 +690,11 @@ } }, { - "@id": "_:n1621454338437066833", + "@id": "_:n1095931710072978339", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { - "@id": "linkedql:offset" + "@id": "linkedql:limit" } } ] @@ -598,7 +708,10 @@ "@id": "linkedql:PathStep" }, { - "@id": "_:n1227112490286966331", + "@id": "linkedql:IteratorStep" + }, + { + "@id": "_:n7940960461887459839", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { @@ -608,69 +721,47 @@ ] }, { - "@id": "linkedql:Unique", + "@id": "linkedql:View", "@type": "rdfs:Class", - "rdfs:comment": "removes duplicate values from the path.", + "rdfs:comment": "resolves to the values of the given property or properties in via of the current objects. If via is a path it's resolved values will be used as properties.", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" }, { - "@id": "_:n6547757674992010008", - "@type": "owl:Restriction", - "owl:cardinality": 1, - "owl:onProperty": { - "@id": "linkedql:from" - } - } - ] - }, - { - "@id": "linkedql:Order", - "@type": "rdfs:Class", - "rdfs:comment": "sorts the results in ascending order according to the current entity / value", - "rdfs:subClassOf": [ - { - "@id": "linkedql:PathStep" + "@id": "linkedql:IteratorStep" }, { - "@id": "_:n4036254078241711198", + "@id": "_:n6177289074236883404", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { "@id": "linkedql:from" } - } - ] - }, - { - "@id": "linkedql:SelectFirst", - "@type": "rdfs:Class", - "rdfs:comment": "Like Select but only returns the first result", - "rdfs:subClassOf": [ - { - "@id": "linkedql:PathStep" }, { - "@id": "_:n1197969629924875303", + "@id": "_:n4127567549237631394", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { - "@id": "linkedql:from" + "@id": "linkedql:properties" } } ] }, { - "@id": "linkedql:ViewReverse", + "@id": "linkedql:Out", "@type": "rdfs:Class", - "rdfs:comment": "is the inverse of View. Starting with the nodes in `path` on the object, follow the quads with predicates defined by `predicatePath` to their subjects.", + "rdfs:comment": "aliases for View", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" }, { - "@id": "_:n6251537544036519808", + "@id": "linkedql:IteratorStep" + }, + { + "@id": "_:n301236345131105742", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { @@ -678,7 +769,7 @@ } }, { - "@id": "_:n1051213466635448344", + "@id": "_:n8700954704201023894", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { @@ -688,15 +779,18 @@ ] }, { - "@id": "linkedql:PropertyNames", + "@id": "linkedql:Intersect", "@type": "rdfs:Class", - "rdfs:comment": "gets the list of predicates that are pointing out from a node.", + "rdfs:comment": "resolves to all the same values resolved by the from step and the provided steps.", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" }, { - "@id": "_:n3269172395352052471", + "@id": "linkedql:IteratorStep" + }, + { + "@id": "_:n6461582695449891350", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { @@ -706,20 +800,31 @@ ] }, { - "@id": "linkedql:Intersect", + "@id": "linkedql:Follow", "@type": "rdfs:Class", - "rdfs:comment": "resolves to all the same values resolved by the from step and the provided steps.", + "rdfs:comment": "is the way to use a path prepared with Morphism. Applies the path chain on the morphism object to the current path. Starts as if at the g.M() and follows through the morphism path.", "rdfs:subClassOf": [ { "@id": "linkedql:PathStep" }, { - "@id": "_:n2823818453963121638", + "@id": "linkedql:IteratorStep" + }, + { + "@id": "_:n3939936992220835105", "@type": "owl:Restriction", "owl:cardinality": 1, "owl:onProperty": { "@id": "linkedql:from" } + }, + { + "@id": "_:n8565384274678116400", + "@type": "owl:Restriction", + "owl:cardinality": 1, + "owl:onProperty": { + "@id": "linkedql:followed" + } } ] }, @@ -727,19 +832,19 @@ "@id": "linkedql:values", "@type": "owl:ObjectProperty", "rdfs:domain": { - "@id": "_:n161473765488462789", + "@id": "_:n3487211217454711567", "@type": "owl:Class", "owl:unionOf": { "@list": [ - { - "@id": "linkedql:HasReverse" - }, { "@id": "linkedql:Is" }, { "@id": "linkedql:Vertex" }, + { + "@id": "linkedql:HasReverse" + }, { "@id": "linkedql:Has" } @@ -750,11 +855,19 @@ "@id": "rdfs:Resource" } }, + { + "@id": "linkedql:offset", + "@type": "owl:DatatypeProperty", + "rdfs:domain": "linkedql:Skip", + "rdfs:range": { + "@id": "xsd:int" + } + }, { "@id": "linkedql:tag", "@type": "owl:DatatypeProperty", "rdfs:domain": { - "@id": "_:n8920519548104281153", + "@id": "_:n6718853691878301872", "@type": "owl:Class", "owl:unionOf": { "@list": [ @@ -772,69 +885,166 @@ } }, { - "@id": "linkedql:properties", + "@id": "linkedql:tags", "@type": "owl:ObjectProperty", "rdfs:domain": { - "@id": "_:n3206185309683448698", + "@id": "_:n2724656406774357364", "@type": "owl:Class", "owl:unionOf": { "@list": [ { - "@id": "linkedql:ViewReverse" - }, - { - "@id": "linkedql:In" - }, - { - "@id": "linkedql:ViewBoth" - }, - { - "@id": "linkedql:View" + "@id": "linkedql:Select" }, { - "@id": "linkedql:Out" + "@id": "linkedql:SelectFirst" } ] } }, "rdfs:range": { - "@id": "linkedql:PathStep" + "@id": "xsd:string" } }, { - "@id": "linkedql:names", + "@id": "linkedql:steps", "@type": "owl:ObjectProperty", "rdfs:domain": { - "@id": "_:n8548896802306168646", + "@id": "_:n7733331238921588911", "@type": "owl:Class", "owl:unionOf": { "@list": [ { - "@id": "linkedql:Properties" + "@id": "linkedql:Difference" }, { - "@id": "linkedql:ReverseProperties" + "@id": "linkedql:Union" + }, + { + "@id": "linkedql:Intersect" } ] } }, "rdfs:range": { - "@id": "xsd:string" + "@id": "linkedql:PathStep" } }, { - "@id": "linkedql:property", + "@id": "linkedql:filter", + "@type": "owl:ObjectProperty", + "rdfs:domain": "linkedql:Filter", + "rdfs:range": { + "@id": "linkedql:Operator" + } + }, + { + "@id": "linkedql:limit", + "@type": "owl:DatatypeProperty", + "rdfs:domain": "linkedql:Limit", + "rdfs:range": { + "@id": "xsd:int" + } + }, + { + "@id": "linkedql:from", "@type": "owl:ObjectProperty", "rdfs:domain": { - "@id": "_:n551031445573634888", + "@id": "_:n6836387890704961384", "@type": "owl:Class", "owl:unionOf": { "@list": [ { - "@id": "linkedql:Has" + "@id": "linkedql:ReversePropertyNamesAs" + }, + { + "@id": "linkedql:Value" }, { "@id": "linkedql:HasReverse" + }, + { + "@id": "linkedql:Has" + }, + { + "@id": "linkedql:View" + }, + { + "@id": "linkedql:Unique" + }, + { + "@id": "linkedql:Count" + }, + { + "@id": "linkedql:Properties" + }, + { + "@id": "linkedql:ReverseProperties" + }, + { + "@id": "linkedql:ReversePropertyNames" + }, + { + "@id": "linkedql:Filter" + }, + { + "@id": "linkedql:ViewReverse" + }, + { + "@id": "linkedql:In" + }, + { + "@id": "linkedql:Difference" + }, + { + "@id": "linkedql:Out" + }, + { + "@id": "linkedql:FollowReverse" + }, + { + "@id": "linkedql:Labels" + }, + { + "@id": "linkedql:PropertyNames" + }, + { + "@id": "linkedql:Order" + }, + { + "@id": "linkedql:As" + }, + { + "@id": "linkedql:Union" + }, + { + "@id": "linkedql:Back" + }, + { + "@id": "linkedql:PropertyNamesAs" + }, + { + "@id": "linkedql:Intersect" + }, + { + "@id": "linkedql:Is" + }, + { + "@id": "linkedql:Skip" + }, + { + "@id": "linkedql:Select" + }, + { + "@id": "linkedql:ViewBoth" + }, + { + "@id": "linkedql:SelectFirst" + }, + { + "@id": "linkedql:Limit" + }, + { + "@id": "linkedql:Follow" } ] } @@ -844,39 +1054,31 @@ } }, { - "@id": "linkedql:tags", + "@id": "linkedql:followed", "@type": "owl:ObjectProperty", "rdfs:domain": { - "@id": "_:n4101380889439320733", + "@id": "_:n1351742506042781062", "@type": "owl:Class", "owl:unionOf": { "@list": [ { - "@id": "linkedql:SelectFirst" + "@id": "linkedql:FollowReverse" }, { - "@id": "linkedql:Select" + "@id": "linkedql:Follow" } ] } }, "rdfs:range": { - "@id": "xsd:string" - } - }, - { - "@id": "linkedql:filter", - "@type": "owl:ObjectProperty", - "rdfs:domain": "linkedql:Filter", - "rdfs:range": { - "@id": "linkedql:Operator" + "@id": "linkedql:PathStep" } }, { "@id": "linkedql:name", "@type": "owl:DatatypeProperty", "rdfs:domain": { - "@id": "_:n4255376591434887535", + "@id": "_:n7858581684545641474", "@type": "owl:Class", "owl:unionOf": { "@list": [ @@ -894,42 +1096,39 @@ } }, { - "@id": "linkedql:followed", + "@id": "linkedql:names", "@type": "owl:ObjectProperty", "rdfs:domain": { - "@id": "_:n5693611581576660543", + "@id": "_:n9117289071709940667", "@type": "owl:Class", "owl:unionOf": { "@list": [ { - "@id": "linkedql:Follow" + "@id": "linkedql:Properties" }, { - "@id": "linkedql:FollowReverse" + "@id": "linkedql:ReverseProperties" } ] } }, "rdfs:range": { - "@id": "linkedql:PathStep" + "@id": "xsd:string" } }, { - "@id": "linkedql:steps", + "@id": "linkedql:property", "@type": "owl:ObjectProperty", "rdfs:domain": { - "@id": "_:n4411805662897003741", + "@id": "_:n722017989461747795", "@type": "owl:Class", "owl:unionOf": { "@list": [ { - "@id": "linkedql:Difference" - }, - { - "@id": "linkedql:Union" + "@id": "linkedql:HasReverse" }, { - "@id": "linkedql:Intersect" + "@id": "linkedql:Has" } ] } @@ -939,118 +1138,24 @@ } }, { - "@id": "linkedql:limit", - "@type": "owl:DatatypeProperty", - "rdfs:domain": "linkedql:Limit", - "rdfs:range": { - "@id": "xsd:int" - } - }, - { - "@id": "linkedql:offset", - "@type": "owl:DatatypeProperty", - "rdfs:domain": "linkedql:Skip", - "rdfs:range": { - "@id": "xsd:int" - } - }, - { - "@id": "linkedql:from", + "@id": "linkedql:properties", "@type": "owl:ObjectProperty", "rdfs:domain": { - "@id": "_:n7112012358991747784", + "@id": "_:n5924667912709065573", "@type": "owl:Class", "owl:unionOf": { "@list": [ - { - "@id": "linkedql:ReversePropertyNames" - }, - { - "@id": "linkedql:Has" - }, - { - "@id": "linkedql:Count" - }, - { - "@id": "linkedql:Filter" - }, - { - "@id": "linkedql:ViewReverse" - }, - { - "@id": "linkedql:Follow" - }, - { - "@id": "linkedql:HasReverse" - }, - { - "@id": "linkedql:Is" - }, - { - "@id": "linkedql:ReverseProperties" - }, - { - "@id": "linkedql:Select" - }, - { - "@id": "linkedql:View" - }, - { - "@id": "linkedql:Unique" - }, - { - "@id": "linkedql:As" - }, { "@id": "linkedql:In" }, - { - "@id": "linkedql:Limit" - }, - { - "@id": "linkedql:PropertyNames" - }, - { - "@id": "linkedql:Back" - }, - { - "@id": "linkedql:ReversePropertyNamesAs" - }, - { - "@id": "linkedql:Order" - }, - { - "@id": "linkedql:Value" - }, - { - "@id": "linkedql:PropertyNamesAs" - }, - { - "@id": "linkedql:Difference" - }, { "@id": "linkedql:ViewBoth" }, { - "@id": "linkedql:Skip" - }, - { - "@id": "linkedql:SelectFirst" - }, - { - "@id": "linkedql:Union" - }, - { - "@id": "linkedql:Intersect" - }, - { - "@id": "linkedql:Labels" - }, - { - "@id": "linkedql:FollowReverse" + "@id": "linkedql:ViewReverse" }, { - "@id": "linkedql:Properties" + "@id": "linkedql:View" }, { "@id": "linkedql:Out" diff --git a/owl/owl.go b/owl/owl.go index ec2a25367..d9eaf6e0f 100644 --- a/owl/owl.go +++ b/owl/owl.go @@ -165,7 +165,7 @@ var subClassOf = quad.IRI(rdfs.SubClassOf).Full() // SubClasses returns all the classes defined as sub classes of the class func (c *Class) SubClasses() []*Class { - p := c.path().In(subClassOf) + p := c.path().FollowRecursive(path.StartMorphism().In(subClassOf), 0, nil) it := p.BuildIterator(c.ctx).Iterate() var subClasses []*Class for it.Next(c.ctx) { diff --git a/query/linkedql/client/client.go b/query/linkedql/client/client.go index 70a68244b..c491eef72 100644 --- a/query/linkedql/client/client.go +++ b/query/linkedql/client/client.go @@ -6,7 +6,7 @@ import ( type Path map[string]interface{} -// As assigns the resolved values of the from step to a given name. The name can be used with the Select and Documents steps to retreive the values or to return to the values in further steps with the Back step. It resolves to the values of the from step. +// As assigns the resolved values of the from step to a given name. The name can be used with the Select and Documents steps to retrieve the values or to return to the values in further steps with the Back step. It resolves to the values of the from step. func (p Path) As(name string) Path { return Path{"@type": "http://cayley.io/linkedql#As", "from": p, "http://cayley.io/linkedql#name": name} } @@ -86,11 +86,6 @@ func (p Path) Out(properties Path) Path { return Path{"@type": "http://cayley.io/linkedql#Out", "from": p, "http://cayley.io/linkedql#properties": properties} } -// Placeholder is like Vertex but resolves to the values in the context it is placed in. It should only be used where a PathStep is expected and can't be resolved on its own. -func Placeholder() Path { - return Path{"@type": "http://cayley.io/linkedql#Placeholder"} -} - // Properties adds tags for all properties of the current entity func (p Path) Properties(names []string) Path { return Path{"@type": "http://cayley.io/linkedql#Properties", "from": p, "http://cayley.io/linkedql#names": names} @@ -170,3 +165,8 @@ func (p Path) ViewBoth(properties Path) Path { func (p Path) ViewReverse(properties Path) Path { return Path{"@type": "http://cayley.io/linkedql#ViewReverse", "from": p, "http://cayley.io/linkedql#properties": properties} } + +// Placeholder is like Vertex but resolves to the values in the context it is placed in. It should only be used where a PathStep is expected and can't be resolved on its own. +func Placeholder() Path { + return Path{"@type": "http://cayley.io/linkedql#Placeholder"} +}