Skip to content

Commit

Permalink
issue #177
Browse files Browse the repository at this point in the history
  • Loading branch information
rsoika committed Jul 23, 2016
1 parent d7dc3a9 commit dfae9be
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,17 @@
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput;
import javax.ws.rs.core.UriInfo;

import org.imixs.workflow.ItemCollection;
import org.imixs.workflow.Model;
import org.imixs.workflow.bpmn.BPMNModel;
import org.imixs.workflow.exceptions.ModelException;
import org.imixs.workflow.jee.ejb.WorkflowService;
import org.imixs.workflow.xml.EntityCollection;
import org.imixs.workflow.xml.XMLItemCollection;
import org.imixs.workflow.xml.XMLItemCollectionAdapter;
Expand All @@ -82,6 +85,9 @@ public class ModelRestService {
@EJB
org.imixs.workflow.jee.ejb.EntityService entityService;

@EJB
WorkflowRestService workflowRestService;

@EJB
org.imixs.workflow.jee.ejb.ModelService modelService;

Expand Down Expand Up @@ -146,8 +152,7 @@ private void printVersionTable(OutputStream out) {
buffer.append("<tr>");

if (modelEntity != null) {
buffer.append("<td><a href=\"./workflow/workitem/" + modelEntity.getUniqueID() + "/file/"
+ modelEntity.getFileNames().get(0) + "\">" + modelVersion + "</a></td>");
buffer.append("<td><a href=\"./model/" + modelVersion + "/bpmn\">" + modelVersion + "</a></td>");

// print upload date...
if (modelEntity != null) {
Expand All @@ -164,8 +169,9 @@ private void printVersionTable(OutputStream out) {
buffer.append("<td>");
for (String group : groupList) {
// build a link for each group to get the Tasks

buffer.append("<a href=\"./model/" + modelVersion + "/groups/"+group + "\">" + group + "</a></br>");

buffer.append(
"<a href=\"./model/" + modelVersion + "/groups/" + group + "\">" + group + "</a></br>");
}
buffer.append("</td>");
buffer.append("</tr>");
Expand Down Expand Up @@ -219,10 +225,22 @@ public EntityCollection findAllTasks(@PathParam("version") String version, @Quer
return new EntityCollection();
}

@GET
@Path("/{version}/bpmn")
public Response getModelFile(@PathParam("version") String version, @Context UriInfo uriInfo) {
ItemCollection modelEntity = modelService.loadModelEntity(version);
if (modelEntity != null) {
return workflowRestService.getWorkItemFile(modelEntity.getUniqueID(), modelEntity.getFileNames().get(0),
uriInfo);
} else {
return Response.status(Response.Status.NOT_FOUND).build();
}
}

@GET
@Path("/{version}/tasks/{taskid}")
public XMLItemCollection getTask(@PathParam("version") String version,
@PathParam("taskid") int processid, @QueryParam("items") String items) {
public XMLItemCollection getTask(@PathParam("version") String version, @PathParam("taskid") int processid,
@QueryParam("items") String items) {
ItemCollection process = null;
try {
process = modelService.getModel(version).getTask(processid);
Expand All @@ -236,8 +254,8 @@ public XMLItemCollection getTask(@PathParam("version") String version,

@GET
@Path("/{version}/tasks/{taskid}/events")
public EntityCollection findAllEventsByTask(@PathParam("version") String version, @PathParam("taskid") int processid,
@QueryParam("items") String items) {
public EntityCollection findAllEventsByTask(@PathParam("version") String version,
@PathParam("taskid") int processid, @QueryParam("items") String items) {
Collection<ItemCollection> col = null;
try {
col = modelService.getModel(version).findAllEventsByTask(processid);
Expand Down Expand Up @@ -277,8 +295,8 @@ public List<String> getGroups(@PathParam("version") String version, @QueryParam(
*/
@GET
@Path("/{version}/groups/{group}")
public EntityCollection findTasksByGroup(@PathParam("version") String version,
@PathParam("group") String group, @QueryParam("items") String items) {
public EntityCollection findTasksByGroup(@PathParam("version") String version, @PathParam("group") String group,
@QueryParam("items") String items) {
Collection<ItemCollection> col = null;
try {
col = modelService.getModel(version).findTasksByGroup(group);
Expand Down
5 changes: 3 additions & 2 deletions src/site/markdown/restapi/modelservice.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ The main resource /model is used to read and update workflow models through the


## The /model resources GET
The /model GET resources are used to get business objects provided by the Imixs Model Manager:
The /model GET resources are used to get model objects provided by the Model Manager:


| URI | Description |
Expand All @@ -14,11 +14,12 @@ The /model GET resources are used to get business objects provided by the Imixs
| /model/{version}/tasks/{taskid}/events | all events assigned to a specific task identified by its eventID. |
| /model/{version}/groups | a collection of all workflow groups |
| /model/{version}/groups/{group} | all tasks of a specific workflow group |
| /model/{version}/bpmn | BPMN source file |



##The /model resources DELETE
The /model DELETE resources URIs are used to delete business objects:
The /model DELETE resources URIs are used to delete model objects:

| URI | Description |
|-----------------------------------------------|-------------------------------------------|
Expand Down

0 comments on commit dfae9be

Please sign in to comment.