oc-front/lib/models/workspace.dart

56 lines
2.1 KiB
Dart
Raw Normal View History

2024-08-30 12:52:32 +02:00
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
import 'package:oc_front/models/abstract.dart';
2024-08-30 12:52:32 +02:00
import 'package:oc_front/models/response.dart';
2024-08-08 08:42:32 +02:00
import 'package:oc_front/models/search.dart';
2024-08-30 12:52:32 +02:00
class Workspace extends SerializerDeserializer<Workspace> implements ShallowData {
String? id;
2024-08-08 08:42:32 +02:00
String? name;
bool? active;
List<DataItem> datas;
2024-11-08 13:59:22 +01:00
List<ComputeItem> computes;
2024-08-08 08:42:32 +02:00
List<StorageItem> storages;
List<ProcessingItem> processings;
List<WorkflowItem> workflows;
2024-08-27 15:38:21 +02:00
String? shared;
Workspace({
this.id,
2024-08-08 08:42:32 +02:00
this.name,
this.active = false,
this.workflows = const [],
this.datas = const [],
2024-11-08 13:59:22 +01:00
this.computes = const [],
2024-08-08 08:42:32 +02:00
this.storages = const [],
this.processings = const [],
2024-08-27 15:38:21 +02:00
this.shared,
});
2024-08-30 12:52:32 +02:00
@override String getID() => id ?? "";
@override String getName() => name ?? "";
@override deserialize(dynamic json) {
try { json = json as Map<String, dynamic>;
} catch (e) { return Workspace(); }
return Workspace(
2024-08-08 08:42:32 +02:00
id: json.containsKey("id") ? json["id"] : null,
2024-08-27 15:38:21 +02:00
shared: json["shared"],
2024-08-08 08:42:32 +02:00
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()) : [],
2024-11-08 13:59:22 +01:00
computes: json.containsKey("compute_resources") ? fromListJson(json["compute_resources"], ComputeItem()) : [],
2024-08-08 08:42:32 +02:00
datas: json.containsKey("data_resources") ? fromListJson(json["data_resources"], DataItem()) : [],
workflows: json.containsKey("workflow_resources") ? fromListJson(json["workflow_resources"], WorkflowItem()) : []
);
}
2024-08-08 08:42:32 +02:00
@override Map<String, dynamic> serialize() => {
"id": id,
"name": name,
"processings": processings.map((e) => e.id).toList(),
"storages": storages.map((e) => e.id).toList(),
2024-11-08 13:59:22 +01:00
"computes": computes.map((e) => e.id).toList(),
2024-08-08 08:42:32 +02:00
"datas": datas.map((e) => e.id).toList(),
"workflows": workflows.map((e) => e.id).toList(),
};
}