diff --git a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/ActionDelete.java b/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/ActionDelete.java index 9954172999e78f62dce9f1b1fc8f926b6bee660d..2afdc7bec206e31a67845c0695ac1aaca6b85d6f 100644 --- a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/ActionDelete.java +++ b/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/ActionDelete.java @@ -12,14 +12,13 @@ import com.x.base.core.project.http.EffectivePerson; import com.x.base.core.project.jaxrs.WoId; import com.x.base.core.project.tools.ListTools; import com.x.processplatform.core.entity.content.Task; +import com.x.processplatform.core.entity.content.Work; import com.x.processplatform.service.processing.MessageFactory; class ActionDelete extends BaseAction { ActionResult execute(EffectivePerson effectivePerson, String id) throws Exception { - ActionResult result = new ActionResult<>(); - Wo wo = new Wo(); String executorSeed = null; try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { @@ -31,27 +30,32 @@ class ActionDelete extends BaseAction { executorSeed = task.getJob(); } - Callable callable = new Callable() { - public String call() throws Exception { - try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { - Task task = emc.find(id, Task.class); - if (null == task) { - throw new ExceptionEntityNotExist(id, Task.class); - } - emc.beginTransaction(Task.class); - emc.remove(task, CheckRemoveType.all); - emc.commit(); - MessageFactory.task_delete(task); - wo.setId(task.getId()); - result.setData(wo); - return ""; + Callable> callable = () -> { + ActionResult result = new ActionResult<>(); + Wo wo = new Wo(); + try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { + Task task = emc.find(id, Task.class); + if (null == task) { + throw new ExceptionEntityNotExist(id, Task.class); } + Work work = emc.find(task.getWork(), Work.class); + if (null == work) { + throw new ExceptionEntityNotExist(task.getWork(), Work.class); + } + emc.beginTransaction(Task.class); + emc.beginTransaction(Work.class); + emc.remove(task, CheckRemoveType.all); + work.getManualTaskIdentityList().remove(task.getIdentity()); + emc.commit(); + MessageFactory.task_delete(task); + wo.setId(task.getId()); + result.setData(wo); + return result; } }; - ProcessPlatformExecutorFactory.get(executorSeed).submit(callable).get(); + return ProcessPlatformExecutorFactory.get(executorSeed).submit(callable).get(); - return result; } public static class Wo extends WoId { diff --git a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/work/ActionEdit.java b/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/work/ActionEdit.java new file mode 100644 index 0000000000000000000000000000000000000000..e255615d75cbb5b47bf31c3a631d4d62eee12a67 --- /dev/null +++ b/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/work/ActionEdit.java @@ -0,0 +1,68 @@ +package com.x.processplatform.service.processing.jaxrs.work; + +import java.util.concurrent.Callable; + +import com.google.gson.JsonElement; +import com.x.base.core.container.EntityManagerContainer; +import com.x.base.core.container.factory.EntityManagerContainerFactory; +import com.x.base.core.entity.JpaObject; +import com.x.base.core.project.bean.WrapCopier; +import com.x.base.core.project.bean.WrapCopierFactory; +import com.x.base.core.project.exception.ExceptionEntityNotExist; +import com.x.base.core.project.executor.ProcessPlatformExecutorFactory; +import com.x.base.core.project.http.ActionResult; +import com.x.base.core.project.http.EffectivePerson; +import com.x.base.core.project.jaxrs.WrapBoolean; +import com.x.base.core.project.tools.ListTools; +import com.x.processplatform.core.entity.content.Work; + +class ActionEdit extends BaseAction { + + ActionResult execute(EffectivePerson effectivePerson, String id, JsonElement jsonElement) throws Exception { + + String executorSeed = null; + try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { + Work work = emc.fetch(id, Work.class, ListTools.toList(Work.job_FIELDNAME)); + if (null == work) { + throw new ExceptionEntityNotExist(id, Work.class); + } + executorSeed = work.getJob(); + } + + Callable> callable = new Callable>() { + public ActionResult call() throws Exception { + try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { + Wi wi = convertToWrapIn(jsonElement, Wi.class); + Work work = emc.find(id, Work.class); + if (null == work) { + throw new ExceptionEntityNotExist(id, Work.class); + } + emc.beginTransaction(Work.class); + Wi.copier.copy(wi, work); + emc.commit(); + ActionResult result = new ActionResult<>(); + Wo wo = new Wo(); + wo.setValue(true); + result.setData(wo); + return result; + } + } + }; + + return ProcessPlatformExecutorFactory.get(executorSeed).submit(callable).get(); + + } + + public static class Wi extends Work { + + private static final long serialVersionUID = 5099568433277325703L; + + static WrapCopier copier = WrapCopierFactory.wi(Wi.class, Work.class, null, JpaObject.FieldsUnmodify); + + } + + public static class Wo extends WrapBoolean { + + } + +} diff --git a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/work/ActionGet.java b/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/work/ActionGet.java new file mode 100644 index 0000000000000000000000000000000000000000..125fb99195713d534dd5151f5e225805d162d253 --- /dev/null +++ b/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/work/ActionGet.java @@ -0,0 +1,38 @@ +package com.x.processplatform.service.processing.jaxrs.work; + +import com.x.base.core.container.EntityManagerContainer; +import com.x.base.core.container.factory.EntityManagerContainerFactory; +import com.x.base.core.entity.JpaObject; +import com.x.base.core.project.bean.WrapCopier; +import com.x.base.core.project.bean.WrapCopierFactory; +import com.x.base.core.project.exception.ExceptionEntityNotExist; +import com.x.base.core.project.http.ActionResult; +import com.x.base.core.project.http.EffectivePerson; +import com.x.processplatform.core.entity.content.Work; + +class ActionGet extends BaseAction { + + ActionResult execute(EffectivePerson effectivePerson, String id) throws Exception { + + try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { + ActionResult result = new ActionResult<>(); + Work work = emc.find(id, Work.class); + if (null == work) { + throw new ExceptionEntityNotExist(id, Work.class); + } + result.setData(Wo.copier.copy(work)); + return result; + } + + } + + public static class Wo extends Work { + + private static final long serialVersionUID = -9161129188274302594L; + + static WrapCopier copier = WrapCopierFactory.wo(Work.class, Wo.class, null, + JpaObject.FieldsInvisible); + + } + +} \ No newline at end of file diff --git a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/work/WorkAction.java b/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/work/WorkAction.java index 6f0e1241a12f2982df9ce6b94f70a6f6ed4f9def..a4a75349d473ef3524d3d0655e3973c70e568a75 100644 --- a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/work/WorkAction.java +++ b/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/work/WorkAction.java @@ -214,6 +214,42 @@ public class WorkAction extends StandardJaxrsAction { asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result)); } + @JaxrsMethodDescribe(value = "更新工作实例.", action = ActionEdit.class) + @PUT + @Path("{id}") + @Produces(HttpMediaType.APPLICATION_JSON_UTF_8) + @Consumes(MediaType.APPLICATION_JSON) + public void edit(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, + @JaxrsParameterDescribe("工作标识") @PathParam("id") String id, JsonElement jsonElement) { + ActionResult result = new ActionResult<>(); + EffectivePerson effectivePerson = this.effectivePerson(request); + try { + result = new ActionEdit().execute(effectivePerson, id, jsonElement); + } catch (Exception e) { + logger.error(e, effectivePerson, request, jsonElement); + result.error(e); + } + asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result)); + } + + @JaxrsMethodDescribe(value = "获取工作实例.", action = ActionGet.class) + @GET + @Path("{id}") + @Produces(HttpMediaType.APPLICATION_JSON_UTF_8) + @Consumes(MediaType.APPLICATION_JSON) + public void get(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, + @JaxrsParameterDescribe("工作标识") @PathParam("id") String id) { + ActionResult result = new ActionResult<>(); + EffectivePerson effectivePerson = this.effectivePerson(request); + try { + result = new ActionGet().execute(effectivePerson, id); + } catch (Exception e) { + logger.error(e, effectivePerson, request, null); + result.error(e); + } + asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result)); + } + @JaxrsMethodDescribe(value = "指定Work运行映射.", action = ActionProjection.class) @GET @Path("{id}/projection")