amee 2.6.0 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/Gemfile +18 -0
  2. data/README +2 -2
  3. data/Rakefile +31 -0
  4. data/VERSION +1 -0
  5. data/amee-ruby.gemspec +147 -0
  6. data/examples/view_profile_item.rb +32 -0
  7. data/lib/amee.rb +0 -1
  8. data/lib/amee/profile_item.rb +27 -6
  9. data/spec/amee_spec.rb +25 -0
  10. data/spec/cache_spec.rb +152 -0
  11. data/spec/connection_spec.rb +295 -0
  12. data/spec/data_category_spec.rb +259 -0
  13. data/spec/data_item_spec.rb +224 -0
  14. data/spec/data_item_value_history_spec.rb +311 -0
  15. data/spec/data_item_value_spec.rb +231 -0
  16. data/spec/data_object_spec.rb +9 -0
  17. data/spec/drill_down_spec.rb +163 -0
  18. data/spec/fixtures/AD63A83B4D41.json +1 -0
  19. data/spec/fixtures/AD63A83B4D41.xml +1 -0
  20. data/spec/fixtures/create_item.json +1 -0
  21. data/spec/fixtures/create_item.xml +1 -0
  22. data/spec/fixtures/data.json +1 -0
  23. data/spec/fixtures/data.xml +1 -0
  24. data/spec/fixtures/data_home_energy_quantity.xml +146 -0
  25. data/spec/fixtures/data_home_energy_quantity_biodiesel.xml +177 -0
  26. data/spec/fixtures/data_transport_car_generic_drill_fuel_diesel.xml +33 -0
  27. data/spec/fixtures/empty.json +1 -0
  28. data/spec/fixtures/empty.xml +1 -0
  29. data/spec/fixtures/parse_test.xml +22 -0
  30. data/spec/fixtures/v0_data_transport_transport_drill_transportType_Car1.xml +20 -0
  31. data/spec/item_definition_spec.rb +313 -0
  32. data/spec/item_value_definition_spec.rb +253 -0
  33. data/spec/logger_spec.rb +16 -0
  34. data/spec/object_spec.rb +44 -0
  35. data/spec/parse_helper_spec.rb +72 -0
  36. data/spec/profile_category_spec.rb +565 -0
  37. data/spec/profile_item_spec.rb +451 -0
  38. data/spec/profile_item_value_spec.rb +196 -0
  39. data/spec/profile_object_spec.rb +24 -0
  40. data/spec/profile_spec.rb +88 -0
  41. data/spec/rails_spec.rb +48 -0
  42. data/spec/spec.opts +2 -0
  43. data/spec/spec_helper.rb +56 -0
  44. data/spec/user_spec.rb +249 -0
  45. metadata +189 -55
  46. data/lib/amee/version.rb +0 -10
@@ -0,0 +1,231 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+
4
+ MockResourceShortPath="/transport/plane/generic/AD63A83B4D41/kgCO2PerPassengerJourney"
5
+ MockResourcePath="/data#{MockResourceShortPath}"
6
+ MockResourceShortUIDPath="/transport/plane/generic/AD63A83B4D41/127612FA4921"
7
+ MockResourceUIDPath="/data#{MockResourceShortUIDPath}"
8
+ MockResourceDataItemShortPath="/transport/plane/generic/AD63A83B4D41"
9
+ MockResourceDataItemPath="/data#{MockResourceDataItemShortPath}"
10
+
11
+ describe AMEE::Data::ItemValue do
12
+
13
+ before(:each) do
14
+ @value = AMEE::Data::ItemValue.new
15
+ end
16
+
17
+ it "should have common AMEE object properties" do
18
+ @value.is_a?(AMEE::Data::Object).should be_true
19
+ end
20
+
21
+ it "should have a value" do
22
+ @value.should respond_to(:value)
23
+ end
24
+
25
+ it "should have a type" do
26
+ @value.should respond_to(:type)
27
+ end
28
+
29
+ it "can be from profile" do
30
+ @value.should respond_to(:from_profile?)
31
+ end
32
+
33
+ it "can be from data" do
34
+ @value.should respond_to(:from_data?)
35
+ end
36
+
37
+ it "should initialize AMEE::Object data on creation" do
38
+ uid = 'ABCD1234'
39
+ @value = AMEE::Data::ItemValue.new(:uid => uid)
40
+ @value.uid.should == uid
41
+ end
42
+
43
+ it "can be created with hash of data" do
44
+ value = "test"
45
+ type = "TEXT"
46
+ from_profile = false
47
+ from_data = true
48
+ @value = AMEE::Data::ItemValue.new(:value => value, :type => type, :from_profile => from_profile, :from_data => from_data)
49
+ @value.value.should == value
50
+ @value.type.should == type
51
+ @value.from_profile?.should be_false
52
+ @value.from_data?.should be_true
53
+ end
54
+
55
+ it "should support DOUBLE data type" do
56
+ @value = AMEE::Data::ItemValue.new(:value => "1.5", :type => "DOUBLE")
57
+ @value.value.should == 1.5
58
+ end
59
+
60
+ it "should support TEXT data type" do
61
+ @value = AMEE::Data::ItemValue.new(:value => "1.5", :type => "TEXT")
62
+ @value.value.should == "1.5"
63
+ end
64
+
65
+ it "allows value to be changed after creation" do
66
+ value = "test"
67
+ type = "TEXT"
68
+ from_profile = false
69
+ from_data = true
70
+ @value = AMEE::Data::ItemValue.new(:value => value, :type => type, :from_profile => from_profile, :from_data => from_data)
71
+ @value.value.should == value
72
+ value = 42
73
+ @value.value = value
74
+ @value.value.should == value
75
+ end
76
+
77
+ end
78
+
79
+ describe AMEE::Data::ItemValue, "with an authenticated connection" do
80
+
81
+ it "should parse XML correctly" do
82
+ connection = flexmock "connection"
83
+ connection.should_receive(:get).with(MockResourcePath).and_return(flexmock(:body => '<Resources><DataItemValueResource><ItemValue Created="2007-08-01 09:00:41.0" Modified="2007-08-01 09:00:41.0" uid="127612FA4921"><Path>kgCO2PerPassengerJourney</Path><Name>kgCO2 Per Passenger Journey</Name><Value>0.1</Value><ItemValueDefinition uid="653828811D42"><Path>kgCO2PerPassengerJourney</Path><Name>kgCO2 Per Passenger Journey</Name><FromProfile>false</FromProfile><FromData>true</FromData><ValueDefinition uid="8CB8A1789CD6"><Name>kgCO2PerJourney</Name><ValueType>DOUBLE</ValueType></ValueDefinition></ItemValueDefinition><DataItem uid="AD63A83B4D41"/></ItemValue><DataItem uid="AD63A83B4D41"/></DataItemValueResource></Resources>'))
84
+ @value = AMEE::Data::ItemValue.get(connection, MockResourcePath)
85
+ @value.uid.should == "127612FA4921"
86
+ @value.name.should == "kgCO2 Per Passenger Journey"
87
+ @value.path.should ==MockResourceShortPath
88
+ @value.full_path.should == MockResourcePath
89
+ @value.created.should == DateTime.new(2007,8,1,9,00,41)
90
+ @value.modified.should == DateTime.new(2007,8,1,9,00,41)
91
+ @value.value.should == 0.1
92
+ @value.type.should == "DOUBLE"
93
+ @value.from_profile?.should be_false
94
+ @value.from_data?.should be_true
95
+ end
96
+
97
+ it "should parse JSON correctly" do
98
+ connection = flexmock "connection"
99
+ connection.should_receive(:get).with(MockResourcePath).and_return(flexmock(:body => '{"dataItem":{"uid":"AD63A83B4D41"},"itemValue":{"item":{"uid":"AD63A83B4D41"},"modified":"2007-08-01 09:00:41.0","created":"2007-08-01 09:00:41.0","value":"0.1","uid":"127612FA4921","path":"kgCO2PerPassengerJourney","name":"kgCO2 Per Passenger Journey","itemValueDefinition":{"valueDefinition":{"valueType":"DOUBLE","uid":"8CB8A1789CD6","name":"kgCO2PerJourney"},"uid":"653828811D42","path":"kgCO2PerPassengerJourney","name":"kgCO2 Per Passenger Journey"}}}'))
100
+ @value = AMEE::Data::ItemValue.get(connection, MockResourcePath)
101
+ @value.uid.should == "127612FA4921"
102
+ @value.name.should == "kgCO2 Per Passenger Journey"
103
+ @value.path.should == MockResourceShortPath
104
+ @value.full_path.should == MockResourcePath
105
+ @value.created.should == DateTime.new(2007,8,1,9,00,41)
106
+ @value.modified.should == DateTime.new(2007,8,1,9,00,41)
107
+ @value.value.should == 0.1
108
+ @value.type.should == "DOUBLE"
109
+ #@value.from_profile?.should be_false # NOT SET IN JSON
110
+ #@value.from_data?.should be_true # NOT SET IN JSON
111
+ end
112
+
113
+ it "should fail gracefully with incorrect XML data" do
114
+ connection = flexmock "connection"
115
+ xml = '<?xml version="1.0" encoding="UTF-8"?><Resources></Resources>'
116
+ connection.should_receive(:get).with("/data").and_return(flexmock(:body => xml))
117
+ lambda{AMEE::Data::ItemValue.get(connection, "/data")}.should raise_error(AMEE::BadData)
118
+ end
119
+
120
+ it "should fail gracefully when the return is an item value history" do
121
+ connection = flexmock "connection"
122
+ xml = '<Resources><DataItemValueResource><ItemValues>'+
123
+ '<ItemValue Created="2007-08-01 09:00:41.0" Modified="2007-08-01 09:00:41.0" uid="127612FA4922"><Path>kgCO2PerPassengerJourney</Path><Name>kgCO2 Per Passenger Journey</Name><StartDate></StartDate>0<Value>1</Value><ItemValueDefinition uid="653828811D42"><Path>kgCO2PerPassengerJourney</Path><Name>kgCO2 Per Passenger Journey</Name><FromProfile>false</FromProfile><FromData>true</FromData><ValueDefinition uid="8CB8A1789CD6"><Name>kgCO2PerJourney</Name><ValueType>DOUBLE</ValueType></ValueDefinition></ItemValueDefinition><DataItem uid="AD63A83B4D41"/></ItemValue><DataItem uid="AD63A83B4D41"/>'+
124
+ '<ItemValue Created="2007-08-01 09:00:41.0" Modified="2007-08-01 09:00:41.0" uid="127612FA4922"><Path>kgCO2PerPassengerJourney</Path><Name>kgCO2 Per Passenger Journey</Name><StartDate></StartDate>1<Value>2</Value><ItemValueDefinition uid="653828811D42"><Path>kgCO2PerPassengerJourney</Path><Name>kgCO2 Per Passenger Journey</Name><FromProfile>false</FromProfile><FromData>true</FromData><ValueDefinition uid="8CB8A1789CD6"><Name>kgCO2PerJourney</Name><ValueType>DOUBLE</ValueType></ValueDefinition></ItemValueDefinition><DataItem uid="AD63A83B4D41"/></ItemValue><DataItem uid="AD63A83B4D41"/>'+
125
+ '</ItemValues></DataItemValueResource></Resources>'
126
+ connection.should_receive(:get).with(MockResourcePath).and_return(flexmock(:body => xml))
127
+ lambda{AMEE::Data::ItemValue.get(connection, MockResourcePath)}.should raise_error(AMEE::BadData)
128
+ end
129
+
130
+ it "should should handle this data" do
131
+ connection = flexmock "connection"
132
+ xml = "<DataItemValueResource><ItemValues><ItemValue uid='14E0F070EDD6'><Path>massCO2PerEnergy</Path><Name>Mass CO2 per Energy</Name><Value>0.1382909</Value><Unit>kg</Unit><PerUnit>kWh</PerUnit><StartDate>1970-01-01T01:00:00+01:00</StartDate><ItemValueDefinition uid='073CE1A98F4C'><Path>massCO2PerEnergy</Path><Name>Mass CO2 per Energy</Name><ValueDefinition modified='2007-07-27 09:30:44.0' uid='45433E48B39F' created='2007-07-27 09:30:44.0'><Name>amount</Name><ValueType>DOUBLE</ValueType><Description/><Environment uid='5F5887BCF726'/></ValueDefinition><Unit>kg</Unit><PerUnit>kWh</PerUnit><FromProfile>false</FromProfile><FromData>true</FromData><DrillDown>false</DrillDown></ItemValueDefinition></ItemValue></ItemValues><DataItem uid='9FFE9E794049'/><Path>/test/api/item_history_test/9FFE9E794049/massCO2PerEnergy</Path></DataItemValueResource>"
133
+ connection.should_receive(:get).with(MockResourcePath).and_return(flexmock(:body => xml))
134
+ lambda{AMEE::Data::ItemValue.get(connection, MockResourcePath)}.should_not raise_error
135
+ end
136
+
137
+ it "should fail gracefully with incorrect JSON data" do
138
+ connection = flexmock "connection"
139
+ json = '{}'
140
+ connection.should_receive(:get).with("/data").and_return(flexmock(:body => json))
141
+ lambda{AMEE::Data::ItemValue.get(connection, "/data")}.should raise_error(AMEE::BadData)
142
+ end
143
+
144
+ it "should fail gracefully on other errors" do
145
+ connection = flexmock "connection"
146
+ connection.should_receive(:get).with("/data").and_raise("unidentified error")
147
+ lambda{AMEE::Data::ItemValue.get(connection, "/data")}.should raise_error(AMEE::BadData)
148
+ end
149
+
150
+ end
151
+
152
+ describe AMEE::Data::ItemValue, "after loading" do
153
+
154
+ before(:each) do
155
+ @path = MockResourcePath
156
+ @connection = flexmock "connection"
157
+ @connection.should_receive(:get).with(@path).and_return(flexmock(:body => '{"dataItem":{"uid":"AD63A83B4D41"},"itemValue":{"item":{"uid":"AD63A83B4D41"},"modified":"2007-08-01 09:00:41.0","created":"2007-08-01 09:00:41.0","value":"0.1","uid":"127612FA4921","path":"kgCO2PerPassengerJourney","name":"kgCO2 Per Passenger Journey","itemValueDefinition":{"valueDefinition":{"valueType":"DOUBLE","uid":"8CB8A1789CD6","name":"kgCO2PerJourney"},"uid":"653828811D42","path":"kgCO2PerPassengerJourney","name":"kgCO2 Per Passenger Journey"}}}'))
158
+ @val = AMEE::Data::ItemValue.get(@connection, "/data/transport/plane/generic/AD63A83B4D41/kgCO2PerPassengerJourney")
159
+ end
160
+
161
+ it "can have value changed and saved back to server" do
162
+ @connection.should_receive(:put).
163
+ with(MockResourceUIDPath,
164
+ :value => 42).and_return(flexmock(:body => ''))
165
+ lambda {
166
+ @val.value = 42
167
+ @val.save!
168
+ }.should_not raise_error
169
+ end
170
+
171
+ it "can have value and start date changed and saved back to server" do
172
+ @connection.should_receive(:put).
173
+ with(MockResourceUIDPath,
174
+ :value => 42,:startDate=>Time.at(10).xmlschema).and_return(flexmock(:body => ''))
175
+ lambda {
176
+ @val.value = 42
177
+ @val.start_date=Time.at(10)
178
+ @val.save!
179
+ }.should_not raise_error
180
+ end
181
+
182
+ it "can be deleted" do
183
+ @connection.should_receive(:delete).
184
+ with(MockResourceUIDPath).
185
+ and_return(flexmock(:body => ''))
186
+ lambda {
187
+ @val.delete!
188
+ }.should_not raise_error
189
+ end
190
+
191
+ it "can be deleted by path if there is no uid" do
192
+ @connection.should_receive(:delete).
193
+ with(MockResourcePath).
194
+ and_return(flexmock(:body => ''))
195
+ lambda {
196
+ @val.uid=nil
197
+ @val.delete!
198
+ }.should_not raise_error
199
+ end
200
+
201
+ it "can be created" do
202
+ @connection.should_receive(:post).
203
+ with(MockResourceDataItemPath,
204
+ :kgCO2PerPassengerJourney=>42,
205
+ :startDate=>(AMEE::Epoch+3).xmlschema).
206
+ and_return({'Location'=>'http://foo.com/'})
207
+ @new=AMEE::Data::ItemValue.new(:value=>42,
208
+ :start_date=>AMEE::Epoch+3,
209
+ :connection=>@connection,
210
+ :path=>MockResourceDataItemShortPath+"/kgCO2PerPassengerJourney")
211
+ lambda {
212
+ @new.create!
213
+ }.should_not raise_error
214
+ end
215
+
216
+ it "can be created over SSL" do
217
+ @connection.should_receive(:post).
218
+ with(MockResourceDataItemPath,
219
+ :kgCO2PerPassengerJourney=>42,
220
+ :startDate=>(AMEE::Epoch+3).xmlschema).
221
+ and_return({'Location'=>'https://foo.com/'})
222
+ @new=AMEE::Data::ItemValue.new(:value=>42,
223
+ :start_date=>AMEE::Epoch+3,
224
+ :connection=>@connection,
225
+ :path=>MockResourceDataItemShortPath+"/kgCO2PerPassengerJourney")
226
+ lambda {
227
+ @new.create!
228
+ }.should_not raise_error
229
+ end
230
+
231
+ end
@@ -0,0 +1,9 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe AMEE::Data::Object do
4
+
5
+ it "should have a full path under /data" do
6
+ AMEE::Data::Object.new.full_path.should == "/data"
7
+ end
8
+
9
+ end
@@ -0,0 +1,163 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe AMEE::Data::DrillDown do
4
+
5
+ before(:each) do
6
+ @drill = AMEE::Data::DrillDown.new :choice_name => 'choice'
7
+ end
8
+
9
+ it "should have common AMEE object properties" do
10
+ @drill.is_a?(AMEE::Data::Object).should be_true
11
+ end
12
+
13
+ it "should have choices" do
14
+ @drill.should respond_to(:choices)
15
+ end
16
+
17
+ it "should have a choice name" do
18
+ @drill.should respond_to(:choice_name)
19
+ end
20
+
21
+ it "should have selections" do
22
+ @drill.should respond_to(:selections)
23
+ end
24
+
25
+ it "provides access to data item uid" do
26
+ @drill.should respond_to(:data_item_uid)
27
+ end
28
+
29
+ it "should initialize AMEE::Object data on creation" do
30
+ uid = 'ABCD1234'
31
+ @drill = AMEE::Data::DrillDown.new(:uid => uid, :choice_name => 'choice')
32
+ @drill.uid.should == uid
33
+ end
34
+
35
+ it "can be created with hash of data" do
36
+ choices = ["one", "two"]
37
+ @drill = AMEE::Data::DrillDown.new(:choices => choices, :choice_name => 'choice')
38
+ @drill.choices.should == choices
39
+ end
40
+
41
+ end
42
+
43
+ describe AMEE::Data::DrillDown, "accessing AMEE V0" do
44
+
45
+ it "loads drilldown resource" do
46
+ connection = flexmock "connection"
47
+ connection.should_receive(:get).with("/data/transport/transport/drill?transportType=Car1").and_return(flexmock(:body => fixture('v0_data_transport_transport_drill_transportType_Car1.xml')))
48
+ drill = AMEE::Data::DrillDown.get(connection, "/data/transport/transport/drill?transportType=Car1")
49
+ drill.choice_name.should == "transportStyle"
50
+ drill.choices.size.should be(1)
51
+ drill.choices[0].should == "-"
52
+ drill.selections.size.should be(1)
53
+ drill.selections['transportType'].should == 'Car1'
54
+ drill.data_item_uid.should be_nil
55
+ end
56
+
57
+ it "provides simple access to uid" do
58
+ connection = flexmock "connection"
59
+ connection.should_receive(:get).with("/data/transport/transport/drill?transportType=Car1&transportStyle=-&transportSize=large&transportFuel=Diesel").and_return(flexmock(:body => '<?xml version="1.0" encoding="UTF-8"?><Resources><DrillDownResource><DataCategory uid="CD13B9174A6A"/><ItemDefinition uid="7CD0FC1D3B36"/><Selections><Choice><name>transportType</name><value>Car1</value></Choice><Choice><name>transportStyle</name><value>-</value></Choice><Choice><name>transportSize</name><value>large</value></Choice><Choice><name>transportFuel</name><value>Diesel</value></Choice></Selections><Choices><name>uid</name><Choice><name>AC6DA76D96EE</name><value>AC6DA76D96EE</value></Choice></Choices></DrillDownResource></Resources>'))
60
+ drill = AMEE::Data::DrillDown.get(connection, "/data/transport/transport/drill?transportType=Car1&transportStyle=-&transportSize=large&transportFuel=Diesel")
61
+ drill.choice_name.should == "uid"
62
+ drill.choices.size.should be(1)
63
+ drill.selections.size.should be(4)
64
+ drill.data_item_uid.should == "AC6DA76D96EE"
65
+ end
66
+
67
+ end
68
+
69
+ describe AMEE::Data::DrillDown, "with an authenticated XML connection" do
70
+
71
+ it "loads drilldown resource" do
72
+ connection = flexmock "connection"
73
+ connection.should_receive(:get).with("/data/transport/car/generic/drill?fuel=diesel").and_return(flexmock(:body => fixture('data_transport_car_generic_drill_fuel_diesel.xml')))
74
+ drill = AMEE::Data::DrillDown.get(connection, "/data/transport/car/generic/drill?fuel=diesel")
75
+ drill.choice_name.should == "size"
76
+ drill.choices.size.should be(3)
77
+ drill.choices[0].should == "large"
78
+ drill.choices[1].should == "medium"
79
+ drill.choices[2].should == "small"
80
+ drill.selections.size.should be(1)
81
+ drill.selections['fuel'].should == 'diesel'
82
+ drill.data_item_uid.should be_nil
83
+ end
84
+
85
+ it "should fail gracefully with incorrect data" do
86
+ connection = flexmock "connection"
87
+ xml = '<?xml version="1.0" encoding="UTF-8"?><Resources></Resources>'
88
+ connection.should_receive(:get).with("/data/transport/car/generic/drill?fuel=diesel").and_return(flexmock(:body => xml))
89
+ lambda{AMEE::Data::DrillDown.get(connection, "/data/transport/car/generic/drill?fuel=diesel")}.should raise_error(AMEE::BadData)
90
+ end
91
+
92
+ it "provides simple access to uid" do
93
+ connection = flexmock "connection"
94
+ connection.should_receive(:get).with("/data/transport/car/generic/drill?fuel=diesel&size=large").and_return(flexmock(:body => '<?xml version="1.0" encoding="UTF-8"?><Resources><DrillDownResource><DataCategory uid="87E55DA88017"><Name>Generic</Name><Path>generic</Path></DataCategory><ItemDefinition uid="123C4A18B5D6"/><Selections><Choice><Name>fuel</Name><Value>diesel</Value></Choice><Choice><Name>size</Name><Value>large</Value></Choice></Selections><Choices><Name>uid</Name><Choices><Choice><Name>4F6CBCEE95F7</Name><Value>4F6CBCEE95F7</Value></Choice></Choices></Choices></DrillDownResource></Resources>'))
95
+ drill = AMEE::Data::DrillDown.get(connection, "/data/transport/car/generic/drill?fuel=diesel&size=large")
96
+ drill.choice_name.should == "uid"
97
+ drill.choices.size.should be(1)
98
+ drill.selections.size.should be(2)
99
+ drill.data_item_uid.should == "4F6CBCEE95F7"
100
+ end
101
+
102
+ end
103
+
104
+ describe AMEE::Data::DrillDown, "with an authenticated JSON connection" do
105
+
106
+ it "loads drilldown resource" do
107
+ connection = flexmock "connection"
108
+ connection.should_receive(:get).with("/data/transport/car/generic/drill?fuel=diesel").and_return(flexmock(:body => '{"itemDefinition":{"uid":"123C4A18B5D6"},"dataCategory":{"modified":"2007-07-27 09:30:44.0","created":"2007-07-27 09:30:44.0","itemDefinition":{"uid":"123C4A18B5D6"},"dataCategory":{"uid":"1D95119FB149","path":"car","name":"Car"},"uid":"87E55DA88017","environment":{"uid":"5F5887BCF726"},"path":"generic","name":"Generic"},"selections":[{"value":"diesel","name":"fuel"}],"choices":{"choices":[{"value":"large","name":"large"},{"value":"medium","name":"medium"},{"value":"small","name":"small"}],"name":"size"}}'))
109
+ drill = AMEE::Data::DrillDown.get(connection, "/data/transport/car/generic/drill?fuel=diesel")
110
+ drill.choice_name.should == "size"
111
+ drill.choices.size.should be(3)
112
+ drill.choices[0].should == "large"
113
+ drill.choices[1].should == "medium"
114
+ drill.choices[2].should == "small"
115
+ drill.selections.size.should be(1)
116
+ drill.selections['fuel'].should == 'diesel'
117
+ drill.data_item_uid.should be_nil
118
+ end
119
+
120
+ it "should fail gracefully with incorrect data" do
121
+ connection = flexmock "connection"
122
+ json = '{}'
123
+ connection.should_receive(:get).with("/data/transport/car/generic/drill?fuel=diesel").and_return(flexmock(:body => json))
124
+ lambda{AMEE::Data::DrillDown.get(connection, "/data/transport/car/generic/drill?fuel=diesel")}.should raise_error(AMEE::BadData)
125
+ end
126
+
127
+ it "provides simple access to uid" do
128
+ connection = flexmock "connection"
129
+ connection.should_receive(:get).with("/data/transport/car/generic/drill?fuel=diesel&size=large").and_return(flexmock(:body => '{"itemDefinition":{"uid":"123C4A18B5D6"},"dataCategory":{"modified":"2007-07-27 09:30:44.0","created":"2007-07-27 09:30:44.0","itemDefinition":{"uid":"123C4A18B5D6"},"dataCategory":{"uid":"1D95119FB149","path":"car","name":"Car"},"uid":"87E55DA88017","environment":{"uid":"5F5887BCF726"},"path":"generic","name":"Generic"},"selections":[{"value":"diesel","name":"fuel"},{"value":"large","name":"size"}],"choices":{"choices":[{"value":"4F6CBCEE95F7","name":"4F6CBCEE95F7"}],"name":"uid"}}'))
130
+ drill = AMEE::Data::DrillDown.get(connection, "/data/transport/car/generic/drill?fuel=diesel&size=large")
131
+ drill.choice_name.should == "uid"
132
+ drill.choices.size.should be(1)
133
+ drill.selections.size.should be(2)
134
+ drill.data_item_uid.should == "4F6CBCEE95F7"
135
+ end
136
+
137
+ end
138
+
139
+ describe AMEE::Data::DrillDown, "with data" do
140
+
141
+ it "should fail gracefully on other GET errors" do
142
+ connection = flexmock "connection"
143
+ connection.should_receive(:get).with("/data/transport/car/generic/drill?fuel=diesel").and_raise("unidentified error")
144
+ lambda{AMEE::Data::DrillDown.get(connection, "/data/transport/car/generic/drill?fuel=diesel")}.should raise_error(AMEE::BadData)
145
+ end
146
+
147
+ it "enables drilling down through the levels" do
148
+ connection = flexmock "connection"
149
+ connection.should_receive(:retries).and_return(0)
150
+ connection.should_receive(:get).with("/data/transport/car/generic", {:itemsPerPage => 10}).and_return(flexmock(:body => '<?xml version="1.0" encoding="UTF-8"?><Resources><DataCategoryResource><Path>/transport/car/generic</Path><DataCategory created="2007-07-27 09:30:44.0" modified="2007-07-27 09:30:44.0" uid="87E55DA88017"><Name>Generic</Name><Path>generic</Path><Environment uid="5F5887BCF726"/><DataCategory uid="1D95119FB149"><Name>Car</Name><Path>car</Path></DataCategory><ItemDefinition uid="123C4A18B5D6"/></DataCategory><Children><DataCategories><DataCategory uid="417DD367E9AA"><Name>Electric</Name><Path>electric</Path></DataCategory></DataCategories><DataItems><DataItem created="2007-07-27 11:04:57.0" modified="2007-07-27 11:04:57.0" uid="4F6CBCEE95F7"><fuel>diesel</fuel><kgCO2PerKm>0.23</kgCO2PerKm><label>diesel, large</label><kgCO2PerKmUS>0.23</kgCO2PerKmUS><size>large</size><path>4F6CBCEE95F7</path><source>NAEI / Company Reporting Guidelines</source></DataItem><DataItem created="2007-07-27 11:04:57.0" modified="2007-07-27 11:04:57.0" uid="7E2B2426C927"><fuel>diesel</fuel><kgCO2PerKm>0.163</kgCO2PerKm><label>diesel, medium</label><kgCO2PerKmUS>0.163</kgCO2PerKmUS><size>medium</size><path>7E2B2426C927</path><source>NAEI / Company Reporting Guidelines</source></DataItem><DataItem created="2007-07-27 11:04:57.0" modified="2007-07-27 11:04:57.0" uid="57E6AC080BF4"><fuel>diesel</fuel><kgCO2PerKm>0.131</kgCO2PerKm><label>diesel, small</label><kgCO2PerKmUS>0.131</kgCO2PerKmUS><size>small</size><path>57E6AC080BF4</path><source>NAEI / Company Reporting Guidelines</source></DataItem><DataItem created="2007-07-27 11:04:57.0" modified="2007-07-27 11:04:57.0" uid="CEA465039777"><fuel>petrol</fuel><kgCO2PerKm>0.257</kgCO2PerKm><label>petrol, large</label><kgCO2PerKmUS>0.349</kgCO2PerKmUS><size>large</size><path>CEA465039777</path><source>"UK NAEI / Company Reporting Guidelines; US EPA/dgen"</source></DataItem><DataItem created="2007-07-27 11:04:57.0" modified="2007-07-27 11:04:57.0" uid="9A9E8852220B"><fuel>petrol</fuel><kgCO2PerKm>0.188</kgCO2PerKm><label>petrol, medium</label><kgCO2PerKmUS>0.27</kgCO2PerKmUS><size>medium</size><path>9A9E8852220B</path><source>"UK NAEI / Company Reporting Guidelines; US EPA/dgen"</source></DataItem><DataItem created="2007-07-27 11:04:57.0" modified="2007-07-27 11:04:57.0" uid="66DB66447D2F"><fuel>petrol</fuel><kgCO2PerKm>0.159</kgCO2PerKm><label>petrol, small</label><kgCO2PerKmUS>0.224</kgCO2PerKmUS><size>small</size><path>66DB66447D2F</path><source>"UK NAEI / Company Reporting Guidelines; US EPA/dgen"</source></DataItem><DataItem created="2007-07-27 11:04:57.0" modified="2007-07-27 11:04:57.0" uid="69A44DCA9845"><fuel>petrol hybrid</fuel><kgCO2PerKm>0.195</kgCO2PerKm><label>petrol hybrid, large</label><kgCO2PerKmUS>0.195</kgCO2PerKmUS><size>large</size><path>69A44DCA9845</path><source>VCA CO2 database is source of original gCO2/km data</source></DataItem><DataItem created="2007-07-27 11:04:57.0" modified="2007-07-27 11:04:57.0" uid="7DC4C91CD8DA"><fuel>petrol hybrid</fuel><kgCO2PerKm>0.11</kgCO2PerKm><label>petrol hybrid, medium</label><kgCO2PerKmUS>0.11</kgCO2PerKmUS><size>medium</size><path>7DC4C91CD8DA</path><source>VCA CO2 database is source of original gCO2/km data</source></DataItem></DataItems><Pager><Start>0</Start><From>1</From><To>8</To><Items>8</Items><CurrentPage>1</CurrentPage><RequestedPage>1</RequestedPage><NextPage>-1</NextPage><PreviousPage>-1</PreviousPage><LastPage>1</LastPage><ItemsPerPage>10</ItemsPerPage><ItemsFound>8</ItemsFound></Pager></Children></DataCategoryResource></Resources>'))
151
+ connection.should_receive(:get).with("/data/transport/car/generic/drill").and_return(flexmock(:body => '<?xml version="1.0" encoding="UTF-8"?><Resources><DrillDownResource><DataCategory uid="87E55DA88017"><Name>Generic</Name><Path>generic</Path></DataCategory><ItemDefinition uid="123C4A18B5D6"/><Selections/><Choices><Name>fuel</Name><Choices><Choice><Name>diesel</Name><Value>diesel</Value></Choice><Choice><Name>petrol</Name><Value>petrol</Value></Choice><Choice><Name>petrol hybrid</Name><Value>petrol hybrid</Value></Choice></Choices></Choices></DrillDownResource></Resources>'))
152
+ connection.should_receive(:get).with("/data/transport/car/generic/drill?fuel=diesel").and_return(flexmock(:body => '<?xml version="1.0" encoding="UTF-8"?><Resources><DrillDownResource><DataCategory uid="87E55DA88017"><Name>Generic</Name><Path>generic</Path></DataCategory><ItemDefinition uid="123C4A18B5D6"/><Selections><Choice><Name>fuel</Name><Value>diesel</Value></Choice></Selections><Choices><Name>size</Name><Choices><Choice><Name>large</Name><Value>large</Value></Choice><Choice><Name>medium</Name><Value>medium</Value></Choice><Choice><Name>small</Name><Value>small</Value></Choice></Choices></Choices></DrillDownResource></Resources>'))
153
+ connection.should_receive(:get).with("/data/transport/car/generic/drill?fuel=diesel&size=large").and_return(flexmock(:body => '<?xml version="1.0" encoding="UTF-8"?><Resources><DrillDownResource><DataCategory uid="87E55DA88017"><Name>Generic</Name><Path>generic</Path></DataCategory><ItemDefinition uid="123C4A18B5D6"/><Selections><Choice><Name>fuel</Name><Value>diesel</Value></Choice><Choice><Name>size</Name><Value>large</Value></Choice></Selections><Choices><Name>uid</Name><Choices><Choice><Name>4F6CBCEE95F7</Name><Value>4F6CBCEE95F7</Value></Choice></Choices></Choices></DrillDownResource></Resources>'))
154
+ category = AMEE::Data::Category.get(connection, "/data/transport/car/generic")
155
+ drill = category.drill
156
+ drill.choice_name.should == "fuel"
157
+ drill = drill.choose "diesel"
158
+ drill.choice_name.should == "size"
159
+ drill = drill.choose "large"
160
+ drill.data_item_uid.should == "4F6CBCEE95F7"
161
+ end
162
+
163
+ end
@@ -0,0 +1 @@
1
+ {"amountPerMonth":0,"userValueChoices":{"choices":[{"value":"","name":"distanceKmPerYear"},{"value":"","name":"journeysPerYear"},{"value":"-999","name":"lat1"},{"value":"-999","name":"lat2"},{"value":"-999","name":"long1"},{"value":"-999","name":"long2"}],"name":"userValueChoices"},"path":"/transport/plane/generic/AD63A83B4D41","dataItem":{"modified":"2007-08-01 09:00:41.0","created":"2007-08-01 09:00:41.0","itemDefinition":{"uid":"441BF4BEA15B"},"itemValues":[{"value":"0","uid":"127612FA4921","path":"kgCO2PerPassengerJourney","name":"kgCO2 Per Passenger Journey","itemValueDefinition":{"valueDefinition":{"valueType":"DOUBLE","uid":"8CB8A1789CD6","name":"kgCO2PerJourney"},"uid":"653828811D42","path":"kgCO2PerPassengerJourney","name":"kgCO2 Per Passenger Journey"}},{"value":"0.158","uid":"7F27A5707101","path":"kgCO2PerPassengerKm","name":"kgCO2 Per Passenger Km","itemValueDefinition":{"valueDefinition":{"valueType":"DOUBLE","uid":"996AE5477B3F","name":"kgCO2PerKm"},"uid":"D7B4340D9404","path":"kgCO2PerPassengerKm","name":"kgCO2 Per Passenger Km"}},{"value":"-","uid":"FF50EC918A8E","path":"size","name":"Size","itemValueDefinition":{"valueDefinition":{"valueType":"TEXT","uid":"CCEB59CACE1B","name":"text"},"uid":"5D7FB5F552A5","path":"size","name":"Size"}},{"value":"domestic","uid":"FDD62D27AA15","path":"type","name":"Type","itemValueDefinition":{"valueDefinition":{"valueType":"TEXT","uid":"CCEB59CACE1B","name":"text"},"uid":"C376560CB19F","path":"type","name":"Type"}},{"value":"DfT INAS Division, 29 March 2007","uid":"9BE08FBEC54E","path":"source","name":"Source","itemValueDefinition":{"valueDefinition":{"valueType":"TEXT","uid":"CCEB59CACE1B","name":"text"},"uid":"0F0592F05AAC","path":"source","name":"Source"}}],"label":"domestic","dataCategory":{"uid":"FBA97B70DBDF","path":"generic","name":"Generic"},"uid":"AD63A83B4D41","environment":{"uid":"5F5887BCF726"},"path":"","name":"AD63A83B4D41"}}
@@ -0,0 +1 @@
1
+ <?xml version="1.0" encoding="UTF-8"?><Resources><DataItemResource><DataItem created="2007-08-01 09:00:41.0" modified="2007-08-01 09:00:41.0" uid="AD63A83B4D41"><Name>AD63A83B4D41</Name><ItemValues><ItemValue uid="127612FA4921"><Path>kgCO2PerPassengerJourney</Path><Name>kgCO2 Per Passenger Journey</Name><Value>0</Value><ItemValueDefinition uid="653828811D42"><Path>kgCO2PerPassengerJourney</Path><Name>kgCO2 Per Passenger Journey</Name><FromProfile>false</FromProfile><FromData>true</FromData><ValueDefinition uid="8CB8A1789CD6"><Name>kgCO2PerJourney</Name><ValueType>DOUBLE</ValueType></ValueDefinition></ItemValueDefinition></ItemValue><ItemValue uid="7F27A5707101"><Path>kgCO2PerPassengerKm</Path><Name>kgCO2 Per Passenger Km</Name><Value>0.158</Value><ItemValueDefinition uid="D7B4340D9404"><Path>kgCO2PerPassengerKm</Path><Name>kgCO2 Per Passenger Km</Name><FromProfile>false</FromProfile><FromData>true</FromData><ValueDefinition uid="996AE5477B3F"><Name>kgCO2PerKm</Name><ValueType>DOUBLE</ValueType></ValueDefinition></ItemValueDefinition></ItemValue><ItemValue uid="FF50EC918A8E"><Path>size</Path><Name>Size</Name><Value>-</Value><ItemValueDefinition uid="5D7FB5F552A5"><Path>size</Path><Name>Size</Name><FromProfile>false</FromProfile><FromData>true</FromData><ValueDefinition uid="CCEB59CACE1B"><Name>text</Name><ValueType>TEXT</ValueType></ValueDefinition></ItemValueDefinition></ItemValue><ItemValue uid="FDD62D27AA15"><Path>type</Path><Name>Type</Name><Value>domestic</Value><ItemValueDefinition uid="C376560CB19F"><Path>type</Path><Name>Type</Name><FromProfile>false</FromProfile><FromData>true</FromData><ValueDefinition uid="CCEB59CACE1B"><Name>text</Name><ValueType>TEXT</ValueType></ValueDefinition></ItemValueDefinition></ItemValue><ItemValue uid="9BE08FBEC54E"><Path>source</Path><Name>Source</Name><Value>DfT INAS Division, 29 March 2007</Value><ItemValueDefinition uid="0F0592F05AAC"><Path>source</Path><Name>Source</Name><FromProfile>false</FromProfile><FromData>true</FromData><ValueDefinition uid="CCEB59CACE1B"><Name>text</Name><ValueType>TEXT</ValueType></ValueDefinition></ItemValueDefinition></ItemValue></ItemValues><Environment uid="5F5887BCF726"/><ItemDefinition uid="441BF4BEA15B"/><DataCategory uid="FBA97B70DBDF"><Name>Generic</Name><Path>generic</Path></DataCategory><Path>AD63A83B4D41</Path><Label>domestic</Label></DataItem><Path>/transport/plane/generic/AD63A83B4D41</Path><Choices><Name>userValueChoices</Name><Choices><Choice><Name>distanceKmPerYear</Name><Value/></Choice><Choice><Name>journeysPerYear</Name><Value/></Choice><Choice><Name>lat1</Name><Value>-999</Value></Choice><Choice><Name>lat2</Name><Value>-999</Value></Choice><Choice><Name>long1</Name><Value>-999</Value></Choice><Choice><Name>long2</Name><Value>-999</Value></Choice></Choices></Choices><AmountPerMonth>0.000</AmountPerMonth></DataItemResource></Resources>
@@ -0,0 +1 @@
1
+ {"apiVersion":"2.0","pager":{"to":0,"lastPage":1,"nextPage":-1,"items":0,"start":0,"itemsFound":0,"requestedPage":1,"currentPage":1,"from":0,"itemsPerPage":10,"previousPage":-1},"profileCategories":[],"dataCategory":{"uid":"A92693A99BAD","dataCategory":{"uid":"30BA55A0C472","deprecated":false,"name":"Energy","path":"energy"},"deprecated":false,"environment":{"uid":"5F5887BCF726","itemsPerFeed":10,"description":"","name":"AMEE","owner":"","path":"","itemsPerPage":10},"created":"2007-07-27 07:30:44.0","name":"Quantity","path":"quantity","itemDefinition":{"uid":"212C818D8F16","environment":{"uid":"5F5887BCF726"},"created":"2007-07-27 07:30:44.0","name":"Energy Quantity","drillDown":"type","modified":"2011-02-16 08:00:50.0"},"modified":"2011-02-16 08:02:10.0"},"environment":{"uid":"5F5887BCF726","itemsPerFeed":10,"created":"Fri Jul 27 08:30:44 UTC 2007","description":"","name":"AMEE","owner":"","path":"","itemsPerPage":10,"modified":"Fri Jul 27 08:30:44 UTC 2007"},"totalAmount":{"unit":"kg/year","value":"2.037"},"path":"/home/energy/quantity","profileItems":[{"amount":{"unit":"kg/year","value":2.037},"uid":"DWR15I7XMTZI","startDate":"2011-08-09T11:20:00-04:00","itemValues":[{"itemValueDefinition":{"perUnit":"year","uid":"068A0D6D03F7","unit":"kWh","name":"Energy Consumption","fromData":false,"path":"energyConsumption","fromProfile":true,"valueDefinition":{"uid":"45433E48B39F","environment":{"uid":"5F5887BCF726"},"created":"2007-07-27 07:30:44.0","description":"","name":"amount","valueType":"DECIMAL","modified":"2007-07-27 07:30:44.0"},"drillDown":false},"perUnit":"year","uid":"JRFV2NA55NLQ","startDate":"2011-08-09T11:20:00-04:00","unit":"kWh","name":"Energy Consumption","value":"10","path":"energyConsumption","displayPath":"energyConsumption","displayName":"Energy Consumption"},{"itemValueDefinition":{"perUnit":"year","uid":"67B7476423C0","unit":"kWh","name":"Current Reading","fromData":false,"path":"currentReading","fromProfile":true,"valueDefinition":{"uid":"45433E48B39F","environment":{"uid":"5F5887BCF726"},"created":"2007-07-27 07:30:44.0","description":"","name":"amount","valueType":"DECIMAL","modified":"2007-07-27 07:30:44.0"},"drillDown":false},"perUnit":"year","uid":"MNWIVN77HDI5","startDate":"2011-08-09T11:20:00-04:00","unit":"kWh","name":"Current Reading","value":"0","path":"currentReading","displayPath":"currentReading","displayName":"Current Reading"},{"itemValueDefinition":{"uid":"1740E500BDAB","choices":"true=true,false=false","name":"Includes Heating","fromData":false,"path":"includesHeating","fromProfile":true,"valueDefinition":{"uid":"CCEB59CACE1B","environment":{"uid":"5F5887BCF726"},"created":"2007-07-27 07:30:44.0","description":"","name":"text","valueType":"TEXT","modified":"2007-07-27 07:30:44.0"},"drillDown":false},"perUnit":"","uid":"5LYTCR26G4S6","startDate":"2011-08-09T11:20:00-04:00","unit":"","name":"Includes Heating","value":"false","path":"includesHeating","displayPath":"includesHeating","displayName":"Includes Heating"},{"itemValueDefinition":{"uid":"527AADFB3B65","name":"Season","fromData":false,"path":"season","fromProfile":true,"valueDefinition":{"uid":"CCEB59CACE1B","environment":{"uid":"5F5887BCF726"},"created":"2007-07-27 07:30:44.0","description":"","name":"text","valueType":"TEXT","modified":"2007-07-27 07:30:44.0"},"drillDown":false},"perUnit":"","uid":"B0LM98JDLY2W","startDate":"2011-08-09T11:20:00-04:00","unit":"","name":"Season","value":"","path":"season","displayPath":"season","displayName":"Season"},{"itemValueDefinition":{"uid":"63005554AE8A","name":"Green tariff","fromData":false,"path":"greenTariff","fromProfile":true,"valueDefinition":{"uid":"CCEB59CACE1B","environment":{"uid":"5F5887BCF726"},"created":"2007-07-27 07:30:44.0","description":"","name":"text","valueType":"TEXT","modified":"2007-07-27 07:30:44.0"},"drillDown":false},"perUnit":"","uid":"E1T2GNS7GVMH","startDate":"2011-08-09T11:20:00-04:00","unit":"","name":"Green tariff","value":"","path":"greenTariff","displayPath":"greenTariff","displayName":"Green tariff"},{"itemValueDefinition":{"uid":"E0EFED6FD7E6","name":"Payment frequency","fromData":false,"path":"paymentFrequency","fromProfile":true,"valueDefinition":{"uid":"CCEB59CACE1B","environment":{"uid":"5F5887BCF726"},"created":"2007-07-27 07:30:44.0","description":"","name":"text","valueType":"TEXT","modified":"2007-07-27 07:30:44.0"},"drillDown":false},"perUnit":"","uid":"QY8J4H5V7N21","startDate":"2011-08-09T11:20:00-04:00","unit":"","name":"Payment frequency","value":"","path":"paymentFrequency","displayPath":"paymentFrequency","displayName":"Payment frequency"},{"itemValueDefinition":{"perUnit":"year","uid":"CF12B3EBAD02","unit":"kg","name":"Mass Per Time","fromData":false,"path":"massPerTime","fromProfile":true,"valueDefinition":{"uid":"45433E48B39F","environment":{"uid":"5F5887BCF726"},"created":"2007-07-27 07:30:44.0","description":"","name":"amount","valueType":"DECIMAL","modified":"2007-07-27 07:30:44.0"},"drillDown":false},"perUnit":"year","uid":"E9ORFAZ41GOI","startDate":"2011-08-09T11:20:00-04:00","unit":"kg","name":"Mass Per Time","value":"0","path":"massPerTime","displayPath":"massPerTime","displayName":"Mass Per Time"},{"itemValueDefinition":{"perUnit":"year","uid":"40AB7E90980C","unit":"kWh","name":"Last Reading","fromData":false,"path":"lastReading","fromProfile":true,"valueDefinition":{"uid":"45433E48B39F","environment":{"uid":"5F5887BCF726"},"created":"2007-07-27 07:30:44.0","description":"","name":"amount","valueType":"DECIMAL","modified":"2007-07-27 07:30:44.0"},"drillDown":false},"perUnit":"year","uid":"FAUR7WOZY5BH","startDate":"2011-08-09T11:20:00-04:00","unit":"kWh","name":"Last Reading","value":"0","path":"lastReading","displayPath":"lastReading","displayName":"Last Reading"},{"itemValueDefinition":{"perUnit":"year","uid":"177D4642A07A","name":"Number of deliveries","fromData":false,"path":"deliveries","fromProfile":true,"valueDefinition":{"uid":"45433E48B39F","environment":{"uid":"5F5887BCF726"},"created":"2007-07-27 07:30:44.0","description":"","name":"amount","valueType":"DECIMAL","modified":"2007-07-27 07:30:44.0"},"drillDown":false},"perUnit":"year","uid":"ME6VDQJW6U2F","startDate":"2011-08-09T11:20:00-04:00","unit":"","name":"Number of deliveries","value":"","path":"deliveries","displayPath":"deliveries","displayName":"Number of deliveries"},{"itemValueDefinition":{"perUnit":"year","uid":"324EC808AC30","unit":"L","name":"Volume Per Time","fromData":false,"path":"volumePerTime","fromProfile":true,"valueDefinition":{"uid":"45433E48B39F","environment":{"uid":"5F5887BCF726"},"created":"2007-07-27 07:30:44.0","description":"","name":"amount","valueType":"DECIMAL","modified":"2007-07-27 07:30:44.0"},"drillDown":false},"perUnit":"year","uid":"1VDXFX6MVJK5","startDate":"2011-08-09T11:20:00-04:00","unit":"L","name":"Volume Per Time","value":"0","path":"volumePerTime","displayPath":"volumePerTime","displayName":"Volume Per Time"}],"amounts":{"amount":[{"perUnit":"year","unit":"kg","default":"true","value":2.037,"type":"CO2"}]},"created":"2011-08-09T15:20:41Z","name":null,"endDate":"","dataItem":{"uid":"66056991EE23","Label":"gas"},"modified":"2011-08-09T15:20:41Z"}],"profile":{"uid":"7V1FQMSWX64O"}}
@@ -0,0 +1 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?><Resources xmlns="http://schemas.amee.cc/2.0"><ProfileCategoryResource><Path>/home/energy/quantity</Path><Profile uid="7V1FQMSWX64O"/><Environment created="Fri Jul 27 08:30:44 UTC 2007" modified="Fri Jul 27 08:30:44 UTC 2007" uid="5F5887BCF726"><Name>AMEE</Name><Path/><Description/><Owner/><ItemsPerPage>10</ItemsPerPage><ItemsPerFeed>10</ItemsPerFeed></Environment><DataCategory uid="A92693A99BAD"><Name>Quantity</Name><Path>quantity</Path><Deprecated>false</Deprecated></DataCategory><ProfileCategories/><ProfileItems><ProfileItem created="2011-08-09T15:20:07Z" modified="2011-08-09T15:20:07Z" uid="40OAI5AZMPTJ"><Name/><ItemValues><ItemValue uid="2YPRCBVE742M"><Path>currentReading</Path><Name>Current Reading</Name><Value>0</Value><Unit>kWh</Unit><PerUnit>year</PerUnit><StartDate>2011-08-09T11:20:00-04:00</StartDate><ItemValueDefinition uid="67B7476423C0"><Path>currentReading</Path><Name>Current Reading</Name><ValueDefinition created="2007-07-27 07:30:44.0" modified="2007-07-27 07:30:44.0" uid="45433E48B39F"><Name>amount</Name><ValueType>DECIMAL</ValueType><Description/><Environment uid="5F5887BCF726"/></ValueDefinition><Unit>kWh</Unit><PerUnit>year</PerUnit><FromProfile>true</FromProfile><FromData>false</FromData><DrillDown>false</DrillDown></ItemValueDefinition></ItemValue><ItemValue uid="QOC3K7QHQ0VY"><Path>energyConsumption</Path><Name>Energy Consumption</Name><Value>10</Value><Unit>kWh</Unit><PerUnit>year</PerUnit><StartDate>2011-08-09T11:20:00-04:00</StartDate><ItemValueDefinition uid="068A0D6D03F7"><Path>energyConsumption</Path><Name>Energy Consumption</Name><ValueDefinition created="2007-07-27 07:30:44.0" modified="2007-07-27 07:30:44.0" uid="45433E48B39F"><Name>amount</Name><ValueType>DECIMAL</ValueType><Description/><Environment uid="5F5887BCF726"/></ValueDefinition><Unit>kWh</Unit><PerUnit>year</PerUnit><FromProfile>true</FromProfile><FromData>false</FromData><DrillDown>false</DrillDown></ItemValueDefinition></ItemValue><ItemValue uid="44KL8LJBKO6L"><Path>includesHeating</Path><Name>Includes Heating</Name><Value>false</Value><Unit/><PerUnit/><StartDate>2011-08-09T11:20:00-04:00</StartDate><ItemValueDefinition uid="1740E500BDAB"><Path>includesHeating</Path><Name>Includes Heating</Name><ValueDefinition created="2007-07-27 07:30:44.0" modified="2007-07-27 07:30:44.0" uid="CCEB59CACE1B"><Name>text</Name><ValueType>TEXT</ValueType><Description/><Environment uid="5F5887BCF726"/></ValueDefinition><FromProfile>true</FromProfile><FromData>false</FromData><DrillDown>false</DrillDown></ItemValueDefinition></ItemValue><ItemValue uid="FBXJH76C2XTI"><Path>season</Path><Name>Season</Name><Value/><Unit/><PerUnit/><StartDate>2011-08-09T11:20:00-04:00</StartDate><ItemValueDefinition uid="527AADFB3B65"><Path>season</Path><Name>Season</Name><ValueDefinition created="2007-07-27 07:30:44.0" modified="2007-07-27 07:30:44.0" uid="CCEB59CACE1B"><Name>text</Name><ValueType>TEXT</ValueType><Description/><Environment uid="5F5887BCF726"/></ValueDefinition><FromProfile>true</FromProfile><FromData>false</FromData><DrillDown>false</DrillDown></ItemValueDefinition></ItemValue><ItemValue uid="G93N2KP5M26W"><Path>greenTariff</Path><Name>Green tariff</Name><Value/><Unit/><PerUnit/><StartDate>2011-08-09T11:20:00-04:00</StartDate><ItemValueDefinition uid="63005554AE8A"><Path>greenTariff</Path><Name>Green tariff</Name><ValueDefinition created="2007-07-27 07:30:44.0" modified="2007-07-27 07:30:44.0" uid="CCEB59CACE1B"><Name>text</Name><ValueType>TEXT</ValueType><Description/><Environment uid="5F5887BCF726"/></ValueDefinition><FromProfile>true</FromProfile><FromData>false</FromData><DrillDown>false</DrillDown></ItemValueDefinition></ItemValue><ItemValue uid="3X8TF60O0A9G"><Path>paymentFrequency</Path><Name>Payment frequency</Name><Value/><Unit/><PerUnit/><StartDate>2011-08-09T11:20:00-04:00</StartDate><ItemValueDefinition uid="E0EFED6FD7E6"><Path>paymentFrequency</Path><Name>Payment frequency</Name><ValueDefinition created="2007-07-27 07:30:44.0" modified="2007-07-27 07:30:44.0" uid="CCEB59CACE1B"><Name>text</Name><ValueType>TEXT</ValueType><Description/><Environment uid="5F5887BCF726"/></ValueDefinition><FromProfile>true</FromProfile><FromData>false</FromData><DrillDown>false</DrillDown></ItemValueDefinition></ItemValue><ItemValue uid="GYR20M15SA9U"><Path>massPerTime</Path><Name>Mass Per Time</Name><Value>0</Value><Unit>kg</Unit><PerUnit>year</PerUnit><StartDate>2011-08-09T11:20:00-04:00</StartDate><ItemValueDefinition uid="CF12B3EBAD02"><Path>massPerTime</Path><Name>Mass Per Time</Name><ValueDefinition created="2007-07-27 07:30:44.0" modified="2007-07-27 07:30:44.0" uid="45433E48B39F"><Name>amount</Name><ValueType>DECIMAL</ValueType><Description/><Environment uid="5F5887BCF726"/></ValueDefinition><Unit>kg</Unit><PerUnit>year</PerUnit><FromProfile>true</FromProfile><FromData>false</FromData><DrillDown>false</DrillDown></ItemValueDefinition></ItemValue><ItemValue uid="8IEWI1PNS7LT"><Path>lastReading</Path><Name>Last Reading</Name><Value>0</Value><Unit>kWh</Unit><PerUnit>year</PerUnit><StartDate>2011-08-09T11:20:00-04:00</StartDate><ItemValueDefinition uid="40AB7E90980C"><Path>lastReading</Path><Name>Last Reading</Name><ValueDefinition created="2007-07-27 07:30:44.0" modified="2007-07-27 07:30:44.0" uid="45433E48B39F"><Name>amount</Name><ValueType>DECIMAL</ValueType><Description/><Environment uid="5F5887BCF726"/></ValueDefinition><Unit>kWh</Unit><PerUnit>year</PerUnit><FromProfile>true</FromProfile><FromData>false</FromData><DrillDown>false</DrillDown></ItemValueDefinition></ItemValue><ItemValue uid="8EE0VN4RMBCB"><Path>deliveries</Path><Name>Number of deliveries</Name><Value/><Unit/><PerUnit>year</PerUnit><StartDate>2011-08-09T11:20:00-04:00</StartDate><ItemValueDefinition uid="177D4642A07A"><Path>deliveries</Path><Name>Number of deliveries</Name><ValueDefinition created="2007-07-27 07:30:44.0" modified="2007-07-27 07:30:44.0" uid="45433E48B39F"><Name>amount</Name><ValueType>DECIMAL</ValueType><Description/><Environment uid="5F5887BCF726"/></ValueDefinition><PerUnit>year</PerUnit><FromProfile>true</FromProfile><FromData>false</FromData><DrillDown>false</DrillDown></ItemValueDefinition></ItemValue><ItemValue uid="4KVXOOCFAS6Y"><Path>volumePerTime</Path><Name>Volume Per Time</Name><Value>0</Value><Unit>L</Unit><PerUnit>year</PerUnit><StartDate>2011-08-09T11:20:00-04:00</StartDate><ItemValueDefinition uid="324EC808AC30"><Path>volumePerTime</Path><Name>Volume Per Time</Name><ValueDefinition created="2007-07-27 07:30:44.0" modified="2007-07-27 07:30:44.0" uid="45433E48B39F"><Name>amount</Name><ValueType>DECIMAL</ValueType><Description/><Environment uid="5F5887BCF726"/></ValueDefinition><Unit>L</Unit><PerUnit>year</PerUnit><FromProfile>true</FromProfile><FromData>false</FromData><DrillDown>false</DrillDown></ItemValueDefinition></ItemValue></ItemValues><Amount unit="kg/year">2.037</Amount><Amounts><Amount default="true" perUnit="year" type="CO2" unit="kg">2.037</Amount></Amounts><StartDate>2011-08-09T11:20:00-04:00</StartDate><EndDate/><DataItem uid="66056991EE23"><Label>gas</Label></DataItem></ProfileItem></ProfileItems><Pager><Start>0</Start><From>0</From><To>0</To><Items>0</Items><CurrentPage>1</CurrentPage><RequestedPage>1</RequestedPage><NextPage>-1</NextPage><PreviousPage>-1</PreviousPage><LastPage>1</LastPage><ItemsPerPage>10</ItemsPerPage><ItemsFound>0</ItemsFound></Pager><TotalAmount unit="kg/year">2.037</TotalAmount></ProfileCategoryResource></Resources>
@@ -0,0 +1 @@
1
+ {"dataCategory":{"modified":"2007-07-27 09:30:44.0","created":"2007-07-27 09:30:44.0","uid":"CD310BEBAC52","environment":{"uid":"5F5887BCF726"},"path":"","name":"Root"},"path":"","children":{"pager":{},"dataCategories":[{"uid":"BBA3AC3E795E","path":"home","name":"Home"},{"uid":"9E5362EAB0E7","path":"metadata","name":"Metadata"},{"uid":"6153F468BE05","path":"test","name":"Test"},{"uid":"263FC0186834","path":"transport","name":"Transport"},{"uid":"2957AE9B6E6B","path":"user","name":"User"}],"dataItems":{}}}
@@ -0,0 +1 @@
1
+ <?xml version="1.0" encoding="UTF-8"?><Resources><DataCategoryResource><Path/><DataCategory created="2007-07-27 09:30:44.0" modified="2007-07-27 09:30:44.0" uid="CD310BEBAC52"><Name>Root</Name><Path/><Environment uid="5F5887BCF726"/></DataCategory><Children><DataCategories><DataCategory uid="BBA3AC3E795E"><Name>Home</Name><Path>home</Path></DataCategory><DataCategory uid="9E5362EAB0E7"><Name>Metadata</Name><Path>metadata</Path></DataCategory><DataCategory uid="6153F468BE05"><Name>Test</Name><Path>test</Path></DataCategory><DataCategory uid="263FC0186834"><Name>Transport</Name><Path>transport</Path></DataCategory><DataCategory uid="2957AE9B6E6B"><Name>User</Name><Path>user</Path></DataCategory></DataCategories></Children></DataCategoryResource></Resources>
@@ -0,0 +1,146 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <Resources xmlns="http://schemas.amee.cc/2.0">
3
+ <DataCategoryResource>
4
+ <Path>/home/energy/quantity</Path>
5
+ <DataCategory created="2007-07-27 08:30:44.0" modified="2010-09-01 12:37:29.0" uid="A92693A99BAD">
6
+ <Name>Quantity</Name>
7
+ <Path>quantity</Path>
8
+ <Deprecated>false</Deprecated>
9
+ <Environment uid="5F5887BCF726"/>
10
+ <DataCategory uid="30BA55A0C472">
11
+ <Name>Energy</Name>
12
+ <Path>energy</Path>
13
+ <Deprecated>false</Deprecated>
14
+ </DataCategory>
15
+ <ItemDefinition uid="212C818D8F16"/>
16
+ </DataCategory>
17
+ <Children>
18
+ <DataCategories/>
19
+ <DataItems>
20
+ <DataItem created="2007-07-27 09:49:32.0" modified="2009-09-15 15:06:12.0" uid="878854C275BC">
21
+ <startDate>1970-01-01T00:00:00Z</startDate>
22
+ <source>net CV RME-type Wells to wheels/European Commission/JRC 2006 http://ies.jrc.ec.europa.eu/our-activities/support-to-eu-policies/well-to-wheels-analysis/WTW.html</source>
23
+ <kgCO2PerKg/>
24
+ <path>878854C275BC</path>
25
+ <label>biodiesel</label>
26
+ <type>biodiesel</type>
27
+ <endDate/>
28
+ <kgCO2PerKWh/>
29
+ <kgCO2PerLitre>2.5000</kgCO2PerLitre>
30
+ </DataItem>
31
+ <DataItem created="2007-07-27 09:49:32.0" modified="2009-09-15 15:06:12.0" uid="CFA7F3896189">
32
+ <startDate>1970-01-01T00:00:00Z</startDate>
33
+ <source>http://www.defra.gov.uk/environment/business/reporting/pdf/20090717-guidelines-ghg-conversion-factors.xls</source>
34
+ <kgCO2PerKg>0.1215</kgCO2PerKg>
35
+ <path>CFA7F3896189</path>
36
+ <label>biomass</label>
37
+ <type>biomass</type>
38
+ <endDate/>
39
+ <kgCO2PerKWh>0.0263</kgCO2PerKWh>
40
+ <kgCO2PerLitre/>
41
+ </DataItem>
42
+ <DataItem created="2007-07-27 09:49:32.0" modified="2009-09-15 15:06:12.0" uid="A70149AF0F26">
43
+ <startDate>1970-01-01T00:00:00Z</startDate>
44
+ <source>http://www.defra.gov.uk/environment/business/reporting/pdf/20090717-guidelines-ghg-conversion-factors.xls</source>
45
+ <kgCO2PerKg>2.5063</kgCO2PerKg>
46
+ <path>A70149AF0F26</path>
47
+ <label>coal</label>
48
+ <type>coal</type>
49
+ <endDate/>
50
+ <kgCO2PerKWh>0.3114</kgCO2PerKWh>
51
+ <kgCO2PerLitre/>
52
+ </DataItem>
53
+ <DataItem created="2009-03-08 21:34:00.0" modified="2009-09-15 15:06:12.0" uid="8982F4AD51BA">
54
+ <startDate>1970-01-01T00:00:00Z</startDate>
55
+ <source>defra/amee 2008</source>
56
+ <kgCO2PerKg>2.810</kgCO2PerKg>
57
+ <path>8982F4AD51BA</path>
58
+ <label>coking coal</label>
59
+ <type>coking coal</type>
60
+ <endDate/>
61
+ <kgCO2PerKWh>0.349</kgCO2PerKWh>
62
+ <kgCO2PerLitre/>
63
+ </DataItem>
64
+ <DataItem created="2007-07-27 09:49:32.0" modified="2009-09-15 15:06:12.0" uid="D6C9BC81155D">
65
+ <startDate>1970-01-01T00:00:00Z</startDate>
66
+ <source>http://www.defra.gov.uk/environment/business/reporting/pdf/20090717-guidelines-ghg-conversion-factors.xls</source>
67
+ <kgCO2PerKg>3.1643</kgCO2PerKg>
68
+ <path>D6C9BC81155D</path>
69
+ <label>diesel</label>
70
+ <type>diesel</type>
71
+ <endDate/>
72
+ <kgCO2PerKWh>0.2748</kgCO2PerKWh>
73
+ <kgCO2PerLitre>2.6391</kgCO2PerLitre>
74
+ </DataItem>
75
+ <DataItem created="2009-03-08 21:34:01.0" modified="2009-09-15 15:06:12.0" uid="D20E0D8A4164">
76
+ <startDate>1970-01-01T00:00:00Z</startDate>
77
+ <source>uses data in /home/energy/electricity</source>
78
+ <kgCO2PerKg/>
79
+ <path>D20E0D8A4164</path>
80
+ <label>electricity</label>
81
+ <type>electricity</type>
82
+ <endDate/>
83
+ <kgCO2PerKWh/>
84
+ <kgCO2PerLitre/>
85
+ </DataItem>
86
+ <DataItem created="2007-07-27 09:49:32.0" modified="2009-09-15 15:06:12.0" uid="66056991EE23">
87
+ <startDate>1970-01-01T00:00:00Z</startDate>
88
+ <source>http://www.defra.gov.uk/environment/business/reporting/pdf/20090717-guidelines-ghg-conversion-factors.xls</source>
89
+ <kgCO2PerKg>2.6935</kgCO2PerKg>
90
+ <path>66056991EE23</path>
91
+ <label>gas</label>
92
+ <type>gas</type>
93
+ <endDate/>
94
+ <kgCO2PerKWh>0.2037</kgCO2PerKWh>
95
+ <kgCO2PerLitre>0.0020091</kgCO2PerLitre>
96
+ </DataItem>
97
+ <DataItem created="2009-09-15 15:06:16.0" modified="2009-09-15 15:06:16.0" uid="72B64430E81B">
98
+ <startDate>1970-01-01T00:00:00Z</startDate>
99
+ <source>http://www.defra.gov.uk/environment/business/reporting/pdf/20090717-guidelines-ghg-conversion-factors.xls</source>
100
+ <kgCO2PerKg>2.4269</kgCO2PerKg>
101
+ <path>72B64430E81B</path>
102
+ <label>gas gross CV</label>
103
+ <type>gas gross CV</type>
104
+ <endDate/>
105
+ <kgCO2PerKWh>0.1836</kgCO2PerKWh>
106
+ <kgCO2PerLitre>0.0018102</kgCO2PerLitre>
107
+ </DataItem>
108
+ <DataItem created="2007-07-27 09:49:32.0" modified="2009-09-15 15:06:12.0" uid="C024BCE859BB">
109
+ <startDate>1970-01-01T00:00:00Z</startDate>
110
+ <source>http://www.defra.gov.uk/environment/business/reporting/pdf/20090717-guidelines-ghg-conversion-factors.xls</source>
111
+ <kgCO2PerKg>3.1496</kgCO2PerKg>
112
+ <path>C024BCE859BB</path>
113
+ <label>kerosene</label>
114
+ <type>kerosene</type>
115
+ <endDate/>
116
+ <kgCO2PerKWh>0.2584</kgCO2PerKWh>
117
+ <kgCO2PerLitre>2.5278</kgCO2PerLitre>
118
+ </DataItem>
119
+ <DataItem created="2007-07-27 09:49:32.0" modified="2009-09-15 15:06:12.0" uid="26709055568C">
120
+ <startDate>1970-01-01T00:00:00Z</startDate>
121
+ <source>http://www.defra.gov.uk/environment/business/reporting/pdf/20090717-guidelines-ghg-conversion-factors.xls</source>
122
+ <kgCO2PerKg>2.9424</kgCO2PerKg>
123
+ <path>26709055568C</path>
124
+ <label>lpg</label>
125
+ <type>lpg</type>
126
+ <endDate/>
127
+ <kgCO2PerKWh>0.2255</kgCO2PerKWh>
128
+ <kgCO2PerLitre>1.4951</kgCO2PerLitre>
129
+ </DataItem>
130
+ </DataItems>
131
+ <Pager>
132
+ <Start>0</Start>
133
+ <From>1</From>
134
+ <To>10</To>
135
+ <Items>12</Items>
136
+ <CurrentPage>1</CurrentPage>
137
+ <RequestedPage>1</RequestedPage>
138
+ <NextPage>2</NextPage>
139
+ <PreviousPage>-1</PreviousPage>
140
+ <LastPage>2</LastPage>
141
+ <ItemsPerPage>10</ItemsPerPage>
142
+ <ItemsFound>10</ItemsFound>
143
+ </Pager>
144
+ </Children>
145
+ </DataCategoryResource>
146
+ </Resources>