publish_my_data 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/publish_my_data/data_cube/dimensions_controller.rb +5 -1
- data/app/models/publish_my_data/data_cube/cube.rb +34 -3
- data/app/views/publish_my_data/datasets/show.html.haml +1 -1
- data/config/routes.rb +1 -0
- data/lib/publish_my_data/version.rb +1 -1
- data/spec/dummy/log/test.log +17529 -0
- metadata +3 -3
@@ -19,6 +19,11 @@ module PublishMyData
|
|
19
19
|
def measure
|
20
20
|
respond_with @cube.measure_property
|
21
21
|
end
|
22
|
+
|
23
|
+
# GET /data/:dataset_slug/cube/area_dimension(.:format)
|
24
|
+
def area_dimension
|
25
|
+
respond_with @cube.area_dimension
|
26
|
+
end
|
22
27
|
|
23
28
|
# all values for a single dimension in the cube.
|
24
29
|
# Useful for getting axes data for cube grids.
|
@@ -39,7 +44,6 @@ module PublishMyData
|
|
39
44
|
end
|
40
45
|
end
|
41
46
|
|
42
|
-
|
43
47
|
# recommended starting columns
|
44
48
|
def recommended
|
45
49
|
respond_to do |format|
|
@@ -56,10 +56,41 @@ module PublishMyData
|
|
56
56
|
dim_objs.sort{ |x,y| y.size <=> x.size } # ordered by size desc
|
57
57
|
end
|
58
58
|
|
59
|
+
# the (one and only) area dimenson for this cube.
|
60
|
+
def area_dimension
|
61
|
+
|
62
|
+
# NOTE: finds any properties which are any level of descendant of sdmxDim:refArea
|
63
|
+
|
64
|
+
query = "PREFIX qb: <http://purl.org/linked-data/cube#>
|
65
|
+
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
66
|
+
PREFIX sdmxDim: <http://purl.org/linked-data/sdmx/2009/dimension#>
|
67
|
+
|
68
|
+
SELECT DISTINCT ?uri ?label WHERE {
|
69
|
+
|
70
|
+
?uri a ?dimensionType .
|
71
|
+
?uri a qb:DimensionProperty .
|
72
|
+
|
73
|
+
OPTIONAL {
|
74
|
+
?uri rdfs:label ?label .
|
75
|
+
?uri rdfs:subPropertyOf+ ?superProperty .
|
76
|
+
}
|
77
|
+
GRAPH <#{dataset.data_graph_uri}> {
|
78
|
+
?s ?uri ?o .
|
79
|
+
}
|
80
|
+
|
81
|
+
FILTER (
|
82
|
+
?dimensionType = sdmxDim:refArea ||
|
83
|
+
(
|
84
|
+
bound(?superProperty) &&
|
85
|
+
?superProperty = sdmxDim:refArea
|
86
|
+
)
|
87
|
+
)
|
88
|
+
}"
|
89
|
+
|
90
|
+
uris_and_labels_only(Tripod::SparqlClient::Query.select(query)).first
|
91
|
+
end
|
92
|
+
|
59
93
|
# the (one and only) measure property for this cube.
|
60
|
-
# This method appears to exist only for the DimensionsController,
|
61
|
-
# currently in PMD Enterprise (link taken 17-Oct-2013):
|
62
|
-
# https://github.com/Swirrl/publish_my_data_enterprise/blob/545215a331ea8752b6ff4c9692db17170453d2c8/app/controllers/publish_my_data/data_cube/dimensions_controller.rb#L19-L23
|
63
94
|
def measure_property
|
64
95
|
|
65
96
|
query = "PREFIX qb: <http://purl.org/linked-data/cube#>
|
data/config/routes.rb
CHANGED
@@ -11,6 +11,7 @@ PublishMyData::Engine.routes.draw do
|
|
11
11
|
# data cube stuff
|
12
12
|
match "/data/*id/cube/dimensions(.:format)" => "data_cube/dimensions#index" # list the dimensions for the cube
|
13
13
|
match "/data/*id/cube/measure(.:format)" => "data_cube/dimensions#measure" # the measure property for the cube
|
14
|
+
match "/data/*id/cube/area_dimension(.:format)" => "data_cube/dimensions#area_dimension" # the measure property for the cube
|
14
15
|
match "/data/*id/cube/dimension_values(.:format)" => "data_cube/dimensions#values" # all values for a single dimension in the cube. Useful for getting axes.
|
15
16
|
match "/data/*id/cube/dimension_size(.:format)" => "data_cube/dimensions#size" # number of values for a dimension in the cube.
|
16
17
|
match "/data/*id/cube/recommended_dimensions(.:format)" => "data_cube/dimensions#recommended" # recommended dimensions to use.
|