01: /*
02: * Copyright (c) 2006 Your Corporation. All Rights Reserved.
03: */
04:
05: package com.tacitknowledge.util.migration.jdbc;
06:
07: import org.apache.commons.lang.StringUtils;
08:
09: import com.technoetic.xplanner.db.hsqldb.HsqlServer;
10:
11: public class UpdatePatchLevel {
12: private AutopatchSupport autopatchSupport;
13:
14: public UpdatePatchLevel(AutopatchSupport autopatchSupport) {
15: this .autopatchSupport = autopatchSupport;
16: }
17:
18: public static void main(String[] arguments) throws Exception {
19: String migrationName = System
20: .getProperty("migration.systemname");
21: AutopatchSupport autopatchSupport = new AutopatchSupport(
22: migrationName);
23: UpdatePatchLevel dummyMigrationLauncher = new UpdatePatchLevel(
24: autopatchSupport);
25: String patchLevel = null;
26: if ((arguments != null) && (arguments.length > 0)) {
27: patchLevel = arguments[0].trim();
28: }
29: dummyMigrationLauncher.updatePatchLevel(migrationName,
30: patchLevel);
31: HsqlServer.shutdown();
32: }
33:
34: protected void updatePatchLevel(String migrationName,
35: String patchLevel) throws Exception {
36: if (migrationName == null) {
37: throw new IllegalArgumentException(
38: "The migration.systemname "
39: + "system property is required");
40: }
41: int patchLevelVal;
42:
43: if (StringUtils.isEmpty(patchLevel)) {
44: patchLevelVal = autopatchSupport.getHighestPatchLevel();
45: } else {
46: patchLevelVal = Integer.parseInt(patchLevel);
47: }
48: autopatchSupport.setPatchLevel(patchLevelVal);
49: }
50:
51: }
|