Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
此号慢热型
o2oa
提交
82599b09
o2oa
项目概览
此号慢热型
/
o2oa
与 Fork 源项目一致
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
82599b09
编写于
5月 14, 2020
作者:
O
o2null
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'feature/entityDump' into 'develop'
更新restore See merge request o2oa/o2oa!505
上级
cfbaac02
62bb7bdd
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
39 addition
and
9 deletion
+39
-9
o2server/x_console/src/main/java/com/x/server/console/action/DumpStorage.java
...rc/main/java/com/x/server/console/action/DumpStorage.java
+39
-9
未找到文件。
o2server/x_console/src/main/java/com/x/server/console/action/DumpStorage.java
浏览文件 @
82599b09
...
...
@@ -6,6 +6,7 @@ import java.util.ArrayList;
import
java.util.Date
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Objects
;
import
javax.persistence.EntityManager
;
import
javax.persistence.EntityManagerFactory
;
...
...
@@ -24,7 +25,10 @@ import com.google.gson.Gson;
import
com.x.base.core.container.factory.PersistenceXmlHelper
;
import
com.x.base.core.entity.JpaObject
;
import
com.x.base.core.entity.StorageObject
;
import
com.x.base.core.entity.annotation.ContainerEntity
;
import
com.x.base.core.entity.annotation.ContainerEntity.Reference
;
import
com.x.base.core.project.config.Config
;
import
com.x.base.core.project.config.DumpRestoreData
;
import
com.x.base.core.project.config.StorageMapping
;
import
com.x.base.core.project.config.StorageMappings
;
import
com.x.base.core.project.gson.XGsonBuilder
;
...
...
@@ -38,13 +42,13 @@ public class DumpStorage {
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
DumpStorage
.
class
);
private
Date
start
=
new
Date
();
private
Date
start
=
new
Date
();
private
File
dir
;
private
DumpRestoreStorageCatalog
catalog
;
private
Gson
pureGsonDateFormated
=
XGsonBuilder
.
instance
();
private
Gson
pureGsonDateFormated
=
XGsonBuilder
.
instance
();
public
boolean
execute
(
String
path
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
path
))
{
...
...
@@ -60,8 +64,7 @@ public class DumpStorage {
FileUtils
.
cleanDirectory
(
this
.
dir
);
this
.
catalog
=
new
DumpRestoreStorageCatalog
();
List
<
String
>
storageContainerEntityNames
=
new
ArrayList
<>();
storageContainerEntityNames
.
addAll
((
List
<
String
>)
Config
.
resource
(
Config
.
RESOURCE_STORAGECONTAINERENTITYNAMES
));
List
<
String
>
storageContainerEntityNames
=
this
.
entities
();
List
<
String
>
classNames
=
ListTools
.
includesExcludesWildcard
(
storageContainerEntityNames
,
Config
.
dumpRestoreStorage
().
getIncludes
(),
Config
.
dumpRestoreStorage
().
getExcludes
());
logger
.
print
(
"dump storage find {} data to dump, start at {}."
,
classNames
.
size
(),
DateTools
.
format
(
start
));
...
...
@@ -153,8 +156,9 @@ public class DumpStorage {
List
<
T
>
normalList
=
null
;
List
<
T
>
emptyList
=
null
;
List
<
T
>
invalidStorageList
=
null
;
ContainerEntity
containerEntity
=
cls
.
getAnnotation
(
ContainerEntity
.
class
);
do
{
list
=
this
.
list
(
em
,
cls
,
id
,
Config
.
dumpRestoreStorage
().
getBatch
Size
());
list
=
this
.
list
(
em
,
cls
,
id
,
containerEntity
.
dump
Size
());
if
(
ListTools
.
isNotEmpty
(
list
))
{
count
+=
list
.
size
();
directory
=
new
File
(
classDirectory
,
Integer
.
toString
(
count
));
...
...
@@ -166,10 +170,10 @@ public class DumpStorage {
for
(
T
t
:
list
)
{
name
=
t
.
getStorage
();
mapping
=
storageMappings
.
get
(
cls
,
name
);
if
(
StringUtils
.
isNotEmpty
(
name
))
{
if
(
StringUtils
.
isNotEmpty
(
name
))
{
if
(
null
==
mapping
&&
Config
.
dumpRestoreStorage
().
getExceptionInvalidStorage
())
{
throw
new
Exception
(
"can not find storageMapping class: "
+
cls
.
getName
()
+
", storage: "
+
name
+
", id: "
+
t
.
getId
()
+
", name: "
+
t
.
getName
()
throw
new
Exception
(
"can not find storageMapping class: "
+
cls
.
getName
()
+
", storage: "
+
name
+
", id: "
+
t
.
getId
()
+
", name: "
+
t
.
getName
()
+
", set exceptionInvalidStorage to false will ignore item."
);
}
}
...
...
@@ -195,7 +199,6 @@ public class DumpStorage {
this
.
dumpWrite
(
file
,
normalList
,
emptyList
,
invalidStorageList
);
}
em
.
clear
();
Runtime
.
getRuntime
().
gc
();
}
while
(
ListTools
.
isNotEmpty
(
list
));
DumpRestoreStorageCatalogItem
item
=
new
DumpRestoreStorageCatalogItem
();
item
.
setCount
(
count
);
...
...
@@ -229,4 +232,31 @@ public class DumpStorage {
cq
.
select
(
root
).
where
(
p
).
orderBy
(
cb
.
asc
(
root
.
get
(
"id"
)));
return
em
.
createQuery
(
cq
).
setMaxResults
(
size
).
getResultList
();
}
/**
* 根据设置的模式不同输出需要dump的entity className
*
* @return
* @throws Exception
*/
@SuppressWarnings
(
"unchecked"
)
private
List
<
String
>
entities
()
throws
Exception
{
List
<
String
>
list
=
new
ArrayList
<>();
if
(
StringUtils
.
equals
(
Config
.
dumpRestoreData
().
getMode
(),
DumpRestoreData
.
TYPE_FULL
))
{
list
.
addAll
((
List
<
String
>)
Config
.
resource
(
Config
.
RESOURCE_CONTAINERENTITYNAMES
));
return
list
;
}
for
(
String
str
:
(
List
<
String
>)
Config
.
resource
(
Config
.
RESOURCE_CONTAINERENTITYNAMES
))
{
Class
<?>
cls
=
Class
.
forName
(
str
);
ContainerEntity
containerEntity
=
cls
.
getAnnotation
(
ContainerEntity
.
class
);
if
(
Objects
.
equals
(
containerEntity
.
reference
(),
Reference
.
strong
))
{
list
.
add
(
str
);
}
}
return
list
;
}
public
static
class
Item
{
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录