From dfae9be71e60058b4b2222cf83ee8ba8211dbf1d Mon Sep 17 00:00:00 2001 From: Ralph Soika Date: Sat, 23 Jul 2016 10:11:54 +0200 Subject: [PATCH] issue #177 --- .../workflow/jaxrs/ModelRestService.java | 38 ++++++++++++++----- src/site/markdown/restapi/modelservice.md | 5 ++- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/ModelRestService.java b/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/ModelRestService.java index 2d55362d9..e3f440f47 100644 --- a/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/ModelRestService.java +++ b/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/ModelRestService.java @@ -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; @@ -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; @@ -146,8 +152,7 @@ private void printVersionTable(OutputStream out) { buffer.append(""); if (modelEntity != null) { - buffer.append("" + modelVersion + ""); + buffer.append("" + modelVersion + ""); // print upload date... if (modelEntity != null) { @@ -164,8 +169,9 @@ private void printVersionTable(OutputStream out) { buffer.append(""); for (String group : groupList) { // build a link for each group to get the Tasks - - buffer.append("" + group + "
"); + + buffer.append( + "" + group + "
"); } buffer.append(""); buffer.append(""); @@ -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); @@ -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 col = null; try { col = modelService.getModel(version).findAllEventsByTask(processid); @@ -277,8 +295,8 @@ public List 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 col = null; try { col = modelService.getModel(version).findTasksByGroup(group); diff --git a/src/site/markdown/restapi/modelservice.md b/src/site/markdown/restapi/modelservice.md index e3ca9ee98..177cd0624 100644 --- a/src/site/markdown/restapi/modelservice.md +++ b/src/site/markdown/restapi/modelservice.md @@ -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 | @@ -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 | |-----------------------------------------------|-------------------------------------------|