-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCannedConceptUtils.js
94 lines (79 loc) · 3.03 KB
/
CannedConceptUtils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
var rdf = require('../vocab/rdf');
var owl = require('../vocab/owl');
var Triple = require('../rdf/Triple');
var ElementTriplesBlock = require('../sparql/element/ElementTriplesBlock');
var ElementFilter = require('../sparql/element/ElementFilter');
var ElementGroup = require('../sparql/element/ElementGroup');
var E_LogicalOr = require('../sparql/expr/E_LogicalOr');
var E_Equals = require('../sparql/expr/E_Equals');
var ExprVar = require('../sparql/expr/ExprVar');
var Concept = require('../sparql/Concept');
var NodeValueUtils = require('../sparql/NodeValueUtils');
var VarUtils = require('../sparql/VarUtils');
var CannedConceptUtils = {
/**
* Parser.parseGraphPattern(
* {
* ?s a ?o .
* Filter(?o = rdf:Property || ?o = owl:DatatypeProperty || ?o = owl:ObjectProperty || ?o = owl:AnnotationProperty)
* # Alternative:
* Filter(?o In (rdf:Property, owl:DatatypeProperty, owl:ObjectProperty, owl:AnnotationProperty))
* }
*
*/
createConceptDeclaredProperties: function(s, o) {
s = s || VarUtils.s;
o = o || VarUtils.o;
var eo = new ExprVar(o);
var rdfProperty = NodeValueUtils.makeNode(rdf.Property);
var owlDatatypeProperty = NodeValueUtils.makeNode(owl.DatatypeProperty);
var owlObjectProperty = NodeValueUtils.makeNode(owl.ObjectProperty);
var owlAnnotationProperty = NodeValueUtils.makeNode(owl.AnnotationProperty);
var result = new Concept(
new ElementGroup([
new ElementTriplesBlock([new Triple(s, rdf.type, o)]),
new ElementFilter(
new E_LogicalOr(
new E_Equals(eo, rdfProperty),
new E_LogicalOr(
new E_Equals(eo, owlDatatypeProperty),
new E_LogicalOr(
new E_Equals(eo, owlObjectProperty),
new E_Equals(eo, owlAnnotationProperty)
)
)
)
)
]),
s);
return result;
}
// TODO We need to integrate the rdfstore js parser, so we can do Concept.parse();
// createConceptDeclaredProperties: function() {
//
// var types = [rdf.Property, owl.AnnotationProperty, owl.DatatypeProperty, owl.ObjectProperty];
//
// var o = VarUtils.o;
// var exprVar = new ExprVar(o);
// var typeExprs = _(types).map(function(node) {
// var nodeValue = NodeValue.makeNode(node);
// var expr = new E_Equals(exprVar, nodeValue);
// return expr;
//
//
// var filterExpr = ExprUtils.orify(typeExprs);
//
// triple = new Triple(propertyVar, vocab.rdf.type, v);
//
// var element = new ElementGroup([
// new ElementTriplesBlock([triple]),
// new ElementFilter(filterExpr)
// ]);
//
// //console.log('ELEMENTE' + element);
//
// facetElements.push(element);
//
// },
};
module.exports = CannedConceptUtils;