TableUtils - 전역
TableUtils API는 테이블 관련 정보에 액세스하기 위한 바로 가기 클래스입니다.
이 클래스는 서버측 스크립트에 사용할 수 있습니다.
TableUtils - tableExists()
테이블이 존재하는지 검사합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 부울 | 테이블이 있으면 True입니다. |
var table = new TableUtils("my_table");
gs.print("Does 'my_table' exist? " + table.tableExists());
출력: 'my_table'이 존재합니까? False
TableUtils - drop(String tableName)
데이터베이스 테이블을 삭제합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| tableName | 문자열 | 삭제할 테이블의 이름 |
| 유형 | 설명 |
|---|---|
| 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_foreverTableUtils - dropAndClean(tableName 문자열)
데이터베이스 테이블을 삭제하고 테이블에 대한 참조를 정리합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| tableName | 문자열 | 삭제할 테이블의 이름 |
| 유형 | 설명 |
|---|---|
| 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 deletedTableUtils - dropTableAndExtensions(tableName 문자열)
데이터베이스 테이블(모든 확장 테이블)을 삭제하고 테이블에 대한 참조를 정리합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| tableName | 문자열 | 삭제할 테이블 |
| 유형 | 설명 |
|---|---|
| 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 deletedTableUtils - getAbsoluteBase()
테이블이 확장된 기본 테이블 이름을 반환합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 문자열 | 기본 테이블 이름 |
var table = new TableUtils("cmdb_ci_server");
gs.print(table.getAbsoluteBase());
출력: cmdb_ci
TableUtils - getAllExtensions()
기본 테이블을 포함하여 테이블을 확장하는 테이블 목록을 반환합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 배열 목록 | 기본 테이블을 포함하여 테이블을 확장하는 테이블 목록입니다. |
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()
지정된 테이블의 계층 구조에 참여하는 모든 클래스의 목록을 반환합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 배열 목록 | 지정된 테이블의 계층 구조에 있는 모든 클래스의 목록입니다. |
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()
테이블 계층 구조를 반환합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 배열 목록 | 상위 계층 구조의 테이블 이름 목록입니다. |
// 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: cmdbTableUtils - getTableExtensions()
테이블을 확장하는 테이블 목록을 반환합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 배열 목록 | 테이블을 확장하는 테이블 이름의 목록입니다. |
이 예는 이 인스턴스의 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_unitTableUtils - hasExtensions()
테이블이 확장되었는지 여부를 결정합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 부울 | 테이블에 확장이 있는 경우 예입니다. |
var table = new TableUtils("cmdb_ci_server");
gs.print(table.hasExtensions());
trueTableUtils - isBaseClass()
테이블이 기본 클래스인지, 즉 상위 클래스가 없고 확장이 있는지 여부를 결정합니다.
예를 들어, Task는 다른 테이블에서 확장되지 않고 이 테이블에서 확장된 테이블을 가지므로 기본 클래스입니다. Sys_user는 부모가 없지만 확장이 없기 때문에 기본 클래스가 아닙니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 부울 | 테이블이 기본 클래스 테이블인지 여부를 나타내는 플래그로, 상위 테이블은 없지만 확장이 있음을 의미합니다. 유효한 값은 다음과 같습니다.
|
예제
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: falseTableUtils - isSoloClass()
테이블에 상위 및 확장이 없는지 확인합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 부울 | 테이블에 상위 테이블이 없고 상위 테이블에서 확장된 테이블이 없는 경우 예입니다. |
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: trueTableUtils - TableUtils(tableName 문자열)
TableUtils 클래스의 인스턴스를 만듭니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| tableName | 문자열 | 테이블 이름 |
var tu = new TableUtils("incident");