Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abook_check
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abook_android
abook_check
Commits
b47d99f6
Commit
b47d99f6
authored
Apr 28, 2021
by
Lee Munkyeong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CheckとDB分離
parent
61794f96
Show whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
944 additions
and
33 deletions
+944
-33
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/ABVDataOpenHelper.java
+0
-12
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/CommunicationDBConnector.java
+59
-0
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/CommunicationDataOpenHelper.java
+161
-0
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/DatabaseVersions.java
+2
-0
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/dao/AbstractCommunicationDao.java
+589
-0
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/dao/ArchiveDao.java
+1
-1
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/dao/ChatGroupDao.java
+1
-1
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/dao/ChatMessageDao.java
+1
-1
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/dao/ChatRoomDao.java
+1
-1
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/dao/CollaborationDao.java
+1
-1
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/dao/CollaborationDetailDao.java
+1
-1
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/dao/ShopMemberDao.java
+1
-1
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/tables/MShopMember.java
+6
-1
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/tables/RChatRoomShopMember.java
+6
-1
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/tables/RCollaborationMember.java
+6
-1
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/tables/RShopMemberGroup.java
+6
-1
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/tables/TChatMessage.java
+6
-1
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/tables/TChatRoom.java
+6
-1
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/tables/TCollaboration.java
+6
-1
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/tables/TCollaborationDetail.java
+6
-1
ABVJE_BL/src/jp/agentec/abook/abv/bl/logic/CommunicationLogic.java
+6
-6
ABVJE_UI_Android/src/jp/agentec/abook/abv/bl/common/db/impl/CommunicationSQLiteOpenHelper.java
+60
-0
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/util/Initializer.java
+12
-0
No files found.
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/ABVDataOpenHelper.java
View file @
b47d99f6
...
@@ -111,18 +111,6 @@ public class ABVDataOpenHelper {
...
@@ -111,18 +111,6 @@ public class ABVDataOpenHelper {
iTableScripts
.
add
(
new
ROperationGroupMasterOperation
());
iTableScripts
.
add
(
new
ROperationGroupMasterOperation
());
iTableScripts
.
add
(
new
TTaskReportApproval
());
iTableScripts
.
add
(
new
TTaskReportApproval
());
//ABCOMM関連テーブル
iTableScripts
.
add
(
new
MChatGroup
());
iTableScripts
.
add
(
new
MShopMember
());
iTableScripts
.
add
(
new
TChatRoom
());
iTableScripts
.
add
(
new
TChatMessage
());
iTableScripts
.
add
(
new
TCollaboration
());
iTableScripts
.
add
(
new
TCollaborationDetail
());
iTableScripts
.
add
(
new
TArchive
());
iTableScripts
.
add
(
new
RShopMemberGroup
());
iTableScripts
.
add
(
new
RChatRoomShopMember
());
iTableScripts
.
add
(
new
RCollaborationMember
());
return
iTableScripts
;
return
iTableScripts
;
}
}
...
...
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/CommunicationDBConnector.java
0 → 100644
View file @
b47d99f6
package
jp
.
agentec
.
abook
.
abv
.
bl
.
data
;
import
jp.agentec.abook.abv.bl.common.db.SQLiteDatabase
;
/**
* DBへの接続を管理するクラス
*
* ActivityのonCreate時に必ず、以下の手順で呼び出すこと。
* もしくはInitilizerの中で行っても良い。
*
* DBConnector conn = DBConnector.getInstance();
* SQLiteOpenHelper sqlLiteOpenHelper = new ...;
* conn.setSqlLiteOpenHelper(sqlLiteOpenHelper);
* conn.init();
*
* @author tsukada
*
*/
public
class
CommunicationDBConnector
{
private
static
volatile
CommunicationDBConnector
dbConnector
=
null
;
public
static
final
String
DatabaseName
=
"ABVJE_COMM"
;
public
static
final
int
DatabaseVersion
=
DatabaseVersions
.
Ver1_3_000
;
protected
SQLiteDatabase
db
=
null
;
private
jp
.
agentec
.
abook
.
abv
.
bl
.
common
.
db
.
SQLiteOpenHelper
sqlLiteOpenHelper
=
null
;
public
void
setSqlLiteOpenHelper
(
jp
.
agentec
.
abook
.
abv
.
bl
.
common
.
db
.
SQLiteOpenHelper
sqlLiteOpenHelper
)
{
this
.
sqlLiteOpenHelper
=
sqlLiteOpenHelper
;
}
public
static
CommunicationDBConnector
getInstance
()
{
if
(
dbConnector
==
null
)
{
synchronized
(
CommunicationDBConnector
.
class
)
{
if
(
dbConnector
==
null
)
{
dbConnector
=
new
CommunicationDBConnector
();
}
}
}
return
dbConnector
;
}
public
SQLiteDatabase
getDatabase
()
{
if
(!
isOpen
())
{
db
=
sqlLiteOpenHelper
.
openDatabase
();
}
return
db
;
}
/**
* データベースコネクションがオープンされているか確認します。
* @return コネクションがオープンされているとtrueを返します。
* @since 1.0.0
*/
public
synchronized
boolean
isOpen
()
{
return
db
!=
null
&&
db
.
isOpen
();
}
}
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/CommunicationDataOpenHelper.java
0 → 100644
View file @
b47d99f6
package
jp
.
agentec
.
abook
.
abv
.
bl
.
data
;
import
java.util.ArrayList
;
import
java.util.List
;
import
jp.agentec.abook.abv.bl.common.db.SQLiteDatabase
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
jp.agentec.abook.abv.bl.data.tables.LContentObjectLog
;
import
jp.agentec.abook.abv.bl.data.tables.LContentPageReadingLog
;
import
jp.agentec.abook.abv.bl.data.tables.LContentReadingLog
;
import
jp.agentec.abook.abv.bl.data.tables.MAcms
;
import
jp.agentec.abook.abv.bl.data.tables.MAppConfig
;
import
jp.agentec.abook.abv.bl.data.tables.MCategory
;
import
jp.agentec.abook.abv.bl.data.tables.MChatGroup
;
import
jp.agentec.abook.abv.bl.data.tables.MGroup
;
import
jp.agentec.abook.abv.bl.data.tables.MMemberInfo
;
import
jp.agentec.abook.abv.bl.data.tables.MOperationGroupMaster
;
import
jp.agentec.abook.abv.bl.data.tables.MPasswordLockInfo
;
import
jp.agentec.abook.abv.bl.data.tables.MServiceOption
;
import
jp.agentec.abook.abv.bl.data.tables.MShopMember
;
import
jp.agentec.abook.abv.bl.data.tables.MWorkerGroup
;
import
jp.agentec.abook.abv.bl.data.tables.RChatRoomShopMember
;
import
jp.agentec.abook.abv.bl.data.tables.RCollaborationMember
;
import
jp.agentec.abook.abv.bl.data.tables.RContentCategory
;
import
jp.agentec.abook.abv.bl.data.tables.RContentGroup
;
import
jp.agentec.abook.abv.bl.data.tables.ROperationContent
;
import
jp.agentec.abook.abv.bl.data.tables.ROperationGroupMasterOperation
;
import
jp.agentec.abook.abv.bl.data.tables.RShopMemberGroup
;
import
jp.agentec.abook.abv.bl.data.tables.RTaskWorkerGroup
;
import
jp.agentec.abook.abv.bl.data.tables.SQLiteTableScript
;
import
jp.agentec.abook.abv.bl.data.tables.TArchive
;
import
jp.agentec.abook.abv.bl.data.tables.TChatMessage
;
import
jp.agentec.abook.abv.bl.data.tables.TChatRoom
;
import
jp.agentec.abook.abv.bl.data.tables.TCollaboration
;
import
jp.agentec.abook.abv.bl.data.tables.TCollaborationDetail
;
import
jp.agentec.abook.abv.bl.data.tables.TContent
;
import
jp.agentec.abook.abv.bl.data.tables.TContentBookmark
;
import
jp.agentec.abook.abv.bl.data.tables.TContentDownloadQueue
;
import
jp.agentec.abook.abv.bl.data.tables.TContentMarking
;
import
jp.agentec.abook.abv.bl.data.tables.TContentMemo
;
import
jp.agentec.abook.abv.bl.data.tables.TContentOldPdf
;
import
jp.agentec.abook.abv.bl.data.tables.TContentPage
;
import
jp.agentec.abook.abv.bl.data.tables.TContentResource
;
import
jp.agentec.abook.abv.bl.data.tables.TContentServerSearched
;
import
jp.agentec.abook.abv.bl.data.tables.TContentTag
;
import
jp.agentec.abook.abv.bl.data.tables.TEnquete
;
import
jp.agentec.abook.abv.bl.data.tables.TMarkingSetting
;
import
jp.agentec.abook.abv.bl.data.tables.TOperation
;
import
jp.agentec.abook.abv.bl.data.tables.TPushMessage
;
import
jp.agentec.abook.abv.bl.data.tables.TTask
;
import
jp.agentec.abook.abv.bl.data.tables.TTaskReport
;
import
jp.agentec.abook.abv.bl.data.tables.TTaskReportApproval
;
import
jp.agentec.abook.abv.bl.data.tables.TTaskReportItems
;
import
jp.agentec.abook.abv.bl.data.tables.TTaskReportSend
;
import
jp.agentec.adf.util.StringUtil
;
public
class
CommunicationDataOpenHelper
{
private
Throwable
lastError
=
null
;
private
boolean
createFailed
=
false
;
private
static
final
String
TAG
=
"DATA"
;
public
Throwable
getLastError
()
{
return
lastError
;
}
public
boolean
isCreated
()
{
return
!
createFailed
;
}
private
List
<
SQLiteTableScript
>
getTableScripts
()
{
List
<
SQLiteTableScript
>
iTableScripts
=
new
ArrayList
<
SQLiteTableScript
>();
//ABCOMM関連テーブル
iTableScripts
.
add
(
new
MChatGroup
());
iTableScripts
.
add
(
new
MShopMember
());
iTableScripts
.
add
(
new
TChatRoom
());
iTableScripts
.
add
(
new
TChatMessage
());
iTableScripts
.
add
(
new
TCollaboration
());
iTableScripts
.
add
(
new
TCollaborationDetail
());
iTableScripts
.
add
(
new
TArchive
());
iTableScripts
.
add
(
new
RShopMemberGroup
());
iTableScripts
.
add
(
new
RChatRoomShopMember
());
iTableScripts
.
add
(
new
RCollaborationMember
());
return
iTableScripts
;
}
public
void
onCreate
(
SQLiteDatabase
db
)
{
Logger
.
i
(
TAG
,
"create database version "
+
db
.
getVersion
());
List
<
SQLiteTableScript
>
iTableScripts
=
getTableScripts
();
try
{
List
<
String
>
ddl
;
db
.
beginTransaction
();
for
(
SQLiteTableScript
iTableScript
:
iTableScripts
)
{
ddl
=
iTableScript
.
getCreateScript
(
db
.
getVersion
());
for
(
String
sql
:
ddl
)
{
if
(!
StringUtil
.
isNullOrWhiteSpace
(
sql
))
{
Logger
.
d
(
TAG
,
sql
);
db
.
execSQL
(
sql
);
}
}
}
db
.
setTransactionSuccessful
();
// commit
createFailed
=
false
;
}
catch
(
Exception
e
)
{
lastError
=
e
;
createFailed
=
true
;
}
finally
{
db
.
endTransaction
();
}
}
public
void
onUpgrade
(
SQLiteDatabase
db
,
int
oldVersion
,
int
newVersion
)
{
Logger
.
i
(
TAG
,
String
.
format
(
"upgrade database to version %d from version : %d"
,
newVersion
,
oldVersion
));
List
<
SQLiteTableScript
>
iTableScripts
=
getTableScripts
();
try
{
List
<
String
>
ddl
;
List
<
String
>
dml
;
db
.
beginTransaction
();
for
(
SQLiteTableScript
iTableScript
:
iTableScripts
)
{
ddl
=
iTableScript
.
getUpgradeScript
(
oldVersion
,
newVersion
);
if
(
ddl
!=
null
)
{
for
(
String
sql
:
ddl
)
{
if
(!
StringUtil
.
isNullOrWhiteSpace
(
sql
))
{
Logger
.
d
(
TAG
,
sql
);
db
.
execSQL
(
sql
);
}
}
}
dml
=
iTableScript
.
getMigrationScript
(
db
,
oldVersion
,
newVersion
,
null
);
if
(
dml
!=
null
)
{
for
(
String
sql
:
dml
)
{
if
(!
StringUtil
.
isNullOrWhiteSpace
(
sql
))
{
Logger
.
d
(
TAG
,
sql
);
db
.
execSQL
(
sql
);
}
}
}
}
db
.
setTransactionSuccessful
();
// commit
createFailed
=
false
;
}
catch
(
Exception
e
)
{
Logger
.
e
(
TAG
,
e
);
lastError
=
e
;
createFailed
=
true
;
}
finally
{
db
.
endTransaction
();
}
}
}
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/DatabaseVersions.java
View file @
b47d99f6
...
@@ -11,5 +11,7 @@ public class DatabaseVersions {
...
@@ -11,5 +11,7 @@ public class DatabaseVersions {
//チャット機能追加(1.2.360障害対応。)
//チャット機能追加(1.2.360障害対応。)
public
static
final
int
Ver1_2_362
=
24
;
public
static
final
int
Ver1_2_362
=
24
;
// コミュニケーション(1.3.000)
public
static
final
int
Ver1_3_000
=
25
;
}
}
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/dao/AbstractCommunicationDao.java
0 → 100644
View file @
b47d99f6
package
jp
.
agentec
.
abook
.
abv
.
bl
.
data
.
dao
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.ConcurrentHashMap
;
import
jp.agentec.abook.abv.bl.common.db.Cursor
;
import
jp.agentec.abook.abv.bl.common.db.SQLiteDatabase
;
import
jp.agentec.abook.abv.bl.common.db.SQLiteStatement
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
jp.agentec.abook.abv.bl.data.CommunicationDBConnector
;
import
jp.agentec.abook.abv.bl.data.DBConnector
;
import
jp.agentec.abook.abv.bl.dto.AbstractDto
;
import
jp.agentec.adf.util.DateTimeFormat
;
import
jp.agentec.adf.util.DateTimeUtil
;
public
class
AbstractCommunicationDao
{
private
static
final
String
TAG
=
"AbstractDao"
;
@SuppressWarnings
(
"rawtypes"
)
private
static
ConcurrentHashMap
<
Class
,
AbstractCommunicationDao
>
daoMap
=
new
ConcurrentHashMap
<
Class
,
AbstractCommunicationDao
>();
@SuppressWarnings
(
"unchecked"
)
public
static
<
T
extends
AbstractCommunicationDao
>
T
getDao
(
Class
<
T
>
clazz
)
{
T
instance
;
if
(
daoMap
.
containsKey
(
clazz
))
{
instance
=
(
T
)
daoMap
.
get
(
clazz
);
}
else
{
// synchronized (daoMap) { // パフォーマンスを考慮し、排他制御をしない。最悪2重に作られても各Daoは状態を持たないため影響はなく、参照がなくなったDaoはgc対象となる。
// if (daoMap.containsKey(clazz)) {
// instance = (T) daoMap.get(clazz);
// }
// else {
try
{
//noinspection ClassNewInstance
instance
=
clazz
.
newInstance
();
daoMap
.
put
(
clazz
,
instance
);
}
catch
(
InstantiationException
e
)
{
throw
new
RuntimeException
(
e
);
}
catch
(
IllegalAccessException
e
)
{
throw
new
RuntimeException
(
e
);
}
// }
// }
}
return
instance
;
}
protected
CommunicationDBConnector
dbConn
=
CommunicationDBConnector
.
getInstance
();
public
SQLiteDatabase
getDatabase
()
{
return
dbConn
.
getDatabase
();
}
/**
* トランザクションを開始します。
*/
public
void
beginTransaction
()
{
dbConn
.
getDatabase
().
beginTransaction
();
}
/**
* トランザクションをコミットします。
*/
public
void
commit
()
{
SQLiteDatabase
db
=
dbConn
.
getDatabase
();
if
(
db
.
inTransaction
())
{
db
.
setTransactionSuccessful
();
db
.
endTransaction
();
}
}
/**
* トランザクションをロールバッグします。
*/
public
void
rollback
()
{
SQLiteDatabase
db
=
dbConn
.
getDatabase
();
if
(
db
.
inTransaction
())
{
db
.
endTransaction
();
}
}
/**
* 指定しテーブルから指定した条件のデータを削除します。<br>
* @param table 削除するテーブル名です。
* @param whereClause 削除する条件(where)のsqlです。prestatementを使う場合、パラメータは?で表記します。nullの指定も可能です。
* @param whereArgs whereClauseでprestatementを使う場合、その値の配列です。nullの指定も可能です。
* @return 削除された行の数を返します。
* @throws Exception データベース接続時に例外が発生しました。
* @since 1.0.0
*/
protected
long
delete
(
String
table
,
String
whereClause
,
String
[]
whereArgs
)
{
SQLiteDatabase
db
=
dbConn
.
getDatabase
();
if
(
Logger
.
isVerboseEnabled
())
{
Logger
.
v
(
TAG
,
"delete table=%s where=%s [%s]"
,
table
,
whereClause
,
join
(
whereArgs
));
}
return
db
.
delete
(
table
,
whereClause
,
whereArgs
);
}
/**
* 指定したsqlを実行します。prestatementはサポートしません。<br>
*
* ★重要: bind()メソッドを使用しないので、Dateを用いる場合は自前でUTCに変換すること
*
* @param sql 実行するsql文です。prestatementはサポートしません。
* @throws Exception sql実行が失敗しました。
*/
protected
void
execSql
(
String
sql
)
{
SQLiteDatabase
db
=
dbConn
.
getDatabase
();
Logger
.
v
(
TAG
,
sql
);
db
.
execSQL
(
sql
);
}
/**
* 指定したsqlを実行します。prestatementをサポートします。<br>
*
* ★重要: bind()メソッドを使用しないので、Dateを用いる場合は自前でUTCに変換すること
*
* @param sql 実行するsql文です。prestatementを使う場合、パラメータは?で表記します。
* @param bindArgs sqlでprestatementを使う場合、その値の配列です。byte[], String, Long, Doubleのみサポートします。
* @throws Exception sql実行が失敗しました。
*/
protected
void
execSql
(
String
sql
,
Object
[]
bindArgs
)
{
SQLiteDatabase
db
=
dbConn
.
getDatabase
();
if
(
Logger
.
isVerboseEnabled
())
{
Logger
.
v
(
TAG
,
"%s [%s]"
,
sql
,
join
(
bindArgs
));
}
db
.
execSQL
(
sql
,
bindArgs
);
}
protected
String
join
(
Object
[]
bindArgs
)
{
if
(
bindArgs
==
null
)
{
return
""
;
}
StringBuffer
sb
=
new
StringBuffer
();
for
(
Object
object
:
bindArgs
)
{
sb
.
append
(
object
);
sb
.
append
(
","
);
}
return
sb
.
toString
();
}
/**
* insert文を実行します。DTOのリストを順次インサートします。
*
* @param sql
* @param list
* @throws Exception
*/
protected
void
insert
(
String
sql
,
List
<?
extends
AbstractDto
>
list
)
{
SQLiteDatabase
db
=
dbConn
.
getDatabase
();
SQLiteStatement
stmt
=
null
;
try
{
stmt
=
db
.
compileStatement
(
sql
);
for
(
AbstractDto
dto
:
list
)
{
if
(
Logger
.
isVerboseEnabled
())
{
Logger
.
v
(
TAG
,
"%s [%s]"
,
sql
,
join
(
dto
.
getInsertValues
()));
}
bind
(
stmt
,
dto
.
getInsertValues
());
stmt
.
execute
();
}
}
finally
{
if
(
stmt
!=
null
)
{
stmt
.
close
();
}
}
}
/**
* インサート文を実行します。
* 基本的にexecSQLと同じですが、呼び出し方が若干異なります。
*
* @param sql
* @param params
* @throws Exception
*/
protected
void
insert
(
String
sql
,
Object
[]
params
)
{
SQLiteDatabase
db
=
dbConn
.
getDatabase
();
SQLiteStatement
stmt
=
null
;
try
{
if
(
Logger
.
isVerboseEnabled
())
{
Logger
.
v
(
TAG
,
"%s [%s]"
,
sql
,
join
(
params
));
}
stmt
=
db
.
compileStatement
(
sql
);
bind
(
stmt
,
params
);
stmt
.
execute
();
}
finally
{
if
(
stmt
!=
null
)
{
stmt
.
close
();
}
}
}
/**
* update文を実行します。
* 基本的にexecSQLと同じですが、呼び出し方が若干異なります。
* 更新された行数を返します。
*
* @param sql
* @param params
* @return
* @throws Exception
*/
protected
long
update
(
String
sql
,
Object
[]
params
)
{
SQLiteDatabase
db
=
dbConn
.
getDatabase
();
SQLiteStatement
stmt
=
null
;
SQLiteStatement
stmt2
=
null
;
try
{
if
(
Logger
.
isVerboseEnabled
())
{
Logger
.
v
(
TAG
,
"%s [%s]"
,
sql
,
join
(
params
));
}
stmt
=
db
.
compileStatement
(
sql
);
bind
(
stmt
,
params
);
stmt
.
execute
();
stmt2
=
db
.
compileStatement
(
"select changes()"
);
long
val
=
stmt2
.
simpleQueryForLong
();
return
val
;
}
finally
{
if
(
stmt
!=
null
)
{
stmt
.
close
();
}
if
(
stmt2
!=
null
)
{
stmt2
.
close
();
}
}
}
/**
* クエリを実行し、最初の行の最初の列の値をint型で返します。
*
* stmt.simpleQueryForLong()と同じ
*
* @param sql
* @param bindArgs
* @return
* @throws Exception
*/
public
int
rawQueryGetInt
(
String
sql
,
String
[]
bindArgs
)
{
SQLiteDatabase
db
=
dbConn
.
getDatabase
();
Cursor
cursor
=
null
;
try
{
if
(
Logger
.
isVerboseEnabled
())
{
Logger
.
v
(
TAG
,
"%s [%s]"
,
sql
,
join
(
bindArgs
));
}
cursor
=
db
.
rawQuery
(
sql
,
bindArgs
);
if
(
cursor
.
moveToNext
())
{
return
cursor
.
getInt
(
0
);
}
return
0
;
}
finally
{
if
(
cursor
!=
null
)
{
cursor
.
close
();
}
}
}
/**
* クエリを実行し、最初の行の最初の列の値をlong型で返します。
*
* stmt.simpleQueryForLong()と同じ
*
* @param sql
* @param bindArgs
* @return
* @throws Exception
*/
public
long
rawQueryGetLong
(
String
sql
,
String
[]
bindArgs
)
{
SQLiteDatabase
db
=
dbConn
.
getDatabase
();
Cursor
cursor
=
null
;
try
{
if
(
Logger
.
isVerboseEnabled
())
{
Logger
.
v
(
TAG
,
"%s [%s]"
,
sql
,
join
(
bindArgs
));
}
cursor
=
db
.
rawQuery
(
sql
,
bindArgs
);
if
(
cursor
.
moveToNext
())
{
return
cursor
.
getLong
(
0
);
}
return
0
;
}
finally
{
if
(
cursor
!=
null
)
{
cursor
.
close
();
}
}
}
/**
* クエリを実行し、最初の行の最初の列の値をInteger型リストで返します。
*
* @param sql
* @param bindArgs
* @return
*/
public
List
<
Integer
>
rawQueryGetIntegerList
(
String
sql
,
String
[]
bindArgs
)
{
SQLiteDatabase
db
=
dbConn
.
getDatabase
();
Cursor
cursor
=
null
;
try
{
List
<
Integer
>
list
=
new
ArrayList
<
Integer
>();
if
(
Logger
.
isVerboseEnabled
())
{
Logger
.
v
(
TAG
,
"%s [%s]"
,
sql
,
join
(
bindArgs
));
}
cursor
=
db
.
rawQuery
(
sql
,
bindArgs
);
while
(
cursor
.
moveToNext
())
{
list
.
add
(
cursor
.
getInt
(
0
));
}
return
list
;
}
finally
{
if
(
cursor
!=
null
)
{
cursor
.
close
();
}
}
}
/**
* クエリを実行し、最初の行の最初の列の値をLong型リストで返します。
*
* @param sql
* @param bindArgs
* @return
*/
public
List
<
Long
>
rawQueryGetLongList
(
String
sql
,
String
[]
bindArgs
)
{
SQLiteDatabase
db
=
dbConn
.
getDatabase
();
Cursor
cursor
=
null
;
try
{
List
<
Long
>
list
=
new
ArrayList
<
Long
>();
if
(
Logger
.
isVerboseEnabled
())
{
Logger
.
v
(
TAG
,
"%s [%s]"
,
sql
,
join
(
bindArgs
));
}
cursor
=
db
.
rawQuery
(
sql
,
bindArgs
);
while
(
cursor
.
moveToNext
())
{
list
.
add
(
cursor
.
getLong
(
0
));
}
return
list
;
}
finally
{
if
(
cursor
!=
null
)
{
cursor
.
close
();
}
}
}
/**
* クエリを実行し、最初の行の最初の列の値をString型で返します。
*
* stmt.simpleQueryForString()と同じ
*
* @param sql
* @param bindArgs
* @return
* @throws Exception
*/
public
String
rawQueryGetString
(
String
sql
,
String
[]
bindArgs
)
{
SQLiteDatabase
db
=
dbConn
.
getDatabase
();
Cursor
cursor
=
null
;
try
{
if
(
Logger
.
isVerboseEnabled
())
{
Logger
.
v
(
TAG
,
"%s [%s]"
,
sql
,
join
(
bindArgs
));
}
cursor
=
db
.
rawQuery
(
sql
,
bindArgs
);
if
(
cursor
.
moveToNext
())
{
return
cursor
.
getString
(
0
);
}
return
null
;
}
finally
{
if
(
cursor
!=
null
)
{
cursor
.
close
();
}
}
}
/**
* クエリを実行し、最初の行の最初の列の値をString型リストで返します。
*
* @param sql
* @param bindArgs
* @return
*/
public
List
<
String
>
rawQueryGetStringList
(
String
sql
,
String
[]
bindArgs
)
{
SQLiteDatabase
db
=
dbConn
.
getDatabase
();
Cursor
cursor
=
null
;
try
{
List
<
String
>
list
=
new
ArrayList
<
String
>();
if
(
Logger
.
isVerboseEnabled
())
{
Logger
.
v
(
TAG
,
"%s [%s]"
,
sql
,
join
(
bindArgs
));
}
cursor
=
db
.
rawQuery
(
sql
,
bindArgs
);
while
(
cursor
.
moveToNext
())
{
list
.
add
(
cursor
.
getString
(
0
));
}
return
list
;
}
finally
{
if
(
cursor
!=
null
)
{
cursor
.
close
();
}
}
}
/**
* クエリを実行し、DTOのリストとして返却します。
* cursorからDTOへの変換は、convertメソッドを使用するため、当該Daoはconvert()メソッドを実装する必要があります。
*
* @param sql
* @param bindArgs
* @param dtoType
* @return
* @throws Exception
*/
@SuppressWarnings
(
"unchecked"
)
protected
<
Dto
extends
AbstractDto
>
List
<
Dto
>
rawQueryGetDtoList
(
String
sql
,
String
[]
bindArgs
,
Class
<
Dto
>
dtoType
)
{
SQLiteDatabase
db
=
dbConn
.
getDatabase
();
Cursor
cursor
=
null
;
try
{
List
<
Dto
>
list
=
new
ArrayList
<
Dto
>();
if
(
Logger
.
isVerboseEnabled
())
{
Logger
.
v
(
TAG
,
"%s [%s]"
,
sql
,
join
(
bindArgs
));
}
cursor
=
db
.
rawQuery
(
sql
,
bindArgs
);
while
(
cursor
.
moveToNext
())
{
list
.
add
((
Dto
)
convert
(
cursor
));
}
return
list
;
}
finally
{
if
(
cursor
!=
null
)
{
cursor
.
close
();
}
}
}
/**
* クエリを実行し、DTOとして返却します。
* cursorからDTOへの変換は、convertメソッドを使用するため、当該Daoはconvert()メソッドを実装する必要があります。
*
* @param sql
* @param bindArgs
* @param dtoType
* @return
* @throws Exception
*/
@SuppressWarnings
(
"unchecked"
)
protected
<
Dto
extends
AbstractDto
>
Dto
rawQueryGetDto
(
String
sql
,
String
[]
bindArgs
,
Class
<
Dto
>
dtoType
)
{
SQLiteDatabase
db
=
dbConn
.
getDatabase
();
Cursor
cursor
=
null
;
try
{
if
(
Logger
.
isVerboseEnabled
())
{
Logger
.
v
(
TAG
,
"%s [%s]"
,
sql
,
join
(
bindArgs
));
}
cursor
=
db
.
rawQuery
(
sql
,
bindArgs
);
if
(
cursor
.
moveToNext
())
{
return
(
Dto
)
convert
(
cursor
);
}
return
null
;
}
finally
{
if
(
cursor
!=
null
)
{
cursor
.
close
();
}
}
}
/**
* SQLiteにおけるBoolの表現は、int型で0がfalse, それ以外がtrueのため、
* その判定を行います。
*
* @param val
* @return
*/
protected
boolean
toBool
(
int
val
)
{
return
val
!=
0
;
}
/**
* ステートメントにパラメータ値をバインドします。
* パラメータの型に応じて自動的にsetterメソッドを選択します。
*
* @param stmt
* @param params
*/
protected
void
bind
(
SQLiteStatement
stmt
,
Object
...
params
)
{
if
(
params
==
null
||
params
.
length
==
0
)
{
return
;
}
for
(
int
i
=
1
;
i
<=
params
.
length
;
i
++)
{
Object
param
=
params
[
i
-
1
];
if
(
param
==
null
)
{
stmt
.
bindNull
(
i
);
}
else
if
(
param
instanceof
String
)
{
stmt
.
bindString
(
i
,
(
String
)
param
);
}
else
if
(
param
instanceof
Integer
)
{
stmt
.
bindLong
(
i
,
(
Integer
)
param
);
}
else
if
(
param
instanceof
Boolean
)
{
stmt
.
bindLong
(
i
,
(
Boolean
)
param
?
1
:
0
);
}
else
if
(
param
instanceof
java
.
util
.
Date
)
{
stmt
.
bindString
(
i
,
DateTimeUtil
.
toStringInTimeZone
(
DateTimeUtil
.
dateToSqlDate
((
java
.
util
.
Date
)
param
),
DateTimeFormat
.
yyyyMMddHHmmssSSS_hyphen
,
"UTC"
));
}
else
//noinspection ConstantConditions
if
(
param
instanceof
java
.
sql
.
Date
)
{
stmt
.
bindString
(
i
,
DateTimeUtil
.
toStringInTimeZone
((
java
.
sql
.
Date
)
param
,
DateTimeFormat
.
yyyyMMddHHmmssSSS_hyphen
,
"UTC"
));
}
else
if
(
param
instanceof
byte
[])
{
stmt
.
bindBlob
(
i
,
(
byte
[])
param
);
}
else
if
(
param
instanceof
Long
)
{
stmt
.
bindLong
(
i
,
(
Long
)
param
);
}
else
if
(
param
instanceof
Short
)
{
stmt
.
bindLong
(
i
,
(
Short
)
param
);
}
else
if
(
param
instanceof
Byte
)
{
stmt
.
bindLong
(
i
,
(
Byte
)
param
);
}
else
if
(
param
instanceof
Float
)
{
stmt
.
bindDouble
(
i
,
(
Float
)
param
);
}
else
if
(
param
instanceof
Double
)
{
stmt
.
bindDouble
(
i
,
(
Double
)
param
);
}
else
{
stmt
.
bindString
(
i
,
""
+
param
);
}
}
}
/**
* カーソルからDtoへのコンバートです。
* 各Daoで実装します。
*
* @param cursor
* @return
*/
protected
AbstractDto
convert
(
Cursor
cursor
)
{
return
null
;
}
protected
String
generateInClause
(
List
<
Long
>
ids
)
{
StringBuffer
sbWhereCluase
=
new
StringBuffer
();
int
count
=
ids
.
size
();
sbWhereCluase
.
append
(
"("
);
if
(!
ids
.
isEmpty
())
{
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
sbWhereCluase
.
append
(
ids
.
get
(
i
));
if
(
i
<
count
-
1
)
{
sbWhereCluase
.
append
(
", "
);
}
}
}
sbWhereCluase
.
append
(
")"
);
return
sbWhereCluase
.
toString
();
}
protected
String
generateInClause
(
int
[]
ids
)
{
StringBuffer
sbWhereCluase
=
new
StringBuffer
();
int
count
=
ids
.
length
;
sbWhereCluase
.
append
(
"("
);
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
sbWhereCluase
.
append
(
ids
[
i
]);
if
(
i
<
count
-
1
)
{
sbWhereCluase
.
append
(
", "
);
}
}
sbWhereCluase
.
append
(
")"
);
return
sbWhereCluase
.
toString
();
}
/**
* vaccum処理を行う
*/
public
void
vacuum
()
{
Logger
.
i
(
TAG
,
"vacuum start."
);
dbConn
.
getDatabase
().
execSQL
(
"vacuum"
);
Logger
.
i
(
TAG
,
"vacuum end."
);
}
}
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/dao/ArchiveDao.java
View file @
b47d99f6
...
@@ -11,7 +11,7 @@ import jp.agentec.abook.abv.bl.dto.CollaborationDto;
...
@@ -11,7 +11,7 @@ import jp.agentec.abook.abv.bl.dto.CollaborationDto;
import
jp.agentec.adf.util.CollectionUtil
;
import
jp.agentec.adf.util.CollectionUtil
;
import
jp.agentec.adf.util.StringUtil
;
import
jp.agentec.adf.util.StringUtil
;
public
class
ArchiveDao
extends
AbstractDao
{
public
class
ArchiveDao
extends
Abstract
Communication
Dao
{
/**
/**
* {@link ArchiveDao} のインスタンスを初期化します。
* {@link ArchiveDao} のインスタンスを初期化します。
...
...
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/dao/ChatGroupDao.java
View file @
b47d99f6
...
@@ -10,7 +10,7 @@ import jp.agentec.abook.abv.bl.dto.GroupDto;
...
@@ -10,7 +10,7 @@ import jp.agentec.abook.abv.bl.dto.GroupDto;
import
jp.agentec.adf.util.CollectionUtil
;
import
jp.agentec.adf.util.CollectionUtil
;
import
jp.agentec.adf.util.StringUtil
;
import
jp.agentec.adf.util.StringUtil
;
public
class
ChatGroupDao
extends
AbstractDao
{
public
class
ChatGroupDao
extends
Abstract
Communication
Dao
{
private
static
final
String
TAG
=
"ChatGroupDao"
;
private
static
final
String
TAG
=
"ChatGroupDao"
;
/*package*/
ChatGroupDao
()
{
/*package*/
ChatGroupDao
()
{
...
...
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/dao/ChatMessageDao.java
View file @
b47d99f6
...
@@ -9,7 +9,7 @@ import jp.agentec.abook.abv.bl.dto.ChatMessageDto;
...
@@ -9,7 +9,7 @@ import jp.agentec.abook.abv.bl.dto.ChatMessageDto;
import
jp.agentec.abook.abv.bl.dto.ChatRoomDto
;
import
jp.agentec.abook.abv.bl.dto.ChatRoomDto
;
import
jp.agentec.adf.util.StringUtil
;
import
jp.agentec.adf.util.StringUtil
;
public
class
ChatMessageDao
extends
AbstractDao
{
public
class
ChatMessageDao
extends
Abstract
Communication
Dao
{
/**
/**
* {@link ChatMessageDao} のインスタンスを初期化します。
* {@link ChatMessageDao} のインスタンスを初期化します。
...
...
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/dao/ChatRoomDao.java
View file @
b47d99f6
...
@@ -11,7 +11,7 @@ import jp.agentec.abook.abv.bl.dto.ShopMemberDto;
...
@@ -11,7 +11,7 @@ import jp.agentec.abook.abv.bl.dto.ShopMemberDto;
import
jp.agentec.adf.util.CollectionUtil
;
import
jp.agentec.adf.util.CollectionUtil
;
import
jp.agentec.adf.util.StringUtil
;
import
jp.agentec.adf.util.StringUtil
;
public
class
ChatRoomDao
extends
AbstractDao
{
public
class
ChatRoomDao
extends
Abstract
Communication
Dao
{
/**
/**
* {@link ChatRoomDao} のインスタンスを初期化します。
* {@link ChatRoomDao} のインスタンスを初期化します。
...
...
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/dao/CollaborationDao.java
View file @
b47d99f6
...
@@ -7,7 +7,7 @@ import jp.agentec.abook.abv.bl.common.log.Logger;
...
@@ -7,7 +7,7 @@ import jp.agentec.abook.abv.bl.common.log.Logger;
import
jp.agentec.abook.abv.bl.dto.ChatMessageDto
;
import
jp.agentec.abook.abv.bl.dto.ChatMessageDto
;
import
jp.agentec.abook.abv.bl.dto.CollaborationDto
;
import
jp.agentec.abook.abv.bl.dto.CollaborationDto
;
public
class
CollaborationDao
extends
AbstractDao
{
public
class
CollaborationDao
extends
Abstract
Communication
Dao
{
/**
/**
* {@link CollaborationDao} のインスタンスを初期化します。
* {@link CollaborationDao} のインスタンスを初期化します。
...
...
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/dao/CollaborationDetailDao.java
View file @
b47d99f6
...
@@ -6,7 +6,7 @@ import jp.agentec.abook.abv.bl.common.db.Cursor;
...
@@ -6,7 +6,7 @@ import jp.agentec.abook.abv.bl.common.db.Cursor;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
jp.agentec.abook.abv.bl.dto.CollaborationDetailDto
;
import
jp.agentec.abook.abv.bl.dto.CollaborationDetailDto
;
public
class
CollaborationDetailDao
extends
AbstractDao
{
public
class
CollaborationDetailDao
extends
Abstract
Communication
Dao
{
/**
/**
* {@link CollaborationDetailDao} のインスタンスを初期化します。
* {@link CollaborationDetailDao} のインスタンスを初期化します。
...
...
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/dao/ShopMemberDao.java
View file @
b47d99f6
...
@@ -14,7 +14,7 @@ import jp.agentec.adf.util.DateTimeFormat;
...
@@ -14,7 +14,7 @@ import jp.agentec.adf.util.DateTimeFormat;
import
jp.agentec.adf.util.DateTimeUtil
;
import
jp.agentec.adf.util.DateTimeUtil
;
import
jp.agentec.adf.util.StringUtil
;
import
jp.agentec.adf.util.StringUtil
;
public
class
ShopMemberDao
extends
AbstractDao
{
public
class
ShopMemberDao
extends
Abstract
Communication
Dao
{
/**
/**
* {@link ShopMemberDao} のインスタンスを初期化します。
* {@link ShopMemberDao} のインスタンスを初期化します。
...
...
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/tables/MShopMember.java
View file @
b47d99f6
...
@@ -4,6 +4,7 @@ import java.util.ArrayList;
...
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.List
;
import
jp.agentec.abook.abv.bl.common.db.SQLiteDatabase
;
import
jp.agentec.abook.abv.bl.common.db.SQLiteDatabase
;
import
jp.agentec.abook.abv.bl.data.DatabaseVersions
;
public
class
MShopMember
extends
SQLiteTableScript
{
public
class
MShopMember
extends
SQLiteTableScript
{
...
@@ -32,7 +33,11 @@ public class MShopMember extends SQLiteTableScript {
...
@@ -32,7 +33,11 @@ public class MShopMember extends SQLiteTableScript {
@Override
@Override
public
List
<
String
>
getUpgradeScript
(
int
oldVersion
,
int
newVersion
)
{
public
List
<
String
>
getUpgradeScript
(
int
oldVersion
,
int
newVersion
)
{
return
null
;
List
<
String
>
ddl
=
new
ArrayList
<
String
>();
if
(
oldVersion
<
DatabaseVersions
.
Ver1_3_000
)
{
ddl
.
addAll
(
getCreateScript
(
newVersion
));
}
return
ddl
;
}
}
@Override
@Override
...
...
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/tables/RChatRoomShopMember.java
View file @
b47d99f6
...
@@ -3,6 +3,7 @@ package jp.agentec.abook.abv.bl.data.tables;
...
@@ -3,6 +3,7 @@ package jp.agentec.abook.abv.bl.data.tables;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
jp.agentec.abook.abv.bl.common.db.SQLiteDatabase
;
import
jp.agentec.abook.abv.bl.common.db.SQLiteDatabase
;
import
jp.agentec.abook.abv.bl.data.DatabaseVersions
;
public
class
RChatRoomShopMember
extends
SQLiteTableScript
{
public
class
RChatRoomShopMember
extends
SQLiteTableScript
{
public
RChatRoomShopMember
()
{
public
RChatRoomShopMember
()
{
...
@@ -23,7 +24,11 @@ public class RChatRoomShopMember extends SQLiteTableScript {
...
@@ -23,7 +24,11 @@ public class RChatRoomShopMember extends SQLiteTableScript {
@Override
@Override
public
List
<
String
>
getUpgradeScript
(
int
oldVersion
,
int
newVersion
)
{
public
List
<
String
>
getUpgradeScript
(
int
oldVersion
,
int
newVersion
)
{
return
null
;
List
<
String
>
ddl
=
new
ArrayList
<
String
>();
if
(
oldVersion
<
DatabaseVersions
.
Ver1_3_000
)
{
ddl
.
addAll
(
getCreateScript
(
newVersion
));
}
return
ddl
;
}
}
@Override
@Override
...
...
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/tables/RCollaborationMember.java
View file @
b47d99f6
...
@@ -4,6 +4,7 @@ import java.util.ArrayList;
...
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.List
;
import
jp.agentec.abook.abv.bl.common.db.SQLiteDatabase
;
import
jp.agentec.abook.abv.bl.common.db.SQLiteDatabase
;
import
jp.agentec.abook.abv.bl.data.DatabaseVersions
;
public
class
RCollaborationMember
extends
SQLiteTableScript
{
public
class
RCollaborationMember
extends
SQLiteTableScript
{
...
@@ -29,7 +30,11 @@ public class RCollaborationMember extends SQLiteTableScript {
...
@@ -29,7 +30,11 @@ public class RCollaborationMember extends SQLiteTableScript {
@Override
@Override
public
List
<
String
>
getUpgradeScript
(
int
oldVersion
,
int
newVersion
)
{
public
List
<
String
>
getUpgradeScript
(
int
oldVersion
,
int
newVersion
)
{
return
null
;
List
<
String
>
ddl
=
new
ArrayList
<
String
>();
if
(
oldVersion
<
DatabaseVersions
.
Ver1_3_000
)
{
ddl
.
addAll
(
getCreateScript
(
newVersion
));
}
return
ddl
;
}
}
@Override
@Override
...
...
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/tables/RShopMemberGroup.java
View file @
b47d99f6
...
@@ -4,6 +4,7 @@ import java.util.ArrayList;
...
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.List
;
import
jp.agentec.abook.abv.bl.common.db.SQLiteDatabase
;
import
jp.agentec.abook.abv.bl.common.db.SQLiteDatabase
;
import
jp.agentec.abook.abv.bl.data.DatabaseVersions
;
public
class
RShopMemberGroup
extends
SQLiteTableScript
{
public
class
RShopMemberGroup
extends
SQLiteTableScript
{
...
@@ -29,7 +30,11 @@ public class RShopMemberGroup extends SQLiteTableScript {
...
@@ -29,7 +30,11 @@ public class RShopMemberGroup extends SQLiteTableScript {
@Override
@Override
public
List
<
String
>
getUpgradeScript
(
int
oldVersion
,
int
newVersion
)
{
public
List
<
String
>
getUpgradeScript
(
int
oldVersion
,
int
newVersion
)
{
return
null
;
List
<
String
>
ddl
=
new
ArrayList
<
String
>();
if
(
oldVersion
<
DatabaseVersions
.
Ver1_3_000
)
{
ddl
.
addAll
(
getCreateScript
(
newVersion
));
}
return
ddl
;
}
}
@Override
@Override
...
...
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/tables/TChatMessage.java
View file @
b47d99f6
...
@@ -4,6 +4,7 @@ import java.util.ArrayList;
...
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.List
;
import
jp.agentec.abook.abv.bl.common.db.SQLiteDatabase
;
import
jp.agentec.abook.abv.bl.common.db.SQLiteDatabase
;
import
jp.agentec.abook.abv.bl.data.DatabaseVersions
;
public
class
TChatMessage
extends
SQLiteTableScript
{
public
class
TChatMessage
extends
SQLiteTableScript
{
...
@@ -37,7 +38,11 @@ public class TChatMessage extends SQLiteTableScript {
...
@@ -37,7 +38,11 @@ public class TChatMessage extends SQLiteTableScript {
@Override
@Override
public
List
<
String
>
getUpgradeScript
(
int
oldVersion
,
int
newVersion
)
{
public
List
<
String
>
getUpgradeScript
(
int
oldVersion
,
int
newVersion
)
{
return
null
;
List
<
String
>
ddl
=
new
ArrayList
<
String
>();
if
(
oldVersion
<
DatabaseVersions
.
Ver1_3_000
)
{
ddl
.
addAll
(
getCreateScript
(
newVersion
));
}
return
ddl
;
}
}
@Override
@Override
...
...
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/tables/TChatRoom.java
View file @
b47d99f6
...
@@ -4,6 +4,7 @@ import java.util.ArrayList;
...
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.List
;
import
jp.agentec.abook.abv.bl.common.db.SQLiteDatabase
;
import
jp.agentec.abook.abv.bl.common.db.SQLiteDatabase
;
import
jp.agentec.abook.abv.bl.data.DatabaseVersions
;
public
class
TChatRoom
extends
SQLiteTableScript
{
public
class
TChatRoom
extends
SQLiteTableScript
{
...
@@ -33,7 +34,11 @@ public class TChatRoom extends SQLiteTableScript {
...
@@ -33,7 +34,11 @@ public class TChatRoom extends SQLiteTableScript {
@Override
@Override
public
List
<
String
>
getUpgradeScript
(
int
oldVersion
,
int
newVersion
)
{
public
List
<
String
>
getUpgradeScript
(
int
oldVersion
,
int
newVersion
)
{
return
null
;
List
<
String
>
ddl
=
new
ArrayList
<
String
>();
if
(
oldVersion
<
DatabaseVersions
.
Ver1_3_000
)
{
ddl
.
addAll
(
getCreateScript
(
newVersion
));
}
return
ddl
;
}
}
@Override
@Override
...
...
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/tables/TCollaboration.java
View file @
b47d99f6
...
@@ -4,6 +4,7 @@ import java.util.ArrayList;
...
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.List
;
import
jp.agentec.abook.abv.bl.common.db.SQLiteDatabase
;
import
jp.agentec.abook.abv.bl.common.db.SQLiteDatabase
;
import
jp.agentec.abook.abv.bl.data.DatabaseVersions
;
public
class
TCollaboration
extends
SQLiteTableScript
{
public
class
TCollaboration
extends
SQLiteTableScript
{
...
@@ -28,7 +29,11 @@ public class TCollaboration extends SQLiteTableScript {
...
@@ -28,7 +29,11 @@ public class TCollaboration extends SQLiteTableScript {
@Override
@Override
public
List
<
String
>
getUpgradeScript
(
int
oldVersion
,
int
newVersion
)
{
public
List
<
String
>
getUpgradeScript
(
int
oldVersion
,
int
newVersion
)
{
return
null
;
List
<
String
>
ddl
=
new
ArrayList
<
String
>();
if
(
oldVersion
<
DatabaseVersions
.
Ver1_3_000
)
{
ddl
.
addAll
(
getCreateScript
(
newVersion
));
}
return
ddl
;
}
}
@Override
@Override
...
...
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/tables/TCollaborationDetail.java
View file @
b47d99f6
...
@@ -4,6 +4,7 @@ import java.util.ArrayList;
...
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.List
;
import
jp.agentec.abook.abv.bl.common.db.SQLiteDatabase
;
import
jp.agentec.abook.abv.bl.common.db.SQLiteDatabase
;
import
jp.agentec.abook.abv.bl.data.DatabaseVersions
;
public
class
TCollaborationDetail
extends
SQLiteTableScript
{
public
class
TCollaborationDetail
extends
SQLiteTableScript
{
...
@@ -31,7 +32,11 @@ public class TCollaborationDetail extends SQLiteTableScript {
...
@@ -31,7 +32,11 @@ public class TCollaborationDetail extends SQLiteTableScript {
@Override
@Override
public
List
<
String
>
getUpgradeScript
(
int
oldVersion
,
int
newVersion
)
{
public
List
<
String
>
getUpgradeScript
(
int
oldVersion
,
int
newVersion
)
{
return
null
;
List
<
String
>
ddl
=
new
ArrayList
<
String
>();
if
(
oldVersion
<
DatabaseVersions
.
Ver1_3_000
)
{
ddl
.
addAll
(
getCreateScript
(
newVersion
));
}
return
ddl
;
}
}
@Override
@Override
...
...
ABVJE_BL/src/jp/agentec/abook/abv/bl/logic/CommunicationLogic.java
View file @
b47d99f6
...
@@ -14,6 +14,7 @@ import java.util.stream.Collectors;
...
@@ -14,6 +14,7 @@ import java.util.stream.Collectors;
import
jp.agentec.abook.abv.bl.common.constant.ABookCommConstants
;
import
jp.agentec.abook.abv.bl.common.constant.ABookCommConstants
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
jp.agentec.abook.abv.bl.common.util.JsonUtil
;
import
jp.agentec.abook.abv.bl.common.util.JsonUtil
;
import
jp.agentec.abook.abv.bl.data.dao.AbstractCommunicationDao
;
import
jp.agentec.abook.abv.bl.data.dao.AbstractDao
;
import
jp.agentec.abook.abv.bl.data.dao.AbstractDao
;
import
jp.agentec.abook.abv.bl.data.dao.ArchiveDao
;
import
jp.agentec.abook.abv.bl.data.dao.ArchiveDao
;
import
jp.agentec.abook.abv.bl.data.dao.ChatGroupDao
;
import
jp.agentec.abook.abv.bl.data.dao.ChatGroupDao
;
...
@@ -31,7 +32,6 @@ import jp.agentec.adf.util.ArrayUtil;
...
@@ -31,7 +32,6 @@ import jp.agentec.adf.util.ArrayUtil;
import
jp.agentec.adf.util.CollectionUtil
;
import
jp.agentec.adf.util.CollectionUtil
;
import
jp.agentec.adf.util.DateTimeUtil
;
import
jp.agentec.adf.util.DateTimeUtil
;
import
jp.agentec.adf.util.StringUtil
;
import
jp.agentec.adf.util.StringUtil
;
import
sun.rmi.runtime.Log
;
/**
/**
* @author Lee-mk
* @author Lee-mk
...
@@ -39,14 +39,14 @@ import sun.rmi.runtime.Log;
...
@@ -39,14 +39,14 @@ import sun.rmi.runtime.Log;
public
class
CommunicationLogic
extends
AbstractLogic
{
public
class
CommunicationLogic
extends
AbstractLogic
{
private
static
final
String
TAG
=
"CommunicationLogic"
;
private
static
final
String
TAG
=
"CommunicationLogic"
;
private
ChatRoomDao
chatRoomDao
=
AbstractDao
.
getDao
(
ChatRoomDao
.
class
);
private
ChatRoomDao
chatRoomDao
=
Abstract
Communication
Dao
.
getDao
(
ChatRoomDao
.
class
);
private
ChatMessageDao
chatMessageDao
=
AbstractDao
.
getDao
(
ChatMessageDao
.
class
);
private
ChatMessageDao
chatMessageDao
=
Abstract
Communication
Dao
.
getDao
(
ChatMessageDao
.
class
);
private
ShopMemberDao
shopMemberDao
=
AbstractDao
.
getDao
(
ShopMemberDao
.
class
);
private
ShopMemberDao
shopMemberDao
=
Abstract
Communication
Dao
.
getDao
(
ShopMemberDao
.
class
);
private
ChatGroupDao
chatGroupDao
=
AbstractDao
.
getDao
(
ChatGroupDao
.
class
);
private
ChatGroupDao
chatGroupDao
=
Abstract
Communication
Dao
.
getDao
(
ChatGroupDao
.
class
);
private
ContentDao
contentDao
=
AbstractDao
.
getDao
(
ContentDao
.
class
);
private
ContentDao
contentDao
=
AbstractDao
.
getDao
(
ContentDao
.
class
);
private
String
localFilePath
;
private
String
localFilePath
;
private
ArchiveDao
archiveDao
=
AbstractDao
.
getDao
(
ArchiveDao
.
class
);
private
ArchiveDao
archiveDao
=
Abstract
Communication
Dao
.
getDao
(
ArchiveDao
.
class
);
/**
/**
* {@link CommunicationLogic} クラスのインスタンスを初期化します。
* {@link CommunicationLogic} クラスのインスタンスを初期化します。
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/bl/common/db/impl/CommunicationSQLiteOpenHelper.java
0 → 100644
View file @
b47d99f6
package
jp
.
agentec
.
abook
.
abv
.
bl
.
common
.
db
.
impl
;
import
android.content.Context
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.database.sqlite.SQLiteOpenHelper
;
import
jp.agentec.abook.abv.bl.common.exception.ABVRuntimeException
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
jp.agentec.abook.abv.bl.data.ABVDataOpenHelper
;
import
jp.agentec.abook.abv.bl.data.CommunicationDataOpenHelper
;
public
class
CommunicationSQLiteOpenHelper
extends
SQLiteOpenHelper
implements
jp
.
agentec
.
abook
.
abv
.
bl
.
common
.
db
.
SQLiteOpenHelper
{
private
static
final
String
TAG
=
"CommunicationSQLiteOpenHelper"
;
public
static
CommunicationDataOpenHelper
abhelper
;
private
Context
context
;
public
CommunicationSQLiteOpenHelper
(
Context
context
,
String
name
,
int
version
)
{
super
(
context
,
name
,
null
,
version
);
this
.
context
=
context
;
}
@Override
public
void
onCreate
(
SQLiteDatabase
db
)
{
abhelper
.
onCreate
(
new
StandardSQLiteDatabase
(
db
));
}
@Override
public
void
onUpgrade
(
SQLiteDatabase
db
,
int
oldVersion
,
int
newVersion
)
{
abhelper
.
onUpgrade
(
new
StandardSQLiteDatabase
(
db
),
oldVersion
,
newVersion
);
}
public
boolean
isCreated
()
{
return
abhelper
.
isCreated
();
}
public
Throwable
getLastError
()
{
return
abhelper
.
getLastError
();
}
@Override
public
StandardSQLiteDatabase
openDatabase
()
{
if
(
context
==
null
)
{
throw
new
ABVRuntimeException
(
"Android context is null. You must call init()"
);
}
abhelper
=
new
CommunicationDataOpenHelper
();
Logger
.
i
(
TAG
,
"open communication database start."
);
StandardSQLiteDatabase
db
=
new
StandardSQLiteDatabase
(
getWritableDatabase
());
// このタイミングでDBが生成され、onCreateが呼び出される
Logger
.
i
(
TAG
,
"open communication database completed."
);
if
(!
isCreated
())
{
throw
new
ABVRuntimeException
(
"Can't open or create database."
,
getLastError
());
}
return
db
;
}
}
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/util/Initializer.java
View file @
b47d99f6
...
@@ -6,10 +6,12 @@ import jp.agentec.abook.abv.bl.common.Constant;
...
@@ -6,10 +6,12 @@ import jp.agentec.abook.abv.bl.common.Constant;
import
jp.agentec.abook.abv.bl.common.Constant.AspectType
;
import
jp.agentec.abook.abv.bl.common.Constant.AspectType
;
import
jp.agentec.abook.abv.bl.common.db.SQLiteDatabase
;
import
jp.agentec.abook.abv.bl.common.db.SQLiteDatabase
;
import
jp.agentec.abook.abv.bl.common.db.SQLiteOpenHelper
;
import
jp.agentec.abook.abv.bl.common.db.SQLiteOpenHelper
;
import
jp.agentec.abook.abv.bl.common.db.impl.CommunicationSQLiteOpenHelper
;
import
jp.agentec.abook.abv.bl.common.db.impl.StandardSQLiteOpenHelper
;
import
jp.agentec.abook.abv.bl.common.db.impl.StandardSQLiteOpenHelper
;
import
jp.agentec.abook.abv.bl.common.exception.ABVException
;
import
jp.agentec.abook.abv.bl.common.exception.ABVException
;
import
jp.agentec.abook.abv.bl.common.log.LogLevel
;
import
jp.agentec.abook.abv.bl.common.log.LogLevel
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
jp.agentec.abook.abv.bl.data.CommunicationDBConnector
;
import
jp.agentec.abook.abv.bl.data.DBConnector
;
import
jp.agentec.abook.abv.bl.data.DBConnector
;
import
jp.agentec.abook.abv.cl.environment.DeviceInfo
;
import
jp.agentec.abook.abv.cl.environment.DeviceInfo
;
import
jp.agentec.abook.abv.cl.environment.NetworkAdapter
;
import
jp.agentec.abook.abv.cl.environment.NetworkAdapter
;
...
@@ -148,6 +150,7 @@ public class Initializer {
...
@@ -148,6 +150,7 @@ public class Initializer {
public
void
initDB
()
{
public
void
initDB
()
{
// DBを開く。マイグレーションがあれば実行されるようにする。
// DBを開く。マイグレーションがあれば実行されるようにする。
DBConnector
conn
=
DBConnector
.
getInstance
();
DBConnector
conn
=
DBConnector
.
getInstance
();
CommunicationDBConnector
communicationConn
=
CommunicationDBConnector
.
getInstance
();
if
(!
conn
.
isOpen
())
{
if
(!
conn
.
isOpen
())
{
Logger
.
i
(
TAG
,
"initDB start"
);
Logger
.
i
(
TAG
,
"initDB start"
);
SQLiteOpenHelper
sqlLiteOpenHelper
=
new
StandardSQLiteOpenHelper
(
context
,
DBConnector
.
DatabaseName
,
DBConnector
.
DatabaseVersion
);
SQLiteOpenHelper
sqlLiteOpenHelper
=
new
StandardSQLiteOpenHelper
(
context
,
DBConnector
.
DatabaseName
,
DBConnector
.
DatabaseVersion
);
...
@@ -156,6 +159,15 @@ public class Initializer {
...
@@ -156,6 +159,15 @@ public class Initializer {
db
.
execSQL
(
"PRAGMA foreign_keys=ON;journal_mode=WAL;synchronous=OFF;"
);
// foreign keyを有効,ジャーナルモードをWAL,書き込み非同期にする
db
.
execSQL
(
"PRAGMA foreign_keys=ON;journal_mode=WAL;synchronous=OFF;"
);
// foreign keyを有効,ジャーナルモードをWAL,書き込み非同期にする
Logger
.
i
(
TAG
,
"initDB end"
);
Logger
.
i
(
TAG
,
"initDB end"
);
}
}
if
(!
communicationConn
.
isOpen
())
{
Logger
.
i
(
TAG
,
"Comm initDB start"
);
SQLiteOpenHelper
commSqlLiteOpenHelper
=
new
CommunicationSQLiteOpenHelper
(
context
,
CommunicationDBConnector
.
DatabaseName
,
DBConnector
.
DatabaseVersion
);
communicationConn
.
setSqlLiteOpenHelper
(
commSqlLiteOpenHelper
);
SQLiteDatabase
commDb
=
conn
.
getDatabase
();
commDb
.
execSQL
(
"PRAGMA foreign_keys=ON;journal_mode=WAL;synchronous=OFF;"
);
// foreign keyを有効,ジャーナルモードをWAL,書き込み非同期にする
Logger
.
i
(
TAG
,
"Comm initDB end"
);
}
}
}
protected
String
s
(
int
id
)
{
protected
String
s
(
int
id
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment