intermediate
This commit is contained in:
@@ -1,29 +1,48 @@
|
||||
import 'package:oc_front/models/abstract.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
|
||||
class Workspace extends SerializerDeserializer<Workspace> {
|
||||
String? id;
|
||||
List<dynamic> data;
|
||||
List<dynamic> datacenter;
|
||||
List<dynamic> storage;
|
||||
List<dynamic> computing;
|
||||
String? name;
|
||||
bool? active;
|
||||
List<DataItem> datas;
|
||||
List<DataCenterItem> datacenters;
|
||||
List<StorageItem> storages;
|
||||
List<ProcessingItem> processings;
|
||||
List<WorkflowItem> workflows;
|
||||
|
||||
Workspace({
|
||||
this.id,
|
||||
this.computing = const [],
|
||||
this.data = const [],
|
||||
this.datacenter = const [],
|
||||
this.storage = const [],
|
||||
this.name,
|
||||
this.active = false,
|
||||
this.workflows = const [],
|
||||
this.datas = const [],
|
||||
this.datacenters = const [],
|
||||
this.storages = const [],
|
||||
this.processings = const [],
|
||||
});
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return Workspace(); }
|
||||
return Workspace(
|
||||
computing: json.containsKey("computing") ? json["computing"] : [],
|
||||
datacenter: json.containsKey("datacenter") ? json["datacenter"] : [],
|
||||
data: json.containsKey("data") ? json["data"] : [],
|
||||
storage: json.containsKey("storage") ? json["storage"] : [],
|
||||
id: json.containsKey("id") ? json["id"] : null,
|
||||
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<String, dynamic> serialize() => {};
|
||||
@override Map<String, dynamic> 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(),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user