Skip to content
Snippets Groups Projects
datamodel.dart 6.17 KiB
import 'dart:convert';

import 'package:shared_preferences/shared_preferences.dart';


class Collection {
  int id;
  String description;
  String collectionName;

  Collection({
    required this.id,
    required this.description,
    required this.collectionName,
  });

  factory Collection.fromJson(Map<String, dynamic> json) {
    return Collection(
      id: json['id'],
      collectionName: json['collectionName'],
      description: json['description'],
    );
  }

  @override
  String toString(){
    return collectionName;
  }
}

class Device{
  int id;
  String urn;

  Device(this.id, this.urn);

  factory Device.fromJson(Map<String, dynamic> parsedJson){
    return Device( parsedJson['id'] as int,
        parsedJson['urn'] as String);
  }

  @override
  String toString(){
    return '{ ${this.id}, ${this.urn} }';
  }
}

class Event{
  int id;  // Device URN id
  String urn;
  String label;
  String type; // Event type name  TODO: this should be an EventType variable
  int typeId;
  String description;
  String status;
  String startDate;
  String endDate;
  String latitude;
  String longitude;
  String elevation;

  Event(
      this.id,
      this.urn,
      this.label,
      this.type,
      this.typeId,
      this.description,
      this.status,
      this.startDate,