Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
开发团队
Flowable Engine
提交
2839acef
F
Flowable Engine
项目概览
开发团队
/
Flowable Engine
通知
9
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Flowable Engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2839acef
编写于
10月 13, 2017
作者:
J
Joram Barrez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix contentDbSchemaManager not using correct changelog
上级
ee4f943f
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
44 addition
and
245 deletion
+44
-245
modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/util/DbSchemaGenerator.java
...org/flowable/cmmn/engine/impl/util/DbSchemaGenerator.java
+0
-179
modules/flowable-cmmn-engine/src/main/resources/org/flowable/cmmn/db/liquibase/csv/changelog-db2-6200.csv
...org/flowable/cmmn/db/liquibase/csv/changelog-db2-6200.csv
+0
-2
modules/flowable-cmmn-engine/src/main/resources/org/flowable/cmmn/db/liquibase/csv/changelog-h2-6200.csv
.../org/flowable/cmmn/db/liquibase/csv/changelog-h2-6200.csv
+0
-2
modules/flowable-cmmn-engine/src/main/resources/org/flowable/cmmn/db/liquibase/csv/changelog-hsql-6200.csv
...rg/flowable/cmmn/db/liquibase/csv/changelog-hsql-6200.csv
+0
-2
modules/flowable-cmmn-engine/src/main/resources/org/flowable/cmmn/db/liquibase/csv/changelog-mssql-6200.csv
...g/flowable/cmmn/db/liquibase/csv/changelog-mssql-6200.csv
+0
-2
modules/flowable-cmmn-engine/src/main/resources/org/flowable/cmmn/db/liquibase/csv/changelog-mysql-6200.csv
...g/flowable/cmmn/db/liquibase/csv/changelog-mysql-6200.csv
+0
-2
modules/flowable-cmmn-engine/src/main/resources/org/flowable/cmmn/db/liquibase/csv/changelog-oracle-6200.csv
.../flowable/cmmn/db/liquibase/csv/changelog-oracle-6200.csv
+0
-2
modules/flowable-cmmn-engine/src/main/resources/org/flowable/cmmn/db/liquibase/csv/changelog-postgres-6200.csv
...lowable/cmmn/db/liquibase/csv/changelog-postgres-6200.csv
+0
-2
modules/flowable-content-engine/src/main/java/org/flowable/content/engine/ContentEngineConfiguration.java
...g/flowable/content/engine/ContentEngineConfiguration.java
+2
-40
modules/flowable-content-engine/src/main/java/org/flowable/content/engine/impl/db/ContentDbSchemaManager.java
...owable/content/engine/impl/db/ContentDbSchemaManager.java
+34
-8
modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/db/DmnDbSchemaManager.java
...a/org/flowable/dmn/engine/impl/db/DmnDbSchemaManager.java
+5
-3
modules/flowable-form-engine/src/main/java/org/flowable/form/engine/impl/db/FormDbSchemaManager.java
...org/flowable/form/engine/impl/db/FormDbSchemaManager.java
+3
-1
未找到文件。
modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/util/DbSchemaGenerator.java
已删除
100644 → 0
浏览文件 @
ee4f943f
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.flowable.cmmn.engine.impl.util
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.io.StringReader
;
import
java.io.StringWriter
;
import
java.nio.file.Files
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.flowable.cmmn.engine.impl.db.CmmnDbSchemaManager
;
import
org.flowable.engine.common.impl.FlowableVersion
;
import
org.flowable.engine.common.impl.FlowableVersions
;
import
liquibase.Liquibase
;
import
liquibase.database.Database
;
import
liquibase.database.DatabaseConnection
;
import
liquibase.database.DatabaseFactory
;
import
liquibase.database.core.DB2Database
;
import
liquibase.database.core.H2Database
;
import
liquibase.database.core.HsqlDatabase
;
import
liquibase.database.core.MSSQLDatabase
;
import
liquibase.database.core.MySQLDatabase
;
import
liquibase.database.core.OracleDatabase
;
import
liquibase.database.core.PostgresDatabase
;
import
liquibase.exception.DatabaseException
;
import
liquibase.exception.LiquibaseException
;
/**
* When this class is executed, it generates
* - the create DDL script for the cmmn engine
* - the upgrade script for going from the previous version to the current version.
*
* @author Joram Barrez
*/
public
class
DbSchemaGenerator
{
// The baseline version, i.e. the version at the time that the first sql script was shipped
private
static
final
String
BASELINE_VERSION
=
"6.2.0.0"
;
private
static
final
String
PREFIX_CHANGELOG
=
"src/main/resources/org/flowable/cmmn/db/liquibase/csv/changelog-"
;
private
static
final
Map
<
String
,
String
>
DATABASES
=
new
HashMap
<>();
static
{
DATABASES
.
put
(
"db2"
,
new
DB2Database
().
getShortName
());
DATABASES
.
put
(
"h2"
,
new
H2Database
().
getShortName
());
DATABASES
.
put
(
"hsql"
,
new
HsqlDatabase
().
getShortName
());
DATABASES
.
put
(
"mssql"
,
new
MSSQLDatabase
().
getShortName
());
DATABASES
.
put
(
"mysql"
,
new
MySQLDatabase
().
getShortName
());
DATABASES
.
put
(
"oracle"
,
new
OracleDatabase
().
getShortName
());
DATABASES
.
put
(
"postgres"
,
new
PostgresDatabase
().
getShortName
());
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
for
(
String
db
:
DATABASES
.
keySet
())
{
generateCreateScript
(
db
);
generateUpdateScript
(
db
);
}
}
protected
static
void
generateCreateScript
(
String
db
)
throws
Exception
{
String
changeLogFileName
=
PREFIX_CHANGELOG
+
"temp.csv"
;
File
tempChangeLogFile
=
new
File
(
changeLogFileName
);
if
(
tempChangeLogFile
.
exists
())
{
tempChangeLogFile
.
delete
();
}
tempChangeLogFile
.
createNewFile
();
Database
database
=
determineDatabase
(
db
,
changeLogFileName
);
generateSql
(
db
,
false
,
database
);
tempChangeLogFile
.
delete
();
}
protected
static
void
generateUpdateScript
(
String
db
)
throws
IOException
,
DatabaseException
,
LiquibaseException
,
FileNotFoundException
{
boolean
isUpdate
=
!
FlowableVersions
.
CURRENT_VERSION
.
equals
(
BASELINE_VERSION
);
String
changeLogFile
=
determineChangeLogFile
(
db
,
isUpdate
);
Database
database
=
determineDatabase
(
db
,
changeLogFile
);
generateSql
(
db
,
isUpdate
,
database
);
}
protected
static
String
determineChangeLogFile
(
String
db
,
boolean
isUpdate
)
throws
IOException
{
String
baseChangeLogFileName
=
PREFIX_CHANGELOG
+
db
+
"-"
;
String
changeLogFileName
=
baseChangeLogFileName
+
cleanVersion
(
FlowableVersions
.
CURRENT_VERSION
)
+
".csv"
;
if
(
isUpdate
)
{
String
previousChangeLogFileName
=
baseChangeLogFileName
+
cleanVersion
(
FlowableVersions
.
getPreviousVersion
(
FlowableVersions
.
CURRENT_VERSION
).
getMainVersion
())
+
".csv"
;
File
previousChangeLogFile
=
new
File
(
previousChangeLogFileName
);
File
newChangeLogFile
=
new
File
(
changeLogFileName
);
if
(
newChangeLogFile
.
exists
())
{
newChangeLogFile
.
delete
();
}
Files
.
copy
(
previousChangeLogFile
.
toPath
(),
newChangeLogFile
.
toPath
());
}
else
{
File
changeLogFile
=
new
File
(
changeLogFileName
);
if
(
changeLogFile
.
exists
())
{
changeLogFile
.
delete
();
}
}
return
changeLogFileName
;
}
protected
static
Database
determineDatabase
(
String
db
,
String
changeLogFile
)
throws
DatabaseException
{
DatabaseFactory
databaseFactory
=
DatabaseFactory
.
getInstance
();
DatabaseConnection
databaseConnection
=
databaseFactory
.
openConnection
(
"offline:"
+
DATABASES
.
get
(
db
)
+
"?productName="
+
db
+
"&outputLiquibaseSql=ALL"
+
"&changeLogFile="
+
changeLogFile
,
null
,
null
,
null
,
null
);
return
DatabaseFactory
.
getInstance
().
findCorrectDatabaseImplementation
(
databaseConnection
);
}
protected
static
void
generateSql
(
String
db
,
boolean
isUpdate
,
Database
database
)
throws
LiquibaseException
,
IOException
,
FileNotFoundException
{
CmmnDbSchemaManager
cmmnDbSchemaManager
=
new
CmmnDbSchemaManager
();
Liquibase
liquibase
=
cmmnDbSchemaManager
.
createLiquibaseInstance
(
database
);
File
outputFile
=
null
;
if
(
isUpdate
)
{
FlowableVersion
previousVersion
=
FlowableVersions
.
getPreviousVersion
(
FlowableVersions
.
CURRENT_VERSION
);
outputFile
=
new
File
(
"src/main/resources/org/flowable/cmmn/db/upgrade/flowable."
+
db
+
".cmmn.upgradestep."
+
cleanVersion
(
previousVersion
.
getMainVersion
())
+
".to."
+
cleanVersion
(
FlowableVersions
.
CURRENT_VERSION
)
+
".sql"
);
}
else
{
outputFile
=
new
File
(
"src/main/resources/org/flowable/cmmn/db/create/flowable."
+
db
+
".cmmn.create.sql"
);
}
if
(
outputFile
.
exists
())
{
outputFile
.
delete
();
}
outputFile
.
createNewFile
();
StringWriter
stringWriter
=
new
StringWriter
();
liquibase
.
update
(
"cmmn"
,
stringWriter
);
stringWriter
.
close
();
String
sqlScript
=
stringWriter
.
toString
();
writeSqlScriptToFile
(
outputFile
,
sqlScript
);
}
protected
static
void
writeSqlScriptToFile
(
File
file
,
String
sqlScript
)
throws
FileNotFoundException
,
IOException
{
PrintWriter
printWriter
=
new
PrintWriter
(
new
FileOutputStream
(
file
));
BufferedReader
reader
=
new
BufferedReader
(
new
StringReader
(
sqlScript
));
String
line
=
reader
.
readLine
();
int
nrOfLinesWritten
=
0
;
while
(
line
!=
null
)
{
if
(!
line
.
startsWith
(
"--"
))
{
printWriter
.
println
(
line
);
nrOfLinesWritten
++;
}
line
=
reader
.
readLine
();
}
printWriter
.
flush
();
printWriter
.
close
();
// No need to generate empty upgrade script
if
(
nrOfLinesWritten
==
0
)
{
file
.
delete
();
}
}
protected
static
String
cleanVersion
(
String
version
)
{
return
version
.
replaceAll
(
"\\."
,
""
);
}
}
modules/flowable-cmmn-engine/src/main/resources/org/flowable/cmmn/db/liquibase/csv/changelog-db2-6200.csv
已删除
100644 → 0
浏览文件 @
ee4f943f
"ID","AUTHOR","FILENAME","DATEEXECUTED","ORDEREXECUTED","EXECTYPE","MD5SUM","DESCRIPTION","COMMENTS","TAG","LIQUIBASE","CONTEXTS","LABELS"
"1","flowable","org/flowable/cmmn/db/liquibase/flowable-cmmn-db-changelog.xml","2017-09-03T22:40:04.992","2","EXECUTED","7:28e5931d36abab0185c189c584a7c2d0","createTable tableName=ACT_CMMN_RE_DEPLOYMENT; createTable tableName=ACT_CMMN_RE_DEPLOYMENT_RESOURCE; addForeignKeyConstraint baseTableName=ACT_CMMN_RE_DEPLOYMENT_RESOURCE, constraintName=ACT_FK_CMMN_RSRC_DPL, referencedTableName=ACT_CMMN_RE_DEPLOYMENT;...",,"","3.5.3","()","","4471204965"
modules/flowable-cmmn-engine/src/main/resources/org/flowable/cmmn/db/liquibase/csv/changelog-h2-6200.csv
已删除
100644 → 0
浏览文件 @
ee4f943f
"ID","AUTHOR","FILENAME","DATEEXECUTED","ORDEREXECUTED","EXECTYPE","MD5SUM","DESCRIPTION","COMMENTS","TAG","LIQUIBASE","CONTEXTS","LABELS"
"1","flowable","org/flowable/cmmn/db/liquibase/flowable-cmmn-db-changelog.xml","2017-09-03T22:40:05.217","2","EXECUTED","7:28e5931d36abab0185c189c584a7c2d0","createTable tableName=ACT_CMMN_RE_DEPLOYMENT; createTable tableName=ACT_CMMN_RE_DEPLOYMENT_RESOURCE; addForeignKeyConstraint baseTableName=ACT_CMMN_RE_DEPLOYMENT_RESOURCE, constraintName=ACT_FK_CMMN_RSRC_DPL, referencedTableName=ACT_CMMN_RE_DEPLOYMENT;...",,"","3.5.3","()","","4471205191"
modules/flowable-cmmn-engine/src/main/resources/org/flowable/cmmn/db/liquibase/csv/changelog-hsql-6200.csv
已删除
100644 → 0
浏览文件 @
ee4f943f
"ID","AUTHOR","FILENAME","DATEEXECUTED","ORDEREXECUTED","EXECTYPE","MD5SUM","DESCRIPTION","COMMENTS","TAG","LIQUIBASE","CONTEXTS","LABELS"
"1","flowable","org/flowable/cmmn/db/liquibase/flowable-cmmn-db-changelog.xml","2017-09-03T22:40:05.116","2","EXECUTED","7:28e5931d36abab0185c189c584a7c2d0","createTable tableName=ACT_CMMN_RE_DEPLOYMENT; createTable tableName=ACT_CMMN_RE_DEPLOYMENT_RESOURCE; addForeignKeyConstraint baseTableName=ACT_CMMN_RE_DEPLOYMENT_RESOURCE, constraintName=ACT_FK_CMMN_RSRC_DPL, referencedTableName=ACT_CMMN_RE_DEPLOYMENT;...",,"","3.5.3","()","","4471205090"
modules/flowable-cmmn-engine/src/main/resources/org/flowable/cmmn/db/liquibase/csv/changelog-mssql-6200.csv
已删除
100644 → 0
浏览文件 @
ee4f943f
"ID","AUTHOR","FILENAME","DATEEXECUTED","ORDEREXECUTED","EXECTYPE","MD5SUM","DESCRIPTION","COMMENTS","TAG","LIQUIBASE","CONTEXTS","LABELS"
"1","flowable","org/flowable/cmmn/db/liquibase/flowable-cmmn-db-changelog.xml","2017-09-03T22:40:05.479","2","EXECUTED","7:28e5931d36abab0185c189c584a7c2d0","createTable tableName=ACT_CMMN_RE_DEPLOYMENT; createTable tableName=ACT_CMMN_RE_DEPLOYMENT_RESOURCE; addForeignKeyConstraint baseTableName=ACT_CMMN_RE_DEPLOYMENT_RESOURCE, constraintName=ACT_FK_CMMN_RSRC_DPL, referencedTableName=ACT_CMMN_RE_DEPLOYMENT;...",,"","3.5.3","()","","4471205429"
modules/flowable-cmmn-engine/src/main/resources/org/flowable/cmmn/db/liquibase/csv/changelog-mysql-6200.csv
已删除
100644 → 0
浏览文件 @
ee4f943f
"ID","AUTHOR","FILENAME","DATEEXECUTED","ORDEREXECUTED","EXECTYPE","MD5SUM","DESCRIPTION","COMMENTS","TAG","LIQUIBASE","CONTEXTS","LABELS"
"1","flowable","org/flowable/cmmn/db/liquibase/flowable-cmmn-db-changelog.xml","2017-09-03T22:40:05.328","2","EXECUTED","7:28e5931d36abab0185c189c584a7c2d0","createTable tableName=ACT_CMMN_RE_DEPLOYMENT; createTable tableName=ACT_CMMN_RE_DEPLOYMENT_RESOURCE; addForeignKeyConstraint baseTableName=ACT_CMMN_RE_DEPLOYMENT_RESOURCE, constraintName=ACT_FK_CMMN_RSRC_DPL, referencedTableName=ACT_CMMN_RE_DEPLOYMENT;...",,"","3.5.3","()","","4471205295"
modules/flowable-cmmn-engine/src/main/resources/org/flowable/cmmn/db/liquibase/csv/changelog-oracle-6200.csv
已删除
100644 → 0
浏览文件 @
ee4f943f
"ID","AUTHOR","FILENAME","DATEEXECUTED","ORDEREXECUTED","EXECTYPE","MD5SUM","DESCRIPTION","COMMENTS","TAG","LIQUIBASE","CONTEXTS","LABELS"
"1","flowable","org/flowable/cmmn/db/liquibase/flowable-cmmn-db-changelog.xml","2017-09-03T22:40:04.856","2","EXECUTED","7:28e5931d36abab0185c189c584a7c2d0","createTable tableName=ACT_CMMN_RE_DEPLOYMENT; createTable tableName=ACT_CMMN_RE_DEPLOYMENT_RESOURCE; addForeignKeyConstraint baseTableName=ACT_CMMN_RE_DEPLOYMENT_RESOURCE, constraintName=ACT_FK_CMMN_RSRC_DPL, referencedTableName=ACT_CMMN_RE_DEPLOYMENT;...",,"","3.5.3","()","","4471204819"
modules/flowable-cmmn-engine/src/main/resources/org/flowable/cmmn/db/liquibase/csv/changelog-postgres-6200.csv
已删除
100644 → 0
浏览文件 @
ee4f943f
"ID","AUTHOR","FILENAME","DATEEXECUTED","ORDEREXECUTED","EXECTYPE","MD5SUM","DESCRIPTION","COMMENTS","TAG","LIQUIBASE","CONTEXTS","LABELS"
"1","flowable","org/flowable/cmmn/db/liquibase/flowable-cmmn-db-changelog.xml","2017-09-03T22:40:05.557","2","EXECUTED","7:28e5931d36abab0185c189c584a7c2d0","createTable tableName=ACT_CMMN_RE_DEPLOYMENT; createTable tableName=ACT_CMMN_RE_DEPLOYMENT_RESOURCE; addForeignKeyConstraint baseTableName=ACT_CMMN_RE_DEPLOYMENT_RESOURCE, constraintName=ACT_FK_CMMN_RSRC_DPL, referencedTableName=ACT_CMMN_RE_DEPLOYMENT;...",,"","3.5.3","()","","4471205537"
modules/flowable-content-engine/src/main/java/org/flowable/content/engine/ContentEngineConfiguration.java
浏览文件 @
2839acef
...
...
@@ -22,7 +22,6 @@ import java.util.Set;
import
javax.sql.DataSource
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.apache.ibatis.transaction.TransactionFactory
;
import
org.flowable.content.api.ContentEngineConfigurationApi
;
...
...
@@ -45,7 +44,6 @@ import org.flowable.content.engine.impl.persistence.entity.TableDataManagerImpl;
import
org.flowable.content.engine.impl.persistence.entity.data.ContentItemDataManager
;
import
org.flowable.content.engine.impl.persistence.entity.data.impl.MybatisContentItemDataManager
;
import
org.flowable.engine.common.AbstractEngineConfiguration
;
import
org.flowable.engine.common.api.FlowableException
;
import
org.flowable.engine.common.impl.cfg.BeansConfigurationHelper
;
import
org.flowable.engine.common.impl.db.DbSqlSessionFactory
;
import
org.flowable.engine.common.impl.interceptor.CommandInterceptor
;
...
...
@@ -59,13 +57,6 @@ import org.flowable.engine.common.runtime.Clock;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
liquibase.Liquibase
;
import
liquibase.database.Database
;
import
liquibase.database.DatabaseConnection
;
import
liquibase.database.DatabaseFactory
;
import
liquibase.database.jvm.JdbcConnection
;
import
liquibase.resource.ClassLoaderResourceAccessor
;
public
class
ContentEngineConfiguration
extends
AbstractEngineConfiguration
implements
ContentEngineConfigurationApi
{
protected
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ContentEngineConfiguration
.
class
);
...
...
@@ -222,37 +213,8 @@ public class ContentEngineConfiguration extends AbstractEngineConfiguration impl
}
public
void
initDbSchema
()
{
try
{
DatabaseConnection
connection
=
new
JdbcConnection
(
dataSource
.
getConnection
());
Database
database
=
DatabaseFactory
.
getInstance
().
findCorrectDatabaseImplementation
(
connection
);
database
.
setDatabaseChangeLogTableName
(
LIQUIBASE_CHANGELOG_PREFIX
+
database
.
getDatabaseChangeLogTableName
());
database
.
setDatabaseChangeLogLockTableName
(
LIQUIBASE_CHANGELOG_PREFIX
+
database
.
getDatabaseChangeLogLockTableName
());
if
(
StringUtils
.
isNotEmpty
(
databaseSchema
))
{
database
.
setDefaultSchemaName
(
databaseSchema
);
database
.
setLiquibaseSchemaName
(
databaseSchema
);
}
if
(
StringUtils
.
isNotEmpty
(
databaseCatalog
))
{
database
.
setDefaultCatalogName
(
databaseCatalog
);
database
.
setLiquibaseCatalogName
(
databaseCatalog
);
}
Liquibase
liquibase
=
new
Liquibase
(
"org/flowable/content/db/liquibase/flowable-content-db-changelog.xml"
,
new
ClassLoaderResourceAccessor
(),
database
);
if
(
DB_SCHEMA_UPDATE_DROP_CREATE
.
equals
(
databaseSchemaUpdate
))
{
LOGGER
.
debug
(
"Dropping and creating schema CONTENT"
);
liquibase
.
dropAll
();
liquibase
.
update
(
"content"
);
}
else
if
(
DB_SCHEMA_UPDATE_TRUE
.
equals
(
databaseSchemaUpdate
))
{
LOGGER
.
debug
(
"Updating schema CONTENT"
);
liquibase
.
update
(
"content"
);
}
else
if
(
DB_SCHEMA_UPDATE_FALSE
.
equals
(
databaseSchemaUpdate
))
{
LOGGER
.
debug
(
"Validating schema CONTENT"
);
liquibase
.
validate
();
}
}
catch
(
Exception
e
)
{
throw
new
FlowableException
(
"Error initialising content data schema"
,
e
);
if
(
dbSchemaManager
!=
null
)
{
((
ContentDbSchemaManager
)
dbSchemaManager
).
initSchema
(
this
,
databaseSchemaUpdate
);
}
}
...
...
modules/flowable-content-engine/src/main/java/org/flowable/content/engine/impl/db/ContentDbSchemaManager.java
浏览文件 @
2839acef
...
...
@@ -19,6 +19,8 @@ import org.flowable.content.engine.impl.util.CommandContextUtil;
import
org.flowable.engine.common.api.FlowableException
;
import
org.flowable.engine.common.impl.db.DbSchemaManager
;
import
org.flowable.engine.common.impl.interceptor.CommandContext
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
liquibase.Liquibase
;
import
liquibase.database.Database
;
...
...
@@ -29,23 +31,27 @@ import liquibase.resource.ClassLoaderResourceAccessor;
public
class
ContentDbSchemaManager
implements
DbSchemaManager
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ContentDbSchemaManager
.
class
);
public
static
String
LIQUIBASE_CHANGELOG
=
"org/flowable/content/db/liquibase/flowable-content-db-changelog.xml"
;
@Override
public
void
dbSchemaCreate
()
{
Liquibase
liquibase
=
createLiquibaseInstance
();
Liquibase
liquibase
=
createLiquibaseInstance
(
CommandContextUtil
.
getContentEngineConfiguration
()
);
try
{
liquibase
.
update
(
"
form
"
);
liquibase
.
update
(
"
content
"
);
}
catch
(
Exception
e
)
{
throw
new
FlowableException
(
"Error creating
form
engine tables"
,
e
);
throw
new
FlowableException
(
"Error creating
content
engine tables"
,
e
);
}
}
@Override
public
void
dbSchemaDrop
()
{
Liquibase
liquibase
=
createLiquibaseInstance
();
Liquibase
liquibase
=
createLiquibaseInstance
(
CommandContextUtil
.
getContentEngineConfiguration
()
);
try
{
liquibase
.
dropAll
();
}
catch
(
Exception
e
)
{
throw
new
FlowableException
(
"Error dropping
form
engine tables"
,
e
);
throw
new
FlowableException
(
"Error dropping
content
engine tables"
,
e
);
}
}
...
...
@@ -55,13 +61,13 @@ public class ContentDbSchemaManager implements DbSchemaManager {
return
null
;
}
protected
static
Liquibase
createLiquibaseInstance
()
{
protected
static
Liquibase
createLiquibaseInstance
(
ContentEngineConfiguration
configuration
)
{
try
{
Connection
jdbcConnection
=
null
;
CommandContext
commandContext
=
CommandContextUtil
.
getCommandContext
();
if
(
commandContext
==
null
)
{
jdbcConnection
=
CommandContextUtil
.
getContentEngineConfiguration
(
commandContext
)
.
getDataSource
().
getConnection
();
jdbcConnection
=
configuration
.
getDataSource
().
getConnection
();
}
else
{
jdbcConnection
=
CommandContextUtil
.
getDbSqlSession
(
commandContext
).
getSqlSession
().
getConnection
();
}
...
...
@@ -74,12 +80,32 @@ public class ContentDbSchemaManager implements DbSchemaManager {
database
.
setDatabaseChangeLogTableName
(
ContentEngineConfiguration
.
LIQUIBASE_CHANGELOG_PREFIX
+
database
.
getDatabaseChangeLogTableName
());
database
.
setDatabaseChangeLogLockTableName
(
ContentEngineConfiguration
.
LIQUIBASE_CHANGELOG_PREFIX
+
database
.
getDatabaseChangeLogLockTableName
());
Liquibase
liquibase
=
new
Liquibase
(
"org/flowable/form/db/liquibase/flowable-form-db-changelog.xml"
,
new
ClassLoaderResourceAccessor
(),
database
);
Liquibase
liquibase
=
new
Liquibase
(
LIQUIBASE_CHANGELOG
,
new
ClassLoaderResourceAccessor
(),
database
);
return
liquibase
;
}
catch
(
Exception
e
)
{
throw
new
FlowableException
(
"Error creating liquibase instance"
,
e
);
}
}
public
void
initSchema
(
ContentEngineConfiguration
configuration
,
String
databaseSchemaUpdate
)
{
try
{
Liquibase
liquibase
=
createLiquibaseInstance
(
configuration
);
if
(
ContentEngineConfiguration
.
DB_SCHEMA_UPDATE_DROP_CREATE
.
equals
(
databaseSchemaUpdate
))
{
LOGGER
.
debug
(
"Dropping and creating schema Content"
);
liquibase
.
dropAll
();
liquibase
.
update
(
"content"
);
}
else
if
(
ContentEngineConfiguration
.
DB_SCHEMA_UPDATE_TRUE
.
equals
(
databaseSchemaUpdate
))
{
LOGGER
.
debug
(
"Updating schema Content"
);
liquibase
.
update
(
"content"
);
}
else
if
(
ContentEngineConfiguration
.
DB_SCHEMA_UPDATE_FALSE
.
equals
(
databaseSchemaUpdate
))
{
LOGGER
.
debug
(
"Validating schema Content"
);
liquibase
.
validate
();
}
}
catch
(
Exception
e
)
{
throw
new
FlowableException
(
"Error initialising Content schema"
,
e
);
}
}
}
modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/db/DmnDbSchemaManager.java
浏览文件 @
2839acef
...
...
@@ -38,6 +38,8 @@ public class DmnDbSchemaManager implements DbSchemaManager {
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
DmnDbSchemaManager
.
class
);
public
static
String
LIQUIBASE_CHANGELOG
=
"org/flowable/dmn/db/liquibase/flowable-dmn-db-changelog.xml"
;
public
void
initSchema
()
{
initSchema
(
CommandContextUtil
.
getDmnEngineConfiguration
());
}
...
...
@@ -65,7 +67,7 @@ public class DmnDbSchemaManager implements DbSchemaManager {
}
}
p
rotected
Liquibase
createLiquibaseInstance
(
DmnEngineConfiguration
dmnEngineConfiguration
)
p
ublic
Liquibase
createLiquibaseInstance
(
DmnEngineConfiguration
dmnEngineConfiguration
)
throws
SQLException
,
DatabaseException
,
LiquibaseException
{
Connection
jdbcConnection
=
null
;
...
...
@@ -97,10 +99,10 @@ public class DmnDbSchemaManager implements DbSchemaManager {
database
.
setLiquibaseCatalogName
(
databaseCatalog
);
}
Liquibase
liquibase
=
new
Liquibase
(
"org/flowable/dmn/db/liquibase/flowable-dmn-db-changelog.xml"
,
new
ClassLoaderResourceAccessor
(),
database
);
Liquibase
liquibase
=
new
Liquibase
(
LIQUIBASE_CHANGELOG
,
new
ClassLoaderResourceAccessor
(),
database
);
return
liquibase
;
}
@Override
public
void
dbSchemaCreate
()
{
try
{
...
...
modules/flowable-form-engine/src/main/java/org/flowable/form/engine/impl/db/FormDbSchemaManager.java
浏览文件 @
2839acef
...
...
@@ -30,6 +30,8 @@ import liquibase.resource.ClassLoaderResourceAccessor;
public
class
FormDbSchemaManager
implements
DbSchemaManager
{
public
static
String
LIQUIBASE_CHANGELOG
=
"org/flowable/form/db/liquibase/flowable-form-db-changelog.xml"
;
@Override
public
void
dbSchemaCreate
()
{
Liquibase
liquibase
=
createLiquibaseInstance
();
...
...
@@ -85,7 +87,7 @@ public class FormDbSchemaManager implements DbSchemaManager {
database
.
setLiquibaseCatalogName
(
formEngineConfiguration
.
getDatabaseCatalog
());
}
Liquibase
liquibase
=
new
Liquibase
(
"org/flowable/form/db/liquibase/flowable-form-db-changelog.xml"
,
new
ClassLoaderResourceAccessor
(),
database
);
Liquibase
liquibase
=
new
Liquibase
(
LIQUIBASE_CHANGELOG
,
new
ClassLoaderResourceAccessor
(),
database
);
return
liquibase
;
}
catch
(
Exception
e
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录