Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ghsby
o2oa
提交
2ad0061b
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,发现更多精彩内容 >>
提交
2ad0061b
编写于
11月 02, 2020
作者:
O
o2sword
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加获取实体对象的属性信息接口
上级
119cb375
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
145 addition
and
0 deletion
+145
-0
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/query/ActionGetEntityProperties.java
...emble/designer/jaxrs/query/ActionGetEntityProperties.java
+126
-0
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/query/QueryAction.java
...om/x/query/assemble/designer/jaxrs/query/QueryAction.java
+19
-0
未找到文件。
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/query/ActionGetEntityProperties.java
0 → 100644
浏览文件 @
2ad0061b
package
com.x.query.assemble.designer.jaxrs.query
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.entity.JpaObject
;
import
com.x.base.core.entity.dynamic.DynamicEntity
;
import
com.x.base.core.project.annotation.FieldDescribe
;
import
com.x.base.core.project.exception.ExceptionAccessDenied
;
import
com.x.base.core.project.exception.ExceptionEntityNotExist
;
import
com.x.base.core.project.gson.GsonPropertyObject
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.query.assemble.designer.Business
;
import
com.x.query.core.entity.schema.Statement
;
import
com.x.query.core.entity.schema.Table
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.reflect.FieldUtils
;
import
org.apache.openjpa.persistence.jdbc.Strategy
;
import
javax.persistence.Column
;
import
javax.persistence.Lob
;
import
java.lang.reflect.Field
;
import
java.util.ArrayList
;
import
java.util.List
;
class
ActionGetEntityProperties
extends
BaseAction
{
ActionResult
<
List
<
Wo
>>
execute
(
EffectivePerson
effectivePerson
,
String
entity
,
String
entityCategory
)
throws
Exception
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
ActionResult
<
List
<
Wo
>>
result
=
new
ActionResult
<>();
Business
business
=
new
Business
(
emc
);
if
(!
business
.
controllable
(
effectivePerson
))
{
throw
new
ExceptionAccessDenied
(
effectivePerson
);
}
Class
<?
extends
JpaObject
>
cls
=
this
.
clazz
(
business
,
entity
,
entityCategory
);
result
.
setData
(
this
.
getEntityDes
(
cls
,
true
,
false
));
return
result
;
}
}
private
<
T
extends
JpaObject
>
List
<
Wo
>
getEntityDes
(
Class
<
T
>
clz
,
Boolean
excludeInvisible
,
Boolean
excludeLob
){
List
<
Wo
>
wos
=
new
ArrayList
<>();
Wo
wo
=
null
;
for
(
Field
field
:
FieldUtils
.
getFieldsListWithAnnotation
(
clz
,
Column
.
class
))
{
if
(
BooleanUtils
.
isTrue
(
excludeInvisible
)
&&
JpaObject
.
FieldsInvisible
.
contains
(
field
.
getName
()))
{
continue
;
}
if
(
BooleanUtils
.
isTrue
(
excludeLob
))
{
if
(
null
!=
field
.
getAnnotation
(
Lob
.
class
))
{
continue
;
}
else
{
Strategy
strategy
=
field
.
getAnnotation
(
Strategy
.
class
);
if
((
null
!=
strategy
)
&&
StringUtils
.
equals
(
JpaObject
.
JsonPropertiesValueHandler
,
strategy
.
value
()))
{
continue
;
}
}
}
wo
=
new
Wo
();
wo
.
setName
(
field
.
getName
());
wo
.
setType
(
field
.
getType
().
getSimpleName
());
FieldDescribe
fd
=
field
.
getAnnotation
(
FieldDescribe
.
class
);
if
(
fd
!=
null
){
wo
.
setDescription
(
fd
.
value
());
}
wos
.
add
(
wo
);
}
return
wos
;
}
private
Class
<?
extends
JpaObject
>
clazz
(
Business
business
,
String
entity
,
String
entityCategory
)
throws
Exception
{
Class
<?
extends
JpaObject
>
cls
=
null
;
if
(
StringUtils
.
equals
(
Statement
.
ENTITYCATEGORY_OFFICIAL
,
entityCategory
)
||
StringUtils
.
equals
(
Statement
.
ENTITYCATEGORY_CUSTOM
,
entityCategory
))
{
try
{
cls
=
(
Class
<?
extends
JpaObject
>)
Class
.
forName
(
entity
);
}
catch
(
Exception
e
)
{
throw
new
ExceptionEntityNotExist
(
entity
,
entityCategory
);
}
}
else
{
Table
table
=
business
.
entityManagerContainer
().
flag
(
entity
,
Table
.
class
);
if
(
null
==
table
)
{
throw
new
ExceptionEntityNotExist
(
entity
,
Table
.
class
);
}
DynamicEntity
dynamicEntity
=
new
DynamicEntity
(
table
.
getName
());
try
{
cls
=
(
Class
<?
extends
JpaObject
>)
Class
.
forName
(
dynamicEntity
.
className
());
}
catch
(
Exception
e
)
{
throw
new
ExceptionEntityNotExist
(
entity
,
entityCategory
);
}
}
return
cls
;
}
public
static
class
Wo
extends
GsonPropertyObject
{
@FieldDescribe
(
"属性名称."
)
private
String
name
;
@FieldDescribe
(
"属性类型."
)
private
String
type
;
@FieldDescribe
(
"属性描述."
)
private
String
description
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
}
}
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/query/QueryAction.java
浏览文件 @
2ad0061b
...
...
@@ -215,4 +215,23 @@ public class QueryAction extends BaseAction {
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"根据标识获取语句操作对象的属性信息."
,
action
=
ActionGetEntityProperties
.
class
)
@GET
@Path
(
"entity/{entity}/category/{entityCategory}/properties"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
getEntityProperties
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
@JaxrsParameterDescribe
(
"实体类名称(系统表要全称如com.x.query.core.entity.Query,自建表只要名称)"
)
@PathParam
(
"entity"
)
String
entity
,
@JaxrsParameterDescribe
(
"实体类类型(自建表:dynamic|系统表:official)"
)
@PathParam
(
"entityCategory"
)
String
entityCategory
)
{
ActionResult
<
List
<
ActionGetEntityProperties
.
Wo
>>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
result
=
new
ActionGetEntityProperties
().
execute
(
effectivePerson
,
entity
,
entityCategory
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
result
.
error
(
e
);
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录