Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ghsby
o2oa
提交
78c682ad
o2oa
项目概览
ghsby
/
o2oa
落后 Fork 源项目 2880 个版本
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
1
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,发现更多精彩内容 >>
提交
78c682ad
编写于
9月 29, 2020
作者:
O
o2sword
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
自定义表查询允许跨表关联查询
上级
86b728f4
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
83 addition
and
10 deletion
+83
-10
o2server/x_base_core_project/src/main/java/com/x/base/core/container/factory/PersistenceXmlHelper.java
...m/x/base/core/container/factory/PersistenceXmlHelper.java
+31
-2
o2server/x_base_core_project/src/main/java/com/x/base/core/container/factory/SliceEntityManagerContainerFactory.java
...container/factory/SliceEntityManagerContainerFactory.java
+1
-1
o2server/x_base_core_project/src/main/java/com/x/base/core/entity/dynamic/DynamicBaseEntity.java
...ava/com/x/base/core/entity/dynamic/DynamicBaseEntity.java
+25
-0
o2server/x_console/src/main/java/com/x/server/console/action/DumpData.java
...e/src/main/java/com/x/server/console/action/DumpData.java
+1
-1
o2server/x_console/src/main/java/com/x/server/console/action/EraseContent.java
...c/main/java/com/x/server/console/action/EraseContent.java
+1
-1
o2server/x_console/src/main/java/com/x/server/console/action/RestoreData.java
...rc/main/java/com/x/server/console/action/RestoreData.java
+1
-1
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/statement/ActionExecute.java
...uery/assemble/designer/jaxrs/statement/ActionExecute.java
+8
-1
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/table/ActionExecute.java
.../x/query/assemble/designer/jaxrs/table/ActionExecute.java
+6
-2
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/statement/ActionExecute.java
...query/assemble/surface/jaxrs/statement/ActionExecute.java
+9
-1
未找到文件。
o2server/x_base_core_project/src/main/java/com/x/base/core/container/factory/PersistenceXmlHelper.java
浏览文件 @
78c682ad
...
...
@@ -7,11 +7,12 @@ import java.util.List;
import
java.util.Properties
;
import
com.x.base.core.container.FactorDistributionPolicy
;
import
com.x.base.core.entity.dynamic.DynamicBaseEntity
;
import
com.x.base.core.entity.JpaObject
;
import
com.x.base.core.entity.dynamic.DynamicEntity
;
import
com.x.base.core.entity.tools.JpaObjectTools
;
import
com.x.base.core.project.config.Config
;
import
com.x.base.core.project.config.Node
;
import
com.x.base.core.project.tools.Crypto
;
import
com.x.base.core.project.tools.ListTools
;
import
org.apache.commons.io.FileUtils
;
...
...
@@ -146,7 +147,7 @@ public class PersistenceXmlHelper {
property
.
addAttribute
(
"value"
,
"false"
);
}
public
static
List
<
String
>
write
(
String
path
,
List
<
String
>
entities
)
throws
Exception
{
public
static
List
<
String
>
write
(
String
path
,
List
<
String
>
entities
,
boolean
dynamicFlag
)
throws
Exception
{
List
<
String
>
names
=
new
ArrayList
<>();
String
name
=
""
;
try
{
...
...
@@ -157,6 +158,7 @@ public class PersistenceXmlHelper {
persistence
.
addAttribute
(
QName
.
get
(
"schemaLocation"
,
"xsi"
,
"http://www.w3.org/2001/XMLSchema-instance"
),
"http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
);
persistence
.
addAttribute
(
"version"
,
"2.0"
);
List
<
String
>
dyClasses
=
new
ArrayList
<>();
for
(
String
className
:
names
)
{
name
=
className
;
Class
<?
extends
JpaObject
>
clazz
=
(
Class
<
JpaObject
>)
Class
.
forName
(
className
);
...
...
@@ -170,6 +172,33 @@ public class PersistenceXmlHelper {
mapped_element
.
addText
(
o
.
getName
());
}
}
if
(
dynamicFlag
)
{
for
(
String
className
:
names
)
{
if
(
className
.
startsWith
(
DynamicEntity
.
CLASS_PACKAGE
))
{
dyClasses
.
add
(
className
);
}
}
if
(!
dyClasses
.
isEmpty
())
{
String
dyClassName
=
DynamicBaseEntity
.
class
.
getName
();
names
.
add
(
dyClassName
);
Element
unit
=
persistence
.
addElement
(
"persistence-unit"
);
unit
.
addAttribute
(
"name"
,
dyClassName
);
unit
.
addAttribute
(
"transaction-type"
,
"RESOURCE_LOCAL"
);
Element
provider
=
unit
.
addElement
(
"provider"
);
provider
.
addText
(
PersistenceProviderImpl
.
class
.
getName
());
for
(
String
dyClass
:
dyClasses
)
{
Element
mapped_element
=
unit
.
addElement
(
"class"
);
mapped_element
.
addText
(
dyClass
);
}
for
(
Class
<?>
o
:
JpaObjectTools
.
scanMappedSuperclass
(
DynamicBaseEntity
.
class
))
{
if
(!
o
.
getName
().
equals
(
DynamicBaseEntity
.
class
.
getName
()))
{
Element
mapped_element
=
unit
.
addElement
(
"class"
);
mapped_element
.
addText
(
o
.
getName
());
}
}
}
}
OutputFormat
format
=
OutputFormat
.
createPrettyPrint
();
format
.
setEncoding
(
"UTF-8"
);
File
file
=
new
File
(
path
);
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/container/factory/SliceEntityManagerContainerFactory.java
浏览文件 @
78c682ad
...
...
@@ -49,7 +49,7 @@ public abstract class SliceEntityManagerContainerFactory {
protected
SliceEntityManagerContainerFactory
(
String
webApplicationDirectory
,
List
<
String
>
entities
,
boolean
sliceFeatureEnable
)
throws
Exception
{
File
path
=
new
File
(
webApplicationDirectory
+
"/WEB-INF/classes/"
+
PERSISTENCE_XML_PATH
);
List
<
String
>
classNames
=
PersistenceXmlHelper
.
write
(
path
.
getAbsolutePath
(),
entities
);
List
<
String
>
classNames
=
PersistenceXmlHelper
.
write
(
path
.
getAbsolutePath
(),
entities
,
true
);
for
(
String
className
:
classNames
)
{
Class
<?
extends
JpaObject
>
clz
=
(
Class
<?
extends
JpaObject
>)
Class
.
forName
(
className
);
checkPersistFieldMap
.
put
(
clz
,
this
.
loadCheckPersistField
(
clz
));
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/entity/dynamic/DynamicBaseEntity.java
0 → 100644
浏览文件 @
78c682ad
package
com.x.base.core.entity.dynamic
;
import
com.x.base.core.entity.SliceJpaObject
;
public
class
DynamicBaseEntity
extends
SliceJpaObject
{
private
static
final
long
serialVersionUID
=
-
4334572608549855123L
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
private
String
id
=
createId
();
/* 以上为 JpaObject 默认字段 */
public
void
onPersist
()
throws
Exception
{
}
}
o2server/x_console/src/main/java/com/x/server/console/action/DumpData.java
浏览文件 @
78c682ad
...
...
@@ -88,7 +88,7 @@ public class DumpData {
logger
.
print
(
"find {} data to dump, start at {}."
,
classNames
.
size
(),
DateTools
.
format
(
start
));
Path
xml
=
Paths
.
get
(
Config
.
dir_local_temp_classes
().
getAbsolutePath
(),
DateTools
.
compact
(
start
)
+
"_dump.xml"
);
PersistenceXmlHelper
.
write
(
xml
.
toString
(),
classNames
);
PersistenceXmlHelper
.
write
(
xml
.
toString
(),
classNames
,
false
);
StorageMappings
storageMappings
=
Config
.
storageMappings
();
Stream
<
String
>
stream
=
BooleanUtils
.
isTrue
(
Config
.
dumpRestoreData
().
getParallel
())
?
classNames
.
parallelStream
()
...
...
o2server/x_console/src/main/java/com/x/server/console/action/EraseContent.java
浏览文件 @
78c682ad
...
...
@@ -69,7 +69,7 @@ public abstract class EraseContent {
StorageMappings
storageMappings
=
Config
.
storageMappings
();
File
persistence
=
new
File
(
Config
.
dir_local_temp_classes
(),
DateTools
.
compact
(
this
.
start
)
+
"_eraseContent.xml"
);
PersistenceXmlHelper
.
write
(
persistence
.
getAbsolutePath
(),
classNames
);
PersistenceXmlHelper
.
write
(
persistence
.
getAbsolutePath
(),
classNames
,
false
);
for
(
int
i
=
0
;
i
<
classNames
.
size
();
i
++)
{
Class
<?
extends
JpaObject
>
cls
=
(
Class
<?
extends
JpaObject
>)
Thread
.
currentThread
()
.
getContextClassLoader
().
loadClass
(
classNames
.
get
(
i
));
...
...
o2server/x_console/src/main/java/com/x/server/console/action/RestoreData.java
浏览文件 @
78c682ad
...
...
@@ -101,7 +101,7 @@ public class RestoreData {
logger
.
print
(
"find: {} data to restore, path: {}."
,
classNames
.
size
(),
this
.
dir
.
toString
());
Path
xml
=
Paths
.
get
(
Config
.
dir_local_temp_classes
().
getAbsolutePath
(),
DateTools
.
compact
(
start
)
+
"_restore.xml"
);
PersistenceXmlHelper
.
write
(
xml
.
toString
(),
classNames
);
PersistenceXmlHelper
.
write
(
xml
.
toString
(),
classNames
,
false
);
Stream
<
String
>
stream
=
BooleanUtils
.
isTrue
(
Config
.
dumpRestoreData
().
getParallel
())
?
classNames
.
parallelStream
()
:
classNames
.
stream
();
...
...
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/statement/ActionExecute.java
浏览文件 @
78c682ad
...
...
@@ -9,6 +9,7 @@ import javax.script.Bindings;
import
javax.script.ScriptContext
;
import
javax.script.SimpleScriptContext
;
import
com.x.base.core.entity.dynamic.DynamicBaseEntity
;
import
org.apache.commons.lang3.StringUtils
;
import
com.google.gson.JsonElement
;
...
...
@@ -95,7 +96,13 @@ class ActionExecute extends BaseAction {
throws
Exception
{
Object
data
=
null
;
Class
<?
extends
JpaObject
>
cls
=
this
.
clazz
(
business
,
statement
);
EntityManager
em
=
business
.
entityManagerContainer
().
get
(
cls
);
EntityManager
em
;
if
(
StringUtils
.
equalsIgnoreCase
(
statement
.
getEntityCategory
(),
Statement
.
ENTITYCATEGORY_DYNAMIC
)
&&
StringUtils
.
equalsIgnoreCase
(
statement
.
getType
(),
Statement
.
TYPE_SELECT
)){
em
=
business
.
entityManagerContainer
().
get
(
DynamicBaseEntity
.
class
);
}
else
{
em
=
business
.
entityManagerContainer
().
get
(
cls
);
}
Query
query
=
em
.
createQuery
(
statement
.
getData
());
for
(
Parameter
<?>
p
:
query
.
getParameters
())
{
if
(
runtime
.
hasParameter
(
p
.
getName
()))
{
...
...
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/table/ActionExecute.java
浏览文件 @
78c682ad
...
...
@@ -3,6 +3,7 @@ package com.x.query.assemble.designer.jaxrs.table;
import
javax.persistence.EntityManager
;
import
javax.persistence.Query
;
import
com.x.base.core.entity.dynamic.DynamicBaseEntity
;
import
org.apache.commons.lang3.StringUtils
;
import
com.google.gson.JsonElement
;
...
...
@@ -36,10 +37,11 @@ class ActionExecute extends BaseAction {
DynamicEntity
dynamicEntity
=
new
DynamicEntity
(
table
.
getName
());
@SuppressWarnings
(
"unchecked"
)
Class
<?
extends
JpaObject
>
cls
=
(
Class
<
JpaObject
>)
Class
.
forName
(
dynamicEntity
.
className
());
EntityManager
em
=
emc
.
get
(
cls
);
Query
query
=
em
.
createQuery
(
wi
.
getData
());
Object
data
=
null
;
if
(
StringUtils
.
equalsIgnoreCase
(
wi
.
getType
(),
Statement
.
TYPE_SELECT
))
{
EntityManager
em
=
emc
.
get
(
DynamicBaseEntity
.
class
);
Query
query
=
em
.
createQuery
(
wi
.
getData
());
if
((
null
!=
wi
.
getMaxResults
())
&&
(
wi
.
getMaxResults
()
>
0
))
{
query
.
setMaxResults
(
wi
.
getMaxResults
());
}
...
...
@@ -48,6 +50,8 @@ class ActionExecute extends BaseAction {
}
data
=
query
.
getResultList
();
}
else
{
EntityManager
em
=
emc
.
get
(
cls
);
Query
query
=
em
.
createQuery
(
wi
.
getData
());
emc
.
beginTransaction
(
cls
);
data
=
query
.
executeUpdate
();
emc
.
commit
();
...
...
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/statement/ActionExecute.java
浏览文件 @
78c682ad
...
...
@@ -10,6 +10,7 @@ import javax.script.CompiledScript;
import
javax.script.ScriptContext
;
import
javax.script.SimpleScriptContext
;
import
com.x.base.core.entity.dynamic.DynamicBaseEntity
;
import
org.apache.commons.lang3.StringUtils
;
import
com.google.gson.JsonElement
;
...
...
@@ -132,7 +133,14 @@ class ActionExecute extends BaseAction {
throws
Exception
{
Object
data
=
null
;
Class
<?
extends
JpaObject
>
cls
=
this
.
clazz
(
business
,
statement
);
EntityManager
em
=
business
.
entityManagerContainer
().
get
(
cls
);
EntityManager
em
;
if
(
StringUtils
.
equalsIgnoreCase
(
statement
.
getEntityCategory
(),
Statement
.
ENTITYCATEGORY_DYNAMIC
)
&&
StringUtils
.
equalsIgnoreCase
(
statement
.
getType
(),
Statement
.
TYPE_SELECT
)){
em
=
business
.
entityManagerContainer
().
get
(
DynamicBaseEntity
.
class
);
}
else
{
em
=
business
.
entityManagerContainer
().
get
(
cls
);
}
Query
query
=
em
.
createQuery
(
statement
.
getData
());
for
(
Parameter
<?>
p
:
query
.
getParameters
())
{
if
(
runtime
.
hasParameter
(
p
.
getName
()))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录