oauth2 state of mind
This commit is contained in:
@@ -7,6 +7,7 @@ import 'package:oc_front/models/resources/data.dart';
|
||||
import 'package:oc_front/models/resources/processing.dart';
|
||||
import 'package:oc_front/models/resources/storage.dart';
|
||||
import 'package:oc_front/models/resources/workflow.dart';
|
||||
import 'package:oc_front/models/resources/workflow_event.dart';
|
||||
|
||||
class Resource implements SerializerDeserializer<Resource> {
|
||||
List<DataItem> datas = [];
|
||||
@@ -503,6 +504,7 @@ Type? getTopicType(String topic) {
|
||||
else if (topic == "compute") { return ComputeItem; }
|
||||
else if (topic == "storage") { return StorageItem; }
|
||||
else if (topic == "workflow") { return WorkflowItem; }
|
||||
else if (topic == "event") { return WorkflowEventItem; }
|
||||
else { return null; }
|
||||
}
|
||||
|
||||
@@ -513,6 +515,7 @@ String getTopic(Type type) {
|
||||
if (type == ComputeItem) { return "compute"; }
|
||||
if (type == StorageItem) { return "storage"; }
|
||||
if (type == WorkflowItem) { return "workflow"; }
|
||||
if (type == WorkflowEventItem) { return "event"; }
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
77
lib/models/resources/workflow_event.dart
Normal file
77
lib/models/resources/workflow_event.dart
Normal file
@@ -0,0 +1,77 @@
|
||||
|
||||
import 'package:oc_front/models/resources/resources.dart';
|
||||
|
||||
class WorkflowEventItem extends AbstractItem<WorkflowEventPricing, WorkflowEventPartnership, WorkflowEventInstance, WorkflowEventItem> {
|
||||
// workflow_execution_id: id of the workflow execution this event targets
|
||||
String? workflowExecutionId;
|
||||
|
||||
WorkflowEventItem({
|
||||
this.workflowExecutionId,
|
||||
}) : super();
|
||||
|
||||
@override String get topic => "event";
|
||||
|
||||
@override WorkflowEventItem deserialize(dynamic data) {
|
||||
try { data = data as Map<String, dynamic>;
|
||||
} catch (e) { return WorkflowEventItem(); }
|
||||
var w = WorkflowEventItem(
|
||||
workflowExecutionId: data.containsKey("workflow_execution_id") && data["workflow_execution_id"] != null
|
||||
? data["workflow_execution_id"] : null,
|
||||
);
|
||||
w.mapFromJSON(data, WorkflowEventInstance());
|
||||
return w;
|
||||
}
|
||||
|
||||
@override Map<String, dynamic> infos() {
|
||||
return {
|
||||
if (workflowExecutionId != null) "workflow_execution_id": workflowExecutionId,
|
||||
};
|
||||
}
|
||||
|
||||
@override Map<String, dynamic> serialize() {
|
||||
var obj = <String, dynamic>{
|
||||
"workflow_execution_id": workflowExecutionId,
|
||||
};
|
||||
obj.addAll(toJSON());
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
class WorkflowEventInstance extends AbstractInstance<WorkflowEventPricing, WorkflowEventPartnership> {
|
||||
WorkflowEventInstance() : super();
|
||||
|
||||
@override WorkflowEventInstance deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return WorkflowEventInstance(); }
|
||||
var w = WorkflowEventInstance();
|
||||
w.mapFromJSON(json, WorkflowEventPartnership());
|
||||
return w;
|
||||
}
|
||||
|
||||
@override Map<String, dynamic> infos() => {};
|
||||
|
||||
@override Map<String, dynamic> serialize() => toJSON();
|
||||
}
|
||||
|
||||
class WorkflowEventPartnership extends AbstractPartnerShip<WorkflowEventPricing> {
|
||||
WorkflowEventPartnership() : super();
|
||||
|
||||
@override WorkflowEventPartnership deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return WorkflowEventPartnership(); }
|
||||
var w = WorkflowEventPartnership();
|
||||
w.mapFromJSON(json, WorkflowEventPricing());
|
||||
return w;
|
||||
}
|
||||
|
||||
@override Map<String, dynamic> serialize() => toJSON();
|
||||
}
|
||||
|
||||
class WorkflowEventPricing extends AbstractPricing {
|
||||
@override WorkflowEventPricing deserialize(dynamic json) {
|
||||
var w = WorkflowEventPricing();
|
||||
w.mapFromJSON(json);
|
||||
return w;
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => toJSON();
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import 'package:oc_front/models/resources/processing.dart';
|
||||
import 'package:oc_front/models/resources/resources.dart';
|
||||
import 'package:oc_front/models/resources/storage.dart';
|
||||
import 'package:oc_front/models/resources/workflow.dart';
|
||||
import 'package:oc_front/models/resources/workflow_event.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/widgets/forms/sub_keys_forms.dart';
|
||||
|
||||
@@ -108,6 +109,7 @@ class Workflow extends SerializerDeserializer<Workflow> implements ShallowData
|
||||
List<dynamic> storage;
|
||||
List<dynamic> processing;
|
||||
List<dynamic> workflows;
|
||||
List<dynamic> events;
|
||||
Graph? graph;
|
||||
List<dynamic> shared;
|
||||
|
||||
@@ -119,6 +121,7 @@ class Workflow extends SerializerDeserializer<Workflow> implements ShallowData
|
||||
this.storage = const [],
|
||||
this.processing = const [],
|
||||
this.workflows = const [],
|
||||
this.events = const [],
|
||||
this.graph,
|
||||
this.shared = const [],
|
||||
});
|
||||
@@ -138,6 +141,7 @@ class Workflow extends SerializerDeserializer<Workflow> implements ShallowData
|
||||
compute: json.containsKey("computes") ? json["computes"] : [],
|
||||
data: json.containsKey("datas") ? json["datas"] : [],
|
||||
storage: json.containsKey("storages") ? json["storages"] : [],
|
||||
events: json.containsKey("events") ? json["events"] : [],
|
||||
shared: json.containsKey("shared") ? json["shared"] : [],
|
||||
graph: json.containsKey("graph") ? Graph().deserialize(json["graph"]) : null,
|
||||
);
|
||||
@@ -151,6 +155,7 @@ class Workflow extends SerializerDeserializer<Workflow> implements ShallowData
|
||||
"computes" : compute,
|
||||
"workflows": workflows,
|
||||
"processings": processing,
|
||||
"events": events,
|
||||
};
|
||||
if (graph != null) {
|
||||
obj["graph"] = graph!.serialize();
|
||||
@@ -690,6 +695,7 @@ class GraphItem extends SerializerDeserializer<GraphItem> {
|
||||
StorageItem? storage;
|
||||
ComputeItem? compute;
|
||||
WorkflowItem? workflow;
|
||||
WorkflowEventItem? event;
|
||||
|
||||
GraphItem({
|
||||
this.id,
|
||||
@@ -701,6 +707,7 @@ class GraphItem extends SerializerDeserializer<GraphItem> {
|
||||
this.storage,
|
||||
this.compute,
|
||||
this.workflow,
|
||||
this.event,
|
||||
});
|
||||
|
||||
AbstractItem? getElement() {
|
||||
@@ -709,6 +716,7 @@ class GraphItem extends SerializerDeserializer<GraphItem> {
|
||||
if (storage != null) { return storage!; }
|
||||
if (compute != null) { return compute!; }
|
||||
if (workflow != null) { return workflow!; }
|
||||
if (event != null) { return event!; }
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -720,17 +728,19 @@ class GraphItem extends SerializerDeserializer<GraphItem> {
|
||||
height = j["height"];
|
||||
|
||||
if (j["element"] != null) {
|
||||
if (j["element"]["type"] == "data") { data = DataItem().deserialize(j["element"]);
|
||||
if (j["element"]["type"] == "data") { data = DataItem().deserialize(j["element"]);
|
||||
} else if (j["element"]["type"] == "processing") { processing = ProcessingItem().deserialize(j["element"]);
|
||||
} else if (j["element"]["type"] == "compute") { compute = ComputeItem().deserialize(j["element"]);
|
||||
} else if (j["element"]["type"] == "storage") { storage = StorageItem().deserialize(j["element"]);
|
||||
} else if (j["element"]["type"] == "workflow") { workflow = WorkflowItem().deserialize(j["element"]);
|
||||
} else if (j["element"]["type"] == "compute") { compute = ComputeItem().deserialize(j["element"]);
|
||||
} else if (j["element"]["type"] == "storage") { storage = StorageItem().deserialize(j["element"]);
|
||||
} else if (j["element"]["type"] == "workflow") { workflow = WorkflowItem().deserialize(j["element"]);
|
||||
} else if (j["element"]["type"] == "event") { event = WorkflowEventItem().deserialize(j["element"]);
|
||||
} else {
|
||||
compute = null;
|
||||
data = null;
|
||||
processing = null;
|
||||
storage = null;
|
||||
workflow = null;
|
||||
event = null;
|
||||
}
|
||||
} else {
|
||||
compute = null;
|
||||
@@ -738,12 +748,13 @@ class GraphItem extends SerializerDeserializer<GraphItem> {
|
||||
processing = null;
|
||||
storage = null;
|
||||
workflow = null;
|
||||
}
|
||||
event = null;
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toDashboard() {
|
||||
Map<String, dynamic> element = {};
|
||||
List<AbstractItem?> items = [data, processing, storage, compute, workflow];
|
||||
List<AbstractItem?> items = [data, processing, storage, compute, workflow, event];
|
||||
for(var el in items) {
|
||||
if (el != null && el.getID() != "") {
|
||||
element = el.serialize();
|
||||
@@ -762,7 +773,7 @@ class GraphItem extends SerializerDeserializer<GraphItem> {
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return GraphItem(); }
|
||||
} catch (e) { return GraphItem(); }
|
||||
return GraphItem(
|
||||
id: json.containsKey("id") ? json["id"] : null,
|
||||
width: json.containsKey("width") ? double.parse(json["width"].toString()) : null,
|
||||
@@ -773,9 +784,10 @@ class GraphItem extends SerializerDeserializer<GraphItem> {
|
||||
storage: json.containsKey("storage") ? StorageItem().deserialize(json["storage"]) : null,
|
||||
compute: json.containsKey("compute") ? ComputeItem().deserialize(json["compute"]) : null,
|
||||
workflow: json.containsKey("workflow") ? WorkflowItem().deserialize(json["workflow"]) : null,
|
||||
event: json.containsKey("event") ? WorkflowEventItem().deserialize(json["event"]) : null,
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() {
|
||||
@override Map<String, dynamic> serialize() {
|
||||
return {
|
||||
"id": id,
|
||||
"width": width,
|
||||
@@ -785,6 +797,7 @@ class GraphItem extends SerializerDeserializer<GraphItem> {
|
||||
"storage": storage?.serialize(),
|
||||
"compute": compute?.serialize(),
|
||||
"workflow": workflow?.serialize(),
|
||||
"event": event?.serialize(),
|
||||
"position": position?.serialize(),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user