diff --git a/document/database/knowledge.a5er b/document/database/knowledge.a5er index 6be0b9861..00fb73dcb 100755 --- a/document/database/knowledge.a5er +++ b/document/database/knowledge.a5er @@ -51,7 +51,7 @@ PName=NOTIFY_QUEUES LName=通知待ちキュー Comment= TableOption= -Page=Main +Page=MAIN Left=120 Top=1700 Field="HASH","HASH","@VARCHAR(32)","NOT NULL",0,"","",$FFFFFFFF,"" @@ -61,7 +61,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20150331055404 -Position="Main",120,1700 +Position="MAIN",120,1700 [Relation] Entity1=USERS @@ -156,18 +156,18 @@ TableOption= Page=MAIN Left=1010 Top=900 -Field="IMAGE_ID","IMAGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,"AUTO_INCREMENT" +Field="IMAGE_ID","IMAGE_ID","BIGSERIAL","NOT NULL",0,"","",$FFFFFFFF,"" Field="ユーザID","USER_ID","@INT",,,"","",$FFFFFFFF,"" Field="ファイル名","FILE_NAME","@VARCHAR(256)",,,"","",$FFFFFFFF,"" Field="ファイルサイズ","FILE_SIZE","@DOUBLE",,,"","",$FFFFFFFF,"" -Field="バイナリ","FILE_BINARY","blob",,,"","",$FFFFFFFF,"" +Field="バイナリ","FILE_BINARY","BYTEA",,,"","",$FFFFFFFF,"" Field="拡張子","EXTENSION","@VARCHAR(256)",,,"","",$FFFFFFFF,"" Field="CONTENT_TYPE","CONTENT_TYPE","@VARCHAR(256)",,,"","",$FFFFFFFF,"" Index=IDX_ACCOUNT_IMAGES_USER_ID=1,USER_ID EffectMode=None Color=$000000 BkColor=$FFFFFF -ModifiedDateTime=20150102014151 +ModifiedDateTime=20150416234339 Position="MAIN",1010,900 [Relation] @@ -198,13 +198,13 @@ TableOption= Page=MAIN Left=580 Top=1470 -Field="NO","NO","bigint","NOT NULL",0,"","",$FFFFFFFF,"AUTO_INCREMENT" +Field="NO","NO","BIGSERIAL","NOT NULL",0,"","",$FFFFFFFF,"" Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",,"","",$FFFFFFFF,"" Index=IDX_LIKES_KNOWLEDGE_ID=0,KNOWLEDGE_ID EffectMode=None Color=$000000 BkColor=$FFFFFF -ModifiedDateTime=20150102013522 +ModifiedDateTime=20150416233511 Position="MAIN",580,1470 [Relation] @@ -236,14 +236,14 @@ TableOption= Page=MAIN Left=1890 Top=1540 -Field="コメント番号","COMMENT_NO","bigint","NOT NULL",0,"","",$FFFFFFFF,"AUTO_INCREMENT" +Field="コメント番号","COMMENT_NO","BIGSERIAL","NOT NULL",0,"","",$FFFFFFFF,"" Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",,"","",$FFFFFFFF,"" Field="コメント","COMMENT","text",,,"","",$FFFFFFFF,"" Index=IDX_COMMENTS_KNOWLEDGE_ID=0,KNOWLEDGE_ID EffectMode=None Color=$000000 BkColor=$FFFFFF -ModifiedDateTime=20150102013923 +ModifiedDateTime=20150416233710 Position="MAIN",1890,1540 [Relation] @@ -274,14 +274,14 @@ TableOption= Page=MAIN Left=1890 Top=1390 -Field="VOTE_NO","VOTE_NO","bigint","NOT NULL",0,"","",$FFFFFFFF,"AUTO_INCREMENT" +Field="VOTE_NO","VOTE_NO","BIGSERIAL","NOT NULL",0,"","",$FFFFFFFF,"" Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",,"","",$FFFFFFFF,"" Field="投票区分","VOTE_KIND","@INT","NOT NULL",,"","",$FFFFFFFF,"" Index=IDX_VOTES_KNOWLEDGE_ID=0,KNOWLEDGE_ID EffectMode=None Color=$000000 BkColor=$FFFFFF -ModifiedDateTime=20150102013835 +ModifiedDateTime=20150416233659 Position="MAIN",1890,1390,435,89 [Relation] @@ -313,14 +313,14 @@ TableOption= Page=MAIN Left=1890 Top=840 -Field="HISTORY_NO","HISTORY_NO","bigint","NOT NULL",0,"","",$FFFFFFFF,"AUTO_INCREMENT" +Field="HISTORY_NO","HISTORY_NO","BIGSERIAL","NOT NULL",0,"","",$FFFFFFFF,"" Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",,"","",$FFFFFFFF,"" Field="日時","VIEW_DATE_TIME","@DATETIME","NOT NULL",,"","",$FFFFFFFF,"" Index=IDX_VIEW_HISTORIES_KNOWLEDGE_ID=0,KNOWLEDGE_ID EffectMode=None Color=$000000 BkColor=$FFFFFF -ModifiedDateTime=20150102013703 +ModifiedDateTime=20150416233623 Position="MAIN",1890,840 [Relation] @@ -497,12 +497,12 @@ TableOption= Page=MAIN Left=70 Top=1310 -Field="タグ_ID","TAG_ID","@INT","NOT NULL",0,"","",$FFFFFFFF,"AUTO_INCREMENT" +Field="タグ_ID","TAG_ID","SERIAL","NOT NULL",0,"","",$FFFFFFFF,"" Field="タグ名称","TAG_NAME","@VARCHAR(128)","NOT NULL",,"","",$FFFFFFFF,"" EffectMode=None Color=$000000 BkColor=$FFFFFF -ModifiedDateTime=20141120205901 +ModifiedDateTime=20150416233544 Position="MAIN",70,1310 [Relation] @@ -534,18 +534,18 @@ TableOption= Page=MAIN Left=1140 Top=1520 -Field="添付ファイル番号","FILE_NO","bigint","NOT NULL",0,"","",$FFFFFFFF,"AUTO_INCREMENT" +Field="添付ファイル番号","FILE_NO","BIGSERIAL","NOT NULL",0,"","",$FFFFFFFF,"" Field="ナレッジID","KNOWLEDGE_ID","bigint",,,"","",$FFFFFFFF,"" Field="コメント番号","COMMENT_NO","bigint",,,"","",$FFFFFFFF,"" Field="ファイル名","FILE_NAME","@VARCHAR(256)",,,"","",$FFFFFFFF,"" Field="ファイルサイズ","FILE_SIZE","@DOUBLE",,,"","",$FFFFFFFF,"" -Field="バイナリ","FILE_BINARY","blob",,,"","",$FFFFFFFF,"" +Field="バイナリ","FILE_BINARY","BYTEA",,,"","",$FFFFFFFF,"" Field="パース結果","PARSE_STATUS","@INT","NOT NULL",,"","",$FFFFFFFF,"" Index=IDX_KNOWLEDGE_FILES_KNOWLEDGE_ID=0,KNOWLEDGE_ID EffectMode=None Color=$000000 BkColor=$FFFFFF -ModifiedDateTime=20150328055544 +ModifiedDateTime=20150416234328 Position="MAIN",1140,1520 [Entity] @@ -556,7 +556,7 @@ TableOption= Page=MAIN Left=1160 Top=1150 -Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,"AUTO_INCREMENT" +Field="ナレッジID","KNOWLEDGE_ID","BIGSERIAL","NOT NULL",0,"","",$FFFFFFFF,"" Field="タイトル","TITLE","@VARCHAR(1024)","NOT NULL",,"","",$FFFFFFFF,"" Field="内容","CONTENT","text",,,"","",$FFFFFFFF,"" Field="公開区分","PUBLIC_FLAG","@INT",,,"","",$FFFFFFFF,"" @@ -567,7 +567,7 @@ Field="コメント件数","COMMENT_COUNT","@INT",,,"","",$FFFFFFFF,"" EffectMode=None Color=$000000 BkColor=$FFFFFF -ModifiedDateTime=20150219042038 +ModifiedDateTime=20150416233526 Position="MAIN",1160,1150 [Comment] diff --git a/document/images/startup-594090_1280.jpg b/document/images/startup-594090_1280.jpg new file mode 100644 index 000000000..befd35460 Binary files /dev/null and b/document/images/startup-594090_1280.jpg differ diff --git a/document/images/startup-594090_1920.jpg b/document/images/startup-594090_1920.jpg new file mode 100644 index 000000000..95728316d Binary files /dev/null and b/document/images/startup-594090_1920.jpg differ diff --git a/document/images/startup-594090_640.jpg b/document/images/startup-594090_640.jpg new file mode 100644 index 000000000..fee0900e8 Binary files /dev/null and b/document/images/startup-594090_640.jpg differ diff --git a/document/memo/connection_memo.txt b/document/memo/connection_memo.txt new file mode 100644 index 000000000..41b0b36e3 --- /dev/null +++ b/document/memo/connection_memo.txt @@ -0,0 +1,21 @@ + diff --git a/pom.xml b/pom.xml index b555d7499..0a02207c0 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,6 @@ UTF-8 - org.support-project @@ -87,6 +86,12 @@ mail 1.4.7 + + + org.postgresql + postgresql + 9.3-1103-jdbc41 + diff --git a/src/main/java/org/support/project/knowledge/bat/AbstractBat.java b/src/main/java/org/support/project/knowledge/bat/AbstractBat.java new file mode 100644 index 000000000..6ea50b4df --- /dev/null +++ b/src/main/java/org/support/project/knowledge/bat/AbstractBat.java @@ -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(); + } + + +} diff --git a/src/main/java/org/support/project/knowledge/bat/DataTransferBat.java b/src/main/java/org/support/project/knowledge/bat/DataTransferBat.java new file mode 100644 index 000000000..649129309 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/bat/DataTransferBat.java @@ -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(); + } + } + + +} diff --git a/src/main/java/org/support/project/knowledge/bat/FileParseBat.java b/src/main/java/org/support/project/knowledge/bat/FileParseBat.java index 02a8d2497..39ec1aae7 100644 --- a/src/main/java/org/support/project/knowledge/bat/FileParseBat.java +++ b/src/main/java/org/support/project/knowledge/bat/FileParseBat.java @@ -29,7 +29,7 @@ import org.support.project.knowledge.parser.ParserFactory; import org.support.project.knowledge.vo.ParseResult; -public class FileParseBat { +public class FileParseBat extends AbstractBat { /** ログ */ private static Log LOG = LogFactory.getLog(FileParseBat.class); @@ -46,6 +46,7 @@ public class FileParseBat { public static void main(String[] args) throws Exception { FileParseBat bat = new FileParseBat(); + bat.dbInit(); bat.start(); } diff --git a/src/main/java/org/support/project/knowledge/bat/KnowledgeFileClearBat.java b/src/main/java/org/support/project/knowledge/bat/KnowledgeFileClearBat.java index 0a57b6730..4bed9e4e1 100644 --- a/src/main/java/org/support/project/knowledge/bat/KnowledgeFileClearBat.java +++ b/src/main/java/org/support/project/knowledge/bat/KnowledgeFileClearBat.java @@ -4,14 +4,19 @@ import org.support.project.common.log.LogFactory; import org.support.project.knowledge.dao.KnowledgeFilesDao; -public class KnowledgeFileClearBat { +public class KnowledgeFileClearBat extends AbstractBat { /** ログ */ private static Log LOG = LogFactory.getLog(KnowledgeFileClearBat.class); public static void main(String[] args) { LOG.trace("start"); - + KnowledgeFileClearBat bat = new KnowledgeFileClearBat(); + bat.dbInit(); + bat.start(); + } + + private void start() { KnowledgeFilesDao filesDao = KnowledgeFilesDao.get(); int count = filesDao.deleteNotConnectFiles(); if (count > 0) { diff --git a/src/main/java/org/support/project/knowledge/bat/MailSendBat.java b/src/main/java/org/support/project/knowledge/bat/MailSendBat.java index 5984bf376..87061fe5c 100644 --- a/src/main/java/org/support/project/knowledge/bat/MailSendBat.java +++ b/src/main/java/org/support/project/knowledge/bat/MailSendBat.java @@ -33,7 +33,7 @@ * @author Koda * */ -public class MailSendBat { +public class MailSendBat extends AbstractBat { /** ログ */ private static Log LOG = LogFactory.getLog(MailSendBat.class); @@ -51,8 +51,8 @@ public class MailSendBat { public static void main(String[] args) throws Exception { MailSendBat bat = new MailSendBat(); + bat.dbInit(); bat.start(); - } /** diff --git a/src/main/java/org/support/project/knowledge/bat/NotifyMailBat.java b/src/main/java/org/support/project/knowledge/bat/NotifyMailBat.java index 532f4abe6..d8e64da3f 100644 --- a/src/main/java/org/support/project/knowledge/bat/NotifyMailBat.java +++ b/src/main/java/org/support/project/knowledge/bat/NotifyMailBat.java @@ -40,7 +40,7 @@ import org.support.project.web.entity.SystemConfigsEntity; import org.support.project.web.entity.UsersEntity; -public class NotifyMailBat { +public class NotifyMailBat extends AbstractBat { /** ログ */ private static Log LOG = LogFactory.getLog(MailSendBat.class); @@ -52,6 +52,7 @@ public class NotifyMailBat { public static void main(String[] args) throws Exception { NotifyMailBat bat = new NotifyMailBat(); + bat.dbInit(); bat.start(); } diff --git a/src/main/java/org/support/project/knowledge/bat/ReIndexingBat.java b/src/main/java/org/support/project/knowledge/bat/ReIndexingBat.java new file mode 100644 index 000000000..c3b974051 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/bat/ReIndexingBat.java @@ -0,0 +1,51 @@ +package org.support.project.knowledge.bat; + +import java.util.List; + +import org.support.project.knowledge.config.AppConfig; +import org.support.project.knowledge.config.SystemConfig; +import org.support.project.knowledge.dao.KnowledgesDao; +import org.support.project.knowledge.entity.KnowledgesEntity; +import org.support.project.knowledge.logic.KnowledgeLogic; +import org.support.project.web.dao.SystemConfigsDao; +import org.support.project.web.entity.SystemConfigsEntity; + + +public class ReIndexingBat extends AbstractBat { + + public static void main(String[] args) throws Exception { + ReIndexingBat bat = new ReIndexingBat(); + bat.dbInit(); //カスタマイズDBが設定されていてばそれを参照 + bat.start(); + } + + private void start() throws Exception { + out("start"); + SystemConfigsEntity entity = SystemConfigsDao.get().selectOnKey(SystemConfig.RE_INDEXING, AppConfig.SYSTEM_NAME); + if (entity != null) { + String[] values = entity.getConfigValue().split(","); + Long start = Long.valueOf(values[0].substring("start=".length())); + Long end = Long.valueOf(values[1].substring("end=".length())); + + out("search knowledge:" + start + "-" + end); + KnowledgesDao knowledgesDao = KnowledgesDao.get(); + List knowledgesEntities = knowledgesDao.selectBetween(start, end); + for (KnowledgesEntity knowledgesEntity : knowledgesEntities) { + out("indexing knowledge: " + knowledgesEntity.getKnowledgeId()); + KnowledgeLogic.get().reindexing(knowledgesEntity); + } + SystemConfigsDao.get().physicalDelete(entity); + } + out("finish"); + } + + + /** + * メッセージをコンソールに出力 + * @param str + */ + private void out(String str) { + System.out.println("[SEND]" + str); + } + +} \ No newline at end of file diff --git a/src/main/java/org/support/project/knowledge/config/AppConfig.java b/src/main/java/org/support/project/knowledge/config/AppConfig.java index 55a5953a2..27f62309a 100644 --- a/src/main/java/org/support/project/knowledge/config/AppConfig.java +++ b/src/main/java/org/support/project/knowledge/config/AppConfig.java @@ -1,7 +1,18 @@ package org.support.project.knowledge.config; +import org.support.project.common.config.ConfigLoader; + public class AppConfig extends org.support.project.web.config.AppConfig { + + public static AppConfig get() { + if (appConfig == null) { + appConfig = ConfigLoader.load(AppConfig.APP_CONFIG, AppConfig.class); + } + return appConfig; + } + private static AppConfig appConfig = null; + public static final String SYSTEM_NAME = "knowledge"; private String indexPath; @@ -18,6 +29,9 @@ public String getIndexPath() { String userHome = System.getProperty("user.home"); path = path.replace("{user.home}", userHome); } + if (path.indexOf("{base.path}") != -1) { + path = path.replace("{base.path}", getBasePath()); + } if (path.indexOf("\\") != -1) { path = path.replaceAll("\\\\", "/"); } diff --git a/src/main/java/org/support/project/knowledge/config/IndexType.java b/src/main/java/org/support/project/knowledge/config/IndexType.java index a7414b7eb..27af9027f 100644 --- a/src/main/java/org/support/project/knowledge/config/IndexType.java +++ b/src/main/java/org/support/project/knowledge/config/IndexType.java @@ -2,7 +2,8 @@ public enum IndexType { knowledge, - KnowledgeFile; + KnowledgeFile, + KnowledgeComment; public int getValue() { diff --git a/src/main/java/org/support/project/knowledge/config/SystemConfig.java b/src/main/java/org/support/project/knowledge/config/SystemConfig.java index 1ce3cee7d..0cafbf8b5 100644 --- a/src/main/java/org/support/project/knowledge/config/SystemConfig.java +++ b/src/main/java/org/support/project/knowledge/config/SystemConfig.java @@ -25,5 +25,7 @@ public class SystemConfig { /** ユーザ登録を実施した後、通知しない(OFF) */ public static final String USER_ADD_NOTIFY_OFF = "OFF"; + /** インデックス再作成のための設定値 */ + public static final String RE_INDEXING = "RE_INDEXING"; } diff --git a/src/main/java/org/support/project/knowledge/control/admin/DatabaseControl.java b/src/main/java/org/support/project/knowledge/control/admin/DatabaseControl.java index ac25c3a0a..ea8ffab0e 100644 --- a/src/main/java/org/support/project/knowledge/control/admin/DatabaseControl.java +++ b/src/main/java/org/support/project/knowledge/control/admin/DatabaseControl.java @@ -1,6 +1,9 @@ package org.support.project.knowledge.control.admin; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; +import java.sql.SQLException; import java.util.List; import javax.servlet.http.HttpServletResponse; @@ -8,12 +11,27 @@ import org.apache.commons.fileupload.FileItem; import org.support.project.common.bean.ValidateError; import org.support.project.common.logic.H2DBServerLogic; +import org.support.project.common.serialize.SerializeUtils; import org.support.project.common.wrapper.FileInputStreamWithDeleteWrapper; +import org.support.project.di.Container; +import org.support.project.knowledge.config.AppConfig; +import org.support.project.knowledge.config.SystemConfig; import org.support.project.knowledge.control.Control; +import org.support.project.knowledge.deploy.InitDB; import org.support.project.knowledge.deploy.InitializationLogic; +import org.support.project.knowledge.logic.DataTransferLogic; import org.support.project.knowledge.logic.DatabaseLogic; +import org.support.project.ormapping.config.ConnectionConfig; +import org.support.project.ormapping.config.ConnectionConfigLoader; +import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.connection.ConnectionManager; +import org.support.project.ormapping.exception.ORMappingException; +import org.support.project.ormapping.transaction.TransactionManager; import org.support.project.web.annotation.Auth; import org.support.project.web.boundary.Boundary; +import org.support.project.web.dao.SystemConfigsDao; +import org.support.project.web.entity.SystemConfigsEntity; +import org.support.project.web.logic.DBConnenctionLogic; public class DatabaseControl extends Control { @@ -28,18 +46,44 @@ public Boundary index() { return super.index(); } + /** + * 組み込みDBを開始 + * @return + */ @Auth(roles="admin") public Boundary start() { H2DBServerLogic h2dbServerLogic = H2DBServerLogic.get(); h2dbServerLogic.start(); boolean active = h2dbServerLogic.isActive(); setAttribute("active", active); - InitializationLogic.get().init(); + + // 組み込みDBを使っている場合、コネクション接続 + if (DBConnenctionLogic.get().getCustomConnectionConfig() == null) { + //現在カスタム設定でない + ConnectionManager.getInstance().addConnectionConfig(DBConnenctionLogic.get().getDefaultConnectionConfig()); + InitializationLogic.get().init(); + } + return super.index(); } + + /** + * 組み込みDBを停止 + * @return + * @throws ORMappingException + * @throws SQLException + */ @Auth(roles="admin") - public Boundary stop() { + public Boundary stop() throws ORMappingException, SQLException { + // 組み込みDBを使っている場合、コネクション解除 + if (DBConnenctionLogic.get().getCustomConnectionConfig() == null) { + //現在カスタム設定でない + TransactionManager transactionManager = Container.getComp(TransactionManager.class); + transactionManager.release(ConnectionManager.getInstance().getDefaultConnectionName()); + ConnectionManager.getInstance().release(); + } + H2DBServerLogic h2dbServerLogic = H2DBServerLogic.get(); h2dbServerLogic.stop(); boolean active = h2dbServerLogic.isActive(); @@ -68,7 +112,11 @@ public Boundary backup() throws IOException { return download("knowledge.zip", inputStream, inputStream.size(), "application/zip"); } - + /** + * 組み込みDBのデータをバックアップから復元 + * @return + * @throws IOException + */ @Auth(roles="admin") public Boundary restore() throws IOException { H2DBServerLogic h2dbServerLogic = H2DBServerLogic.get(); @@ -93,6 +141,145 @@ public Boundary restore() throws IOException { setAttribute("active", active); return super.index(); } + + /** + * データベースに接続 + * @return + */ + @Auth(roles="admin") + public Boundary connect() { + ConnectionConfig connectionConfig = DBConnenctionLogic.get().getCustomConnectionConfig(); + if (connectionConfig == null) { + //ConnectionConfigLoader loader = Container.getComp("XML", ConnectionConfigLoader.class); + //connectionConfig = loader.load(ORMappingParameter.CONNECTION_SETTING); + connectionConfig = new ConnectionConfig(); + setAttribute("custom", Boolean.FALSE); + } else { + setAttribute("custom", Boolean.TRUE); + if (DataTransferLogic.get().isTransferRequested()) { + setAttribute("transfer", Boolean.TRUE); + } else { + setAttribute("transfer", Boolean.FALSE); + ConnectionManager.getInstance().addConnectionConfig(connectionConfig); //新しいコネクション設定をセット + } + } + + setAttributeOnProperty(connectionConfig); + return forward("connection.jsp"); + } + + /** + * コネクションのカスタム設定を保存 + * @return + * @throws Exception + */ + @Auth(roles="admin") + public Boundary custom_save() throws Exception { + ConnectionConfig connectionConfig = super.getParamOnProperty(ConnectionConfig.class); + if (!ConnectionManager.getInstance().checkConnectionConfig(connectionConfig)) { + // 入力したコネクション設定が無効 + addMsgWarn("errors.invalid", getResource("knowledge.connection.label.custom")); + return forward("connection.jsp"); + } + // カスタム設定 + connectionConfig.setName("custom"); + ConnectionManager.getInstance().removeDefaultConnectionConfig(); // 現在有効なコネクションの設定を削除 + ConnectionManager.getInstance().addConnectionConfig(connectionConfig); //新しいコネクション設定をセット + + // 新しい接続先のDBを初期化 + InitDB initDB = new InitDB(); + initDB.start(); + + // 設定ファイルを保存 + OutputStream out = null; + try { + out = new FileOutputStream(DBConnenctionLogic.get().getCustomConnectionConfigPath()); + SerializeUtils.writeObject(connectionConfig, out); + } finally { + if (out != null) { + out.close(); + } + } + addMsgSuccess("message.success.save.target", getResource("knowledge.connection.label.custom")); + return connect(); + } + + /** + * コネクションのカスタム設定を削除 + * @return + */ + @Auth(roles="admin") + public Boundary custom_delete() { + ConnectionConfig connectionConfig = DBConnenctionLogic.get().getCustomConnectionConfig(); + if (connectionConfig != null) { + ConnectionManager.getInstance().removeConnectionConfig(connectionConfig); + DBConnenctionLogic.get().removeCustomConnectionConfig(); + } + + // カスタム設定を削除したので、デフォルトを切り替え + ConnectionConfigLoader loader = Container.getComp("XML", ConnectionConfigLoader.class); + connectionConfig = loader.load(ORMappingParameter.CONNECTION_SETTING); + // 設定が正しく読み込めれば、それを使う + ConnectionManager.getInstance().addConnectionConfig(connectionConfig); + + addMsgSuccess("message.success.delete.target", getResource("knowledge.connection.label.custom")); + + return connect(); + } + /** + * データ移行のリクエストをうける + * @return + * @throws IOException + */ + @Auth(roles="admin") + public Boundary data_transfer() throws IOException { + DataTransferLogic.get().requestTransfer(); + addMsgSuccess("knowledge.connection.msg.custom.transfer.request"); + return connect(); + } + + + /** + * インデックス再生性のページを表示 + * @return + */ + @Auth(roles="admin") + public Boundary reindexing() { + SystemConfigsEntity entity = SystemConfigsDao.get().selectOnKey(SystemConfig.RE_INDEXING, AppConfig.SYSTEM_NAME); + if (entity != null) { + setAttribute("start_reindexing", Boolean.TRUE); + } else { + setAttribute("start_reindexing", Boolean.FALSE); + } + return forward("reindexing.jsp"); + } + + /** + * インデックス再生性のリクエストをうける + * @return + */ + @Auth(roles="admin") + public Boundary start_reindexing() { + SystemConfigsEntity entity = SystemConfigsDao.get().selectOnKey(SystemConfig.RE_INDEXING, AppConfig.SYSTEM_NAME); + if (entity != null) { + addMsgInfo("message.allready.started"); + return reindexing(); + } + Long start = getParam("start", Long.class); + Long end = getParam("end", Long.class); + String val = "start=" + start + ",end=" + end; + + entity = new SystemConfigsEntity(); + entity.setSystemName(AppConfig.SYSTEM_NAME); + entity.setConfigName(SystemConfig.RE_INDEXING); + entity.setConfigValue(val); + + SystemConfigsDao.get().save(entity); + + return reindexing(); + } + + } diff --git a/src/main/java/org/support/project/knowledge/control/protect/AccountControl.java b/src/main/java/org/support/project/knowledge/control/protect/AccountControl.java index b0048fb26..4809c60c0 100644 --- a/src/main/java/org/support/project/knowledge/control/protect/AccountControl.java +++ b/src/main/java/org/support/project/knowledge/control/protect/AccountControl.java @@ -51,10 +51,13 @@ public Boundary index() { LoginedUser loginedUser = super.getLoginedUser(); if (loginedUser == null) { - sendError(HttpStatus.SC_401_UNAUTHORIZED, ""); + return sendError(HttpStatus.SC_401_UNAUTHORIZED, ""); } Integer userId = loginedUser.getLoginUser().getUserId(); UsersEntity user = UsersDao.get().selectOnKey(userId); + if (user == null) { + return sendError(HttpStatus.SC_404_NOT_FOUND, "NOT FOUND"); + } user.setPassword(null); setAttributeOnProperty(user); @@ -77,7 +80,7 @@ public Boundary update() { LoginedUser loginedUser = super.getLoginedUser(); if (loginedUser == null) { - sendError(HttpStatus.SC_401_UNAUTHORIZED, ""); + return sendError(HttpStatus.SC_401_UNAUTHORIZED, ""); } Map values = getParams(); @@ -102,7 +105,7 @@ public Boundary update() { UsersDao dao = UsersDao.get(); user = dao.selectOnKey(getLoginUserId()); if (user == null) { - sendError(HttpStatus.SC_400_BAD_REQUEST, "user is allready removed."); + return sendError(HttpStatus.SC_400_BAD_REQUEST, "user is allready removed."); } if (userAddType.getConfigValue().equals(SystemConfig.USER_ADD_TYPE_VALUE_ADMIN)) { //ユーザ登録を管理者が行っている場合、メールアドレスは変更出来ない(変更用の画面も使えない) diff --git a/src/main/java/org/support/project/knowledge/control/protect/KnowledgeControl.java b/src/main/java/org/support/project/knowledge/control/protect/KnowledgeControl.java index d564d5660..575d3bb1a 100644 --- a/src/main/java/org/support/project/knowledge/control/protect/KnowledgeControl.java +++ b/src/main/java/org/support/project/knowledge/control/protect/KnowledgeControl.java @@ -282,9 +282,9 @@ public Boundary view() throws InvalidParamException { /** * コメント追加 * @return - * @throws InvalidParamException + * @throws Exception */ - public Boundary comment() throws InvalidParamException { + public Boundary comment() throws Exception { // 共通処理呼の表示条件の保持の呼び出し String params = setViewParam(); Long knowledgeId = super.getPathLong(Long.valueOf(-1)); diff --git a/src/main/java/org/support/project/knowledge/dao/KnowledgeFilesDao.java b/src/main/java/org/support/project/knowledge/dao/KnowledgeFilesDao.java index 1a61da6d0..be5e9e568 100644 --- a/src/main/java/org/support/project/knowledge/dao/KnowledgeFilesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/KnowledgeFilesDao.java @@ -41,7 +41,7 @@ public List selectOnKnowledgeId(Long knowledgeId) { StringBuilder sql = new StringBuilder(); sql.append("SELECT FILE_NO, KNOWLEDGE_ID, FILE_NAME, FILE_SIZE, INSERT_USER, INSERT_DATETIME, UPDATE_USER, UPDATE_DATETIME, DELETE_FLAG "); sql.append("FROM KNOWLEDGE_FILES WHERE KNOWLEDGE_ID = ?;"); - return executeQuery(sql.toString(), KnowledgeFilesEntity.class, knowledgeId); + return executeQueryList(sql.toString(), KnowledgeFilesEntity.class, knowledgeId); } /** @@ -52,7 +52,7 @@ public KnowledgeFilesEntity selectOnKeyWithoutBinary(Long fileNo) { StringBuilder sql = new StringBuilder(); sql.append("SELECT FILE_NO, KNOWLEDGE_ID, FILE_NAME, FILE_SIZE, INSERT_USER, INSERT_DATETIME, UPDATE_USER, UPDATE_DATETIME, DELETE_FLAG "); sql.append("FROM KNOWLEDGE_FILES WHERE FILE_NO = ?;"); - return executeQueryOnKey(sql.toString(), KnowledgeFilesEntity.class, fileNo); + return executeQuerySingle(sql.toString(), KnowledgeFilesEntity.class, fileNo); } /** diff --git a/src/main/java/org/support/project/knowledge/dao/KnowledgesDao.java b/src/main/java/org/support/project/knowledge/dao/KnowledgesDao.java index 3c3a245ae..4d99174e2 100644 --- a/src/main/java/org/support/project/knowledge/dao/KnowledgesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/KnowledgesDao.java @@ -1,6 +1,7 @@ package org.support.project.knowledge.dao; import java.sql.Timestamp; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -55,7 +56,7 @@ public Integer getNextId() { public List selectKnowledge(int offset, int limit, Integer userId) { // String sql = "SELECT * FROM KNOWLEDGES WHERE DELETE_FLAG = 0 ORDER BY UPDATE_DATETIME DESC Limit ? offset ?;"; String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_selectKnowledgeWithUserName.sql"); - return executeQuery(sql, KnowledgesEntity.class, limit, offset); + return executeQueryList(sql, KnowledgesEntity.class, limit, offset); } @@ -65,6 +66,9 @@ public List selectKnowledge(int offset, int limit, Integer use * @return */ public List selectKnowledges(List knowledgeIds) { + if (knowledgeIds == null || knowledgeIds.isEmpty()) { + return new ArrayList(); + } StringBuilder sql = new StringBuilder(); sql.append("SELECT "); sql.append(" KNOWLEDGES.*"); @@ -83,7 +87,7 @@ public List selectKnowledges(List knowledgeIds) { count++; } sql.append(")"); - return executeQuery(sql.toString(), KnowledgesEntity.class, knowledgeIds.toArray(new Long[0])); + return executeQueryList(sql.toString(), KnowledgesEntity.class, knowledgeIds.toArray(new Long[0])); } @@ -95,7 +99,7 @@ public List selectKnowledges(List knowledgeIds) { */ public KnowledgesEntity selectOnKeyWithUserName(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_selectOnKeyWithUserName.sql"); - return executeQueryOnKey(sql, KnowledgesEntity.class, knowledgeId); + return executeQuerySingle(sql, KnowledgesEntity.class, knowledgeId); } @@ -106,7 +110,7 @@ public KnowledgesEntity selectOnKeyWithUserName(Long knowledgeId) { */ public List selectOnUser(Integer userId) { String sql = "SELECT KNOWLEDGE_ID FROM KNOWLEDGES WHERE INSERT_USER = ? ORDER BY KNOWLEDGE_ID DESC"; - return executeQuery(sql, Long.class, userId); + return executeQueryList(sql, Long.class, userId); } @@ -121,4 +125,17 @@ public void deleteOnUser(Integer loginUserId) { } + + /** + * 登録されているナレッジを、番号指定で取得 + * @param start + * @param end + * @return + */ + public List selectBetween(Long start, Long end) { + String sql = "SELECT * FROM knowledges WHERE knowledge_id BETWEEN ? AND ? AND DELETE_FLAG = 0 ORDER BY knowledge_id"; + return executeQueryList(sql, KnowledgesEntity.class, start, end); + } + + } diff --git a/src/main/java/org/support/project/knowledge/dao/LikesDao.java b/src/main/java/org/support/project/knowledge/dao/LikesDao.java index 3417f5bd2..eb1f139f3 100644 --- a/src/main/java/org/support/project/knowledge/dao/LikesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/LikesDao.java @@ -35,7 +35,7 @@ public Long countOnKnowledgeId(Long knowledgeId) { public List selectOnKnowledge(Long knowledgeId, int offset, int limit) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_selectOnKnowledge.sql"); - return executeQuery(sql, LikesEntity.class, knowledgeId, limit, offset); + return executeQueryList(sql, LikesEntity.class, knowledgeId, limit, offset); } diff --git a/src/main/java/org/support/project/knowledge/dao/TagsDao.java b/src/main/java/org/support/project/knowledge/dao/TagsDao.java index 7af7d5b74..167daed23 100644 --- a/src/main/java/org/support/project/knowledge/dao/TagsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/TagsDao.java @@ -68,7 +68,7 @@ public TagsEntity selectOnTagName(String tag) { */ public List selectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectOnKnowledgeId.sql"); - return executeQuery(sql, TagsEntity.class, knowledgeId); + return executeQueryList(sql, TagsEntity.class, knowledgeId); } @@ -82,7 +82,7 @@ public List selectOnKnowledgeId(Long knowledgeId) { */ public List selectTagsWithCount(int offset, int limit) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectTagsWithCount.sql"); - return executeQuery(sql, TagsEntity.class, limit, offset); + return executeQueryList(sql, TagsEntity.class, limit, offset); } /** @@ -96,7 +96,7 @@ public List selectTagsWithCount(int offset, int limit) { */ public List selectTagsWithCountOnUser(int userid, int offset, int limit) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectTagsWithCountOnUser.sql"); - return executeQuery(sql, TagsEntity.class, userid, limit, offset); + return executeQueryList(sql, TagsEntity.class, userid, limit, offset); } /** @@ -119,7 +119,7 @@ public List selectWithKnowledgeCount(int userId, List params.add(new Integer(offset)); sql = sql.replace("${groups}", builder.join(", ")); - return executeQuery(sql, TagsEntity.class, params.toArray(new Integer[0])); + return executeQueryList(sql, TagsEntity.class, params.toArray(new Integer[0])); } /** * タグの一覧と、それに紐づくナレッジの件数を取得 @@ -130,7 +130,7 @@ public List selectWithKnowledgeCount(int userId, List */ public List selectWithKnowledgeCountAdmin(int offset, int limit) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectWithKnowledgeCountAdmin.sql"); - return executeQuery(sql, TagsEntity.class, limit, offset); + return executeQueryList(sql, TagsEntity.class, limit, offset); } } diff --git a/src/main/java/org/support/project/knowledge/dao/TargetsDao.java b/src/main/java/org/support/project/knowledge/dao/TargetsDao.java index ccf385a4e..bb142d6d4 100644 --- a/src/main/java/org/support/project/knowledge/dao/TargetsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/TargetsDao.java @@ -30,7 +30,7 @@ public static TargetsDao get() { */ public List selectOnKeyword(String keyword, int offset, int limit) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TargetsDao/selectOnKeyword.sql"); - return executeQuery(sql, LabelValue.class, keyword, keyword, limit, offset); + return executeQueryList(sql, LabelValue.class, keyword, keyword, limit, offset); } @@ -42,7 +42,7 @@ public List selectOnKeyword(String keyword, int offset, int limit) { */ public List selectGroupsOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TargetsDao/selectGroupsOnKnowledgeId.sql"); - return executeQuery(sql, GroupsEntity.class, knowledgeId); + return executeQueryList(sql, GroupsEntity.class, knowledgeId); } /** @@ -52,7 +52,7 @@ public List selectGroupsOnKnowledgeId(Long knowledgeId) { */ public List selectUsersOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TargetsDao/selectUsersOnKnowledgeId.sql"); - return executeQuery(sql, UsersEntity.class, knowledgeId); + return executeQueryList(sql, UsersEntity.class, knowledgeId); } diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenAccountImagesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenAccountImagesDao.java index 6f6e55cbe..b5de711f0 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenAccountImagesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenAccountImagesDao.java @@ -12,6 +12,8 @@ import org.support.project.ormapping.common.SQLManager; import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; +import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; import org.support.project.di.Container; @@ -42,28 +44,55 @@ public static GenAccountImagesDao get() { */ public List physicalSelectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_physical_select_all.sql"); - return executeQuery(sql, AccountImagesEntity.class); + return executeQueryList(sql, AccountImagesEntity.class); } /** * キーで1件取得(削除フラグを無視して取得) */ public AccountImagesEntity physicalSelectOnKey(Long imageId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_physical_select_on_key.sql"); - return executeQueryOnKey(sql, AccountImagesEntity.class, imageId); + return executeQuerySingle(sql, AccountImagesEntity.class, imageId); } /** * 全て取得 */ public List selectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_select_all.sql"); - return executeQuery(sql, AccountImagesEntity.class); + return executeQueryList(sql, AccountImagesEntity.class); } /** * キーで1件取得 */ public AccountImagesEntity selectOnKey(Long imageId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_select_on_key.sql"); - return executeQueryOnKey(sql, AccountImagesEntity.class, imageId); + return executeQuerySingle(sql, AccountImagesEntity.class, imageId); + } + /** + * 登録(データを生で操作/DBの採番機能のカラムも自分でセット) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public AccountImagesEntity rawPhysicalInsert(AccountImagesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_raw_insert.sql"); + executeUpdate(sql, + entity.getImageId() + , entity.getUserId() + , entity.getFileName() + , entity.getFileSize() + , entity.getFileBinary() + , entity.getExtension() + , entity.getContentType() + , entity.getInsertUser() + , entity.getInsertDatetime() + , entity.getUpdateUser() + , entity.getUpdateDatetime() + , entity.getDeleteFlag() + ); + String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); + if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { + String setValSql = "select setval('ACCOUNT_IMAGES_IMAGE_ID_seq', (select max(IMAGE_ID) from ACCOUNT_IMAGES));"; + executeQuerySingle(setValSql, Long.class); + } + return entity; } /** * 登録(データを生で操作) @@ -73,8 +102,7 @@ public AccountImagesEntity physicalInsert(AccountImagesEntity entity) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_insert.sql"); Class type = PropertyUtil.getPropertyType(entity, "imageId"); Object key = executeInsert(sql, type, - entity.getImageId() - , entity.getUserId() + entity.getUserId() , entity.getFileName() , entity.getFileSize() , entity.getFileBinary() diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenCommentsDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenCommentsDao.java index a8a6ba2fb..5ee8c73b0 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenCommentsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenCommentsDao.java @@ -11,6 +11,8 @@ import org.support.project.ormapping.common.SQLManager; import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; +import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; import org.support.project.di.Container; @@ -41,28 +43,51 @@ public static GenCommentsDao get() { */ public List physicalSelectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_physical_select_all.sql"); - return executeQuery(sql, CommentsEntity.class); + return executeQueryList(sql, CommentsEntity.class); } /** * キーで1件取得(削除フラグを無視して取得) */ public CommentsEntity physicalSelectOnKey(Long commentNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_physical_select_on_key.sql"); - return executeQueryOnKey(sql, CommentsEntity.class, commentNo); + return executeQuerySingle(sql, CommentsEntity.class, commentNo); } /** * 全て取得 */ public List selectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_select_all.sql"); - return executeQuery(sql, CommentsEntity.class); + return executeQueryList(sql, CommentsEntity.class); } /** * キーで1件取得 */ public CommentsEntity selectOnKey(Long commentNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_select_on_key.sql"); - return executeQueryOnKey(sql, CommentsEntity.class, commentNo); + return executeQuerySingle(sql, CommentsEntity.class, commentNo); + } + /** + * 登録(データを生で操作/DBの採番機能のカラムも自分でセット) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public CommentsEntity rawPhysicalInsert(CommentsEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_raw_insert.sql"); + executeUpdate(sql, + entity.getCommentNo() + , entity.getKnowledgeId() + , entity.getComment() + , entity.getInsertUser() + , entity.getInsertDatetime() + , entity.getUpdateUser() + , entity.getUpdateDatetime() + , entity.getDeleteFlag() + ); + String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); + if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { + String setValSql = "select setval('COMMENTS_COMMENT_NO_seq', (select max(COMMENT_NO) from COMMENTS));"; + executeQuerySingle(setValSql, Long.class); + } + return entity; } /** * 登録(データを生で操作) @@ -72,8 +97,7 @@ public CommentsEntity physicalInsert(CommentsEntity entity) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_insert.sql"); Class type = PropertyUtil.getPropertyType(entity, "commentNo"); Object key = executeInsert(sql, type, - entity.getCommentNo() - , entity.getKnowledgeId() + entity.getKnowledgeId() , entity.getComment() , entity.getInsertUser() , entity.getInsertDatetime() diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeFilesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeFilesDao.java index 85d5f1b9c..8260a8528 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeFilesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeFilesDao.java @@ -12,6 +12,8 @@ import org.support.project.ormapping.common.SQLManager; import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; +import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; import org.support.project.di.Container; @@ -42,28 +44,55 @@ public static GenKnowledgeFilesDao get() { */ public List physicalSelectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_physical_select_all.sql"); - return executeQuery(sql, KnowledgeFilesEntity.class); + return executeQueryList(sql, KnowledgeFilesEntity.class); } /** * キーで1件取得(削除フラグを無視して取得) */ public KnowledgeFilesEntity physicalSelectOnKey(Long fileNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_physical_select_on_key.sql"); - return executeQueryOnKey(sql, KnowledgeFilesEntity.class, fileNo); + return executeQuerySingle(sql, KnowledgeFilesEntity.class, fileNo); } /** * 全て取得 */ public List selectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_select_all.sql"); - return executeQuery(sql, KnowledgeFilesEntity.class); + return executeQueryList(sql, KnowledgeFilesEntity.class); } /** * キーで1件取得 */ public KnowledgeFilesEntity selectOnKey(Long fileNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_select_on_key.sql"); - return executeQueryOnKey(sql, KnowledgeFilesEntity.class, fileNo); + return executeQuerySingle(sql, KnowledgeFilesEntity.class, fileNo); + } + /** + * 登録(データを生で操作/DBの採番機能のカラムも自分でセット) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public KnowledgeFilesEntity rawPhysicalInsert(KnowledgeFilesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_raw_insert.sql"); + executeUpdate(sql, + entity.getFileNo() + , entity.getKnowledgeId() + , entity.getCommentNo() + , entity.getFileName() + , entity.getFileSize() + , entity.getFileBinary() + , entity.getParseStatus() + , entity.getInsertUser() + , entity.getInsertDatetime() + , entity.getUpdateUser() + , entity.getUpdateDatetime() + , entity.getDeleteFlag() + ); + String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); + if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { + String setValSql = "select setval('KNOWLEDGE_FILES_FILE_NO_seq', (select max(FILE_NO) from KNOWLEDGE_FILES));"; + executeQuerySingle(setValSql, Long.class); + } + return entity; } /** * 登録(データを生で操作) @@ -73,8 +102,7 @@ public KnowledgeFilesEntity physicalInsert(KnowledgeFilesEntity entity) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_insert.sql"); Class type = PropertyUtil.getPropertyType(entity, "fileNo"); Object key = executeInsert(sql, type, - entity.getFileNo() - , entity.getKnowledgeId() + entity.getKnowledgeId() , entity.getCommentNo() , entity.getFileName() , entity.getFileSize() diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeGroupsDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeGroupsDao.java index fa920c225..ae987a4dc 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeGroupsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeGroupsDao.java @@ -11,6 +11,8 @@ import org.support.project.ormapping.common.SQLManager; import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; +import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; import org.support.project.di.Container; @@ -41,56 +43,73 @@ public static GenKnowledgeGroupsDao get() { */ public List physicalSelectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_physical_select_all.sql"); - return executeQuery(sql, KnowledgeGroupsEntity.class); + return executeQueryList(sql, KnowledgeGroupsEntity.class); } /** * キーで1件取得(削除フラグを無視して取得) */ public KnowledgeGroupsEntity physicalSelectOnKey(Integer groupId, Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_physical_select_on_key.sql"); - return executeQueryOnKey(sql, KnowledgeGroupsEntity.class, groupId, knowledgeId); + return executeQuerySingle(sql, KnowledgeGroupsEntity.class, groupId, knowledgeId); } /** * 全て取得 */ public List selectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_select_all.sql"); - return executeQuery(sql, KnowledgeGroupsEntity.class); + return executeQueryList(sql, KnowledgeGroupsEntity.class); } /** * キーで1件取得 */ public KnowledgeGroupsEntity selectOnKey(Integer groupId, Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_select_on_key.sql"); - return executeQueryOnKey(sql, KnowledgeGroupsEntity.class, groupId, knowledgeId); + return executeQuerySingle(sql, KnowledgeGroupsEntity.class, groupId, knowledgeId); } /** * GROUP_ID でリストを取得 */ public List selectOnGroupId(Integer groupId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_select_on_group_id.sql"); - return executeQuery(sql, KnowledgeGroupsEntity.class, groupId); + return executeQueryList(sql, KnowledgeGroupsEntity.class, groupId); } /** * KNOWLEDGE_ID でリストを取得 */ public List selectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_select_on_knowledge_id.sql"); - return executeQuery(sql, KnowledgeGroupsEntity.class, knowledgeId); + return executeQueryList(sql, KnowledgeGroupsEntity.class, knowledgeId); } /** * GROUP_ID でリストを取得 */ public List physicalSelectOnGroupId(Integer groupId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_physical_select_on_group_id.sql"); - return executeQuery(sql, KnowledgeGroupsEntity.class, groupId); + return executeQueryList(sql, KnowledgeGroupsEntity.class, groupId); } /** * KNOWLEDGE_ID でリストを取得 */ public List physicalSelectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_physical_select_on_knowledge_id.sql"); - return executeQuery(sql, KnowledgeGroupsEntity.class, knowledgeId); + return executeQueryList(sql, KnowledgeGroupsEntity.class, knowledgeId); + } + /** + * 登録(データを生で操作/DBの採番機能のカラムも自分でセット) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public KnowledgeGroupsEntity rawPhysicalInsert(KnowledgeGroupsEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_raw_insert.sql"); + executeUpdate(sql, + entity.getGroupId() + , entity.getKnowledgeId() + , entity.getInsertUser() + , entity.getInsertDatetime() + , entity.getUpdateUser() + , entity.getUpdateDatetime() + , entity.getDeleteFlag() + ); + return entity; } /** * 登録(データを生で操作) @@ -99,8 +118,8 @@ public List physicalSelectOnKnowledgeId(Long knowledgeId) public KnowledgeGroupsEntity physicalInsert(KnowledgeGroupsEntity entity) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_insert.sql"); executeUpdate(sql, - entity.getKnowledgeId() - , entity.getGroupId() + entity.getGroupId() + , entity.getKnowledgeId() , entity.getInsertUser() , entity.getInsertDatetime() , entity.getUpdateUser() diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeTagsDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeTagsDao.java index f22405507..1050697d9 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeTagsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeTagsDao.java @@ -11,6 +11,8 @@ import org.support.project.ormapping.common.SQLManager; import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; +import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; import org.support.project.di.Container; @@ -41,56 +43,73 @@ public static GenKnowledgeTagsDao get() { */ public List physicalSelectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_physical_select_all.sql"); - return executeQuery(sql, KnowledgeTagsEntity.class); + return executeQueryList(sql, KnowledgeTagsEntity.class); } /** * キーで1件取得(削除フラグを無視して取得) */ public KnowledgeTagsEntity physicalSelectOnKey(Long knowledgeId, Integer tagId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_physical_select_on_key.sql"); - return executeQueryOnKey(sql, KnowledgeTagsEntity.class, knowledgeId, tagId); + return executeQuerySingle(sql, KnowledgeTagsEntity.class, knowledgeId, tagId); } /** * 全て取得 */ public List selectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_select_all.sql"); - return executeQuery(sql, KnowledgeTagsEntity.class); + return executeQueryList(sql, KnowledgeTagsEntity.class); } /** * キーで1件取得 */ public KnowledgeTagsEntity selectOnKey(Long knowledgeId, Integer tagId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_select_on_key.sql"); - return executeQueryOnKey(sql, KnowledgeTagsEntity.class, knowledgeId, tagId); + return executeQuerySingle(sql, KnowledgeTagsEntity.class, knowledgeId, tagId); } /** * KNOWLEDGE_ID でリストを取得 */ public List selectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_select_on_knowledge_id.sql"); - return executeQuery(sql, KnowledgeTagsEntity.class, knowledgeId); + return executeQueryList(sql, KnowledgeTagsEntity.class, knowledgeId); } /** * TAG_ID でリストを取得 */ public List selectOnTagId(Integer tagId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_select_on_tag_id.sql"); - return executeQuery(sql, KnowledgeTagsEntity.class, tagId); + return executeQueryList(sql, KnowledgeTagsEntity.class, tagId); } /** * KNOWLEDGE_ID でリストを取得 */ public List physicalSelectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_physical_select_on_knowledge_id.sql"); - return executeQuery(sql, KnowledgeTagsEntity.class, knowledgeId); + return executeQueryList(sql, KnowledgeTagsEntity.class, knowledgeId); } /** * TAG_ID でリストを取得 */ public List physicalSelectOnTagId(Integer tagId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_physical_select_on_tag_id.sql"); - return executeQuery(sql, KnowledgeTagsEntity.class, tagId); + return executeQueryList(sql, KnowledgeTagsEntity.class, tagId); + } + /** + * 登録(データを生で操作/DBの採番機能のカラムも自分でセット) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public KnowledgeTagsEntity rawPhysicalInsert(KnowledgeTagsEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_raw_insert.sql"); + executeUpdate(sql, + entity.getKnowledgeId() + , entity.getTagId() + , entity.getInsertUser() + , entity.getInsertDatetime() + , entity.getUpdateUser() + , entity.getUpdateDatetime() + , entity.getDeleteFlag() + ); + return entity; } /** * 登録(データを生で操作) diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeUsersDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeUsersDao.java index e921236cd..91e0c568e 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeUsersDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeUsersDao.java @@ -11,6 +11,8 @@ import org.support.project.ormapping.common.SQLManager; import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; +import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; import org.support.project.di.Container; @@ -41,56 +43,73 @@ public static GenKnowledgeUsersDao get() { */ public List physicalSelectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_physical_select_all.sql"); - return executeQuery(sql, KnowledgeUsersEntity.class); + return executeQueryList(sql, KnowledgeUsersEntity.class); } /** * キーで1件取得(削除フラグを無視して取得) */ public KnowledgeUsersEntity physicalSelectOnKey(Long knowledgeId, Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_physical_select_on_key.sql"); - return executeQueryOnKey(sql, KnowledgeUsersEntity.class, knowledgeId, userId); + return executeQuerySingle(sql, KnowledgeUsersEntity.class, knowledgeId, userId); } /** * 全て取得 */ public List selectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_select_all.sql"); - return executeQuery(sql, KnowledgeUsersEntity.class); + return executeQueryList(sql, KnowledgeUsersEntity.class); } /** * キーで1件取得 */ public KnowledgeUsersEntity selectOnKey(Long knowledgeId, Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_select_on_key.sql"); - return executeQueryOnKey(sql, KnowledgeUsersEntity.class, knowledgeId, userId); + return executeQuerySingle(sql, KnowledgeUsersEntity.class, knowledgeId, userId); } /** * KNOWLEDGE_ID でリストを取得 */ public List selectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_select_on_knowledge_id.sql"); - return executeQuery(sql, KnowledgeUsersEntity.class, knowledgeId); + return executeQueryList(sql, KnowledgeUsersEntity.class, knowledgeId); } /** * USER_ID でリストを取得 */ public List selectOnUserId(Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_select_on_user_id.sql"); - return executeQuery(sql, KnowledgeUsersEntity.class, userId); + return executeQueryList(sql, KnowledgeUsersEntity.class, userId); } /** * KNOWLEDGE_ID でリストを取得 */ public List physicalSelectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_physical_select_on_knowledge_id.sql"); - return executeQuery(sql, KnowledgeUsersEntity.class, knowledgeId); + return executeQueryList(sql, KnowledgeUsersEntity.class, knowledgeId); } /** * USER_ID でリストを取得 */ public List physicalSelectOnUserId(Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_physical_select_on_user_id.sql"); - return executeQuery(sql, KnowledgeUsersEntity.class, userId); + return executeQueryList(sql, KnowledgeUsersEntity.class, userId); + } + /** + * 登録(データを生で操作/DBの採番機能のカラムも自分でセット) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public KnowledgeUsersEntity rawPhysicalInsert(KnowledgeUsersEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_raw_insert.sql"); + executeUpdate(sql, + entity.getKnowledgeId() + , entity.getUserId() + , entity.getInsertUser() + , entity.getInsertDatetime() + , entity.getUpdateUser() + , entity.getUpdateDatetime() + , entity.getDeleteFlag() + ); + return entity; } /** * 登録(データを生で操作) diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgesDao.java index aa1cd17f8..0074c2a78 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgesDao.java @@ -11,6 +11,8 @@ import org.support.project.ormapping.common.SQLManager; import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; +import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; import org.support.project.di.Container; @@ -41,28 +43,56 @@ public static GenKnowledgesDao get() { */ public List physicalSelectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_physical_select_all.sql"); - return executeQuery(sql, KnowledgesEntity.class); + return executeQueryList(sql, KnowledgesEntity.class); } /** * キーで1件取得(削除フラグを無視して取得) */ public KnowledgesEntity physicalSelectOnKey(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_physical_select_on_key.sql"); - return executeQueryOnKey(sql, KnowledgesEntity.class, knowledgeId); + return executeQuerySingle(sql, KnowledgesEntity.class, knowledgeId); } /** * 全て取得 */ public List selectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_select_all.sql"); - return executeQuery(sql, KnowledgesEntity.class); + return executeQueryList(sql, KnowledgesEntity.class); } /** * キーで1件取得 */ public KnowledgesEntity selectOnKey(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_select_on_key.sql"); - return executeQueryOnKey(sql, KnowledgesEntity.class, knowledgeId); + return executeQuerySingle(sql, KnowledgesEntity.class, knowledgeId); + } + /** + * 登録(データを生で操作/DBの採番機能のカラムも自分でセット) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public KnowledgesEntity rawPhysicalInsert(KnowledgesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_raw_insert.sql"); + executeUpdate(sql, + entity.getKnowledgeId() + , entity.getTitle() + , entity.getContent() + , entity.getPublicFlag() + , entity.getTagIds() + , entity.getTagNames() + , entity.getLikeCount() + , entity.getCommentCount() + , entity.getInsertUser() + , entity.getInsertDatetime() + , entity.getUpdateUser() + , entity.getUpdateDatetime() + , entity.getDeleteFlag() + ); + String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); + if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { + String setValSql = "select setval('KNOWLEDGES_KNOWLEDGE_ID_seq', (select max(KNOWLEDGE_ID) from KNOWLEDGES));"; + executeQuerySingle(setValSql, Long.class); + } + return entity; } /** * 登録(データを生で操作) @@ -72,8 +102,7 @@ public KnowledgesEntity physicalInsert(KnowledgesEntity entity) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_insert.sql"); Class type = PropertyUtil.getPropertyType(entity, "knowledgeId"); Object key = executeInsert(sql, type, - entity.getKnowledgeId() - , entity.getTitle() + entity.getTitle() , entity.getContent() , entity.getPublicFlag() , entity.getTagIds() diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenLikesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenLikesDao.java index afa221277..2d5af0cfa 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenLikesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenLikesDao.java @@ -11,6 +11,8 @@ import org.support.project.ormapping.common.SQLManager; import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; +import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; import org.support.project.di.Container; @@ -41,28 +43,50 @@ public static GenLikesDao get() { */ public List physicalSelectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_physical_select_all.sql"); - return executeQuery(sql, LikesEntity.class); + return executeQueryList(sql, LikesEntity.class); } /** * キーで1件取得(削除フラグを無視して取得) */ public LikesEntity physicalSelectOnKey(Long no) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_physical_select_on_key.sql"); - return executeQueryOnKey(sql, LikesEntity.class, no); + return executeQuerySingle(sql, LikesEntity.class, no); } /** * 全て取得 */ public List selectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_select_all.sql"); - return executeQuery(sql, LikesEntity.class); + return executeQueryList(sql, LikesEntity.class); } /** * キーで1件取得 */ public LikesEntity selectOnKey(Long no) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_select_on_key.sql"); - return executeQueryOnKey(sql, LikesEntity.class, no); + return executeQuerySingle(sql, LikesEntity.class, no); + } + /** + * 登録(データを生で操作/DBの採番機能のカラムも自分でセット) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public LikesEntity rawPhysicalInsert(LikesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_raw_insert.sql"); + executeUpdate(sql, + entity.getNo() + , entity.getKnowledgeId() + , entity.getInsertUser() + , entity.getInsertDatetime() + , entity.getUpdateUser() + , entity.getUpdateDatetime() + , entity.getDeleteFlag() + ); + String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); + if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { + String setValSql = "select setval('LIKES_NO_seq', (select max(NO) from LIKES));"; + executeQuerySingle(setValSql, Long.class); + } + return entity; } /** * 登録(データを生で操作) @@ -72,8 +96,7 @@ public LikesEntity physicalInsert(LikesEntity entity) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_insert.sql"); Class type = PropertyUtil.getPropertyType(entity, "no"); Object key = executeInsert(sql, type, - entity.getNo() - , entity.getKnowledgeId() + entity.getKnowledgeId() , entity.getInsertUser() , entity.getInsertDatetime() , entity.getUpdateUser() diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenNotifyConfigsDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenNotifyConfigsDao.java index a1ef80cb8..c8a5d8947 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenNotifyConfigsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenNotifyConfigsDao.java @@ -11,6 +11,8 @@ import org.support.project.ormapping.common.SQLManager; import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; +import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; import org.support.project.di.Container; @@ -41,28 +43,54 @@ public static GenNotifyConfigsDao get() { */ public List physicalSelectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_physical_select_all.sql"); - return executeQuery(sql, NotifyConfigsEntity.class); + return executeQueryList(sql, NotifyConfigsEntity.class); } /** * キーで1件取得(削除フラグを無視して取得) */ public NotifyConfigsEntity physicalSelectOnKey(Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_physical_select_on_key.sql"); - return executeQueryOnKey(sql, NotifyConfigsEntity.class, userId); + return executeQuerySingle(sql, NotifyConfigsEntity.class, userId); } /** * 全て取得 */ public List selectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_select_all.sql"); - return executeQuery(sql, NotifyConfigsEntity.class); + return executeQueryList(sql, NotifyConfigsEntity.class); } /** * キーで1件取得 */ public NotifyConfigsEntity selectOnKey(Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_select_on_key.sql"); - return executeQueryOnKey(sql, NotifyConfigsEntity.class, userId); + return executeQuerySingle(sql, NotifyConfigsEntity.class, userId); + } + /** + * 登録(データを生で操作/DBの採番機能のカラムも自分でセット) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public NotifyConfigsEntity rawPhysicalInsert(NotifyConfigsEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_raw_insert.sql"); + executeUpdate(sql, + entity.getUserId() + , entity.getNotifyMail() + , entity.getNotifyDesktop() + , entity.getMyItemComment() + , entity.getMyItemLike() + , entity.getMyItemStock() + , entity.getToItemSave() + , entity.getToItemComment() + , entity.getToItemIgnorePublic() + , entity.getStockItemSave() + , entity.getStokeItemComment() + , entity.getInsertUser() + , entity.getInsertDatetime() + , entity.getUpdateUser() + , entity.getUpdateDatetime() + , entity.getDeleteFlag() + ); + return entity; } /** * 登録(データを生で操作) diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenNotifyQueuesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenNotifyQueuesDao.java index f69569b63..02b259c6a 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenNotifyQueuesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenNotifyQueuesDao.java @@ -11,6 +11,8 @@ import org.support.project.ormapping.common.SQLManager; import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; +import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; import org.support.project.di.Container; @@ -41,28 +43,46 @@ public static GenNotifyQueuesDao get() { */ public List physicalSelectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_physical_select_all.sql"); - return executeQuery(sql, NotifyQueuesEntity.class); + return executeQueryList(sql, NotifyQueuesEntity.class); } /** * キーで1件取得(削除フラグを無視して取得) */ public NotifyQueuesEntity physicalSelectOnKey(String hash) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_physical_select_on_key.sql"); - return executeQueryOnKey(sql, NotifyQueuesEntity.class, hash); + return executeQuerySingle(sql, NotifyQueuesEntity.class, hash); } /** * 全て取得 */ public List selectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_select_all.sql"); - return executeQuery(sql, NotifyQueuesEntity.class); + return executeQueryList(sql, NotifyQueuesEntity.class); } /** * キーで1件取得 */ public NotifyQueuesEntity selectOnKey(String hash) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_select_on_key.sql"); - return executeQueryOnKey(sql, NotifyQueuesEntity.class, hash); + return executeQuerySingle(sql, NotifyQueuesEntity.class, hash); + } + /** + * 登録(データを生で操作/DBの採番機能のカラムも自分でセット) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public NotifyQueuesEntity rawPhysicalInsert(NotifyQueuesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_raw_insert.sql"); + executeUpdate(sql, + entity.getHash() + , entity.getType() + , entity.getId() + , entity.getInsertUser() + , entity.getInsertDatetime() + , entity.getUpdateUser() + , entity.getUpdateDatetime() + , entity.getDeleteFlag() + ); + return entity; } /** * 登録(データを生で操作) diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenStocksDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenStocksDao.java index 1bcdd7a4a..36258e34a 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenStocksDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenStocksDao.java @@ -11,6 +11,8 @@ import org.support.project.ormapping.common.SQLManager; import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; +import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; import org.support.project.di.Container; @@ -41,56 +43,74 @@ public static GenStocksDao get() { */ public List physicalSelectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_physical_select_all.sql"); - return executeQuery(sql, StocksEntity.class); + return executeQueryList(sql, StocksEntity.class); } /** * キーで1件取得(削除フラグを無視して取得) */ public StocksEntity physicalSelectOnKey(Long knowledgeId, Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_physical_select_on_key.sql"); - return executeQueryOnKey(sql, StocksEntity.class, knowledgeId, userId); + return executeQuerySingle(sql, StocksEntity.class, knowledgeId, userId); } /** * 全て取得 */ public List selectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_select_all.sql"); - return executeQuery(sql, StocksEntity.class); + return executeQueryList(sql, StocksEntity.class); } /** * キーで1件取得 */ public StocksEntity selectOnKey(Long knowledgeId, Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_select_on_key.sql"); - return executeQueryOnKey(sql, StocksEntity.class, knowledgeId, userId); + return executeQuerySingle(sql, StocksEntity.class, knowledgeId, userId); } /** * KNOWLEDGE_ID でリストを取得 */ public List selectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_select_on_knowledge_id.sql"); - return executeQuery(sql, StocksEntity.class, knowledgeId); + return executeQueryList(sql, StocksEntity.class, knowledgeId); } /** * USER_ID でリストを取得 */ public List selectOnUserId(Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_select_on_user_id.sql"); - return executeQuery(sql, StocksEntity.class, userId); + return executeQueryList(sql, StocksEntity.class, userId); } /** * KNOWLEDGE_ID でリストを取得 */ public List physicalSelectOnKnowledgeId(Long knowledgeId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_physical_select_on_knowledge_id.sql"); - return executeQuery(sql, StocksEntity.class, knowledgeId); + return executeQueryList(sql, StocksEntity.class, knowledgeId); } /** * USER_ID でリストを取得 */ public List physicalSelectOnUserId(Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_physical_select_on_user_id.sql"); - return executeQuery(sql, StocksEntity.class, userId); + return executeQueryList(sql, StocksEntity.class, userId); + } + /** + * 登録(データを生で操作/DBの採番機能のカラムも自分でセット) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public StocksEntity rawPhysicalInsert(StocksEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_raw_insert.sql"); + executeUpdate(sql, + entity.getKnowledgeId() + , entity.getUserId() + , entity.getComment() + , entity.getInsertUser() + , entity.getInsertDatetime() + , entity.getUpdateUser() + , entity.getUpdateDatetime() + , entity.getDeleteFlag() + ); + return entity; } /** * 登録(データを生で操作) @@ -99,8 +119,8 @@ public List physicalSelectOnUserId(Integer userId) { public StocksEntity physicalInsert(StocksEntity entity) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_insert.sql"); executeUpdate(sql, - entity.getUserId() - , entity.getKnowledgeId() + entity.getKnowledgeId() + , entity.getUserId() , entity.getComment() , entity.getInsertUser() , entity.getInsertDatetime() diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenTagsDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenTagsDao.java index 860e426af..a346e613c 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenTagsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenTagsDao.java @@ -11,6 +11,8 @@ import org.support.project.ormapping.common.SQLManager; import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; +import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; import org.support.project.di.Container; @@ -41,28 +43,50 @@ public static GenTagsDao get() { */ public List physicalSelectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_physical_select_all.sql"); - return executeQuery(sql, TagsEntity.class); + return executeQueryList(sql, TagsEntity.class); } /** * キーで1件取得(削除フラグを無視して取得) */ public TagsEntity physicalSelectOnKey(Integer tagId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_physical_select_on_key.sql"); - return executeQueryOnKey(sql, TagsEntity.class, tagId); + return executeQuerySingle(sql, TagsEntity.class, tagId); } /** * 全て取得 */ public List selectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_select_all.sql"); - return executeQuery(sql, TagsEntity.class); + return executeQueryList(sql, TagsEntity.class); } /** * キーで1件取得 */ public TagsEntity selectOnKey(Integer tagId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_select_on_key.sql"); - return executeQueryOnKey(sql, TagsEntity.class, tagId); + return executeQuerySingle(sql, TagsEntity.class, tagId); + } + /** + * 登録(データを生で操作/DBの採番機能のカラムも自分でセット) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public TagsEntity rawPhysicalInsert(TagsEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_raw_insert.sql"); + executeUpdate(sql, + entity.getTagId() + , entity.getTagName() + , entity.getInsertUser() + , entity.getInsertDatetime() + , entity.getUpdateUser() + , entity.getUpdateDatetime() + , entity.getDeleteFlag() + ); + String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); + if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { + String setValSql = "select setval('TAGS_TAG_ID_seq', (select max(TAG_ID) from TAGS));"; + executeQuerySingle(setValSql, Long.class); + } + return entity; } /** * 登録(データを生で操作) @@ -72,8 +96,7 @@ public TagsEntity physicalInsert(TagsEntity entity) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_insert.sql"); Class type = PropertyUtil.getPropertyType(entity, "tagId"); Object key = executeInsert(sql, type, - entity.getTagId() - , entity.getTagName() + entity.getTagName() , entity.getInsertUser() , entity.getInsertDatetime() , entity.getUpdateUser() diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenViewHistoriesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenViewHistoriesDao.java index 65d3eca94..22bfb42ab 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenViewHistoriesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenViewHistoriesDao.java @@ -11,6 +11,8 @@ import org.support.project.ormapping.common.SQLManager; import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; +import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; import org.support.project.di.Container; @@ -41,28 +43,51 @@ public static GenViewHistoriesDao get() { */ public List physicalSelectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_physical_select_all.sql"); - return executeQuery(sql, ViewHistoriesEntity.class); + return executeQueryList(sql, ViewHistoriesEntity.class); } /** * キーで1件取得(削除フラグを無視して取得) */ public ViewHistoriesEntity physicalSelectOnKey(Long historyNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_physical_select_on_key.sql"); - return executeQueryOnKey(sql, ViewHistoriesEntity.class, historyNo); + return executeQuerySingle(sql, ViewHistoriesEntity.class, historyNo); } /** * 全て取得 */ public List selectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_select_all.sql"); - return executeQuery(sql, ViewHistoriesEntity.class); + return executeQueryList(sql, ViewHistoriesEntity.class); } /** * キーで1件取得 */ public ViewHistoriesEntity selectOnKey(Long historyNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_select_on_key.sql"); - return executeQueryOnKey(sql, ViewHistoriesEntity.class, historyNo); + return executeQuerySingle(sql, ViewHistoriesEntity.class, historyNo); + } + /** + * 登録(データを生で操作/DBの採番機能のカラムも自分でセット) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public ViewHistoriesEntity rawPhysicalInsert(ViewHistoriesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_raw_insert.sql"); + executeUpdate(sql, + entity.getHistoryNo() + , entity.getKnowledgeId() + , entity.getViewDateTime() + , entity.getInsertUser() + , entity.getInsertDatetime() + , entity.getUpdateUser() + , entity.getUpdateDatetime() + , entity.getDeleteFlag() + ); + String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); + if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { + String setValSql = "select setval('VIEW_HISTORIES_HISTORY_NO_seq', (select max(HISTORY_NO) from VIEW_HISTORIES));"; + executeQuerySingle(setValSql, Long.class); + } + return entity; } /** * 登録(データを生で操作) @@ -72,8 +97,7 @@ public ViewHistoriesEntity physicalInsert(ViewHistoriesEntity entity) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_insert.sql"); Class type = PropertyUtil.getPropertyType(entity, "historyNo"); Object key = executeInsert(sql, type, - entity.getHistoryNo() - , entity.getKnowledgeId() + entity.getKnowledgeId() , entity.getViewDateTime() , entity.getInsertUser() , entity.getInsertDatetime() diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenVotesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenVotesDao.java index 3d714f9dd..5077e8847 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenVotesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenVotesDao.java @@ -11,6 +11,8 @@ import org.support.project.ormapping.common.SQLManager; import org.support.project.ormapping.common.DBUserPool; import org.support.project.ormapping.common.IDGen; +import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.common.util.PropertyUtil; import org.support.project.di.Container; @@ -41,28 +43,51 @@ public static GenVotesDao get() { */ public List physicalSelectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_physical_select_all.sql"); - return executeQuery(sql, VotesEntity.class); + return executeQueryList(sql, VotesEntity.class); } /** * キーで1件取得(削除フラグを無視して取得) */ public VotesEntity physicalSelectOnKey(Long voteNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_physical_select_on_key.sql"); - return executeQueryOnKey(sql, VotesEntity.class, voteNo); + return executeQuerySingle(sql, VotesEntity.class, voteNo); } /** * 全て取得 */ public List selectAll() { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_select_all.sql"); - return executeQuery(sql, VotesEntity.class); + return executeQueryList(sql, VotesEntity.class); } /** * キーで1件取得 */ public VotesEntity selectOnKey(Long voteNo) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_select_on_key.sql"); - return executeQueryOnKey(sql, VotesEntity.class, voteNo); + return executeQuerySingle(sql, VotesEntity.class, voteNo); + } + /** + * 登録(データを生で操作/DBの採番機能のカラムも自分でセット) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public VotesEntity rawPhysicalInsert(VotesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_raw_insert.sql"); + executeUpdate(sql, + entity.getVoteNo() + , entity.getKnowledgeId() + , entity.getVoteKind() + , entity.getInsertUser() + , entity.getInsertDatetime() + , entity.getUpdateUser() + , entity.getUpdateDatetime() + , entity.getDeleteFlag() + ); + String driverClass = ConnectionManager.getInstance().getDriverClass(getConnectionName()); + if (ORMappingParameter.DRIVER_NAME_POSTGRESQL.equals(driverClass)) { + String setValSql = "select setval('VOTES_VOTE_NO_seq', (select max(VOTE_NO) from VOTES));"; + executeQuerySingle(setValSql, Long.class); + } + return entity; } /** * 登録(データを生で操作) @@ -72,8 +97,7 @@ public VotesEntity physicalInsert(VotesEntity entity) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_insert.sql"); Class type = PropertyUtil.getPropertyType(entity, "voteNo"); Object key = executeInsert(sql, type, - entity.getVoteNo() - , entity.getKnowledgeId() + entity.getKnowledgeId() , entity.getVoteKind() , entity.getInsertUser() , entity.getInsertDatetime() diff --git a/src/main/java/org/support/project/knowledge/deploy/InitializationListener.java b/src/main/java/org/support/project/knowledge/deploy/InitializationListener.java index 7601d4ab5..edffb311f 100644 --- a/src/main/java/org/support/project/knowledge/deploy/InitializationListener.java +++ b/src/main/java/org/support/project/knowledge/deploy/InitializationListener.java @@ -29,7 +29,7 @@ public void contextInitialized(ServletContextEvent contextEvent) { InitializationLogic.get().init(); // 添付ファイル格納ディレクトリ(テンポラリディレクトリ)が存在しなければ生成 - AppConfig appConfig = ConfigLoader.load(AppConfig.APP_CONFIG, AppConfig.class); + AppConfig appConfig = AppConfig.get(); String tmpDir = appConfig.getTmpPath(); File tmp = new File(tmpDir); if (!tmp.exists()) { @@ -42,7 +42,10 @@ public void contextInitialized(ServletContextEvent contextEvent) { idx.mkdirs(); LOG.info("idx directory created." + idxDir); } - LOG.info("Knowledge start on '" + contextEvent.getServletContext().getRealPath("/") + "'"); + String path = contextEvent.getServletContext().getRealPath("/"); + LOG.info("Knowledge start on '" + path + "'"); + LOG.info(path); + appConfig.setWebRealPath(path); } } diff --git a/src/main/java/org/support/project/knowledge/logic/DataTransferLogic.java b/src/main/java/org/support/project/knowledge/logic/DataTransferLogic.java new file mode 100644 index 000000000..99dba8960 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/DataTransferLogic.java @@ -0,0 +1,190 @@ +package org.support.project.knowledge.logic; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.lang.reflect.Method; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.support.project.common.classanalysis.ClassSearch; +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.di.Container; +import org.support.project.knowledge.deploy.InitDB; +import org.support.project.ormapping.config.ConnectionConfig; +import org.support.project.ormapping.connection.ConnectionManager; +import org.support.project.ormapping.dao.AbstractDao; +import org.support.project.ormapping.tool.dao.InitializeDao; +import org.support.project.ormapping.transaction.TransactionManager; +import org.support.project.web.config.AppConfig; + +public class DataTransferLogic { + private static final String TRANSFER_REQEST = "TRANSFER_REQEST"; + private static final String TRANSFER_STARTED = "TRANSFER_STARTED"; + + /** ログ */ + private static Log LOG = LogFactory.getLog(DataTransferLogic.class); + + public static DataTransferLogic get() { + return Container.getComp(DataTransferLogic.class); + } + + public void transferData(ConnectionConfig from, ConnectionConfig to) throws Exception { + InitDB initDB = new InitDB(); + ConnectionManager.getInstance().addConnectionConfig(to); + InitializeDao initializeDao = InitializeDao.get(); + initializeDao.setConnectionName(to.getName()); + initializeDao.dropAllTable(); + initDB.start(); + + ConnectionManager.getInstance().addConnectionConfig(from); + // コピー元も念のため、バージョンを合わせるために初期化を行う? +// initDB.start(); + + List targets = new ArrayList(); + ClassSearch classSearch = Container.getComp(ClassSearch.class); + Class[] classes = classSearch.classSearch("org.support.project.knowledge.dao.gen", false); + targets.addAll(Arrays.asList(classes)); + classes = classSearch.classSearch("org.support.project.web.dao.gen", false); + targets.addAll(Arrays.asList(classes)); + +// 削除してから、再登録する場合、H2SQLだと同じ番号になるが、Postgresqlだと次の番号になりNG +// //初期ロールと初期ユーザを削除 +// UserRolesDao userRolesDao = UserRolesDao.get(); +// userRolesDao.setConnectionName(to.getName()); +// List userRolesEntities = userRolesDao.physicalSelectAll(); +// for (UserRolesEntity userRolesEntity : userRolesEntities) { +// userRolesDao.physicalDelete(userRolesEntity); +// } +// UsersDao usersDao = UsersDao.get(); +// usersDao.setConnectionName(to.getName()); +// List usersEntities = usersDao.physicalSelectAll(); +// for (UsersEntity usersEntity : usersEntities) { +// usersDao.physicalDelete(usersEntity); +// } +// RolesDao rolesDao = RolesDao.get(); +// rolesDao.setConnectionName(to.getName()); +// List rolesEntities = rolesDao.physicalSelectAll(); +// for (RolesEntity rolesEntity : rolesEntities) { +// rolesDao.physicalDelete(rolesEntity); +// } +// SystemsDao systemsDao = SystemsDao.get(); +// systemsDao.setConnectionName(to.getName()); +// List systemsEntities = systemsDao.physicalSelectAll(); +// for (SystemsEntity systemsEntity : systemsEntities) { +// systemsDao.physicalDelete(systemsEntity); +// } + + // データコピー + for (Class class1 : targets) { + if (AbstractDao.class.isAssignableFrom(class1)) { + System.out.println("Data transfer : " + class1.getName()); + Object dao = Container.getComp(class1); + // From からデータ取得 + Method setConnectionNameMethods = class1.getMethod("setConnectionName", String.class); + setConnectionNameMethods.invoke(dao, from.getName()); + + Method selectAllMethods = class1.getMethod("physicalSelectAll"); + List list = (List) selectAllMethods.invoke(dao); + + // Toへデータ登録 + setConnectionNameMethods.invoke(dao, to.getName()); + TransactionManager transactionManager = Container.getComp(TransactionManager.class); + transactionManager.start(to.getName()); + for (Object entity : list) { + if (LOG.isTraceEnabled()) { + LOG.trace(entity); + } + Method insertMethods = class1.getMethod("rawPhysicalInsert", entity.getClass()); + try { + insertMethods.invoke(dao, entity); + } catch (Exception e) { + // 初期登録ユーザなどをコピーしようとすると、主キー制約違反になるが無視する + LOG.warn("Data copy error"); + } + } + transactionManager.commit(to.getName()); + } + } + + } + + + + /** + * データコピーのリクエストを登録 + * @throws IOException + */ + public void requestTransfer() throws IOException { + if (!isTransferRequested()) { + AppConfig appConfig = ConfigLoader.load(AppConfig.APP_CONFIG, AppConfig.class); + File base = new File(appConfig.getBasePath()); + File config = new File(base, TRANSFER_REQEST); + OutputStream out = null; + try { + out = new FileOutputStream(config); + out.write(new String("TRANSFER_REQEST").getBytes(Charset.forName("UTF-8"))); + } finally { + if (out != null) { + out.close(); + } + } + } + } + + /** + * コピーのリクエストがあるかチェック + * @return + */ + public boolean isTransferRequested() { + AppConfig appConfig = ConfigLoader.load(AppConfig.APP_CONFIG, AppConfig.class); + File base = new File(appConfig.getBasePath()); + File config = new File(base, TRANSFER_REQEST); + return config.exists(); + } + + /** + * 既に開始済かどうかチェックし、開始済でなければ開始済のフラグをON + * @return + * @throws IOException + */ + public boolean isTransferStarted() throws IOException { + AppConfig appConfig = ConfigLoader.load(AppConfig.APP_CONFIG, AppConfig.class); + File base = new File(appConfig.getBasePath()); + File config = new File(base, TRANSFER_STARTED); + if (!config.exists()) { + OutputStream out = null; + try { + out = new FileOutputStream(config); + out.write(new String("TRANSFER_STARTED").getBytes(Charset.forName("UTF-8"))); + } finally { + if (out != null) { + out.close(); + } + } + return false; + } + return true; + } + /** + * データ移行の終了 + */ + public void finishTransfer() { + AppConfig appConfig = ConfigLoader.load(AppConfig.APP_CONFIG, AppConfig.class); + File base = new File(appConfig.getBasePath()); + File config = new File(base, TRANSFER_STARTED); + if (config.exists()) { + config.delete(); + } + config = new File(base, TRANSFER_REQEST); + if (config.exists()) { + config.delete(); + } + } + +} diff --git a/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java b/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java index 5622617de..86de4a951 100644 --- a/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java @@ -53,6 +53,9 @@ public class KnowledgeLogic { public static final int TYPE_KNOWLEDGE = IndexType.knowledge.getValue(); public static final int TYPE_FILE = IndexType.KnowledgeFile.getValue(); + public static final int TYPE_COMMENT = IndexType.KnowledgeComment.getValue(); + + public static final String COMMENT_ID_PREFIX = "COMMENT-"; public static KnowledgeLogic get() { return Container.getComp(KnowledgeLogic.class); @@ -120,7 +123,7 @@ public KnowledgesEntity insert(KnowledgesEntity entity, List tags, L fileLogic.setKnowledgeFiles(entity, fileNos, loginedUser); // 全文検索エンジンへ登録 - saveIndex(entity, tags, targets, loginedUser); + saveIndex(entity, tags, targets, loginedUser.getUserId()); // 一覧表示用の情報を更新 updateKnowledgeExInfo(entity); @@ -159,7 +162,7 @@ public KnowledgesEntity update(KnowledgesEntity entity, List tags, L fileLogic.setKnowledgeFiles(entity, fileNos, loginedUser); // 全文検索エンジンへ登録 - saveIndex(entity, tags, targets, loginedUser); + saveIndex(entity, tags, targets, loginedUser.getUserId()); // 一覧表示用の情報を更新 updateKnowledgeExInfo(entity); @@ -238,13 +241,13 @@ private void saveAccessUser(KnowledgesEntity entity, LoginedUser loginedUser, Li * @param loginedUser * @throws Exception */ - private void saveIndex(KnowledgesEntity entity, List tags, List targets, LoginedUser loginedUser) throws Exception { + private void saveIndex(KnowledgesEntity entity, List tags, List targets, Integer creator) throws Exception { IndexingValue indexingValue = new IndexingValue(); indexingValue.setType(TYPE_KNOWLEDGE); indexingValue.setId(String.valueOf(entity.getKnowledgeId())); indexingValue.setTitle(entity.getTitle()); indexingValue.setContents(entity.getContent()); - indexingValue.addUser(loginedUser.getLoginUser().getUserId()); + indexingValue.addUser(creator); if (entity.getPublicFlag() == null || PUBLIC_FLAG_PUBLIC == entity.getPublicFlag()) { indexingValue.addUser(ALL_USER); } @@ -268,7 +271,7 @@ private void saveIndex(KnowledgesEntity entity, List tags, List getKnowledgeDatas(List list) { entity.setTitle(entity.getTitle()); StringBuilder builder = new StringBuilder(); - builder.append("[添付]"); + builder.append("[FILE] "); if (StringUtils.isNotEmpty(searchResultValue.getHighlightedTitle())) { builder.append(searchResultValue.getHighlightedTitle()); @@ -494,6 +497,23 @@ private List getKnowledgeDatas(List list) { entity.setContent(builder.toString()); knowledges.add(entity); } + } else if (searchResultValue.getType() == TYPE_COMMENT) { + // TODO 1件づつ処理しているので、パフォーマンスが悪いので後で処理を検討 + String id = searchResultValue.getId().substring(COMMENT_ID_PREFIX.length()); + Long commentNo = new Long(id); + CommentsEntity commentsEntity = CommentsDao.get().selectOnKey(commentNo); + if (commentsEntity != null && commentsEntity.getKnowledgeId() != null) { + KnowledgesEntity entity = knowledgesDao.selectOnKeyWithUserName(commentsEntity.getKnowledgeId()); + entity.setTitle(entity.getTitle()); + + StringBuilder builder = new StringBuilder(); + builder.append("[COMMENT] "); + if (StringUtils.isNotEmpty(searchResultValue.getHighlightedContents())) { + builder.append(searchResultValue.getHighlightedContents()); + } + entity.setContent(builder.toString()); + knowledges.add(entity); + } } } @@ -814,8 +834,9 @@ public void updateKnowledgeExInfo(KnowledgesEntity entity) { * コメント保存 * @param knowledgeId * @param comment + * @throws Exception */ - public void saveComment(Long knowledgeId, String comment) { + public void saveComment(Long knowledgeId, String comment) throws Exception { CommentsDao commentsDao = CommentsDao.get(); CommentsEntity commentsEntity = new CommentsEntity(); commentsEntity.setKnowledgeId(knowledgeId); @@ -824,8 +845,80 @@ public void saveComment(Long knowledgeId, String comment) { // 一覧表示用の情報を更新 KnowledgeLogic.get().updateKnowledgeExInfo(knowledgeId); + // 検索エンジンに追加 + addIndexOnComment(commentsEntity); + // 通知(TODO 別スレッド化を検討) NotifyLogic.get().notifyOnKnowledgeComment(knowledgeId, commentsEntity); } + + + /** + * コメントを全文検索エンジンへ登録 + * @param commentsEntity + * @throws Exception + */ + public void addIndexOnComment(CommentsEntity commentsEntity) throws Exception { + KnowledgesDao knowledgesDao = KnowledgesDao.get(); + KnowledgesEntity entity = knowledgesDao.selectOnKey(commentsEntity.getKnowledgeId()); + + IndexingValue indexingValue = new IndexingValue(); + indexingValue.setType(TYPE_COMMENT); + indexingValue.setId(COMMENT_ID_PREFIX + String.valueOf(commentsEntity.getCommentNo())); + indexingValue.setTitle(""); + indexingValue.setContents(commentsEntity.getComment()); + indexingValue.addUser(entity.getInsertUser()); + if (entity.getPublicFlag() == null || PUBLIC_FLAG_PUBLIC == entity.getPublicFlag()) { + indexingValue.addUser(ALL_USER); + } + + List tags = TagsDao.get().selectOnKnowledgeId(commentsEntity.getKnowledgeId()); + if (tags != null) { + for (TagsEntity tagsEntity : tags) { + indexingValue.addTag(tagsEntity.getTagId()); + } + } + if (entity.getPublicFlag() != null && entity.getPublicFlag().intValue() == PUBLIC_FLAG_PROTECT) { + TargetLogic targetLogic = TargetLogic.get(); + List targets = targetLogic.selectTargetsOnKnowledgeId(commentsEntity.getKnowledgeId()); + if (targets != null) { + for (LabelValue target : targets) { + Integer id = TargetLogic.get().getGroupId(target.getValue()); + if (id != Integer.MIN_VALUE) { + indexingValue.addGroup(id); + } + id = TargetLogic.get().getUserId(target.getValue()); + if (id != Integer.MIN_VALUE) { + indexingValue.addUser(id); + } + } + } + } + indexingValue.setCreator(commentsEntity.getInsertUser()); + indexingValue.setTime(commentsEntity.getUpdateDatetime().getTime()); // 更新日時をセットするので、更新日時でソート + + IndexLogic.get().save(indexingValue); //全文検索のエンジンにも保存(DBに保存する意味ないかも) + } + + public void reindexing(KnowledgesEntity knowledgesEntity) throws Exception { + // ナレッジの情報を検索エンジンへ更新 + List tags = tagsDao.selectOnKnowledgeId(knowledgesEntity.getKnowledgeId()); + List targets = TargetLogic.get().selectTargetsOnKnowledgeId(knowledgesEntity.getKnowledgeId()); + saveIndex(knowledgesEntity, tags, targets, knowledgesEntity.getInsertUser()); + + // コメントを検索エンジンへ + List comments = CommentsDao.get().selectOnKnowledgeId(knowledgesEntity.getKnowledgeId()); + for (CommentsEntity commentsEntity : comments) { + addIndexOnComment(commentsEntity); + } + + //添付ファイルを検索エンジンへ + KnowledgeFilesDao filesDao = KnowledgeFilesDao.get(); + List filesEntities = filesDao.selectOnKnowledgeId(knowledgesEntity.getKnowledgeId()); + for (KnowledgeFilesEntity knowledgeFilesEntity : filesEntities) { + //添付ファイルのパースは、パースバッチに任せる(ステータスをパース待ちにしておけばバッチが処理する) + filesDao.changeStatus(knowledgeFilesEntity.getFileNo(), FileParseBat.PARSE_STATUS_WAIT, FileParseBat.UPDATE_USER_ID); + } + } } diff --git a/src/main/java/org/support/project/knowledge/websocket/DataTransferEndpoint.java b/src/main/java/org/support/project/knowledge/websocket/DataTransferEndpoint.java new file mode 100644 index 000000000..67d48d8e7 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/websocket/DataTransferEndpoint.java @@ -0,0 +1,114 @@ +package org.support.project.knowledge.websocket; + +import java.io.File; +import java.io.IOException; + +import javax.websocket.OnClose; +import javax.websocket.OnError; +import javax.websocket.OnMessage; +import javax.websocket.OnOpen; +import javax.websocket.Session; +import javax.websocket.server.ServerEndpoint; + +import net.arnx.jsonic.JSON; +import net.arnx.jsonic.JSONException; + +import org.support.project.common.bat.AsyncJavaJob; +import org.support.project.common.bat.BatListener; +import org.support.project.common.bat.ConsoleListener; +import org.support.project.common.bat.JobResult; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.knowledge.bat.DataTransferBat; +import org.support.project.knowledge.config.AppConfig; +import org.support.project.ormapping.config.ConnectionConfig; +import org.support.project.ormapping.connection.ConnectionManager; +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.bean.MessageResult; +import org.support.project.web.logic.DBConnenctionLogic; + +@ServerEndpoint(value = "/data_transfer", configurator=NotifyEndpointConfigurator.class) +public class DataTransferEndpoint { + + /** ログ */ + private static Log LOG = LogFactory.getLog(DataTransferEndpoint.class); + + private Thread thread; + + @OnOpen + public void onOpen(Session session) throws IOException { + if (session.getUserProperties().containsKey(NotifyEndpointConfigurator.LOCALE_KEY)) { + LoginedUser loginuser = (LoginedUser) session.getUserProperties().get(NotifyEndpointConfigurator.LOGIN_USER_KEY); + if (!loginuser.isAdmin()) { + // 管理者以外はアクセス出来ない + session.close(); + return; + } + + // データ移行開始 + LOG.info("websocket open: " + session.getId() + " : " + loginuser.getUserId()); + + // データ移行するまで、コネクションを切る + ConnectionConfig connectionConfig = DBConnenctionLogic.get().getCustomConnectionConfig(); + ConnectionManager.getInstance().removeConnectionConfig(connectionConfig); //新しいコネクション設定をいったん解除(データ移行中) + + // データ移行バッチプログラム実行 + AppConfig appConfig = AppConfig.get(); + + LOG.info(appConfig.getWebRealPath()); + + AsyncJavaJob job = new AsyncJavaJob(); + job.addjarDir(new File(appConfig.getWebRealPath().concat("/WEB-INF/lib/"))); + job.addClassPathDir(new File(appConfig.getWebRealPath().concat("/WEB-INF/classes/"))); + job.setMainClass(DataTransferBat.class.getName()); + job.setConsoleListener(new ConsoleListener() { + @Override + public void write(String message) { + LOG.info(message); + try { + MessageResult result = new MessageResult(); + //result.setMessage(message); + result.setMessage("*"); + session.getBasicRemote().sendText(JSON.encode(result)); + } catch (JSONException | IOException e) { + LOG.warn("websocket message send error", e); + } + } + }); + + job.addListener(new BatListener() { + @Override + public void finish(JobResult result) { + ConnectionManager.getInstance().addConnectionConfig(connectionConfig); //新しいコネクション設定をセット + MessageResult message = new MessageResult(); + message.setMessage("Data Transfer is ended. [status]" + result.getResultCode()); + try { + session.getBasicRemote().sendText(JSON.encode(message)); + session.close(); + } catch (JSONException | IOException e) { + LOG.warn("websocket message send error", e); + } + } + }); + + thread = new Thread(job); + thread.start(); + } + } + + @OnClose + public void onClose(Session session) { + } + + @OnMessage + public void onMessage(String text) throws JSONException, IOException { + } + + @OnError + public void onError(Throwable t) { + LOG.warn("websocket on error." + t.getClass().getName() + " : " + t.getMessage()); + if (LOG.isDebugEnabled()) { + LOG.warn("websocket error -> ", t); + } + } +} diff --git a/src/main/java/org/support/project/knowledge/websocket/NotifyEndpoint.java b/src/main/java/org/support/project/knowledge/websocket/NotifyEndpoint.java index 85067eb2e..5d892074d 100644 --- a/src/main/java/org/support/project/knowledge/websocket/NotifyEndpoint.java +++ b/src/main/java/org/support/project/knowledge/websocket/NotifyEndpoint.java @@ -7,6 +7,7 @@ import java.util.Map; import javax.websocket.OnClose; +import javax.websocket.OnError; import javax.websocket.OnMessage; import javax.websocket.OnOpen; import javax.websocket.Session; @@ -76,4 +77,14 @@ public void onMessage(String text) throws JSONException, IOException { // notify.notifyObservers(message); } + @OnError + public void onError(Throwable t) { + LOG.warn("websocket on error." + t.getClass().getName() + " : " + t.getMessage()); + if (LOG.isDebugEnabled()) { + LOG.warn("websocket error -> ", t); + } + } + + + } diff --git a/src/main/java/org/support/project/knowledge/websocket/ReindexingEndpoint.java b/src/main/java/org/support/project/knowledge/websocket/ReindexingEndpoint.java new file mode 100644 index 000000000..55804b212 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/websocket/ReindexingEndpoint.java @@ -0,0 +1,105 @@ +package org.support.project.knowledge.websocket; + +import java.io.File; +import java.io.IOException; + +import javax.websocket.OnClose; +import javax.websocket.OnError; +import javax.websocket.OnMessage; +import javax.websocket.OnOpen; +import javax.websocket.Session; +import javax.websocket.server.ServerEndpoint; + +import net.arnx.jsonic.JSON; +import net.arnx.jsonic.JSONException; + +import org.support.project.common.bat.AsyncJavaJob; +import org.support.project.common.bat.BatListener; +import org.support.project.common.bat.ConsoleListener; +import org.support.project.common.bat.JobResult; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.knowledge.bat.ReIndexingBat; +import org.support.project.knowledge.config.AppConfig; +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.bean.MessageResult; + +@ServerEndpoint(value = "/reindexing", configurator=NotifyEndpointConfigurator.class) +public class ReindexingEndpoint { + /** ログ */ + private static Log LOG = LogFactory.getLog(DataTransferEndpoint.class); + + private Thread thread; + + @OnOpen + public void onOpen(Session session) throws IOException { + if (session.getUserProperties().containsKey(NotifyEndpointConfigurator.LOCALE_KEY)) { + LoginedUser loginuser = (LoginedUser) session.getUserProperties().get(NotifyEndpointConfigurator.LOGIN_USER_KEY); + if (!loginuser.isAdmin()) { + // 管理者以外はアクセス出来ない + session.close(); + return; + } + // インデックス再作成 + LOG.info("websocket open: " + session.getId() + " : " + loginuser.getUserId()); + + // バッチプログラム実行 + AppConfig appConfig = AppConfig.get(); + + LOG.info(appConfig.getWebRealPath()); + + AsyncJavaJob job = new AsyncJavaJob(); + job.addjarDir(new File(appConfig.getWebRealPath().concat("/WEB-INF/lib/"))); + job.addClassPathDir(new File(appConfig.getWebRealPath().concat("/WEB-INF/classes/"))); + job.setMainClass(ReIndexingBat.class.getName()); + job.setConsoleListener(new ConsoleListener() { + @Override + public void write(String message) { + LOG.info(message); + try { + if (message.startsWith("[SEND]")) { + MessageResult result = new MessageResult(); + result.setMessage(message.substring("[SEND]".length())); + session.getBasicRemote().sendText(JSON.encode(result)); + } + } catch (JSONException | IOException e) { + LOG.warn("websocket message send error", e); + } + } + }); + + job.addListener(new BatListener() { + @Override + public void finish(JobResult result) { + MessageResult message = new MessageResult(); + message.setMessage("Reindexing is ended. [status]" + result.getResultCode()); + try { + session.getBasicRemote().sendText(JSON.encode(message)); + session.close(); + } catch (JSONException | IOException e) { + LOG.warn("websocket message send error", e); + } + } + }); + + thread = new Thread(job); + thread.start(); + } + } + + @OnClose + public void onClose(Session session) { + } + + @OnMessage + public void onMessage(String text) throws JSONException, IOException { + } + + @OnError + public void onError(Throwable t) { + LOG.warn("websocket on error." + t.getClass().getName() + " : " + t.getMessage()); + if (LOG.isDebugEnabled()) { + LOG.warn("websocket error -> ", t); + } + } +} diff --git a/src/main/resources/appconfig.xml b/src/main/resources/appconfig.xml index d129ba574..bfe4b1d1c 100644 --- a/src/main/resources/appconfig.xml +++ b/src/main/resources/appconfig.xml @@ -1,9 +1,10 @@ Asia/Tokyo - {user.home}/.knowledge/index/ - {user.home}/.knowledge/tmp/ - {user.home}/.knowledge/db/ + {user.home}/.knowledge + {base.path}/index/ + {base.path}/tmp/ + {base.path}/db/ 500 100 diff --git a/src/main/resources/appresource.properties b/src/main/resources/appresource.properties index 05ad916b5..d9809a71d 100644 --- a/src/main/resources/appresource.properties +++ b/src/main/resources/appresource.properties @@ -49,6 +49,7 @@ message.success.accept.target={1} was Accepted. message.success.save.target={1} was Saved. message.allready.updated=Allready updated. +message.allready.started=\u3059\u3067\u306b\u958b\u59cb\u6e08\u3067\u3059 # Common Label label.version=0.5.0 @@ -83,6 +84,9 @@ label.upload=Upload label.backup=Backup label.restore=Restore label.back=Back +label.start=\u958b\u59cb +label.end=\u7d42\u4e86 +label.stop=\u505c\u6b62 label.public.view= [Public] label.protect.view= [Protection] @@ -119,6 +123,8 @@ knowledge.navbar.menu.knowledge.add=Add Knowledge knowledge.navbar.tag=Tag knowledge.navbar.data=Data knowledge.navbar.data.backup=Backup & Restore +knowledge.navbar.data.connect=\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u63a5\u7d9a\u5148\u5909\u66f4 +knowledge.navbar.data.reindexing=\u691c\u7d22\u7528\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u518d\u69cb\u7bc9 knowledge.auth.description=Prompts for sign-in is required functions.
(Such as knowledge of editing is required sign-in) knowledge.auth.signin=Sign In @@ -304,6 +310,7 @@ knowledge.data.label.backup.msg=Download the service of data, you can back up da knowledge.data.label.restore=Restoration (data upload) knowledge.data.label.restore.msg=You will restore the data from the data of the local PC knowledge.data.label.restore.msg.danger=When you run the restore will overwrite the server's data. For this reason, there is a possibility that the current data disappears. +knowledge.data.label.restore.msg.info=\u3053\u306e\u30da\u30fc\u30b8\u3067\u7ba1\u7406\u3057\u3066\u3044\u308b\u30c7\u30fc\u30bf\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304c\u5bfe\u8c61\u306b\u306a\u308a\u307e\u3059\u3002\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u63a5\u7d9a\u5148\u5909\u66f4\u3067\u30c7\u30fc\u30bf\u306e\u683c\u7d0d\u5148\u3092\u5909\u66f4\u3057\u3066\u3044\u308b\u5834\u5408\u3001\u5bfe\u8c61\u306b\u306a\u308a\u307e\u305b\u3093\u3002\u305d\u306e\u5834\u5408\u3001\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u306a\u3069\u306e\u7ba1\u7406\u306f\u5229\u7528\u74b0\u5883\u306b\u5408\u308f\u305b\u3066\u3054\u81ea\u8eab\u3067\u5b9f\u65bd\u3057\u3066\u304f\u3060\u3055\u3044\u3002 knowledge.data.label.active=database server status knowledge.data.label.active.msg=You can change the operating status of the database server. And when you want to back up and restore, please stop the database before shutting down the service. knowledge.data.label.active.msg2=\u203bPlease refer to the stop when you shut down in the case of use in Docker. @@ -319,6 +326,29 @@ knowledge.data.label.msg.empty=No files to be restored is not specified knowledge.data.label.msg.invalid.file=I did not recognize that the file you want to restore is a file that was backed up. Do not specify a different file? knowledge.data.label.msg.fail=I failed to restore. Please try again. knowledge.data.label.msg.before.stop=Please stop the database before restoration +knowledge.connection.label.driverClass=driverClass +knowledge.connection.label.URL=URL +knowledge.connection.label.user=user +knowledge.connection.label.password=password +knowledge.connection.label.schema=schema +knowledge.connection.label.maxConn=max connection +knowledge.connection.label.autocommit=auto commit +knowledge.connection.label.custom=\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u5148\u8a2d\u5b9a +knowledge.connection.label.transfer=\u7d44\u307f\u8fbc\u307fDB\u3067\u4fdd\u5b58\u3057\u3066\u3044\u305f\u30c7\u30fc\u30bf\u3092\u30ab\u30b9\u30bf\u30e0\u8a2d\u5b9a\u306eDB\u306b\u30b3\u30d4\u30fc +knowledge.connection.msg.custom.enable=\u73fe\u5728\u3001\u30ab\u30b9\u30bf\u30e0\u8a2d\u5b9a\u304c\u6709\u52b9\u306b\u306a\u3063\u3066\u3044\u307e\u3059 +knowledge.connection.msg.custom.disable=\u30ab\u30b9\u30bf\u30e0\u8a2d\u5b9a\u306f\u5b58\u5728\u3057\u306a\u3044\u305f\u3081\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u7d44\u307f\u8fbc\u307fDB\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059 +knowledge.connection.msg.custom.transfer=\u30ab\u30b9\u30bf\u30e0DB\u3078\u30c7\u30fc\u30bf\u306e\u30b3\u30d4\u30fc\u4e2d\u3067\u3059\u3002\u5b8c\u4e86\u3059\u308b\u307e\u3067\u3057\u3070\u3089\u304f\u304a\u307e\u3061\u304f\u3060\u3055\u3044\u3002 +knowledge.connection.msg.custom.transfer.request=\u30ab\u30b9\u30bf\u30e0DB\u3078\u30c7\u30fc\u30bf\u306e\u30b3\u30d4\u30fc\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u53d7\u3051\u4ed8\u3051\u307e\u3057\u305f +knowledge.reindexing.title=\u691c\u7d22\u7528\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u518d\u4f5c\u6210 +knowledge.reindexing.msg1=Knowledge\u3067\u306f\u3001\u30c7\u30fc\u30bf\u4fdd\u5b58\u7528\u306eDatabase\u306e\u4ed6\u306b\u3001\u691c\u7d22\u7528\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\uff08Lucene\uff09\u3092\u6301\u3063\u3066\u3044\u307e\u3059\u3002 +knowledge.reindexing.msg2=\u672c\u753b\u9762\u3067\u306f\u3001\u305d\u306e\u691c\u7d22\u7528\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u518d\u4f5c\u6210\u3057\u307e\u3059\u3002 +knowledge.reindexing.msg3=\u30d0\u30fc\u30b8\u30e7\u30f3 0.5.1\u304b\u3089\u3001\u30b3\u30e1\u30f3\u30c8\u3067\u3082\u691c\u7d22\u51fa\u6765\u308b\u3088\u3046\u306b\u6a5f\u80fd\u4fee\u6b63\u3057\u307e\u3057\u305f\u304c\u3001\u4eca\u307e\u3067\u767b\u9332\u3055\u308c\u305f\u904e\u53bb\u306e\u30b3\u30e1\u30f3\u30c8\u30c7\u30fc\u30bf\u304c\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u5165\u3063\u3066\u3044\u306a\u3044\u305f\u3081\u3001\u691c\u7d22\u7d50\u679c\u306b\u5165\u308a\u307e\u305b\u3093\u3002 +knowledge.reindexing.msg4=\u307e\u305f\u3001DB\u3092\u30c0\u30f3\u30d7\u304b\u3089\u5fa9\u5143\u3057\u305f\u3088\u3046\u306a\u5834\u5408\u3082\u3001\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u307e\u3067\u5fa9\u5143\u3059\u308b\u308f\u3051\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002 +knowledge.reindexing.msg5=\u305d\u306e\u3088\u3046\u306a\u5834\u5408\u306b\u3001\u672c\u753b\u9762\u306e\u6a5f\u80fd\u3092\u4f7f\u3044\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u518d\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002 +knowledge.reindexing.label.start=\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u4f5c\u6210\u3059\u308b\u30ca\u30ec\u30c3\u30b8\u306e\u756a\u53f7\uff08\u958b\u59cb\uff09 +knowledge.reindexing.label.end=\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u4f5c\u6210\u3059\u308b\u30ca\u30ec\u30c3\u30b8\u306e\u756a\u53f7\uff08\u7d42\u4e86\uff09 +knowledge.reindexing.msg.start=\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u518d\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059\u3002\uff08\u3053\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u304d\u3048\u308b\u307e\u3067\u3001\u304a\u5f85\u3061\u304f\u3060\u3055\u3044\uff09 +knowledge.reindexing.msg.end=\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u518d\u4f5c\u6210\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3002 knowledge.notify.title=Notify Config knowledge.notify.msg=Please set the notification of when the post state has changed diff --git a/src/main/resources/appresource_ja.properties b/src/main/resources/appresource_ja.properties index c1be2b81e..b358fe528 100644 --- a/src/main/resources/appresource_ja.properties +++ b/src/main/resources/appresource_ja.properties @@ -49,6 +49,7 @@ message.success.accept.target={1} \u3092\u627f\u8a8d\u3057\u307e\u3057\u305f\u30 message.success.save.target={1} \u4fdd\u5b58\u3057\u307e\u3057\u305f\u3002 message.allready.updated=\u3059\u3067\u306b\u66f4\u65b0\u3055\u308c\u3066\u3044\u307e\u3059 +message.allready.started=\u3059\u3067\u306b\u958b\u59cb\u6e08\u3067\u3059 # Common Label label.version=0.5.0 @@ -83,6 +84,9 @@ label.upload=\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9 label.backup=\u30d0\u30c3\u30af\u30a2\u30c3\u30d7 label.restore=\u5fa9\u5143 label.back=\u623b\u308b +label.start=\u958b\u59cb +label.end=\u7d42\u4e86 +label.stop=\u505c\u6b62 label.public.view= [\u516c\u958b] label.protect.view= [\u4fdd\u8b77] @@ -119,6 +123,8 @@ knowledge.navbar.menu.knowledge.add=\u30ca\u30ec\u30c3\u30b8\u767b\u9332 knowledge.navbar.tag=\u30bf\u30b0 knowledge.navbar.data=\u30c7\u30fc\u30bf\u7ba1\u7406 knowledge.navbar.data.backup=\u30c7\u30fc\u30bf\u306e\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3068\u5fa9\u5143 +knowledge.navbar.data.connect=\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u63a5\u7d9a\u5148\u5909\u66f4 +knowledge.navbar.data.reindexing=\u691c\u7d22\u7528\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u518d\u69cb\u7bc9 knowledge.auth.description=\u30b5\u30a4\u30f3\u30a4\u30f3\u304c\u5fc5\u8981\u306a\u6a5f\u80fd\u3067\u3059\u3002
(\u30ca\u30ec\u30c3\u30b8\u306e\u7de8\u96c6\u306a\u3069\u306f\u30b5\u30a4\u30f3\u30a4\u30f3\u304c\u5fc5\u8981\u3067\u3059) knowledge.auth.signin=\u30b5\u30a4\u30f3\u30a4\u30f3\u5b9f\u884c @@ -138,14 +144,14 @@ knowledge.auth.msg.changed=\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u521d\u671f\u531 knowledge.auth.label.back.top=Top\u3078\u623b\u308b knowledge.top.description=Knowledge\u306f\u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9\u306e\u30d5\u30ea\u30fc\u306a\u60c5\u5831\u5171\u6709\u30b5\u30fc\u30d3\u30b9\u3067\u3059 -knowledge.top.use.button=\u60c5\u5831\u3092\u898b\u308b +knowledge.top.use.button=Show knowledges knowledge.top.features.title=#### \u7279\u5fb4 knowledge.top.features.1=- Markdown\u8a18\u6cd5\u3067\u60c5\u5831\u767b\u9332 -knowledge.top.features.2=- \u8a18\u4e8b\u306e\u30bf\u30a4\u30c8\u30eb/\u672c\u6587\u3092\u5168\u6587\u691c\u7d22\u3067\u76ee\u7684\u306e\u60c5\u5831\u3092\u63a2\u305b\u307e\u3059 -knowledge.top.features.3=- \u60c5\u5831\u306e\u516c\u958b\u7bc4\u56f2\u3092\u67d4\u8edf\u306b\u6307\u5b9a\u3067\u304d\u307e\u3059 +knowledge.top.features.2=- \u691c\u7d22\u3067\u76ee\u7684\u306e\u60c5\u5831\u3092\u63a2\u305b\u307e\u3059 +knowledge.top.features.3=- \u60c5\u5831\u306e\u516c\u958b\u7bc4\u56f2\u3092[\u81ea\u5206\u3060\u3051\u3001\u30c1\u30fc\u30e0\u3001\u5168\u3066\u306e\u4eba]\u3068\u67d4\u8edf\u306b\u6307\u5b9a\u3067\u304d\u307e\u3059 knowledge.top.features.4=- \u60c5\u5831\u306b\u4ed8\u3051\u305f\u30bf\u30b0\u3067\u3001\u60c5\u5831\u306e\u7a2e\u5225\u306e\u7ba1\u7406\u3092\u884c\u3048\u307e\u3059 -knowledge.top.features.5=- \u6dfb\u4ed8\u30d5\u30a1\u30a4\u30eb\u3092\u767b\u9332\u3067\u304d\u307e\u3059 -knowledge.top.features.6=- \u6dfb\u4ed8\u30d5\u30a1\u30a4\u30eb\u306e\u4e2d\u8eab\u3067\u3082\u691c\u7d22\u3067\u304d\u307e\u3059 +knowledge.top.features.5=- \u6dfb\u4ed8\u30d5\u30a1\u30a4\u30eb\u3092\u767b\u9332\u3067\u304d\u3001\u4e2d\u8eab\u306b\u66f8\u304b\u308c\u305f\u5185\u5bb9\u3067\u3082\u691c\u7d22\u51fa\u6765\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059 +knowledge.top.features.6=- \u6295\u7a3f\u304c\u3042\u3063\u305f\u5834\u5408\u306b\u901a\u77e5\u3092\u9001\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059 knowledge.list.title= \u30ca\u30ec\u30c3\u30b8\u4e00\u89a7 knowledge.list.empty=\u6761\u4ef6\u306b\u8a72\u5f53\u3059\u308b\u60c5\u5831\u306f\u5b58\u5728\u3057\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u6761\u4ef6\uff08\u691c\u7d22\u30ad\u30fc\u30ef\u30fc\u30c9\u3001\u30bf\u30b0\u3001\u30da\u30fc\u30b8\u304d\u308a\u304b\u3048\uff09\u306e\u5909\u66f4\u3092\u304a\u8a66\u3057\u304f\u3060\u3055\u3044\u3002 @@ -304,6 +310,7 @@ knowledge.data.label.backup.msg=\u30b5\u30fc\u30d3\u30b9\u306e\u30c7\u30fc\u30bf knowledge.data.label.restore=\u5fa9\u5143\uff08\u30c7\u30fc\u30bf\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\uff09 knowledge.data.label.restore.msg=\u30ed\u30fc\u30ab\u30ebPC\u306e\u30c7\u30fc\u30bf\u304b\u3089\u30c7\u30fc\u30bf\u3092\u5fa9\u5143\u3057\u307e\u3059 knowledge.data.label.restore.msg.danger=\u5fa9\u5143\u3092\u5b9f\u884c\u3059\u308b\u3068\u30b5\u30fc\u30d0\u30fc\u306e\u30c7\u30fc\u30bf\u3092\u4e0a\u66f8\u304d\u3057\u307e\u3059\u3002\u3053\u306e\u305f\u3081\u3001\u73fe\u5728\u306e\u30c7\u30fc\u30bf\u304c\u6d88\u3048\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002 +knowledge.data.label.restore.msg.info=\u3053\u306e\u30da\u30fc\u30b8\u3067\u7ba1\u7406\u3057\u3066\u3044\u308b\u30c7\u30fc\u30bf\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304c\u5bfe\u8c61\u306b\u306a\u308a\u307e\u3059\u3002\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u63a5\u7d9a\u5148\u5909\u66f4\u3067\u30c7\u30fc\u30bf\u306e\u683c\u7d0d\u5148\u3092\u5909\u66f4\u3057\u3066\u3044\u308b\u5834\u5408\u3001\u5bfe\u8c61\u306b\u306a\u308a\u307e\u305b\u3093\u3002\u305d\u306e\u5834\u5408\u3001\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u306a\u3069\u306e\u7ba1\u7406\u306f\u5229\u7528\u74b0\u5883\u306b\u5408\u308f\u305b\u3066\u3054\u81ea\u8eab\u3067\u5b9f\u65bd\u3057\u3066\u304f\u3060\u3055\u3044\u3002 knowledge.data.label.active=\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30b5\u30fc\u30d0\u30fc\u306e\u7a3c\u50cd\u72b6\u614b knowledge.data.label.active.msg=\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30b5\u30fc\u30d0\u30fc\u306e\u7a3c\u52d5\u72b6\u614b\u3092\u5909\u66f4\u3067\u304d\u307e\u3059\u3002
\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3084\u5fa9\u5143\u3059\u308b\u969b\u3084\u3001\u30b5\u30fc\u30d3\u30b9\u3092\u30b7\u30e3\u30c3\u30c8\u30c0\u30a6\u30f3\u3059\u308b\u524d\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u505c\u6b62\u3057\u3066\u304f\u3060\u3055\u3044\u3002 knowledge.data.label.active.msg2=\u203bDocker\u3067\u5229\u7528\u306e\u5834\u5408\u306f\u30b7\u30e3\u30c3\u30c8\u30c0\u30a6\u30f3\u3059\u308b\u969b\u306b\u505c\u6b62\u3092\u3057\u3066\u304f\u3060\u3055\u3044\u3002 @@ -319,6 +326,29 @@ knowledge.data.label.msg.empty=\u5fa9\u5143\u3059\u308b\u30d5\u30a1\u30a4\u30eb\ knowledge.data.label.msg.invalid.file=\u5fa9\u5143\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u304c\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3067\u3042\u308b\u3053\u3068\u3092\u8a8d\u8b58\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u5225\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u305b\u3093\u304b\uff1f knowledge.data.label.msg.fail=\u5fa9\u5143\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002\u518d\u5ea6\u304a\u8a66\u3057\u304f\u3060\u3055\u3044\u3002 knowledge.data.label.msg.before.stop=\u5fa9\u5143\u306e\u524d\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u505c\u6b62\u3057\u3066\u304f\u3060\u3055\u3044 +knowledge.connection.label.driverClass=driverClass +knowledge.connection.label.URL=URL +knowledge.connection.label.user=user +knowledge.connection.label.password=password +knowledge.connection.label.schema=schema +knowledge.connection.label.maxConn=max connection +knowledge.connection.label.autocommit=auto commit +knowledge.connection.label.custom=\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u5148\u8a2d\u5b9a +knowledge.connection.label.transfer=\u7d44\u307f\u8fbc\u307fDB\u3067\u4fdd\u5b58\u3057\u3066\u3044\u305f\u30c7\u30fc\u30bf\u3092\u30ab\u30b9\u30bf\u30e0\u8a2d\u5b9a\u306eDB\u306b\u30b3\u30d4\u30fc +knowledge.connection.msg.custom.enable=\u73fe\u5728\u3001\u30ab\u30b9\u30bf\u30e0\u8a2d\u5b9a\u304c\u6709\u52b9\u306b\u306a\u3063\u3066\u3044\u307e\u3059 +knowledge.connection.msg.custom.disable=\u30ab\u30b9\u30bf\u30e0\u8a2d\u5b9a\u306f\u5b58\u5728\u3057\u306a\u3044\u305f\u3081\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u7d44\u307f\u8fbc\u307fDB\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059 +knowledge.connection.msg.custom.transfer=\u30ab\u30b9\u30bf\u30e0DB\u3078\u30c7\u30fc\u30bf\u306e\u30b3\u30d4\u30fc\u4e2d\u3067\u3059\u3002\u5b8c\u4e86\u3059\u308b\u307e\u3067\u3057\u3070\u3089\u304f\u304a\u307e\u3061\u304f\u3060\u3055\u3044\u3002\uff08\u3053\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u304d\u3048\u308b\u307e\u3067\u3001\u64cd\u4f5c\u3057\u306a\u3044\u3067\u304f\u3060\u3055\u3044\uff09 +knowledge.connection.msg.custom.transfer.request=\u30ab\u30b9\u30bf\u30e0DB\u3078\u30c7\u30fc\u30bf\u306e\u30b3\u30d4\u30fc\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u53d7\u3051\u4ed8\u3051\u307e\u3057\u305f +knowledge.reindexing.title=\u691c\u7d22\u7528\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u518d\u4f5c\u6210 +knowledge.reindexing.msg1=Knowledge\u3067\u306f\u3001\u30c7\u30fc\u30bf\u4fdd\u5b58\u7528\u306eDatabase\u306e\u4ed6\u306b\u3001\u691c\u7d22\u7528\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\uff08Lucene\uff09\u3092\u6301\u3063\u3066\u3044\u307e\u3059\u3002 +knowledge.reindexing.msg2=\u672c\u753b\u9762\u3067\u306f\u3001\u305d\u306e\u691c\u7d22\u7528\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u518d\u4f5c\u6210\u3057\u307e\u3059\u3002 +knowledge.reindexing.msg3=\u30d0\u30fc\u30b8\u30e7\u30f3 0.5.1\u304b\u3089\u3001\u30b3\u30e1\u30f3\u30c8\u3067\u3082\u691c\u7d22\u51fa\u6765\u308b\u3088\u3046\u306b\u6a5f\u80fd\u4fee\u6b63\u3057\u307e\u3057\u305f\u304c\u3001\u4eca\u307e\u3067\u767b\u9332\u3055\u308c\u305f\u904e\u53bb\u306e\u30b3\u30e1\u30f3\u30c8\u30c7\u30fc\u30bf\u304c\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u5165\u3063\u3066\u3044\u306a\u3044\u305f\u3081\u3001\u691c\u7d22\u7d50\u679c\u306b\u5165\u308a\u307e\u305b\u3093\u3002 +knowledge.reindexing.msg4=\u307e\u305f\u3001DB\u3092\u30c0\u30f3\u30d7\u304b\u3089\u5fa9\u5143\u3057\u305f\u3088\u3046\u306a\u5834\u5408\u3082\u3001\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u307e\u3067\u5fa9\u5143\u3059\u308b\u308f\u3051\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002 +knowledge.reindexing.msg5=\u305d\u306e\u3088\u3046\u306a\u5834\u5408\u306b\u3001\u672c\u753b\u9762\u306e\u6a5f\u80fd\u3092\u4f7f\u3044\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u518d\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002 +knowledge.reindexing.label.start=\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u4f5c\u6210\u3059\u308b\u30ca\u30ec\u30c3\u30b8\u306e\u756a\u53f7\uff08\u958b\u59cb\uff09 +knowledge.reindexing.label.end=\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u4f5c\u6210\u3059\u308b\u30ca\u30ec\u30c3\u30b8\u306e\u756a\u53f7\uff08\u7d42\u4e86\uff09 +knowledge.reindexing.msg.start=\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u518d\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059\u3002\uff08\u3053\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u304d\u3048\u308b\u307e\u3067\u3001\u304a\u5f85\u3061\u304f\u3060\u3055\u3044\uff09 +knowledge.reindexing.msg.end=\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u518d\u4f5c\u6210\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3002 knowledge.notify.title=\u901a\u77e5\u8a2d\u5b9a knowledge.notify.msg=\u6295\u7a3f\u306e\u72b6\u614b\u304c\u5909\u5316\u3057\u305f\u969b\u306e\u901a\u77e5\u3092\u8a2d\u5b9a\u3057\u307e\u3059 diff --git a/src/main/resources/connection.xml b/src/main/resources/connection.xml index d4f89ead2..7b9b1eea6 100644 --- a/src/main/resources/connection.xml +++ b/src/main/resources/connection.xml @@ -1,5 +1,6 @@ + connection org.h2.Driver jdbc:h2:tcp://localhost/./knowledge_db sa diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_insert.sql index fa582a620..118d90ace 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_insert.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_insert.sql @@ -13,7 +13,7 @@ IMAGE_ID , UPDATE_DATETIME , DELETE_FLAG ) VALUES ( -? +DEFAULT , ? , ? , ? diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_raw_insert.sql new file mode 100644 index 000000000..fa582a620 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/AccountImagesDao/AccountImagesDao_raw_insert.sql @@ -0,0 +1,28 @@ +INSERT INTO ACCOUNT_IMAGES +( +IMAGE_ID + , USER_ID + , FILE_NAME + , FILE_SIZE + , FILE_BINARY + , EXTENSION + , CONTENT_TYPE + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_insert.sql index 84df3c317..33e0ffd1d 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_insert.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_insert.sql @@ -9,7 +9,7 @@ COMMENT_NO , UPDATE_DATETIME , DELETE_FLAG ) VALUES ( -? +DEFAULT , ? , ? , ? diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_raw_insert.sql new file mode 100644 index 000000000..84df3c317 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/CommentsDao/CommentsDao_raw_insert.sql @@ -0,0 +1,20 @@ +INSERT INTO COMMENTS +( +COMMENT_NO + , KNOWLEDGE_ID + , COMMENT + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_insert.sql index 9140096a1..43d474d05 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_insert.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_insert.sql @@ -13,7 +13,7 @@ FILE_NO , UPDATE_DATETIME , DELETE_FLAG ) VALUES ( -? +DEFAULT , ? , ? , ? diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_raw_insert.sql new file mode 100644 index 000000000..9140096a1 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeFilesDao/KnowledgeFilesDao_raw_insert.sql @@ -0,0 +1,28 @@ +INSERT INTO KNOWLEDGE_FILES +( +FILE_NO + , KNOWLEDGE_ID + , COMMENT_NO + , FILE_NAME + , FILE_SIZE + , FILE_BINARY + , PARSE_STATUS + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_insert.sql index 747662ebc..cd1af52fa 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_insert.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_insert.sql @@ -1,7 +1,7 @@ INSERT INTO KNOWLEDGE_GROUPS ( -KNOWLEDGE_ID - , GROUP_ID +GROUP_ID + , KNOWLEDGE_ID , INSERT_USER , INSERT_DATETIME , UPDATE_USER diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_raw_insert.sql new file mode 100644 index 000000000..cd1af52fa --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeGroupsDao/KnowledgeGroupsDao_raw_insert.sql @@ -0,0 +1,18 @@ +INSERT INTO KNOWLEDGE_GROUPS +( +GROUP_ID + , KNOWLEDGE_ID + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_raw_insert.sql new file mode 100644 index 000000000..3e41c4aca --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeTagsDao/KnowledgeTagsDao_raw_insert.sql @@ -0,0 +1,18 @@ +INSERT INTO KNOWLEDGE_TAGS +( +KNOWLEDGE_ID + , TAG_ID + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_raw_insert.sql new file mode 100644 index 000000000..9440e9f3f --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeUsersDao/KnowledgeUsersDao_raw_insert.sql @@ -0,0 +1,18 @@ +INSERT INTO KNOWLEDGE_USERS +( +KNOWLEDGE_ID + , USER_ID + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_insert.sql index c38942bce..e67ce01da 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_insert.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_insert.sql @@ -14,7 +14,7 @@ KNOWLEDGE_ID , UPDATE_DATETIME , DELETE_FLAG ) VALUES ( -? +DEFAULT , ? , ? , ? diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_raw_insert.sql new file mode 100644 index 000000000..c38942bce --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_raw_insert.sql @@ -0,0 +1,30 @@ +INSERT INTO KNOWLEDGES +( +KNOWLEDGE_ID + , TITLE + , CONTENT + , PUBLIC_FLAG + , TAG_IDS + , TAG_NAMES + , LIKE_COUNT + , COMMENT_COUNT + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_insert.sql index 2783621da..361503e62 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_insert.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_insert.sql @@ -8,7 +8,7 @@ NO , UPDATE_DATETIME , DELETE_FLAG ) VALUES ( -? +DEFAULT , ? , ? , ? diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_raw_insert.sql new file mode 100644 index 000000000..2783621da --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_raw_insert.sql @@ -0,0 +1,18 @@ +INSERT INTO LIKES +( +NO + , KNOWLEDGE_ID + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_raw_insert.sql new file mode 100644 index 000000000..77d158bfd --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotifyConfigsDao/NotifyConfigsDao_raw_insert.sql @@ -0,0 +1,36 @@ +INSERT INTO NOTIFY_CONFIGS +( +USER_ID + , NOTIFY_MAIL + , NOTIFY_DESKTOP + , MY_ITEM_COMMENT + , MY_ITEM_LIKE + , MY_ITEM_STOCK + , TO_ITEM_SAVE + , TO_ITEM_COMMENT + , TO_ITEM_IGNORE_PUBLIC + , STOCK_ITEM_SAVE + , STOKE_ITEM_COMMENT + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_raw_insert.sql new file mode 100644 index 000000000..cb9052e08 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/NotifyQueuesDao/NotifyQueuesDao_raw_insert.sql @@ -0,0 +1,20 @@ +INSERT INTO NOTIFY_QUEUES +( +HASH + , TYPE + , ID + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_insert.sql index fb43fb550..abda4712c 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_insert.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_insert.sql @@ -1,7 +1,7 @@ INSERT INTO STOCKS ( -USER_ID - , KNOWLEDGE_ID +KNOWLEDGE_ID + , USER_ID , COMMENT , INSERT_USER , INSERT_DATETIME diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_raw_insert.sql new file mode 100644 index 000000000..abda4712c --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/StocksDao/StocksDao_raw_insert.sql @@ -0,0 +1,20 @@ +INSERT INTO STOCKS +( +KNOWLEDGE_ID + , USER_ID + , COMMENT + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_insert.sql index 1ec2e9328..94679d234 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_insert.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_insert.sql @@ -8,7 +8,7 @@ TAG_ID , UPDATE_DATETIME , DELETE_FLAG ) VALUES ( -? +DEFAULT , ? , ? , ? diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_raw_insert.sql new file mode 100644 index 000000000..1ec2e9328 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_raw_insert.sql @@ -0,0 +1,18 @@ +INSERT INTO TAGS +( +TAG_ID + , TAG_NAME + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_insert.sql index e3e44900e..199f8578f 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_insert.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_insert.sql @@ -9,7 +9,7 @@ HISTORY_NO , UPDATE_DATETIME , DELETE_FLAG ) VALUES ( -? +DEFAULT , ? , ? , ? diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_raw_insert.sql new file mode 100644 index 000000000..e3e44900e --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ViewHistoriesDao/ViewHistoriesDao_raw_insert.sql @@ -0,0 +1,20 @@ +INSERT INTO VIEW_HISTORIES +( +HISTORY_NO + , KNOWLEDGE_ID + , VIEW_DATE_TIME + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_insert.sql index f0cc30dfa..ff6f8236b 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_insert.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_insert.sql @@ -9,7 +9,7 @@ VOTE_NO , UPDATE_DATETIME , DELETE_FLAG ) VALUES ( -? +DEFAULT , ? , ? , ? diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_raw_insert.sql new file mode 100644 index 000000000..f0cc30dfa --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/VotesDao/VotesDao_raw_insert.sql @@ -0,0 +1,20 @@ +INSERT INTO VOTES +( +VOTE_NO + , KNOWLEDGE_ID + , VOTE_KIND + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/database/ddl.sql b/src/main/resources/org/support/project/knowledge/database/ddl.sql index 30ce56fdd..879b2b800 100644 --- a/src/main/resources/org/support/project/knowledge/database/ddl.sql +++ b/src/main/resources/org/support/project/knowledge/database/ddl.sql @@ -1,8 +1,3 @@ --- Project Name : knowledge --- Date/Time : 2015/03/31 5:54:19 --- RDBMS Type : PostgreSQL --- Application : A5:SQL Mk-2 - -- 通知待ちキュー drop table if exists NOTIFY_QUEUES cascade; @@ -45,11 +40,11 @@ create table NOTIFY_CONFIGS ( drop table if exists ACCOUNT_IMAGES cascade; create table ACCOUNT_IMAGES ( - IMAGE_ID bigint not null AUTO_INCREMENT + IMAGE_ID BIGSERIAL not null , USER_ID integer , FILE_NAME character varying(256) , FILE_SIZE double precision - , FILE_BINARY blob + , FILE_BINARY BYTEA , EXTENSION character varying(256) , CONTENT_TYPE character varying(256) , INSERT_USER integer @@ -67,7 +62,7 @@ create unique index IDX_ACCOUNT_IMAGES_USER_ID drop table if exists LIKES cascade; create table LIKES ( - NO bigint not null AUTO_INCREMENT + NO BIGSERIAL not null , KNOWLEDGE_ID bigint not null , INSERT_USER integer , INSERT_DATETIME timestamp @@ -84,7 +79,7 @@ create index IDX_LIKES_KNOWLEDGE_ID drop table if exists COMMENTS cascade; create table COMMENTS ( - COMMENT_NO bigint not null AUTO_INCREMENT + COMMENT_NO BIGSERIAL not null , KNOWLEDGE_ID bigint not null , COMMENT text , INSERT_USER integer @@ -102,7 +97,7 @@ create index IDX_COMMENTS_KNOWLEDGE_ID drop table if exists VOTES cascade; create table VOTES ( - VOTE_NO bigint not null AUTO_INCREMENT + VOTE_NO BIGSERIAL not null , KNOWLEDGE_ID bigint not null , VOTE_KIND integer not null , INSERT_USER integer @@ -120,7 +115,7 @@ create index IDX_VOTES_KNOWLEDGE_ID drop table if exists VIEW_HISTORIES cascade; create table VIEW_HISTORIES ( - HISTORY_NO bigint not null AUTO_INCREMENT + HISTORY_NO BIGSERIAL not null , KNOWLEDGE_ID bigint not null , VIEW_DATE_TIME timestamp not null , INSERT_USER integer @@ -195,7 +190,7 @@ create table KNOWLEDGE_TAGS ( drop table if exists TAGS cascade; create table TAGS ( - TAG_ID integer not null AUTO_INCREMENT + TAG_ID SERIAL not null , TAG_NAME character varying(128) not null , INSERT_USER integer , INSERT_DATETIME timestamp @@ -209,12 +204,12 @@ create table TAGS ( drop table if exists KNOWLEDGE_FILES cascade; create table KNOWLEDGE_FILES ( - FILE_NO bigint not null AUTO_INCREMENT + FILE_NO BIGSERIAL not null , KNOWLEDGE_ID bigint , COMMENT_NO bigint , FILE_NAME character varying(256) , FILE_SIZE double precision - , FILE_BINARY blob + , FILE_BINARY BYTEA , PARSE_STATUS integer not null , INSERT_USER integer , INSERT_DATETIME timestamp @@ -231,7 +226,7 @@ create index IDX_KNOWLEDGE_FILES_KNOWLEDGE_ID drop table if exists KNOWLEDGES cascade; create table KNOWLEDGES ( - KNOWLEDGE_ID bigint not null AUTO_INCREMENT + KNOWLEDGE_ID BIGSERIAL not null , TITLE character varying(1024) not null , CONTENT text , PUBLIC_FLAG integer diff --git a/src/main/webapp/WEB-INF/views/admin/database/connection.jsp b/src/main/webapp/WEB-INF/views/admin/database/connection.jsp new file mode 100644 index 000000000..4a197cf78 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/admin/database/connection.jsp @@ -0,0 +1,138 @@ +<%@page import="org.support.project.knowledge.config.SystemConfig"%> +<%@page import="org.support.project.common.config.INT_FLAG"%> +<%@page import="org.support.project.knowledge.vo.Roles"%> +<%@page import="org.support.project.web.util.JspUtil"%> +<%@page pageEncoding="UTF-8" isELIgnored="false" session="false" errorPage="/WEB-INF/views/commons/errors/jsp_error.jsp"%> +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> +<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> + +<% JspUtil jspUtil = new JspUtil(request, pageContext); %> + + + + + + + + +<% if (jspUtil.is(Boolean.TRUE, "transfer")) { %> + +<% } %> + + + + + +

<%= jspUtil.label("knowledge.navbar.data.connect") %>

+ +<% if(jspUtil.is(Boolean.TRUE, "custom")) { %> + + + <% if (jspUtil.is(Boolean.TRUE, "transfer")) { %> + + <% } %> + +<% } else { %> + +<% } %> + +
+
+ +
+ +
+ +
+
+ + " /> +
+
+ + " /> +
+
+ + " /> +
+
+ + " /> +
+
+ + " /> +
+
+ + " /> +
+ + + + + +  <%= jspUtil.label("label.delete") %> + + +<% if(jspUtil.is(Boolean.TRUE, "custom") && !(jspUtil.is(Boolean.TRUE, "transfer"))) { %> + +  <%= jspUtil.label("knowledge.connection.label.transfer") %> + +<% } %> + +
+ + + +
+ +
+ diff --git a/src/main/webapp/WEB-INF/views/admin/database/index.jsp b/src/main/webapp/WEB-INF/views/admin/database/index.jsp index ee358255d..c8bbf6716 100644 --- a/src/main/webapp/WEB-INF/views/admin/database/index.jsp +++ b/src/main/webapp/WEB-INF/views/admin/database/index.jsp @@ -30,12 +30,20 @@ $("#input-id").fileinput(); -

<%= jspUtil.label("knowledge.navbar.data") %>

+

<%= jspUtil.label("knowledge.navbar.data.backup") %>

+ + + + + <%= jspUtil.label("knowledge.data.msg") %> diff --git a/src/main/webapp/WEB-INF/views/admin/database/reindexing.jsp b/src/main/webapp/WEB-INF/views/admin/database/reindexing.jsp new file mode 100644 index 000000000..2ca9cb252 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/admin/database/reindexing.jsp @@ -0,0 +1,106 @@ +<%@page import="org.support.project.knowledge.config.SystemConfig"%> +<%@page import="org.support.project.common.config.INT_FLAG"%> +<%@page import="org.support.project.knowledge.vo.Roles"%> +<%@page import="org.support.project.web.util.JspUtil"%> +<%@page pageEncoding="UTF-8" isELIgnored="false" session="false" errorPage="/WEB-INF/views/commons/errors/jsp_error.jsp"%> +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> +<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> + +<% JspUtil jspUtil = new JspUtil(request, pageContext); %> + + + + + + + + +<% if (jspUtil.is(Boolean.TRUE, "start_reindexing")) { %> + +<% } %> + + + + + +

<%= jspUtil.label("knowledge.reindexing.title") %>

+ +<% if(jspUtil.is(Boolean.TRUE, "start_reindexing")) { %> + +<% } %> + + + +
+
+ + " required="required"/> +
+
+ + " required="required"/> +
+ + +
+ + + +<% if(jspUtil.is(Boolean.TRUE, "start_reindexing")) { %> +
+ + +
+<% } %> + + +
+ +
+ diff --git a/src/main/webapp/WEB-INF/views/commons/layout/commonNavbar.jsp b/src/main/webapp/WEB-INF/views/commons/layout/commonNavbar.jsp index cc9e61898..d4fd766c2 100644 --- a/src/main/webapp/WEB-INF/views/commons/layout/commonNavbar.jsp +++ b/src/main/webapp/WEB-INF/views/commons/layout/commonNavbar.jsp @@ -129,6 +129,16 @@  <%= jspUtil.label("knowledge.navbar.data.backup") %> +
  • + +  <%= jspUtil.label("knowledge.navbar.data.connect") %> + +
  • +
  • + +  <%= jspUtil.label("knowledge.navbar.data.reindexing") %> + +
  • diff --git a/src/main/webapp/WEB-INF/views/commons/layout/layoutMain.jsp b/src/main/webapp/WEB-INF/views/commons/layout/layoutMain.jsp index a4f59a9fd..56825ec4e 100644 --- a/src/main/webapp/WEB-INF/views/commons/layout/layoutMain.jsp +++ b/src/main/webapp/WEB-INF/views/commons/layout/layoutMain.jsp @@ -48,11 +48,6 @@ ${param.PARAM_CONTENT} <% jspUtil.debug(); %> - - - -${param.PARAM_SCRIPTS} - @@ -77,6 +72,13 @@ ${param.PARAM_SCRIPTS} + + + +${param.PARAM_SCRIPTS} + + + diff --git a/src/main/webapp/WEB-INF/views/index/index.jsp b/src/main/webapp/WEB-INF/views/index/index.jsp index c21219cc5..46a972fef 100644 --- a/src/main/webapp/WEB-INF/views/index/index.jsp +++ b/src/main/webapp/WEB-INF/views/index/index.jsp @@ -1,58 +1,234 @@ <%@page import="org.support.project.web.util.JspUtil"%> -<%@page pageEncoding="UTF-8" isELIgnored="false" session="false" - errorPage="/WEB-INF/views/commons/errors/jsp_error.jsp"%> +<%@page pageEncoding="UTF-8" isELIgnored="false" session="false" errorPage="/WEB-INF/views/commons/errors/jsp_error.jsp"%> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> <% JspUtil jspUtil = new JspUtil(request, pageContext); %> - - - - - - - - - - - -
    -

     Knowledge

    -

    -

    <%= jspUtil.label("knowledge.top.description") %>

    -

    - -  <%= jspUtil.label("knowledge.top.use.button") %> - -

    -
    - -
    -<%= jspUtil.label("knowledge.top.features.title") %> -<%= jspUtil.label("knowledge.top.features.1") %> -<%= jspUtil.label("knowledge.top.features.2") %> -<%= jspUtil.label("knowledge.top.features.3") %> -<%= jspUtil.label("knowledge.top.features.4") %> -<%= jspUtil.label("knowledge.top.features.5") %> -<%= jspUtil.label("knowledge.top.features.6") %> + + + + + + + + + + +" name="title"> +" name="description"> + + + + + + + + + +<%=jspUtil.label("knowledge.title")%> + +" /> + + + + + + + + + +
    + + + + <%-- +
    +

    <%=jspUtil.label("knowledge.top.description")%>

    +
    + --%> + +
    +
    + +
    +<%=jspUtil.label("knowledge.top.features.title")%> +<%=jspUtil.label("knowledge.top.features.1")%> +<%=jspUtil.label("knowledge.top.features.2")%> +<%=jspUtil.label("knowledge.top.features.3")%> +<%=jspUtil.label("knowledge.top.features.4")%> +<%=jspUtil.label("knowledge.top.features.5")%> +<%=jspUtil.label("knowledge.top.features.6")%> + +[-> More Information](https://support-project.org/knowledge_info/index "-> More Information")
    - + + + +
    + + + + + + + + - diff --git a/src/main/webapp/images/startup-594090_1280.jpg b/src/main/webapp/images/startup-594090_1280.jpg new file mode 100644 index 000000000..befd35460 Binary files /dev/null and b/src/main/webapp/images/startup-594090_1280.jpg differ diff --git a/src/test/java/org/support/project/knowledge/dao/AccountImagesDaoTest.java b/src/test/java/org/support/project/knowledge/dao/AccountImagesDaoTest.java new file mode 100644 index 000000000..eab1b2923 --- /dev/null +++ b/src/test/java/org/support/project/knowledge/dao/AccountImagesDaoTest.java @@ -0,0 +1,63 @@ +package org.support.project.knowledge.dao; + +import static org.junit.Assert.assertNotNull; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.support.project.common.util.FileUtil; +import org.support.project.common.util.RandomUtil; +import org.support.project.knowledge.entity.AccountImagesEntity; + +public class AccountImagesDaoTest { + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testSelectOnUserId() throws FileNotFoundException, IOException { + try { + AccountImagesEntity entity = new AccountImagesEntity(); + entity.setUserId(RandomUtil.randamNum(10000, 60000)); + entity.setFileBinary(getClass().getResourceAsStream("/appresource_ja.properties")); + + AccountImagesDao dao = AccountImagesDao.get(); + entity = dao.insert(entity); + + assertNotNull(entity.getImageId()); + + + entity = dao.selectOnUserId(entity.getUserId()); + + FileUtil.copy(entity.getFileBinary(), new FileOutputStream(new File("/data/test"))); + FileUtil.delete(new File("/data/test")); + + assertNotNull(entity.getImageId()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + + } + +} diff --git a/src/test/java/org/support/project/knowledge/dao/LikesDaoTest.java b/src/test/java/org/support/project/knowledge/dao/LikesDaoTest.java new file mode 100644 index 000000000..eb25bb12a --- /dev/null +++ b/src/test/java/org/support/project/knowledge/dao/LikesDaoTest.java @@ -0,0 +1,68 @@ +package org.support.project.knowledge.dao; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.knowledge.entity.LikesEntity; + +public class LikesDaoTest { + /** ログ */ + private static Log LOG = LogFactory.getLog(LikesDaoTest.class); + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testInsert() { + LikesDao dao = LikesDao.get(); + + // 自動採番 + LikesEntity entity = new LikesEntity(); + entity.setKnowledgeId(new Long(1)); + //log.debug(entity); + + entity = dao.insert(entity); + LOG.debug(entity); + Assert.assertNotNull(entity.getNo()); + + Long max = entity.getNo(); + + // 手入力 + entity = new LikesEntity(); + entity.setKnowledgeId(new Long(1)); + entity.setNo(max + 1); + + entity = dao.rawPhysicalInsert(entity); + LOG.debug(entity); + Assert.assertEquals(Long.valueOf(max + 1), entity.getNo()); + + // 再度自動採番 + entity = new LikesEntity(); + entity.setKnowledgeId(new Long(1)); + + entity = dao.insert(entity); + LOG.debug(entity); + Assert.assertEquals(Long.valueOf(max + 2), entity.getNo()); + } + +}