국제화 관련 코드 리팩토링
[Tadpole.git] / com.hangum.tadpole.commons.libs / src / com / hangum / tadpole / commons / libs / core / define / PublicTadpoleDefine.java
blobead8018403c6e347fb50dd6a8a3ceeb574839b68
1 /*******************************************************************************
2 * Copyright (c) 2013 hangum.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser Public License v2.1
5 * which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
7 *
8 * Contributors:
9 * hangum - initial API and implementation
10 ******************************************************************************/
11 package com.hangum.tadpole.commons.libs.core.define;
13 import java.util.HashMap;
14 import java.util.Map;
16 import org.apache.commons.io.FileUtils;
17 import org.apache.commons.io.IOUtils;
19 /**
20 * 전역 변수 정의
22 * @author hangum
25 public class PublicTadpoleDefine {
26 /** URL system version information */
27 public static final String URL_SYSTEM_VERION = String.format("?%s%s=%s", SystemDefine.DBHUB_MAJOR_VERSION, SystemDefine.DBHUB_SUB_VERSION, SystemDefine.DBHUB_RELEASE_DATE);
29 /** product type */
30 public static enum PRODUCT_TYPE {TadpoleDBHub, TadpoleHistoryHub, TadpoleAPIHub};
31 public static PRODUCT_TYPE ACTIVE_PRODUCT_TYPE = PRODUCT_TYPE.TadpoleDBHub;
33 /** default search count */
34 public static final int INT_SEARCH_COUNT = 25;
36 /** set user info */
37 public static String CERT_USER_INFO = "";
39 /** define default time zone*/
40 public static final String DEFAULT_TIME_ZONE = "Asia/Seoul";
42 /** default log file name*/
43 public static String DEFAULT_LOG_FILE = String.format("./logs/%s.log", ACTIVE_PRODUCT_TYPE.name());
44 public static String DEFAULT_VELOCITY_LOG_FILE = String.format("./logs/%sVelocity.log", ACTIVE_PRODUCT_TYPE.name());
46 /**
47 * 환경 정보 파일
49 public static final String TDB_CONFIG_FILE = "tadpole_interface.properties";
51 /**
52 * Define gateway db list key
54 public static final String GATEWAY_DB_LIST = "GATEWAY_DB_LIST";
56 /** cookie path */
57 public static String _cookiePath = "/";
59 public static final int systemAdminId = -1;
61 /** Default resource name */
62 public static final String DEFAUL_RESOURCE_NAME = "_TDB_DEF_NAME_";
64 /** filter type */
65 public static enum FILTER_TYPE {INCLUDE, EXCLUDE};
67 /** mail type */
68 public static enum MAIL_TYPE {NONE, SEND_GRID, SMTP};
70 /** 시스템 사용 그룹 정의 */
71 public static enum SYSTEM_USE_GROUP {PERSONAL, GROUP}
73 /** 디비 연결시 엑션 */
74 public static enum DB_CONNECTION_ASK {NO, PASSWORD, OTP, PASSWORD_OTP};
76 /** 사용자 쿼리를 프리페어 스테이트 먼트로 처리하는 파라미터 타입 */
77 public static enum PARAMETER_TYPE {JAVA_BASIC, ORACLE, MYBATIS_SHARP, MYBATIS_DOLLAR};
79 /** 사용자 디비의 권한 메시지 정의 */
80 public static enum AUTH_CODE_DEFINE {VALID, TIME_EXPIRE, AUTH_EXPIRE};
82 /** rest api service key */
83 public static final String SERVICE_KEY_NAME = "serviceID";
85 /** default system encrypt password */
86 public static final String SYSTEM_DEFAULT_USER = "hangum@tadpolehub.com";
87 public static final String SYSTEM_DEFAULT_PASSWORD = "startService.tdb.son";
89 /** COOKIE USER ID */
90 public static final String TDB_COOKIE_UPDATE_CHECK = "TDB_COOKIE_UPDATE_CHECK";
91 public static final String TDB_COOKIE_USER_ID = "TDB_USER_ID";
92 public static final String TDB_COOKIE_USER_PWD = "TDB_USER_PWD";
93 public static final String TDB_COOKIE_USER_SAVE_CKECK = "TDB_USER_SAVE_CHECK";
94 public static final String TDB_COOKIE_USER_LANGUAGE = "TDB_USER_LANGUAGE";
95 public static final String TDB_COOKIE_USER_IP = "TDB_USER_IP";
97 /**
98 * PLAN Statement ID
100 public static final String STATEMENT_ID = "||TDB_STMT_ID||"; //$NON-NLS-1$
102 /** 0번째 테이블 컬럼을 선택한다 */
103 public static final String DEFINE_TABLE_COLUMN_BASE_ZERO = "TDB_BASE_ZERO";
104 public static final String DEFINE_TABLE_COLUMN_BASE_ZERO_TYPE = "TDB_BASE_TYPE";
107 * 특별 컬럼을 정의 합니다.
109 public static final String SPECIAL_USER_DEFINE_HIDE_COLUMN = "TDB_HIDE";
112 * 분리자
114 public static final String DELIMITER = "||_D_||"; //$NON-NLS-1$
115 public static final String DELIMITER_DBL = "||_D_D_||"; //$NON-NLS-1$
117 /** 라인분리자 */
118 public static final String LINE_SEPARATOR = "\n";//System.getProperty("line.separator"); //$NON-NLS-1$
119 public static final String DOUBLE_LINE_SEPARATOR = LINE_SEPARATOR + LINE_SEPARATOR;
121 /** DIR SEPARATOR */
122 public static final char DIR_SEPARATOR = IOUtils.DIR_SEPARATOR;
124 /** temp dir
125 임시 디렉토리 생성에 오류 있음. 확인 필요.
126 java.io.IOException: Directory '/tmpTempTable1458208430419' could not be created 오류 발생.
127 환경 설정에 문제인지(prefix 혹은 디렉토리 미지정).. 아니면 코드상의 오류(DIRECTORY-SEPERATOR 가 빠진 문제)인지 확인 필요
129 public static final String TEMP_DIR = FileUtils.getTempDirectoryPath() + PublicTadpoleDefine.DIR_SEPARATOR;
131 /** 쿼리 구분자 */
132 public static final String SQL_DELIMITER = ";"; //$NON-NLS-1$
134 /** tadpole default port */
135 public static final String TADPOLE_DEFAULT_PORT = "10081";
137 /** tadpole url */
138 public static final String TADPOLE_URL = "http://127.0.0.1:%s";
141 * tadpole url
143 * @return
145 public static String getTadpoleUrl() {
146 String tadpolePort = System.getProperty("org.osgi.service.http.port", TADPOLE_DEFAULT_PORT); //$NON-NLS-1$ //$NON-NLS-2$
147 return String.format(TADPOLE_URL, tadpolePort);
150 /** 외부 계정으로 올챙이가 접속 할때의 외부 계정 리스트. 현재는 external_account 의 type에 사용. */
151 public enum EXTERNAL_ACCOUNT {AMAZONRDS, DBSAFER};
153 /** user login type */
154 public static enum INPUT_TYPE {NORMAL, LDAP};
156 /** yes, no */
157 public static enum YES_NO {YES, NO};
159 /** Success, Fail */
160 public static enum SUCCESS_FAIL {S, F};
162 /** change resource save */
163 public static final String SAVE_FILE = "CHANGE_TADPOLE_RESOURE"; //$NON-NLS-1$
165 /** erd - select table */
166 public static final String SELECT_ERD_TABLE = "SELECT_ERD_TABLE_RESOURE"; //$NON-NLS-1$
168 // /** auto commit 사용여부를 가립니다. */
169 // public static final String AUTOCOMMIT_USE = "_AUTOCOMMIT_USE"; //$NON-NLS-1$
171 /** Tadpole support browser list */
172 public static enum TADPOLE_SUPPORT_BROWSER {EDGE, FIREFOX, CHROME, SAFARI, IE, OPERA};
174 /** Tadpole support browser list */
175 public static enum TADPOLE_SUPPORT_BROWSERIP {FIREFOX, CHROME, OPERA};
177 /** 테드폴 사용자 역활 타입을 지정합니다 */
178 public enum USER_ROLE_TYPE {SYSTEM_ADMIN, OBSERVER, USER, API_USER};
180 /**
181 * This variable is user_role_table.
183 public static enum DB_USER_ROLE_TYPE {SYSTEM_ADMIN, ADMIN, DBA, MANAGER, USER, GUEST};
185 // /**
186 // * Setting SQL Client Info
187 // * @return
188 // */
189 // public static Properties getSQLClientInfo() {
190 // Properties prop = new Properties();
191 // prop.setProperty("ApplicationName", String.format("%s %s %s", SystemDefine.NAME, SystemDefine.MAJOR_VERSION, SystemDefine.RELEASE_DATE));
192 //// prop.setProperty("ClientUser", RWT.getRequest().getRemoteHost());
193 //// prop.setProperty("ClientHostname", RWT.getRequest().getLocalAddr());
195 // return prop;
196 // }
199 * ace editor theme list
200 https://docs.c9.io/docs/syntax-highlighting-themes
202 private static Map<String, String> mapTheme = new HashMap<String, String>();
203 public static Map<String, String> getMapTheme() {
204 if(mapTheme.isEmpty()) {
205 mapTheme.put("Chrome", "chrome");
206 mapTheme.put("Clouds", "clouds");
207 mapTheme.put("Clouds Midnight", "clouds_midnight");
208 mapTheme.put("Cobalt", "cobalt");
209 mapTheme.put("Crimson Editor", "crimson_editor");
210 mapTheme.put("Dawn", "dawn");
211 mapTheme.put("Eclipse", "eclipse");
212 mapTheme.put("Idle Fingers", "idle_fingers");
213 mapTheme.put("Kr Theme", "kr_theme");
214 mapTheme.put("Merbivore", "merbivore");
215 mapTheme.put("Merbivore Soft", "merbivore_soft");
216 mapTheme.put("Mono Industrial", "mono_industrial");
217 mapTheme.put("Monokai", "monokai");
218 mapTheme.put("Pastel On Dark", "pastel_on_dark");
219 mapTheme.put("Solarized Dark", "solarized_dark");
220 mapTheme.put("Solarized Light", "solarized_light");
221 mapTheme.put("TextMate", "textmate");
222 mapTheme.put("Tomorrow", "tomorrow");
223 mapTheme.put("Tomorrow Night", "tomorrow_night");
224 mapTheme.put("Tomorrow Night Blue", "tomorrow_night_blue");
225 mapTheme.put("Tomorrow Night Bright", "tomorrow_night_bright");
226 mapTheme.put("Tomorrow Night Eighties", "tomorrow_night_eighties");
227 mapTheme.put("Twilight", "twilight");
228 mapTheme.put("Vibrant Inkv", "vibrant_inkv");
230 return mapTheme;
234 * db operation type
236 * @author hangum
239 public enum DBOperationType {
240 PRODUCTION("Production Server"),
241 DR("Disaster Recovery"),
242 DEVELOP("Development Server"),
243 TEST("Test Server"),
244 BACKUP("Backup Server"),
245 OTHERS("Others");
247 private String typeName;
249 private DBOperationType(String typeName) {
250 this.typeName = typeName;
253 public String getTypeName() {
254 return typeName;
257 public static DBOperationType getNameToType(String name) {
258 if(PRODUCTION.typeName.equals(name)) return PRODUCTION;
259 else if(DR.typeName.equals(name)) return DR;
260 else if(DEVELOP.typeName.equals(name)) return DEVELOP;
261 else if(TEST.typeName.equals(name)) return TEST;
262 else if(BACKUP.typeName.equals(name)) return BACKUP;
263 else return OTHERS;
267 /** 에디터 결과를 오픈하는 뷰 타입을 정의 */
268 public static enum RESULT_COMP_TYPE {Table, Text};
270 /** 내보내기 종류 정의 (배포탭에서 변수로 사용 하여서 수정시 주의 요망) */
271 public static enum EXPORT_METHOD {TEXT, EXCEL, HTML, JSON, XML, SQL};
273 /** CSV export 시 기본 값 */
274 public static String CSV_EXPORT_DEFAULT_VALUE = " ";
276 /** 에디터를 열때 오픈하는 타입을 적습니다. */
277 public static enum EDITOR_OPEN_TYPE {NONE, STRING, FILE};
279 /** save resource type */
280 public static enum RESOURCE_TYPE {ERD, SQL, AUTO_SQL, OBJECT};
282 /** define SQL, ERD shared type */
283 public static enum SHARED_TYPE {PUBLIC, PRIVATE};
285 /** executed sql type */
286 public static enum SQL_STATEMENT_TYPE {NONE, PREPARED_STATEMENT};
288 /**
289 * executed sql history type - 이름을 정할때 10자가 넘지 않아야한다.
291 * EDITOR : 에디터에서 실행
292 * EDIT_DOWN : 쿼리 다운로드에서
293 * API_PROGRAM : API Hub에서 실행
294 * API_USER : SHARED HUB 에서 실행
295 * REQ_QUERY : 사용자 요청 쿼리(예를 들어 사용자 결제를 받아 실행한 쿼리)
296 * HISTORY_HUB : 히스토리 허브에서 요청한 쿼리
298 public static enum EXECUTE_SQL_TYPE {EDITOR, EDIT_DOWN, API, API_USER, REQ_QUERY, HISTORYHUB};
300 /** 데이터 수정 상태를 가르킵니다 */
301 public static enum DATA_STATUS {NEW, MODIFY, DEL};
303 /** 기본 상태 정의 */
304 public static enum BASIC_STATUS {NONE, START, DONE};
306 /** objec explorer에서 정의한 action */
307 public static enum OBJECT_TYPE {
308 TABLES,
309 VIEWS,
310 SYNONYM,
311 SEQUENCE,
312 LINK,
313 INDEXES,
314 CONSTRAINTS,
315 PROCEDURES,
316 PROCEDURE_PARAMETER,
317 FUNCTIONS,
318 TRIGGERS,
319 COLLECTIONS,
320 JAVASCRIPT,
321 PACKAGES,
322 SCHEDULE,
323 COLUMNS,
324 JOBS,
325 JAVA
328 /** sql type - http://www.orafaq.com/faq/what_are_the_difference_between_ddl_dml_and_dcl_commands */
329 public static enum SQL_TYPE {DDL, DML};//, DCL, TCL};
331 /** query type */
332 public static enum QUERY_DML_TYPE {SELECT, EXPLAIN_PLAN, INSERT, UPDATE, DELETE, UNKNOWN};
334 /** query ddl type */
335 public static enum QUERY_DDL_STATUS {CREATE, ALTER, DROP, UNKNOWN};
336 public static enum QUERY_DDL_TYPE {TABLE, VIEW, SEQUENCE, INDEX, PROCEDURE, FUNCTION, TRIGGER, PACKAGE, SYNONYM, LINK, JOBS, JAVA, UNKNOWN};
337 public static enum ACCEAS_CTL_DDL_TYPE {SCHEMA, TABLEoVIEW, FUNCTION, PROCEDURE};
338 public static String[] DB_PRIMARY_KEY = {
339 "PRI",
340 "PK",
341 "PRIMARY",
342 "PRIMARY KEY", // pgsql
345 public static String[] DB_FOREIGN_KEY = {
346 "FK",
347 "FOREIGN KEY", // pgsql
350 public static String[] DB_MULTI_KEY = {
351 "MUL",
352 "PRIMARY KEY,FOREIGN KEY" // pgsql
356 * is primary key
357 * @param key
358 * @return
360 public static boolean isPK(String key) {
361 for(String searchKey : DB_PRIMARY_KEY) {
362 if(searchKey.equalsIgnoreCase(key)) return true;
365 return false;
369 * is foreign key
370 * @param key
371 * @return
373 public static boolean isFK(String key) {
374 for(String searchKey : DB_FOREIGN_KEY) {
375 if(searchKey.equalsIgnoreCase(key)) return true;
378 return false;
382 * is multi key
383 * @param key
384 * @return
386 public static boolean isMUL(String key) {
387 for(String searchKey : DB_MULTI_KEY) {
388 if(searchKey.equalsIgnoreCase(key)) return true;
391 return false;
394 * is key
395 * @param key
396 * @return
398 public static boolean isKEY(String key) {
399 return isKEY(key, YES_NO.NO.name());
401 public static boolean isKEY(String key, String isNull) {
402 boolean isReturn = true;
404 // 컬럼이 null허용이면 false
405 if(isPK(key)) if("YES".equals(isNull)) return false; //$NON-NLS-1$
406 if(isFK(key)) if("YES".equals(isNull)) return false; //$NON-NLS-1$
407 if(isMUL(key)) if("YES".equals(isNull)) return false; //$NON-NLS-1$
409 return isReturn;