All files / output zcl_abapgit_sap_namespace.clas.mjs

46.36% Statements 51/110
80% Branches 16/20
66.66% Functions 4/6
46.36% Lines 51/110

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 1101x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x                                                   1x                                                   1x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x               9x 6x 6x 9x 3x 1x   2x 2x 9x 2x   6x 9x 1x 1x 1x
const {cx_root} = await import("./cx_root.clas.mjs");
// zcl_abapgit_sap_namespace.clas.abap
class zcl_abapgit_sap_namespace {
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'ZCL_ABAPGIT_SAP_NAMESPACE';
  static IMPLEMENTED_INTERFACES = ["ZIF_ABAPGIT_SAP_NAMESPACE"];
  static ATTRIBUTES = {};
  static METHODS = {};
  constructor() {
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
    };
  }
  async constructor_(INPUT) {
    if (super.constructor_) { await super.constructor_(INPUT); }
    return this;
  }
  async zif_abapgit_sap_namespace$exists(INPUT) {
    let rv_yes = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
    let iv_namespace = INPUT?.iv_namespace;
    if (iv_namespace === undefined) { iv_namespace = new abap.types.Character(10, {}).set(INPUT.iv_namespace); }
    let lv_editflag = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOLEAN","ddicName":"ABAP_BOOLEAN","description":"ABAP_BOOLEAN"});
    let lo_obj = new abap.types.ABAPObject({qualifiedName: undefined, RTTIName: undefined});
    let lo_nsp = new abap.types.ABAPObject({qualifiedName: undefined, RTTIName: undefined});
    let fs_lg_obj_ = new abap.types.FieldSymbol(new abap.types.Character(4));
    try {
      await abap.statements.select(lv_editflag, {select: "SELECT editflag FROM " + abap.buildDbTableName("trnspace") + " WHERE \"namespace\" = '" + iv_namespace.get() + "' UP TO 1 ROWS"});
      rv_yes.set(abap.builtin.boolc(abap.compare.eq(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0))));
    } catch (e) {
      if ((abap.Classes['CX_SY_DYNAMIC_OSQL_ERROR'] && e instanceof abap.Classes['CX_SY_DYNAMIC_OSQL_ERROR'])) {
        abap.statements.assign({target: fs_lg_obj_, dynamicName: 'XCO_CP_SYSTEM=>NAMESPACE', dynamicSource: (() => {
            try { return xco_cp_system; } catch {}
            try { return this.xco_cp_system; } catch {}
        })()});
        lo_obj.set(fs_lg_obj_);
        lo_nsp.set(await abap.dynamicCallLookup(lo_obj.get(), "if_xco_cp_namespace_factory$for")({iv_value: iv_namespace}));
        rv_yes.set(await abap.dynamicCallLookup(lo_nsp.get(), "if_xco_cp_namespace$exists")());
      } else {
        throw e;
      }
    }
    return rv_yes;
  }
  async zif_abapgit_sap_namespace$is_editable(INPUT) {
    let rv_yes = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
    let iv_namespace = INPUT?.iv_namespace;
    if (iv_namespace === undefined) { iv_namespace = new abap.types.Character(10, {}).set(INPUT.iv_namespace); }
    let lv_editflag = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOLEAN","ddicName":"ABAP_BOOLEAN","description":"ABAP_BOOLEAN"});
    let lo_obj = new abap.types.ABAPObject({qualifiedName: undefined, RTTIName: undefined});
    let lo_nsp = new abap.types.ABAPObject({qualifiedName: undefined, RTTIName: undefined});
    let fs_lg_obj_ = new abap.types.FieldSymbol(new abap.types.Character(4));
    try {
      await abap.statements.select(lv_editflag, {select: "SELECT editflag FROM " + abap.buildDbTableName("trnspace") + " WHERE \"namespace\" = '" + iv_namespace.get() + "' UP TO 1 ROWS"});
      rv_yes.set(abap.builtin.boolc(abap.compare.eq(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0)) && abap.compare.eq(lv_editflag, abap.CharacterFactory.get(1, 'X'))));
    } catch (e) {
      if ((abap.Classes['CX_SY_DYNAMIC_OSQL_ERROR'] && e instanceof abap.Classes['CX_SY_DYNAMIC_OSQL_ERROR'])) {
        abap.statements.assign({target: fs_lg_obj_, dynamicName: 'XCO_CP_SYSTEM=>NAMESPACE', dynamicSource: (() => {
            try { return xco_cp_system; } catch {}
            try { return this.xco_cp_system; } catch {}
        })()});
        lo_obj.set(fs_lg_obj_);
        lo_nsp.set(await abap.dynamicCallLookup(lo_obj.get(), "if_xco_cp_namespace_factory$for")({iv_value: iv_namespace}));
        rv_yes.set(await abap.dynamicCallLookup(lo_nsp.get(), "if_xco_cp_namespace$is_changeable")());
      } else {
        throw e;
      }
    }
    return rv_yes;
  }
  async zif_abapgit_sap_namespace$split_by_name(INPUT) {
    let rs_obj_namespace = new abap.types.Structure({
    "namespace": new abap.types.Character(10, {}),
    "obj_without_namespace": new abap.types.Character(40, {})}, "zif_abapgit_definitions=>ty_obj_namespace", undefined, {}, {});
    let iv_obj_with_namespace = INPUT?.iv_obj_with_namespace;
    let iv_allow_slash_in_name = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
    if (INPUT && INPUT.iv_allow_slash_in_name) {iv_allow_slash_in_name.set(INPUT.iv_allow_slash_in_name);}
    if (INPUT === undefined || INPUT.iv_allow_slash_in_name === undefined) {iv_allow_slash_in_name = abap.builtin.abap_true;}
    let lv_regex = new abap.types.String({qualifiedName: "STRING"});
    let lv_length = new abap.types.Integer({qualifiedName: "I"});
    let lr_ex = new abap.types.ABAPObject({qualifiedName: "CX_ROOT", RTTIName: "\\CLASS=CX_ROOT"});
    lv_regex.set(abap.CharacterFactory.get(15, '^\\/[^\\/]{1,8}\\/'));
    try {
      abap.statements.find(iv_obj_with_namespace, {regex: lv_regex, length: lv_length});
    } catch (e) {
      if ((abap.Classes['CX_ROOT'] && e instanceof abap.Classes['CX_ROOT'])) {
        lr_ex.set(e);
        await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise({iv_text: (await lr_ex.get().if_message$get_text())});
      } else {
        throw e;
      }
    }
    if (abap.compare.eq(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0)) && abap.compare.gt(lv_length, abap.IntegerFactory.get(1))) {
      rs_obj_namespace.get().namespace.set(iv_obj_with_namespace.getOffset({length: lv_length}));
      rs_obj_namespace.get().obj_without_namespace.set(iv_obj_with_namespace.getOffset({offset: lv_length}));
    } else {
      if (abap.compare.eq(iv_obj_with_namespace.getOffset({length: 1}), abap.CharacterFactory.get(1, '/'))) {
        await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise({iv_text: new abap.types.String().set(`The object ${abap.templateFormatting(iv_obj_with_namespace)} has an invalid namespace`)});
      }
      rs_obj_namespace.get().obj_without_namespace.set(iv_obj_with_namespace);
    }
    if (abap.compare.eq(iv_allow_slash_in_name, abap.builtin.abap_false) && abap.compare.ca(rs_obj_namespace.get().obj_without_namespace, abap.CharacterFactory.get(1, '/'))) {
      await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise({iv_text: new abap.types.String().set(`Object without namespace ${abap.templateFormatting(rs_obj_namespace.get().obj_without_namespace)} contains a '/'`)});
    }
    return rs_obj_namespace;
  }
}
abap.Classes['ZCL_ABAPGIT_SAP_NAMESPACE'] = zcl_abapgit_sap_namespace;
export {zcl_abapgit_sap_namespace};