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
e9629e7a
Commit
e9629e7a
authored
Dec 13, 2018
by
Sun
Browse files
no commit message
parent
e4054436
Changes
411
Hide whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
20 of 411+
files are displayed.
Plain diff
Email patch
JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/creator/ChainedActivitiesCreator.java
deleted
100644 → 0
View file @
e4054436
package
com.jeespring.modules.act.service.creator
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.activiti.engine.ProcessEngine
;
import
org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity
;
import
org.activiti.engine.impl.pvm.process.ActivityImpl
;
import
org.springframework.util.CollectionUtils
;
import
com.jeespring.modules.act.utils.ProcessDefUtils
;
public
class
ChainedActivitiesCreator
extends
RuntimeActivityCreatorSupport
implements
RuntimeActivityCreator
{
@Override
@SuppressWarnings
(
"unchecked"
)
public
ActivityImpl
[]
createActivities
(
ProcessEngine
processEngine
,
ProcessDefinitionEntity
processDefinition
,
RuntimeActivityDefinitionEntity
info
)
{
info
.
setFactoryName
(
ChainedActivitiesCreator
.
class
.
getName
());
RuntimeActivityDefinitionEntityIntepreter
radei
=
new
RuntimeActivityDefinitionEntityIntepreter
(
info
);
if
(
radei
.
getCloneActivityIds
()
==
null
)
{
radei
.
setCloneActivityIds
(
CollectionUtils
.
arrayToList
(
new
String
[
radei
.
getAssignees
().
size
()]));
}
return
createActivities
(
processEngine
,
processDefinition
,
info
.
getProcessInstanceId
(),
radei
.
getPrototypeActivityId
(),
radei
.
getNextActivityId
(),
radei
.
getAssignees
(),
radei
.
getCloneActivityIds
());
}
private
ActivityImpl
[]
createActivities
(
ProcessEngine
processEngine
,
ProcessDefinitionEntity
processDefinition
,
String
processInstanceId
,
String
prototypeActivityId
,
String
nextActivityId
,
List
<
String
>
assignees
,
List
<
String
>
activityIds
)
{
ActivityImpl
prototypeActivity
=
ProcessDefUtils
.
getActivity
(
processEngine
,
processDefinition
.
getId
(),
prototypeActivityId
);
List
<
ActivityImpl
>
activities
=
new
ArrayList
<
ActivityImpl
>();
for
(
int
i
=
0
;
i
<
assignees
.
size
();
i
++)
{
if
(
activityIds
.
get
(
i
)
==
null
)
{
String
activityId
=
createUniqueActivityId
(
processInstanceId
,
prototypeActivityId
);
activityIds
.
set
(
i
,
activityId
);
}
ActivityImpl
clone
=
createActivity
(
processEngine
,
processDefinition
,
prototypeActivity
,
activityIds
.
get
(
i
),
assignees
.
get
(
i
));
activities
.
add
(
clone
);
}
ActivityImpl
nextActivity
=
ProcessDefUtils
.
getActivity
(
processEngine
,
processDefinition
.
getId
(),
nextActivityId
);
createActivityChain
(
activities
,
nextActivity
);
return
activities
.
toArray
(
new
ActivityImpl
[
0
]);
}
}
JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/creator/MultiInstanceActivityCreator.java
deleted
100644 → 0
View file @
e4054436
package
com.jeespring.modules.act.service.creator
;
import
java.util.List
;
import
org.activiti.engine.ProcessEngine
;
import
org.activiti.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior
;
import
org.activiti.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior
;
import
org.activiti.engine.impl.bpmn.behavior.SequentialMultiInstanceBehavior
;
import
org.activiti.engine.impl.bpmn.behavior.TaskActivityBehavior
;
import
org.activiti.engine.impl.el.FixedValue
;
import
org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity
;
import
org.activiti.engine.impl.pvm.PvmTransition
;
import
org.activiti.engine.impl.pvm.process.ActivityImpl
;
import
com.jeespring.modules.act.utils.ProcessDefUtils
;
public
class
MultiInstanceActivityCreator
extends
RuntimeActivityCreatorSupport
implements
RuntimeActivityCreator
{
@Override
public
ActivityImpl
[]
createActivities
(
ProcessEngine
processEngine
,
ProcessDefinitionEntity
processDefinition
,
RuntimeActivityDefinitionEntity
info
)
{
info
.
setFactoryName
(
MultiInstanceActivityCreator
.
class
.
getName
());
RuntimeActivityDefinitionEntityIntepreter
radei
=
new
RuntimeActivityDefinitionEntityIntepreter
(
info
);
if
(
radei
.
getCloneActivityId
()
==
null
)
{
String
cloneActivityId
=
createUniqueActivityId
(
info
.
getProcessInstanceId
(),
radei
.
getPrototypeActivityId
());
radei
.
setCloneActivityId
(
cloneActivityId
);
}
return
new
ActivityImpl
[]
{
createMultiInstanceActivity
(
processEngine
,
processDefinition
,
info
.
getProcessInstanceId
(),
radei
.
getPrototypeActivityId
(),
radei
.
getCloneActivityId
(),
radei
.
getSequential
(),
radei
.
getAssignees
())
};
}
private
ActivityImpl
createMultiInstanceActivity
(
ProcessEngine
processEngine
,
ProcessDefinitionEntity
processDefinition
,
String
processInstanceId
,
String
prototypeActivityId
,
String
cloneActivityId
,
boolean
isSequential
,
List
<
String
>
assignees
)
{
ActivityImpl
prototypeActivity
=
ProcessDefUtils
.
getActivity
(
processEngine
,
processDefinition
.
getId
(),
prototypeActivityId
);
//拷贝listener,executionListeners会激活历史记录的保存
ActivityImpl
clone
=
cloneActivity
(
processDefinition
,
prototypeActivity
,
cloneActivityId
,
"executionListeners"
,
"properties"
);
//拷贝所有后向链接
for
(
PvmTransition
trans
:
prototypeActivity
.
getOutgoingTransitions
())
{
clone
.
createOutgoingTransition
(
trans
.
getId
()).
setDestination
((
ActivityImpl
)
trans
.
getDestination
());
}
MultiInstanceActivityBehavior
multiInstanceBehavior
=
isSequential
?
new
SequentialMultiInstanceBehavior
(
clone
,
(
TaskActivityBehavior
)
prototypeActivity
.
getActivityBehavior
())
:
new
ParallelMultiInstanceBehavior
(
clone
,
(
TaskActivityBehavior
)
prototypeActivity
.
getActivityBehavior
());
clone
.
setActivityBehavior
(
multiInstanceBehavior
);
clone
.
setScope
(
true
);
clone
.
setProperty
(
"multiInstance"
,
isSequential
?
"sequential"
:
"parallel"
);
//设置多实例节点属性
multiInstanceBehavior
.
setLoopCardinalityExpression
(
new
FixedValue
(
assignees
.
size
()));
multiInstanceBehavior
.
setCollectionExpression
(
new
FixedValue
(
assignees
));
return
clone
;
}
}
JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/creator/RuntimeActivityCreator.java
deleted
100644 → 0
View file @
e4054436
package
com.jeespring.modules.act.service.creator
;
import
org.activiti.engine.ProcessEngine
;
import
org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity
;
import
org.activiti.engine.impl.pvm.process.ActivityImpl
;
public
interface
RuntimeActivityCreator
{
public
ActivityImpl
[]
createActivities
(
ProcessEngine
processEngine
,
ProcessDefinitionEntity
processDefinition
,
RuntimeActivityDefinitionEntity
info
);
}
\ No newline at end of file
JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/creator/RuntimeActivityCreatorSupport.java
deleted
100644 → 0
View file @
e4054436
package
com.jeespring.modules.act.service.creator
;
import
java.lang.reflect.Field
;
import
java.util.List
;
import
org.activiti.engine.ProcessEngine
;
import
org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior
;
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.junit.Assert
;
import
org.springframework.beans.BeanUtils
;
import
com.jeespring.modules.act.utils.ProcessDefUtils
;
public
abstract
class
RuntimeActivityCreatorSupport
{
private
static
int
SEQUNCE_NUMBER
=
0
;
protected
ActivityImpl
cloneActivity
(
ProcessDefinitionEntity
processDefinition
,
ActivityImpl
prototypeActivity
,
String
newActivityId
,
String
...
fieldNames
)
{
ActivityImpl
clone
=
processDefinition
.
createActivity
(
newActivityId
);
copyFields
(
prototypeActivity
,
clone
,
fieldNames
);
return
clone
;
}
protected
TaskDefinition
cloneTaskDefinition
(
TaskDefinition
taskDefinition
)
{
TaskDefinition
newTaskDefinition
=
new
TaskDefinition
(
taskDefinition
.
getTaskFormHandler
());
BeanUtils
.
copyProperties
(
taskDefinition
,
newTaskDefinition
);
return
newTaskDefinition
;
}
protected
ActivityImpl
createActivity
(
ProcessEngine
processEngine
,
ProcessDefinitionEntity
processDefinition
,
ActivityImpl
prototypeActivity
,
String
cloneActivityId
,
String
assignee
)
{
ActivityImpl
clone
=
cloneActivity
(
processDefinition
,
prototypeActivity
,
cloneActivityId
,
"executionListeners"
,
"properties"
);
//设置assignee
UserTaskActivityBehavior
activityBehavior
=
(
UserTaskActivityBehavior
)
(
prototypeActivity
.
getActivityBehavior
());
TaskDefinition
taskDefinition
=
cloneTaskDefinition
(
activityBehavior
.
getTaskDefinition
());
taskDefinition
.
setKey
(
cloneActivityId
);
if
(
assignee
!=
null
)
{
taskDefinition
.
setAssigneeExpression
(
new
FixedValue
(
assignee
));
}
UserTaskActivityBehavior
cloneActivityBehavior
=
new
UserTaskActivityBehavior
(
null
,
taskDefinition
);
clone
.
setActivityBehavior
(
cloneActivityBehavior
);
return
clone
;
}
protected
ActivityImpl
createActivity
(
ProcessEngine
processEngine
,
ProcessDefinitionEntity
processDefinition
,
String
prototypeActivityId
,
String
cloneActivityId
,
String
assignee
)
{
ActivityImpl
prototypeActivity
=
ProcessDefUtils
.
getActivity
(
processEngine
,
processDefinition
.
getId
(),
prototypeActivityId
);
return
createActivity
(
processEngine
,
processDefinition
,
prototypeActivity
,
cloneActivityId
,
assignee
);
}
protected
void
createActivityChain
(
List
<
ActivityImpl
>
activities
,
ActivityImpl
nextActivity
)
{
for
(
int
i
=
0
;
i
<
activities
.
size
();
i
++)
{
//设置各活动的下线
activities
.
get
(
i
).
getOutgoingTransitions
().
clear
();
activities
.
get
(
i
).
createOutgoingTransition
(
"flow"
+
(
i
+
1
))
.
setDestination
(
i
==
activities
.
size
()
-
1
?
nextActivity
:
activities
.
get
(
i
+
1
));
}
}
protected
String
createUniqueActivityId
(
String
processInstanceId
,
String
prototypeActivityId
)
{
return
processInstanceId
+
":"
+
prototypeActivityId
+
":"
+
System
.
currentTimeMillis
()
+
"-"
+
(
SEQUNCE_NUMBER
++);
}
private
static
void
copyFields
(
Object
source
,
Object
target
,
String
...
fieldNames
)
{
Assert
.
assertNotNull
(
source
);
Assert
.
assertNotNull
(
target
);
Assert
.
assertSame
(
source
.
getClass
(),
target
.
getClass
());
for
(
String
fieldName
:
fieldNames
)
{
try
{
Field
field
=
FieldUtils
.
getField
(
source
.
getClass
(),
fieldName
,
true
);
field
.
setAccessible
(
true
);
field
.
set
(
target
,
field
.
get
(
source
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
}
JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/creator/RuntimeActivityDefinitionEntity.java
deleted
100644 → 0
View file @
e4054436
package
com.jeespring.modules.act.service.creator
;
import
java.io.IOException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
public
interface
RuntimeActivityDefinitionEntity
{
/**
* 反序列化PropertiesText到Map
*/
void
deserializeProperties
()
throws
IOException
;
/**
* 获取工厂名
*/
String
getFactoryName
();
/**
* 获取流程定义的ID
*/
String
getProcessDefinitionId
();
/**
* 获取流程实例的ID
*/
String
getProcessInstanceId
();
/**
* 获取PropertiesText,它是一个JSON字符串
*/
String
getPropertiesText
();
/**
* 获取指定的属性值
*/
<
T
>
T
getProperty
(
String
name
);
/**
* 序列化Map至PropertiesText
*/
void
serializeProperties
()
throws
JsonProcessingException
;
/**
* 设置工厂名
*/
void
setFactoryName
(
String
factoryName
);
/**
* 设置流程定义ID
*/
void
setProcessDefinitionId
(
String
processDefinitionId
);
/**
* 设置流程实例ID
*/
void
setProcessInstanceId
(
String
processInstanceId
);
/**
* 设置PropertiesText
*/
void
setPropertiesText
(
String
propertiesText
);
<
T
>
void
setProperty
(
String
name
,
T
value
);
}
\ No newline at end of file
JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/creator/RuntimeActivityDefinitionEntityIntepreter.java
deleted
100644 → 0
View file @
e4054436
package
com.jeespring.modules.act.service.creator
;
import
java.util.List
;
/**
* RuntimeActivityDefinitionEntity的解释类(代理类)
* 主要用以解释properties字段的值,如为get("name")提供getName()方法
*
* @author bluejoe2008@gmail.com
*
*/
public
class
RuntimeActivityDefinitionEntityIntepreter
{
RuntimeActivityDefinitionEntity
_entity
;
public
RuntimeActivityDefinitionEntityIntepreter
(
RuntimeActivityDefinitionEntity
entity
)
{
super
();
_entity
=
entity
;
}
public
List
<
String
>
getAssignees
()
{
return
_entity
.
getProperty
(
"assignees"
);
}
public
String
getCloneActivityId
()
{
return
_entity
.
getProperty
(
"cloneActivityId"
);
}
public
List
<
String
>
getCloneActivityIds
()
{
return
_entity
.
getProperty
(
"cloneActivityIds"
);
}
public
String
getNextActivityId
()
{
return
_entity
.
getProperty
(
"nextActivityId"
);
}
public
String
getPrototypeActivityId
()
{
return
_entity
.
getProperty
(
"prototypeActivityId"
);
}
public
boolean
getSequential
()
{
return
(
Boolean
)
_entity
.
getProperty
(
"sequential"
);
}
public
void
setAssignees
(
List
<
String
>
assignees
)
{
_entity
.
setProperty
(
"assignees"
,
assignees
);
}
public
void
setCloneActivityId
(
String
cloneActivityId
)
{
_entity
.
setProperty
(
"cloneActivityId"
,
cloneActivityId
);
}
public
void
setCloneActivityIds
(
List
<
String
>
cloneActivityIds
)
{
_entity
.
setProperty
(
"cloneActivityIds"
,
cloneActivityIds
);
}
public
void
setNextActivityId
(
String
nextActivityId
)
{
_entity
.
setProperty
(
"nextActivityId"
,
nextActivityId
);
}
public
void
setPrototypeActivityId
(
String
prototypeActivityId
)
{
_entity
.
setProperty
(
"prototypeActivityId"
,
prototypeActivityId
);
}
public
void
setSequential
(
boolean
sequential
)
{
_entity
.
setProperty
(
"sequential"
,
sequential
);
}
}
JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/creator/RuntimeActivityDefinitionManager.java
deleted
100644 → 0
View file @
e4054436
package
com.jeespring.modules.act.service.creator
;
import
java.util.List
;
public
interface
RuntimeActivityDefinitionManager
{
/**
* 获取所有的活动定义信息,引擎会在启动的时候加载这些活动定义并进行注册
*/
List
<
RuntimeActivityDefinitionEntity
>
list
()
throws
Exception
;
/**
* 删除所有活动定义
*/
void
removeAll
()
throws
Exception
;
/**
* 新增一条活动定义的信息
*/
void
save
(
RuntimeActivityDefinitionEntity
entity
)
throws
Exception
;
}
\ No newline at end of file
JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/creator/SimpleRuntimeActivityDefinitionEntity.java
deleted
100644 → 0
View file @
e4054436
package
com.jeespring.modules.act.service.creator
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.Map
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
public
class
SimpleRuntimeActivityDefinitionEntity
implements
RuntimeActivityDefinitionEntity
{
String
_factoryName
;
String
_processDefinitionId
;
public
Map
<
String
,
Object
>
getProperties
()
{
return
_properties
;
}
public
void
setProperties
(
Map
<
String
,
Object
>
properties
)
{
_properties
=
properties
;
}
@Override
public
void
setFactoryName
(
String
factoryName
)
{
_factoryName
=
factoryName
;
}
@Override
public
void
setProcessDefinitionId
(
String
processDefinitionId
)
{
_processDefinitionId
=
processDefinitionId
;
}
@Override
public
void
setProcessInstanceId
(
String
processInstanceId
)
{
_processInstanceId
=
processInstanceId
;
}
@Override
public
void
setPropertiesText
(
String
propertiesText
)
{
_propertiesText
=
propertiesText
;
}
String
_processInstanceId
;
Map
<
String
,
Object
>
_properties
=
new
HashMap
<
String
,
Object
>();
String
_propertiesText
;
@Override
public
void
deserializeProperties
()
throws
IOException
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
_properties
=
objectMapper
.
readValue
(
_propertiesText
,
Map
.
class
);
}
@Override
public
String
getFactoryName
()
{
return
_factoryName
;
}
@Override
public
String
getProcessDefinitionId
()
{
return
_processDefinitionId
;
}
@Override
public
String
getProcessInstanceId
()
{
return
_processInstanceId
;
}
@Override
public
String
getPropertiesText
()
{
return
_propertiesText
;
}
@Override
public
<
T
>
T
getProperty
(
String
name
)
{
return
(
T
)
_properties
.
get
(
name
);
}
@Override
public
void
serializeProperties
()
throws
JsonProcessingException
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
_propertiesText
=
objectMapper
.
writeValueAsString
(
_properties
);
}
@Override
public
<
T
>
void
setProperty
(
String
name
,
T
value
)
{
_properties
.
put
(
name
,
value
);
}
}
JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/ext/ActGroupEntityService.java
deleted
100644 → 0
View file @
e4054436
/**
* 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-framework/src/main/java/com/jeespring/modules/act/service/ext/ActGroupEntityServiceFactory.java
deleted
100644 → 0
View file @
e4054436
/**
* 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-framework/src/main/java/com/jeespring/modules/act/service/ext/ActUserEntityService.java
deleted
100644 → 0
View file @
e4054436
/**
* 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-framework/src/main/java/com/jeespring/modules/act/service/ext/ActUserEntityServiceFactory.java
deleted
100644 → 0
View file @
e4054436
/**
* 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-framework/src/main/java/com/jeespring/modules/act/utils/ActUtils.java
deleted
100644 → 0
View file @
e4054436
/**
* 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-framework/src/main/java/com/jeespring/modules/act/utils/DateConverter.java
deleted
100644 → 0
View file @
e4054436
/**
* 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-framework/src/main/java/com/jeespring/modules/act/utils/ProcessDefCache.java
deleted
100644 → 0
View file @
e4054436
/**
* 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-framework/src/main/java/com/jeespring/modules/act/utils/ProcessDefUtils.java
deleted
100644 → 0
View file @
e4054436
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-framework/src/main/java/com/jeespring/modules/act/utils/PropertyType.java
deleted
100644 → 0
View file @
e4054436
/**
* 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-framework/src/main/java/com/jeespring/modules/act/utils/Variable.java
deleted
100644 → 0
View file @
e4054436
/**
* 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-framework/src/main/java/com/jeespring/modules/act/web/ActModelController.java
deleted
100644 → 0
View file @
e4054436
/**
* 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-framework/src/main/java/com/jeespring/modules/act/web/ActProcessController.java
deleted
100644 → 0
View file @
e4054436
/**
* 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/"
;
}
}
Prev
1
…
12
13
14
15
16
17
18
19
20
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