TableUtils - 전역

  • 릴리스 버전: Xanadu
  • 업데이트 날짜 2024년 08월 01일
  • 읽기13분
  • TableUtils 스크립트 포함은 테이블 관련 정보에 액세스하기 위한 바로 가기를 제공합니다.

    이 클래스는 서버 측 스크립트에 사용할 수 있습니다.

    TableUtils - TableUtils(문자열 tableName)

    TableUtils 클래스의 인스턴스를 만듭니다.

    표 1. 매개변수
    이름 유형 설명
    tableName 문자열 테이블 이름
    var tu = new TableUtils("incident");

    TableUtils - 드롭(문자열 tableName)

    데이터베이스 테이블을 삭제합니다.

    주:
    각별히 주의해서 사용하십시오. 테이블을 삭제하면 테이블과 모든 데이터가 영구적으로 삭제됩니다. 테이블이 확장된 경우 dropTableAndExtensions를 사용합니다.
    표 2. 매개변수
    이름 유형 설명
    tableName 문자열 삭제할 테이블의 이름
    표 3. 반환
    유형 설명
    void
    var tu = new TableUtils();
    tu.drop("table_that_will_be_lost_forever");
    출력:
    dropping table table_that_will_be_lost_forever
    Starting cache flush
    Cache flush complete
    TABLE DROP: admin dropped table table_that_will_be_lost_forever

    TableUtils - dropAndClean(문자열 tableName)

    데이터베이스 테이블을 삭제하고 테이블에 대한 참조를 정리합니다.

    주:
    각별히 주의해서 사용하십시오. 데이터베이스 테이블을 삭제하면 테이블과 모든 데이터가 영구적으로 삭제됩니다. 테이블이 확장된 경우 dropTableAndExtensions를 사용합니다.
    표 4. 매개변수
    이름 유형 설명
    tableName 문자열 삭제할 테이블의 이름
    표 5. 반환
    유형 설명
    void
    var tu = new TableUtils();
    tu.dropAndClean("table_that_will_be_lost_forever");
    출력:
    dropping table table_that_will_be_lost_forever
    Starting cache flush
    Cache flush complete
    TABLE DROP: admin dropped table table_that_will_be_lost_forever
    *** Script: removing gauges for table_that_will_be_lost_forever
    *** Script: removing forms for table_that_will_be_lost_forever
    *** Script: removing styles for table_that_will_be_lost_forever
    *** Script: removing forms sections for table_that_will_be_lost_forever
    *** Script: removing lists for table_that_will_be_lost_forever
    *** Script: removing related lists for table_that_will_be_lost_forever
    *** Script: removing references to table_that_will_be_lost_forever
    *** Script: removing dictionary entries for table_that_will_be_lost_forever
    Background message, type:info, message: Table deleted

    TableUtils - dropTableAndExtensions(문자열 tableName)

    데이터베이스 테이블과 모든 확장 테이블을 삭제하고 테이블에 대한 참조를 정리합니다.

    주:
    각별히 주의해서 사용하십시오. 데이터베이스 테이블을 삭제하면 테이블과 모든 데이터가 영구적으로 삭제됩니다.
    표 6. 매개변수
    이름 유형 설명
    tableName 문자열 삭제할 테이블
    표 7. 반환
    유형 설명
    void
    var tu = new TableUtils();
    tu.dropTableAndExtensions("table_that_will_be_lost_forever");
    출력:
    dropping table parent_table_that_will_be_lost_forever
    Starting cache flush
    Cache flush complete
    TABLE DROP: admin dropped table ext_table_that_will_be_lost_forever
    removing gauges for ext_table_that_will_be_lost_forever
    removing forms for ext_table_that_will_be_lost_forever
    removing styles for ext_table_that_will_be_lost_forever
    removing forms sections for ext_table_that_will_be_lost_forever
    removing lists for ext_table_that_will_be_lost_forever
    removing related lists for ext_table_that_will_be_lost_forever
    removing references to ext_table_that_will_be_lost_forever
    removing dictionary entries for ext_table_that_will_be_lost_forever
    Background message, type:info, message: Table deleted
    dropping table parent_table_that_will_be_lost_forever
    Starting cache flush
    Cache flush complete
    TABLE DROP: admin dropped table parent_table_that_will_be_lost_forever
    removing gauges for parent_table_that_will_be_lost_forever
    removing forms for parent_table_that_will_be_lost_forever
    removing styles for parent_table_that_will_be_lost_forever
    removing forms sections for parent_table_that_will_be_lost_forever
    removing lists for parent_table_that_will_be_lost_forever
    removing related lists for parent_table_that_will_be_lost_forever
    removing references to parent_table_that_will_be_lost_forever
    removing dictionary entries for parent_table_that_will_be_lost_forever
    Background message, type:info, message: Table deleted

    TableUtils - getAbsoluteBase()

    테이블이 확장된 기본 테이블 이름을 반환합니다.

    주:
    cmdb_ci 계층 구조 아래 테이블에 대해 이 메서드는 실제 기본 테이블인 cmdb가 아닌 cmdb_ci 반환합니다.
    표 8. 매개변수
    이름 유형 설명
    없음
    표 9. 반환
    유형 설명
    문자열 기본 테이블 이름
    var table = new TableUtils("cmdb_ci_server");
    gs.print(table.getAbsoluteBase());

    출력: cmdb_ci

    TableUtils - getAllExtensions()

    기본 테이블을 포함하여 테이블을 확장하는 테이블 목록을 반환합니다.

    표 10. 매개변수
    이름 유형 설명
    없음
    표 11. 반환
    유형 설명
    배열 목록 기본 테이블을 포함하여 테이블을 확장하는 테이블 목록입니다.
    var table = new TableUtils("task");
    gs.print(table.getAllExtensions());
    출력:
    [task, incident, issue, kb_submission, sysapproval_group, change_request, change_request_imac, sc_task, 
    problem, sc_req_item, ticket, ast_transfer_order, planned_task, change_task, change_phase, sc_request]

    TableUtils - getHierarchy()

    지정된 테이블의 계층 구조에 포함되는 모든 클래스의 목록을 반환합니다.

    표 12. 매개변수
    이름 유형 설명
    없음
    표 13. 반환
    유형 설명
    배열 목록 지정된 테이블의 계층 구조에 있는 모든 클래스의 목록입니다.
    var table = new TableUtils("cmdb_ci_server");
    gs.print(table.getHierarchy());

    출력: [cmdb_ci_server, cmdb_ci_computer, cmdb_ci_hardware, cmdb_ci, cmdb_ci_mainframe, cmdb_ci_linux_server, cmdb_ci_mainframe_lpar, cmdb_ci_esx_server, cmdb_ci_unix_server, cmdb_ci_solaris_server, cmdb_ci_hpux_server, cmdb_ci_aix_server, cmdb_ci_osx_server, cmdb_ci_netware_server, cmdb_ci_win_server]

    TableUtils - getTables()

    테이블 계층 구조를 반환합니다.

    표 14. 매개변수
    이름 유형 설명
    없음
    표 15. 반환
    유형 설명
    배열 목록 상위 계층 구조의 테이블 이름 목록입니다.
    // Get the hierarchy of tables
    var table = new TableUtils("cmdb_ci_computer");
    var tableArrayList = table.getTables();
    
    // Use the j2js method to convert the Java ArrayList to JavaScript
    gs.include("j2js");
    var tableArray = j2js(tableArrayList);
    
    // Write the value of each element in the JavaScript array
    var i = 0;
    while ( i < tableArray.length ) {
    gs.print("Table with index " + i + ": " + tableArray[i]);
    i++;
    }
    
    출력:
    Table with index 0: cmdb_ci_computer
    Table with index 1: cmdb_ci_hardware
    Table with index 2: cmdb_ci
    Table with index 3: cmdb

    TableUtils - getTableExtensions()

    테이블을 확장하는 테이블 목록을 반환합니다.

    표 16. 매개변수
    이름 유형 설명
    없음
    표 17. 반환
    유형 설명
    배열 목록 테이블을 확장하는 테이블 이름의 목록입니다.

    이 예에서는 이 인스턴스의 58개 테이블이 컴퓨터 [cmdb_ci_computer] 테이블을 확장함을 보여줍니다. (출력은 아래에 요약되어 있습니다.)

    // Get the tables that extend the table
    var table = new TableUtils("cmdb_ci_computer");
    var tableArrayList = table.getTableExtensions();
     
    // Use the j2js method to convert the Java ArrayList to JavaScript
    gs.include("j2js");
    var tableArray = j2js(tableArrayList);
     
    // Write the value of each element in the JavaScript array
    var i = 0;
    while ( i < tableArray.length ) {
      gs.print("Table with index " + i + ": " + tableArray[i]);
      i++;
    }
    출력:
    Table with index 0: cmdb_ci_mainframe_hardware
    Table with index 1: cmdb_ci_handheld_computing
    Table with index 2: cmdb_ci_ucs_blade
    Table with index 3: cmdb_ci_storage_switch
    Table with index 4: cmdb_ci_server
    Table with index 5: cmdb_ci_hmc_server
    …
    Table with index 56: cmdb_ci_pc_hardware
    Table with index 57: cmdb_ci_ucs_rack_unit

    TableUtils - hasExtensions()

    테이블이 확장되었는지 여부를 결정합니다.

    표 18. 매개변수
    이름 유형 설명
    없음
    표 19. 반환
    유형 설명
    부울 테이블에 확장이 있는 경우 True입니다.
    var table = new TableUtils("cmdb_ci_server");
    gs.print(table.hasExtensions());
    출력:
    true

    TableUtils - isBaseClass()

    테이블이 기본 클래스인지, 즉 부모가 없고 확장이 있는지 확인합니다.

    예를 들어 Task는 다른 테이블에서 확장되지 않고 다른 테이블에서 확장된 테이블을 포함하므로 기본 클래스입니다. Sys_user는 부모가 없지만 확장이 없기 때문에 기본 클래스가 아닙니다.

    표 20. 매개변수
    이름 유형 설명
    없음
    표 21. 반환
    유형 설명
    부울 테이블이 기본 클래스 테이블인지 여부를 나타내는 플래그로, 상위 테이블은 없지만 확장명은 있음을 의미합니다.
    유효한 값은 다음과 같습니다.
    • true: 테이블이 기본 클래스입니다.
    • false: 테이블이 기본 클래스가 아닙니다.
    var table = new TableUtils("task");
    gs.print("Task is base class: " + table.isBaseClass());
     
    var table = new TableUtils("sys_user");
    gs.print("User is base class: " + table.isBaseClass());
    출력:
     Task is base class: true
    User is base class: false

    TableUtils - isSoloClass()

    테이블에 상위 및 확장이 없는지 여부를 확인합니다.

    표 22. 매개변수
    이름 유형 설명
    없음
    표 23. 반환
    유형 설명
    부울 테이블에 상위가 없고 상위에서 확장된 테이블이 없는 경우 예입니다.
    var table = new TableUtils("task");
    gs.print("task is solo class: " + table.isSoloClass());
     
    var table = new TableUtils("cmdb_ci_win_server");
    gs.print("cmdb_ci_win_server is solo class: " + table.isSoloClass());
     
    var table = new TableUtils("sys_user");
    gs.print("sys_user is solo class: " + table.isSoloClass());
    출력:
    task is solo class: false
    cmdb_ci_win_server is solo class: false
    sys_user is solo class: true

    TableUtils - tableExists()

    테이블이 존재하는지 검사합니다.

    표 24. 매개변수
    이름 유형 설명
    없음
    표 25. 반환
    유형 설명
    부울 테이블이 존재하면 예입니다.
    var table = new TableUtils("my_table");
    gs.print("Does 'my_table' exist? " + table.tableExists());

    출력: 'my_table'가 존재합니까? 거짓