-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f92cf4
commit 08e212b
Showing
82 changed files
with
2,428 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!-- | ||
<name>connection</name> | ||
<driverClass>org.h2.Driver</driverClass> | ||
<URL>jdbc:h2:tcp://localhost/./knowledge_db</URL> | ||
<user>sa</user> | ||
<password></password> | ||
<schema>public</schema> | ||
<maxConn>5</maxConn> | ||
<autocommit>false</autocommit> | ||
|
||
<name>connection</name> | ||
<driverClass>org.postgresql.Driver</driverClass> | ||
<URL>jdbc:postgresql://localhost:5432/ek003024</URL> | ||
<user>ek003024</user> | ||
<password></password> | ||
<schema>public</schema> | ||
<maxConn>5</maxConn> | ||
<autocommit>false</autocommit> | ||
|
||
|
||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/java/org/support/project/knowledge/bat/AbstractBat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.support.project.knowledge.bat; | ||
|
||
import org.support.project.web.logic.DBConnenctionLogic; | ||
|
||
public abstract class AbstractBat { | ||
/** | ||
* コネクションの接続先がカスタマイズされていたら、バッチでもカスタマイズ先を参照する | ||
*/ | ||
public void dbInit() { | ||
DBConnenctionLogic.get().connectCustomConnection(); | ||
} | ||
|
||
|
||
} |
83 changes: 83 additions & 0 deletions
83
src/main/java/org/support/project/knowledge/bat/DataTransferBat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package org.support.project.knowledge.bat; | ||
|
||
import org.h2.tools.Server; | ||
import org.support.project.common.config.ConfigLoader; | ||
import org.support.project.common.log.Log; | ||
import org.support.project.common.log.LogFactory; | ||
import org.support.project.knowledge.logic.DataTransferLogic; | ||
import org.support.project.ormapping.config.ConnectionConfig; | ||
import org.support.project.web.config.AppConfig; | ||
import org.support.project.web.logic.DBConnenctionLogic; | ||
|
||
public class DataTransferBat extends AbstractBat implements Runnable { | ||
/** ログ */ | ||
private static Log LOG = LogFactory.getLog(DataTransferBat.class); | ||
|
||
private boolean runing = false; | ||
private boolean serverStarted = false; | ||
|
||
public static void main(String[] args) throws Exception { | ||
LOG.trace("start"); | ||
DataTransferBat bat = new DataTransferBat(); | ||
bat.start(); | ||
} | ||
|
||
@Override | ||
public void run() { | ||
// データ取得元の組み込みDBを起動(既に起動している場合起動しない) | ||
runing = true; | ||
try { | ||
AppConfig appConfig = ConfigLoader.load(AppConfig.APP_CONFIG, AppConfig.class); | ||
String[] parms = { "-tcp", "-baseDir", appConfig.getDatabasePath() }; | ||
|
||
Server server = Server.createTcpServer(parms); | ||
server.start(); | ||
|
||
//System.out.println("Database start..."); | ||
serverStarted = true; | ||
while (runing) { | ||
Thread.sleep(1000); | ||
} | ||
server.stop(); | ||
} catch (Exception e) { | ||
LOG.error(e); | ||
} | ||
System.out.println("Database stop."); | ||
} | ||
|
||
/** | ||
* | ||
* @throws Exception | ||
*/ | ||
private void start() throws Exception { | ||
// 多重起動チェック | ||
if (DataTransferLogic.get().isTransferStarted()) { | ||
LOG.info("ALL Ready started."); | ||
return; | ||
} | ||
// DBを起動 | ||
Thread thread = new Thread(this); | ||
thread.start(); | ||
try { | ||
// サーバーが起動するまで待機 | ||
while(!serverStarted) { | ||
Thread.sleep(1000); | ||
} | ||
// コネクションの設定を読み込み | ||
ConnectionConfig defaultConnection = DBConnenctionLogic.get().getDefaultConnectionConfig(); | ||
ConnectionConfig customConnection = DBConnenctionLogic.get().getCustomConnectionConfig(); | ||
// データ移行を実行(すごく時間がかかる可能性あり) | ||
DataTransferLogic.get().transferData(defaultConnection, customConnection); | ||
} catch (Exception e) { | ||
LOG.error("ERROR", e); | ||
} finally { | ||
// データ移行終了 | ||
DataTransferLogic.get().finishTransfer(); | ||
// DBを停止 | ||
runing = false; | ||
thread.join(); | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.