381 lines
13 KiB
Dart
381 lines
13 KiB
Dart
|
import 'package:oc_front/models/abstract.dart';
|
||
|
|
||
|
const List<ComputingItem> _emptyComputing = [];
|
||
|
const List<DataItem> _emptyData = [];
|
||
|
const List<DataCenterItem> _emptyDataCenter = [];
|
||
|
const List<StorageItem> _emptyStorage = [];
|
||
|
class Search extends SerializerDeserializer<Search> {
|
||
|
Search({
|
||
|
this.computing = _emptyComputing,
|
||
|
this.datacenter = _emptyDataCenter,
|
||
|
this.data = _emptyData,
|
||
|
this.storage = _emptyStorage,
|
||
|
});
|
||
|
List<ComputingItem> computing;
|
||
|
List<DataCenterItem> datacenter;
|
||
|
List<DataItem> data;
|
||
|
List<StorageItem> storage;
|
||
|
@override deserialize(dynamic json) {
|
||
|
json = json as Map<String, dynamic>;
|
||
|
return Search(
|
||
|
computing: json.containsKey("computing") ? fromListJson(json["computing"], ComputingItem()) : [],
|
||
|
datacenter: json.containsKey("datacenter") ? fromListJson(json["datacenter"], DataCenterItem()) : [],
|
||
|
data: json.containsKey("data") ? fromListJson(json["data"], DataItem()) : [],
|
||
|
storage: json.containsKey("storage") ? fromListJson(json["storage"], StorageItem()) : [],
|
||
|
);
|
||
|
}
|
||
|
@override Map<String, dynamic> serialize() => {};
|
||
|
}
|
||
|
const List<String> _empty = [];
|
||
|
abstract class AbstractItem {
|
||
|
String? id;
|
||
|
String? name;
|
||
|
String? logo;
|
||
|
String? type;
|
||
|
String? owner;
|
||
|
String? description;
|
||
|
String? shortDescription;
|
||
|
String topic = "";
|
||
|
}
|
||
|
|
||
|
Type? getTopicType(String topic) {
|
||
|
if (topic == "computing") { return ComputingItem; }
|
||
|
else if (topic == "data") { return DataItem; }
|
||
|
else if (topic == "datacenter") { return DataCenterItem; }
|
||
|
else if (topic == "storage") { return StorageItem; }
|
||
|
else { return null; }
|
||
|
}
|
||
|
|
||
|
String getTopic(Type type) {
|
||
|
if (type == ComputingItem) { return "computing"; }
|
||
|
if (type == DataItem) { return "data"; }
|
||
|
if (type == DataCenterItem) { return "datacenter"; }
|
||
|
if (type == StorageItem) { return "storage"; }
|
||
|
return "";
|
||
|
}
|
||
|
|
||
|
bool isComputing(String topic) => topic == "computing";
|
||
|
bool isData(String topic) => topic == "data";
|
||
|
bool isDataCenter(String topic) => topic == "datacenter";
|
||
|
bool isStorage(String topic) => topic == "storage";
|
||
|
|
||
|
class ComputingItem extends SerializerDeserializer<ComputingItem> implements AbstractItem {
|
||
|
ComputingItem({
|
||
|
this.id,
|
||
|
this.name,
|
||
|
this.logo,
|
||
|
this.type,
|
||
|
this.owner,
|
||
|
this.price,
|
||
|
this.image,
|
||
|
this.command,
|
||
|
this.licence,
|
||
|
this.description,
|
||
|
this.requirements,
|
||
|
this.ports = _empty,
|
||
|
this.shortDescription,
|
||
|
this.dinputs = _empty,
|
||
|
this.doutputs = _empty,
|
||
|
this.arguments = _empty,
|
||
|
this.environment = _empty,
|
||
|
});
|
||
|
@override String? id;
|
||
|
@override String? name;
|
||
|
@override String? logo;
|
||
|
@override String? type;
|
||
|
@override String? owner;
|
||
|
@override String topic = "computing";
|
||
|
double? price;
|
||
|
String? image;
|
||
|
String? command;
|
||
|
String? licence;
|
||
|
List<dynamic> ports;
|
||
|
List<dynamic> dinputs;
|
||
|
List<dynamic> doutputs;
|
||
|
List<dynamic> arguments;
|
||
|
@override String? description;
|
||
|
@override String? shortDescription;
|
||
|
List<dynamic> environment;
|
||
|
ExecRequirements? requirements;
|
||
|
|
||
|
@override deserialize(dynamic json) {
|
||
|
try { json = json as Map<String, dynamic>;
|
||
|
} catch (e) { return ComputingItem(); }
|
||
|
return ComputingItem(
|
||
|
id: json.containsKey("ID") ? json["ID"] : null,
|
||
|
name: json.containsKey("name") ? json["name"] : null,
|
||
|
logo: json.containsKey("logo") ? json["logo"] : null,
|
||
|
type: json.containsKey("type") ? json["type"] : null,
|
||
|
owner: json.containsKey("owner") ? json["owner"] : null,
|
||
|
price: json.containsKey("price") ? json["price"]?.toDouble() : null,
|
||
|
image: json.containsKey("image") ? json["image"] : null,
|
||
|
command: json.containsKey("command") ? json["command"] : null,
|
||
|
licence: json.containsKey("licence") ? json["licence"] : null,
|
||
|
description: json.containsKey("description") ? json["description"] : null,
|
||
|
ports: json["ports"] ?? [],
|
||
|
shortDescription: json.containsKey("short_description") ? json["short_description"] : null,
|
||
|
dinputs: json["dinputs"] ?? [],
|
||
|
doutputs: json["doutputs"] ?? [],
|
||
|
arguments: json["arguments"] ?? [],
|
||
|
environment: json["environment"] ?? [],
|
||
|
requirements: json.containsKey("requirements") ? ExecRequirements().deserialize(json["execution_requirements"]) : null,
|
||
|
);
|
||
|
}
|
||
|
@override Map<String, dynamic> serialize() => {};
|
||
|
}
|
||
|
|
||
|
class ExecRequirements extends SerializerDeserializer<ExecRequirements> {
|
||
|
ExecRequirements({
|
||
|
this.ram,
|
||
|
this.cpus,
|
||
|
this.gpus,
|
||
|
this.diskIO,
|
||
|
this.scallingModel,
|
||
|
this.parallel = false,
|
||
|
});
|
||
|
double? ram;
|
||
|
double? cpus;
|
||
|
double? gpus;
|
||
|
String? diskIO;
|
||
|
bool parallel = false;
|
||
|
double? scallingModel;
|
||
|
|
||
|
@override deserialize(dynamic json) {
|
||
|
try { json = json as Map<String, dynamic>;
|
||
|
} catch (e) { return ExecRequirements(); }
|
||
|
return ExecRequirements(
|
||
|
ram: json.containsKey("ram") ? json["ram"]?.toDouble() : null,
|
||
|
cpus: json.containsKey("cpus") ? json["cpus"]?.toDouble() : null,
|
||
|
gpus: json.containsKey("gpus") ? json["gpus"]?.toDouble() : null,
|
||
|
diskIO: json.containsKey("disk_io") ? json["disk_io"] : null,
|
||
|
scallingModel: json.containsKey("scaling_model") ? json["scaling_model"]?.toDouble() : null,
|
||
|
parallel: json.containsKey("parallel") ? json["parallel"] : false,
|
||
|
);
|
||
|
}
|
||
|
@override Map<String, dynamic> serialize() => {};
|
||
|
}
|
||
|
|
||
|
class DataItem extends SerializerDeserializer<DataItem> implements AbstractItem {
|
||
|
DataItem({
|
||
|
this.id,
|
||
|
this.name,
|
||
|
this.logo,
|
||
|
this.type,
|
||
|
this.dtype,
|
||
|
this.owner,
|
||
|
this.example,
|
||
|
this.location,
|
||
|
this.description,
|
||
|
this.protocol = _empty,
|
||
|
this.shortDescription,
|
||
|
});
|
||
|
@override String? id;
|
||
|
@override String? name;
|
||
|
@override String? logo;
|
||
|
@override String? type;
|
||
|
@override String topic = "data";
|
||
|
String? dtype;
|
||
|
String? example;
|
||
|
String? location;
|
||
|
@override String? description;
|
||
|
List<dynamic> protocol;
|
||
|
@override String? shortDescription;
|
||
|
@override String? owner;
|
||
|
|
||
|
@override deserialize(dynamic json) {
|
||
|
try { json = json as Map<String, dynamic>;
|
||
|
} catch (e) { return DataItem(); }
|
||
|
return DataItem(
|
||
|
id: json.containsKey("ID") ? json["ID"] : null,
|
||
|
name: json.containsKey("name") ? json["name"] : null,
|
||
|
logo: json.containsKey("logo") ? json["logo"] : null,
|
||
|
type: json.containsKey("type") ? json["type"] : null,
|
||
|
owner: json.containsKey("owner") ? json["owner"] : null,
|
||
|
dtype: json.containsKey("dtype") ? json["dtype"] : null,
|
||
|
example: json.containsKey("example") ? json["example"] : null,
|
||
|
location: json.containsKey("location") ? json["location"] : null,
|
||
|
description: json.containsKey("description") ? json["description"] : null,
|
||
|
protocol: json["protocol"] ?? [],
|
||
|
shortDescription: json.containsKey("short_description") ? json["short_description"] : null
|
||
|
);
|
||
|
}
|
||
|
@override Map<String, dynamic> serialize() => {};
|
||
|
}
|
||
|
const List<GPU> _emptyGPU = [];
|
||
|
class DataCenterItem extends SerializerDeserializer<DataCenterItem> implements AbstractItem {
|
||
|
DataCenterItem({
|
||
|
this.id,
|
||
|
this.cpu,
|
||
|
this.ram,
|
||
|
this.name,
|
||
|
this.logo,
|
||
|
this.type,
|
||
|
this.owner,
|
||
|
this.acronym,
|
||
|
this.bookingPrice,
|
||
|
this.description,
|
||
|
this.hosts = _empty,
|
||
|
this.gpus = _emptyGPU,
|
||
|
this.shortDescription,
|
||
|
});
|
||
|
CPU? cpu;
|
||
|
RAM? ram;
|
||
|
@override String? id;
|
||
|
@override String? name;
|
||
|
@override String? logo;
|
||
|
@override String? type;
|
||
|
@override String? owner;
|
||
|
@override String topic = "datacenter";
|
||
|
String? acronym;
|
||
|
List<GPU> gpus = [];
|
||
|
@override String? description;
|
||
|
List<dynamic> hosts;
|
||
|
double? bookingPrice;
|
||
|
@override String? shortDescription;
|
||
|
|
||
|
@override deserialize(dynamic json) {
|
||
|
try { json = json as Map<String, dynamic>;
|
||
|
} catch (e) { return DataCenterItem(); }
|
||
|
return DataCenterItem(
|
||
|
id: json.containsKey("ID") ? json["ID"] : null,
|
||
|
ram: json.containsKey("ram") ? RAM().deserialize(json["ram"]) : null,
|
||
|
cpu: json.containsKey("cpu") ? CPU().deserialize(json["cpu"]) : null,
|
||
|
acronym: json.containsKey("acronym") ? json["acronym"] : null,
|
||
|
name: json.containsKey("name") ? json["name"] : null,
|
||
|
logo: json.containsKey("logo") ? json["logo"] : null,
|
||
|
type: json.containsKey("type") ? json["type"] : null,
|
||
|
owner: json.containsKey("owner") ? json["owner"] : null,
|
||
|
bookingPrice: json.containsKey("bookingPrice") ? json["bookingPrice"]?.toDouble() : null,
|
||
|
description: json.containsKey("description") ? json["description"] : null,
|
||
|
hosts: json["hosts"] ?? [],
|
||
|
shortDescription: json.containsKey("short_description") ? json["short_description"] : null,
|
||
|
gpus: json.containsKey("gpus") ? fromListJson(json["gpus"] ?? [], GPU()) : [],
|
||
|
);
|
||
|
}
|
||
|
@override Map<String, dynamic> serialize() => {};
|
||
|
}
|
||
|
class CPU extends SerializerDeserializer<CPU> {
|
||
|
CPU({
|
||
|
this.cores,
|
||
|
this.platform,
|
||
|
this.architecture,
|
||
|
this.minimumMemory,
|
||
|
this.shared = false,
|
||
|
});
|
||
|
double? cores;
|
||
|
String? platform;
|
||
|
bool shared = false;
|
||
|
String? architecture;
|
||
|
double? minimumMemory;
|
||
|
|
||
|
@override deserialize(dynamic json) {
|
||
|
try { json = json as Map<String, dynamic>;
|
||
|
} catch (e) { return CPU(); }
|
||
|
return CPU(
|
||
|
cores: json.containsKey("cores") ? json["cores"]?.toDouble() : null,
|
||
|
platform: json.containsKey("platform") ? json["platform"] : null,
|
||
|
architecture: json.containsKey("architecture") ? json["architecture"] : null,
|
||
|
minimumMemory: json.containsKey("minimumMemory") ? json["minimumMemory"]?.toDouble() : null,
|
||
|
shared: json.containsKey("shared") ? json["shared"] : false,
|
||
|
);
|
||
|
}
|
||
|
@override Map<String, dynamic> serialize() => {};
|
||
|
}
|
||
|
class GPU extends SerializerDeserializer<GPU> {
|
||
|
GPU({
|
||
|
this.cudaCores,
|
||
|
this.memory,
|
||
|
this.model,
|
||
|
this.tensorCores,
|
||
|
});
|
||
|
double? cudaCores;
|
||
|
double? memory;
|
||
|
String? model;
|
||
|
double? tensorCores;
|
||
|
|
||
|
@override deserialize(dynamic json) {
|
||
|
try { json = json as Map<String, dynamic>;
|
||
|
} catch (e) { return GPU(); }
|
||
|
return GPU(
|
||
|
cudaCores: json.containsKey("cuda_cores") ? json["cuda_cores"]?.toDouble() : null,
|
||
|
memory: json.containsKey("memory") ? json["memory"]?.toDouble() : null,
|
||
|
model: json.containsKey("model") ? json["model"] : null,
|
||
|
tensorCores: json.containsKey("tensor_cores") ? json["tensor_cores"]?.toDouble() : null,
|
||
|
);
|
||
|
}
|
||
|
@override Map<String, dynamic> serialize() => {};
|
||
|
}
|
||
|
class RAM extends SerializerDeserializer<RAM> {
|
||
|
RAM({
|
||
|
this.ecc = false,
|
||
|
this.size,
|
||
|
});
|
||
|
bool ecc = false;
|
||
|
double? size;
|
||
|
|
||
|
@override deserialize(dynamic json) {
|
||
|
try { json = json as Map<String, dynamic>;
|
||
|
} catch (e) { return RAM(); }
|
||
|
return RAM(
|
||
|
ecc: json.containsKey("ecc") ? json["ecc"] : false,
|
||
|
size: json.containsKey("size") ? json["size"]?.toDouble() : null,
|
||
|
);
|
||
|
}
|
||
|
@override Map<String, dynamic> serialize() => {};
|
||
|
}
|
||
|
class StorageItem extends SerializerDeserializer<StorageItem> implements AbstractItem {
|
||
|
StorageItem({
|
||
|
this.id,
|
||
|
this.url,
|
||
|
this.size,
|
||
|
this.name,
|
||
|
this.logo,
|
||
|
this.type,
|
||
|
this.owner,
|
||
|
this.acronym,
|
||
|
this.throughput,
|
||
|
this.redundancy,
|
||
|
this.description,
|
||
|
this.bookingPrice,
|
||
|
this.shortDescription,
|
||
|
this.encryption = false,
|
||
|
});
|
||
|
@override String? id;
|
||
|
String? url;
|
||
|
@override String? name;
|
||
|
@override String? logo;
|
||
|
@override String? type;
|
||
|
@override String topic = "storage";
|
||
|
double? size;
|
||
|
@override String? owner;
|
||
|
String? acronym;
|
||
|
String? redundancy;
|
||
|
String? throughput;
|
||
|
@override String? description;
|
||
|
double? bookingPrice;
|
||
|
bool encryption = false;
|
||
|
@override String? shortDescription;
|
||
|
|
||
|
|
||
|
@override deserialize(dynamic json) {
|
||
|
try { json = json as Map<String, dynamic>;
|
||
|
} catch (e) { return StorageItem(); }
|
||
|
return StorageItem(
|
||
|
id: json.containsKey("ID") ? json["ID"] : null,
|
||
|
url: json.containsKey("URL") ? json["URL"] : null,
|
||
|
size: json.containsKey("size") ? json["size"]?.toDouble() : null,
|
||
|
name: json.containsKey("name") ? json["name"] : null,
|
||
|
logo: json.containsKey("logo") ? json["logo"] : null,
|
||
|
type: json.containsKey("type") ? json["type"] : null,
|
||
|
owner: json.containsKey("owner") ? json["owner"] : null,
|
||
|
acronym: json.containsKey("DCacronym") ? json["DCacronym"] : null,
|
||
|
bookingPrice: json.containsKey("bookingPrice") ? json["bookingPrice"]?.toDouble() : null,
|
||
|
description: json.containsKey("description") ? json["description"] : null,
|
||
|
throughput: json.containsKey("throughput") ? json["throughput"] : [],
|
||
|
shortDescription: json.containsKey("short_description") ? json["short_description"] : null,
|
||
|
redundancy: json.containsKey("redundancy") ? json["redundancy"] : [],
|
||
|
encryption: json.containsKey("encryption") ? json["encryption"] : false,
|
||
|
);
|
||
|
}
|
||
|
@override Map<String, dynamic> serialize() => {};
|
||
|
}
|