提交 5ecddcfe 编写于 作者: T Tom Baeyens

ACT-1333 fixing upgrade script

上级 9c666c73
......@@ -187,6 +187,14 @@
</fileset>
</path>
</sql>
<condition property="isPostgres">
<equals arg1="${database}" arg2="postgres" />
</condition>
<java classname="org.activiti.upgrade.CleanPostgres" fork="true" if="isPostgres">
<classpath>
<path path="${test_classpath}"/>
</classpath>
</java>
<sql driver="${jdbc.driver}" url="${jdbc.url}" userid="${jdbc.username}" password="${jdbc.password}"
classpath="${test_classpath}">
<path>
......@@ -257,6 +265,12 @@
</fileset>
</path>
</sql>
<java classname="org.activiti.upgrade.CleanPostgres" fork="true">
<arg line="${database}"/>
<classpath>
<path path="${test_classpath}"/>
</classpath>
</java>
<sql driver="${jdbc.driver}" url="${jdbc.url}" userid="${jdbc.username}" password="${jdbc.password}"
classpath="${test_classpath}">
<path>
......
/* 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.activiti.upgrade;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.logging.Logger;
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.activiti.engine.impl.db.DbSqlSession;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.interceptor.CommandExecutor;
public class CleanPostgres {
private static Logger log = Logger.getLogger(CleanPostgres.class.getName());
static String[] cleanStatements = new String[] {
"drop table ACT_GE_PROPERTY cascade;",
"drop table ACT_GE_BYTEARRAY cascade;",
"drop table ACT_RE_MODEL cascade;",
"drop table ACT_RE_DEPLOYMENT cascade;",
"drop table ACT_RE_PROCDEF cascade;",
"drop table ACT_RU_IDENTITYLINK cascade;",
"drop table ACT_RU_VARIABLE cascade;",
"drop table ACT_RU_TASK cascade;",
"drop table ACT_RU_EXECUTION cascade;",
"drop table ACT_RU_JOB cascade;",
"drop table ACT_RU_EVENT_SUBSCR cascade;",
"drop table ACT_HI_PROCINST cascade;",
"drop table ACT_HI_ACTINST cascade;",
"drop table ACT_HI_VARINST cascade;",
"drop table ACT_HI_TASKINST cascade;",
"drop table ACT_HI_DETAIL cascade;",
"drop table ACT_HI_COMMENT cascade;",
"drop table ACT_HI_ATTACHMENT cascade;",
"drop table ACT_ID_INFO cascade;",
"drop table ACT_ID_MEMBERSHIP cascade;",
"drop table ACT_ID_GROUP cascade;",
"drop table ACT_ID_USER cascade;"};
public static void main(String[] args) {
try {
if ("postgres".equals(args[0])) {
ProcessEngineConfigurationImpl processEngineConfiguration = UpgradeTestCase.createProcessEngineConfiguration("postgres");
processEngineConfiguration.buildProcessEngine();
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
commandExecutor.execute(new Command<Object>() {
public Object execute(CommandContext commandContext) {
try {
Connection connection = commandContext.getSession(DbSqlSession.class).getSqlSession().getConnection();
connection.setAutoCommit(false);
for (String cleanStatement : cleanStatements) {
try {
PreparedStatement preparedStatement = connection.prepareStatement(cleanStatement);
preparedStatement.execute();
connection.commit();
log.info("executed ["+cleanStatement+"] successfully");
} catch (Exception e) {
log.info("ERROR WHILE EXECUTING ["+cleanStatement+"]:");
e.printStackTrace();
connection.rollback();
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
});
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
/* 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.activiti.upgrade;
import java.util.Date;
......
/* 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.activiti.upgrade;
......
/* 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.activiti.upgrade;
......
......@@ -87,7 +87,7 @@ public abstract class UpgradeTestCase extends TestCase {
public abstract void runInTheOldVersion();
public static ProcessEngineConfigurationImpl createProcessEngineConfiguration(String database) throws IOException, FileNotFoundException {
public static ProcessEngineConfigurationImpl createProcessEngineConfiguration(String database) throws Exception {
ProcessEngineConfigurationImpl processEngineConfiguration;
processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
.createStandaloneProcessEngineConfiguration()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册