import {
  relationType,
  ifType,
  conditionMethodType,
  assignMethodType,
  valueType,
  groupType,
} from "@/enums/process";
export class process implements IProcess {
  constructor(id?: string) {
    if (id) {
      this.id = id;
    }
  }
  public id = "";
  public name = "未命名";
  public relation = relationType.and;
  public assemble = new Array<IAssemble>();
}
export class assemble implements IAssemble {
  constructor(id?: string) {
    if (id) {
      this.id = id;
    }
  }
  public id = "";
  public remark = "";
  public condition = new condition();
  public return = "";
  public assign = new Array<IAssign>();
}
export class assign implements IAssign {
  constructor(id?: string) {
    if (id) {
      this.id = id;
    }
  }
  public id = "";
  public label = "";
  public method = assignMethodType.equal;
  public value = "";
}
export class condition implements ICondition {
  constructor(id?: string) {
    if (id) {
      this.id = id;
    }
  }
  public id = "";
  public relation = relationType.and;
  public group = new Array<IGroup>();
}
class group implements IGroup {
  constructor(id?: string, type = groupType.judge) {
    this.type = type;
    if (id) {
      switch (type) {
        case groupType.condition:
          this.data = new condition(id);
          break;
        case groupType.judge:
        default:
          this.data = new judge(id);
          break;
      }
    } else {
      this.data = new judge();
    }
  }
  public type = groupType.judge;
  public data: judge | condition;
}
export class conditionContainer extends group {
  constructor(id?: string) {
    super();
    if (id) {
      this.data = new condition(id);
    }
  }
  public type = groupType.condition;
  public data = new condition();
}
export class judgeContainer extends group {
  constructor(id?: string, type = groupType.judge) {
    super();
    this.type = type;
    if (id) {
      this.data = new judge(id);
    }
  }

  public type = groupType.judge;
  public data = new judge();
}
export class judge implements IJudge {
  constructor(id?: string) {
    if (id) {
      this.id = id;
    }
  }
  public if = new ifValue();
  public method = conditionMethodType.equal;
  public value = new valueValue();
  public id = "";
}
export class ifValue implements IIf {
  constructor(id?: string) {
    if (id) {
      this.id = id;
    }
  }
  public type = ifType.attributeValue;
  public id = "";
  public label = "";
}
export class valueValue implements IValue {
  constructor(id?: string) {
    if (id) {
      this.id = id;
    }
  }
  public type = valueType.attributeValue;
  public id = "";
  public label = "";
}
