提交 db7406e5 编写于 作者: O o2null

Merge branch 'feature/druid' into 'develop'

修复导入应用没有刷新缓存

See merge request o2oa/o2oa!1380
......@@ -12,6 +12,8 @@ import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.organization.OrganizationDefinition;
import com.x.base.core.project.tools.ListTools;
import com.x.processplatform.assemble.designer.Business;
......@@ -20,46 +22,53 @@ import com.x.processplatform.core.entity.element.Application;
class ActionCreate extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
/* 这里的角色多一个 RoleDefinition.ProcessPlatformCreator */
if ((effectivePerson.isNotManager()) && (!business.organization().person().hasRole(effectivePerson,
OrganizationDefinition.Manager, OrganizationDefinition.ProcessPlatformManager,
OrganizationDefinition.ProcessPlatformCreator))) {
throw new ExceptionInsufficientPermission(effectivePerson.getDistinguishedName());
}
emc.beginTransaction(Application.class);
Application application = new Application();
Wi.copier.copy(wi, application);
application.setCreatorPerson(effectivePerson.getDistinguishedName());
application.setLastUpdatePerson(effectivePerson.getDistinguishedName());
application.setLastUpdateTime(new Date());
application.setControllerList(ListTools.add(application.getControllerList(), true, true, effectivePerson.getDistinguishedName()));
emc.persist(application, CheckPersistType.all);
emc.commit();
CacheManager.notify(Application.class);
Wo wo = new Wo();
wo.setId(application.getId());
result.setData(wo);
MessageFactory.application_create(application);
return result;
}
}
private static final Logger LOGGER = LoggerFactory.getLogger(ActionCreate.class);
public static class Wo extends WoId {
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
// 这里的角色多一个 RoleDefinition.ProcessPlatformCreator
if ((effectivePerson.isNotManager()) && (!business.organization().person().hasRole(effectivePerson,
OrganizationDefinition.Manager, OrganizationDefinition.ProcessPlatformManager,
OrganizationDefinition.ProcessPlatformCreator))) {
throw new ExceptionInsufficientPermission(effectivePerson.getDistinguishedName());
}
emc.beginTransaction(Application.class);
Application application = new Application();
Wi.copier.copy(wi, application);
// 如果是管理员就不写入到创建者
if (!effectivePerson.isManager()) {
application.setCreatorPerson(effectivePerson.getDistinguishedName());
}
application.setLastUpdatePerson(effectivePerson.getDistinguishedName());
application.setLastUpdateTime(new Date());
application.setControllerList(
ListTools.add(application.getControllerList(), true, true, effectivePerson.getDistinguishedName()));
emc.persist(application, CheckPersistType.all);
emc.commit();
CacheManager.notify(Application.class);
Wo wo = new Wo();
wo.setId(application.getId());
result.setData(wo);
MessageFactory.application_create(application);
return result;
}
}
}
public static class Wo extends WoId {
public static class Wi extends Application {
}
private static final long serialVersionUID = 6624639107781167248L;
public static class Wi extends Application {
static WrapCopier<Wi, Application> copier = WrapCopierFactory.wi(Wi.class, Application.class, null,
FieldsUnmodifyIncludePorperties);
private static final long serialVersionUID = 6624639107781167248L;
}
static WrapCopier<Wi, Application> copier = WrapCopierFactory.wi(Wi.class, Application.class, null,
FieldsUnmodifyIncludePorperties);
}
}
......@@ -12,49 +12,56 @@ import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.processplatform.assemble.designer.Business;
import com.x.processplatform.assemble.designer.MessageFactory;
import com.x.processplatform.core.entity.element.Application;
class ActionEdit extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, JsonElement jsonElement) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
emc.beginTransaction(Application.class);
Application application = emc.find(id, Application.class);
if (null == application) {
throw new ExceptionApplicationNotExist(id);
}
if (!business.editable(effectivePerson, application)) {
throw new ExceptionInsufficientPermission(effectivePerson.getDistinguishedName());
}
Wi.copier.copy(wi, application);
application.setLastUpdatePerson(effectivePerson.getDistinguishedName());
application.setLastUpdateTime(new Date());
emc.commit();
CacheManager.notify(Application.class);
Wo wo = new Wo();
wo.setId(application.getId());
result.setData(wo);
MessageFactory.application_update(application);
return result;
}
}
public static class Wo extends WoId {
}
public static class Wi extends Application {
private static final long serialVersionUID = 6624639107781167248L;
static WrapCopier<Wi, Application> copier = WrapCopierFactory.wi(Wi.class, Application.class, null,
JpaObject.FieldsUnmodifyIncludePorpertiesExcludeId);
}
private static final Logger LOGGER = LoggerFactory.getLogger(ActionEdit.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, JsonElement jsonElement) throws Exception {
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
emc.beginTransaction(Application.class);
Application application = emc.find(id, Application.class);
if (null == application) {
throw new ExceptionApplicationNotExist(id);
}
if (!business.editable(effectivePerson, application)) {
throw new ExceptionInsufficientPermission(effectivePerson.getDistinguishedName());
}
Wi.copier.copy(wi, application);
application.setLastUpdatePerson(effectivePerson.getDistinguishedName());
application.setLastUpdateTime(new Date());
emc.commit();
CacheManager.notify(Application.class);
Wo wo = new Wo();
wo.setId(application.getId());
result.setData(wo);
MessageFactory.application_update(application);
return result;
}
}
public static class Wo extends WoId {
}
public static class Wi extends Application {
private static final long serialVersionUID = 6624639107781167248L;
static WrapCopier<Wi, Application> copier = WrapCopierFactory.wi(Wi.class, Application.class, null,
JpaObject.FieldsUnmodifyIncludePorpertiesExcludeId);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册