Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
开发团队
Flowable Engine
提交
0a4f4f34
F
Flowable Engine
项目概览
开发团队
/
Flowable Engine
通知
9
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Flowable Engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0a4f4f34
编写于
11月 29, 2013
作者:
T
Tijs Rademakers
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove standalone tasks from REST and add custom form types to REST webapp
上级
806b5143
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
170 addition
and
33 deletion
+170
-33
modules/activiti-rest/src/main/java/org/activiti/rest/form/MonthFormType.java
...t/src/main/java/org/activiti/rest/form/MonthFormType.java
+43
-0
modules/activiti-rest/src/main/java/org/activiti/rest/form/ProcessDefinitionFormType.java
...ava/org/activiti/rest/form/ProcessDefinitionFormType.java
+63
-0
modules/activiti-rest/src/main/java/org/activiti/rest/form/UserFormType.java
...st/src/main/java/org/activiti/rest/form/UserFormType.java
+57
-0
modules/activiti-rest/src/main/java/org/activiti/rest/service/demo/DemoDataGenerator.java
...ava/org/activiti/rest/service/demo/DemoDataGenerator.java
+0
-33
modules/activiti-webapp-rest2/src/main/resources/activiti-context.xml
...viti-webapp-rest2/src/main/resources/activiti-context.xml
+7
-0
未找到文件。
modules/activiti-rest/src/main/java/org/activiti/rest/form/MonthFormType.java
0 → 100644
浏览文件 @
0a4f4f34
/* 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.rest.form
;
import
org.activiti.engine.form.AbstractFormType
;
/**
* @author Joram Barrez
*/
public
class
MonthFormType
extends
AbstractFormType
{
public
static
final
String
TYPE_NAME
=
"month"
;
public
String
getName
()
{
return
TYPE_NAME
;
}
@Override
public
Object
convertFormValueToModelValue
(
String
propertyValue
)
{
Integer
month
=
Integer
.
valueOf
(
propertyValue
);
return
month
;
}
@Override
public
String
convertModelValueToFormValue
(
Object
modelValue
)
{
if
(
modelValue
==
null
)
{
return
null
;
}
return
modelValue
.
toString
();
}
}
modules/activiti-rest/src/main/java/org/activiti/rest/form/ProcessDefinitionFormType.java
0 → 100644
浏览文件 @
0a4f4f34
/* 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.rest.form
;
import
org.activiti.engine.ActivitiIllegalArgumentException
;
import
org.activiti.engine.ActivitiObjectNotFoundException
;
import
org.activiti.engine.ProcessEngines
;
import
org.activiti.engine.form.AbstractFormType
;
import
org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity
;
import
org.activiti.engine.repository.ProcessDefinition
;
/**
* @author Joram Barrez
*/
public
class
ProcessDefinitionFormType
extends
AbstractFormType
{
public
static
final
String
TYPE_NAME
=
"processDefinition"
;
public
String
getName
()
{
return
TYPE_NAME
;
}
@Override
public
Object
convertFormValueToModelValue
(
String
propertyValue
)
{
if
(
propertyValue
!=
null
)
{
ProcessDefinition
processDefinition
=
ProcessEngines
.
getDefaultProcessEngine
()
.
getRepositoryService
()
.
createProcessDefinitionQuery
()
.
processDefinitionId
(
propertyValue
)
.
singleResult
();
if
(
processDefinition
==
null
)
{
throw
new
ActivitiObjectNotFoundException
(
"Process definition with id "
+
propertyValue
+
" does not exist"
,
ProcessDefinitionEntity
.
class
);
}
return
processDefinition
;
}
return
null
;
}
@Override
public
String
convertModelValueToFormValue
(
Object
modelValue
)
{
if
(
modelValue
==
null
)
{
return
null
;
}
if
(!(
modelValue
instanceof
ProcessDefinition
))
{
throw
new
ActivitiIllegalArgumentException
(
"This form type only support process definitions, but is "
+
modelValue
.
getClass
());
}
return
((
ProcessDefinition
)
modelValue
).
getId
();
}
}
modules/activiti-rest/src/main/java/org/activiti/rest/form/UserFormType.java
0 → 100644
浏览文件 @
0a4f4f34
/* 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.rest.form
;
import
org.activiti.engine.ActivitiObjectNotFoundException
;
import
org.activiti.engine.ProcessEngines
;
import
org.activiti.engine.form.AbstractFormType
;
import
org.activiti.engine.identity.User
;
/**
* Form type that holds an ID of a user.
*
* @author 'Frederik Heremans'
*/
public
class
UserFormType
extends
AbstractFormType
{
public
static
final
String
TYPE_NAME
=
"user"
;
public
String
getName
()
{
return
TYPE_NAME
;
}
@Override
public
Object
convertFormValueToModelValue
(
String
propertyValue
)
{
// Check if user exists
if
(
propertyValue
!=
null
)
{
// TODO: perhaps better wiring mechanism for service
long
count
=
ProcessEngines
.
getDefaultProcessEngine
()
.
getIdentityService
()
.
createUserQuery
()
.
userId
(
propertyValue
).
count
();
if
(
count
==
0
)
{
throw
new
ActivitiObjectNotFoundException
(
"User "
+
propertyValue
+
" does not exist"
,
User
.
class
);
}
return
propertyValue
;
}
return
null
;
}
@Override
public
String
convertModelValueToFormValue
(
Object
modelValue
)
{
return
(
String
)
modelValue
;
}
}
modules/activiti-rest/src/main/java/org/activiti/rest/service/demo/DemoDataGenerator.java
浏览文件 @
0a4f4f34
...
@@ -29,7 +29,6 @@ import org.activiti.engine.identity.User;
...
@@ -29,7 +29,6 @@ import org.activiti.engine.identity.User;
import
org.activiti.engine.impl.util.IoUtil
;
import
org.activiti.engine.impl.util.IoUtil
;
import
org.activiti.engine.repository.Deployment
;
import
org.activiti.engine.repository.Deployment
;
import
org.activiti.engine.repository.Model
;
import
org.activiti.engine.repository.Model
;
import
org.activiti.engine.task.Task
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.io.IOUtils
;
import
org.codehaus.jackson.map.ObjectMapper
;
import
org.codehaus.jackson.map.ObjectMapper
;
import
org.codehaus.jackson.node.ObjectNode
;
import
org.codehaus.jackson.node.ObjectNode
;
...
@@ -74,9 +73,6 @@ public class DemoDataGenerator implements ModelDataJsonConstants {
...
@@ -74,9 +73,6 @@ public class DemoDataGenerator implements ModelDataJsonConstants {
LOGGER
.
info
(
"Initializing demo models"
);
LOGGER
.
info
(
"Initializing demo models"
);
initDemoModelData
();
initDemoModelData
();
}
}
initDemoStandaloneTasks
();
}
}
public
void
setProcessEngine
(
ProcessEngine
processEngine
)
{
public
void
setProcessEngine
(
ProcessEngine
processEngine
)
{
...
@@ -228,35 +224,6 @@ protected void initDemoProcessDefinitions() {
...
@@ -228,35 +224,6 @@ protected void initDemoProcessDefinitions() {
}
}
}
}
protected
void
initDemoStandaloneTasks
()
{
List
<
User
>
users
=
identityService
.
createUserQuery
().
list
();
List
<
Group
>
groups
=
identityService
.
createGroupQuery
().
groupType
(
"assignment"
).
list
();
Random
random
=
new
Random
();
String
loremIpsum
=
"Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et "
+
"dolore magna aliqua Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat"
+
" Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur Excepteur sint occaecat "
+
"cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est laborum"
;
String
[]
words
=
loremIpsum
.
split
(
" "
);
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
Task
task
=
taskService
.
newTask
();
task
.
setName
(
randomSentence
(
words
,
6
));
task
.
setDescription
(
randomSentence
(
words
,
15
));
taskService
.
saveTask
(
task
);
if
(
random
.
nextBoolean
())
{
taskService
.
setAssignee
(
task
.
getId
(),
users
.
get
(
random
.
nextInt
(
users
.
size
())).
getId
());
}
else
{
taskService
.
addCandidateGroup
(
task
.
getId
(),
groups
.
get
(
random
.
nextInt
(
groups
.
size
())).
getId
());
}
}
}
protected
String
randomSentence
(
String
[]
words
,
int
length
)
{
protected
String
randomSentence
(
String
[]
words
,
int
length
)
{
Random
random
=
new
Random
();
Random
random
=
new
Random
();
StringBuilder
strb
=
new
StringBuilder
();
StringBuilder
strb
=
new
StringBuilder
();
...
...
modules/activiti-webapp-rest2/src/main/resources/activiti-context.xml
浏览文件 @
0a4f4f34
...
@@ -41,6 +41,13 @@ http://www.springframework.org/schema/tx http://www.springframework.org/schema/t
...
@@ -41,6 +41,13 @@ http://www.springframework.org/schema/tx http://www.springframework.org/schema/t
<property
name=
"mailServerHost"
value=
"localhost"
/>
<property
name=
"mailServerHost"
value=
"localhost"
/>
<property
name=
"mailServerPort"
value=
"5025"
/>
<property
name=
"mailServerPort"
value=
"5025"
/>
<property
name=
"jobExecutorActivate"
value=
"false"
/>
<property
name=
"jobExecutorActivate"
value=
"false"
/>
<property
name=
"customFormTypes"
>
<list>
<bean
class=
"org.activiti.rest.form.UserFormType"
/>
<bean
class=
"org.activiti.rest.form.ProcessDefinitionFormType"
/>
<bean
class=
"org.activiti.rest.form.MonthFormType"
/>
</list>
</property>
</bean>
</bean>
<bean
id=
"processEngine"
class=
"org.activiti.spring.ProcessEngineFactoryBean"
>
<bean
id=
"processEngine"
class=
"org.activiti.spring.ProcessEngineFactoryBean"
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录