Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JeeSpringCloud
Commits
08c32267
Commit
08c32267
authored
Dec 13, 2018
by
Sun
Browse files
no commit message
parent
e9629e7a
Changes
412
Show whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
20 of 412+
files are displayed.
Plain diff
Email patch
JeeSpringCloud/jeespring-act/src/main/java/com/jeespring/modules/act/service/ext/ActGroupEntityService.java
0 → 100644
View file @
08c32267
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.act.service.ext
;
import
java.util.List
;
import
java.util.Map
;
import
org.activiti.engine.identity.Group
;
import
org.activiti.engine.identity.GroupQuery
;
import
org.activiti.engine.impl.GroupQueryImpl
;
import
org.activiti.engine.impl.Page
;
import
org.activiti.engine.impl.persistence.entity.GroupEntity
;
import
org.activiti.engine.impl.persistence.entity.GroupEntityManager
;
import
org.springframework.stereotype.Service
;
import
com.google.common.collect.Lists
;
import
com.jeespring.common.utils.SpringContextHolder
;
import
com.jeespring.modules.act.utils.ActUtils
;
import
com.jeespring.modules.sys.entity.Role
;
import
com.jeespring.modules.sys.entity.User
;
import
com.jeespring.modules.sys.service.SystemService
;
/**
* Activiti Group Entity Service
* @author JeeSpring
* @version 2013-12-05
*/
@Service
public
class
ActGroupEntityService
extends
GroupEntityManager
{
private
SystemService
systemService
;
public
SystemService
getSystemService
()
{
if
(
systemService
==
null
){
systemService
=
SpringContextHolder
.
getBean
(
SystemService
.
class
);
}
return
systemService
;
}
@Override
public
Group
createNewGroup
(
String
groupId
)
{
return
new
GroupEntity
(
groupId
);
}
@Override
public
void
insertGroup
(
Group
group
)
{
// getDbSqlSession().insert((PersistentObject) group);
throw
new
RuntimeException
(
"not implement method."
);
}
public
void
updateGroup
(
GroupEntity
updatedGroup
)
{
// CommandContext commandContext = Context.getCommandContext();
// DbSqlSession dbSqlSession = commandContext.getDbSqlSession();
// dbSqlSession.update(updatedGroup);
throw
new
RuntimeException
(
"not implement method."
);
}
@Override
public
void
deleteGroup
(
String
groupId
)
{
// GroupEntity group = getDbSqlSession().selectById(GroupEntity.class, groupId);
// getDbSqlSession().delete("deleteMembershipsByGroupId", groupId);
// getDbSqlSession().delete(group);
throw
new
RuntimeException
(
"not implement method."
);
}
@Override
public
GroupQuery
createNewGroupQuery
()
{
// return new GroupQueryImpl(Context.getProcessEngineConfiguration().getCommandExecutorTxRequired());
throw
new
RuntimeException
(
"not implement method."
);
}
// @SuppressWarnings("unchecked")
@Override
public
List
<
Group
>
findGroupByQueryCriteria
(
GroupQueryImpl
query
,
Page
page
)
{
// return getDbSqlSession().selectList("selectGroupByQueryCriteria", query, page);
throw
new
RuntimeException
(
"not implement method."
);
}
@Override
public
long
findGroupCountByQueryCriteria
(
GroupQueryImpl
query
)
{
// return (Long) getDbSqlSession().selectOne("selectGroupCountByQueryCriteria", query);
throw
new
RuntimeException
(
"not implement method."
);
}
@Override
public
List
<
Group
>
findGroupsByUser
(
String
userId
)
{
// return getDbSqlSession().selectList("selectGroupsByUserId", userId);
List
<
Group
>
list
=
Lists
.
newArrayList
();
User
user
=
getSystemService
().
getUserByLoginName
(
userId
);
if
(
user
!=
null
&&
user
.
getRoleList
()
!=
null
){
for
(
Role
role
:
user
.
getRoleList
()){
list
.
add
(
ActUtils
.
toActivitiGroup
(
role
));
}
}
return
list
;
}
@Override
public
List
<
Group
>
findGroupsByNativeQuery
(
Map
<
String
,
Object
>
parameterMap
,
int
firstResult
,
int
maxResults
)
{
// return getDbSqlSession().selectListWithRawParameter("selectGroupByNativeQuery", parameterMap, firstResult, maxResults);
throw
new
RuntimeException
(
"not implement method."
);
}
@Override
public
long
findGroupCountByNativeQuery
(
Map
<
String
,
Object
>
parameterMap
)
{
// return (Long) getDbSqlSession().selectOne("selectGroupCountByNativeQuery", parameterMap);
throw
new
RuntimeException
(
"not implement method."
);
}
}
\ No newline at end of file
JeeSpringCloud/jeespring-act/src/main/java/com/jeespring/modules/act/service/ext/ActGroupEntityServiceFactory.java
0 → 100644
View file @
08c32267
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.act.service.ext
;
import
org.activiti.engine.impl.interceptor.Session
;
import
org.activiti.engine.impl.interceptor.SessionFactory
;
import
org.activiti.engine.impl.persistence.entity.GroupIdentityManager
;
import
org.springframework.beans.factory.annotation.Autowired
;
/**
* Activiti Group Entity Factory
* @author JeeSpring
* @version 2013-11-03
*/
public
class
ActGroupEntityServiceFactory
implements
SessionFactory
{
@Autowired
private
ActGroupEntityService
actGroupEntityService
;
@Override
public
Class
<?>
getSessionType
()
{
// 返回原始的GroupIdentityManager类型
return
GroupIdentityManager
.
class
;
}
@Override
public
Session
openSession
()
{
// 返回自定义的GroupEntityManager实例
return
actGroupEntityService
;
}
}
JeeSpringCloud/jeespring-act/src/main/java/com/jeespring/modules/act/service/ext/ActUserEntityService.java
0 → 100644
View file @
08c32267
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.act.service.ext
;
import
java.util.List
;
import
java.util.Map
;
import
org.activiti.engine.identity.Group
;
import
org.activiti.engine.identity.User
;
import
org.activiti.engine.identity.UserQuery
;
import
org.activiti.engine.impl.Page
;
import
org.activiti.engine.impl.UserQueryImpl
;
import
org.activiti.engine.impl.persistence.entity.IdentityInfoEntity
;
import
org.activiti.engine.impl.persistence.entity.UserEntity
;
import
org.activiti.engine.impl.persistence.entity.UserEntityManager
;
import
org.springframework.stereotype.Service
;
import
com.google.common.collect.Lists
;
import
com.jeespring.common.utils.SpringContextHolder
;
import
com.jeespring.modules.act.utils.ActUtils
;
import
com.jeespring.modules.sys.entity.Role
;
import
com.jeespring.modules.sys.service.SystemService
;
/**
* Activiti User Entity Service
* @author JeeSpring
* @version 2013-11-03
*/
@Service
public
class
ActUserEntityService
extends
UserEntityManager
{
private
SystemService
systemService
;
public
SystemService
getSystemService
()
{
if
(
systemService
==
null
){
systemService
=
SpringContextHolder
.
getBean
(
SystemService
.
class
);
}
return
systemService
;
}
@Override
public
User
createNewUser
(
String
userId
)
{
return
new
UserEntity
(
userId
);
}
@Override
public
void
insertUser
(
User
user
)
{
// getDbSqlSession().insert((PersistentObject) user);
throw
new
RuntimeException
(
"not implement method."
);
}
public
void
updateUser
(
UserEntity
updatedUser
)
{
// CommandContext commandContext = Context.getCommandContext();
// DbSqlSession dbSqlSession = commandContext.getDbSqlSession();
// dbSqlSession.update(updatedUser);
throw
new
RuntimeException
(
"not implement method."
);
}
@Override
public
UserEntity
findUserById
(
String
userId
)
{
// return (UserEntity) getDbSqlSession().selectOne("selectUserById", userId);
return
ActUtils
.
toActivitiUser
(
getSystemService
().
getUserByLoginName
(
userId
));
}
@Override
public
void
deleteUser
(
String
userId
)
{
// UserEntity user = findUserById(userId);
// if (user != null) {
// List<IdentityInfoEntity> identityInfos = getDbSqlSession().selectList("selectIdentityInfoByUserId", userId);
// for (IdentityInfoEntity identityInfo : identityInfos) {
// getIdentityInfoManager().deleteIdentityInfo(identityInfo);
// }
// getDbSqlSession().delete("deleteMembershipsByUserId", userId);
// user.delete();
// }
User
user
=
findUserById
(
userId
);
if
(
user
!=
null
)
{
getSystemService
().
deleteUser
(
new
com
.
jeespring
.
modules
.
sys
.
entity
.
User
(
user
.
getId
()));
}
}
@Override
public
List
<
User
>
findUserByQueryCriteria
(
UserQueryImpl
query
,
Page
page
)
{
// return getDbSqlSession().selectList("selectUserByQueryCriteria", query, page);
throw
new
RuntimeException
(
"not implement method."
);
}
@Override
public
long
findUserCountByQueryCriteria
(
UserQueryImpl
query
)
{
// return (Long) getDbSqlSession().selectOne("selectUserCountByQueryCriteria", query);
throw
new
RuntimeException
(
"not implement method."
);
}
@Override
public
List
<
Group
>
findGroupsByUser
(
String
userId
)
{
// return getDbSqlSession().selectList("selectGroupsByUserId", userId);
List
<
Group
>
list
=
Lists
.
newArrayList
();
for
(
Role
role
:
getSystemService
().
findRole
(
new
Role
(
new
com
.
jeespring
.
modules
.
sys
.
entity
.
User
(
null
,
userId
)))){
list
.
add
(
ActUtils
.
toActivitiGroup
(
role
));
}
return
list
;
}
@Override
public
UserQuery
createNewUserQuery
()
{
// return new UserQueryImpl(Context.getProcessEngineConfiguration().getCommandExecutorTxRequired());
throw
new
RuntimeException
(
"not implement method."
);
}
@Override
public
IdentityInfoEntity
findUserInfoByUserIdAndKey
(
String
userId
,
String
key
)
{
// Map<String, String> parameters = new HashMap<String, String>();
// parameters.put("userId", userId);
// parameters.put("key", key);
// return (IdentityInfoEntity) getDbSqlSession().selectOne("selectIdentityInfoByUserIdAndKey", parameters);
throw
new
RuntimeException
(
"not implement method."
);
}
@Override
public
List
<
String
>
findUserInfoKeysByUserIdAndType
(
String
userId
,
String
type
)
{
// Map<String, String> parameters = new HashMap<String, String>();
// parameters.put("userId", userId);
// parameters.put("type", type);
// return (List) getDbSqlSession().getSqlSession().selectList("selectIdentityInfoKeysByUserIdAndType", parameters);
throw
new
RuntimeException
(
"not implement method."
);
}
@Override
public
Boolean
checkPassword
(
String
userId
,
String
password
)
{
// User user = findUserById(userId);
// if ((user != null) && (password != null) && (password.equals(user.getPassword()))) {
// return true;
// }
// return false;
throw
new
RuntimeException
(
"not implement method."
);
}
@Override
public
List
<
User
>
findPotentialStarterUsers
(
String
proceDefId
)
{
// Map<String, String> parameters = new HashMap<String, String>();
// parameters.put("procDefId", proceDefId);
// return (List<User>) getDbSqlSession().selectOne("selectUserByQueryCriteria", parameters);
throw
new
RuntimeException
(
"not implement method."
);
}
@Override
public
List
<
User
>
findUsersByNativeQuery
(
Map
<
String
,
Object
>
parameterMap
,
int
firstResult
,
int
maxResults
)
{
// return getDbSqlSession().selectListWithRawParameter("selectUserByNativeQuery", parameterMap, firstResult, maxResults);
throw
new
RuntimeException
(
"not implement method."
);
}
@Override
public
long
findUserCountByNativeQuery
(
Map
<
String
,
Object
>
parameterMap
)
{
// return (Long) getDbSqlSession().selectOne("selectUserCountByNativeQuery", parameterMap);
throw
new
RuntimeException
(
"not implement method."
);
}
}
JeeSpringCloud/jeespring-act/src/main/java/com/jeespring/modules/act/service/ext/ActUserEntityServiceFactory.java
0 → 100644
View file @
08c32267
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.act.service.ext
;
import
org.activiti.engine.impl.interceptor.Session
;
import
org.activiti.engine.impl.interceptor.SessionFactory
;
import
org.activiti.engine.impl.persistence.entity.UserIdentityManager
;
import
org.springframework.beans.factory.annotation.Autowired
;
/**
* Activiti User Entity Service Factory
* @author JeeSpring
* @version 2013-11-03
*/
public
class
ActUserEntityServiceFactory
implements
SessionFactory
{
@Autowired
private
ActUserEntityService
actUserEntityService
;
@Override
public
Class
<?>
getSessionType
()
{
// 返回原始的UserIdentityManager类型
return
UserIdentityManager
.
class
;
}
@Override
public
Session
openSession
()
{
// 返回自定义的UserEntityManager实例
return
actUserEntityService
;
}
}
JeeSpringCloud/jeespring-act/src/main/java/com/jeespring/modules/act/utils/ActUtils.java
0 → 100644
View file @
08c32267
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.act.utils
;
import
java.lang.annotation.Annotation
;
import
java.lang.reflect.Method
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.activiti.engine.impl.persistence.entity.GroupEntity
;
import
org.activiti.engine.impl.persistence.entity.UserEntity
;
import
com.fasterxml.jackson.annotation.JsonBackReference
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.jeespring.common.annotation.FieldName
;
import
com.jeespring.common.config.Global
;
import
com.jeespring.common.utils.Encodes
;
import
com.jeespring.common.utils.ObjectUtils
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.modules.act.entity.Act
;
import
com.jeespring.modules.sys.entity.Role
;
import
com.jeespring.modules.sys.entity.User
;
/**
* 流程工具
* @author JeeSpring
* @version 2013-11-03
*/
public
class
ActUtils
{
// private static Logger logger = LoggerFactory.getLogger(ActUtils.class);
/**
* 定义流程定义KEY,必须以“PD_”开头
* 组成结构:string[]{"流程标识","业务主表表名"}
*/
public
static
final
String
[]
PD_LEAVE
=
new
String
[]{
"leave"
,
"oa_leave"
};
public
static
final
String
[]
PD_TEST_AUDIT
=
new
String
[]{
"test_audit"
,
"oa_test_audit"
};
// /**
// * 流程定义Map(自动初始化)
// */
// private static Map<String, String> procDefMap = new HashMap<String, String>() {
// private static final long serialVersionUID = 1L;
// {
// for (Field field : ActUtils.class.getFields()){
// if(StringUtils.startsWith(field.getName(), "PD_")){
// try{
// String[] ss = (String[])field.get(null);
// put(ss[0], ss[1]);
// }catch (Exception e) {
// logger.debug("load pd error: {}", field.getName());
// }
// }
// }
// }
// };
//
// /**
// * 获取流程执行(办理)URL
// * @param procId
// * @return
// */
// public static String getProcExeUrl(String procId) {
// String url = procDefMap.get(StringUtils.split(procId, ":")[0]);
// if (StringUtils.isBlank(url)){
// return "404";
// }
// return url;
// }
@SuppressWarnings
({
"unused"
})
public
static
Map
<
String
,
Object
>
getMobileEntity
(
Object
entity
,
String
spiltType
){
if
(
spiltType
==
null
){
spiltType
=
"@"
;
}
Map
<
String
,
Object
>
map
=
Maps
.
newHashMap
();
List
<
String
>
field
=
Lists
.
newArrayList
();
List
<
String
>
value
=
Lists
.
newArrayList
();
List
<
String
>
chinesName
=
Lists
.
newArrayList
();
try
{
for
(
Method
m
:
entity
.
getClass
().
getMethods
()){
if
(
m
.
getAnnotation
(
JsonIgnore
.
class
)
==
null
&&
m
.
getAnnotation
(
JsonBackReference
.
class
)
==
null
&&
m
.
getName
().
startsWith
(
"get"
)){
if
(
m
.
isAnnotationPresent
(
FieldName
.
class
))
{
Annotation
p
=
m
.
getAnnotation
(
FieldName
.
class
);
FieldName
fieldName
=(
FieldName
)
p
;
chinesName
.
add
(
fieldName
.
value
());
}
else
{
chinesName
.
add
(
""
);
}
if
(
"getAct"
.
equals
(
m
.
getName
())){
Object
act
=
m
.
invoke
(
entity
,
new
Object
[]{});
Method
actMet
=
act
.
getClass
().
getMethod
(
"getTaskId"
);
map
.
put
(
"taskId"
,
ObjectUtils
.
toString
(
m
.
invoke
(
act
,
new
Object
[]{}),
""
));
}
else
{
field
.
add
(
StringUtils
.
uncapitalize
(
m
.
getName
().
substring
(
3
)));
value
.
add
(
ObjectUtils
.
toString
(
m
.
invoke
(
entity
,
new
Object
[]{}),
""
));
}
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
map
.
put
(
"beanTitles"
,
StringUtils
.
join
(
field
,
spiltType
));
map
.
put
(
"beanInfos"
,
StringUtils
.
join
(
value
,
spiltType
));
map
.
put
(
"chineseNames"
,
StringUtils
.
join
(
chinesName
,
spiltType
));
return
map
;
}
/**
* 获取流程表单URL
* @param formKey
* @param act 表单传递参数
* @return
*/
public
static
String
getFormUrl
(
String
formKey
,
Act
act
){
StringBuilder
formUrl
=
new
StringBuilder
();
String
formServerUrl
=
Global
.
getConfig
(
"activiti.form.server.url"
);
if
(
StringUtils
.
isBlank
(
formServerUrl
)){
formUrl
.
append
(
Global
.
getAdminPath
());
}
else
{
formUrl
.
append
(
formServerUrl
);
}
formUrl
.
append
(
formKey
).
append
(
formUrl
.
indexOf
(
"?"
)
==
-
1
?
"?"
:
"&"
);
formUrl
.
append
(
"act.taskId="
).
append
(
act
.
getTaskId
()
!=
null
?
act
.
getTaskId
()
:
""
);
formUrl
.
append
(
"&act.taskName="
).
append
(
act
.
getTaskName
()
!=
null
?
Encodes
.
urlEncode
(
act
.
getTaskName
())
:
""
);
formUrl
.
append
(
"&act.taskDefKey="
).
append
(
act
.
getTaskDefKey
()
!=
null
?
act
.
getTaskDefKey
()
:
""
);
formUrl
.
append
(
"&act.procInsId="
).
append
(
act
.
getProcInsId
()
!=
null
?
act
.
getProcInsId
()
:
""
);
formUrl
.
append
(
"&act.procDefId="
).
append
(
act
.
getProcDefId
()
!=
null
?
act
.
getProcDefId
()
:
""
);
formUrl
.
append
(
"&act.status="
).
append
(
act
.
getStatus
()
!=
null
?
act
.
getStatus
()
:
""
);
formUrl
.
append
(
"&id="
).
append
(
act
.
getBusinessId
()
!=
null
?
act
.
getBusinessId
()
:
""
);
return
formUrl
.
toString
();
}
/**
* 转换流程节点类型为中文说明
* @param type 英文名称
* @return 翻译后的中文名称
*/
public
static
String
parseToZhType
(
String
type
)
{
Map
<
String
,
String
>
types
=
new
HashMap
<
String
,
String
>();
types
.
put
(
"userTask"
,
"用户任务"
);
types
.
put
(
"serviceTask"
,
"系统任务"
);
types
.
put
(
"startEvent"
,
"开始节点"
);
types
.
put
(
"endEvent"
,
"结束节点"
);
types
.
put
(
"exclusiveGateway"
,
"条件判断节点(系统自动根据条件处理)"
);
types
.
put
(
"inclusiveGateway"
,
"并行处理任务"
);
types
.
put
(
"callActivity"
,
"子流程"
);
return
types
.
get
(
type
)
==
null
?
type
:
types
.
get
(
type
);
}
public
static
UserEntity
toActivitiUser
(
User
user
){
if
(
user
==
null
){
return
null
;
}
UserEntity
userEntity
=
new
UserEntity
();
userEntity
.
setId
(
user
.
getLoginName
());
userEntity
.
setFirstName
(
user
.
getName
());
userEntity
.
setLastName
(
StringUtils
.
EMPTY
);
userEntity
.
setPassword
(
user
.
getPassword
());
userEntity
.
setEmail
(
user
.
getEmail
());
userEntity
.
setRevision
(
1
);
return
userEntity
;
}
public
static
GroupEntity
toActivitiGroup
(
Role
role
){
if
(
role
==
null
){
return
null
;
}
GroupEntity
groupEntity
=
new
GroupEntity
();
groupEntity
.
setId
(
role
.
getEnname
());
groupEntity
.
setName
(
role
.
getName
());
groupEntity
.
setType
(
role
.
getRoleType
());
groupEntity
.
setRevision
(
1
);
return
groupEntity
;
}
/*public static void main(String[] args) {
User user = new User();
System.out.println(getMobileEntity(user, "@"));
}*/
}
JeeSpringCloud/jeespring-act/src/main/java/com/jeespring/modules/act/utils/DateConverter.java
0 → 100644
View file @
08c32267
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.act.utils
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
org.apache.commons.beanutils.Converter
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.time.DateUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* 日期转换类
* @author JeeSpring
* @version 2013-11-03
*/
public
class
DateConverter
implements
Converter
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
DateConverter
.
class
);
private
static
final
String
DATETIME_PATTERN
=
"yyyy-MM-dd HH:mm:ss"
;
private
static
final
String
DATETIME_PATTERN_NO_SECOND
=
"yyyy-MM-dd HH:mm"
;
private
static
final
String
DATE_PATTERN
=
"yyyy-MM-dd"
;
private
static
final
String
MONTH_PATTERN
=
"yyyy-MM"
;
@Override
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
public
Object
convert
(
Class
type
,
Object
value
)
{
Object
result
=
null
;
if
(
type
==
Date
.
class
)
{
try
{
result
=
doConvertToDate
(
value
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
}
else
if
(
type
==
String
.
class
)
{
result
=
doConvertToString
(
value
);
}
return
result
;
}
/**
* Convert String to Date
*
* @param value
* @return
* @throws ParseException
*/
private
Date
doConvertToDate
(
Object
value
)
throws
ParseException
{
Date
result
=
null
;
if
(
value
instanceof
String
)
{
result
=
DateUtils
.
parseDate
((
String
)
value
,
new
String
[]
{
DATE_PATTERN
,
DATETIME_PATTERN
,
DATETIME_PATTERN_NO_SECOND
,
MONTH_PATTERN
});
// all patterns failed, try a milliseconds constructor
if
(
result
==
null
&&
StringUtils
.
isNotEmpty
((
String
)
value
))
{
try
{
result
=
new
Date
(
new
Long
((
String
)
value
).
longValue
());
}
catch
(
Exception
e
)
{
logger
.
error
(
"Converting from milliseconds to Date fails!"
);
e
.
printStackTrace
();
}
}
}
else
if
(
value
instanceof
Object
[])
{
// let's try to convert the first element only
Object
[]
array
=
(
Object
[])
value
;
if
(
array
.
length
>=
1
)
{
value
=
array
[
0
];
result
=
doConvertToDate
(
value
);
}
}
else
if
(
Date
.
class
.
isAssignableFrom
(
value
.
getClass
()))
{
result
=
(
Date
)
value
;
}
return
result
;
}
/**
* Convert Date to String
*
* @param value
* @return
*/
private
String
doConvertToString
(
Object
value
)
{
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
DATETIME_PATTERN
);
String
result
=
null
;
if
(
value
instanceof
Date
)
{
result
=
simpleDateFormat
.
format
(
value
);
}
return
result
;
}
}
\ No newline at end of file
JeeSpringCloud/jeespring-act/src/main/java/com/jeespring/modules/act/utils/ProcessDefCache.java
0 → 100644
View file @
08c32267
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.act.utils
;
import
java.util.List
;
import
org.activiti.engine.RepositoryService
;
import
org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity
;
import
org.activiti.engine.impl.pvm.process.ActivityImpl
;
import
org.activiti.engine.repository.ProcessDefinition
;
import
org.apache.commons.lang3.ObjectUtils
;
import
com.jeespring.common.utils.CacheUtils
;
import
com.jeespring.common.utils.SpringContextHolder
;
/**
* 流程定义缓存
* @author JeeSpring
* @version 2013-12-05
*/
public
class
ProcessDefCache
{
private
static
final
String
ACT_CACHE
=
"actCache"
;
private
static
final
String
ACT_CACHE_PD_ID_
=
"pd_id_"
;
/**
* 获得流程定义对象
* @param procDefId
* @return
*/
public
static
ProcessDefinition
get
(
String
procDefId
)
{
ProcessDefinition
pd
=
(
ProcessDefinition
)
CacheUtils
.
get
(
ACT_CACHE
,
ACT_CACHE_PD_ID_
+
procDefId
);
if
(
pd
==
null
)
{
RepositoryService
repositoryService
=
SpringContextHolder
.
getBean
(
RepositoryService
.
class
);
// pd = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(pd);
pd
=
repositoryService
.
createProcessDefinitionQuery
().
processDefinitionId
(
procDefId
).
singleResult
();
if
(
pd
!=
null
)
{
CacheUtils
.
put
(
ACT_CACHE
,
ACT_CACHE_PD_ID_
+
procDefId
,
pd
);
}
}
return
pd
;
}
/**
* 获得流程定义的所有活动节点
* @param procDefId
* @return
*/
public
static
List
<
ActivityImpl
>
getActivitys
(
String
procDefId
)
{
ProcessDefinition
pd
=
get
(
procDefId
);
if
(
pd
!=
null
)
{
return
((
ProcessDefinitionEntity
)
pd
).
getActivities
();
}
return
null
;
}
/**
* 获得流程定义活动节点
* @param procDefId
* @param activityId
* @return
*/
public
static
ActivityImpl
getActivity
(
String
procDefId
,
String
activityId
)
{
ProcessDefinition
pd
=
get
(
procDefId
);
if
(
pd
!=
null
)
{
List
<
ActivityImpl
>
list
=
getActivitys
(
procDefId
);
if
(
list
!=
null
){
for
(
ActivityImpl
activityImpl
:
list
)
{
if
(
activityId
.
equals
(
activityImpl
.
getId
())){
return
activityImpl
;
}
}
}
}
return
null
;
}
/**
* 获取流程定义活动节点名称
* @param procDefId
* @param activityId
* @return
*/
@SuppressWarnings
(
"deprecation"
)
public
static
String
getActivityName
(
String
procDefId
,
String
activityId
)
{
ActivityImpl
activity
=
getActivity
(
procDefId
,
activityId
);
if
(
activity
!=
null
)
{
return
ObjectUtils
.
toString
(
activity
.
getProperty
(
"name"
));
}
return
null
;
}
}
JeeSpringCloud/jeespring-act/src/main/java/com/jeespring/modules/act/utils/ProcessDefUtils.java
0 → 100644
View file @
08c32267
package
com.jeespring.modules.act.utils
;
import
java.util.LinkedHashSet
;
import
java.util.Set
;
import
org.activiti.engine.ProcessEngine
;
import
org.activiti.engine.delegate.Expression
;
import
org.activiti.engine.impl.RepositoryServiceImpl
;
import
org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior
;
import
org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl
;
import
org.activiti.engine.impl.el.FixedValue
;
import
org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity
;
import
org.activiti.engine.impl.pvm.process.ActivityImpl
;
import
org.activiti.engine.impl.task.TaskDefinition
;
import
org.apache.commons.lang3.reflect.FieldUtils
;
import
org.apache.log4j.Logger
;
/**
* 流程定义相关操作的封装
* @author bluejoe2008@gmail.com
*/
public
abstract
class
ProcessDefUtils
{
public
static
ActivityImpl
getActivity
(
ProcessEngine
processEngine
,
String
processDefId
,
String
activityId
)
{
ProcessDefinitionEntity
pde
=
getProcessDefinition
(
processEngine
,
processDefId
);
return
(
ActivityImpl
)
pde
.
findActivity
(
activityId
);
}
public
static
ProcessDefinitionEntity
getProcessDefinition
(
ProcessEngine
processEngine
,
String
processDefId
)
{
return
(
ProcessDefinitionEntity
)
((
RepositoryServiceImpl
)
processEngine
.
getRepositoryService
()).
getDeployedProcessDefinition
(
processDefId
);
}
public
static
void
grantPermission
(
ActivityImpl
activity
,
String
assigneeExpression
,
String
candidateGroupIdExpressions
,
String
candidateUserIdExpressions
)
throws
Exception
{
TaskDefinition
taskDefinition
=
((
UserTaskActivityBehavior
)
activity
.
getActivityBehavior
()).
getTaskDefinition
();
taskDefinition
.
setAssigneeExpression
(
assigneeExpression
==
null
?
null
:
new
FixedValue
(
assigneeExpression
));
FieldUtils
.
writeField
(
taskDefinition
,
"candidateUserIdExpressions"
,
ExpressionUtils
.
stringToExpressionSet
(
candidateUserIdExpressions
),
true
);
FieldUtils
.
writeField
(
taskDefinition
,
"candidateGroupIdExpressions"
,
ExpressionUtils
.
stringToExpressionSet
(
candidateGroupIdExpressions
),
true
);
Logger
.
getLogger
(
ProcessDefUtils
.
class
).
info
(
String
.
format
(
"granting previledges for [%s, %s, %s] on [%s, %s]"
,
assigneeExpression
,
candidateGroupIdExpressions
,
candidateUserIdExpressions
,
activity
.
getProcessDefinition
().
getKey
(),
activity
.
getProperty
(
"name"
)));
}
/**
* 实现常见类型的expression的包装和转换
*
* @author bluejoe2008@gmail.com
*
*/
public
static
class
ExpressionUtils
{
public
static
Expression
stringToExpression
(
ProcessEngineConfigurationImpl
conf
,
String
expr
)
{
return
conf
.
getExpressionManager
().
createExpression
(
expr
);
}
public
static
Expression
stringToExpression
(
String
expr
)
{
return
new
FixedValue
(
expr
);
}
public
static
Set
<
Expression
>
stringToExpressionSet
(
String
exprs
)
{
Set
<
Expression
>
set
=
new
LinkedHashSet
<
Expression
>();
for
(
String
expr
:
exprs
.
split
(
";"
))
{
set
.
add
(
stringToExpression
(
expr
));
}
return
set
;
}
}
}
\ No newline at end of file
JeeSpringCloud/jeespring-act/src/main/java/com/jeespring/modules/act/utils/PropertyType.java
0 → 100644
View file @
08c32267
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.act.utils
;
import
java.util.Date
;
/**
* 属性数据类型
* @author JeeSpring
* @version 2013-11-03
*/
public
enum
PropertyType
{
S
(
String
.
class
),
I
(
Integer
.
class
),
L
(
Long
.
class
),
F
(
Float
.
class
),
N
(
Double
.
class
),
D
(
Date
.
class
),
SD
(
java
.
sql
.
Date
.
class
),
B
(
Boolean
.
class
);
private
Class
<?>
clazz
;
private
PropertyType
(
Class
<?>
clazz
)
{
this
.
clazz
=
clazz
;
}
public
Class
<?>
getValue
()
{
return
clazz
;
}
}
\ No newline at end of file
JeeSpringCloud/jeespring-act/src/main/java/com/jeespring/modules/act/utils/Variable.java
0 → 100644
View file @
08c32267
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.act.utils
;
import
java.util.Map
;
import
org.apache.commons.beanutils.ConvertUtils
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.google.common.collect.Maps
;
import
com.jeespring.common.utils.StringUtils
;
/**
* 流程变量对象
* @author JeeSpring
* @version 2013-11-03
*/
public
class
Variable
{
private
Map
<
String
,
Object
>
map
=
Maps
.
newHashMap
();
private
String
keys
;
private
String
values
;
private
String
types
;
public
Variable
(){
}
public
Variable
(
Map
<
String
,
Object
>
map
){
this
.
map
=
map
;
}
public
String
getKeys
()
{
return
keys
;
}
public
void
setKeys
(
String
keys
)
{
this
.
keys
=
keys
;
}
public
String
getValues
()
{
return
values
;
}
public
void
setValues
(
String
values
)
{
this
.
values
=
values
;
}
public
String
getTypes
()
{
return
types
;
}
public
void
setTypes
(
String
types
)
{
this
.
types
=
types
;
}
@JsonIgnore
public
Map
<
String
,
Object
>
getVariableMap
()
{
ConvertUtils
.
register
(
new
DateConverter
(),
java
.
util
.
Date
.
class
);
if
(
StringUtils
.
isBlank
(
keys
))
{
return
map
;
}
String
[]
arrayKey
=
keys
.
split
(
","
);
String
[]
arrayValue
=
values
.
split
(
","
);
String
[]
arrayType
=
types
.
split
(
","
);
for
(
int
i
=
0
;
i
<
arrayKey
.
length
;
i
++)
{
String
key
=
arrayKey
[
i
];
String
value
=
arrayValue
[
i
];
String
type
=
arrayType
[
i
];
Class
<?>
targetType
=
Enum
.
valueOf
(
PropertyType
.
class
,
type
).
getValue
();
Object
objectValue
=
ConvertUtils
.
convert
(
value
,
targetType
);
map
.
put
(
key
,
objectValue
);
}
return
map
;
}
public
Map
<
String
,
Object
>
getMap
()
{
return
map
;
}
}
JeeSpringCloud/jeespring-act/src/main/java/com/jeespring/modules/act/web/ActModelController.java
0 → 100644
View file @
08c32267
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.act.web
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.modules.act.service.ActModelService
;
/**
* 流程模型相关Controller
* @author JeeSpring
* @version 2013-11-03
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/act/model"
)
public
class
ActModelController
extends
AbstractBaseController
{
@Autowired
private
ActModelService
actModelService
;
/**
* 流程模型列表
*/
@RequiresPermissions
(
"act:model:edit"
)
@RequestMapping
(
value
=
{
"list"
,
""
})
public
String
modelList
(
String
category
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
Page
<
org
.
activiti
.
engine
.
repository
.
Model
>
page
=
actModelService
.
modelList
(
new
Page
<
org
.
activiti
.
engine
.
repository
.
Model
>(
request
,
response
),
category
);
model
.
addAttribute
(
"page"
,
page
);
model
.
addAttribute
(
"category"
,
category
);
return
"modules/act/actModelList"
;
}
/**
* 创建模型
*/
@RequiresPermissions
(
"act:model:edit"
)
@RequestMapping
(
value
=
"create"
,
method
=
RequestMethod
.
GET
)
public
String
create
(
Model
model
)
{
return
"modules/act/actModelCreate"
;
}
/**
* 创建模型
*/
@RequiresPermissions
(
"act:model:edit"
)
@RequestMapping
(
value
=
"create"
,
method
=
RequestMethod
.
POST
)
public
void
create
(
String
name
,
String
key
,
String
description
,
String
category
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
try
{
org
.
activiti
.
engine
.
repository
.
Model
modelData
=
actModelService
.
create
(
name
,
key
,
description
,
category
);
response
.
sendRedirect
(
request
.
getContextPath
()
+
"/act/process-editor/modeler.jsp?modelId="
+
modelData
.
getId
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
logger
.
error
(
"创建模型失败:"
,
e
);
}
}
/**
* 根据Model部署流程
*/
@RequiresPermissions
(
"act:model:edit"
)
@RequestMapping
(
value
=
"deploy"
)
public
String
deploy
(
String
id
,
RedirectAttributes
redirectAttributes
)
{
String
message
=
actModelService
.
deploy
(
id
);
redirectAttributes
.
addFlashAttribute
(
"message"
,
message
);
return
"redirect:"
+
adminPath
+
"/act/process"
;
}
/**
* 导出model的xml文件
*/
@RequiresPermissions
(
"act:model:edit"
)
@RequestMapping
(
value
=
"export"
)
public
void
export
(
String
id
,
HttpServletResponse
response
)
{
actModelService
.
export
(
id
,
response
);
}
/**
* 更新Model分类
*/
@RequiresPermissions
(
"act:model:edit"
)
@RequestMapping
(
value
=
"updateCategory"
)
public
String
updateCategory
(
String
id
,
String
category
,
RedirectAttributes
redirectAttributes
)
{
actModelService
.
updateCategory
(
id
,
category
);
redirectAttributes
.
addFlashAttribute
(
"message"
,
"设置成功,模块ID="
+
id
);
return
"redirect:"
+
adminPath
+
"/act/model"
;
}
/**
* 删除Model
* @param id
* @param redirectAttributes
* @return
*/
@RequiresPermissions
(
"act:model:edit"
)
@RequestMapping
(
value
=
"delete"
)
public
String
delete
(
String
id
,
RedirectAttributes
redirectAttributes
)
{
actModelService
.
delete
(
id
);
redirectAttributes
.
addFlashAttribute
(
"message"
,
"删除成功,模型ID="
+
id
);
return
"redirect:"
+
adminPath
+
"/act/model"
;
}
}
JeeSpringCloud/jeespring-act/src/main/java/com/jeespring/modules/act/web/ActProcessController.java
0 → 100644
View file @
08c32267
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.act.web
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.UnsupportedEncodingException
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.xml.stream.XMLStreamException
;
import
org.activiti.engine.runtime.ProcessInstance
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.modules.act.service.ActProcessService
;
/**
* 流程定义相关Controller
* @author JeeSpring
* @version 2013-11-03
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/act/process"
)
public
class
ActProcessController
extends
AbstractBaseController
{
@Autowired
private
ActProcessService
actProcessService
;
/**
* 流程定义列表
*/
@RequiresPermissions
(
"act:process:edit"
)
@RequestMapping
(
value
=
{
"list"
,
""
})
public
String
processList
(
String
category
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
/*
* 保存两个对象,一个是ProcessDefinition(流程定义),一个是Deployment(流程部署)
*/
Page
<
Object
[]>
page
=
actProcessService
.
processList
(
new
Page
<
Object
[]>(
request
,
response
),
category
);
model
.
addAttribute
(
"page"
,
page
);
model
.
addAttribute
(
"category"
,
category
);
return
"modules/act/actProcessList"
;
}
/**
* 运行中的实例列表
*/
@RequiresPermissions
(
"act:process:edit"
)
@RequestMapping
(
value
=
"running"
)
public
String
runningList
(
String
procInsId
,
String
procDefKey
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
Page
<
ProcessInstance
>
page
=
actProcessService
.
runningList
(
new
Page
<
ProcessInstance
>(
request
,
response
),
procInsId
,
procDefKey
);
model
.
addAttribute
(
"page"
,
page
);
model
.
addAttribute
(
"procInsId"
,
procInsId
);
model
.
addAttribute
(
"procDefKey"
,
procDefKey
);
return
"modules/act/actProcessRunningList"
;
}
/**
* 读取资源,通过部署ID
* @param processDefinitionId 流程定义ID
* @param processInstanceId 流程实例ID
* @param resourceType 资源类型(xml|image)
* @param response
* @throws Exception
*/
@RequiresPermissions
(
"act:process:edit"
)
@RequestMapping
(
value
=
"resource/read"
)
public
void
resourceRead
(
String
procDefId
,
String
proInsId
,
String
resType
,
HttpServletResponse
response
)
throws
Exception
{
InputStream
resourceAsStream
=
actProcessService
.
resourceRead
(
procDefId
,
proInsId
,
resType
);
byte
[]
b
=
new
byte
[
1024
];
int
len
=
-
1
;
while
((
len
=
resourceAsStream
.
read
(
b
,
0
,
1024
))
!=
-
1
)
{
response
.
getOutputStream
().
write
(
b
,
0
,
len
);
}
}
/**
* 部署流程
*/
@RequiresPermissions
(
"act:process:edit"
)
@RequestMapping
(
value
=
"/deploy"
,
method
=
RequestMethod
.
GET
)
public
String
deploy
(
Model
model
)
{
return
"modules/act/actProcessDeploy"
;
}
/**
* 部署流程 - 保存
* @param file
* @return
*/
@RequiresPermissions
(
"act:process:edit"
)
@RequestMapping
(
value
=
"/deploy"
,
method
=
RequestMethod
.
POST
)
public
String
deploy
(
@Value
(
"#{APP_PROP['activiti.export.diagram.path']}"
)
String
exportDir
,
String
category
,
MultipartFile
file
,
RedirectAttributes
redirectAttributes
)
{
String
fileName
=
file
.
getOriginalFilename
();
if
(
StringUtils
.
isBlank
(
fileName
)){
redirectAttributes
.
addFlashAttribute
(
"message"
,
"请选择要部署的流程文件"
);
}
else
{
String
message
=
actProcessService
.
deploy
(
exportDir
,
category
,
file
);
redirectAttributes
.
addFlashAttribute
(
"message"
,
message
);
}
return
"redirect:"
+
adminPath
+
"/act/process"
;
}
/**
* 设置流程分类
*/
@RequiresPermissions
(
"act:process:edit"
)
@RequestMapping
(
value
=
"updateCategory"
)
public
String
updateCategory
(
String
procDefId
,
String
category
,
RedirectAttributes
redirectAttributes
)
{
actProcessService
.
updateCategory
(
procDefId
,
category
);
return
"redirect:"
+
adminPath
+
"/act/process"
;
}
/**
* 挂起、激活流程实例
*/
@RequiresPermissions
(
"act:process:edit"
)
@RequestMapping
(
value
=
"update/{state}"
)
public
String
updateState
(
@PathVariable
(
"state"
)
String
state
,
String
procDefId
,
RedirectAttributes
redirectAttributes
)
{
String
message
=
actProcessService
.
updateState
(
state
,
procDefId
);
redirectAttributes
.
addFlashAttribute
(
"message"
,
message
);
return
"redirect:"
+
adminPath
+
"/act/process"
;
}
/**
* 将部署的流程转换为模型
* @param procDefId
* @param redirectAttributes
* @return
* @throws UnsupportedEncodingException
* @throws XMLStreamException
*/
@RequiresPermissions
(
"act:process:edit"
)
@RequestMapping
(
value
=
"convert/toModel"
)
public
String
convertToModel
(
String
procDefId
,
RedirectAttributes
redirectAttributes
)
throws
UnsupportedEncodingException
,
XMLStreamException
{
org
.
activiti
.
engine
.
repository
.
Model
modelData
=
actProcessService
.
convertToModel
(
procDefId
);
redirectAttributes
.
addFlashAttribute
(
"message"
,
"转换模型成功,模型ID="
+
modelData
.
getId
());
return
"redirect:"
+
adminPath
+
"/act/model"
;
}
/**
* 导出图片文件到硬盘
*/
@RequiresPermissions
(
"act:process:edit"
)
@RequestMapping
(
value
=
"export/diagrams"
)
@ResponseBody
public
List
<
String
>
exportDiagrams
(
@Value
(
"#{APP_PROP['activiti.export.diagram.path']}"
)
String
exportDir
)
throws
IOException
{
List
<
String
>
files
=
actProcessService
.
exportDiagrams
(
exportDir
);;
return
files
;
}
/**
* 删除部署的流程,级联删除流程实例
* @param deploymentId 流程部署ID
*/
@RequiresPermissions
(
"act:process:edit"
)
@RequestMapping
(
value
=
"delete"
)
public
String
delete
(
String
deploymentId
)
{
actProcessService
.
deleteDeployment
(
deploymentId
);
return
"redirect:"
+
adminPath
+
"/act/process"
;
}
/**
* 删除流程实例
* @param procInsId 流程实例ID
* @param reason 删除原因
*/
@RequiresPermissions
(
"act:process:edit"
)
@RequestMapping
(
value
=
"deleteProcIns"
)
public
String
deleteProcIns
(
String
procInsId
,
String
reason
,
RedirectAttributes
redirectAttributes
)
{
if
(
StringUtils
.
isBlank
(
reason
)){
addMessage
(
redirectAttributes
,
"请填写删除原因"
);
}
else
{
actProcessService
.
deleteProcIns
(
procInsId
,
reason
);
addMessage
(
redirectAttributes
,
"删除流程实例成功,实例ID="
+
procInsId
);
}
return
"redirect:"
+
adminPath
+
"/act/process/running/"
;
}
}
JeeSpringCloud/jeespring-act/src/main/java/com/jeespring/modules/act/web/ActTaskController.java
0 → 100644
View file @
08c32267
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.act.web
;
import
java.io.InputStream
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.modules.act.entity.Act
;
import
com.jeespring.modules.act.service.ActTaskService
;
import
com.jeespring.modules.act.utils.ActUtils
;
import
com.jeespring.modules.sys.utils.UserUtils
;
/**
* 流程个人任务相关Controller
* @author JeeSpring
* @version 2013-11-03
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/act/task"
)
public
class
ActTaskController
extends
AbstractBaseController
{
@Autowired
private
ActTaskService
actTaskService
;
/**
* 获取待办列表
* @param act procDefKey 流程定义标识
* @return
*/
@RequestMapping
(
value
=
{
"todo"
,
""
})
public
String
todoList
(
Act
act
,
HttpServletResponse
response
,
Model
model
)
throws
Exception
{
List
<
Act
>
list
=
actTaskService
.
todoList
(
act
);
model
.
addAttribute
(
"list"
,
list
);
if
(
UserUtils
.
getPrincipal
().
isMobileLogin
()){
return
renderString
(
response
,
list
);
}
return
"modules/act/actTaskTodoList"
;
}
/**
* 获取已办任务
* @param act page
* @param act procDefKey 流程定义标识
* @return
*/
@RequestMapping
(
value
=
"historic"
)
public
String
historicList
(
Act
act
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
throws
Exception
{
Page
<
Act
>
page
=
new
Page
<
Act
>(
request
,
response
);
page
=
actTaskService
.
historicList
(
page
,
act
);
model
.
addAttribute
(
"page"
,
page
);
if
(
UserUtils
.
getPrincipal
().
isMobileLogin
()){
return
renderString
(
response
,
page
);
}
return
"modules/act/actTaskHistoricList"
;
}
/**
* 获取流转历史列表
* @param act procInsId 流程实例
* @param startAct 开始活动节点名称
* @param endAct 结束活动节点名称
*/
@RequestMapping
(
value
=
"histoicFlow"
)
public
String
histoicFlow
(
Act
act
,
String
startAct
,
String
endAct
,
Model
model
){
if
(
StringUtils
.
isNotBlank
(
act
.
getProcInsId
())){
List
<
Act
>
histoicFlowList
=
actTaskService
.
histoicFlowList
(
act
.
getProcInsId
(),
startAct
,
endAct
);
model
.
addAttribute
(
"histoicFlowList"
,
histoicFlowList
);
}
return
"modules/act/actTaskHistoricFlow"
;
}
/**
* 获取流程列表
* @param category 流程分类
*/
@RequestMapping
(
value
=
"process"
)
public
String
processList
(
String
category
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
Page
<
Object
[]>
page
=
new
Page
<
Object
[]>(
request
,
response
);
page
=
actTaskService
.
processList
(
page
,
category
);
model
.
addAttribute
(
"page"
,
page
);
model
.
addAttribute
(
"category"
,
category
);
return
"modules/act/actTaskProcessList"
;
}
/**
* 获取流程表单
* @param act taskId 任务ID
* @param act taskName 任务名称
* @param act taskDefKey 任务环节标识
* @param act procInsId 流程实例ID
* @param act procDefId 流程定义ID
*/
@RequestMapping
(
value
=
"form"
)
public
String
form
(
Act
act
,
HttpServletRequest
request
,
Model
model
){
// 获取流程XML上的表单KEY
String
formKey
=
actTaskService
.
getFormKey
(
act
.
getProcDefId
(),
act
.
getTaskDefKey
());
// 获取流程实例对象
if
(
act
.
getProcInsId
()
!=
null
){
act
.
setProcIns
(
actTaskService
.
getProcIns
(
act
.
getProcInsId
()));
}
return
"redirect:"
+
ActUtils
.
getFormUrl
(
formKey
,
act
);
// // 传递参数到视图
// model.addAttribute("act", act);
// model.addAttribute("formUrl", formUrl);
// return "modules/act/actTaskForm";
}
/**
* 启动流程
* @param act procDefKey 流程定义KEY
* @param act businessTable 业务表表名
* @param act businessId 业务表编号
*/
@RequestMapping
(
value
=
"start"
)
@ResponseBody
public
String
start
(
Act
act
,
String
table
,
String
id
,
Model
model
)
throws
Exception
{
actTaskService
.
startProcess
(
act
.
getProcDefKey
(),
act
.
getBusinessId
(),
act
.
getBusinessTable
(),
act
.
getTitle
());
return
"true"
;
//adminPath + "/act/task";
}
/**
* 签收任务
* @param act taskId 任务ID
*/
@RequestMapping
(
value
=
"claim"
)
@ResponseBody
public
String
claim
(
Act
act
)
{
String
userId
=
UserUtils
.
getUser
().
getLoginName
();
//ObjectUtils.toString(UserUtils.getUser().getId());
actTaskService
.
claim
(
act
.
getTaskId
(),
userId
);
return
"true"
;
//adminPath + "/act/task";
}
/**
* 完成任务
* @param act taskId 任务ID
* @param act procInsId 流程实例ID,如果为空,则不保存任务提交意见
* @param act comment 任务提交意见的内容
* @param act vars 任务流程变量,如下
* vars.keys=flag,pass
* vars.values=1,true
* vars.types=S,B @see com.thinkgem.jeesite.modules.act.utils.PropertyType
*/
@RequestMapping
(
value
=
"complete"
)
@ResponseBody
public
String
complete
(
Act
act
)
{
actTaskService
.
complete
(
act
.
getTaskId
(),
act
.
getProcInsId
(),
act
.
getComment
(),
act
.
getVars
().
getVariableMap
());
return
"true"
;
//adminPath + "/act/task";
}
/**
* 读取带跟踪的图片
*/
@RequestMapping
(
value
=
"trace/photo/{procDefId}/{execId}"
)
public
void
tracePhoto
(
@PathVariable
(
"procDefId"
)
String
procDefId
,
@PathVariable
(
"execId"
)
String
execId
,
HttpServletResponse
response
)
throws
Exception
{
InputStream
imageStream
=
actTaskService
.
tracePhoto
(
procDefId
,
execId
);
// 输出资源内容到相应对象
byte
[]
b
=
new
byte
[
1024
];
int
len
;
while
((
len
=
imageStream
.
read
(
b
,
0
,
1024
))
!=
-
1
)
{
response
.
getOutputStream
().
write
(
b
,
0
,
len
);
}
}
/**
* 输出跟踪流程信息
*
* @param proInsId
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping
(
value
=
"trace/info/{proInsId}"
)
public
List
<
Map
<
String
,
Object
>>
traceInfo
(
@PathVariable
(
"proInsId"
)
String
proInsId
)
throws
Exception
{
List
<
Map
<
String
,
Object
>>
activityInfos
=
actTaskService
.
traceProcess
(
proInsId
);
return
activityInfos
;
}
/**
* 显示流程图
@RequestMapping(value = "processPic")
public void processPic(String procDefId, HttpServletResponse response) throws Exception {
ProcessDefinition procDef = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId).singleResult();
String diagramResourceName = procDef.getDiagramResourceName();
InputStream imageStream = repositoryService.getResourceAsStream(procDef.getDeploymentId(), diagramResourceName);
byte[] b = new byte[1024];
int len = -1;
while ((len = imageStream.read(b, 0, 1024)) != -1) {
response.getOutputStream().write(b, 0, len);
}
}*/
/**
* 获取跟踪信息
@RequestMapping(value = "processMap")
public String processMap(String procDefId, String proInstId, Model model)
throws Exception {
List<ActivityImpl> actImpls = new ArrayList<ActivityImpl>();
ProcessDefinition processDefinition = repositoryService
.createProcessDefinitionQuery().processDefinitionId(procDefId)
.singleResult();
ProcessDefinitionImpl pdImpl = (ProcessDefinitionImpl) processDefinition;
String processDefinitionId = pdImpl.getId();// 流程标识
ProcessDefinitionEntity def = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService)
.getDeployedProcessDefinition(processDefinitionId);
List<ActivityImpl> activitiList = def.getActivities();// 获得当前任务的所有节点
List<String> activeActivityIds = runtimeService.getActiveActivityIds(proInstId);
for (String activeId : activeActivityIds) {
for (ActivityImpl activityImpl : activitiList) {
String id = activityImpl.getId();
if (activityImpl.isScope()) {
if (activityImpl.getActivities().size() > 1) {
List<ActivityImpl> subAcList = activityImpl
.getActivities();
for (ActivityImpl subActImpl : subAcList) {
String subid = subActImpl.getId();
System.out.println("subImpl:" + subid);
if (activeId.equals(subid)) {// 获得执行到那个节点
actImpls.add(subActImpl);
break;
}
}
}
}
if (activeId.equals(id)) {// 获得执行到那个节点
actImpls.add(activityImpl);
System.out.println(id);
}
}
}
model.addAttribute("procDefId", procDefId);
model.addAttribute("proInstId", proInstId);
model.addAttribute("actImpls", actImpls);
return "modules/act/actTaskMap";
}*/
/**
* 删除任务
* @param taskId 流程实例ID
* @param reason 删除原因
*/
@RequiresPermissions
(
"act:process:edit"
)
@RequestMapping
(
value
=
"deleteTask"
)
public
String
deleteTask
(
String
taskId
,
String
reason
,
RedirectAttributes
redirectAttributes
)
{
if
(
StringUtils
.
isBlank
(
reason
)){
addMessage
(
redirectAttributes
,
"请填写删除原因"
);
}
else
{
actTaskService
.
deleteTask
(
taskId
,
reason
);
addMessage
(
redirectAttributes
,
"删除任务成功,任务ID="
+
taskId
);
}
return
"redirect:"
+
adminPath
+
"/act/task"
;
}
}
JeeSpringCloud/jeespring-act/src/main/java/com/jeespring/modules/oa/dao/TestAuditDao.java
0 → 100644
View file @
08c32267
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.oa.dao
;
import
com.jeespring.common.persistence.InterfaceBaseDao
;
import
com.jeespring.common.persistence.annotation.MyBatisDao
;
import
com.jeespring.modules.oa.entity.TestAudit
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* 审批DAO接口
* @author thinkgem
* @version 2014-05-16
*/
@Mapper
public
interface
TestAuditDao
extends
InterfaceBaseDao
<
TestAudit
>
{
public
TestAudit
getByProcInsId
(
String
procInsId
);
public
int
updateInsId
(
TestAudit
testAudit
);
public
int
updateHrText
(
TestAudit
testAudit
);
public
int
updateLeadText
(
TestAudit
testAudit
);
public
int
updateMainLeadText
(
TestAudit
testAudit
);
}
JeeSpringCloud/jeespring-act/src/main/java/com/jeespring/modules/oa/entity/TestAudit.java
0 → 100644
View file @
08c32267
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.oa.entity
;
import
com.jeespring.common.persistence.ActEntity
;
import
com.jeespring.modules.sys.entity.Office
;
import
com.jeespring.modules.sys.entity.User
;
/**
* 审批Entity
* @author thinkgem
* @version 2014-05-16
*/
public
class
TestAudit
extends
ActEntity
<
TestAudit
>
{
private
static
final
long
serialVersionUID
=
1L
;
private
User
user
;
// 归属用户
private
Office
office
;
// 归属部门
private
String
post
;
// 岗位
private
String
age
;
// 性别
private
String
edu
;
// 学历
private
String
content
;
// 调整原因
private
String
olda
;
// 现行标准 薪酬档级
private
String
oldb
;
// 现行标准 月工资额
private
String
oldc
;
// 现行标准 年薪总额
private
String
newa
;
// 调整后标准 薪酬档级
private
String
newb
;
// 调整后标准 月工资额
private
String
newc
;
// 调整后标准 年薪总额
private
String
addNum
;
// 月增资
private
String
exeDate
;
// 执行时间
private
String
hrText
;
// 人力资源部门意见
private
String
leadText
;
// 分管领导意见
private
String
mainLeadText
;
// 集团主要领导意见
public
TestAudit
()
{
super
();
}
public
TestAudit
(
String
id
){
super
(
id
);
}
public
String
getPost
()
{
return
post
;
}
public
void
setPost
(
String
post
)
{
this
.
post
=
post
;
}
public
String
getAge
()
{
return
age
;
}
public
void
setAge
(
String
age
)
{
this
.
age
=
age
;
}
public
String
getEdu
()
{
return
edu
;
}
public
void
setEdu
(
String
edu
)
{
this
.
edu
=
edu
;
}
public
String
getContent
()
{
return
content
;
}
public
void
setContent
(
String
content
)
{
this
.
content
=
content
;
}
public
String
getOlda
()
{
return
olda
;
}
public
void
setOlda
(
String
olda
)
{
this
.
olda
=
olda
;
}
public
String
getOldb
()
{
return
oldb
;
}
public
void
setOldb
(
String
oldb
)
{
this
.
oldb
=
oldb
;
}
public
String
getOldc
()
{
return
oldc
;
}
public
void
setOldc
(
String
oldc
)
{
this
.
oldc
=
oldc
;
}
public
String
getNewa
()
{
return
newa
;
}
public
void
setNewa
(
String
newa
)
{
this
.
newa
=
newa
;
}
public
String
getNewb
()
{
return
newb
;
}
public
void
setNewb
(
String
newb
)
{
this
.
newb
=
newb
;
}
public
String
getNewc
()
{
return
newc
;
}
public
void
setNewc
(
String
newc
)
{
this
.
newc
=
newc
;
}
public
String
getExeDate
()
{
return
exeDate
;
}
public
void
setExeDate
(
String
exeDate
)
{
this
.
exeDate
=
exeDate
;
}
public
String
getHrText
()
{
return
hrText
;
}
public
void
setHrText
(
String
hrText
)
{
this
.
hrText
=
hrText
;
}
public
String
getLeadText
()
{
return
leadText
;
}
public
void
setLeadText
(
String
leadText
)
{
this
.
leadText
=
leadText
;
}
public
String
getMainLeadText
()
{
return
mainLeadText
;
}
public
void
setMainLeadText
(
String
mainLeadText
)
{
this
.
mainLeadText
=
mainLeadText
;
}
public
User
getUser
()
{
return
user
;
}
public
void
setUser
(
User
user
)
{
this
.
user
=
user
;
}
public
Office
getOffice
()
{
return
office
;
}
public
void
setOffice
(
Office
office
)
{
this
.
office
=
office
;
}
public
String
getAddNum
()
{
return
addNum
;
}
public
void
setAddNum
(
String
addNum
)
{
this
.
addNum
=
addNum
;
}
}
JeeSpringCloud/jeespring-act/src/main/java/com/jeespring/modules/oa/service/TestAuditService.java
0 → 100644
View file @
08c32267
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.oa.service
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.google.common.collect.Maps
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.service.AbstractBaseService
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.modules.act.service.ActTaskService
;
import
com.jeespring.modules.act.utils.ActUtils
;
import
com.jeespring.modules.oa.entity.TestAudit
;
import
com.jeespring.modules.oa.dao.TestAuditDao
;
/**
* 审批Service
* @author thinkgem
* @version 2014-05-16
*/
@Service
@Transactional
(
readOnly
=
true
)
public
class
TestAuditService
extends
AbstractBaseService
<
TestAuditDao
,
TestAudit
>
{
@Autowired
private
ActTaskService
actTaskService
;
public
TestAudit
getByProcInsId
(
String
procInsId
)
{
return
dao
.
getByProcInsId
(
procInsId
);
}
@Override
public
Page
<
TestAudit
>
findPage
(
Page
<
TestAudit
>
page
,
TestAudit
testAudit
)
{
testAudit
.
setPage
(
page
);
page
.
setList
(
dao
.
findList
(
testAudit
));
return
page
;
}
/**
* 审核新增或编辑
* @param testAudit
*/
@Override
@Transactional
(
readOnly
=
false
)
public
void
save
(
TestAudit
testAudit
)
{
// 申请发起
if
(
StringUtils
.
isBlank
(
testAudit
.
getId
())){
testAudit
.
preInsert
();
dao
.
insert
(
testAudit
);
// 启动流程
actTaskService
.
startProcess
(
ActUtils
.
PD_TEST_AUDIT
[
0
],
ActUtils
.
PD_TEST_AUDIT
[
1
],
testAudit
.
getId
(),
testAudit
.
getContent
());
}
// 重新编辑申请
else
{
testAudit
.
preUpdate
();
dao
.
update
(
testAudit
);
testAudit
.
getAct
().
setComment
((
"yes"
.
equals
(
testAudit
.
getAct
().
getFlag
())?
"[重申] "
:
"[销毁] "
)+
testAudit
.
getAct
().
getComment
());
// 完成流程任务
Map
<
String
,
Object
>
vars
=
Maps
.
newHashMap
();
vars
.
put
(
"pass"
,
"yes"
.
equals
(
testAudit
.
getAct
().
getFlag
())?
"1"
:
"0"
);
actTaskService
.
complete
(
testAudit
.
getAct
().
getTaskId
(),
testAudit
.
getAct
().
getProcInsId
(),
testAudit
.
getAct
().
getComment
(),
testAudit
.
getContent
(),
vars
);
}
}
/**
* 审核审批保存
* @param testAudit
*/
@Transactional
(
readOnly
=
false
)
public
void
auditSave
(
TestAudit
testAudit
)
{
// 设置意见
testAudit
.
getAct
().
setComment
((
"yes"
.
equals
(
testAudit
.
getAct
().
getFlag
())?
"[同意] "
:
"[驳回] "
)+
testAudit
.
getAct
().
getComment
());
testAudit
.
preUpdate
();
// 对不同环节的业务逻辑进行操作
String
taskDefKey
=
testAudit
.
getAct
().
getTaskDefKey
();
// 审核环节
if
(
"audit"
.
equals
(
taskDefKey
)){
}
else
if
(
"audit2"
.
equals
(
taskDefKey
)){
testAudit
.
setHrText
(
testAudit
.
getAct
().
getComment
());
dao
.
updateHrText
(
testAudit
);
}
else
if
(
"audit3"
.
equals
(
taskDefKey
)){
testAudit
.
setLeadText
(
testAudit
.
getAct
().
getComment
());
dao
.
updateLeadText
(
testAudit
);
}
else
if
(
"audit4"
.
equals
(
taskDefKey
)){
testAudit
.
setMainLeadText
(
testAudit
.
getAct
().
getComment
());
dao
.
updateMainLeadText
(
testAudit
);
}
else
if
(
"apply_end"
.
equals
(
taskDefKey
)){
}
// 未知环节,直接返回
else
{
return
;
}
// 提交流程任务
Map
<
String
,
Object
>
vars
=
Maps
.
newHashMap
();
vars
.
put
(
"pass"
,
"yes"
.
equals
(
testAudit
.
getAct
().
getFlag
())?
"1"
:
"0"
);
actTaskService
.
complete
(
testAudit
.
getAct
().
getTaskId
(),
testAudit
.
getAct
().
getProcInsId
(),
testAudit
.
getAct
().
getComment
(),
vars
);
// vars.put("var_test", "yes_no_test2");
// actTaskService.getProcessEngine().getTaskService().addComment(testAudit.getAct().getTaskId(), testAudit.getAct().getProcInsId(), testAudit.getAct().getComment());
// actTaskService.jumpTask(testAudit.getAct().getProcInsId(), testAudit.getAct().getTaskId(), "audit2", vars);
}
}
JeeSpringCloud/jeespring-act/src/main/java/com/jeespring/modules/oa/web/TestAuditController.java
0 → 100644
View file @
08c32267
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.oa.web
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.modules.sys.entity.User
;
import
com.jeespring.modules.sys.utils.UserUtils
;
import
com.jeespring.modules.oa.entity.TestAudit
;
import
com.jeespring.modules.oa.service.TestAuditService
;
/**
* 审批Controller
* @author thinkgem
* @version 2014-05-16
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/oa/testAudit"
)
public
class
TestAuditController
extends
AbstractBaseController
{
@Autowired
private
TestAuditService
testAuditService
;
@ModelAttribute
public
TestAudit
get
(
@RequestParam
(
required
=
false
)
String
id
){
//,
// @RequestParam(value="act.procInsId", required=false) String procInsId) {
TestAudit
testAudit
=
null
;
if
(
StringUtils
.
isNotBlank
(
id
)){
testAudit
=
testAuditService
.
get
(
id
);
// }else if (StringUtils.isNotBlank(procInsId)){
// testAudit = testAuditService.getByProcInsId(procInsId);
}
if
(
testAudit
==
null
){
testAudit
=
new
TestAudit
();
}
return
testAudit
;
}
@RequiresPermissions
(
"oa:testAudit:view"
)
@RequestMapping
(
value
=
{
"list"
,
""
})
public
String
list
(
TestAudit
testAudit
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
User
user
=
UserUtils
.
getUser
();
if
(!
user
.
isAdmin
()){
testAudit
.
setCreateBy
(
user
);
}
Page
<
TestAudit
>
page
=
testAuditService
.
findPage
(
new
Page
<
TestAudit
>(
request
,
response
),
testAudit
);
model
.
addAttribute
(
"page"
,
page
);
return
"modules/oa/testAuditList"
;
}
/**
* 申请单填写
* @param testAudit
* @param model
* @return
*/
@RequiresPermissions
(
"oa:testAudit:view"
)
@RequestMapping
(
value
=
"form"
)
public
String
form
(
TestAudit
testAudit
,
Model
model
)
{
String
view
=
"testAuditForm"
;
// 查看审批申请单
if
(
StringUtils
.
isNotBlank
(
testAudit
.
getId
())){
//.getAct().getProcInsId())){
// 环节编号
String
taskDefKey
=
testAudit
.
getAct
().
getTaskDefKey
();
// 查看工单
if
(
testAudit
.
getAct
().
isFinishTask
()){
view
=
"testAuditView"
;
}
// 修改环节
else
if
(
"modify"
.
equals
(
taskDefKey
)){
view
=
"testAuditForm"
;
}
// 审核环节
else
if
(
"audit"
.
equals
(
taskDefKey
)){
view
=
"testAuditAudit"
;
// String formKey = "/oa/testAudit";
// return "redirect:" + ActUtils.getFormUrl(formKey, testAudit.getAct());
}
// 审核环节2
else
if
(
"audit2"
.
equals
(
taskDefKey
)){
view
=
"testAuditAudit"
;
}
// 审核环节3
else
if
(
"audit3"
.
equals
(
taskDefKey
)){
view
=
"testAuditAudit"
;
}
// 审核环节4
else
if
(
"audit4"
.
equals
(
taskDefKey
)){
view
=
"testAuditAudit"
;
}
// 兑现环节
else
if
(
"apply_end"
.
equals
(
taskDefKey
)){
view
=
"testAuditAudit"
;
}
}
model
.
addAttribute
(
"testAudit"
,
testAudit
);
return
"modules/oa/"
+
view
;
}
/**
* 申请单保存/修改
* @param testAudit
* @param model
* @param redirectAttributes
* @return
*/
@RequiresPermissions
(
"oa:testAudit:edit"
)
@RequestMapping
(
value
=
"save"
)
public
String
save
(
TestAudit
testAudit
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
if
(!
beanValidator
(
model
,
testAudit
)){
return
form
(
testAudit
,
model
);
}
testAuditService
.
save
(
testAudit
);
addMessage
(
redirectAttributes
,
"提交审批'"
+
testAudit
.
getUser
().
getName
()
+
"'成功"
);
return
"redirect:"
+
adminPath
+
"/act/task/todo/"
;
}
/**
* 工单执行(完成任务)
* @param testAudit
* @param model
* @return
*/
@RequiresPermissions
(
"oa:testAudit:edit"
)
@RequestMapping
(
value
=
"saveAudit"
)
public
String
saveAudit
(
TestAudit
testAudit
,
Model
model
)
{
if
(
StringUtils
.
isBlank
(
testAudit
.
getAct
().
getFlag
())
||
StringUtils
.
isBlank
(
testAudit
.
getAct
().
getComment
())){
addMessage
(
model
,
"请填写审核意见。"
);
return
form
(
testAudit
,
model
);
}
testAuditService
.
auditSave
(
testAudit
);
return
"redirect:"
+
adminPath
+
"/act/task/todo/"
;
}
/**
* 删除工单
* @param id
* @param redirectAttributes
* @return
*/
@RequiresPermissions
(
"oa:testAudit:edit"
)
@RequestMapping
(
value
=
"delete"
)
public
String
delete
(
TestAudit
testAudit
,
RedirectAttributes
redirectAttributes
)
{
testAuditService
.
delete
(
testAudit
);
addMessage
(
redirectAttributes
,
"删除审批成功"
);
return
"redirect:"
+
adminPath
+
"/oa/testAudit/?repage"
;
}
}
JeeSpringCloud/jeespring-act/src/main/java/org/activiti/editor/language/json/converter/BpmnJsonConverter.java
0 → 100644
View file @
08c32267
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.activiti.editor.language.json.converter
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.node.ArrayNode
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
math.geom2d.Point2D
;
import
math.geom2d.conic.Circle2D
;
import
math.geom2d.curve.AbstractContinuousCurve2D
;
import
math.geom2d.line.Line2D
;
import
math.geom2d.polygon.Polyline2D
;
import
org.activiti.bpmn.model.Activity
;
import
org.activiti.bpmn.model.Artifact
;
import
org.activiti.bpmn.model.BaseElement
;
import
org.activiti.bpmn.model.BoundaryEvent
;
import
org.activiti.bpmn.model.BpmnModel
;
import
org.activiti.bpmn.model.Event
;
import
org.activiti.bpmn.model.EventDefinition
;
import
org.activiti.bpmn.model.ExtensionElement
;
import
org.activiti.bpmn.model.FlowElement
;
import
org.activiti.bpmn.model.FlowElementsContainer
;
import
org.activiti.bpmn.model.FlowNode
;
import
org.activiti.bpmn.model.Gateway
;
import
org.activiti.bpmn.model.GraphicInfo
;
import
org.activiti.bpmn.model.Lane
;
import
org.activiti.bpmn.model.Message
;
import
org.activiti.bpmn.model.MessageEventDefinition
;
import
org.activiti.bpmn.model.MessageFlow
;
import
org.activiti.bpmn.model.Pool
;
import
org.activiti.bpmn.model.Process
;
import
org.activiti.bpmn.model.SequenceFlow
;
import
org.activiti.bpmn.model.Signal
;
import
org.activiti.bpmn.model.SignalEventDefinition
;
import
org.activiti.bpmn.model.SubProcess
;
import
org.activiti.bpmn.model.ValuedDataObject
;
import
org.activiti.editor.constants.EditorJsonConstants
;
import
org.activiti.editor.constants.StencilConstants
;
import
org.activiti.editor.language.json.converter.util.JsonConverterUtil
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author Tijs Rademakers
* @modify xuhuisheng 解决modeler发布的流程图,sequenceFlow不显示的问题
*/
public
class
BpmnJsonConverter
implements
EditorJsonConstants
,
StencilConstants
,
ActivityProcessor
{
protected
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
BpmnJsonConverter
.
class
);
protected
static
Map
<
Class
<?
extends
BaseElement
>,
Class
<?
extends
BaseBpmnJsonConverter
>>
convertersToJsonMap
=
new
HashMap
<
Class
<?
extends
BaseElement
>,
Class
<?
extends
BaseBpmnJsonConverter
>>();
protected
static
Map
<
String
,
Class
<?
extends
BaseBpmnJsonConverter
>>
convertersToBpmnMap
=
new
HashMap
<
String
,
Class
<?
extends
BaseBpmnJsonConverter
>>();
public
static
final
String
MODELER_NAMESPACE
=
"http://activiti.com/modeler"
;
protected
static
final
DateFormat
defaultFormat
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
);
protected
static
final
DateFormat
entFormat
=
new
SimpleDateFormat
(
"yyyyMMddHHmmssSSS"
);
static
{
// start and end events
StartEventJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
EndEventJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
// connectors
SequenceFlowJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
MessageFlowJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
AssociationJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
// task types
BusinessRuleTaskJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
MailTaskJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
ManualTaskJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
ReceiveTaskJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
ScriptTaskJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
ServiceTaskJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
UserTaskJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
CallActivityJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
CamelTaskJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
MuleTaskJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
SendTaskJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
// gateways
ExclusiveGatewayJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
InclusiveGatewayJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
ParallelGatewayJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
EventGatewayJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
// scope constructs
SubProcessJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
EventSubProcessJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
// catch events
CatchEventJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
// throw events
ThrowEventJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
// boundary events
BoundaryEventJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
// artifacts
TextAnnotationJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
DataStoreJsonConverter
.
fillTypes
(
convertersToBpmnMap
,
convertersToJsonMap
);
}
private
static
final
List
<
String
>
DI_CIRCLES
=
new
ArrayList
<
String
>();
private
static
final
List
<
String
>
DI_RECTANGLES
=
new
ArrayList
<
String
>();
private
static
final
List
<
String
>
DI_GATEWAY
=
new
ArrayList
<
String
>();
static
{
DI_CIRCLES
.
add
(
STENCIL_EVENT_START_ERROR
);
DI_CIRCLES
.
add
(
STENCIL_EVENT_START_MESSAGE
);
DI_CIRCLES
.
add
(
STENCIL_EVENT_START_NONE
);
DI_CIRCLES
.
add
(
STENCIL_EVENT_START_TIMER
);
DI_CIRCLES
.
add
(
STENCIL_EVENT_START_SIGNAL
);
DI_CIRCLES
.
add
(
STENCIL_EVENT_BOUNDARY_ERROR
);
DI_CIRCLES
.
add
(
STENCIL_EVENT_BOUNDARY_SIGNAL
);
DI_CIRCLES
.
add
(
STENCIL_EVENT_BOUNDARY_TIMER
);
DI_CIRCLES
.
add
(
STENCIL_EVENT_BOUNDARY_MESSAGE
);
DI_CIRCLES
.
add
(
STENCIL_EVENT_BOUNDARY_CANCEL
);
DI_CIRCLES
.
add
(
STENCIL_EVENT_BOUNDARY_COMPENSATION
);
DI_CIRCLES
.
add
(
STENCIL_EVENT_CATCH_MESSAGE
);
DI_CIRCLES
.
add
(
STENCIL_EVENT_CATCH_SIGNAL
);
DI_CIRCLES
.
add
(
STENCIL_EVENT_CATCH_TIMER
);
DI_CIRCLES
.
add
(
STENCIL_EVENT_THROW_NONE
);
DI_CIRCLES
.
add
(
STENCIL_EVENT_THROW_SIGNAL
);
DI_CIRCLES
.
add
(
STENCIL_EVENT_END_NONE
);
DI_CIRCLES
.
add
(
STENCIL_EVENT_END_ERROR
);
DI_CIRCLES
.
add
(
STENCIL_EVENT_END_CANCEL
);
DI_CIRCLES
.
add
(
STENCIL_EVENT_END_TERMINATE
);
DI_RECTANGLES
.
add
(
STENCIL_CALL_ACTIVITY
);
DI_RECTANGLES
.
add
(
STENCIL_SUB_PROCESS
);
DI_RECTANGLES
.
add
(
STENCIL_EVENT_SUB_PROCESS
);
DI_RECTANGLES
.
add
(
STENCIL_TASK_BUSINESS_RULE
);
DI_RECTANGLES
.
add
(
STENCIL_TASK_MAIL
);
DI_RECTANGLES
.
add
(
STENCIL_TASK_MANUAL
);
DI_RECTANGLES
.
add
(
STENCIL_TASK_RECEIVE
);
DI_RECTANGLES
.
add
(
STENCIL_TASK_SCRIPT
);
DI_RECTANGLES
.
add
(
STENCIL_TASK_SEND
);
DI_RECTANGLES
.
add
(
STENCIL_TASK_SERVICE
);
DI_RECTANGLES
.
add
(
STENCIL_TASK_USER
);
DI_RECTANGLES
.
add
(
STENCIL_TASK_CAMEL
);
DI_RECTANGLES
.
add
(
STENCIL_TASK_MULE
);
DI_RECTANGLES
.
add
(
STENCIL_TEXT_ANNOTATION
);
DI_GATEWAY
.
add
(
STENCIL_GATEWAY_EVENT
);
DI_GATEWAY
.
add
(
STENCIL_GATEWAY_EXCLUSIVE
);
DI_GATEWAY
.
add
(
STENCIL_GATEWAY_INCLUSIVE
);
DI_GATEWAY
.
add
(
STENCIL_GATEWAY_PARALLEL
);
}
protected
ObjectMapper
objectMapper
=
new
ObjectMapper
();
public
ObjectNode
convertToJson
(
BpmnModel
model
)
{
ObjectNode
modelNode
=
objectMapper
.
createObjectNode
();
double
maxX
=
0.0
;
double
maxY
=
0.0
;
for
(
GraphicInfo
flowInfo
:
model
.
getLocationMap
().
values
())
{
if
((
flowInfo
.
getX
()
+
flowInfo
.
getWidth
())
>
maxX
)
{
maxX
=
flowInfo
.
getX
()
+
flowInfo
.
getWidth
();
}
if
((
flowInfo
.
getY
()
+
flowInfo
.
getHeight
())
>
maxY
)
{
maxY
=
flowInfo
.
getY
()
+
flowInfo
.
getHeight
();
}
}
maxX
+=
50
;
maxY
+=
50
;
if
(
maxX
<
1485
)
{
maxX
=
1485
;
}
if
(
maxY
<
700
)
{
maxY
=
700
;
}
modelNode
.
put
(
"bounds"
,
BpmnJsonConverterUtil
.
createBoundsNode
(
maxX
,
maxY
,
0
,
0
));
modelNode
.
put
(
"resourceId"
,
"canvas"
);
ObjectNode
stencilNode
=
objectMapper
.
createObjectNode
();
stencilNode
.
put
(
"id"
,
"BPMNDiagram"
);
modelNode
.
put
(
"stencil"
,
stencilNode
);
ObjectNode
stencilsetNode
=
objectMapper
.
createObjectNode
();
stencilsetNode
.
put
(
"namespace"
,
"http://b3mn.org/stencilset/bpmn2.0#"
);
stencilsetNode
.
put
(
"url"
,
"../editor/stencilsets/bpmn2.0/bpmn2.0.json"
);
modelNode
.
put
(
"stencilset"
,
stencilsetNode
);
ArrayNode
shapesArrayNode
=
objectMapper
.
createArrayNode
();
Process
mainProcess
=
null
;
if
(
model
.
getPools
().
size
()
>
0
)
{
mainProcess
=
model
.
getProcess
(
model
.
getPools
().
get
(
0
).
getId
());
}
else
{
mainProcess
=
model
.
getMainProcess
();
}
ObjectNode
propertiesNode
=
objectMapper
.
createObjectNode
();
if
(
StringUtils
.
isNotEmpty
(
mainProcess
.
getId
()))
{
propertiesNode
.
put
(
PROPERTY_PROCESS_ID
,
mainProcess
.
getId
());
}
if
(
StringUtils
.
isNotEmpty
(
mainProcess
.
getName
()))
{
propertiesNode
.
put
(
PROPERTY_NAME
,
mainProcess
.
getName
());
}
if
(
StringUtils
.
isNotEmpty
(
mainProcess
.
getDocumentation
()))
{
propertiesNode
.
put
(
PROPERTY_DOCUMENTATION
,
mainProcess
.
getDocumentation
());
}
if
(
mainProcess
.
isExecutable
()
==
false
)
{
propertiesNode
.
put
(
PROPERTY_PROCESS_EXECUTABLE
,
"No"
);
}
if
(
StringUtils
.
isNoneEmpty
(
model
.
getTargetNamespace
()))
{
propertiesNode
.
put
(
PROPERTY_PROCESS_NAMESPACE
,
model
.
getTargetNamespace
());
}
BpmnJsonConverterUtil
.
convertMessagesToJson
(
model
.
getMessages
(),
propertiesNode
);
BpmnJsonConverterUtil
.
convertListenersToJson
(
mainProcess
.
getExecutionListeners
(),
true
,
propertiesNode
);
BpmnJsonConverterUtil
.
convertEventListenersToJson
(
mainProcess
.
getEventListeners
(),
propertiesNode
);
BpmnJsonConverterUtil
.
convertSignalDefinitionsToJson
(
model
,
propertiesNode
);
BpmnJsonConverterUtil
.
convertMessagesToJson
(
model
,
propertiesNode
);
if
(
CollectionUtils
.
isNotEmpty
(
mainProcess
.
getDataObjects
()))
{
BpmnJsonConverterUtil
.
convertDataPropertiesToJson
(
mainProcess
.
getDataObjects
(),
propertiesNode
);
}
modelNode
.
put
(
EDITOR_SHAPE_PROPERTIES
,
propertiesNode
);
boolean
poolHasDI
=
false
;
if
(
model
.
getPools
().
size
()
>
0
)
{
for
(
Pool
pool
:
model
.
getPools
())
{
GraphicInfo
graphicInfo
=
model
.
getGraphicInfo
(
pool
.
getId
());
if
(
graphicInfo
!=
null
)
{
poolHasDI
=
true
;
break
;
}
}
}
if
((
model
.
getPools
().
size
()
>
0
)
&&
poolHasDI
)
{
for
(
Pool
pool
:
model
.
getPools
())
{
GraphicInfo
graphicInfo
=
model
.
getGraphicInfo
(
pool
.
getId
());
if
(
graphicInfo
==
null
)
{
continue
;
}
ObjectNode
poolNode
=
BpmnJsonConverterUtil
.
createChildShape
(
pool
.
getId
(),
STENCIL_POOL
,
graphicInfo
.
getX
()
+
graphicInfo
.
getWidth
(),
graphicInfo
.
getY
()
+
graphicInfo
.
getHeight
(),
graphicInfo
.
getX
(),
graphicInfo
.
getY
());
shapesArrayNode
.
add
(
poolNode
);
ObjectNode
poolPropertiesNode
=
objectMapper
.
createObjectNode
();
poolPropertiesNode
.
put
(
PROPERTY_OVERRIDE_ID
,
pool
.
getId
());
poolPropertiesNode
.
put
(
PROPERTY_PROCESS_ID
,
pool
.
getProcessRef
());
if
(
pool
.
isExecutable
()
==
false
)
{
poolPropertiesNode
.
put
(
PROPERTY_PROCESS_EXECUTABLE
,
PROPERTY_VALUE_NO
);
}
if
(
StringUtils
.
isNotEmpty
(
pool
.
getName
()))
{
poolPropertiesNode
.
put
(
PROPERTY_NAME
,
pool
.
getName
());
}
poolNode
.
put
(
EDITOR_SHAPE_PROPERTIES
,
poolPropertiesNode
);
ArrayNode
laneShapesArrayNode
=
objectMapper
.
createArrayNode
();
poolNode
.
put
(
EDITOR_CHILD_SHAPES
,
laneShapesArrayNode
);
ArrayNode
outgoingArrayNode
=
objectMapper
.
createArrayNode
();
poolNode
.
put
(
"outgoing"
,
outgoingArrayNode
);
Process
process
=
model
.
getProcess
(
pool
.
getId
());
if
(
process
!=
null
)
{
Map
<
String
,
ArrayNode
>
laneMap
=
new
HashMap
<
String
,
ArrayNode
>();
for
(
Lane
lane
:
process
.
getLanes
())
{
GraphicInfo
laneGraphicInfo
=
model
.
getGraphicInfo
(
lane
.
getId
());
if
(
laneGraphicInfo
==
null
)
{
continue
;
}
ObjectNode
laneNode
=
BpmnJsonConverterUtil
.
createChildShape
(
lane
.
getId
(),
STENCIL_LANE
,
laneGraphicInfo
.
getX
()
+
laneGraphicInfo
.
getWidth
(),
laneGraphicInfo
.
getY
()
+
laneGraphicInfo
.
getHeight
(),
laneGraphicInfo
.
getX
(),
laneGraphicInfo
.
getY
());
laneShapesArrayNode
.
add
(
laneNode
);
ObjectNode
lanePropertiesNode
=
objectMapper
.
createObjectNode
();
lanePropertiesNode
.
put
(
PROPERTY_OVERRIDE_ID
,
lane
.
getId
());
if
(
StringUtils
.
isNotEmpty
(
lane
.
getName
()))
{
lanePropertiesNode
.
put
(
PROPERTY_NAME
,
lane
.
getName
());
}
laneNode
.
put
(
EDITOR_SHAPE_PROPERTIES
,
lanePropertiesNode
);
ArrayNode
elementShapesArrayNode
=
objectMapper
.
createArrayNode
();
laneNode
.
put
(
EDITOR_CHILD_SHAPES
,
elementShapesArrayNode
);
laneNode
.
put
(
"outgoing"
,
objectMapper
.
createArrayNode
());
laneMap
.
put
(
lane
.
getId
(),
elementShapesArrayNode
);
}
for
(
FlowElement
flowElement
:
process
.
getFlowElements
())
{
Lane
laneForElement
=
null
;
GraphicInfo
laneGraphicInfo
=
null
;
FlowElement
lookForElement
=
null
;
if
(
flowElement
instanceof
SequenceFlow
)
{
SequenceFlow
sequenceFlow
=
(
SequenceFlow
)
flowElement
;
lookForElement
=
model
.
getFlowElement
(
sequenceFlow
.
getSourceRef
());
}
else
{
lookForElement
=
flowElement
;
}
for
(
Lane
lane
:
process
.
getLanes
())
{
if
(
lane
.
getFlowReferences
().
contains
(
lookForElement
.
getId
()))
{
laneGraphicInfo
=
model
.
getGraphicInfo
(
lane
.
getId
());
if
(
laneGraphicInfo
!=
null
)
{
laneForElement
=
lane
;
}
break
;
}
}
if
(
flowElement
instanceof
SequenceFlow
||
(
laneForElement
!=
null
))
{
processFlowElement
(
flowElement
,
process
,
model
,
laneMap
.
get
(
laneForElement
.
getId
()),
laneGraphicInfo
.
getX
(),
laneGraphicInfo
.
getY
());
}
}
processArtifacts
(
process
,
model
,
shapesArrayNode
,
0.0
,
0.0
);
}
for
(
MessageFlow
messageFlow
:
model
.
getMessageFlows
().
values
())
{
if
(
messageFlow
.
getSourceRef
().
equals
(
pool
.
getId
()))
{
outgoingArrayNode
.
add
(
BpmnJsonConverterUtil
.
createResourceNode
(
messageFlow
.
getId
()));
}
}
}
processMessageFlows
(
model
,
shapesArrayNode
);
}
else
{
processFlowElements
(
model
.
getMainProcess
(),
model
,
shapesArrayNode
,
0.0
,
0.0
);
processMessageFlows
(
model
,
shapesArrayNode
);
}
modelNode
.
put
(
EDITOR_CHILD_SHAPES
,
shapesArrayNode
);
return
modelNode
;
}
public
void
processFlowElements
(
FlowElementsContainer
container
,
BpmnModel
model
,
ArrayNode
shapesArrayNode
,
double
subProcessX
,
double
subProcessY
)
{
for
(
FlowElement
flowElement
:
container
.
getFlowElements
())
{
processFlowElement
(
flowElement
,
container
,
model
,
shapesArrayNode
,
subProcessX
,
subProcessY
);
}
processArtifacts
(
container
,
model
,
shapesArrayNode
,
subProcessX
,
subProcessY
);
}
protected
void
processFlowElement
(
FlowElement
flowElement
,
FlowElementsContainer
container
,
BpmnModel
model
,
ArrayNode
shapesArrayNode
,
double
containerX
,
double
containerY
)
{
Class
<?
extends
BaseBpmnJsonConverter
>
converter
=
convertersToJsonMap
.
get
(
flowElement
.
getClass
());
if
(
converter
!=
null
)
{
try
{
converter
.
newInstance
().
convertToJson
(
flowElement
,
this
,
model
,
container
,
shapesArrayNode
,
containerX
,
containerY
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"Error converting {}"
,
flowElement
,
e
);
}
}
}
protected
void
processArtifacts
(
FlowElementsContainer
container
,
BpmnModel
model
,
ArrayNode
shapesArrayNode
,
double
containerX
,
double
containerY
)
{
for
(
Artifact
artifact
:
container
.
getArtifacts
())
{
Class
<?
extends
BaseBpmnJsonConverter
>
converter
=
convertersToJsonMap
.
get
(
artifact
.
getClass
());
if
(
converter
!=
null
)
{
try
{
converter
.
newInstance
().
convertToJson
(
artifact
,
this
,
model
,
container
,
shapesArrayNode
,
containerX
,
containerY
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"Error converting {}"
,
artifact
,
e
);
}
}
}
}
protected
void
processMessageFlows
(
BpmnModel
model
,
ArrayNode
shapesArrayNode
)
{
for
(
MessageFlow
messageFlow
:
model
.
getMessageFlows
().
values
())
{
MessageFlowJsonConverter
jsonConverter
=
new
MessageFlowJsonConverter
();
jsonConverter
.
convertToJson
(
messageFlow
,
this
,
model
,
null
,
shapesArrayNode
,
0.0
,
0.0
);
}
}
public
BpmnModel
convertToBpmnModel
(
JsonNode
modelNode
)
{
BpmnModel
bpmnModel
=
new
BpmnModel
();
bpmnModel
.
setTargetNamespace
(
"http://activiti.org/test"
);
Map
<
String
,
JsonNode
>
shapeMap
=
new
HashMap
<
String
,
JsonNode
>();
Map
<
String
,
JsonNode
>
sourceRefMap
=
new
HashMap
<
String
,
JsonNode
>();
Map
<
String
,
JsonNode
>
edgeMap
=
new
HashMap
<
String
,
JsonNode
>();
Map
<
String
,
List
<
JsonNode
>>
sourceAndTargetMap
=
new
HashMap
<
String
,
List
<
JsonNode
>>();
readShapeDI
(
modelNode
,
0
,
0
,
shapeMap
,
sourceRefMap
,
bpmnModel
);
filterAllEdges
(
modelNode
,
edgeMap
,
sourceAndTargetMap
,
shapeMap
,
sourceRefMap
);
readEdgeDI
(
edgeMap
,
sourceAndTargetMap
,
bpmnModel
);
ArrayNode
shapesArrayNode
=
(
ArrayNode
)
modelNode
.
get
(
EDITOR_CHILD_SHAPES
);
if
((
shapesArrayNode
==
null
)
||
(
shapesArrayNode
.
size
()
==
0
))
{
return
bpmnModel
;
}
boolean
nonEmptyPoolFound
=
false
;
Map
<
String
,
Lane
>
elementInLaneMap
=
new
HashMap
<
String
,
Lane
>();
// first create the pool structure
for
(
JsonNode
shapeNode
:
shapesArrayNode
)
{
String
stencilId
=
BpmnJsonConverterUtil
.
getStencilId
(
shapeNode
);
if
(
STENCIL_POOL
.
equals
(
stencilId
))
{
Pool
pool
=
new
Pool
();
pool
.
setId
(
BpmnJsonConverterUtil
.
getElementId
(
shapeNode
));
pool
.
setName
(
JsonConverterUtil
.
getPropertyValueAsString
(
PROPERTY_NAME
,
shapeNode
));
pool
.
setProcessRef
(
JsonConverterUtil
.
getPropertyValueAsString
(
PROPERTY_PROCESS_ID
,
shapeNode
));
pool
.
setExecutable
(
JsonConverterUtil
.
getPropertyValueAsBoolean
(
PROPERTY_PROCESS_EXECUTABLE
,
shapeNode
,
true
));
bpmnModel
.
getPools
().
add
(
pool
);
Process
process
=
new
Process
();
process
.
setId
(
pool
.
getProcessRef
());
process
.
setName
(
pool
.
getName
());
process
.
setExecutable
(
pool
.
isExecutable
());
bpmnModel
.
addProcess
(
process
);
ArrayNode
laneArrayNode
=
(
ArrayNode
)
shapeNode
.
get
(
EDITOR_CHILD_SHAPES
);
for
(
JsonNode
laneNode
:
laneArrayNode
)
{
// should be a lane, but just check to be certain
String
laneStencilId
=
BpmnJsonConverterUtil
.
getStencilId
(
laneNode
);
if
(
STENCIL_LANE
.
equals
(
laneStencilId
))
{
nonEmptyPoolFound
=
true
;
Lane
lane
=
new
Lane
();
lane
.
setId
(
BpmnJsonConverterUtil
.
getElementId
(
laneNode
));
lane
.
setName
(
JsonConverterUtil
.
getPropertyValueAsString
(
PROPERTY_NAME
,
laneNode
));
lane
.
setParentProcess
(
process
);
process
.
getLanes
().
add
(
lane
);
processJsonElements
(
laneNode
.
get
(
EDITOR_CHILD_SHAPES
),
modelNode
,
lane
,
shapeMap
,
bpmnModel
);
if
(
CollectionUtils
.
isNotEmpty
(
lane
.
getFlowReferences
()))
{
for
(
String
elementRef
:
lane
.
getFlowReferences
())
{
elementInLaneMap
.
put
(
elementRef
,
lane
);
}
}
}
}
}
}
// Signal Definitions exist on the root level
JsonNode
signalDefinitionNode
=
BpmnJsonConverterUtil
.
getProperty
(
PROPERTY_SIGNAL_DEFINITIONS
,
modelNode
);
signalDefinitionNode
=
BpmnJsonConverterUtil
.
validateIfNodeIsTextual
(
signalDefinitionNode
);
signalDefinitionNode
=
BpmnJsonConverterUtil
.
validateIfNodeIsTextual
(
signalDefinitionNode
);
// no idea why this needs to be done twice ..
if
(
signalDefinitionNode
!=
null
)
{
if
(
signalDefinitionNode
instanceof
ArrayNode
)
{
ArrayNode
signalDefinitionArrayNode
=
(
ArrayNode
)
signalDefinitionNode
;
Iterator
<
JsonNode
>
signalDefinitionIterator
=
signalDefinitionArrayNode
.
iterator
();
while
(
signalDefinitionIterator
.
hasNext
())
{
JsonNode
signalDefinitionJsonNode
=
signalDefinitionIterator
.
next
();
String
signalId
=
signalDefinitionJsonNode
.
get
(
PROPERTY_SIGNAL_DEFINITION_ID
).
asText
();
String
signalName
=
signalDefinitionJsonNode
.
get
(
PROPERTY_SIGNAL_DEFINITION_NAME
).
asText
();
String
signalScope
=
signalDefinitionJsonNode
.
get
(
PROPERTY_SIGNAL_DEFINITION_SCOPE
).
asText
();
Signal
signal
=
new
Signal
();
signal
.
setId
(
signalId
);
signal
.
setName
(
signalName
);
signal
.
setScope
((
signalScope
.
toLowerCase
().
equals
(
"processinstance"
))
?
Signal
.
SCOPE_PROCESS_INSTANCE
:
Signal
.
SCOPE_GLOBAL
);
bpmnModel
.
addSignal
(
signal
);
}
}
}
if
(
nonEmptyPoolFound
==
false
)
{
Process
process
=
new
Process
();
bpmnModel
.
getProcesses
().
add
(
process
);
process
.
setId
(
BpmnJsonConverterUtil
.
getPropertyValueAsString
(
PROPERTY_PROCESS_ID
,
modelNode
));
process
.
setName
(
BpmnJsonConverterUtil
.
getPropertyValueAsString
(
PROPERTY_NAME
,
modelNode
));
String
namespace
=
BpmnJsonConverterUtil
.
getPropertyValueAsString
(
PROPERTY_PROCESS_NAMESPACE
,
modelNode
);
if
(
StringUtils
.
isNotEmpty
(
namespace
))
{
bpmnModel
.
setTargetNamespace
(
namespace
);
}
process
.
setDocumentation
(
BpmnJsonConverterUtil
.
getPropertyValueAsString
(
PROPERTY_DOCUMENTATION
,
modelNode
));
JsonNode
processExecutableNode
=
JsonConverterUtil
.
getProperty
(
PROPERTY_PROCESS_EXECUTABLE
,
modelNode
);
if
((
processExecutableNode
!=
null
)
&&
StringUtils
.
isNotEmpty
(
processExecutableNode
.
asText
()))
{
process
.
setExecutable
(
JsonConverterUtil
.
getPropertyValueAsBoolean
(
PROPERTY_PROCESS_EXECUTABLE
,
modelNode
));
}
BpmnJsonConverterUtil
.
convertJsonToMessages
(
modelNode
,
bpmnModel
);
BpmnJsonConverterUtil
.
convertJsonToListeners
(
modelNode
,
process
);
JsonNode
eventListenersNode
=
BpmnJsonConverterUtil
.
getProperty
(
PROPERTY_EVENT_LISTENERS
,
modelNode
);
if
(
eventListenersNode
!=
null
)
{
eventListenersNode
=
BpmnJsonConverterUtil
.
validateIfNodeIsTextual
(
eventListenersNode
);
BpmnJsonConverterUtil
.
parseEventListeners
(
eventListenersNode
.
get
(
PROPERTY_EVENTLISTENER_VALUE
),
process
);
}
JsonNode
processDataPropertiesNode
=
modelNode
.
get
(
EDITOR_SHAPE_PROPERTIES
).
get
(
PROPERTY_DATA_PROPERTIES
);
if
(
processDataPropertiesNode
!=
null
)
{
List
<
ValuedDataObject
>
dataObjects
=
BpmnJsonConverterUtil
.
convertJsonToDataProperties
(
processDataPropertiesNode
,
process
);
process
.
setDataObjects
(
dataObjects
);
process
.
getFlowElements
().
addAll
(
dataObjects
);
}
processJsonElements
(
shapesArrayNode
,
modelNode
,
process
,
shapeMap
,
bpmnModel
);
}
else
{
// sequence flows are on root level so need additional parsing for pools
for
(
JsonNode
shapeNode
:
shapesArrayNode
)
{
if
(
STENCIL_SEQUENCE_FLOW
.
equalsIgnoreCase
(
BpmnJsonConverterUtil
.
getStencilId
(
shapeNode
))
||
STENCIL_ASSOCIATION
.
equalsIgnoreCase
(
BpmnJsonConverterUtil
.
getStencilId
(
shapeNode
)))
{
String
sourceRef
=
BpmnJsonConverterUtil
.
lookForSourceRef
(
shapeNode
.
get
(
EDITOR_SHAPE_ID
).
asText
(),
modelNode
.
get
(
EDITOR_CHILD_SHAPES
));
if
(
sourceRef
!=
null
)
{
Lane
lane
=
elementInLaneMap
.
get
(
sourceRef
);
SequenceFlowJsonConverter
flowConverter
=
new
SequenceFlowJsonConverter
();
if
(
lane
!=
null
)
{
flowConverter
.
convertToBpmnModel
(
shapeNode
,
modelNode
,
this
,
lane
,
shapeMap
,
bpmnModel
);
}
else
{
flowConverter
.
convertToBpmnModel
(
shapeNode
,
modelNode
,
this
,
bpmnModel
.
getProcesses
().
get
(
0
),
shapeMap
,
bpmnModel
);
}
}
}
}
}
// sequence flows are now all on root level
Map
<
String
,
SubProcess
>
subShapesMap
=
new
HashMap
<
String
,
SubProcess
>();
for
(
Process
process
:
bpmnModel
.
getProcesses
())
{
for
(
FlowElement
flowElement
:
process
.
findFlowElementsOfType
(
SubProcess
.
class
))
{
SubProcess
subProcess
=
(
SubProcess
)
flowElement
;
fillSubShapes
(
subShapesMap
,
subProcess
);
}
if
(
subShapesMap
.
size
()
>
0
)
{
List
<
String
>
removeSubFlowsList
=
new
ArrayList
<
String
>();
for
(
FlowElement
flowElement
:
process
.
findFlowElementsOfType
(
SequenceFlow
.
class
))
{
SequenceFlow
sequenceFlow
=
(
SequenceFlow
)
flowElement
;
if
(
subShapesMap
.
containsKey
(
sequenceFlow
.
getSourceRef
()))
{
SubProcess
subProcess
=
subShapesMap
.
get
(
sequenceFlow
.
getSourceRef
());
if
(
subProcess
.
getFlowElement
(
sequenceFlow
.
getId
())
==
null
)
{
subProcess
.
addFlowElement
(
sequenceFlow
);
removeSubFlowsList
.
add
(
sequenceFlow
.
getId
());
}
}
}
for
(
String
flowId
:
removeSubFlowsList
)
{
process
.
removeFlowElement
(
flowId
);
}
}
}
Map
<
String
,
FlowWithContainer
>
allFlowMap
=
new
HashMap
<
String
,
FlowWithContainer
>();
List
<
Gateway
>
gatewayWithOrderList
=
new
ArrayList
<
Gateway
>();
// post handling of process elements
for
(
Process
process
:
bpmnModel
.
getProcesses
())
{
postProcessElements
(
process
,
process
.
getFlowElements
(),
edgeMap
,
bpmnModel
,
allFlowMap
,
gatewayWithOrderList
);
}
// sort the sequence flows
for
(
Gateway
gateway
:
gatewayWithOrderList
)
{
List
<
ExtensionElement
>
orderList
=
gateway
.
getExtensionElements
().
get
(
"EDITOR_FLOW_ORDER"
);
if
(
CollectionUtils
.
isNotEmpty
(
orderList
))
{
for
(
ExtensionElement
orderElement
:
orderList
)
{
String
flowValue
=
orderElement
.
getElementText
();
if
(
StringUtils
.
isNotEmpty
(
flowValue
))
{
if
(
allFlowMap
.
containsKey
(
flowValue
))
{
FlowWithContainer
flowWithContainer
=
allFlowMap
.
get
(
flowValue
);
flowWithContainer
.
getFlowContainer
().
removeFlowElement
(
flowWithContainer
.
getSequenceFlow
().
getId
());
flowWithContainer
.
getFlowContainer
().
addFlowElement
(
flowWithContainer
.
getSequenceFlow
());
}
}
}
}
gateway
.
getExtensionElements
().
remove
(
"EDITOR_FLOW_ORDER"
);
}
return
bpmnModel
;
}
public
void
processJsonElements
(
JsonNode
shapesArrayNode
,
JsonNode
modelNode
,
BaseElement
parentElement
,
Map
<
String
,
JsonNode
>
shapeMap
,
BpmnModel
bpmnModel
)
{
for
(
JsonNode
shapeNode
:
shapesArrayNode
)
{
String
stencilId
=
BpmnJsonConverterUtil
.
getStencilId
(
shapeNode
);
Class
<?
extends
BaseBpmnJsonConverter
>
converter
=
convertersToBpmnMap
.
get
(
stencilId
);
try
{
BaseBpmnJsonConverter
converterInstance
=
converter
.
newInstance
();
converterInstance
.
convertToBpmnModel
(
shapeNode
,
modelNode
,
this
,
parentElement
,
shapeMap
,
bpmnModel
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"Error converting {}"
,
BpmnJsonConverterUtil
.
getStencilId
(
shapeNode
),
e
);
}
}
}
private
void
fillSubShapes
(
Map
<
String
,
SubProcess
>
subShapesMap
,
SubProcess
subProcess
)
{
for
(
FlowElement
flowElement
:
subProcess
.
getFlowElements
())
{
if
(
flowElement
instanceof
SubProcess
)
{
SubProcess
childSubProcess
=
(
SubProcess
)
flowElement
;
subShapesMap
.
put
(
childSubProcess
.
getId
(),
subProcess
);
fillSubShapes
(
subShapesMap
,
childSubProcess
);
}
else
{
subShapesMap
.
put
(
flowElement
.
getId
(),
subProcess
);
}
}
}
private
void
postProcessElements
(
FlowElementsContainer
parentContainer
,
Collection
<
FlowElement
>
flowElementList
,
Map
<
String
,
JsonNode
>
edgeMap
,
BpmnModel
bpmnModel
,
Map
<
String
,
FlowWithContainer
>
allFlowMap
,
List
<
Gateway
>
gatewayWithOrderList
)
{
for
(
FlowElement
flowElement
:
flowElementList
)
{
if
(
flowElement
instanceof
Event
)
{
Event
event
=
(
Event
)
flowElement
;
if
(
CollectionUtils
.
isNotEmpty
(
event
.
getEventDefinitions
()))
{
EventDefinition
eventDef
=
event
.
getEventDefinitions
().
get
(
0
);
if
(
eventDef
instanceof
SignalEventDefinition
)
{
SignalEventDefinition
signalEventDef
=
(
SignalEventDefinition
)
eventDef
;
if
(
StringUtils
.
isNotEmpty
(
signalEventDef
.
getSignalRef
()))
{
if
(
bpmnModel
.
getSignal
(
signalEventDef
.
getSignalRef
())
==
null
)
{
bpmnModel
.
addSignal
(
new
Signal
(
signalEventDef
.
getSignalRef
(),
signalEventDef
.
getSignalRef
()));
}
}
}
else
if
(
eventDef
instanceof
MessageEventDefinition
)
{
MessageEventDefinition
messageEventDef
=
(
MessageEventDefinition
)
eventDef
;
if
(
StringUtils
.
isNotEmpty
(
messageEventDef
.
getMessageRef
()))
{
if
(
bpmnModel
.
getMessage
(
messageEventDef
.
getMessageRef
())
==
null
)
{
bpmnModel
.
addMessage
(
new
Message
(
messageEventDef
.
getMessageRef
(),
messageEventDef
.
getMessageRef
(),
null
));
}
}
}
}
}
if
(
flowElement
instanceof
BoundaryEvent
)
{
BoundaryEvent
boundaryEvent
=
(
BoundaryEvent
)
flowElement
;
Activity
activity
=
retrieveAttachedRefObject
(
boundaryEvent
.
getAttachedToRefId
(),
parentContainer
.
getFlowElements
());
if
(
activity
==
null
)
{
LOGGER
.
warn
(
"Boundary event "
+
boundaryEvent
.
getId
()
+
" is not attached to any activity"
);
}
else
{
boundaryEvent
.
setAttachedToRef
(
activity
);
activity
.
getBoundaryEvents
().
add
(
boundaryEvent
);
}
}
else
if
(
flowElement
instanceof
Gateway
)
{
if
(
flowElement
.
getExtensionElements
().
containsKey
(
"EDITOR_FLOW_ORDER"
))
{
gatewayWithOrderList
.
add
((
Gateway
)
flowElement
);
}
}
else
if
(
flowElement
instanceof
SubProcess
)
{
SubProcess
subProcess
=
(
SubProcess
)
flowElement
;
postProcessElements
(
subProcess
,
subProcess
.
getFlowElements
(),
edgeMap
,
bpmnModel
,
allFlowMap
,
gatewayWithOrderList
);
}
else
if
(
flowElement
instanceof
SequenceFlow
)
{
SequenceFlow
sequenceFlow
=
(
SequenceFlow
)
flowElement
;
FlowElement
sourceFlowElement
=
parentContainer
.
getFlowElement
(
sequenceFlow
.
getSourceRef
());
if
((
sourceFlowElement
!=
null
)
&&
sourceFlowElement
instanceof
FlowNode
)
{
FlowWithContainer
flowWithContainer
=
new
FlowWithContainer
(
sequenceFlow
,
parentContainer
);
if
((
sequenceFlow
.
getExtensionElements
().
get
(
"EDITOR_RESOURCEID"
)
!=
null
)
&&
(
sequenceFlow
.
getExtensionElements
().
get
(
"EDITOR_RESOURCEID"
).
size
()
>
0
))
{
allFlowMap
.
put
(
sequenceFlow
.
getExtensionElements
().
get
(
"EDITOR_RESOURCEID"
).
get
(
0
).
getElementText
(),
flowWithContainer
);
sequenceFlow
.
getExtensionElements
().
remove
(
"EDITOR_RESOURCEID"
);
}
((
FlowNode
)
sourceFlowElement
).
getOutgoingFlows
().
add
(
sequenceFlow
);
JsonNode
edgeNode
=
edgeMap
.
get
(
sequenceFlow
.
getId
());
if
(
edgeNode
!=
null
)
{
boolean
isDefault
=
JsonConverterUtil
.
getPropertyValueAsBoolean
(
"defaultflow"
,
edgeNode
);
if
(
isDefault
)
{
if
(
sourceFlowElement
instanceof
Activity
)
{
((
Activity
)
sourceFlowElement
).
setDefaultFlow
(
sequenceFlow
.
getId
());
}
else
if
(
sourceFlowElement
instanceof
Gateway
)
{
((
Gateway
)
sourceFlowElement
).
setDefaultFlow
(
sequenceFlow
.
getId
());
}
}
}
}
FlowElement
targetFlowElement
=
parentContainer
.
getFlowElement
(
sequenceFlow
.
getTargetRef
());
if
((
targetFlowElement
!=
null
)
&&
targetFlowElement
instanceof
FlowNode
)
{
((
FlowNode
)
targetFlowElement
).
getIncomingFlows
().
add
(
sequenceFlow
);
}
}
}
}
private
Activity
retrieveAttachedRefObject
(
String
attachedToRefId
,
Collection
<
FlowElement
>
flowElementList
)
{
Activity
activity
=
null
;
if
(
StringUtils
.
isNotEmpty
(
attachedToRefId
))
{
for
(
FlowElement
flowElement
:
flowElementList
)
{
if
(
attachedToRefId
.
equals
(
flowElement
.
getId
()))
{
activity
=
(
Activity
)
flowElement
;
break
;
}
else
if
(
flowElement
instanceof
SubProcess
)
{
SubProcess
subProcess
=
(
SubProcess
)
flowElement
;
Activity
retrievedActivity
=
retrieveAttachedRefObject
(
attachedToRefId
,
subProcess
.
getFlowElements
());
if
(
retrievedActivity
!=
null
)
{
activity
=
retrievedActivity
;
break
;
}
}
}
}
return
activity
;
}
private
void
readShapeDI
(
JsonNode
objectNode
,
double
parentX
,
double
parentY
,
Map
<
String
,
JsonNode
>
shapeMap
,
Map
<
String
,
JsonNode
>
sourceRefMap
,
BpmnModel
bpmnModel
)
{
if
(
objectNode
.
get
(
EDITOR_CHILD_SHAPES
)
!=
null
)
{
for
(
JsonNode
jsonChildNode
:
objectNode
.
get
(
EDITOR_CHILD_SHAPES
))
{
String
stencilId
=
BpmnJsonConverterUtil
.
getStencilId
(
jsonChildNode
);
if
(
STENCIL_SEQUENCE_FLOW
.
equals
(
stencilId
)
==
false
)
{
GraphicInfo
graphicInfo
=
new
GraphicInfo
();
JsonNode
boundsNode
=
jsonChildNode
.
get
(
EDITOR_BOUNDS
);
ObjectNode
upperLeftNode
=
(
ObjectNode
)
boundsNode
.
get
(
EDITOR_BOUNDS_UPPER_LEFT
);
graphicInfo
.
setX
(
upperLeftNode
.
get
(
EDITOR_BOUNDS_X
).
asDouble
()
+
parentX
);
graphicInfo
.
setY
(
upperLeftNode
.
get
(
EDITOR_BOUNDS_Y
).
asDouble
()
+
parentY
);
ObjectNode
lowerRightNode
=
(
ObjectNode
)
boundsNode
.
get
(
EDITOR_BOUNDS_LOWER_RIGHT
);
graphicInfo
.
setWidth
(
lowerRightNode
.
get
(
EDITOR_BOUNDS_X
).
asDouble
()
-
graphicInfo
.
getX
()
+
parentX
);
graphicInfo
.
setHeight
(
lowerRightNode
.
get
(
EDITOR_BOUNDS_Y
).
asDouble
()
-
graphicInfo
.
getY
()
+
parentY
);
String
childShapeId
=
jsonChildNode
.
get
(
EDITOR_SHAPE_ID
).
asText
();
bpmnModel
.
addGraphicInfo
(
BpmnJsonConverterUtil
.
getElementId
(
jsonChildNode
),
graphicInfo
);
shapeMap
.
put
(
childShapeId
,
jsonChildNode
);
ArrayNode
outgoingNode
=
(
ArrayNode
)
jsonChildNode
.
get
(
"outgoing"
);
if
((
outgoingNode
!=
null
)
&&
(
outgoingNode
.
size
()
>
0
))
{
for
(
JsonNode
outgoingChildNode
:
outgoingNode
)
{
JsonNode
resourceNode
=
outgoingChildNode
.
get
(
EDITOR_SHAPE_ID
);
if
(
resourceNode
!=
null
)
{
sourceRefMap
.
put
(
resourceNode
.
asText
(),
jsonChildNode
);
}
}
}
readShapeDI
(
jsonChildNode
,
graphicInfo
.
getX
(),
graphicInfo
.
getY
(),
shapeMap
,
sourceRefMap
,
bpmnModel
);
}
}
}
}
private
void
filterAllEdges
(
JsonNode
objectNode
,
Map
<
String
,
JsonNode
>
edgeMap
,
Map
<
String
,
List
<
JsonNode
>>
sourceAndTargetMap
,
Map
<
String
,
JsonNode
>
shapeMap
,
Map
<
String
,
JsonNode
>
sourceRefMap
)
{
if
(
objectNode
.
get
(
EDITOR_CHILD_SHAPES
)
!=
null
)
{
for
(
JsonNode
jsonChildNode
:
objectNode
.
get
(
EDITOR_CHILD_SHAPES
))
{
ObjectNode
childNode
=
(
ObjectNode
)
jsonChildNode
;
String
stencilId
=
BpmnJsonConverterUtil
.
getStencilId
(
childNode
);
if
(
STENCIL_SUB_PROCESS
.
equals
(
stencilId
))
{
filterAllEdges
(
childNode
,
edgeMap
,
sourceAndTargetMap
,
shapeMap
,
sourceRefMap
);
}
else
if
(
STENCIL_SEQUENCE_FLOW
.
equals
(
stencilId
)
||
STENCIL_ASSOCIATION
.
equals
(
stencilId
))
{
String
childEdgeId
=
BpmnJsonConverterUtil
.
getElementId
(
childNode
);
JsonNode
targetNode
=
childNode
.
get
(
"target"
);
if
((
targetNode
!=
null
)
&&
(
targetNode
.
isNull
()
==
false
))
{
String
targetRefId
=
targetNode
.
get
(
EDITOR_SHAPE_ID
).
asText
();
List
<
JsonNode
>
sourceAndTargetList
=
new
ArrayList
<
JsonNode
>();
sourceAndTargetList
.
add
(
sourceRefMap
.
get
(
childNode
.
get
(
EDITOR_SHAPE_ID
).
asText
()));
sourceAndTargetList
.
add
(
shapeMap
.
get
(
targetRefId
));
sourceAndTargetMap
.
put
(
childEdgeId
,
sourceAndTargetList
);
}
edgeMap
.
put
(
childEdgeId
,
childNode
);
}
}
}
}
private
void
readEdgeDI
(
Map
<
String
,
JsonNode
>
edgeMap
,
Map
<
String
,
List
<
JsonNode
>>
sourceAndTargetMap
,
BpmnModel
bpmnModel
)
{
for
(
String
edgeId
:
edgeMap
.
keySet
())
{
JsonNode
edgeNode
=
edgeMap
.
get
(
edgeId
);
List
<
JsonNode
>
sourceAndTargetList
=
sourceAndTargetMap
.
get
(
edgeId
);
JsonNode
sourceRefNode
=
null
;
JsonNode
targetRefNode
=
null
;
if
((
sourceAndTargetList
!=
null
)
&&
(
sourceAndTargetList
.
size
()
>
1
))
{
sourceRefNode
=
sourceAndTargetList
.
get
(
0
);
targetRefNode
=
sourceAndTargetList
.
get
(
1
);
}
if
(
sourceRefNode
==
null
)
{
LOGGER
.
info
(
"Skipping edge {} because source ref is null"
,
edgeId
);
continue
;
}
if
(
targetRefNode
==
null
)
{
LOGGER
.
info
(
"Skipping edge {} because target ref is null"
,
edgeId
);
continue
;
}
JsonNode
dockersNode
=
edgeNode
.
get
(
EDITOR_DOCKERS
);
double
sourceDockersX
=
dockersNode
.
get
(
0
).
get
(
EDITOR_BOUNDS_X
).
asDouble
();
double
sourceDockersY
=
dockersNode
.
get
(
0
).
get
(
EDITOR_BOUNDS_Y
).
asDouble
();
GraphicInfo
sourceInfo
=
bpmnModel
.
getGraphicInfo
(
BpmnJsonConverterUtil
.
getElementId
(
sourceRefNode
));
GraphicInfo
targetInfo
=
bpmnModel
.
getGraphicInfo
(
BpmnJsonConverterUtil
.
getElementId
(
targetRefNode
));
double
sourceRefLineX
=
sourceInfo
.
getX
()
+
sourceDockersX
;
double
sourceRefLineY
=
sourceInfo
.
getY
()
+
sourceDockersY
;
double
nextPointInLineX
;
double
nextPointInLineY
;
nextPointInLineX
=
dockersNode
.
get
(
1
).
get
(
EDITOR_BOUNDS_X
).
asDouble
();
nextPointInLineY
=
dockersNode
.
get
(
1
).
get
(
EDITOR_BOUNDS_Y
).
asDouble
();
if
(
dockersNode
.
size
()
==
2
)
{
nextPointInLineX
+=
targetInfo
.
getX
();
nextPointInLineY
+=
targetInfo
.
getY
();
}
Line2D
firstLine
=
new
Line2D
(
sourceRefLineX
,
sourceRefLineY
,
nextPointInLineX
,
nextPointInLineY
);
String
sourceRefStencilId
=
BpmnJsonConverterUtil
.
getStencilId
(
sourceRefNode
);
String
targetRefStencilId
=
BpmnJsonConverterUtil
.
getStencilId
(
targetRefNode
);
List
<
GraphicInfo
>
graphicInfoList
=
new
ArrayList
<
GraphicInfo
>();
AbstractContinuousCurve2D
source2D
=
null
;
if
(
DI_CIRCLES
.
contains
(
sourceRefStencilId
))
{
source2D
=
new
Circle2D
(
sourceInfo
.
getX
()
+
sourceDockersX
,
sourceInfo
.
getY
()
+
sourceDockersY
,
sourceDockersX
);
}
else
if
(
DI_RECTANGLES
.
contains
(
sourceRefStencilId
))
{
source2D
=
createRectangle
(
sourceInfo
);
}
else
if
(
DI_GATEWAY
.
contains
(
sourceRefStencilId
))
{
source2D
=
createGateway
(
sourceInfo
);
}
if
(
source2D
!=
null
)
{
Collection
<
Point2D
>
intersections
=
source2D
.
intersections
(
firstLine
);
if
((
intersections
!=
null
)
&&
(
intersections
.
size
()
>
0
))
{
Point2D
intersection
=
intersections
.
iterator
().
next
();
graphicInfoList
.
add
(
createGraphicInfo
(
intersection
.
x
(),
intersection
.
y
()));
}
else
{
graphicInfoList
.
add
(
createGraphicInfo
(
sourceRefLineX
,
sourceRefLineY
));
}
}
Line2D
lastLine
=
null
;
if
(
dockersNode
.
size
()
>
2
)
{
for
(
int
i
=
1
;
i
<
(
dockersNode
.
size
()
-
1
);
i
++)
{
double
x
=
dockersNode
.
get
(
i
).
get
(
EDITOR_BOUNDS_X
).
asDouble
();
double
y
=
dockersNode
.
get
(
i
).
get
(
EDITOR_BOUNDS_Y
).
asDouble
();
graphicInfoList
.
add
(
createGraphicInfo
(
x
,
y
));
}
double
startLastLineX
=
dockersNode
.
get
(
dockersNode
.
size
()
-
2
).
get
(
EDITOR_BOUNDS_X
).
asDouble
();
double
startLastLineY
=
dockersNode
.
get
(
dockersNode
.
size
()
-
2
).
get
(
EDITOR_BOUNDS_Y
).
asDouble
();
double
endLastLineX
=
dockersNode
.
get
(
dockersNode
.
size
()
-
1
).
get
(
EDITOR_BOUNDS_X
).
asDouble
();
double
endLastLineY
=
dockersNode
.
get
(
dockersNode
.
size
()
-
1
).
get
(
EDITOR_BOUNDS_Y
).
asDouble
();
endLastLineX
+=
targetInfo
.
getX
();
endLastLineY
+=
targetInfo
.
getY
();
lastLine
=
new
Line2D
(
startLastLineX
,
startLastLineY
,
endLastLineX
,
endLastLineY
);
}
else
{
lastLine
=
firstLine
;
}
AbstractContinuousCurve2D
target2D
=
null
;
if
(
DI_RECTANGLES
.
contains
(
targetRefStencilId
))
{
target2D
=
createRectangle
(
targetInfo
);
}
else
if
(
DI_CIRCLES
.
contains
(
targetRefStencilId
))
{
double
targetDockersX
=
dockersNode
.
get
(
dockersNode
.
size
()
-
1
).
get
(
EDITOR_BOUNDS_X
).
asDouble
();
double
targetDockersY
=
dockersNode
.
get
(
dockersNode
.
size
()
-
1
).
get
(
EDITOR_BOUNDS_Y
).
asDouble
();
target2D
=
new
Circle2D
(
targetInfo
.
getX
()
+
targetDockersX
,
targetInfo
.
getY
()
+
targetDockersY
,
targetDockersX
);
}
else
if
(
DI_GATEWAY
.
contains
(
targetRefStencilId
))
{
target2D
=
createGateway
(
targetInfo
);
}
if
(
target2D
!=
null
)
{
Collection
<
Point2D
>
intersections
=
target2D
.
intersections
(
lastLine
);
if
((
intersections
!=
null
)
&&
(
intersections
.
size
()
>
0
))
{
Point2D
intersection
=
intersections
.
iterator
().
next
();
graphicInfoList
.
add
(
createGraphicInfo
(
intersection
.
x
(),
intersection
.
y
()));
}
else
{
graphicInfoList
.
add
(
createGraphicInfo
(
lastLine
.
getPoint2
().
x
(),
lastLine
.
getPoint2
().
y
()));
}
}
bpmnModel
.
addFlowGraphicInfoList
(
edgeId
,
graphicInfoList
);
// if sequence has a name, just add a label graphic info
if
(!
""
.
equals
(
edgeNode
.
get
(
"properties"
).
get
(
"name"
)))
{
bpmnModel
.
addLabelGraphicInfo
(
edgeId
,
createGraphicInfo
(
graphicInfoList
.
get
(
0
).
getX
(),
graphicInfoList
.
get
(
0
).
getY
()));
}
}
}
private
Polyline2D
createRectangle
(
GraphicInfo
graphicInfo
)
{
Polyline2D
rectangle
=
new
Polyline2D
(
new
Point2D
(
graphicInfo
.
getX
(),
graphicInfo
.
getY
()),
new
Point2D
(
graphicInfo
.
getX
()
+
graphicInfo
.
getWidth
(),
graphicInfo
.
getY
()),
new
Point2D
(
graphicInfo
.
getX
()
+
graphicInfo
.
getWidth
(),
graphicInfo
.
getY
()
+
graphicInfo
.
getHeight
()),
new
Point2D
(
graphicInfo
.
getX
(),
graphicInfo
.
getY
()
+
graphicInfo
.
getHeight
()),
new
Point2D
(
graphicInfo
.
getX
(),
graphicInfo
.
getY
()));
return
rectangle
;
}
private
Polyline2D
createGateway
(
GraphicInfo
graphicInfo
)
{
double
middleX
=
graphicInfo
.
getX
()
+
(
graphicInfo
.
getWidth
()
/
2
);
double
middleY
=
graphicInfo
.
getY
()
+
(
graphicInfo
.
getHeight
()
/
2
);
Polyline2D
gatewayRectangle
=
new
Polyline2D
(
new
Point2D
(
graphicInfo
.
getX
(),
middleY
),
new
Point2D
(
middleX
,
graphicInfo
.
getY
()),
new
Point2D
(
graphicInfo
.
getX
()
+
graphicInfo
.
getWidth
(),
middleY
),
new
Point2D
(
middleX
,
graphicInfo
.
getY
()
+
graphicInfo
.
getHeight
()),
new
Point2D
(
graphicInfo
.
getX
(),
middleY
));
return
gatewayRectangle
;
}
private
GraphicInfo
createGraphicInfo
(
double
x
,
double
y
)
{
GraphicInfo
graphicInfo
=
new
GraphicInfo
();
graphicInfo
.
setX
(
x
);
graphicInfo
.
setY
(
y
);
return
graphicInfo
;
}
class
FlowWithContainer
{
protected
SequenceFlow
sequenceFlow
;
protected
FlowElementsContainer
flowContainer
;
public
FlowWithContainer
(
SequenceFlow
sequenceFlow
,
FlowElementsContainer
flowContainer
)
{
this
.
sequenceFlow
=
sequenceFlow
;
this
.
flowContainer
=
flowContainer
;
}
public
SequenceFlow
getSequenceFlow
()
{
return
sequenceFlow
;
}
public
void
setSequenceFlow
(
SequenceFlow
sequenceFlow
)
{
this
.
sequenceFlow
=
sequenceFlow
;
}
public
FlowElementsContainer
getFlowContainer
()
{
return
flowContainer
;
}
public
void
setFlowContainer
(
FlowElementsContainer
flowContainer
)
{
this
.
flowContainer
=
flowContainer
;
}
}
}
\ No newline at end of file
JeeSpringCloud/jeespring-act/src/main/resources/mappings/modules/act/ActDao.xml
0 → 100644
View file @
08c32267
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.jeespring.modules.act.dao.ActDao"
>
<update
id=
"updateProcInsIdByBusinessId"
>
UPDATE ${businessTable} SET
proc_ins_id = #{procInsId}
WHERE id = #{businessId}
</update>
</mapper>
\ No newline at end of file
JeeSpringCloud/jeespring-act/src/main/resources/mappings/oa/TestAuditDao.xml
0 → 100644
View file @
08c32267
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.jeespring.modules.oa.dao.TestAuditDao"
>
<sql
id=
"testAuditColumns"
>
a.id,
a.post,
a.age,
a.edu,
a.content,
a.olda,
a.oldb,
a.oldc,
a.newa,
a.newb,
a.newc,
a.add_num,
a.exe_date,
a.hr_text,
a.lead_text,
a.main_lead_text,
a.proc_ins_id,
u.id AS "user.id",
u.name AS "user.name",
o.id AS "office.id",
o.name AS "office.name",
a.create_by AS "createBy.id",
a.create_date,
a.update_by AS "updateBy.id",
a.update_date,
a.remarks,
a.del_flag
</sql>
<sql
id=
"testAuditJoins"
>
JOIN sys_user u ON u.id=a.user_id
JOIN sys_office o ON o.id=a.office_id
</sql>
<select
id=
"get"
resultType=
"TestAudit"
>
SELECT
<include
refid=
"testAuditColumns"
/>
FROM oa_test_audit a
<include
refid=
"testAuditJoins"
/>
WHERE a.id = #{id}
</select>
<select
id=
"getByProcInsId"
resultType=
"TestAudit"
>
SELECT
<include
refid=
"testAuditColumns"
/>
FROM oa_test_audit a
<include
refid=
"testAuditJoins"
/>
WHERE a.proc_ins_id = #{procInsId}
</select>
<select
id=
"findList"
resultType=
"TestAudit"
>
SELECT
<include
refid=
"testAuditColumns"
/>
FROM oa_test_audit a
<include
refid=
"testAuditJoins"
/>
WHERE a.del_flag = #{DEL_FLAG_NORMAL}
<if
test=
"user != null and user.id != null and user.id != ''"
>
AND u.id LIKE
<if
test=
"dbName == 'oracle'"
>
'%'||#{user.id}||'%'
</if>
<if
test=
"dbName == 'mssql'"
>
'%'+#{user.id}+'%'
</if>
<if
test=
"dbName == 'mysql'"
>
CONCAT('%', #{user.id}, '%')
</if>
</if>
ORDER BY a.update_date DESC
</select>
<select
id=
"findAllList"
resultType=
"TestAudit"
>
SELECT
<include
refid=
"testAuditColumns"
/>
FROM oa_test_audit a
<include
refid=
"testAuditJoins"
/>
WHERE a.del_flag = #{DEL_FLAG_NORMAL}
ORDER BY a.update_date DESC
</select>
<insert
id=
"insert"
>
INSERT INTO oa_test_audit(
id,
user_id,
office_id,
post,
age,
edu,
content,
olda,
oldb,
oldc,
newa,
newb,
newc,
add_num,
exe_date,
create_by,
create_date,
update_by,
update_date,
remarks,
del_flag
) VALUES (
#{id},
#{user.id},
#{office.id},
#{post},
#{age},
#{edu},
#{content},
#{olda},
#{oldb},
#{oldc},
#{newa},
#{newb},
#{newc},
#{addNum},
#{exeDate},
#{createBy.id},
#{createDate},
#{updateBy.id},
#{updateDate},
#{remarks},
#{delFlag}
)
</insert>
<update
id=
"update"
>
UPDATE oa_test_audit SET
user_id = #{user.id},
office_id = #{office.id},
post = #{post},
age = #{age},
edu = #{edu},
content = #{content},
olda = #{olda},
oldb = #{oldb},
oldc = #{oldc},
newa = #{newa},
newb = #{newb},
newc = #{newc},
add_num = #{addNum},
exe_date = #{exeDate},
update_by = #{updateBy.id},
update_date = #{updateDate},
remarks = #{remarks}
WHERE id = #{id}
</update>
<update
id=
"updateInsId"
>
UPDATE oa_test_audit SET
proc_ins_id = #{procInsId},
update_by = #{updateBy.id},
update_date = #{updateDate}
WHERE id = #{id}
</update>
<update
id=
"updateHrText"
>
UPDATE oa_test_audit SET
hr_text = #{hrText},
update_by = #{updateBy.id},
update_date = #{updateDate}
WHERE id = #{id}
</update>
<update
id=
"updateLeadText"
>
UPDATE oa_test_audit SET
lead_text = #{leadText},
update_by = #{updateBy.id},
update_date = #{updateDate}
WHERE id = #{id}
</update>
<update
id=
"updateMainLeadText"
>
UPDATE oa_test_audit SET
main_lead_text = #{mainLeadText},
update_by = #{updateBy.id},
update_date = #{updateDate}
WHERE id = #{id}
</update>
<update
id=
"delete"
>
UPDATE oa_test_audit SET
del_flag = #{DEL_FLAG_DELETE}
WHERE id = #{id}
</update>
</mapper>
\ No newline at end of file
Prev
1
2
3
4
5
6
7
…
21
Next
Write
Preview
Supports
Markdown
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