1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use crate::{JobProcessStatus, TaskPlatform, TaskType};
use std::str::FromStr;

pub fn convert_process_status(status: String) -> JobProcessStatus {
    if status == *"Running" {
        JobProcessStatus::Running
    } else if status == *"Pending" {
        JobProcessStatus::Pending
    } else if status == *"Queued" {
        JobProcessStatus::Queued
    } else if status == *"Completed" {
        JobProcessStatus::Completed
    } else if status == *"Cancelled" {
        JobProcessStatus::Cancelled
    } else if status == *"Failed" {
        JobProcessStatus::Failed
    } else if status == *"Skipped" {
        JobProcessStatus::Skipped
    } else {
        JobProcessStatus::Pending
    }
}

pub fn convert_job_process_status(status: JobProcessStatus) -> String {
    match status {
        JobProcessStatus::Running => "Running".to_owned(),
        JobProcessStatus::Pending => "Pending".to_owned(),
        JobProcessStatus::Queued => "Queued".to_owned(),
        JobProcessStatus::Completed => "Completed".to_owned(),
        JobProcessStatus::Cancelled => "Cancelled".to_owned(),
        JobProcessStatus::Failed => "Failed".to_owned(),
        JobProcessStatus::Skipped => "Skipped".to_owned(),
    }
}

pub fn task_platform_from_string(value: String) -> TaskPlatform {
    TaskPlatform::from_str(value.as_str()).expect("error: ")
}

pub fn task_platform_to_string(platform: TaskPlatform) -> String {
    platform.to_string()
}

pub fn task_type_from_string(value: String) -> TaskType {
    TaskType::from_str(value.as_str()).expect("error: ")
}

pub fn task_type_to_string(platform: TaskType) -> String {
    platform.to_string()
}