import 'package:flutter_flow_chart/flutter_flow_chart.dart'; import 'package:oc_front/models/abstract.dart'; import 'package:oc_front/models/response.dart'; import 'package:oc_front/models/search.dart'; class Workspace extends SerializerDeserializer implements ShallowData { String? id; String? name; bool? active; List datas; List datacenters; List storages; List processings; List workflows; String? shared; Workspace({ this.id, this.name, this.active = false, this.workflows = const [], this.datas = const [], this.datacenters = const [], this.storages = const [], this.processings = const [], this.shared, }); @override String getID() => id ?? ""; @override String getName() => name ?? ""; @override deserialize(dynamic json) { try { json = json as Map; } catch (e) { return Workspace(); } return Workspace( id: json.containsKey("id") ? json["id"] : null, shared: json["shared"], name: json.containsKey("name") ? json["name"] : null, active: json.containsKey("active") ? json["active"] : false, processings: json.containsKey("processing_resources") ? fromListJson(json["processing_resources"], ProcessingItem()) : [], storages: json.containsKey("storage_resources") ? fromListJson(json["storage_resources"], StorageItem()) : [], datacenters: json.containsKey("datacenter_resources") ? fromListJson(json["datacenter_resources"], DataCenterItem()) : [], datas: json.containsKey("data_resources") ? fromListJson(json["data_resources"], DataItem()) : [], workflows: json.containsKey("workflow_resources") ? fromListJson(json["workflow_resources"], WorkflowItem()) : [] ); } @override Map serialize() => { "id": id, "name": name, "processings": processings.map((e) => e.id).toList(), "storages": storages.map((e) => e.id).toList(), "datacenters": datacenters.map((e) => e.id).toList(), "datas": datas.map((e) => e.id).toList(), "workflows": workflows.map((e) => e.id).toList(), }; }