Skip to content
Snippets Groups Projects
Commit 8f678ee1 authored by Maximilian Betz's avatar Maximilian Betz
Browse files

corrected urn<=>id handling.

parent a18c1730
No related branches found
No related tags found
No related merge requests found
......@@ -75,6 +75,7 @@ class AddEvent extends StatelessWidget {
}).toList(),
onChanged: (value) {
currentEvent.store.urn = value.toString();
currentEvent.store.id = availableDevice.getDeviceIdFromUrn(value.toString());
}
),
TextFormField(
......
......@@ -64,8 +64,21 @@ class EventType{
}
abstract class DeviceStoreBase{
abstract class DeviceStoreBase {
List<Device> store = [];
int getDeviceIdFromUrn(String urn) {
for (var device in store) {
if (device.urn == urn) {
return device.id;
}
}
throw Exception('Device with urn:' + urn + ' was not found.');
}
void reset(){
store = [];
}
}
abstract class EventStoreBase{
......@@ -90,6 +103,10 @@ class EventStoreInstance extends EventStoreBase {
EventStoreInstance._internal() {
store = [];
}
void reset(){
store = [];
}
}
class EventCurrentInstance extends EventCurrentBase {
......@@ -100,7 +117,11 @@ class EventCurrentInstance extends EventCurrentBase {
}
EventCurrentInstance._internal(){
store = Event(0, 'urn0', '', '', '', 'PENDING');
store = Event(-1, 'urn0', '', '', '', 'PENDING');
}
void reset(){
store = Event(-1, 'urn0', '', '', '', 'PENDING');
}
}
......@@ -114,6 +135,11 @@ class EventTypeStoreInstance extends EventTypeStoreBase{
EventTypeStoreInstance._internal(){
store = [];
}
void reset(){
store = [];
}
}
......
......@@ -12,20 +12,26 @@ void main() {
EventStoreInstance events = EventStoreInstance();
EventTypeStoreInstance eventTypes = EventTypeStoreInstance();
EventCurrentInstance currentEvent = EventCurrentInstance();
DeviceStoreInstance availableDevice = DeviceStoreInstance();
DeviceStoreInstance availableDevices = DeviceStoreInstance();
//Reset old data
events.reset();
eventTypes.reset();
currentEvent.reset();
availableDevices.reset();
// Add some dummy devices
// TODO: load from shared preferences.
// TODO: this shall be requested from sensor.awi.de after selecting a collection in configuration.
availableDevice.store.add(Device.fromJson({'id': 8311, 'urn':'station:neumayer_iii:awi_snow_sampler_1'}));
availableDevice.store.add(Device.fromJson({'id': 4086, 'urn':'acoustic_backscatter_sensor:test'}));
availableDevice.store.add(Device.fromJson({'id': 1393, 'urn':'vessel:polarstern:hydrosweep_ds3'}));
availableDevices.store.add(Device.fromJson({'id': 8311, 'urn':'station:neumayer_iii:awi_snow_sampler_1'}));
availableDevices.store.add(Device.fromJson({'id': 4086, 'urn':'acoustic_backscatter_sensor:test'}));
availableDevices.store.add(Device.fromJson({'id': 1393, 'urn':'vessel:polarstern:hydrosweep_ds3'}));
// Fill the textboxes in addevent with some usefull data.
// TODO: store this in shared preferences so that last entered data reappears when restarting the app.
currentEvent.store.urn = 'acoustic_backscatter_sensor:test';
currentEvent.store.id = 1234;
currentEvent.store.id = 4086;
currentEvent.store.description = 'blabla';
currentEvent.store.label = 'PS129_ABC';
currentEvent.store.type = 'Deployment';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment