Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
此号慢热型
o2oa
提交
c86de453
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,体验更适合开发者的 AI 搜索 >>
提交
c86de453
编写于
5月 19, 2020
作者:
L
luojing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
teamwork后台服务
上级
9673ac90
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
1593 addition
and
0 deletion
+1593
-0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/factory/ProjectConfigFactory.java
...amwork/assemble/control/factory/ProjectConfigFactory.java
+230
-0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/global/ActionListProjectConfigNextWithFilter.java
...l/jaxrs/global/ActionListProjectConfigNextWithFilter.java
+140
-0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/global/ActionProjectConfigDelete.java
...emble/control/jaxrs/global/ActionProjectConfigDelete.java
+70
-0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/global/ActionProjectConfigGet.java
...assemble/control/jaxrs/global/ActionProjectConfigGet.java
+79
-0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/global/ActionProjectConfigGetByProject.java
...control/jaxrs/global/ActionProjectConfigGetByProject.java
+83
-0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/global/ActionProjectConfigSave.java
...ssemble/control/jaxrs/global/ActionProjectConfigSave.java
+61
-0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/global/ProjectConfigFlagForQueryEmptyException.java
...jaxrs/global/ProjectConfigFlagForQueryEmptyException.java
+12
-0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/global/ProjectConfigNotExistsException.java
...control/jaxrs/global/ProjectConfigNotExistsException.java
+12
-0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/global/ProjectConfigPersistException.java
...e/control/jaxrs/global/ProjectConfigPersistException.java
+20
-0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/global/ProjectConfigQueryException.java
...ble/control/jaxrs/global/ProjectConfigQueryException.java
+16
-0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/global/WrapInQueryProjectConfig.java
...semble/control/jaxrs/global/WrapInQueryProjectConfig.java
+223
-0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/service/ProjectConfigPersistService.java
...assemble/control/service/ProjectConfigPersistService.java
+140
-0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/service/ProjectConfigQueryService.java
...k/assemble/control/service/ProjectConfigQueryService.java
+227
-0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/service/ProjectConfigService.java
...amwork/assemble/control/service/ProjectConfigService.java
+280
-0
未找到文件。
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/factory/ProjectConfigFactory.java
0 → 100644
浏览文件 @
c86de453
package
com.x.teamwork.assemble.control.factory
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.persistence.EntityManager
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Order
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
org.apache.commons.lang3.StringUtils
;
import
com.x.base.core.project.exception.ExceptionWhen
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.teamwork.assemble.control.AbstractFactory
;
import
com.x.teamwork.assemble.control.Business
;
import
com.x.teamwork.core.entity.Dynamic_
;
import
com.x.teamwork.core.entity.Priority
;
import
com.x.teamwork.core.entity.Priority_
;
import
com.x.teamwork.core.entity.Project
;
import
com.x.teamwork.core.entity.ProjectConfig
;
import
com.x.teamwork.core.entity.ProjectConfig_
;
import
com.x.teamwork.core.entity.ProjectGroup
;
import
com.x.teamwork.core.entity.ProjectGroup_
;
import
com.x.teamwork.core.entity.Project_
;
import
com.x.teamwork.core.entity.tools.CriteriaBuilderTools
;
import
com.x.teamwork.core.entity.tools.filter.QueryFilter
;
public
class
ProjectConfigFactory
extends
AbstractFactory
{
public
ProjectConfigFactory
(
Business
business
)
throws
Exception
{
super
(
business
);
}
/**
* 获取指定Id的ProjectGroup实体信息对象
* @param id
* @return
* @throws Exception
*/
public
ProjectConfig
get
(
String
id
)
throws
Exception
{
return
this
.
entityManagerContainer
().
find
(
id
,
ProjectConfig
.
class
,
ExceptionWhen
.
none
);
}
/**
* 获取指定name的优先级实体信息对象
* @param name
* @return
* @throws Exception
*/
public
List
<
Priority
>
getByName
(
String
name
)
throws
Exception
{
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
Priority
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Priority
>
cq
=
cb
.
createQuery
(
Priority
.
class
);
Root
<
Priority
>
root
=
cq
.
from
(
Priority
.
class
);
Predicate
p
=
cb
.
equal
(
root
.
get
(
Priority_
.
priority
),
name
);
return
em
.
createQuery
(
cq
.
where
(
p
)).
getResultList
();
}
/**
* 列示指定Id的ProjectGroup实体信息列表
* @param ids
* @return
* @throws Exception
*/
public
List
<
Priority
>
listPriority
()
throws
Exception
{
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
Priority
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Priority
>
cq
=
cb
.
createQuery
(
Priority
.
class
);
Root
<
Priority
>
root
=
cq
.
from
(
Priority
.
class
);
//Predicate p = cb.equal( root.get(Priority_.owner), person );
cq
.
orderBy
(
cb
.
asc
(
root
.
get
(
Priority_
.
order
)
)
);
return
em
.
createQuery
(
cq
).
getResultList
();
}
/**
* 根据用户列示ProjectGroup实体信息列表
* @param person
* @return
* @throws Exception
*/
public
List
<
String
>
listByPerson
(
String
person
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
person
)
){
throw
new
Exception
(
"person can not be empty!"
);
}
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
ProjectGroup
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
String
>
cq
=
cb
.
createQuery
(
String
.
class
);
Root
<
ProjectGroup
>
root
=
cq
.
from
(
ProjectGroup
.
class
);
Predicate
p
=
cb
.
equal
(
root
.
get
(
ProjectGroup_
.
owner
),
person
);
cq
.
select
(
root
.
get
(
ProjectGroup_
.
id
)
);
return
em
.
createQuery
(
cq
.
where
(
p
)).
getResultList
();
}
/**
* 根据用户列示Priority实体信息列表
* @param person
* @return
* @throws Exception
*/
public
List
<
Priority
>
listPriorityByPerson
(
String
person
)
throws
Exception
{
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
Priority
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Priority
>
cq
=
cb
.
createQuery
(
Priority
.
class
);
Root
<
Priority
>
root
=
cq
.
from
(
Priority
.
class
);
//Predicate p = cb.equal( root.get(Priority_.owner), person );
cq
.
orderBy
(
cb
.
desc
(
root
.
get
(
Priority_
.
order
)
)
);
return
em
.
createQuery
(
cq
).
getResultList
();
}
/**
* 根据条件查询所有符合条件的项目配置信息ID,项目配置信息不会很多 ,所以直接查询出来
* @param maxCount
* @param sequenceFieldValue
* @param orderField
* @param orderType
* @param personName
* @param queryFilter
* @return
* @throws Exception
*/
public
List
<
String
>
listAllProjectConfigIds
(
Integer
maxCount
,
String
personName
,
QueryFilter
queryFilter
)
throws
Exception
{
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
ProjectConfig
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
String
>
cq
=
cb
.
createQuery
(
String
.
class
);
Root
<
ProjectConfig
>
root
=
cq
.
from
(
ProjectConfig
.
class
);
Predicate
p_permission
=
null
;
/*if( StringUtils.isNotEmpty( personName )) {
//可以管理的栏目,肯定可以发布信息
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, cb.isMember( personName, root.get( Project_.participantPersonList )) );
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, cb.isMember( personName, root.get( Project_.manageablePersonList )) );
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, cb.equal( root.get( Project_.creatorPerson ), personName ) );
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, cb.equal( root.get( Project_.executor ), personName ) );
}*/
Predicate
p
=
CriteriaBuilderTools
.
composePredicateWithQueryFilter
(
ProjectConfig_
.
class
,
cb
,
p_permission
,
root
,
queryFilter
);
cq
.
distinct
(
true
).
select
(
root
.
get
(
ProjectConfig_
.
id
)
);
return
em
.
createQuery
(
cq
.
where
(
p
)).
setMaxResults
(
maxCount
).
getResultList
();
}
/**
* 根据条件查询符合条件的项目信息ID
* @param maxCount
* @param orderField
* @param orderType
* @param personName
* @param identityNames
* @param unitNames
* @param groupNames
* @param queryFilter
* @return
* @throws Exception
*/
public
List
<
ProjectConfig
>
listWithFilter
(
Integer
maxCount
,
String
orderField
,
String
orderType
,
String
personName
,
List
<
String
>
identityNames
,
List
<
String
>
unitNames
,
List
<
String
>
groupNames
,
QueryFilter
queryFilter
)
throws
Exception
{
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
ProjectConfig
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
ProjectConfig
>
cq
=
cb
.
createQuery
(
ProjectConfig
.
class
);
Root
<
ProjectConfig
>
root
=
cq
.
from
(
ProjectConfig
.
class
);
Predicate
p_permission
=
null
;
Predicate
p
=
CriteriaBuilderTools
.
composePredicateWithQueryFilter
(
ProjectConfig_
.
class
,
cb
,
p_permission
,
root
,
queryFilter
);
Order
orderWithField
=
CriteriaBuilderTools
.
getOrder
(
cb
,
root
,
ProjectConfig_
.
class
,
orderField
,
orderType
);
if
(
orderWithField
!=
null
){
cq
.
orderBy
(
orderWithField
);
}
return
em
.
createQuery
(
cq
.
where
(
p
)).
setMaxResults
(
maxCount
).
getResultList
();
}
/**
* 根据条件查询符合条件的项目信息ID,根据上一条的sequnce查询指定数量的信息
* @param maxCount
* @param sequenceFieldValue
* @param orderField
* @param orderType
* @param personName
* @param identityNames
* @param unitNames
* @param groupNames
* @param queryFilter
* @return
* @throws Exception
*/
public
List
<
ProjectConfig
>
listWithFilter
(
Integer
maxCount
,
Object
sequenceFieldValue
,
String
orderField
,
String
orderType
,
String
personName
,
List
<
String
>
identityNames
,
List
<
String
>
unitNames
,
List
<
String
>
groupNames
,
QueryFilter
queryFilter
)
throws
Exception
{
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
ProjectConfig
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
ProjectConfig
>
cq
=
cb
.
createQuery
(
ProjectConfig
.
class
);
Root
<
ProjectConfig
>
root
=
cq
.
from
(
ProjectConfig
.
class
);
Predicate
p_permission
=
null
;
Predicate
p
=
CriteriaBuilderTools
.
composePredicateWithQueryFilter
(
ProjectConfig_
.
class
,
cb
,
p_permission
,
root
,
queryFilter
);
if
(
sequenceFieldValue
!=
null
&&
StringUtils
.
isNotEmpty
(
sequenceFieldValue
.
toString
()
))
{
Predicate
p_seq
=
cb
.
isNotNull
(
root
.
get
(
Dynamic_
.
sequence
)
);
if
(
"desc"
.
equalsIgnoreCase
(
orderType
)){
p_seq
=
cb
.
and
(
p_seq
,
cb
.
lessThan
(
root
.
get
(
ProjectConfig_
.
sequence
),
sequenceFieldValue
.
toString
()
));
}
else
{
p_seq
=
cb
.
and
(
p_seq
,
cb
.
greaterThan
(
root
.
get
(
ProjectConfig_
.
sequence
),
sequenceFieldValue
.
toString
()
));
}
p
=
cb
.
and
(
p
,
p_seq
);
}
Order
orderWithField
=
CriteriaBuilderTools
.
getOrder
(
cb
,
root
,
ProjectConfig_
.
class
,
orderField
,
orderType
);
if
(
orderWithField
!=
null
){
cq
.
orderBy
(
orderWithField
);
}
System
.
out
.
println
(
">>>SQL:"
+
em
.
createQuery
(
cq
.
where
(
p
)).
setMaxResults
(
maxCount
).
toString
()
);
return
em
.
createQuery
(
cq
.
where
(
p
)).
setMaxResults
(
maxCount
).
getResultList
();
}
/**
* 获取指定name的优先级实体信息对象
* @param name
* @return
* @throws Exception
*/
public
List
<
ProjectConfig
>
getProjectConfigByProject
(
String
name
)
throws
Exception
{
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
ProjectConfig
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
ProjectConfig
>
cq
=
cb
.
createQuery
(
ProjectConfig
.
class
);
Root
<
ProjectConfig
>
root
=
cq
.
from
(
ProjectConfig
.
class
);
Predicate
p
=
cb
.
equal
(
root
.
get
(
ProjectConfig_
.
project
),
name
);
return
em
.
createQuery
(
cq
.
where
(
p
)).
getResultList
();
}
}
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/global/ActionListProjectConfigNextWithFilter.java
0 → 100644
浏览文件 @
c86de453
package
com.x.teamwork.assemble.control.jaxrs.global
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
org.apache.commons.lang3.StringUtils
;
import
com.google.gson.JsonElement
;
import
com.x.base.core.entity.JpaObject
;
import
com.x.base.core.project.bean.WrapCopier
;
import
com.x.base.core.project.bean.WrapCopierFactory
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.teamwork.core.entity.tools.filter.QueryFilter
;
import
com.x.teamwork.core.entity.ProjectConfig
;
public
class
ActionListProjectConfigNextWithFilter
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionListProjectConfigNextWithFilter
.
class
);
protected
ActionResult
<
List
<
Wo
>>
execute
(
HttpServletRequest
request
,
EffectivePerson
effectivePerson
,
String
flag
,
Integer
count
,
JsonElement
jsonElement
)
throws
Exception
{
ActionResult
<
List
<
Wo
>>
result
=
new
ActionResult
<>();
ResultObject
resultObject
=
null
;
List
<
Wo
>
wos
=
new
ArrayList
<>();
Wi
wrapIn
=
null
;
Boolean
check
=
true
;
QueryFilter
queryFilter
=
null
;
if
(
StringUtils
.
isEmpty
(
flag
)
||
"(0)"
.
equals
(
flag
))
{
flag
=
null
;
}
try
{
wrapIn
=
this
.
convertToWrapIn
(
jsonElement
,
Wi
.
class
);
}
catch
(
Exception
e
)
{
check
=
false
;
Exception
exception
=
new
ProjectConfigQueryException
(
e
,
"系统在将JSON信息转换为对象时发生异常。JSON:"
+
jsonElement
.
toString
());
result
.
error
(
exception
);
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
}
if
(
Boolean
.
TRUE
.
equals
(
check
)
){
if
(
wrapIn
==
null
)
{
wrapIn
=
new
Wi
();
}
queryFilter
=
wrapIn
.
getQueryFilter
();
}
if
(
Boolean
.
TRUE
.
equals
(
check
)
){
/*采用缓存
* cacheKey = ApplicationCache.concreteCacheKey( "ActionListNextWithFilter", effectivePerson.getDistinguishedName(), flag, count,
wrapIn.getOrderField(), wrapIn.getOrderType(), queryFilter.getContentSHA1() );
element = projectCache.get( cacheKey );
if ((null != element) && (null != element.getObjectValue())) {
resultObject = (ResultObject) element.getObjectValue();
result.setCount( resultObject.getTotal() );
result.setData( resultObject.getWos() );
} else {*/
try
{
//获取用户能查看的所有的项目信息ID列表,最多查询2000条数据
List
<
String
>
projectConfigIds
=
projectConfigQueryService
.
listAllProjectConfigIds
(
effectivePerson
,
2000
,
queryFilter
);
if
(
ListTools
.
isNotEmpty
(
projectConfigIds
))
{
//直接根据可见项目ID列表进行分页查询
Long
total
=
Long
.
parseLong
(
projectConfigIds
.
size
()
+
""
);
List
<
ProjectConfig
>
projectConfigList
=
projectConfigQueryService
.
listWithProjectConfigIdFilter
(
count
,
flag
,
wrapIn
.
getOrderField
(),
wrapIn
.
getOrderType
(),
projectConfigIds
);
if
(
ListTools
.
isNotEmpty
(
projectConfigList
))
{
for
(
ProjectConfig
projectConfig
:
projectConfigList
)
{
Wo
wo
=
Wo
.
copier
.
copy
(
projectConfig
);
wos
.
add
(
wo
);
}
}
resultObject
=
new
ResultObject
(
total
,
wos
);
//projectCache.put(new Element( cacheKey, resultObject ));
result
.
setCount
(
resultObject
.
getTotal
()
);
result
.
setData
(
resultObject
.
getWos
()
);
}
}
catch
(
Exception
e
)
{
check
=
false
;
logger
.
warn
(
"系统查询项目配置信息列表时发生异常!"
);
result
.
error
(
e
);
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
}
//}
}
return
result
;
}
public
static
class
Wi
extends
WrapInQueryProjectConfig
{
}
public
static
class
Wo
extends
ProjectConfig
{
private
static
final
long
serialVersionUID
=
-
5076990764713538973L
;
public
static
List
<
String
>
Excludes
=
new
ArrayList
<
String
>();
static
WrapCopier
<
ProjectConfig
,
Wo
>
copier
=
WrapCopierFactory
.
wo
(
ProjectConfig
.
class
,
Wo
.
class
,
null
,
ListTools
.
toList
(
JpaObject
.
FieldsInvisible
));
}
public
static
class
ResultObject
{
private
Long
total
;
private
List
<
Wo
>
wos
;
public
ResultObject
()
{}
public
ResultObject
(
Long
count
,
List
<
Wo
>
data
)
{
this
.
total
=
count
;
this
.
wos
=
data
;
}
public
Long
getTotal
()
{
return
total
;
}
public
void
setTotal
(
Long
total
)
{
this
.
total
=
total
;
}
public
List
<
Wo
>
getWos
()
{
return
wos
;
}
public
void
setWos
(
List
<
Wo
>
wos
)
{
this
.
wos
=
wos
;
}
}
}
\ No newline at end of file
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/global/ActionProjectConfigDelete.java
0 → 100644
浏览文件 @
c86de453
package
com.x.teamwork.assemble.control.jaxrs.global
;
import
javax.servlet.http.HttpServletRequest
;
import
org.apache.commons.lang3.StringUtils
;
import
com.x.base.core.project.cache.ApplicationCache
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.jaxrs.WoId
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.teamwork.core.entity.ProjectConfig
;
public
class
ActionProjectConfigDelete
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionProjectConfigDelete
.
class
);
protected
ActionResult
<
Wo
>
execute
(
HttpServletRequest
request
,
EffectivePerson
effectivePerson
,
String
flag
)
throws
Exception
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
ProjectConfig
projectConfig
=
null
;
Boolean
check
=
true
;
Wo
wo
=
new
Wo
();
if
(
StringUtils
.
isEmpty
(
flag
)
)
{
check
=
false
;
Exception
exception
=
new
ProjectConfigFlagForQueryEmptyException
();
result
.
error
(
exception
);
}
if
(
Boolean
.
TRUE
.
equals
(
check
)
){
try
{
projectConfig
=
projectConfigQueryService
.
get
(
flag
);
if
(
projectConfig
==
null
)
{
check
=
false
;
Exception
exception
=
new
ProjectConfigNotExistsException
(
flag
);
result
.
error
(
exception
);
}
}
catch
(
Exception
e
)
{
check
=
false
;
Exception
exception
=
new
ProjectConfigQueryException
(
e
,
"根据指定flag查询项目配置信息对象时发生异常。flag:"
+
flag
);
result
.
error
(
exception
);
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
}
}
if
(
Boolean
.
TRUE
.
equals
(
check
)
){
try
{
projectConfigPersistService
.
delete
(
flag
,
effectivePerson
);
// 更新缓存
ApplicationCache
.
notify
(
ProjectConfig
.
class
);
wo
.
setId
(
projectConfig
.
getId
()
);
}
catch
(
Exception
e
)
{
check
=
false
;
Exception
exception
=
new
ProjectConfigQueryException
(
e
,
"根据指定flag删除项目配置信息对象时发生异常。flag:"
+
flag
);
result
.
error
(
exception
);
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
}
}
result
.
setData
(
wo
);
return
result
;
}
public
static
class
Wo
extends
WoId
{
}
}
\ No newline at end of file
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/global/ActionProjectConfigGet.java
0 → 100644
浏览文件 @
c86de453
package
com.x.teamwork.assemble.control.jaxrs.global
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
org.apache.commons.lang3.StringUtils
;
import
com.x.base.core.entity.JpaObject
;
import
com.x.base.core.project.bean.WrapCopier
;
import
com.x.base.core.project.bean.WrapCopierFactory
;
import
com.x.base.core.project.cache.ApplicationCache
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.teamwork.core.entity.Priority
;
import
com.x.teamwork.core.entity.ProjectConfig
;
import
com.x.teamwork.core.entity.ProjectGroup
;
import
net.sf.ehcache.Element
;
public
class
ActionProjectConfigGet
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionProjectConfigGet
.
class
);
protected
ActionResult
<
Wo
>
execute
(
HttpServletRequest
request
,
EffectivePerson
effectivePerson
,
String
id
)
throws
Exception
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Wo
wo
=
null
;
ProjectConfig
projectConfig
=
null
;
Boolean
check
=
true
;
if
(
StringUtils
.
isEmpty
(
id
)
)
{
check
=
false
;
Exception
exception
=
new
PriorityFlagForQueryEmptyException
();
result
.
error
(
exception
);
}
if
(
Boolean
.
TRUE
.
equals
(
check
)
){
try
{
projectConfig
=
projectConfigQueryService
.
get
(
id
);
if
(
projectConfig
==
null
)
{
check
=
false
;
Exception
exception
=
new
ProjectConfigNotExistsException
(
id
);
result
.
error
(
exception
);
}
}
catch
(
Exception
e
)
{
check
=
false
;
Exception
exception
=
new
ProjectConfigQueryException
(
e
,
"根据指定flag查询项目配置信息对象时发生异常。id:"
+
id
);
result
.
error
(
exception
);
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
}
}
if
(
Boolean
.
TRUE
.
equals
(
check
)
){
try
{
wo
=
Wo
.
copier
.
copy
(
projectConfig
);
result
.
setData
(
wo
);
}
catch
(
Exception
e
)
{
Exception
exception
=
new
ProjectConfigQueryException
(
e
,
"将查询出来的项目配置信息对象转换为可输出的数据信息时发生异常。"
);
result
.
error
(
exception
);
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
}
}
return
result
;
}
public
static
class
Wo
extends
ProjectConfig
{
private
static
final
long
serialVersionUID
=
-
5076990764713538973L
;
public
static
List
<
String
>
Excludes
=
new
ArrayList
<
String
>();
static
WrapCopier
<
ProjectConfig
,
Wo
>
copier
=
WrapCopierFactory
.
wo
(
ProjectConfig
.
class
,
Wo
.
class
,
null
,
ListTools
.
toList
(
JpaObject
.
FieldsInvisible
));
}
}
\ No newline at end of file
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/global/ActionProjectConfigGetByProject.java
0 → 100644
浏览文件 @
c86de453
package
com.x.teamwork.assemble.control.jaxrs.global
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
org.apache.commons.lang3.StringUtils
;
import
com.x.base.core.entity.JpaObject
;
import
com.x.base.core.project.bean.WrapCopier
;
import
com.x.base.core.project.bean.WrapCopierFactory
;
import
com.x.base.core.project.cache.ApplicationCache
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.teamwork.core.entity.Priority
;
import
com.x.teamwork.core.entity.ProjectConfig
;
import
com.x.teamwork.core.entity.ProjectGroup
;
import
net.sf.ehcache.Element
;
public
class
ActionProjectConfigGetByProject
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionProjectConfigGetByProject
.
class
);
protected
ActionResult
<
Wo
>
execute
(
HttpServletRequest
request
,
EffectivePerson
effectivePerson
,
String
id
)
throws
Exception
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Wo
wo
=
null
;
ProjectConfig
projectConfig
=
null
;
List
<
ProjectConfig
>
projectConfigs
=
null
;
Boolean
check
=
true
;
if
(
StringUtils
.
isEmpty
(
id
)
)
{
check
=
false
;
Exception
exception
=
new
PriorityFlagForQueryEmptyException
();
result
.
error
(
exception
);
}
if
(
Boolean
.
TRUE
.
equals
(
check
)
){
try
{
projectConfigs
=
projectConfigQueryService
.
getProjectConfigByProject
(
id
);
if
(
ListTools
.
isNotEmpty
(
projectConfigs
)){
projectConfig
=
projectConfigs
.
get
(
0
);
}
if
(
projectConfig
==
null
)
{
check
=
false
;
Exception
exception
=
new
ProjectConfigNotExistsException
(
id
);
result
.
error
(
exception
);
}
}
catch
(
Exception
e
)
{
check
=
false
;
Exception
exception
=
new
ProjectConfigQueryException
(
e
,
"根据指定flag查询项目配置信息对象时发生异常。id:"
+
id
);
result
.
error
(
exception
);
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
}
}
if
(
Boolean
.
TRUE
.
equals
(
check
)
){
try
{
wo
=
Wo
.
copier
.
copy
(
projectConfig
);
result
.
setData
(
wo
);
}
catch
(
Exception
e
)
{
Exception
exception
=
new
ProjectConfigQueryException
(
e
,
"将查询出来的项目配置信息对象转换为可输出的数据信息时发生异常。"
);
result
.
error
(
exception
);
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
}
}
return
result
;
}
public
static
class
Wo
extends
ProjectConfig
{
private
static
final
long
serialVersionUID
=
-
5076990764713538973L
;
public
static
List
<
String
>
Excludes
=
new
ArrayList
<
String
>();
static
WrapCopier
<
ProjectConfig
,
Wo
>
copier
=
WrapCopierFactory
.
wo
(
ProjectConfig
.
class
,
Wo
.
class
,
null
,
ListTools
.
toList
(
JpaObject
.
FieldsInvisible
));
}
}
\ No newline at end of file
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/global/ActionProjectConfigSave.java
0 → 100644
浏览文件 @
c86de453
package
com.x.teamwork.assemble.control.jaxrs.global
;
import
javax.servlet.http.HttpServletRequest
;
import
com.google.gson.JsonElement
;
import
com.x.base.core.project.bean.WrapCopier
;
import
com.x.base.core.project.bean.WrapCopierFactory
;
import
com.x.base.core.project.cache.ApplicationCache
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.jaxrs.WoId
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.teamwork.core.entity.ProjectConfig
;
public
class
ActionProjectConfigSave
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionProjectConfigSave
.
class
);
protected
ActionResult
<
Wo
>
execute
(
HttpServletRequest
request
,
EffectivePerson
effectivePerson
,
JsonElement
jsonElement
)
throws
Exception
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
ProjectConfig
projectConfig
=
null
;
Wi
wi
=
null
;
Wo
wo
=
new
Wo
();
try
{
wi
=
this
.
convertToWrapIn
(
jsonElement
,
Wi
.
class
);
}
catch
(
Exception
e
)
{
Exception
exception
=
new
PriorityPersistException
(
e
,
"系统在将JSON信息转换为对象时发生异常。JSON:"
+
jsonElement
.
toString
());
result
.
error
(
exception
);
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
}
try
{
projectConfig
=
projectConfigPersistService
.
save
(
wi
,
effectivePerson
);
// 更新缓存
ApplicationCache
.
notify
(
ProjectConfig
.
class
);
wo
.
setId
(
projectConfig
.
getId
()
);
}
catch
(
Exception
e
)
{
Exception
exception
=
new
PriorityPersistException
(
e
,
"项目配置信息保存时发生异常。"
);
result
.
error
(
exception
);
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
}
result
.
setData
(
wo
);
return
result
;
}
public
static
class
Wi
extends
ProjectConfig
{
private
static
final
long
serialVersionUID
=
-
6314932919066148113L
;
public
static
WrapCopier
<
Wi
,
ProjectConfig
>
copier
=
WrapCopierFactory
.
wi
(
Wi
.
class
,
ProjectConfig
.
class
,
null
,
null
);
}
public
static
class
Wo
extends
WoId
{
}
}
\ No newline at end of file
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/global/ProjectConfigFlagForQueryEmptyException.java
0 → 100644
浏览文件 @
c86de453
package
com.x.teamwork.assemble.control.jaxrs.global
;
import
com.x.base.core.project.exception.PromptException
;
class
ProjectConfigFlagForQueryEmptyException
extends
PromptException
{
private
static
final
long
serialVersionUID
=
1859164370743532895L
;
ProjectConfigFlagForQueryEmptyException
()
{
super
(
"查询的项目配置信息ID为空,无法继续查询数据。"
);
}
}
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/global/ProjectConfigNotExistsException.java
0 → 100644
浏览文件 @
c86de453
package
com.x.teamwork.assemble.control.jaxrs.global
;
import
com.x.base.core.project.exception.PromptException
;
class
ProjectConfigNotExistsException
extends
PromptException
{
private
static
final
long
serialVersionUID
=
1859164370743532895L
;
ProjectConfigNotExistsException
(
String
id
)
{
super
(
"指定ID的项目配置信息不存在。ID:"
+
id
);
}
}
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/global/ProjectConfigPersistException.java
0 → 100644
浏览文件 @
c86de453
package
com.x.teamwork.assemble.control.jaxrs.global
;
import
com.x.base.core.project.exception.PromptException
;
class
ProjectConfigPersistException
extends
PromptException
{
private
static
final
long
serialVersionUID
=
1859164370743532895L
;
ProjectConfigPersistException
(
Throwable
e
)
{
super
(
"系统在保存项目配置信息时发生异常。"
,
e
);
}
ProjectConfigPersistException
(
Throwable
e
,
String
message
)
{
super
(
"系统在保存项目配置信息时发生异常。Message:"
+
message
,
e
);
}
ProjectConfigPersistException
(
String
message
)
{
super
(
"系统在保存项目配置信息时发生异常。Message:"
+
message
);
}
}
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/global/ProjectConfigQueryException.java
0 → 100644
浏览文件 @
c86de453
package
com.x.teamwork.assemble.control.jaxrs.global
;
import
com.x.base.core.project.exception.PromptException
;
class
ProjectConfigQueryException
extends
PromptException
{
private
static
final
long
serialVersionUID
=
1859164370743532895L
;
ProjectConfigQueryException
(
Throwable
e
)
{
super
(
"系统在查询项目配置信息时发生异常。"
,
e
);
}
ProjectConfigQueryException
(
Throwable
e
,
String
message
)
{
super
(
"系统在查询项目配置信息时发生异常。Message:"
+
message
,
e
);
}
}
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/global/WrapInQueryProjectConfig.java
0 → 100644
浏览文件 @
c86de453
package
com.x.teamwork.assemble.control.jaxrs.global
;
import
javax.persistence.Column
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.openjpa.persistence.jdbc.Index
;
import
com.x.base.core.entity.JpaObject
;
import
com.x.base.core.entity.annotation.CheckPersist
;
import
com.x.base.core.project.annotation.FieldDescribe
;
import
com.x.teamwork.core.entity.tools.filter.QueryFilter
;
import
com.x.teamwork.core.entity.tools.filter.term.EqualsTerm
;
import
com.x.teamwork.core.entity.tools.filter.term.LikeTerm
;
public
class
WrapInQueryProjectConfig
{
@FieldDescribe
(
"用于排列的属性,非必填,默认为createTime."
)
private
String
orderField
=
"createTime"
;
@FieldDescribe
(
"排序方式:DESC | ASC,非必填, 默认为DESC."
)
private
String
orderType
=
"DESC"
;
@FieldDescribe
(
"项目ID."
)
private
String
project
=
null
;
@FieldDescribe
(
"新建任务:true|false."
)
private
String
taskCreate
=
null
;
@FieldDescribe
(
"复制任务:true|false."
)
private
String
taskCopy
=
null
;
@FieldDescribe
(
"删除任务:true|false."
)
private
String
taskRemove
=
null
;
@FieldDescribe
(
"新建泳道:true|false."
)
private
String
laneCreate
=
null
;
@FieldDescribe
(
"编辑泳道:true|false."
)
private
String
laneEdit
=
null
;
@FieldDescribe
(
"删除泳道:true|false."
)
private
String
laneRemove
=
null
;
@FieldDescribe
(
"上传附件:true|false."
)
private
String
attachmentUpload
=
null
;
@FieldDescribe
(
"允许评论:true|false."
)
private
String
comment
=
null
;
private
Long
rank
=
0L
;
public
String
getProject
()
{
return
project
;
}
public
void
setProject
(
String
project
)
{
this
.
project
=
project
;
}
public
String
getTaskCreate
()
{
return
taskCreate
;
}
public
void
setTaskCreate
(
String
taskCreate
)
{
this
.
taskCreate
=
taskCreate
;
}
public
String
getTaskCopy
()
{
return
taskCopy
;
}
public
void
setTaskCopy
(
String
taskCopy
)
{
this
.
taskCopy
=
taskCopy
;
}
public
String
getTaskRemove
()
{
return
taskRemove
;
}
public
void
setTaskRemove
(
String
taskRemove
)
{
this
.
taskRemove
=
taskRemove
;
}
public
String
getLaneCreate
()
{
return
laneCreate
;
}
public
void
setLaneCreate
(
String
laneCreate
)
{
this
.
laneCreate
=
laneCreate
;
}
public
String
getLaneEdit
()
{
return
laneEdit
;
}
public
void
setLaneEdit
(
String
laneEdit
)
{
this
.
laneEdit
=
laneEdit
;
}
public
String
getLaneRemove
()
{
return
laneRemove
;
}
public
void
setLaneRemove
(
String
laneRemove
)
{
this
.
laneRemove
=
laneRemove
;
}
public
String
getAttachmentUpload
()
{
return
attachmentUpload
;
}
public
void
setAttachmentUpload
(
String
attachmentUpload
)
{
this
.
attachmentUpload
=
attachmentUpload
;
}
public
String
getComment
()
{
return
comment
;
}
public
void
setComment
(
String
comment
)
{
this
.
comment
=
comment
;
}
public
String
getOrderField
()
{
return
orderField
;
}
public
void
setOrderField
(
String
orderField
)
{
this
.
orderField
=
orderField
;
}
public
String
getOrderType
()
{
return
orderType
;
}
public
void
setOrderType
(
String
orderType
)
{
this
.
orderType
=
orderType
;
}
public
Long
getRank
()
{
return
rank
;
}
public
void
setRank
(
Long
rank
)
{
this
.
rank
=
rank
;
}
/**
* 根据传入的查询参数,组织一个完整的QueryFilter对象
* @return
*/
public
QueryFilter
getQueryFilter
()
{
QueryFilter
queryFilter
=
new
QueryFilter
();
queryFilter
.
setJoinType
(
"and"
);
//组织查询条件对象
if
(
StringUtils
.
isNotEmpty
(
this
.
getProject
()))
{
queryFilter
.
addEqualsTerm
(
new
EqualsTerm
(
"project"
,
this
.
getProject
()
)
);
}
if
(
StringUtils
.
isNotEmpty
(
this
.
getTaskCreate
()
))
{
if
(
"true"
.
equalsIgnoreCase
(
this
.
getTaskCreate
()
))
{
queryFilter
.
addEqualsTerm
(
new
EqualsTerm
(
"taskCreate"
,
true
)
);
}
else
{
queryFilter
.
addEqualsTerm
(
new
EqualsTerm
(
"taskCreate"
,
false
)
);
}
}
if
(
StringUtils
.
isNotEmpty
(
this
.
getTaskCopy
()
))
{
if
(
"true"
.
equalsIgnoreCase
(
this
.
getTaskCopy
()
))
{
queryFilter
.
addEqualsTerm
(
new
EqualsTerm
(
"taskCopy"
,
true
)
);
}
else
{
queryFilter
.
addEqualsTerm
(
new
EqualsTerm
(
"taskCopy"
,
false
)
);
}
}
if
(
StringUtils
.
isNotEmpty
(
this
.
getTaskRemove
()
))
{
if
(
"true"
.
equalsIgnoreCase
(
this
.
getTaskRemove
()
))
{
queryFilter
.
addEqualsTerm
(
new
EqualsTerm
(
"taskRemove"
,
true
)
);
}
else
{
queryFilter
.
addEqualsTerm
(
new
EqualsTerm
(
"taskRemove"
,
false
)
);
}
}
if
(
StringUtils
.
isNotEmpty
(
this
.
getLaneCreate
()
))
{
if
(
"true"
.
equalsIgnoreCase
(
this
.
getLaneCreate
()
))
{
queryFilter
.
addEqualsTerm
(
new
EqualsTerm
(
"laneCreate"
,
true
)
);
}
else
{
queryFilter
.
addEqualsTerm
(
new
EqualsTerm
(
"laneCreate"
,
false
)
);
}
}
if
(
StringUtils
.
isNotEmpty
(
this
.
getLaneEdit
()
))
{
if
(
"true"
.
equalsIgnoreCase
(
this
.
getLaneEdit
()
))
{
queryFilter
.
addEqualsTerm
(
new
EqualsTerm
(
"laneEdit"
,
true
)
);
}
else
{
queryFilter
.
addEqualsTerm
(
new
EqualsTerm
(
"laneEdit"
,
false
)
);
}
}
if
(
StringUtils
.
isNotEmpty
(
this
.
getLaneRemove
()
))
{
if
(
"true"
.
equalsIgnoreCase
(
this
.
getLaneRemove
()
))
{
queryFilter
.
addEqualsTerm
(
new
EqualsTerm
(
"laneRemove"
,
true
)
);
}
else
{
queryFilter
.
addEqualsTerm
(
new
EqualsTerm
(
"laneRemove"
,
false
)
);
}
}
if
(
StringUtils
.
isNotEmpty
(
this
.
getAttachmentUpload
()
))
{
if
(
"true"
.
equalsIgnoreCase
(
this
.
getAttachmentUpload
()
))
{
queryFilter
.
addEqualsTerm
(
new
EqualsTerm
(
"attachmentUpload"
,
true
)
);
}
else
{
queryFilter
.
addEqualsTerm
(
new
EqualsTerm
(
"attachmentUpload"
,
false
)
);
}
}
if
(
StringUtils
.
isNotEmpty
(
this
.
getComment
()
))
{
if
(
"true"
.
equalsIgnoreCase
(
this
.
getComment
()
))
{
queryFilter
.
addEqualsTerm
(
new
EqualsTerm
(
"comment"
,
true
)
);
}
else
{
queryFilter
.
addEqualsTerm
(
new
EqualsTerm
(
"comment"
,
false
)
);
}
}
return
queryFilter
;
}
}
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/service/ProjectConfigPersistService.java
0 → 100644
浏览文件 @
c86de453
package
com.x.teamwork.assemble.control.service
;
import
java.util.List
;
import
org.apache.commons.lang3.StringUtils
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.entity.annotation.CheckPersistType
;
import
com.x.base.core.entity.annotation.CheckRemoveType
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.teamwork.core.entity.ProjectConfig
;
import
com.x.teamwork.core.entity.ProjectGroupRele
;
public
class
ProjectConfigPersistService
{
private
ProjectConfigService
projectConfigService
=
new
ProjectConfigService
();
/**
* 删除优先级信息
* @param flag
* @param effectivePerson
* @throws Exception
*/
public
void
delete
(
String
id
,
EffectivePerson
effectivePerson
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
id
))
{
throw
new
Exception
(
"id is empty."
);
}
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
projectConfigService
.
delete
(
emc
,
id
);
}
catch
(
Exception
e
)
{
throw
e
;
}
}
/**
* 保存项目配置信息
* @param object
* @param effectivePerson
* @return
* @throws Exception
*/
public
ProjectConfig
save
(
ProjectConfig
object
,
EffectivePerson
effectivePerson
)
throws
Exception
{
if
(
object
==
null
)
{
throw
new
Exception
(
"object is null."
);
}
if
(
effectivePerson
==
null
)
{
throw
new
Exception
(
"effectivePerson is null."
);
}
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
object
.
setOwner
(
effectivePerson
.
getDistinguishedName
()
);
object
=
projectConfigService
.
save
(
emc
,
object
);
}
catch
(
Exception
e
)
{
throw
e
;
}
return
object
;
}
/**
* 将项目添加到项目组中去
* @param projectId
* @param groupId
* @return
* @throws Exception
*/
public
ProjectGroupRele
addToGroup
(
String
projectId
,
String
groupId
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
projectId
))
{
throw
new
Exception
(
"projectId is empty."
);
}
if
(
StringUtils
.
isEmpty
(
groupId
))
{
throw
new
Exception
(
"groupId is empty."
);
}
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
return
projectConfigService
.
addToGroup
(
emc
,
projectId
,
groupId
);
}
catch
(
Exception
e
)
{
throw
e
;
}
}
/**
* 将项目从项目组中除去
* @param emc
* @param projectId
* @param groupId
* @throws Exception
*/
public
void
removeFromGroup
(
String
projectId
,
String
groupId
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
projectId
))
{
throw
new
Exception
(
"projectId is empty."
);
}
if
(
StringUtils
.
isEmpty
(
groupId
))
{
throw
new
Exception
(
"groupId is empty."
);
}
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
projectConfigService
.
removeFromGroup
(
emc
,
groupId
,
projectId
);
}
catch
(
Exception
e
)
{
throw
e
;
}
}
/**
* 先删除项目所有已经关联的项目组,然后再将新的项目组与项目关联
* @param projectId
* @param groups
* @throws Exception
*/
public
void
releProjectToGroup
(
String
projectId
,
List
<
String
>
groups
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
projectId
))
{
return
;
}
ProjectGroupRele
projectGroupRele
=
null
;
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
//查询项目所有已经关联的项目组关联信息
List
<
ProjectGroupRele
>
reles
=
projectConfigService
.
listReleWithProject
(
emc
,
projectId
);
emc
.
beginTransaction
(
ProjectGroupRele
.
class
);
//删除项目所有已经关联的项目组关联信息
if
(
ListTools
.
isNotEmpty
(
reles
))
{
for
(
ProjectGroupRele
rele
:
reles
)
{
emc
.
remove
(
rele
,
CheckRemoveType
.
all
);
}
}
//将新的项目组与项目关联
if
(
ListTools
.
isNotEmpty
(
groups
))
{
for
(
String
group
:
groups
)
{
projectGroupRele
=
new
ProjectGroupRele
();
projectGroupRele
.
setProjectId
(
projectId
);
projectGroupRele
.
setGroupId
(
group
);
emc
.
persist
(
projectGroupRele
,
CheckPersistType
.
all
);
}
}
emc
.
commit
();
}
catch
(
Exception
e
)
{
throw
e
;
}
}
}
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/service/ProjectConfigQueryService.java
0 → 100644
浏览文件 @
c86de453
package
com.x.teamwork.assemble.control.service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.apache.commons.lang3.StringUtils
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.teamwork.core.entity.ProjectGroupRele
;
import
com.x.teamwork.core.entity.tools.filter.QueryFilter
;
import
com.x.teamwork.core.entity.tools.filter.term.EqualsTerm
;
import
com.x.teamwork.core.entity.tools.filter.term.InTerm
;
import
com.x.teamwork.core.entity.Priority
;
import
com.x.teamwork.core.entity.Project
;
import
com.x.teamwork.core.entity.ProjectConfig
;
import
com.x.teamwork.core.entity.ProjectGroup
;
/**
* 对项目组信息查询的服务
*
* @author O2LEE
*/
public
class
ProjectConfigQueryService
{
private
ProjectConfigService
projectConfigService
=
new
ProjectConfigService
();
public
List
<
ProjectGroup
>
list
(
List
<
String
>
groupIds
)
throws
Exception
{
if
(
ListTools
.
isEmpty
(
groupIds
))
{
return
null
;
}
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
return
projectConfigService
.
list
(
emc
,
groupIds
);
}
catch
(
Exception
e
)
{
throw
e
;
}
}
/**
* 根据项目组的标识查询项目组信息
* @param id
* @return
* @throws Exception
*/
public
ProjectConfig
get
(
String
id
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
id
))
{
return
null
;
}
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
return
projectConfigService
.
get
(
emc
,
id
);
}
catch
(
Exception
e
)
{
throw
e
;
}
}
/**
* 根据project获取项目配置信息列表
* @param project
* @return
* @throws Exception
*/
public
List
<
ProjectConfig
>
getProjectConfigByProject
(
String
project
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
project
))
{
return
new
ArrayList
<>();
}
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
return
projectConfigService
.
getProjectConfigByProject
(
emc
,
project
);
}
catch
(
Exception
e
)
{
throw
e
;
}
}
/**
* 根据用户列示优先级信息列表
* @param person
* @return
* @throws Exception
*/
public
List
<
Priority
>
listPriority
()
throws
Exception
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
return
projectConfigService
.
listPriority
(
emc
);
}
catch
(
Exception
e
)
{
throw
e
;
}
}
/**
* 根据用户列示优先级信息列表
* @param person
* @return
* @throws Exception
*/
public
List
<
Priority
>
listPriorityByPerson
(
String
person
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
person
))
{
return
new
ArrayList
<>();
}
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
return
projectConfigService
.
listPriorityByPerson
(
emc
,
person
);
}
catch
(
Exception
e
)
{
throw
e
;
}
}
/**
* 根据条件查询项目配置ID列表,最大查询2000条,查询未删除
* @param effectivePerson
* @param i
* @param queryFilter
* @return
* @throws Exception
*/
public
List
<
String
>
listAllProjectConfigIds
(
EffectivePerson
effectivePerson
,
int
maxCount
,
QueryFilter
queryFilter
)
throws
Exception
{
String
personName
=
effectivePerson
.
getDistinguishedName
();
if
(
maxCount
==
0
)
{
maxCount
=
1000
;
}
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
return
projectConfigService
.
listAllProjectConfigIds
(
emc
,
maxCount
,
personName
,
queryFilter
);
}
catch
(
Exception
e
)
{
throw
e
;
}
}
/**
* 根据项目ID列表查询项目信息列表,根据上一条的sequnce查询指定数量的信息
* @param pageSize
* @param lastId
* @param orderField
* @param orderType
* @param projectIds
* @return
* @throws Exception
*/
public
List
<
ProjectConfig
>
listWithProjectConfigIdFilter
(
Integer
pageSize
,
String
lastId
,
String
orderField
,
String
orderType
,
List
<
String
>
projectConfigIds
)
throws
Exception
{
ProjectConfig
projectConfig
=
null
;
if
(
pageSize
==
0
)
{
pageSize
=
20
;
}
if
(
StringUtils
.
isEmpty
(
orderField
)
)
{
orderField
=
"createTime"
;
}
if
(
StringUtils
.
isEmpty
(
orderType
)
)
{
orderType
=
"desc"
;
}
QueryFilter
queryFilter
=
new
QueryFilter
();
queryFilter
.
addInTerm
(
new
InTerm
(
"id"
,
new
ArrayList
<>(
projectConfigIds
)
));
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
if
(
lastId
!=
null
)
{
projectConfig
=
emc
.
find
(
lastId
,
ProjectConfig
.
class
);
}
if
(
projectConfig
!=
null
)
{
return
projectConfigService
.
listWithFilter
(
emc
,
pageSize
,
projectConfig
.
getSequence
(),
orderField
,
orderType
,
null
,
null
,
null
,
null
,
queryFilter
);
}
else
{
return
projectConfigService
.
listWithFilter
(
emc
,
pageSize
,
null
,
orderField
,
orderType
,
null
,
null
,
null
,
null
,
queryFilter
);
}
}
catch
(
Exception
e
)
{
throw
e
;
}
}
/**
* 根据项目组ID,查询项目组内所有的项目ID列表
* @param emc
* @param group
* @return
* @throws Exception
*/
public
List
<
String
>
listProjectIdByGroup
(
String
group
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
group
))
{
return
new
ArrayList
<>();
}
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
return
projectConfigService
.
listProjectIdByGroup
(
emc
,
group
);
}
catch
(
Exception
e
)
{
throw
e
;
}
}
public
List
<
String
>
listGroupIdByProject
(
String
projectId
)
throws
Exception
{
List
<
String
>
result
=
new
ArrayList
<>();
if
(
StringUtils
.
isEmpty
(
projectId
))
{
return
result
;
}
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
List
<
ProjectGroupRele
>
reles
=
projectConfigService
.
listReleWithProject
(
emc
,
projectId
);
if
(
ListTools
.
isNotEmpty
(
reles
))
{
for
(
ProjectGroupRele
rele
:
reles
)
{
if
(
!
result
.
contains
(
rele
.
getGroupId
()
))
{
result
.
add
(
rele
.
getGroupId
()
);
}
}
}
}
catch
(
Exception
e
)
{
throw
e
;
}
return
result
;
}
/**
* 判断是否存在分组和项目的关联
* @param groupId
* @param projectId
* @return
* @throws Exception
*/
public
boolean
existsWithProjectAndGroup
(
String
groupId
,
String
projectId
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
groupId
))
{
return
false
;
}
if
(
StringUtils
.
isEmpty
(
projectId
))
{
return
false
;
}
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
List
<
ProjectGroupRele
>
reles
=
projectConfigService
.
listReleWithProjectAndGroup
(
emc
,
projectId
,
groupId
);
if
(
ListTools
.
isNotEmpty
(
reles
))
{
return
true
;
}
}
catch
(
Exception
e
)
{
throw
e
;
}
return
false
;
}
}
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/service/ProjectConfigService.java
0 → 100644
浏览文件 @
c86de453
package
com.x.teamwork.assemble.control.service
;
import
java.util.List
;
import
org.apache.commons.lang3.StringUtils
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.entity.JpaObject
;
import
com.x.base.core.entity.annotation.CheckPersistType
;
import
com.x.base.core.entity.annotation.CheckRemoveType
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.teamwork.assemble.control.Business
;
import
com.x.teamwork.core.entity.Priority
;
import
com.x.teamwork.core.entity.Project
;
import
com.x.teamwork.core.entity.ProjectConfig
;
import
com.x.teamwork.core.entity.ProjectGroup
;
import
com.x.teamwork.core.entity.ProjectGroupRele
;
import
com.x.teamwork.core.entity.tools.filter.QueryFilter
;
/**
* 对项目组查询信息的服务
*
* @author O2LEE
*/
class
ProjectConfigService
{
protected
List
<
ProjectGroup
>
list
(
EntityManagerContainer
emc
,
List
<
String
>
groupIds
)
throws
Exception
{
Business
business
=
new
Business
(
emc
);
return
business
.
projectGroupFactory
().
list
(
groupIds
);
}
/**
* 根据优先级ID查询优先级的信息
* @param emc
* @param id
* @return
* @throws Exception
*/
protected
ProjectConfig
get
(
EntityManagerContainer
emc
,
String
id
)
throws
Exception
{
Business
business
=
new
Business
(
emc
);
return
business
.
projectConfigFactory
().
get
(
id
);
}
/**
* 根据优先级ID删除优先级信息
* @param emc
* @param id
* @throws Exception
*/
protected
void
delete
(
EntityManagerContainer
emc
,
String
id
)
throws
Exception
{
ProjectConfig
projectConfig
=
emc
.
find
(
id
,
ProjectConfig
.
class
);
emc
.
beginTransaction
(
ProjectConfig
.
class
);
if
(
projectConfig
!=
null
)
{
emc
.
remove
(
projectConfig
,
CheckRemoveType
.
all
);
}
emc
.
commit
();
}
/**
* 向数据库持久化项目配置信息
* @param emc
* @param projectGroup
* @return
* @throws Exception
*/
protected
ProjectConfig
save
(
EntityManagerContainer
emc
,
ProjectConfig
object
)
throws
Exception
{
ProjectConfig
projectConfig
=
null
;
if
(
StringUtils
.
isEmpty
(
object
.
getId
()
)
){
object
.
setId
(
ProjectConfig
.
createId
()
);
}
projectConfig
=
emc
.
find
(
object
.
getId
(),
ProjectConfig
.
class
);
emc
.
beginTransaction
(
ProjectConfig
.
class
);
if
(
projectConfig
==
null
){
// 保存一个新的对象
projectConfig
=
new
ProjectConfig
();
object
.
copyTo
(
projectConfig
);
projectConfig
.
setId
(
object
.
getId
()
);
emc
.
persist
(
projectConfig
,
CheckPersistType
.
all
);
}
else
{
//对象已经存在,更新对象信息
if
(
StringUtils
.
isNotEmpty
(
projectConfig
.
getOwner
()
))
{
object
.
setOwner
(
projectConfig
.
getOwner
()
);
}
object
.
copyTo
(
projectConfig
,
JpaObject
.
FieldsUnmodify
);
emc
.
check
(
projectConfig
,
CheckPersistType
.
all
);
}
emc
.
commit
();
return
projectConfig
;
}
/**
* 根据条件查询项目ID列表,最大查询2000条
* @param emc
* @param maxCount
* @param personName
* @param identityNames
* @param unitNames
* @param groupNames
* @param queryFilter
* @return
* @throws Exception
*/
public
List
<
String
>
listAllProjectConfigIds
(
EntityManagerContainer
emc
,
int
maxCount
,
String
personName
,
QueryFilter
queryFilter
)
throws
Exception
{
Business
business
=
new
Business
(
emc
);
return
business
.
projectConfigFactory
().
listAllProjectConfigIds
(
maxCount
,
personName
,
queryFilter
);
}
/**
* 根据project获取项目配置信息列表
* @param emc
* @param project
* @return
* @throws Exception
*/
protected
List
<
ProjectConfig
>
getProjectConfigByProject
(
EntityManagerContainer
emc
,
String
project
)
throws
Exception
{
Business
business
=
new
Business
(
emc
);
return
business
.
projectConfigFactory
().
getProjectConfigByProject
(
project
);
}
/**
* 将项目添加到项目组中去
* @param emc
* @param projectId
* @param groupId
* @return
* @throws Exception
*/
protected
ProjectGroupRele
addToGroup
(
EntityManagerContainer
emc
,
String
projectId
,
String
groupId
)
throws
Exception
{
List
<
ProjectGroupRele
>
reles
=
null
;
Business
business
=
new
Business
(
emc
);
ProjectGroupRele
projectGroupRele
=
null
;
ProjectGroup
projectGroup
=
emc
.
find
(
groupId
,
ProjectGroup
.
class
);
if
(
projectGroup
!=
null
){
reles
=
business
.
projectGroupReleFactory
().
listWithGroupAndProject
(
groupId
,
projectId
);
if
(
ListTools
.
isEmpty
(
reles
))
{
emc
.
beginTransaction
(
ProjectGroup
.
class
);
projectGroupRele
=
new
ProjectGroupRele
();
projectGroupRele
.
setId
(
ProjectGroupRele
.
createId
()
);
projectGroupRele
.
setProjectId
(
projectId
);
projectGroupRele
.
setGroupId
(
groupId
);
emc
.
persist
(
projectGroupRele
,
CheckPersistType
.
all
);
emc
.
commit
();
}
}
return
projectGroupRele
;
}
/**
* 将项目从项目组中除去
* @param emc
* @param projectId
* @param groupId
* @throws Exception
*/
protected
void
removeFromGroup
(
EntityManagerContainer
emc
,
String
projectId
,
String
groupId
)
throws
Exception
{
Business
business
=
new
Business
(
emc
);
List
<
ProjectGroupRele
>
reles
=
business
.
projectGroupReleFactory
().
listWithGroupAndProject
(
groupId
,
projectId
);
if
(
ListTools
.
isNotEmpty
(
reles
))
{
emc
.
beginTransaction
(
ProjectGroup
.
class
);
for
(
ProjectGroupRele
rele
:
reles
)
{
emc
.
remove
(
rele
,
CheckRemoveType
.
all
);
}
emc
.
commit
();
}
}
/**
* 根据用户列示所有的优先级信息列表
* @param emc
* @param person
* @return
* @throws Exception
*/
protected
List
<
Priority
>
listPriority
(
EntityManagerContainer
emc
)
throws
Exception
{
Business
business
=
new
Business
(
emc
);
return
business
.
priorityFactory
().
listPriority
();
}
/**
* 根据用户列示所有的优先级信息列表
* @param emc
* @param person
* @return
* @throws Exception
*/
protected
List
<
Priority
>
listPriorityByPerson
(
EntityManagerContainer
emc
,
String
person
)
throws
Exception
{
Business
business
=
new
Business
(
emc
);
return
business
.
priorityFactory
().
listPriorityByPerson
(
person
);
}
/**
* 根据用户列示所有的项目组信息ID列表
* @param emc
* @param person
* @return
* @throws Exception
*/
protected
List
<
String
>
listGroupIdsByPerson
(
EntityManagerContainer
emc
,
String
person
)
throws
Exception
{
Business
business
=
new
Business
(
emc
);
return
business
.
projectGroupFactory
().
listByPerson
(
person
);
}
/**
* 根据项目组ID,查询项目组内所有的项目ID列表
* @param emc
* @param group
* @return
* @throws Exception
*/
protected
List
<
String
>
listProjectIdByGroup
(
EntityManagerContainer
emc
,
String
group
)
throws
Exception
{
Business
business
=
new
Business
(
emc
);
return
business
.
projectGroupReleFactory
().
listProjectIdByGroup
(
group
);
}
/**
* 根据项目ID查询项目所有的项目组关联信息对象列表
* @param emc
* @param projectId
* @return
* @throws Exception
*/
protected
List
<
ProjectGroupRele
>
listReleWithProject
(
EntityManagerContainer
emc
,
String
projectId
)
throws
Exception
{
Business
business
=
new
Business
(
emc
);
return
business
.
projectGroupReleFactory
().
listReleWithProject
(
projectId
);
}
/**
* 判断是否存在分组和项目的关联
* @param emc
* @param projectId
* @param groupId
* @return
* @throws Exception
*/
protected
List
<
ProjectGroupRele
>
listReleWithProjectAndGroup
(
EntityManagerContainer
emc
,
String
projectId
,
String
groupId
)
throws
Exception
{
Business
business
=
new
Business
(
emc
);
return
business
.
projectGroupReleFactory
().
listWithGroupAndProject
(
groupId
,
projectId
);
}
/**
* 根据过滤条件查询符合要求的项目信息列表
* @param emc
* @param maxCount
* @param orderField
* @param orderType
* @param personName
* @param identityNames
* @param unitNames
* @param groupNames
* @param group 项目分组
* @param title
* @return
* @throws Exception
*/
protected
List
<
ProjectConfig
>
listWithFilter
(
EntityManagerContainer
emc
,
Integer
maxCount
,
String
orderField
,
String
orderType
,
String
personName
,
List
<
String
>
identityNames
,
List
<
String
>
unitNames
,
List
<
String
>
groupNames
,
QueryFilter
queryFilter
)
throws
Exception
{
Business
business
=
new
Business
(
emc
);
return
business
.
projectConfigFactory
().
listWithFilter
(
maxCount
,
orderField
,
orderType
,
personName
,
identityNames
,
unitNames
,
groupNames
,
queryFilter
);
}
/**
* 根据条件查询符合条件的项目信息ID,根据上一条的sequnce查询指定数量的信息
* @param emc
* @param maxCount
* @param sequnce
* @param orderField
* @param orderType
* @param personName
* @param identityNames
* @param unitNames
* @param groupNames
* @param group 项目分组
* @param title
* @return
* @throws Exception
*/
protected
List
<
ProjectConfig
>
listWithFilter
(
EntityManagerContainer
emc
,
Integer
maxCount
,
String
sequnce
,
String
orderField
,
String
orderType
,
String
personName
,
List
<
String
>
identityNames
,
List
<
String
>
unitNames
,
List
<
String
>
groupNames
,
QueryFilter
queryFilter
)
throws
Exception
{
Business
business
=
new
Business
(
emc
);
return
business
.
projectConfigFactory
().
listWithFilter
(
maxCount
,
sequnce
,
orderField
,
orderType
,
personName
,
identityNames
,
unitNames
,
groupNames
,
queryFilter
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录