Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
开发团队
Flowable Engine
提交
b9a3b30e
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,发现更多精彩内容 >>
提交
b9a3b30e
编写于
11月 21, 2011
作者:
T
trademak
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Additional REST services for JPM Android
上级
a5b82644
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
167 addition
and
3 deletion
+167
-3
modules/activiti-webapp-rest2/src/main/java/org/activiti/rest/api/identity/UserSearchResource.java
...va/org/activiti/rest/api/identity/UserSearchResource.java
+87
-0
modules/activiti-webapp-rest2/src/main/java/org/activiti/rest/api/task/TaskResource.java
...rc/main/java/org/activiti/rest/api/task/TaskResource.java
+8
-2
modules/activiti-webapp-rest2/src/main/java/org/activiti/rest/api/task/TaskUrlAddResource.java
...n/java/org/activiti/rest/api/task/TaskUrlAddResource.java
+67
-0
modules/activiti-webapp-rest2/src/main/java/org/activiti/rest/application/ActivitiRestApplication.java
...rg/activiti/rest/application/ActivitiRestApplication.java
+5
-1
未找到文件。
modules/activiti-webapp-rest2/src/main/java/org/activiti/rest/api/identity/UserSearchResource.java
0 → 100644
浏览文件 @
b9a3b30e
/* 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.api.identity
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.activiti.engine.ActivitiException
;
import
org.activiti.engine.identity.User
;
import
org.activiti.rest.api.ActivitiUtil
;
import
org.activiti.rest.api.DataResponse
;
import
org.activiti.rest.api.SecuredResource
;
import
org.restlet.resource.Get
;
/**
* @author Tijs Rademakers
*/
public
class
UserSearchResource
extends
SecuredResource
{
@Get
public
DataResponse
searchUsers
()
{
if
(
authenticate
()
==
false
)
return
null
;
String
searchText
=
(
String
)
getRequest
().
getAttributes
().
get
(
"searchText"
);
if
(
searchText
==
null
)
{
throw
new
ActivitiException
(
"No searchText provided"
);
}
searchText
=
"%"
+
searchText
+
"%"
;
List
<
User
>
firstNameMatchList
=
ActivitiUtil
.
getIdentityService
().
createUserQuery
().
userFirstNameLike
(
searchText
).
list
();
List
<
User
>
lastNameMatchList
=
ActivitiUtil
.
getIdentityService
().
createUserQuery
().
userLastNameLike
(
searchText
).
list
();
Map
<
String
,
UserResponse
>
userMap
=
new
HashMap
<
String
,
UserResponse
>();
if
(
firstNameMatchList
!=
null
)
{
for
(
User
user
:
firstNameMatchList
)
{
userMap
.
put
(
user
.
getId
(),
new
UserResponse
(
user
));
}
}
if
(
lastNameMatchList
!=
null
)
{
for
(
User
user
:
lastNameMatchList
)
{
if
(
userMap
.
containsKey
(
user
.
getId
())
==
false
)
{
userMap
.
put
(
user
.
getId
(),
new
UserResponse
(
user
));
}
}
}
List
<
UserResponse
>
userList
=
new
ArrayList
<
UserResponse
>();
userList
.
addAll
(
userMap
.
values
());
Collections
.
sort
(
userList
,
new
UserResponseComparable
());
DataResponse
response
=
new
DataResponse
();
response
.
setStart
(
0
);
response
.
setSize
(
userList
.
size
());
response
.
setSort
(
"lastName"
);
response
.
setOrder
(
"asc"
);
response
.
setTotal
(
userList
.
size
());
response
.
setData
(
userList
);
return
response
;
}
protected
class
UserResponseComparable
implements
Comparator
<
UserResponse
>{
@Override
public
int
compare
(
UserResponse
user1
,
UserResponse
user2
)
{
return
user1
.
getLastName
().
compareTo
(
user2
.
getLastName
());
}
}
}
modules/activiti-webapp-rest2/src/main/java/org/activiti/rest/api/task/TaskResource.java
浏览文件 @
b9a3b30e
...
...
@@ -36,7 +36,7 @@ import org.restlet.resource.Post;
public
class
TaskResource
extends
SecuredResource
{
@Get
public
TaskResponse
getTask
s
()
{
public
TaskResponse
getTask
()
{
if
(
authenticate
()
==
false
)
return
null
;
String
taskId
=
(
String
)
getRequest
().
getAttributes
().
get
(
"taskId"
);
Task
task
=
ActivitiUtil
.
getTaskService
().
createTaskQuery
().
taskId
(
taskId
).
singleResult
();
...
...
@@ -68,7 +68,13 @@ public class TaskResource extends SecuredResource {
}
}
List
<
Attachment
>
attachmentList
=
ActivitiUtil
.
getTaskService
().
getTaskAttachments
(
task
.
getId
());
List
<
Attachment
>
attachmentList
=
null
;
if
(
task
.
getProcessInstanceId
()
!=
null
&&
task
.
getProcessInstanceId
().
length
()
>
0
)
{
attachmentList
=
ActivitiUtil
.
getTaskService
().
getProcessInstanceAttachments
(
task
.
getProcessInstanceId
());
}
else
{
attachmentList
=
ActivitiUtil
.
getTaskService
().
getTaskAttachments
(
task
.
getId
());
}
if
(
attachmentList
!=
null
)
{
for
(
Attachment
attachment
:
attachmentList
)
{
AttachmentResponse
attachmentResponse
=
new
AttachmentResponse
(
attachment
);
...
...
modules/activiti-webapp-rest2/src/main/java/org/activiti/rest/api/task/TaskUrlAddResource.java
0 → 100644
浏览文件 @
b9a3b30e
/* 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.api.task
;
import
org.activiti.engine.ActivitiException
;
import
org.activiti.engine.task.Attachment
;
import
org.activiti.rest.api.ActivitiUtil
;
import
org.activiti.rest.api.SecuredResource
;
import
org.codehaus.jackson.JsonNode
;
import
org.codehaus.jackson.map.ObjectMapper
;
import
org.restlet.representation.Representation
;
import
org.restlet.resource.Put
;
/**
* @author Tijs Rademakers
*/
public
class
TaskUrlAddResource
extends
SecuredResource
{
@Put
public
AttachmentResponse
addUrl
(
Representation
entity
)
{
if
(
authenticate
()
==
false
)
return
null
;
String
taskId
=
(
String
)
getRequest
().
getAttributes
().
get
(
"taskId"
);
if
(
taskId
==
null
||
taskId
.
length
()
==
0
)
{
throw
new
ActivitiException
(
"No taskId provided"
);
}
try
{
String
taskParams
=
entity
.
getText
();
JsonNode
taskJSON
=
new
ObjectMapper
().
readTree
(
taskParams
);
String
name
=
null
;
if
(
taskJSON
.
path
(
"name"
)
!=
null
&&
taskJSON
.
path
(
"name"
).
getTextValue
()
!=
null
)
{
name
=
taskJSON
.
path
(
"name"
).
getTextValue
();
}
String
description
=
null
;
if
(
taskJSON
.
path
(
"description"
)
!=
null
&&
taskJSON
.
path
(
"description"
).
getTextValue
()
!=
null
)
{
description
=
taskJSON
.
path
(
"description"
).
getTextValue
();
}
String
url
=
null
;
if
(
taskJSON
.
path
(
"url"
)
!=
null
&&
taskJSON
.
path
(
"url"
).
getTextValue
()
!=
null
)
{
url
=
taskJSON
.
path
(
"url"
).
getTextValue
();
}
Attachment
attachment
=
ActivitiUtil
.
getTaskService
().
createAttachment
(
"url"
,
taskId
,
null
,
name
,
description
,
url
);
return
new
AttachmentResponse
(
attachment
);
}
catch
(
Exception
e
)
{
throw
new
ActivitiException
(
"Unable to add new attachment to task "
+
taskId
);
}
}
}
modules/activiti-webapp-rest2/src/main/java/org/activiti/rest/application/ActivitiRestApplication.java
浏览文件 @
b9a3b30e
...
...
@@ -22,6 +22,7 @@ import org.activiti.rest.api.identity.LoginResource;
import
org.activiti.rest.api.identity.UserGroupsResource
;
import
org.activiti.rest.api.identity.UserPictureResource
;
import
org.activiti.rest.api.identity.UserResource
;
import
org.activiti.rest.api.identity.UserSearchResource
;
import
org.activiti.rest.api.management.JobExecuteResource
;
import
org.activiti.rest.api.management.JobResource
;
import
org.activiti.rest.api.management.JobsExecuteResource
;
...
...
@@ -45,6 +46,7 @@ import org.activiti.rest.api.task.TaskFormResource;
import
org.activiti.rest.api.task.TaskOperationResource
;
import
org.activiti.rest.api.task.TaskPropertiesResource
;
import
org.activiti.rest.api.task.TaskResource
;
import
org.activiti.rest.api.task.TaskUrlAddResource
;
import
org.activiti.rest.api.task.TasksResource
;
import
org.activiti.rest.api.task.TasksSummaryResource
;
import
org.restlet.Application
;
...
...
@@ -102,6 +104,7 @@ public class ActivitiRestApplication extends Application {
router
.
attach
(
"/user/{userId}"
,
UserResource
.
class
);
router
.
attach
(
"/user/{userId}/groups"
,
UserGroupsResource
.
class
);
router
.
attach
(
"/user/{userId}/picture"
,
UserPictureResource
.
class
);
router
.
attach
(
"/users/{searchText}"
,
UserSearchResource
.
class
);
router
.
attach
(
"/group/{groupId}"
,
GroupResource
.
class
);
router
.
attach
(
"/groups/{groupId}/users"
,
GroupUsersResource
.
class
);
...
...
@@ -117,8 +120,9 @@ public class ActivitiRestApplication extends Application {
router
.
attach
(
"/task"
,
TaskAddResource
.
class
);
router
.
attach
(
"/task/{taskId}"
,
TaskResource
.
class
);
router
.
attach
(
"/task/{taskId}/form"
,
TaskFormResource
.
class
);
router
.
attach
(
"/task/{taskId}/{operation}"
,
TaskOperationResource
.
class
);
router
.
attach
(
"/task/{taskId}/attachment"
,
TaskAttachmentAddResource
.
class
);
router
.
attach
(
"/task/{taskId}/url"
,
TaskUrlAddResource
.
class
);
router
.
attach
(
"/task/{taskId}/{operation}"
,
TaskOperationResource
.
class
);
router
.
attach
(
"/attachment/{attachmentId}"
,
TaskAttachmentResource
.
class
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录