提交 f9ff249b 编写于 作者: O o2null

Merge branch 'cherry-pick-9b9cd152' into 'develop'

Merge branch 'fix/#330' into 'wrdp'

See merge request o2oa/o2oa!1469
......@@ -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<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
ActionResult<Wo> 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<String> callable = new Callable<String>() {
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<ActionResult<Wo>> callable = () -> {
ActionResult<Wo> 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 {
......
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<Wo> 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<ActionResult<Wo>> callable = new Callable<ActionResult<Wo>>() {
public ActionResult<Wo> 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<Wo> 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<Wi, Work> copier = WrapCopierFactory.wi(Wi.class, Work.class, null, JpaObject.FieldsUnmodify);
}
public static class Wo extends WrapBoolean {
}
}
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<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> 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<Work, Wo> copier = WrapCopierFactory.wo(Work.class, Wo.class, null,
JpaObject.FieldsInvisible);
}
}
\ No newline at end of file
......@@ -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<ActionEdit.Wo> 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<ActionGet.Wo> 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")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册