v 1.0
This commit is contained in:
20
LICENSE
Normal file
20
LICENSE
Normal file
@@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2021 yudao-cloud
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
File diff suppressed because it is too large
Load Diff
145
sql/mysql/bpm/bpm.sql
Normal file
145
sql/mysql/bpm/bpm.sql
Normal file
@@ -0,0 +1,145 @@
|
||||
DROP TABLE IF EXISTS `bpm_category`;
|
||||
CREATE TABLE `bpm_category` (
|
||||
`id` bigint(0) NOT NULL PRIMARY KEY AUTO_INCREMENT COMMENT '分类编号',
|
||||
`name` varchar(255) DEFAULT NULL COMMENT '分类名',
|
||||
`code` varchar(255) DEFAULT NULL COMMENT '分类标志',
|
||||
`description` varchar(255) DEFAULT NULL COMMENT '分类描述',
|
||||
`status` int(11) DEFAULT NULL COMMENT '分类状态,枚举 CommonStatusEnum',
|
||||
`sort` int(11) DEFAULT NULL COMMENT '分类排序',
|
||||
`create_time` datetime COMMENT '创建时间',
|
||||
`update_time` datetime COMMENT '最后更新时间',
|
||||
`creator` varchar(255) COMMENT '创建者,目前使用 SysUser 的 id 编号',
|
||||
`updater` varchar(255) COMMENT '更新者,目前使用 SysUser 的 id 编号',
|
||||
`deleted` tinyint(1) DEFAULT NULL COMMENT '是否删除',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号'
|
||||
) ENGINE=InnoDB COMMENT='流程分类';
|
||||
|
||||
DROP TABLE IF EXISTS `bpm_form`;
|
||||
CREATE TABLE `bpm_form` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
|
||||
`name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '表单名',
|
||||
`status` tinyint NOT NULL COMMENT '开启状态',
|
||||
`conf` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '表单的配置',
|
||||
`fields` varchar(5000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '表单项的数组',
|
||||
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注',
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '工作流的表单定义';
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `bpm_oa_leave`;
|
||||
CREATE TABLE `bpm_oa_leave` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '请假表单主键',
|
||||
`user_id` bigint NOT NULL COMMENT '申请人的用户编号',
|
||||
`type` tinyint NOT NULL COMMENT '请假类型',
|
||||
`reason` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '请假原因',
|
||||
`start_time` datetime NOT NULL COMMENT '开始时间',
|
||||
`end_time` datetime NOT NULL COMMENT '结束时间',
|
||||
`day` tinyint NOT NULL COMMENT '请假天数',
|
||||
`result` tinyint NOT NULL COMMENT '请假结果',
|
||||
`process_instance_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '流程实例的编号',
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'OA 请假申请表';
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `bpm_process_definition_info`;
|
||||
CREATE TABLE `bpm_process_definition_info` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
|
||||
`process_definition_id` varchar(64) NOT NULL COMMENT '流程定义的编号',
|
||||
`model_id` varchar(64) NOT NULL COMMENT '流程模型的编号',
|
||||
`icon` varchar(255) DEFAULT NULL COMMENT '图标',
|
||||
`description` varchar(255) DEFAULT NULL COMMENT '描述',
|
||||
`form_type` tinyint NOT NULL COMMENT '表单类型',
|
||||
`form_id` bigint NULL DEFAULT NULL COMMENT '表单编号',
|
||||
`form_conf` varchar(1000) DEFAULT NULL COMMENT '表单的配置',
|
||||
`form_fields` varchar(5000) DEFAULT NULL COMMENT '表单项的数组',
|
||||
`form_custom_create_path` varchar(255) DEFAULT NULL COMMENT '自定义表单的提交路径',
|
||||
`form_custom_view_path` varchar(255) DEFAULT NULL COMMENT '自定义表单的查看路径',
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'Bpm 流程定义信息表';
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `bpm_process_expression`;
|
||||
CREATE TABLE `bpm_process_expression` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
|
||||
`name` varchar(64) DEFAULT NULL COMMENT '流程实例的名字',
|
||||
`status` tinyint NOT NULL COMMENT '流程实例的状态',
|
||||
`expression` varchar(5000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '表达式',
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '流程表达式';
|
||||
|
||||
DROP TABLE IF EXISTS `bpm_process_instance_copy`;
|
||||
CREATE TABLE `bpm_process_instance_copy` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
|
||||
`start_user_id` bigint NOT NULL COMMENT '发起流程的用户编号',
|
||||
`process_instance_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '流程实例的名字',
|
||||
`process_instance_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '流程实例的编号',
|
||||
`category` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '流程分类',
|
||||
`task_id` varchar(64) DEFAULT NULL COMMENT '任务主键',
|
||||
`task_name` varchar(64) DEFAULT NULL COMMENT '任务名称',
|
||||
`user_id` bigint NOT NULL COMMENT '用户编号(被抄送的用户编号)',
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 296 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '流程抄送表';
|
||||
|
||||
DROP TABLE IF EXISTS `bpm_process_listener`;
|
||||
CREATE TABLE `bpm_process_listener` (
|
||||
`id` bigint(20) NOT NULL COMMENT '主键 ID,自增',
|
||||
`name` varchar(255) DEFAULT NULL COMMENT '监听器名字',
|
||||
`status` int(11) DEFAULT NULL COMMENT '状态',
|
||||
`type` varchar(255) DEFAULT NULL COMMENT '监听类型',
|
||||
`event` varchar(255) DEFAULT NULL COMMENT '监听事件',
|
||||
`value_type` varchar(255) DEFAULT NULL COMMENT '值类型',
|
||||
`value` varchar(255) DEFAULT NULL COMMENT '值',
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='流程监听器';
|
||||
|
||||
DROP TABLE IF EXISTS `bpm_user_group`;
|
||||
CREATE TABLE `bpm_user_group` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
|
||||
`name` varchar(30) DEFAULT '' COMMENT '组名',
|
||||
`description` varchar(255) DEFAULT '' COMMENT '描述',
|
||||
`status` tinyint NOT NULL COMMENT '状态(0正常 1停用)',
|
||||
`user_ids` varchar(1024) DEFAULT '0' COMMENT '成员编号数组',
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 113 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '用户组';
|
||||
171
sql/mysql/bpm/bpm_tables.sql
Normal file
171
sql/mysql/bpm/bpm_tables.sql
Normal file
@@ -0,0 +1,171 @@
|
||||
-- 删除表,如果已存在
|
||||
DROP TABLE IF EXISTS `bpm_category`;
|
||||
CREATE TABLE `bpm_category` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '分类编号',
|
||||
`name` varchar(255) NOT NULL COMMENT '分类名',
|
||||
`code` varchar(255) NOT NULL COMMENT '分类标志',
|
||||
`description` varchar(255) DEFAULT NULL COMMENT '分类描述',
|
||||
`status` int NOT NULL COMMENT '分类状态',
|
||||
`sort` int DEFAULT NULL COMMENT '分类排序',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
|
||||
`creator` varchar(64) DEFAULT NULL COMMENT '创建者',
|
||||
`updater` varchar(64) DEFAULT NULL COMMENT '更新者',
|
||||
`deleted` bit(1) NOT NULL DEFAULT 0 COMMENT '是否删除',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='BPM 流程分类';
|
||||
|
||||
-- 删除表,如果已存在
|
||||
DROP TABLE IF EXISTS `bpm_form`;
|
||||
CREATE TABLE `bpm_form` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
|
||||
`name` varchar(255) NOT NULL COMMENT '表单名',
|
||||
`status` int NOT NULL COMMENT '状态',
|
||||
`conf` varchar(2000) DEFAULT NULL COMMENT '表单的配置',
|
||||
`fields` varchar(2000) DEFAULT NULL COMMENT '表单项的数组',
|
||||
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
|
||||
`creator` varchar(64) DEFAULT NULL COMMENT '创建者',
|
||||
`updater` varchar(64) DEFAULT NULL COMMENT '更新者',
|
||||
`deleted` bit(1) NOT NULL DEFAULT 0 COMMENT '是否删除',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='BPM 工作流的表单定义';
|
||||
|
||||
-- 删除表,如果已存在
|
||||
DROP TABLE IF EXISTS `bpm_process_definition_info`;
|
||||
CREATE TABLE `bpm_process_definition_info` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
|
||||
`process_definition_id` varchar(255) NOT NULL COMMENT '流程定义的编号',
|
||||
`model_id` varchar(255) DEFAULT NULL COMMENT '流程模型的编号',
|
||||
`model_type` int DEFAULT NULL COMMENT '流程模型的类型',
|
||||
`category` varchar(255) DEFAULT NULL COMMENT '流程分类的编码',
|
||||
`icon` varchar(255) DEFAULT NULL COMMENT '图标',
|
||||
`description` varchar(255) DEFAULT NULL COMMENT '描述',
|
||||
`form_type` int DEFAULT NULL COMMENT '表单类型',
|
||||
`form_id` bigint DEFAULT NULL COMMENT '动态表单编号',
|
||||
`form_conf` varchar(2000) DEFAULT NULL COMMENT '表单的配置',
|
||||
`form_fields` varchar(2000) DEFAULT NULL COMMENT '表单项的数组',
|
||||
`form_custom_create_path` varchar(255) DEFAULT NULL COMMENT '自定义表单的提交路径',
|
||||
`form_custom_view_path` varchar(255) DEFAULT NULL COMMENT '自定义表单的查看路径',
|
||||
`simple_model` varchar(2000) DEFAULT NULL COMMENT 'SIMPLE 设计器模型数据 json 格式',
|
||||
`visible` bit(1) DEFAULT NULL COMMENT '是否可见',
|
||||
`sort` bigint DEFAULT NULL COMMENT '排序值',
|
||||
`start_user_ids` varchar(2000) DEFAULT NULL COMMENT '可发起用户编号数组',
|
||||
`start_dept_ids` varchar(2000) DEFAULT NULL COMMENT '可发起部门编号数组',
|
||||
`manager_user_ids` varchar(2000) DEFAULT NULL COMMENT '可管理用户编号数组',
|
||||
`allow_cancel_running_process` bit(1) DEFAULT NULL COMMENT '是否允许撤销审批中的申请',
|
||||
`process_id_rule` varchar(2000) DEFAULT NULL COMMENT '流程 ID 规则',
|
||||
`auto_approval_type` int DEFAULT NULL COMMENT '自动去重类型',
|
||||
`title_setting` varchar(2000) DEFAULT NULL COMMENT '标题设置',
|
||||
`summary_setting` varchar(2000) DEFAULT NULL COMMENT '摘要设置',
|
||||
`process_before_trigger_setting` varchar(2000) DEFAULT NULL COMMENT '流程前置通知设置',
|
||||
`process_after_trigger_setting` varchar(2000) DEFAULT NULL COMMENT '流程后置通知设置',
|
||||
`task_before_trigger_setting` varchar(2000) DEFAULT NULL COMMENT '任务前置通知设置',
|
||||
`task_after_trigger_setting` varchar(2000) DEFAULT NULL COMMENT '任务后置通知设置',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
|
||||
`creator` varchar(64) DEFAULT NULL COMMENT '创建者',
|
||||
`updater` varchar(64) DEFAULT NULL COMMENT '更新者',
|
||||
`deleted` bit(1) NOT NULL DEFAULT 0 COMMENT '是否删除',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='BPM 流程定义的拓信息';
|
||||
|
||||
-- 删除表,如果已存在
|
||||
DROP TABLE IF EXISTS `bpm_process_expression`;
|
||||
CREATE TABLE `bpm_process_expression` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
|
||||
`name` varchar(255) NOT NULL COMMENT '表达式名字',
|
||||
`status` int NOT NULL COMMENT '表达式状态',
|
||||
`expression` varchar(2000) NOT NULL COMMENT '表达式',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
|
||||
`creator` varchar(64) DEFAULT NULL COMMENT '创建者',
|
||||
`updater` varchar(64) DEFAULT NULL COMMENT '更新者',
|
||||
`deleted` bit(1) NOT NULL DEFAULT 0 COMMENT '是否删除',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='BPM 流程表达式';
|
||||
|
||||
-- 删除表,如果已存在
|
||||
DROP TABLE IF EXISTS `bpm_process_listener`;
|
||||
CREATE TABLE `bpm_process_listener` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键 ID',
|
||||
`name` varchar(255) NOT NULL COMMENT '监听器名字',
|
||||
`status` int NOT NULL COMMENT '状态',
|
||||
`type` varchar(64) NOT NULL COMMENT '监听类型',
|
||||
`event` varchar(64) DEFAULT NULL COMMENT '监听事件',
|
||||
`value_type` varchar(64) DEFAULT NULL COMMENT '值类型',
|
||||
`value` varchar(255) DEFAULT NULL COMMENT '值',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
|
||||
`creator` varchar(64) DEFAULT NULL COMMENT '创建者',
|
||||
`updater` varchar(64) DEFAULT NULL COMMENT '更新者',
|
||||
`deleted` bit(1) NOT NULL DEFAULT 0 COMMENT '是否删除',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='BPM 流程监听器';
|
||||
|
||||
-- 删除表,如果已存在
|
||||
DROP TABLE IF EXISTS `bpm_user_group`;
|
||||
CREATE TABLE `bpm_user_group` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
|
||||
`name` varchar(255) NOT NULL COMMENT '组名',
|
||||
`description` varchar(255) DEFAULT NULL COMMENT '描述',
|
||||
`status` int NOT NULL COMMENT '状态',
|
||||
`user_ids` varchar(2000) DEFAULT NULL COMMENT '成员用户编号数组',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
|
||||
`creator` varchar(64) DEFAULT NULL COMMENT '创建者',
|
||||
`updater` varchar(64) DEFAULT NULL COMMENT '更新者',
|
||||
`deleted` bit(1) NOT NULL DEFAULT 0 COMMENT '是否删除',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='BPM 用户组';
|
||||
|
||||
-- 删除表,如果已存在
|
||||
DROP TABLE IF EXISTS `bpm_oa_leave`;
|
||||
CREATE TABLE `bpm_oa_leave` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '请假表单主键',
|
||||
`user_id` bigint NOT NULL COMMENT '申请人的用户编号',
|
||||
`type` varchar(255) NOT NULL COMMENT '请假类型',
|
||||
`reason` varchar(255) DEFAULT NULL COMMENT '原因',
|
||||
`start_time` datetime DEFAULT NULL COMMENT '开始时间',
|
||||
`end_time` datetime DEFAULT NULL COMMENT '结束时间',
|
||||
`day` bigint DEFAULT NULL COMMENT '请假天数',
|
||||
`status` int DEFAULT NULL COMMENT '审批结果',
|
||||
`process_instance_id` varchar(255) DEFAULT NULL COMMENT '对应的流程编号',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
|
||||
`creator` varchar(64) DEFAULT NULL COMMENT '创建者',
|
||||
`updater` varchar(64) DEFAULT NULL COMMENT '更新者',
|
||||
`deleted` bit(1) NOT NULL DEFAULT 0 COMMENT '是否删除',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='OA 请假申请';
|
||||
|
||||
-- 删除表,如果已存在
|
||||
DROP TABLE IF EXISTS `bpm_process_instance_copy`;
|
||||
CREATE TABLE `bpm_process_instance_copy` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
|
||||
`start_user_id` bigint DEFAULT NULL COMMENT '发起人 Id',
|
||||
`process_instance_name` varchar(255) DEFAULT NULL COMMENT '流程名',
|
||||
`process_instance_id` varchar(255) DEFAULT NULL COMMENT '流程实例的编号',
|
||||
`process_definition_id` varchar(255) DEFAULT NULL COMMENT '流程实例的流程定义编号',
|
||||
`category` varchar(255) DEFAULT NULL COMMENT '流程分类',
|
||||
`activity_id` varchar(255) DEFAULT NULL COMMENT '流程活动的编号',
|
||||
`activity_name` varchar(255) DEFAULT NULL COMMENT '流程活动的名字',
|
||||
`task_id` varchar(255) DEFAULT NULL COMMENT '流程活动的编号',
|
||||
`user_id` bigint DEFAULT NULL COMMENT '用户编号(被抄送的用户编号)',
|
||||
`reason` varchar(255) DEFAULT NULL COMMENT '抄送意见',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
|
||||
`creator` varchar(64) DEFAULT NULL COMMENT '创建者',
|
||||
`updater` varchar(64) DEFAULT NULL COMMENT '更新者',
|
||||
`deleted` bit(1) NOT NULL DEFAULT 0 COMMENT '是否删除',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='流程抄送';
|
||||
@@ -0,0 +1,781 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package com.alibaba.druid.pool;
|
||||
|
||||
import com.alibaba.cloud.commons.lang.StringUtils;
|
||||
import com.alibaba.druid.VERSION;
|
||||
import com.alibaba.druid.support.logging.Log;
|
||||
import com.alibaba.druid.support.logging.LogFactory;
|
||||
import com.alibaba.druid.util.JdbcUtils;
|
||||
import com.alibaba.druid.util.MySqlUtils;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.SQLWarning;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DruidPooledStatement extends PoolableWrapper implements Statement {
|
||||
private static final Log LOG = LogFactory.getLog(DruidPooledStatement.class);
|
||||
private final Statement stmt;
|
||||
protected DruidPooledConnection conn;
|
||||
protected List<ResultSet> resultSetTrace;
|
||||
protected boolean closed;
|
||||
protected int fetchRowPeak = -1;
|
||||
protected int exceptionCount;
|
||||
|
||||
public DruidPooledStatement(DruidPooledConnection conn, Statement stmt) {
|
||||
super(stmt);
|
||||
this.conn = conn;
|
||||
this.stmt = stmt;
|
||||
}
|
||||
|
||||
protected void addResultSetTrace(ResultSet resultSet) {
|
||||
if (this.resultSetTrace == null) {
|
||||
this.resultSetTrace = new ArrayList(1);
|
||||
} else if (this.resultSetTrace.size() > 0) {
|
||||
int lastIndex = this.resultSetTrace.size() - 1;
|
||||
ResultSet lastResultSet = (ResultSet)this.resultSetTrace.get(lastIndex);
|
||||
|
||||
try {
|
||||
if (lastResultSet.isClosed()) {
|
||||
this.resultSetTrace.set(lastIndex, resultSet);
|
||||
return;
|
||||
}
|
||||
} catch (SQLException var5) {
|
||||
}
|
||||
}
|
||||
|
||||
this.resultSetTrace.add(resultSet);
|
||||
}
|
||||
|
||||
protected void recordFetchRowCount(int fetchRowCount) {
|
||||
if (this.fetchRowPeak < fetchRowCount) {
|
||||
this.fetchRowPeak = fetchRowCount;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int getFetchRowPeak() {
|
||||
return this.fetchRowPeak;
|
||||
}
|
||||
|
||||
protected SQLException checkException(Throwable error) throws SQLException {
|
||||
String sql = null;
|
||||
if (this instanceof DruidPooledPreparedStatement) {
|
||||
sql = ((DruidPooledPreparedStatement)this).getSql();
|
||||
}
|
||||
|
||||
this.handleSocketTimeout(error);
|
||||
++this.exceptionCount;
|
||||
return this.conn.handleException(error, sql);
|
||||
}
|
||||
|
||||
protected SQLException checkException(Throwable error, String sql) throws SQLException {
|
||||
this.handleSocketTimeout(error);
|
||||
++this.exceptionCount;
|
||||
return this.conn.handleException(error, sql);
|
||||
}
|
||||
|
||||
protected void handleSocketTimeout(Throwable error) throws SQLException {
|
||||
if (this.conn != null && this.conn.transactionInfo == null && this.conn.holder != null) {
|
||||
DruidDataSource dataSource = null;
|
||||
DruidConnectionHolder holder = this.conn.holder;
|
||||
if (holder.dataSource instanceof DruidDataSource) {
|
||||
dataSource = (DruidDataSource)holder.dataSource;
|
||||
}
|
||||
|
||||
if (dataSource != null) {
|
||||
if (dataSource.killWhenSocketReadTimeout) {
|
||||
SQLException sqlException = null;
|
||||
if (error instanceof SQLException) {
|
||||
sqlException = (SQLException)error;
|
||||
}
|
||||
|
||||
if (sqlException != null) {
|
||||
Throwable cause = error.getCause();
|
||||
boolean socketReadTimeout = cause instanceof SocketTimeoutException && "Read timed out".equals(cause.getMessage());
|
||||
if (socketReadTimeout) {
|
||||
if (JdbcUtils.isMysqlDbType(dataSource.dbTypeName)) {
|
||||
String killQuery = MySqlUtils.buildKillQuerySql(this.conn.getConnection(), (SQLException)error);
|
||||
if (killQuery != null) {
|
||||
DruidPooledConnection killQueryConn = null;
|
||||
Statement killQueryStmt = null;
|
||||
|
||||
try {
|
||||
killQueryConn = dataSource.getConnection(1000L);
|
||||
if (killQueryConn != null) {
|
||||
killQueryStmt = killQueryConn.createStatement();
|
||||
killQueryStmt.execute(killQuery);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(killQuery + " success.");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LOG.warn(killQuery + " error.", ex);
|
||||
return;
|
||||
} finally {
|
||||
JdbcUtils.close(killQueryStmt);
|
||||
JdbcUtils.close(killQueryConn);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DruidPooledConnection getPoolableConnection() {
|
||||
return this.conn;
|
||||
}
|
||||
|
||||
public Statement getStatement() {
|
||||
return this.stmt;
|
||||
}
|
||||
|
||||
protected void checkOpen() throws SQLException {
|
||||
if (this.closed) {
|
||||
Throwable disableError = null;
|
||||
if (this.conn != null) {
|
||||
disableError = this.conn.getDisableError();
|
||||
}
|
||||
|
||||
if (disableError != null) {
|
||||
throw new SQLException("statement is closed", disableError);
|
||||
} else {
|
||||
throw new SQLException("statement is closed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void clearResultSet() {
|
||||
if (this.resultSetTrace != null) {
|
||||
for(ResultSet rs : this.resultSetTrace) {
|
||||
try {
|
||||
if (!rs.isClosed()) {
|
||||
rs.close();
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
LOG.error("clearResultSet error", ex);
|
||||
}
|
||||
}
|
||||
|
||||
this.resultSetTrace.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void incrementExecuteCount() {
|
||||
DruidPooledConnection conn = this.getPoolableConnection();
|
||||
if (conn != null) {
|
||||
DruidConnectionHolder holder = conn.getConnectionHolder();
|
||||
if (holder != null) {
|
||||
DruidAbstractDataSource dataSource = holder.getDataSource();
|
||||
if (dataSource != null) {
|
||||
dataSource.incrementExecuteCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void incrementExecuteBatchCount() {
|
||||
DruidPooledConnection conn = this.getPoolableConnection();
|
||||
if (conn != null) {
|
||||
DruidConnectionHolder holder = conn.getConnectionHolder();
|
||||
if (holder != null) {
|
||||
if (holder.getDataSource() != null) {
|
||||
DruidAbstractDataSource dataSource = holder.getDataSource();
|
||||
if (dataSource != null) {
|
||||
dataSource.incrementExecuteBatchCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void incrementExecuteUpdateCount() {
|
||||
DruidPooledConnection conn = this.getPoolableConnection();
|
||||
if (conn != null) {
|
||||
DruidConnectionHolder holder = conn.getConnectionHolder();
|
||||
if (holder != null) {
|
||||
DruidAbstractDataSource dataSource = holder.getDataSource();
|
||||
if (dataSource != null) {
|
||||
dataSource.incrementExecuteUpdateCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void incrementExecuteQueryCount() {
|
||||
DruidPooledConnection conn = this.conn;
|
||||
if (conn != null) {
|
||||
DruidConnectionHolder holder = conn.holder;
|
||||
if (holder != null) {
|
||||
DruidAbstractDataSource dataSource = holder.dataSource;
|
||||
if (dataSource != null) {
|
||||
++dataSource.executeQueryCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void transactionRecord(String sql) throws SQLException {
|
||||
this.conn.transactionRecord(sql);
|
||||
}
|
||||
|
||||
public final ResultSet executeQuery(String sql) throws SQLException {
|
||||
this.checkOpen();
|
||||
this.incrementExecuteQueryCount();
|
||||
this.transactionRecord(sql);
|
||||
this.conn.beforeExecute();
|
||||
|
||||
ResultSet var3;
|
||||
try {
|
||||
ResultSet rs = this.stmt.executeQuery(sql);
|
||||
if (rs != null) {
|
||||
DruidPooledResultSet poolableResultSet = new DruidPooledResultSet(this, rs);
|
||||
this.addResultSetTrace(poolableResultSet);
|
||||
DruidPooledResultSet var4 = poolableResultSet;
|
||||
return var4;
|
||||
}
|
||||
|
||||
var3 = rs;
|
||||
} catch (Throwable t) {
|
||||
this.errorCheck(t);
|
||||
throw this.checkException(t, sql);
|
||||
} finally {
|
||||
this.conn.afterExecute();
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
|
||||
public final int executeUpdate(String sql) throws SQLException {
|
||||
this.checkOpen();
|
||||
this.incrementExecuteUpdateCount();
|
||||
this.transactionRecord(sql);
|
||||
this.conn.beforeExecute();
|
||||
|
||||
int var2;
|
||||
try {
|
||||
var2 = this.stmt.executeUpdate(sql);
|
||||
} catch (Throwable t) {
|
||||
this.errorCheck(t);
|
||||
throw this.checkException(t, sql);
|
||||
} finally {
|
||||
this.conn.afterExecute();
|
||||
}
|
||||
|
||||
return var2;
|
||||
}
|
||||
|
||||
protected final void errorCheck(Throwable t) {
|
||||
String errorClassName = t.getClass().getName();
|
||||
if (errorClassName.endsWith(".CommunicationsException") && this.conn.holder != null && this.conn.holder.dataSource.testWhileIdle) {
|
||||
DruidConnectionHolder holder = this.conn.holder;
|
||||
DruidAbstractDataSource dataSource = holder.dataSource;
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
long lastActiveTimeMillis = holder.lastActiveTimeMillis;
|
||||
if (lastActiveTimeMillis < holder.lastKeepTimeMillis) {
|
||||
lastActiveTimeMillis = holder.lastKeepTimeMillis;
|
||||
}
|
||||
|
||||
long idleMillis = currentTimeMillis - lastActiveTimeMillis;
|
||||
long lastValidIdleMillis = currentTimeMillis - holder.lastActiveTimeMillis;
|
||||
String errorMsg = "CommunicationsException, druid version " + VERSION.getVersionNumber() + ", jdbcUrl : " + dataSource.jdbcUrl + ", testWhileIdle " + dataSource.testWhileIdle + ", idle millis " + idleMillis + ", minIdle " + dataSource.minIdle + ", poolingCount " + dataSource.getPoolingCount() + ", timeBetweenEvictionRunsMillis " + dataSource.timeBetweenEvictionRunsMillis + ", lastValidIdleMillis " + lastValidIdleMillis + ", driver " + dataSource.driver.getClass().getName();
|
||||
if (dataSource.exceptionSorter != null) {
|
||||
errorMsg = errorMsg + ", exceptionSorter " + dataSource.exceptionSorter.getClass().getName();
|
||||
}
|
||||
|
||||
LOG.error(errorMsg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
|
||||
this.checkOpen();
|
||||
this.incrementExecuteUpdateCount();
|
||||
this.transactionRecord(sql);
|
||||
this.conn.beforeExecute();
|
||||
|
||||
int var3;
|
||||
try {
|
||||
var3 = this.stmt.executeUpdate(sql, autoGeneratedKeys);
|
||||
} catch (Throwable t) {
|
||||
this.errorCheck(t);
|
||||
throw this.checkException(t, sql);
|
||||
} finally {
|
||||
this.conn.afterExecute();
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
|
||||
public final int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
|
||||
this.checkOpen();
|
||||
this.incrementExecuteUpdateCount();
|
||||
this.transactionRecord(sql);
|
||||
this.conn.beforeExecute();
|
||||
|
||||
int var3;
|
||||
try {
|
||||
var3 = this.stmt.executeUpdate(sql, columnIndexes);
|
||||
} catch (Throwable t) {
|
||||
this.errorCheck(t);
|
||||
throw this.checkException(t, sql);
|
||||
} finally {
|
||||
this.conn.afterExecute();
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
|
||||
public final int executeUpdate(String sql, String[] columnNames) throws SQLException {
|
||||
this.checkOpen();
|
||||
this.incrementExecuteUpdateCount();
|
||||
this.transactionRecord(sql);
|
||||
this.conn.beforeExecute();
|
||||
|
||||
int var3;
|
||||
try {
|
||||
var3 = this.stmt.executeUpdate(sql, columnNames);
|
||||
} catch (Throwable t) {
|
||||
this.errorCheck(t);
|
||||
throw this.checkException(t, sql);
|
||||
} finally {
|
||||
this.conn.afterExecute();
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
|
||||
public final boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
|
||||
this.checkOpen();
|
||||
this.incrementExecuteCount();
|
||||
this.transactionRecord(sql);
|
||||
this.conn.beforeExecute();
|
||||
|
||||
boolean var3;
|
||||
try {
|
||||
var3 = this.stmt.execute(sql, autoGeneratedKeys);
|
||||
} catch (Throwable t) {
|
||||
this.errorCheck(t);
|
||||
throw this.checkException(t, sql);
|
||||
} finally {
|
||||
this.conn.afterExecute();
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
|
||||
public final boolean execute(String sql, int[] columnIndexes) throws SQLException {
|
||||
this.checkOpen();
|
||||
this.incrementExecuteCount();
|
||||
this.transactionRecord(sql);
|
||||
this.conn.beforeExecute();
|
||||
|
||||
boolean var3;
|
||||
try {
|
||||
var3 = this.stmt.execute(sql, columnIndexes);
|
||||
} catch (Throwable t) {
|
||||
this.errorCheck(t);
|
||||
throw this.checkException(t, sql);
|
||||
} finally {
|
||||
this.conn.afterExecute();
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
|
||||
public final boolean execute(String sql, String[] columnNames) throws SQLException {
|
||||
this.checkOpen();
|
||||
this.incrementExecuteCount();
|
||||
this.transactionRecord(sql);
|
||||
this.conn.beforeExecute();
|
||||
|
||||
boolean var3;
|
||||
try {
|
||||
var3 = this.stmt.execute(sql, columnNames);
|
||||
} catch (Throwable t) {
|
||||
this.errorCheck(t);
|
||||
throw this.checkException(t, sql);
|
||||
} finally {
|
||||
this.conn.afterExecute();
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
|
||||
|
||||
public int getMaxFieldSize() throws SQLException {
|
||||
this.checkOpen();
|
||||
|
||||
try {
|
||||
return this.stmt.getMaxFieldSize();
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public void close() throws SQLException {
|
||||
if (!this.closed) {
|
||||
this.clearResultSet();
|
||||
if (this.stmt != null) {
|
||||
this.stmt.close();
|
||||
}
|
||||
|
||||
this.closed = true;
|
||||
DruidConnectionHolder connHolder = this.conn.getConnectionHolder();
|
||||
if (connHolder != null) {
|
||||
connHolder.removeTrace(this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void setMaxFieldSize(int max) throws SQLException {
|
||||
this.checkOpen();
|
||||
|
||||
try {
|
||||
this.stmt.setMaxFieldSize(max);
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public final int getMaxRows() throws SQLException {
|
||||
this.checkOpen();
|
||||
|
||||
try {
|
||||
return this.stmt.getMaxRows();
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public void setMaxRows(int max) throws SQLException {
|
||||
this.checkOpen();
|
||||
|
||||
try {
|
||||
this.stmt.setMaxRows(max);
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public final void setEscapeProcessing(boolean enable) throws SQLException {
|
||||
this.checkOpen();
|
||||
|
||||
try {
|
||||
this.stmt.setEscapeProcessing(enable);
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public final int getQueryTimeout() throws SQLException {
|
||||
this.checkOpen();
|
||||
|
||||
try {
|
||||
return this.stmt.getQueryTimeout();
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public void setQueryTimeout(int seconds) throws SQLException {
|
||||
this.checkOpen();
|
||||
|
||||
try {
|
||||
this.stmt.setQueryTimeout(seconds);
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public final void cancel() throws SQLException {
|
||||
this.checkOpen();
|
||||
|
||||
try {
|
||||
this.stmt.cancel();
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public final SQLWarning getWarnings() throws SQLException {
|
||||
this.checkOpen();
|
||||
|
||||
try {
|
||||
return this.stmt.getWarnings();
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public final void clearWarnings() throws SQLException {
|
||||
this.checkOpen();
|
||||
|
||||
try {
|
||||
this.stmt.clearWarnings();
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public final void setCursorName(String name) throws SQLException {
|
||||
this.checkOpen();
|
||||
|
||||
try {
|
||||
this.stmt.setCursorName(name);
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean execute(String sql) throws SQLException {
|
||||
checkOpen();
|
||||
|
||||
incrementExecuteCount();
|
||||
transactionRecord(sql);
|
||||
|
||||
try {
|
||||
if (StringUtils.isNotEmpty(sql)){
|
||||
sql = sql.replace("TRUE", "1");
|
||||
sql = sql.replace("FALSE", "0");
|
||||
}
|
||||
return stmt.execute(sql);
|
||||
} catch (Throwable t) {
|
||||
errorCheck(t);
|
||||
throw checkException(t, sql);
|
||||
}
|
||||
}
|
||||
|
||||
public final ResultSet getResultSet() throws SQLException {
|
||||
this.checkOpen();
|
||||
|
||||
try {
|
||||
ResultSet rs = this.stmt.getResultSet();
|
||||
if (rs == null) {
|
||||
return null;
|
||||
} else {
|
||||
DruidPooledResultSet poolableResultSet = new DruidPooledResultSet(this, rs);
|
||||
this.addResultSetTrace(poolableResultSet);
|
||||
return poolableResultSet;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public final int getUpdateCount() throws SQLException {
|
||||
this.checkOpen();
|
||||
|
||||
try {
|
||||
return this.stmt.getUpdateCount();
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean getMoreResults() throws SQLException {
|
||||
this.checkOpen();
|
||||
|
||||
try {
|
||||
boolean moreResults = this.stmt.getMoreResults();
|
||||
if (this.resultSetTrace != null && this.resultSetTrace.size() > 0) {
|
||||
ResultSet lastResultSet = (ResultSet)this.resultSetTrace.get(this.resultSetTrace.size() - 1);
|
||||
if (lastResultSet instanceof DruidPooledResultSet) {
|
||||
DruidPooledResultSet pooledResultSet = (DruidPooledResultSet)lastResultSet;
|
||||
pooledResultSet.closed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return moreResults;
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public void setFetchDirection(int direction) throws SQLException {
|
||||
this.checkOpen();
|
||||
|
||||
try {
|
||||
this.stmt.setFetchDirection(direction);
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public final int getFetchDirection() throws SQLException {
|
||||
this.checkOpen();
|
||||
|
||||
try {
|
||||
return this.stmt.getFetchDirection();
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public void setFetchSize(int rows) throws SQLException {
|
||||
this.checkOpen();
|
||||
|
||||
try {
|
||||
this.stmt.setFetchSize(rows);
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public final int getFetchSize() throws SQLException {
|
||||
this.checkOpen();
|
||||
|
||||
try {
|
||||
return this.stmt.getFetchSize();
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public final int getResultSetConcurrency() throws SQLException {
|
||||
this.checkOpen();
|
||||
|
||||
try {
|
||||
return this.stmt.getResultSetConcurrency();
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public final int getResultSetType() throws SQLException {
|
||||
this.checkOpen();
|
||||
|
||||
try {
|
||||
return this.stmt.getResultSetType();
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public final void addBatch(String sql) throws SQLException {
|
||||
this.checkOpen();
|
||||
this.transactionRecord(sql);
|
||||
|
||||
try {
|
||||
this.stmt.addBatch(sql);
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t, sql);
|
||||
}
|
||||
}
|
||||
|
||||
public final void clearBatch() throws SQLException {
|
||||
if (!this.closed) {
|
||||
try {
|
||||
this.stmt.clearBatch();
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int[] executeBatch() throws SQLException {
|
||||
this.checkOpen();
|
||||
this.incrementExecuteBatchCount();
|
||||
this.conn.beforeExecute();
|
||||
|
||||
int[] var1;
|
||||
try {
|
||||
var1 = this.stmt.executeBatch();
|
||||
} catch (Throwable t) {
|
||||
this.errorCheck(t);
|
||||
throw this.checkException(t);
|
||||
} finally {
|
||||
this.conn.afterExecute();
|
||||
}
|
||||
|
||||
return var1;
|
||||
}
|
||||
|
||||
public final Connection getConnection() throws SQLException {
|
||||
this.checkOpen();
|
||||
return this.conn;
|
||||
}
|
||||
|
||||
public final boolean getMoreResults(int current) throws SQLException {
|
||||
this.checkOpen();
|
||||
|
||||
try {
|
||||
boolean results = this.stmt.getMoreResults(current);
|
||||
if (this.resultSetTrace != null && this.resultSetTrace.size() > 0) {
|
||||
ResultSet lastResultSet = (ResultSet)this.resultSetTrace.get(this.resultSetTrace.size() - 1);
|
||||
if (lastResultSet instanceof DruidPooledResultSet) {
|
||||
DruidPooledResultSet pooledResultSet = (DruidPooledResultSet)lastResultSet;
|
||||
pooledResultSet.closed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public final ResultSet getGeneratedKeys() throws SQLException {
|
||||
this.checkOpen();
|
||||
|
||||
try {
|
||||
ResultSet rs = this.stmt.getGeneratedKeys();
|
||||
DruidPooledResultSet poolableResultSet = new DruidPooledResultSet(this, rs);
|
||||
this.addResultSetTrace(poolableResultSet);
|
||||
return poolableResultSet;
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public final int getResultSetHoldability() throws SQLException {
|
||||
this.checkOpen();
|
||||
|
||||
try {
|
||||
return this.stmt.getResultSetHoldability();
|
||||
} catch (Throwable t) {
|
||||
throw this.checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean isClosed() throws SQLException {
|
||||
return this.closed;
|
||||
}
|
||||
|
||||
public final void setPoolable(boolean poolable) throws SQLException {
|
||||
if (!poolable) {
|
||||
throw new SQLException("not support");
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean isPoolable() throws SQLException {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.stmt.toString();
|
||||
}
|
||||
|
||||
public void closeOnCompletion() throws SQLException {
|
||||
this.stmt.closeOnCompletion();
|
||||
}
|
||||
|
||||
public boolean isCloseOnCompletion() throws SQLException {
|
||||
return this.stmt.isCloseOnCompletion();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,546 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package liquibase.database.core;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import liquibase.CatalogAndSchema;
|
||||
import liquibase.GlobalConfiguration;
|
||||
import liquibase.Scope;
|
||||
import liquibase.database.AbstractJdbcDatabase;
|
||||
import liquibase.database.DatabaseConnection;
|
||||
import liquibase.database.OfflineConnection;
|
||||
import liquibase.database.jvm.JdbcConnection;
|
||||
import liquibase.exception.DatabaseException;
|
||||
import liquibase.exception.UnexpectedLiquibaseException;
|
||||
import liquibase.exception.ValidationErrors;
|
||||
import liquibase.executor.ExecutorService;
|
||||
import liquibase.statement.DatabaseFunction;
|
||||
import liquibase.statement.SequenceCurrentValueFunction;
|
||||
import liquibase.statement.SequenceNextValueFunction;
|
||||
import liquibase.statement.UniqueConstraint;
|
||||
import liquibase.statement.core.RawCallStatement;
|
||||
import liquibase.statement.core.RawParameterizedSqlStatement;
|
||||
import liquibase.structure.DatabaseObject;
|
||||
import liquibase.structure.core.Catalog;
|
||||
import liquibase.structure.core.Column;
|
||||
import liquibase.structure.core.Index;
|
||||
import liquibase.structure.core.PrimaryKey;
|
||||
import liquibase.structure.core.Schema;
|
||||
import liquibase.util.JdbcUtil;
|
||||
import liquibase.util.StringUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class DmDatabase extends AbstractJdbcDatabase {
|
||||
private static final String PROXY_USER_REGEX = ".*(?:thin|oci)\\:(.+)/@.*";
|
||||
public static final Pattern PROXY_USER_PATTERN = Pattern.compile(".*(?:thin|oci)\\:(.+)/@.*");
|
||||
private static final String VERSION_REGEX = "(\\d+)\\.(\\d+)\\..*";
|
||||
private static final Pattern VERSION_PATTERN = Pattern.compile("(\\d+)\\.(\\d+)\\..*");
|
||||
public static final String PRODUCT_NAME = "DM DBMS";
|
||||
private static final ResourceBundle coreBundle = ResourceBundle.getBundle("liquibase/i18n/liquibase-core");
|
||||
protected final int SHORT_IDENTIFIERS_LENGTH = 30;
|
||||
protected final int LONG_IDENTIFIERS_LEGNTH = 128;
|
||||
public static final int ORACLE_12C_MAJOR_VERSION = 12;
|
||||
public static final int ORACLE_23C_MAJOR_VERSION = 23;
|
||||
private final Set<String> reservedWords = new HashSet();
|
||||
private Set<String> userDefinedTypes;
|
||||
private Map<String, String> savedSessionNlsSettings;
|
||||
private Boolean canAccessDbaRecycleBin;
|
||||
private Integer databaseMajorVersion;
|
||||
private Integer databaseMinorVersion;
|
||||
|
||||
public DmDatabase() {
|
||||
super.unquotedObjectsAreUppercased = true;
|
||||
super.setCurrentDateTimeFunction("SYSTIMESTAMP");
|
||||
this.dateFunctions.add(new DatabaseFunction("SYSDATE"));
|
||||
this.dateFunctions.add(new DatabaseFunction("SYSTIMESTAMP"));
|
||||
this.dateFunctions.add(new DatabaseFunction("CURRENT_TIMESTAMP"));
|
||||
super.sequenceNextValueFunction = "%s.nextval";
|
||||
super.sequenceCurrentValueFunction = "%s.currval";
|
||||
}
|
||||
|
||||
public int getPriority() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
private void tryProxySession(String url, Connection con) {
|
||||
Matcher m = PROXY_USER_PATTERN.matcher(url);
|
||||
if (m.matches()) {
|
||||
Properties props = new Properties();
|
||||
props.put("PROXY_USER_NAME", m.group(1));
|
||||
|
||||
try {
|
||||
Method method = con.getClass().getMethod("openProxySession", Integer.TYPE, Properties.class);
|
||||
method.setAccessible(true);
|
||||
method.invoke(con, 1, props);
|
||||
} catch (Exception e) {
|
||||
Scope.getCurrentScope().getLog(this.getClass()).info("Could not open proxy session on OracleDatabase: " + e.getCause().getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Method method = con.getClass().getMethod("isProxySession");
|
||||
method.setAccessible(true);
|
||||
boolean b = (Boolean)method.invoke(con);
|
||||
if (!b) {
|
||||
Scope.getCurrentScope().getLog(this.getClass()).info("Proxy session not established on OracleDatabase: ");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Scope.getCurrentScope().getLog(this.getClass()).info("Could not open proxy session on OracleDatabase: " + e.getCause().getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setConnection(DatabaseConnection conn) {
|
||||
this.reservedWords.addAll(Arrays.asList("GROUP", "USER", "SESSION", "PASSWORD", "RESOURCE", "START", "SIZE", "UID", "DESC", "ORDER"));
|
||||
Connection sqlConn = null;
|
||||
if (!(conn instanceof OfflineConnection)) {
|
||||
try {
|
||||
if (conn instanceof JdbcConnection) {
|
||||
sqlConn = ((JdbcConnection)conn).getWrappedConnection();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new UnexpectedLiquibaseException(e);
|
||||
}
|
||||
|
||||
if (sqlConn != null) {
|
||||
this.tryProxySession(conn.getURL(), sqlConn);
|
||||
|
||||
try {
|
||||
this.reservedWords.addAll(Arrays.asList(sqlConn.getMetaData().getSQLKeywords().toUpperCase().split(",\\s*")));
|
||||
} catch (SQLException e) {
|
||||
Scope.getCurrentScope().getLog(this.getClass()).info("Could get sql keywords on OracleDatabase: " + e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
Method method = sqlConn.getClass().getMethod("setRemarksReporting", Boolean.TYPE);
|
||||
method.setAccessible(true);
|
||||
method.invoke(sqlConn, true);
|
||||
} catch (Exception e) {
|
||||
Scope.getCurrentScope().getLog(this.getClass()).info("Could not set remarks reporting on OracleDatabase: " + e.getMessage());
|
||||
}
|
||||
|
||||
CallableStatement statement = null;
|
||||
|
||||
try {
|
||||
statement = sqlConn.prepareCall("{call DBMS_UTILITY.DB_VERSION(?,?)}");
|
||||
statement.registerOutParameter(1, 12);
|
||||
statement.registerOutParameter(2, 12);
|
||||
statement.execute();
|
||||
String compatibleVersion = statement.getString(2);
|
||||
if (compatibleVersion != null) {
|
||||
Matcher majorVersionMatcher = VERSION_PATTERN.matcher(compatibleVersion);
|
||||
if (majorVersionMatcher.matches()) {
|
||||
this.databaseMajorVersion = Integer.valueOf(majorVersionMatcher.group(1));
|
||||
this.databaseMinorVersion = Integer.valueOf(majorVersionMatcher.group(2));
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String message = "Cannot read from DBMS_UTILITY.DB_VERSION: " + e.getMessage();
|
||||
Scope.getCurrentScope().getLog(this.getClass()).info("Could not set check compatibility mode on OracleDatabase, assuming not running in any sort of compatibility mode: " + message);
|
||||
} finally {
|
||||
JdbcUtil.closeStatement(statement);
|
||||
}
|
||||
|
||||
if (GlobalConfiguration.DDL_LOCK_TIMEOUT.getCurrentValue() != null) {
|
||||
int timeoutValue = (Integer)GlobalConfiguration.DDL_LOCK_TIMEOUT.getCurrentValue();
|
||||
Scope.getCurrentScope().getLog(this.getClass()).fine("Setting DDL_LOCK_TIMEOUT value to " + timeoutValue);
|
||||
String sql = "ALTER SESSION SET DDL_LOCK_TIMEOUT=" + timeoutValue;
|
||||
PreparedStatement ddlLockTimeoutStatement = null;
|
||||
|
||||
try {
|
||||
ddlLockTimeoutStatement = sqlConn.prepareStatement(sql);
|
||||
ddlLockTimeoutStatement.execute();
|
||||
} catch (SQLException sqle) {
|
||||
Scope.getCurrentScope().getUI().sendErrorMessage("Unable to set the DDL_LOCK_TIMEOUT_VALUE: " + sqle.getMessage(), sqle);
|
||||
Scope.getCurrentScope().getLog(this.getClass()).warning("Unable to set the DDL_LOCK_TIMEOUT_VALUE: " + sqle.getMessage(), sqle);
|
||||
} finally {
|
||||
JdbcUtil.closeStatement(ddlLockTimeoutStatement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.setConnection(conn);
|
||||
}
|
||||
|
||||
public String getShortName() {
|
||||
return "dm";
|
||||
}
|
||||
|
||||
protected String getDefaultDatabaseProductName() {
|
||||
return PRODUCT_NAME;
|
||||
}
|
||||
|
||||
public int getDatabaseMajorVersion() throws DatabaseException {
|
||||
return this.databaseMajorVersion == null ? super.getDatabaseMajorVersion() : this.databaseMajorVersion;
|
||||
}
|
||||
|
||||
public int getDatabaseMinorVersion() throws DatabaseException {
|
||||
return this.databaseMinorVersion == null ? super.getDatabaseMinorVersion() : this.databaseMinorVersion;
|
||||
}
|
||||
|
||||
public Integer getDefaultPort() {
|
||||
return 5236;
|
||||
}
|
||||
|
||||
public String getJdbcCatalogName(CatalogAndSchema schema) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getJdbcSchemaName(CatalogAndSchema schema) {
|
||||
return this.correctObjectName(schema.getCatalogName() == null ? schema.getSchemaName() : schema.getCatalogName(), Schema.class);
|
||||
}
|
||||
|
||||
protected String getAutoIncrementClause(String generationType, Boolean defaultOnNull) {
|
||||
if (StringUtil.isEmpty(generationType)) {
|
||||
return super.getAutoIncrementClause();
|
||||
} else {
|
||||
String autoIncrementClause = "GENERATED %s AS IDENTITY";
|
||||
String generationStrategy = generationType;
|
||||
if (Boolean.TRUE.equals(defaultOnNull) && generationType.toUpperCase().equals("BY DEFAULT")) {
|
||||
generationStrategy = generationType + " ON NULL";
|
||||
}
|
||||
|
||||
return String.format(autoIncrementClause, generationStrategy);
|
||||
}
|
||||
}
|
||||
|
||||
public String generatePrimaryKeyName(String tableName) {
|
||||
return tableName.length() > 27 ? "PK_" + tableName.toUpperCase(Locale.US).substring(0, 27) : "PK_" + tableName.toUpperCase(Locale.US);
|
||||
}
|
||||
|
||||
public boolean supportsInitiallyDeferrableColumns() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReservedWord(String objectName) {
|
||||
return this.reservedWords.contains(objectName.toUpperCase());
|
||||
}
|
||||
|
||||
public boolean supportsSequences() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean supports(Class<? extends DatabaseObject> object) {
|
||||
return Schema.class.isAssignableFrom(object) ? false : super.supports(object);
|
||||
}
|
||||
|
||||
public boolean supportsSchemas() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected String getConnectionCatalogName() throws DatabaseException {
|
||||
if (this.getConnection() instanceof OfflineConnection) {
|
||||
return this.getConnection().getCatalog();
|
||||
} else if (!(this.getConnection() instanceof JdbcConnection)) {
|
||||
return this.defaultCatalogName;
|
||||
} else {
|
||||
try {
|
||||
return (String)((ExecutorService)Scope.getCurrentScope().getSingleton(ExecutorService.class)).getExecutor("jdbc", this).queryForObject(new RawCallStatement("select sys_context( 'userenv', 'current_schema' ) from dual"), String.class);
|
||||
} catch (Exception e) {
|
||||
Scope.getCurrentScope().getLog(this.getClass()).info("Error getting default schema", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCorrectDatabaseImplementation(DatabaseConnection conn) throws DatabaseException {
|
||||
return "oracle".equalsIgnoreCase(conn.getDatabaseProductName());
|
||||
}
|
||||
|
||||
public String getDefaultDriver(String url) {
|
||||
return url.startsWith("jdbc:dm") ? "dm.jdbc.driver.DmDriver" : null;
|
||||
}
|
||||
|
||||
public String getDefaultCatalogName() {
|
||||
String defaultCatalogName = super.getDefaultCatalogName();
|
||||
if (Boolean.TRUE.equals(GlobalConfiguration.PRESERVE_SCHEMA_CASE.getCurrentValue())) {
|
||||
return defaultCatalogName;
|
||||
} else {
|
||||
return defaultCatalogName == null ? null : defaultCatalogName.toUpperCase(Locale.US);
|
||||
}
|
||||
}
|
||||
|
||||
public String getDateLiteral(String isoDate) {
|
||||
String normalLiteral = super.getDateLiteral(isoDate);
|
||||
if (this.isDateOnly(isoDate)) {
|
||||
return "TO_DATE(" + normalLiteral + ", 'YYYY-MM-DD')";
|
||||
} else if (this.isTimeOnly(isoDate)) {
|
||||
return "TO_DATE(" + normalLiteral + ", 'HH24:MI:SS')";
|
||||
} else if (this.isTimestamp(isoDate)) {
|
||||
return "TO_TIMESTAMP(" + normalLiteral + ", 'YYYY-MM-DD HH24:MI:SS.FF')";
|
||||
} else if (this.isDateTime(isoDate)) {
|
||||
int seppos = normalLiteral.lastIndexOf(46);
|
||||
if (seppos != -1) {
|
||||
normalLiteral = normalLiteral.substring(0, seppos) + "'";
|
||||
}
|
||||
|
||||
return "TO_DATE(" + normalLiteral + ", 'YYYY-MM-DD HH24:MI:SS')";
|
||||
} else {
|
||||
return "UNSUPPORTED:" + isoDate;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSystemObject(DatabaseObject example) {
|
||||
if (example == null) {
|
||||
return false;
|
||||
} else if (this.isLiquibaseObject(example)) {
|
||||
return false;
|
||||
} else {
|
||||
if (example instanceof Schema) {
|
||||
if ("SYSTEM".equals(example.getName()) || "SYS".equals(example.getName()) || "CTXSYS".equals(example.getName()) || "XDB".equals(example.getName())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ("SYSTEM".equals(example.getSchema().getCatalogName()) || "SYS".equals(example.getSchema().getCatalogName()) || "CTXSYS".equals(example.getSchema().getCatalogName()) || "XDB".equals(example.getSchema().getCatalogName())) {
|
||||
return true;
|
||||
}
|
||||
} else if (this.isSystemObject(example.getSchema())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (example instanceof Catalog) {
|
||||
if ("SYSTEM".equals(example.getName()) || "SYS".equals(example.getName()) || "CTXSYS".equals(example.getName()) || "XDB".equals(example.getName())) {
|
||||
return true;
|
||||
}
|
||||
} else if (example.getName() != null) {
|
||||
if (example.getName().startsWith("BIN$")) {
|
||||
boolean filteredInOriginalQuery = this.canAccessDbaRecycleBin();
|
||||
if (!filteredInOriginalQuery) {
|
||||
filteredInOriginalQuery = StringUtil.trimToEmpty(example.getSchema().getName()).equalsIgnoreCase(this.getConnection().getConnectionUserName());
|
||||
}
|
||||
|
||||
if (!filteredInOriginalQuery) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return !(example instanceof PrimaryKey) && !(example instanceof Index) && !(example instanceof UniqueConstraint);
|
||||
}
|
||||
|
||||
if (example.getName().startsWith("AQ$")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (example.getName().startsWith("DR$")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (example.getName().startsWith("SYS_IOT_OVER")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((example.getName().startsWith("MDRT_") || example.getName().startsWith("MDRS_")) && example.getName().endsWith("$")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (example.getName().startsWith("MLOG$_")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (example.getName().startsWith("RUPD$_")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (example.getName().startsWith("WM$_")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ("CREATE$JAVA$LOB$TABLE".equals(example.getName())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ("JAVA$CLASS$MD5$TABLE".equals(example.getName())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (example.getName().startsWith("ISEQ$$_")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (example.getName().startsWith("USLOG$")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (example.getName().startsWith("SYS_FBA")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.isSystemObject(example);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean supportsTablespaces() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean supportsAutoIncrement() {
|
||||
boolean isAutoIncrementSupported = false;
|
||||
|
||||
try {
|
||||
if (this.getDatabaseMajorVersion() >= 12) {
|
||||
isAutoIncrementSupported = true;
|
||||
}
|
||||
} catch (DatabaseException var3) {
|
||||
isAutoIncrementSupported = false;
|
||||
}
|
||||
|
||||
return isAutoIncrementSupported;
|
||||
}
|
||||
|
||||
public boolean supportsRestrictForeignKeys() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getDataTypeMaxParameters(String dataTypeName) {
|
||||
if ("BINARY_FLOAT".equals(dataTypeName.toUpperCase())) {
|
||||
return 0;
|
||||
} else {
|
||||
return "BINARY_DOUBLE".equals(dataTypeName.toUpperCase()) ? 0 : super.getDataTypeMaxParameters(dataTypeName);
|
||||
}
|
||||
}
|
||||
|
||||
public String getSystemTableWhereClause(String tableNameColumn) {
|
||||
List<String> clauses = new ArrayList(Arrays.asList("BIN$", "AQ$", "DR$", "SYS_IOT_OVER", "MLOG$_", "RUPD$_", "WM$_", "ISEQ$$_", "USLOG$", "SYS_FBA"));
|
||||
clauses.replaceAll((s) -> tableNameColumn + " NOT LIKE '" + s + "%'");
|
||||
return "(" + StringUtil.join(clauses, " AND ") + ")";
|
||||
}
|
||||
|
||||
public boolean jdbcCallsCatalogsSchemas() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Set<String> getUserDefinedTypes() {
|
||||
if (this.userDefinedTypes == null) {
|
||||
this.userDefinedTypes = new HashSet();
|
||||
if (this.getConnection() != null && !(this.getConnection() instanceof OfflineConnection)) {
|
||||
try {
|
||||
try {
|
||||
this.userDefinedTypes.addAll(((ExecutorService)Scope.getCurrentScope().getSingleton(ExecutorService.class)).getExecutor("jdbc", this).queryForList(new RawParameterizedSqlStatement("SELECT DISTINCT TYPE_NAME FROM ALL_TYPES"), String.class));
|
||||
} catch (DatabaseException var2) {
|
||||
this.userDefinedTypes.addAll(((ExecutorService)Scope.getCurrentScope().getSingleton(ExecutorService.class)).getExecutor("jdbc", this).queryForList(new RawParameterizedSqlStatement("SELECT TYPE_NAME FROM USER_TYPES"), String.class));
|
||||
}
|
||||
} catch (DatabaseException var3) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.userDefinedTypes;
|
||||
}
|
||||
|
||||
public String generateDatabaseFunctionValue(DatabaseFunction databaseFunction) {
|
||||
if (databaseFunction != null && "current_timestamp".equalsIgnoreCase(databaseFunction.toString())) {
|
||||
return databaseFunction.toString();
|
||||
} else if (!(databaseFunction instanceof SequenceNextValueFunction) && !(databaseFunction instanceof SequenceCurrentValueFunction)) {
|
||||
return super.generateDatabaseFunctionValue(databaseFunction);
|
||||
} else {
|
||||
String quotedSeq = super.generateDatabaseFunctionValue(databaseFunction);
|
||||
return quotedSeq.replaceFirst("\"([^.\"]+)\\.([^.\"]+)\"", "\"$1\".\"$2\"");
|
||||
}
|
||||
}
|
||||
|
||||
public ValidationErrors validate() {
|
||||
ValidationErrors errors = super.validate();
|
||||
DatabaseConnection connection = this.getConnection();
|
||||
if (connection != null && !(connection instanceof OfflineConnection)) {
|
||||
if (!this.canAccessDbaRecycleBin()) {
|
||||
errors.addWarning(this.getDbaRecycleBinWarning());
|
||||
}
|
||||
|
||||
return errors;
|
||||
} else {
|
||||
Scope.getCurrentScope().getLog(this.getClass()).info("Cannot validate offline database");
|
||||
return errors;
|
||||
}
|
||||
}
|
||||
|
||||
public String getDbaRecycleBinWarning() {
|
||||
return "Liquibase needs to access the DBA_RECYCLEBIN table so we can automatically handle the case where constraints are deleted and restored. Since Oracle doesn't properly restore the original table names referenced in the constraint, we use the information from the DBA_RECYCLEBIN to automatically correct this issue.\n\nThe user you used to connect to the database (" + this.getConnection().getConnectionUserName() + ") needs to have \"SELECT ON SYS.DBA_RECYCLEBIN\" permissions set before we can perform this operation. Please run the following SQL to set the appropriate permissions, and try running the command again.\n\n GRANT SELECT ON SYS.DBA_RECYCLEBIN TO " + this.getConnection().getConnectionUserName() + ";";
|
||||
}
|
||||
|
||||
public boolean canAccessDbaRecycleBin() {
|
||||
if (this.canAccessDbaRecycleBin == null) {
|
||||
DatabaseConnection connection = this.getConnection();
|
||||
if (connection == null || connection instanceof OfflineConnection) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Statement statement = null;
|
||||
|
||||
try {
|
||||
statement = ((JdbcConnection)connection).createStatement();
|
||||
ResultSet resultSet = statement.executeQuery("select 1 from dba_recyclebin where 0=1");
|
||||
resultSet.close();
|
||||
this.canAccessDbaRecycleBin = true;
|
||||
} catch (Exception var7) {
|
||||
if (var7 instanceof SQLException && var7.getMessage().startsWith("ORA-00942")) {
|
||||
this.canAccessDbaRecycleBin = false;
|
||||
} else {
|
||||
Scope.getCurrentScope().getLog(this.getClass()).warning("Cannot check dba_recyclebin access", var7);
|
||||
this.canAccessDbaRecycleBin = false;
|
||||
}
|
||||
} finally {
|
||||
JdbcUtil.close((ResultSet)null, statement);
|
||||
}
|
||||
}
|
||||
|
||||
return this.canAccessDbaRecycleBin;
|
||||
}
|
||||
|
||||
public boolean supportsNotNullConstraintNames() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isValidOracleIdentifier(String identifier, Class<? extends DatabaseObject> type) {
|
||||
if (identifier != null && identifier.length() >= 1) {
|
||||
if (!identifier.matches("^(i?)[A-Z][A-Z0-9\\$\\_\\#]*$")) {
|
||||
return false;
|
||||
} else {
|
||||
return identifier.length() <= 128;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int getIdentifierMaximumLength() {
|
||||
try {
|
||||
if (this.getDatabaseMajorVersion() < 12) {
|
||||
return 30;
|
||||
} else {
|
||||
return this.getDatabaseMajorVersion() == 12 && this.getDatabaseMinorVersion() <= 1 ? 30 : 128;
|
||||
}
|
||||
} catch (DatabaseException ex) {
|
||||
throw new UnexpectedLiquibaseException("Cannot determine the Oracle database version number", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean supportsDatabaseChangeLogHistory() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String correctObjectName(String objectName, Class<? extends DatabaseObject> objectType) {
|
||||
return objectType.equals(Column.class) && StringUtils.startsWithIgnoreCase(objectName, "int") ? "NUMBER(*, 0)" : super.correctObjectName(objectName, objectType);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package liquibase.datatype.core;
|
||||
|
||||
import liquibase.change.core.LoadDataChange;
|
||||
import liquibase.database.Database;
|
||||
import liquibase.database.core.*;
|
||||
import liquibase.datatype.DataTypeInfo;
|
||||
import liquibase.datatype.DatabaseDataType;
|
||||
import liquibase.datatype.LiquibaseDataType;
|
||||
import liquibase.exception.UnexpectedLiquibaseException;
|
||||
import liquibase.statement.DatabaseFunction;
|
||||
import liquibase.util.StringUtil;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@DataTypeInfo(name = "boolean", aliases = {"java.sql.Types.BOOLEAN", "java.lang.Boolean", "bit", "bool"}, minParameters = 0, maxParameters = 0, priority = LiquibaseDataType.PRIORITY_DEFAULT)
|
||||
public class BooleanType extends LiquibaseDataType {
|
||||
|
||||
@Override
|
||||
public DatabaseDataType toDatabaseDataType(Database database) {
|
||||
String originalDefinition = StringUtil.trimToEmpty(getRawDefinition());
|
||||
// if ((database instanceof Firebird3Database)) {
|
||||
// return new DatabaseDataType("BOOLEAN");
|
||||
// }
|
||||
|
||||
if ((database instanceof AbstractDb2Database) || (database instanceof FirebirdDatabase)) {
|
||||
return new DatabaseDataType("SMALLINT");
|
||||
} else if (database instanceof MSSQLDatabase) {
|
||||
return new DatabaseDataType(database.escapeDataTypeName("bit"));
|
||||
} else if (database instanceof MySQLDatabase) {
|
||||
if (originalDefinition.toLowerCase(Locale.US).startsWith("bit")) {
|
||||
return new DatabaseDataType("BIT", getParameters());
|
||||
}
|
||||
return new DatabaseDataType("BIT", 1);
|
||||
} else if (database instanceof OracleDatabase) {
|
||||
return new DatabaseDataType("NUMBER", 1);
|
||||
} else if ((database instanceof SybaseASADatabase) || (database instanceof SybaseDatabase)) {
|
||||
return new DatabaseDataType("BIT");
|
||||
} else if (database instanceof DerbyDatabase) {
|
||||
if (((DerbyDatabase) database).supportsBooleanDataType()) {
|
||||
return new DatabaseDataType("BOOLEAN");
|
||||
} else {
|
||||
return new DatabaseDataType("SMALLINT");
|
||||
}
|
||||
} else if (database.getClass().isAssignableFrom(DB2Database.class)) {
|
||||
if (((DB2Database) database).supportsBooleanDataType())
|
||||
return new DatabaseDataType("BOOLEAN");
|
||||
else
|
||||
return new DatabaseDataType("SMALLINT");
|
||||
} else if (database instanceof HsqlDatabase) {
|
||||
return new DatabaseDataType("BOOLEAN");
|
||||
} else if (database instanceof PostgresDatabase) {
|
||||
if (originalDefinition.toLowerCase(Locale.US).startsWith("bit")) {
|
||||
return new DatabaseDataType("BIT", getParameters());
|
||||
}
|
||||
} else if(database instanceof DmDatabase) {
|
||||
return new DatabaseDataType("bit");
|
||||
}
|
||||
|
||||
return super.toDatabaseDataType(database);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String objectToSql(Object value, Database database) {
|
||||
if ((value == null) || "null".equals(value.toString().toLowerCase(Locale.US))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String returnValue;
|
||||
if (value instanceof String) {
|
||||
value = ((String) value).replaceAll("'", "");
|
||||
if ("true".equals(((String) value).toLowerCase(Locale.US)) || "1".equals(value) || "b'1'".equals(((String) value).toLowerCase(Locale.US)) || "t".equals(((String) value).toLowerCase(Locale.US)) || ((String) value).toLowerCase(Locale.US).equals(this.getTrueBooleanValue(database).toLowerCase(Locale.US))) {
|
||||
returnValue = this.getTrueBooleanValue(database);
|
||||
} else if ("false".equals(((String) value).toLowerCase(Locale.US)) || "0".equals(value) || "b'0'".equals(
|
||||
((String) value).toLowerCase(Locale.US)) || "f".equals(((String) value).toLowerCase(Locale.US)) || ((String) value).toLowerCase(Locale.US).equals(this.getFalseBooleanValue(database).toLowerCase(Locale.US))) {
|
||||
returnValue = this.getFalseBooleanValue(database);
|
||||
} else {
|
||||
throw new UnexpectedLiquibaseException("Unknown boolean value: " + value);
|
||||
}
|
||||
} else if (value instanceof Long) {
|
||||
if (Long.valueOf(1).equals(value)) {
|
||||
returnValue = this.getTrueBooleanValue(database);
|
||||
} else {
|
||||
returnValue = this.getFalseBooleanValue(database);
|
||||
}
|
||||
} else if (value instanceof Number) {
|
||||
if (value.equals(1) || "1".equals(value.toString()) || "1.0".equals(value.toString())) {
|
||||
returnValue = this.getTrueBooleanValue(database);
|
||||
} else {
|
||||
returnValue = this.getFalseBooleanValue(database);
|
||||
}
|
||||
} else if (value instanceof DatabaseFunction) {
|
||||
return value.toString();
|
||||
} else if (value instanceof Boolean) {
|
||||
if (((Boolean) value)) {
|
||||
returnValue = this.getTrueBooleanValue(database);
|
||||
} else {
|
||||
returnValue = this.getFalseBooleanValue(database);
|
||||
}
|
||||
} else {
|
||||
throw new UnexpectedLiquibaseException("Cannot convert type " + value.getClass() + " to a boolean value");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
protected boolean isNumericBoolean(Database database) {
|
||||
if (database instanceof DerbyDatabase) {
|
||||
return !((DerbyDatabase) database).supportsBooleanDataType();
|
||||
} else if (database.getClass().isAssignableFrom(DB2Database.class)) {
|
||||
return !((DB2Database) database).supportsBooleanDataType();
|
||||
}
|
||||
return (database instanceof Db2zDatabase) || (database instanceof DB2Database) || (database instanceof FirebirdDatabase) || (database instanceof
|
||||
MSSQLDatabase) || (database instanceof MySQLDatabase) || (database instanceof OracleDatabase) ||
|
||||
(database instanceof SQLiteDatabase) || (database instanceof SybaseASADatabase) || (database instanceof
|
||||
SybaseDatabase) || (database instanceof DmDatabase);
|
||||
}
|
||||
|
||||
/**
|
||||
* The database-specific value to use for "false" "boolean" columns.
|
||||
*/
|
||||
public String getFalseBooleanValue(Database database) {
|
||||
if (isNumericBoolean(database)) {
|
||||
return "0";
|
||||
}
|
||||
if (database instanceof InformixDatabase) {
|
||||
return "'f'";
|
||||
}
|
||||
return "FALSE";
|
||||
}
|
||||
|
||||
/**
|
||||
* The database-specific value to use for "true" "boolean" columns.
|
||||
*/
|
||||
public String getTrueBooleanValue(Database database) {
|
||||
if (isNumericBoolean(database)) {
|
||||
return "1";
|
||||
}
|
||||
if (database instanceof InformixDatabase) {
|
||||
return "'t'";
|
||||
}
|
||||
return "TRUE";
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() {
|
||||
return LoadDataChange.LOAD_DATA_TYPE.BOOLEAN;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
Reference in New Issue
Block a user