Skip to content

Commit 6821ad7

Browse files
committed
Query examples
1 parent d5ebba8 commit 6821ad7

File tree

3 files changed

+132
-19
lines changed

3 files changed

+132
-19
lines changed

_layouts/mdcontent.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
layout: standard
3+
---
4+
5+
<div class="mdcontent">
6+
{{ content }}
7+
</div>

public/css/layout.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ a.relevant {
2020
.big {
2121
font-size: 2em;
2222
}
23+
24+
div.mdcontent {
25+
padding: 2em;
26+
}

samples.md

Lines changed: 121 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,139 @@
11
---
2-
layout: standard
2+
layout: mdcontent
33
title: Query examples
44
---
55

66

7-
### Get *boolean* returning methods with an *int* parameter
7+
### Select recursive methods
88

9-
SELECT ?method WHERE {
10-
?method a woc:Method .
11-
?method woc:returns woc:boolean .
12-
?method woc:has_parameter ?par .
13-
?par woc:parameter_position 0 .
14-
?par woc:type woc:int .
9+
SELECT ?method
10+
WHERE {
11+
?method a woc:Method ;
12+
woc:references+ ?method .
13+
}
14+
LIMIT 20
15+
16+
17+
### Get the most referenced classes
18+
19+
SELECT ?class (COUNT(DISTINCT ?anotherClass) as ?count)
20+
WHERE {
21+
?class a woc:Class .
22+
?method a woc:Method ;
23+
woc:isDeclaredBy ?anotherClass ;
24+
woc:references ?class .
25+
FILTER (?class != ?anotherClass)
26+
}
27+
GROUP BY ?class
28+
ORDER BY DESC(?count)
29+
LIMIT 3
30+
31+
### Sort classes by the number of subclasses
32+
33+
SELECT ?superClass (COUNT(DISTINCT ?class) as ?count)
34+
WHERE {
35+
?class a woc:Class;
36+
woc:extends* ?superClass .
37+
}
38+
GROUP BY ?superClass
39+
ORDER BY DESC(?count)
40+
LIMIT 3
41+
42+
43+
### Singletons
44+
45+
SELECT DISTINCT ?class
46+
WHERE {
47+
?class woc:hasConstructor ?constructor ;
48+
woc:hasField ?field ;
49+
woc:hasMethod ?method .
50+
?constructor woc:hasModifier woc:Private .
51+
?field woc:hasModifier woc:Static , woc:Private ;
52+
woc:hasType ?class .
53+
?method woc:returns ?field ;
54+
woc:hasModifier woc:Static , woc:Public .
55+
}
1556

16-
filter not exists {
17-
?method woc:has_parameter ?par1 .
18-
?par1 woc:parameter_position 1
19-
}
57+
58+
### Builder
59+
60+
SELECT DISTINCT ?abstractBuilder ?concreteBuilder ?product
61+
WHERE {
62+
?abstractBuilder a woc:Class;
63+
woc:hasModifier woc:Abstract ;
64+
woc:hasField ?field ;
65+
woc:hasMethod ?abstractBuildMethod ;
66+
woc:hasMethod ?getter .
67+
?product a woc:Class .
68+
?field woc:hasType ?product .
69+
?getter woc:returns ?field .
70+
?abstractBuildMethod woc:hasModifier woc:Abstract .
71+
?concreteBuilder woc:extends ?abstractBuilder ;
72+
woc:hasMethod ?concreteBuildMethod .
73+
?concreteBuildMethod woc:overrides ?abstractBuildMethod .
74+
?concreteBuildMethod woc:references ?field .
75+
FILTER NOT EXISTS {
76+
?getter woc:hasParameter ?parameter
77+
}
78+
}
79+
80+
81+
### Factories
82+
83+
SELECT DISTINCT ?factory
84+
WHERE {
85+
?abstractClass a woc:Class ;
86+
woc:hasModifier woc:Abstract .
87+
?factory a woc:Class;
88+
woc:hasMethod ?method .
89+
?method woc:hasReturnType/woc:extends* ?abstractClass .
90+
FILTER NOT EXISTS {
91+
?factory woc:hasMethod ?anotherMethod .
92+
?anotherMethod woc:hasReturnType ?type ;
93+
woc:hasModifier woc:Public .
94+
FILTER NOT EXISTS {
95+
?type woc:extends* ?abstractClass .
96+
}
97+
}
2098
}
99+
LIMIT 20
21100

22101

23-
### Get *lambdas* implementing an *interface*
102+
### Select all resources associated with Public-key cryptography and, in particular, with RSA
24103

104+
SELECT ?r
105+
WHERE {
106+
?r dul:associatedWith
107+
dbr:Public-key_cryptography ,
108+
dbr:RSA_\(cryptosystem\) .
109+
}
110+
111+
112+
### Select methods to manipulate Zip files
25113

26-
SELECT ?lambda WHERE {
27-
?lambda woc:functional_implements ?i
114+
SELECT ?method
115+
WHERE {
116+
?method a woc:Method ;
117+
dul:associatedWith dbr:Zip_\(file_format\) , dbr:Input\/output
28118
}
29119

30120

31-
### Get methods' usage cases
121+
### Select methods to read an image at a specified URL, along with the return type
122+
123+
SELECT ?method ?type
124+
WHERE {
125+
?method a woc:Method;
126+
woc:hasParameter ?parameter ;
127+
woc:hasReturnType ?type .
128+
?parameter dul:associatedWith dbr:Uniform_Resource_Locator, dbr:Image .
129+
}
130+
32131

132+
### Select methods to compute the cube root of a parameter of type double
33133

34-
SELECT ?invoker {
35-
?method a woc:Method .
36-
?invoker woc:requests ?method .
134+
SELECT ?method
135+
WHERE {
136+
?method a woc:Method ;
137+
woc:hasParameter/woc:hasType woc:Double ;
138+
dul:associatedWith dbr:Cube_root .
37139
}

0 commit comments

Comments
 (0)