All files / output zcl_abapgit_progress.clas.mjs

16.12% Statements 20/124
75% Branches 6/8
33.33% Functions 3/9
16.12% Lines 20/124

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 1241x 1x                   1x                                                                                                 6x 6x 6x 6x 6x     6x 6x 6x 6x         8x 8x 8x 8x 8x                                                                                   1x 1x 1x
const {cx_root} = await import("./cx_root.clas.mjs");
// zcl_abapgit_progress.clas.abap
class zcl_abapgit_progress {
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'ZCL_ABAPGIT_PROGRESS';
  static IMPLEMENTED_INTERFACES = ["ZIF_ABAPGIT_PROGRESS"];
  static ATTRIBUTES = {"GI_PROGRESS": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_PROGRESS", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_PROGRESS"});}, "visibility": "O", "is_constant": " ", "is_class": "X"},
  "MV_TOTAL": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "visibility": "O", "is_constant": " ", "is_class": " "},
  "MV_CV_TIME_NEXT": {"type": () => {return new abap.types.Time();}, "visibility": "I", "is_constant": " ", "is_class": " "},
  "MV_CV_DATUM_NEXT": {"type": () => {return new abap.types.Date();}, "visibility": "I", "is_constant": " ", "is_class": " "}};
  static METHODS = {"CALC_PCT": {"visibility": "O", "parameters": {"RV_PCT": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "is_optional": " "}, "IV_CURRENT": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "is_optional": " "}}},
  "SET_INSTANCE": {"visibility": "U", "parameters": {"II_PROGRESS": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_PROGRESS", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_PROGRESS"});}, "is_optional": " "}}},
  "GET_INSTANCE": {"visibility": "U", "parameters": {"RI_PROGRESS": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_PROGRESS", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_PROGRESS"});}, "is_optional": " "}, "IV_TOTAL": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "is_optional": " "}}}};
  #mv_cv_time_next;
  #mv_cv_datum_next;
  constructor() {
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
      "calc_pct": this.calc_pct.bind(this),
    };
    this.gi_progress = zcl_abapgit_progress.gi_progress;
    this.mv_total = new abap.types.Integer({qualifiedName: "I"});
    this.#mv_cv_time_next = new abap.types.Time();
    this.FRIENDS_ACCESS_INSTANCE["mv_cv_time_next"] = this.#mv_cv_time_next;
    this.#mv_cv_datum_next = new abap.types.Date();
    this.FRIENDS_ACCESS_INSTANCE["mv_cv_datum_next"] = this.#mv_cv_datum_next;
  }
  async constructor_(INPUT) {
    if (super.constructor_) { await super.constructor_(INPUT); }
    return this;
  }
  async calc_pct(INPUT) {
    let rv_pct = new abap.types.Integer({qualifiedName: "I"});
    let iv_current = INPUT?.iv_current;
    if (iv_current?.getQualifiedName === undefined || iv_current.getQualifiedName() !== "I") { iv_current = undefined; }
    if (iv_current === undefined) { iv_current = new abap.types.Integer({qualifiedName: "I"}).set(INPUT.iv_current); }
    let lv_f = new abap.types.Float({qualifiedName: "F"});
    try {
      lv_f.set(abap.operators.multiply(abap.operators.divide(iv_current,this.mv_total),abap.IntegerFactory.get(100)));
      rv_pct.set(lv_f);
      if (abap.compare.eq(rv_pct, abap.IntegerFactory.get(100))) {
        rv_pct.set(abap.IntegerFactory.get(99));
      } else if (abap.compare.eq(rv_pct, abap.IntegerFactory.get(0))) {
        rv_pct.set(abap.IntegerFactory.get(1));
      }
    } catch (e) {
      if ((abap.Classes['CX_SY_ZERODIVIDE'] && e instanceof abap.Classes['CX_SY_ZERODIVIDE'])) {
        rv_pct.set(abap.IntegerFactory.get(0));
      } else {
        throw e;
      }
    }
    return rv_pct;
  }
  async get_instance(INPUT) {
    return zcl_abapgit_progress.get_instance(INPUT);
  }
  static async get_instance(INPUT) {
    let ri_progress = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_PROGRESS", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_PROGRESS"});
    let iv_total = INPUT?.iv_total;
    if (iv_total?.getQualifiedName === undefined || iv_total.getQualifiedName() !== "I") { iv_total = undefined; }
    if (iv_total === undefined) { iv_total = new abap.types.Integer({qualifiedName: "I"}).set(INPUT.iv_total); }
    if (abap.compare.initial(zcl_abapgit_progress.gi_progress)) {
      zcl_abapgit_progress.gi_progress.set(await (new abap.Classes['ZCL_ABAPGIT_PROGRESS']()).constructor_());
    }
    await zcl_abapgit_progress.gi_progress.get().zif_abapgit_progress$set_total({iv_total: iv_total});
    ri_progress.set(zcl_abapgit_progress.gi_progress);
    return ri_progress;
  }
  async set_instance(INPUT) {
    return zcl_abapgit_progress.set_instance(INPUT);
  }
  static async set_instance(INPUT) {
    let ii_progress = INPUT?.ii_progress;
    if (ii_progress?.getQualifiedName === undefined || ii_progress.getQualifiedName() !== "ZIF_ABAPGIT_PROGRESS") { ii_progress = undefined; }
    if (ii_progress === undefined) { ii_progress = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_PROGRESS", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_PROGRESS"}).set(INPUT.ii_progress); }
    zcl_abapgit_progress.gi_progress.set(ii_progress);
  }
  async zif_abapgit_progress$off() {
    if (abap.FunctionModules['SAPGUI_PROGRESS_INDICATOR'] === undefined) { if (abap.Classes['CX_SY_DYN_CALL_ILLEGAL_FUNC'.trimEnd()] === undefined) { throw "CX_SY_DYN_CALL_ILLEGAL_FUNC not found"; } else { throw new abap.Classes['CX_SY_DYN_CALL_ILLEGAL_FUNC'.trimEnd()]();} }
    await abap.FunctionModules['SAPGUI_PROGRESS_INDICATOR']();
  }
  async zif_abapgit_progress$set_total(INPUT) {
    let iv_total = INPUT?.iv_total;
    if (iv_total?.getQualifiedName === undefined || iv_total.getQualifiedName() !== "I") { iv_total = undefined; }
    if (iv_total === undefined) { iv_total = new abap.types.Integer({qualifiedName: "I"}).set(INPUT.iv_total); }
    this.mv_total.set(iv_total);
    this.#mv_cv_time_next.clear();
    this.#mv_cv_datum_next.clear();
  }
  async zif_abapgit_progress$show(INPUT) {
    let iv_current = INPUT?.iv_current;
    if (iv_current?.getQualifiedName === undefined || iv_current.getQualifiedName() !== "I") { iv_current = undefined; }
    if (iv_current === undefined) { iv_current = new abap.types.Integer({qualifiedName: "I"}).set(INPUT.iv_current); }
    let iv_text = INPUT?.iv_text;
    let lv_pct = new abap.types.Integer({qualifiedName: "I"});
    let lv_time = new abap.types.Time({qualifiedName: "T"});
    let lc_wait_secs = new abap.types.Integer({qualifiedName: "I"});
    lc_wait_secs.set(2);
    abap.statements.getTime();
    lv_time.set(abap.builtin.sy.get().uzeit);
    if (abap.compare.initial(this.#mv_cv_time_next) && abap.compare.initial(this.#mv_cv_datum_next)) {
      this.#mv_cv_time_next.set(lv_time);
      this.#mv_cv_datum_next.set(abap.builtin.sy.get().datum);
    }
    if (abap.compare.ge(lv_time, this.#mv_cv_time_next) && abap.compare.eq(abap.builtin.sy.get().datum, this.#mv_cv_datum_next) || abap.compare.gt(abap.builtin.sy.get().datum, this.#mv_cv_datum_next)) {
      lv_pct.set((await this.calc_pct({iv_current: iv_current})));
      if (abap.FunctionModules['SAPGUI_PROGRESS_INDICATOR'] === undefined) { if (abap.Classes['CX_SY_DYN_CALL_ILLEGAL_FUNC'.trimEnd()] === undefined) { throw "CX_SY_DYN_CALL_ILLEGAL_FUNC not found"; } else { throw new abap.Classes['CX_SY_DYN_CALL_ILLEGAL_FUNC'.trimEnd()]();} }
      await abap.FunctionModules['SAPGUI_PROGRESS_INDICATOR']({exporting: {percentage: lv_pct, text: iv_text}});
      this.#mv_cv_time_next.set(abap.operators.add(lv_time,lc_wait_secs));
    }
    if (abap.compare.gt(abap.builtin.sy.get().datum, this.#mv_cv_datum_next)) {
      this.#mv_cv_datum_next.set(abap.builtin.sy.get().datum);
    }
    if (abap.compare.lt(this.#mv_cv_time_next, lv_time)) {
      this.#mv_cv_datum_next.set(abap.operators.add(abap.builtin.sy.get().datum,abap.IntegerFactory.get(1)));
    }
  }
}
abap.Classes['ZCL_ABAPGIT_PROGRESS'] = zcl_abapgit_progress;
zcl_abapgit_progress.gi_progress = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_PROGRESS", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_PROGRESS"});
export {zcl_abapgit_progress};