提交 ab3c4169 编写于 作者: O o2null

Merge branch 'feature/index' into 'develop'

Feature/index

See merge request o2oa/o2oa!1250
......@@ -8,7 +8,8 @@ goto out
if not exist "%~dp0local" (
md "%~dp0local"
)
echo ^<configuration^> > "%~dp0local\service.xml"
echo ^<?xml version="1.0" encoding="GBK" ?^> > "%~dp0local\service.xml"
echo ^<configuration^> >> "%~dp0local\service.xml"
echo ^<id^>O2SERVER^<^/id^> >> "%~dp0local\service.xml"
echo ^<name^>O2SERVER SERVICE^<^/name^> >> "%~dp0local\service.xml"
echo ^<description^>O2OA Platform Service.^<^/description^> >> "%~dp0local\service.xml"
......@@ -17,4 +18,4 @@ echo ^<log mode="none"^/^> >> "%~dp0local\service.xml"
echo ^</configuration^> >> "%~dp0local\service.xml"
copy "%~dp0commons\winsw.exe" "%~dp0local\service.exe"
"%~dp0local\service.exe" %1
:out
\ No newline at end of file
:out
......@@ -5,41 +5,23 @@ import com.x.base.core.project.annotation.Module;
import com.x.base.core.project.annotation.ModuleCategory;
import com.x.base.core.project.annotation.ModuleType;
//@Module(type = ModuleType.ASSEMBLE, category = ModuleCategory.OFFICIAL, name = "数据查询设计", packageName = "com.x.query.assemble.designer", containerEntities = {
// "com.x.query.core.entity.program.Argument", "com.x.query.core.entity.Item", "com.x.query.core.entity.Query",
// "com.x.query.core.entity.View", "com.x.query.core.entity.Stat", "com.x.query.core.entity.Reveal",
// "com.x.query.core.entity.neural.Entry", "com.x.query.core.entity.neural.InText",
// "com.x.query.core.entity.neural.OutText", "com.x.query.core.entity.neural.InValue",
// "com.x.query.core.entity.neural.OutValue", "com.x.query.core.entity.neural.Model",
// "com.x.query.core.entity.schema.Table", "com.x.query.core.entity.schema.Statement",
// "com.x.query.core.entity.ImportModel",
// "com.x.processplatform.core.entity.content.Review", "com.x.processplatform.core.entity.content.Work",
// "com.x.processplatform.core.entity.content.WorkCompleted", "com.x.processplatform.core.entity.content.Task",
// "com.x.processplatform.core.entity.content.TaskCompleted", "com.x.processplatform.core.entity.content.Read",
// "com.x.processplatform.core.entity.content.ReadCompleted","com.x.processplatform.core.entity.element.Process",
// "com.x.processplatform.core.entity.content.Attachment", "com.x.cms.core.entity.Document",
// "com.x.cms.core.entity.AppInfo", "com.x.cms.core.entity.CategoryInfo", "com.x.cms.core.entity.Review",
// "com.x.organization.core.entity.Person", "com.x.organization.core.entity.Unit", "com.x.organization.core.entity.Group",
// "com.x.query.dynamic.entity.*" }, storageTypes = { StorageType.processPlatform }, storeJars = {
// "x_query_core_entity", "x_organization_core_entity", "x_organization_core_express",
// "x_processplatform_core_entity", "x_cms_core_entity",
// "x_query_core_express" }, dynamicJars = { "x_query_dynamic_entity" })
@Module(type = ModuleType.ASSEMBLE, category = ModuleCategory.OFFICIAL, name = "数据查询设计", packageName = "com.x.query.assemble.designer", containerEntities = {
"com.x.query.core.entity.program.Argument", "com.x.query.core.entity.Item", "com.x.query.core.entity.Query",
"com.x.query.core.entity.View", "com.x.query.core.entity.Stat", "com.x.query.core.entity.Reveal",
"com.x.query.core.entity.neural.Entry", "com.x.query.core.entity.neural.InText",
"com.x.query.core.entity.neural.OutText", "com.x.query.core.entity.neural.InValue",
"com.x.query.core.entity.neural.OutValue", "com.x.query.core.entity.neural.Model",
"com.x.query.core.entity.schema.Table", "com.x.query.core.entity.schema.Statement",
"com.x.query.core.entity.ImportModel", "com.x.processplatform.core.entity.content.Review",
"com.x.processplatform.core.entity.content.Work", "com.x.processplatform.core.entity.content.WorkCompleted",
"com.x.processplatform.core.entity.content.Task", "com.x.processplatform.core.entity.content.TaskCompleted",
"com.x.processplatform.core.entity.content.Read", "com.x.processplatform.core.entity.content.ReadCompleted",
"com.x.processplatform.core.entity.element.Process", "com.x.processplatform.core.entity.content.Attachment",
"com.x.cms.core.entity.Document", "com.x.cms.core.entity.AppInfo", "com.x.cms.core.entity.CategoryInfo",
"com.x.cms.core.entity.Review", "com.x.organization.core.entity.Person", "com.x.organization.core.entity.Unit",
"com.x.organization.core.entity.Group" }, storageTypes = { StorageType.processPlatform }, storeJars = {
"x_query_core_entity", "x_organization_core_entity", "x_organization_core_express",
"x_processplatform_core_entity", "x_cms_core_entity", "x_query_core_express" })
"com.x.query.core.entity.program.Argument", "com.x.query.core.entity.Item", "com.x.query.core.entity.Query",
"com.x.query.core.entity.View", "com.x.query.core.entity.Stat",
// "com.x.query.core.entity.Reveal",
"com.x.query.core.entity.neural.Entry", "com.x.query.core.entity.neural.InText",
"com.x.query.core.entity.neural.OutText", "com.x.query.core.entity.neural.InValue",
"com.x.query.core.entity.neural.OutValue", "com.x.query.core.entity.neural.Model",
"com.x.query.core.entity.schema.Table", "com.x.query.core.entity.schema.Statement",
"com.x.query.core.entity.ImportModel", "com.x.processplatform.core.entity.content.Review",
"com.x.processplatform.core.entity.content.Work", "com.x.processplatform.core.entity.content.WorkCompleted",
"com.x.processplatform.core.entity.content.Task", "com.x.processplatform.core.entity.content.TaskCompleted",
"com.x.processplatform.core.entity.content.Read", "com.x.processplatform.core.entity.content.ReadCompleted",
"com.x.processplatform.core.entity.element.Process", "com.x.processplatform.core.entity.content.Attachment",
"com.x.cms.core.entity.Document", "com.x.cms.core.entity.AppInfo", "com.x.cms.core.entity.CategoryInfo",
"com.x.cms.core.entity.Review", "com.x.organization.core.entity.Person", "com.x.organization.core.entity.Unit",
"com.x.organization.core.entity.Group" }, storageTypes = { StorageType.processPlatform }, storeJars = {
"x_query_core_entity", "x_organization_core_entity", "x_organization_core_express",
"x_processplatform_core_entity", "x_cms_core_entity", "x_query_core_express" })
public class x_query_assemble_designer extends Deployable {
}
......@@ -7,8 +7,9 @@ import com.x.base.core.project.annotation.ModuleType;
@Module(type = ModuleType.ASSEMBLE, category = ModuleCategory.OFFICIAL, name = "数据查询", packageName = "com.x.query.assemble.surface", containerEntities = {
"com.x.query.core.entity.program.Argument", "com.x.query.core.entity.Item", "com.x.query.core.entity.Query",
"com.x.query.core.entity.View", "com.x.query.core.entity.Stat", "com.x.query.core.entity.Reveal",
"com.x.query.core.entity.segment.Word", "com.x.query.core.entity.segment.Entry",
"com.x.query.core.entity.View", "com.x.query.core.entity.Stat",
// "com.x.query.core.entity.Reveal",
// "com.x.query.core.entity.segment.Word", "com.x.query.core.entity.segment.Entry",
"com.x.query.core.entity.neural.Entry", "com.x.query.core.entity.neural.InText",
"com.x.query.core.entity.neural.OutText", "com.x.query.core.entity.neural.InValue",
"com.x.query.core.entity.neural.OutValue", "com.x.query.core.entity.neural.Model",
......
......@@ -7,8 +7,9 @@ import com.x.base.core.project.annotation.ModuleType;
@Module(type = ModuleType.SERVICE, category = ModuleCategory.OFFICIAL, name = "数据查询服务", packageName = "com.x.query.service.processing", containerEntities = {
"com.x.query.core.entity.program.Argument", "com.x.query.core.entity.Item", "com.x.query.core.entity.Query",
"com.x.query.core.entity.View", "com.x.query.core.entity.Stat", "com.x.query.core.entity.Reveal",
"com.x.query.core.entity.segment.Word", "com.x.query.core.entity.segment.Entry",
"com.x.query.core.entity.View", "com.x.query.core.entity.Stat",
// "com.x.query.core.entity.Reveal",
// "com.x.query.core.entity.segment.Word", "com.x.query.core.entity.segment.Entry",
"com.x.query.core.entity.neural.Entry", "com.x.query.core.entity.neural.InText",
"com.x.query.core.entity.neural.OutText", "com.x.query.core.entity.neural.InValue",
"com.x.query.core.entity.neural.OutValue", "com.x.query.core.entity.neural.Model",
......
......@@ -18,21 +18,20 @@ import com.x.cms.assemble.control.Business;
import com.x.cms.core.entity.element.Script;
import com.x.cms.core.entity.element.Script_;
public class ScriptFactory extends ElementFactory {
public ScriptFactory(Business business) throws Exception {
super(business);
}
public ScriptFactory(Business business) throws Exception {
super(business);
}
public Script pick(String flag) throws Exception {
return this.pick(flag, ExceptionWhen.none);
}
public Script pick(String flag) throws Exception {
return this.pick(flag, ExceptionWhen.none);
}
@Deprecated
public Script pick(String flag, ExceptionWhen exceptionWhen) throws Exception {
return this.pick(flag, Script.class);
}
@Deprecated
public Script pick(String flag, ExceptionWhen exceptionWhen) throws Exception {
return this.pick(flag, Script.class);
}
// public List<Script> list( List<String> ids ) throws Exception {
// EntityManager em = this.entityManagerContainer().get(Script.class);
......@@ -43,99 +42,101 @@ public class ScriptFactory extends ElementFactory {
// return em.createQuery(cq.where(p)).getResultList();
// }
public List<String> listWithApp(String appId) throws Exception {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.equal(root.get(Script_.appId), appId);
cq.select(root.get(Script_.id)).where(p);
return em.createQuery(cq).getResultList();
}
public List<String> listWithApp(String appId) throws Exception {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.equal(root.get(Script_.appId), appId);
cq.select(root.get(Script_.id)).where(p);
return em.createQuery(cq).getResultList();
}
public List<Script> listScriptWithApp(String appId) throws Exception {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Script> cq = cb.createQuery(Script.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.equal(root.get(Script_.appId), appId);
return em.createQuery(cq.where(p)).getResultList();
}
public List<Script> listScriptWithApp(String appId) throws Exception {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Script> cq = cb.createQuery(Script.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.equal(root.get(Script_.appId), appId);
return em.createQuery(cq.where(p)).getResultList();
}
public String getWithAppWithName(String appId, String name) throws Exception {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.equal(root.get(Script_.alias), name);
p = cb.or(p, cb.equal(root.get(Script_.name), name));
p = cb.and(p, cb.equal(root.get(Script_.appId), appId));
cq.select(root.get(Script_.id)).where(p);
List<String> list = em.createQuery(cq).setMaxResults(1).getResultList();
return list.isEmpty() ? null : list.get(0);
}
public String getWithAppWithName(String appId, String name) throws Exception {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.equal(root.get(Script_.alias), name);
p = cb.or(p, cb.equal(root.get(Script_.name), name));
p = cb.and(p, cb.equal(root.get(Script_.appId), appId));
cq.select(root.get(Script_.id)).where(p);
List<String> list = em.createQuery(cq).setMaxResults(1).getResultList();
return list.isEmpty() ? null : list.get(0);
}
@SuppressWarnings("unchecked")
public List<Script> listScriptNestedWithAppInfoWithUniqueName( String appId, String uniqueName ) throws Exception {
List<Script> list = new ArrayList<>();
try {
Cache.CacheCategory cacheCategory = new Cache.CacheCategory(Script.class);
Cache.CacheKey cacheKey = new Cache.CacheKey( this.getClass(), "listScriptNestedWithAppInfoWithUniqueName", appId, uniqueName );
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey );
if (optional.isPresent()) {
list = (List<Script>) optional.get();
} else {
List<String> names = new ArrayList<>();
names.add( uniqueName );
while (!names.isEmpty()) {
List<String> loops = new ArrayList<>();
for ( String name : names ) {
Script o = this.getScriptWithAppInfoWithUniqueName(appId, name);
if ((null != o) && (!list.contains(o))) {
list.add(o);
loops.addAll(o.getDependScriptList());
}
}
names = loops;
}
if (!list.isEmpty()) {
Collections.reverse(list);
CacheManager.put(cacheCategory, cacheKey, list );
}
}
return list;
} catch (Exception e) {
throw new Exception("listScriptNestedWithAppInfoWithUniqueName error.", e);
}
}
@SuppressWarnings("unchecked")
public List<Script> listScriptNestedWithAppInfoWithUniqueName(String appId, String uniqueName) throws Exception {
List<Script> list = new ArrayList<>();
try {
Cache.CacheCategory cacheCategory = new Cache.CacheCategory(Script.class);
Cache.CacheKey cacheKey = new Cache.CacheKey(this.getClass(), "listScriptNestedWithAppInfoWithUniqueName",
appId, uniqueName);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) {
list = (List<Script>) optional.get();
} else {
List<String> names = new ArrayList<>();
names.add(uniqueName);
while (!names.isEmpty()) {
List<String> loops = new ArrayList<>();
for (String name : names) {
Script o = this.getScriptWithAppInfoWithUniqueName(appId, name);
if ((null != o) && (!list.contains(o))) {
list.add(o);
loops.addAll(o.getDependScriptList());
}
}
names = loops;
}
if (!list.isEmpty()) {
Collections.reverse(list);
CacheManager.put(cacheCategory, cacheKey, list);
}
}
return list;
} catch (Exception e) {
throw new Exception("listScriptNestedWithAppInfoWithUniqueName error.", e);
}
}
public Script getScriptWithAppInfoWithUniqueName( String appId, String uniqueName ) throws Exception {
Script script = null;
try {
Cache.CacheCategory cacheCategory = new Cache.CacheCategory(Script.class);
Cache.CacheKey cacheKey = new Cache.CacheKey( this.getClass(), "getScriptWithAppInfoWithUniqueName", appId, uniqueName );
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey );
if (optional.isPresent()) {
script = (Script) optional.get();
} else {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Script> cq = cb.createQuery(Script.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.equal( root.get(Script_.name), uniqueName );
p = cb.or( p, cb.equal( root.get(Script_.alias), uniqueName ));
p = cb.or( p, cb.equal( root.get(Script_.id), uniqueName ));
p = cb.and( p, cb.equal( root.get(Script_.appId), appId ));
List<Script> list = em.createQuery( cq.where(p) ).setMaxResults(1).getResultList();
if (!list.isEmpty()) {
script = list.get(0);
em.detach(script);
CacheManager.put(cacheCategory, cacheKey, script );
}
}
return script;
} catch (Exception e) {
throw new Exception("getScriptWithAppInfoWithUniqueName error.", e);
}
}
private Script getScriptWithAppInfoWithUniqueName(String appId, String uniqueName) throws Exception {
Script script = null;
try {
Cache.CacheCategory cacheCategory = new Cache.CacheCategory(Script.class);
Cache.CacheKey cacheKey = new Cache.CacheKey(this.getClass(), "getScriptWithAppInfoWithUniqueName", appId,
uniqueName);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) {
script = (Script) optional.get();
} else {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Script> cq = cb.createQuery(Script.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.equal(root.get(Script_.name), uniqueName);
p = cb.or(p, cb.equal(root.get(Script_.alias), uniqueName));
p = cb.or(p, cb.equal(root.get(Script_.id), uniqueName));
p = cb.and(p, cb.equal(root.get(Script_.appId), appId));
List<Script> list = em.createQuery(cq.where(p)).setMaxResults(1).getResultList();
if (!list.isEmpty()) {
script = list.get(0);
em.detach(script);
CacheManager.put(cacheCategory, cacheKey, script);
}
}
return script;
} catch (Exception e) {
throw new Exception("getScriptWithAppInfoWithUniqueName error.", e);
}
}
}
......@@ -25,74 +25,74 @@ import com.x.portal.core.entity.Portal_;
public class PortalFactory extends AbstractFactory {
static CacheCategory cache = new CacheCategory(Portal.class);
static CacheCategory cache = new CacheCategory(Portal.class);
public PortalFactory(Business abstractBusiness) throws Exception {
super(abstractBusiness);
}
public PortalFactory(Business abstractBusiness) throws Exception {
super(abstractBusiness);
}
public List<String> list(EffectivePerson effectivePerson) throws Exception {
EntityManager em = this.entityManagerContainer().get(Portal.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Portal> root = cq.from(Portal.class);
Predicate p = cb.conjunction();
if (effectivePerson.isNotManager() && (!this.business().organization().person().hasRole(effectivePerson,
OrganizationDefinition.PortalManager))) {
List<String> identities = this.business().organization().identity()
.listWithPerson(effectivePerson.getDistinguishedName());
List<String> units = this.business().organization().unit()
.listWithPersonSupNested(effectivePerson.getDistinguishedName());
p = cb.equal(root.get(Portal_.creatorPerson), effectivePerson.getDistinguishedName());
p = cb.or(p, cb.isMember(effectivePerson.getDistinguishedName(), root.get(Portal_.controllerList)));
p = cb.or(cb.and(cb.isEmpty(root.get(Portal_.availableIdentityList)),
cb.isEmpty(root.get(Portal_.availableUnitList))));
p = cb.or(p, root.get(Portal_.availableIdentityList).in(identities));
p = cb.or(p, root.get(Portal_.availableUnitList).in(units));
}
cq.select(root.get(Portal_.id)).where(p);
return em.createQuery(cq).getResultList().stream().distinct().collect(Collectors.toList());
}
public List<String> list(EffectivePerson effectivePerson) throws Exception {
EntityManager em = this.entityManagerContainer().get(Portal.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Portal> root = cq.from(Portal.class);
Predicate p = cb.conjunction();
if (effectivePerson.isNotManager() && (!this.business().organization().person().hasRole(effectivePerson,
OrganizationDefinition.PortalManager))) {
List<String> identities = this.business().organization().identity()
.listWithPerson(effectivePerson.getDistinguishedName());
List<String> units = this.business().organization().unit()
.listWithPersonSupNested(effectivePerson.getDistinguishedName());
p = cb.equal(root.get(Portal_.creatorPerson), effectivePerson.getDistinguishedName());
p = cb.or(p, cb.isMember(effectivePerson.getDistinguishedName(), root.get(Portal_.controllerList)));
p = cb.or(p, cb.and(cb.isEmpty(root.get(Portal_.availableIdentityList)),
cb.isEmpty(root.get(Portal_.availableUnitList))));
p = cb.or(p, root.get(Portal_.availableIdentityList).in(identities));
p = cb.or(p, root.get(Portal_.availableUnitList).in(units));
}
cq.select(root.get(Portal_.id)).where(p);
return em.createQuery(cq).getResultList().stream().distinct().collect(Collectors.toList());
}
public boolean visible(EffectivePerson effectivePerson, Portal portal) throws Exception {
if (effectivePerson.isManager() || BooleanUtils.isTrue(this.business().organization().person()
.hasRole(effectivePerson, OrganizationDefinition.PortalManager))) {
return true;
}
if (effectivePerson.isPerson(portal.getCreatorPerson())) {
return true;
}
if (effectivePerson.isPerson(portal.getControllerList())) {
return true;
}
if (ListTools.isEmpty(portal.getAvailableIdentityList(), portal.getAvailableUnitList())) {
return true;
}
List<String> identities = this.business().organization().identity()
.listWithPerson(effectivePerson.getDistinguishedName());
if (ListTools.containsAny(identities, portal.getAvailableIdentityList())) {
return true;
}
List<String> units = this.business().organization().unit().listWithPersonSupNested(effectivePerson);
if (ListTools.containsAny(units, portal.getAvailableUnitList())) {
return true;
}
return false;
}
public boolean visible(EffectivePerson effectivePerson, Portal portal) throws Exception {
if (effectivePerson.isManager() || BooleanUtils.isTrue(this.business().organization().person()
.hasRole(effectivePerson, OrganizationDefinition.PortalManager))) {
return true;
}
if (effectivePerson.isPerson(portal.getCreatorPerson())) {
return true;
}
if (effectivePerson.isPerson(portal.getControllerList())) {
return true;
}
if (ListTools.isEmpty(portal.getAvailableIdentityList(), portal.getAvailableUnitList())) {
return true;
}
List<String> identities = this.business().organization().identity()
.listWithPerson(effectivePerson.getDistinguishedName());
if (ListTools.containsAny(identities, portal.getAvailableIdentityList())) {
return true;
}
List<String> units = this.business().organization().unit().listWithPersonSupNested(effectivePerson);
if (ListTools.containsAny(units, portal.getAvailableUnitList())) {
return true;
}
return false;
}
public Portal pick(String flag) throws Exception {
CacheKey cacheKey = new CacheKey(flag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
return (Portal) optional.get();
} else {
Portal o = this.business().entityManagerContainer().flag(flag, Portal.class);
if (null != o) {
this.business().entityManagerContainer().get(Portal.class).detach(o);
CacheManager.put(cache, cacheKey, o);
return o;
}
return null;
}
}
public Portal pick(String flag) throws Exception {
CacheKey cacheKey = new CacheKey(flag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
return (Portal) optional.get();
} else {
Portal o = this.business().entityManagerContainer().flag(flag, Portal.class);
if (null != o) {
this.business().entityManagerContainer().get(Portal.class).detach(o);
CacheManager.put(cache, cacheKey, o);
return o;
}
return null;
}
}
}
\ No newline at end of file
......@@ -74,8 +74,7 @@ public class ScriptFactory extends AbstractFactory {
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.equal(root.get(Script_.portal), portalId);
List<String> list = em.createQuery(cq.select(root.get(Script_.id)).where(p)).getResultList();
return list;
return em.createQuery(cq.select(root.get(Script_.id)).where(p)).getResultList();
}
@SuppressWarnings("unchecked")
......
package com.x.processplatform.assemble.surface.factory.cms;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.cache.Cache;
import com.x.base.core.project.cache.CacheManager;
import com.x.cms.core.entity.element.Script;
import com.x.cms.core.entity.element.Script_;
import com.x.processplatform.assemble.surface.Business;
import com.x.processplatform.assemble.surface.factory.element.ElementFactory;
public class ScriptFactory extends ElementFactory {
public ScriptFactory(Business abstractBusiness) throws Exception {
super(abstractBusiness);
}
public ScriptFactory(Business abstractBusiness) throws Exception {
super(abstractBusiness);
}
public Script pick(String flag) throws Exception {
return this.pick(flag, Script.class);
}
@SuppressWarnings("unchecked")
public List<Script> listScriptNestedWithAppInfoWithUniqueName(String appId, String uniqueName) throws Exception {
List<Script> list = new ArrayList<>();
try {
Cache.CacheCategory cacheCategory = new Cache.CacheCategory(Script.class);
Cache.CacheKey cacheKey = new Cache.CacheKey(this.getClass(), "listScriptNestedWithAppInfoWithUniqueName",
appId, uniqueName);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) {
list = (List<Script>) optional.get();
} else {
List<String> names = new ArrayList<>();
names.add(uniqueName);
while (!names.isEmpty()) {
List<String> loops = new ArrayList<>();
for (String name : names) {
Script o = this.getScriptWithAppInfoWithUniqueName(appId, name);
if ((null != o) && (!list.contains(o))) {
list.add(o);
loops.addAll(o.getDependScriptList());
}
}
names = loops;
}
if (!list.isEmpty()) {
Collections.reverse(list);
CacheManager.put(cacheCategory, cacheKey, list);
}
}
return list;
} catch (Exception e) {
throw new Exception("listScriptNestedWithAppInfoWithUniqueName error.", e);
}
}
public Script pick(String flag) throws Exception {
return this.pick(flag, Script.class);
}
private Script getScriptWithAppInfoWithUniqueName(String appId, String uniqueName) throws Exception {
Script script = null;
try {
Cache.CacheCategory cacheCategory = new Cache.CacheCategory(Script.class);
Cache.CacheKey cacheKey = new Cache.CacheKey(this.getClass(), "getScriptWithAppInfoWithUniqueName", appId,
uniqueName);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) {
script = (Script) optional.get();
} else {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Script> cq = cb.createQuery(Script.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.equal(root.get(Script_.name), uniqueName);
p = cb.or(p, cb.equal(root.get(Script_.alias), uniqueName));
p = cb.or(p, cb.equal(root.get(Script_.id), uniqueName));
p = cb.and(p, cb.equal(root.get(Script_.appId), appId));
List<Script> list = em.createQuery(cq.where(p)).setMaxResults(1).getResultList();
if (!list.isEmpty()) {
script = list.get(0);
em.detach(script);
CacheManager.put(cacheCategory, cacheKey, script);
}
}
return script;
} catch (Exception e) {
throw new Exception("getScriptWithAppInfoWithUniqueName error.", e);
}
}
}
\ No newline at end of file
......@@ -2,8 +2,11 @@ package com.x.processplatform.assemble.surface.factory.element;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
......@@ -11,118 +14,149 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.cache.Cache.CacheCategory;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.exception.ExceptionWhen;
import com.x.base.core.project.tools.ListTools;
import com.x.processplatform.assemble.surface.Business;
import com.x.processplatform.core.entity.element.Application;
import com.x.processplatform.core.entity.element.Script;
import com.x.processplatform.core.entity.element.Script_;
public class ScriptFactory extends ElementFactory {
public ScriptFactory(Business abstractBusiness) throws Exception {
super(abstractBusiness);
}
public ScriptFactory(Business abstractBusiness) throws Exception {
super(abstractBusiness);
}
public Script pick(String flag) throws Exception {
return this.pick(flag, ExceptionWhen.none);
}
@Deprecated
public Script pick(String flag, ExceptionWhen exceptionWhen) throws Exception {
return this.pick(flag, Script.class);
}
public Script pick(String flag) throws Exception {
return this.pick(flag, ExceptionWhen.none);
}
@SuppressWarnings("unchecked")
public List<Script> listScriptNestedWithApplicationWithUniqueName(String applicationId, String uniqueName)
throws Exception {
List<Script> list = new ArrayList<>();
if (StringUtils.isEmpty(applicationId)) {
return list;
}
CacheCategory cacheCategory = new CacheCategory(Script.class);
CacheKey cacheKey = new CacheKey("listScriptNestedWithApplicationWithUniqueName", applicationId,
uniqueName);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) {
list = (List<Script>) optional.get();
} else {
List<String> names = new ArrayList<>();
names.add(uniqueName);
while (!names.isEmpty()) {
List<String> loops = new ArrayList<>();
for (String name : names) {
Script o = this.getScriptWithApplicationWithUniqueName(applicationId, name);
if ((null != o) && (!list.contains(o))) {
list.add(o);
loops.addAll(o.getDependScriptList());
}
}
names = loops;
}
if (!list.isEmpty()) {
Collections.reverse(list);
CacheManager.put(cacheCategory, cacheKey, list);
}
}
return list;
}
@Deprecated
public Script pick(String flag, ExceptionWhen exceptionWhen) throws Exception {
return this.pick(flag, Script.class);
}
private Script getScriptWithApplicationWithUniqueName(String applicationId, String uniqueName) throws Exception {
Script script = this.getWithApplicationWithId(applicationId, uniqueName);
if (null == script) {
script = this.getWithApplicationWithAlias(applicationId, uniqueName);
}
if (null == script) {
script = this.getWithApplicationWithName(applicationId, uniqueName);
}
if (script != null) {
this.entityManagerContainer().get(Script.class).detach(script);
}
return script;
}
@SuppressWarnings("unchecked")
public List<Script> listScriptNestedWithApplicationWithUniqueName(Application application, String uniqueName)
throws Exception {
List<Script> list = new ArrayList<>();
if (null == application) {
return list;
}
CacheCategory cacheCategory = new CacheCategory(Script.class);
CacheKey cacheKey = new CacheKey("listScriptNestedWithApplicationWithUniqueName", application.getId(),
uniqueName);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) {
list = (List<Script>) optional.get();
} else {
List<String> names = new ArrayList<>();
names.add(uniqueName);
while (!names.isEmpty()) {
List<String> loops = new ArrayList<>();
for (String name : names) {
Script o = this.getScriptWithApplicationWithUniqueName(application, name);
if ((null != o) && (!list.contains(o))) {
list.add(o);
loops.addAll(o.getDependScriptList());
}
}
names = loops;
}
if (!list.isEmpty()) {
Collections.reverse(list);
CacheManager.put(cacheCategory, cacheKey, list);
}
}
return list;
}
private Script getWithApplicationWithId(String applicationId, String uniqueName) throws Exception {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Script> cq = cb.createQuery(Script.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.equal(root.get(Script_.id), uniqueName);
p = cb.and(p, cb.equal(root.get(Script_.application), applicationId));
List<Script> list = em.createQuery(cq.where(p)).setMaxResults(1).getResultList();
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
private Script getScriptWithApplicationWithUniqueName(Application application, String uniqueName) throws Exception {
Script script = this.getWithApplicationWithId(application, uniqueName);
if (null == script) {
script = this.getWithApplicationWithAlias(application, uniqueName);
}
if (null == script) {
script = this.getWithApplicationWithName(application, uniqueName);
}
if(script != null){
this.entityManagerContainer().get(Script.class).detach(script);
}
return script;
}
private Script getWithApplicationWithAlias(String applicationId, String uniqueName) throws Exception {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Script> cq = cb.createQuery(Script.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.equal(root.get(Script_.alias), uniqueName);
p = cb.and(p, cb.equal(root.get(Script_.application), applicationId));
List<Script> list = em.createQuery(cq.where(p)).setMaxResults(1).getResultList();
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
private Script getWithApplicationWithId(Application application, String uniqueName) throws Exception {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Script> cq = cb.createQuery(Script.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.equal(root.get(Script_.id), uniqueName);
p = cb.and(p, cb.equal(root.get(Script_.application), application.getId()));
List<Script> list = em.createQuery(cq.where(p)).setMaxResults(1).getResultList();
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
private Script getWithApplicationWithName(String applicationId, String uniqueName) throws Exception {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Script> cq = cb.createQuery(Script.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.equal(root.get(Script_.name), uniqueName);
p = cb.and(p, cb.equal(root.get(Script_.application), applicationId));
List<Script> list = em.createQuery(cq.where(p)).setMaxResults(1).getResultList();
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
private Script getWithApplicationWithAlias(Application application, String uniqueName) throws Exception {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Script> cq = cb.createQuery(Script.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.equal(root.get(Script_.alias), uniqueName);
p = cb.and(p, cb.equal(root.get(Script_.application), application.getId()));
List<Script> list = em.createQuery(cq.where(p)).setMaxResults(1).getResultList();
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* 递归获取脚本以及递归依赖的脚本
*
* @param flag
* @return
* @throws Exception
*/
public List<Script> listScriptNested(String flag) throws Exception {
Map<String, Script> map = new LinkedHashMap<>();
this.listScriptNested(flag, map);
return map.entrySet().stream().map(Map.Entry::getValue).collect(Collectors.toList());
}
private Script getWithApplicationWithName(Application application, String uniqueName) throws Exception {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Script> cq = cb.createQuery(Script.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.equal(root.get(Script_.name), uniqueName);
p = cb.and(p, cb.equal(root.get(Script_.application), application.getId()));
List<Script> list = em.createQuery(cq.where(p)).setMaxResults(1).getResultList();
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
private void listScriptNested(String flag, Map<String, Script> map)
throws Exception {
if (map.containsKey(flag)) {
return;
}
Script script = this.pick(flag);
if ((null != script) && (!map.containsKey(script.getId()))) {
map.put(script.getId(), script);
if (ListTools.isNotEmpty(script.getDependScriptList())) {
for (String str : script.getDependScriptList()) {
listScriptNested(str, map);
}
}
}
}
}
package com.x.processplatform.assemble.surface.factory.portal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.cache.Cache.CacheCategory;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import com.x.portal.core.entity.Script;
import com.x.portal.core.entity.Script_;
import com.x.processplatform.assemble.surface.Business;
import com.x.processplatform.assemble.surface.factory.element.ElementFactory;
public class ScriptFactory extends ElementFactory {
public ScriptFactory(Business abstractBusiness) throws Exception {
super(abstractBusiness);
}
public ScriptFactory(Business abstractBusiness) throws Exception {
super(abstractBusiness);
}
public Script pick(String flag) throws Exception {
return this.pick(flag, Script.class);
}
@SuppressWarnings("unchecked")
public List<Script> listScriptNestedWithPortalWithFlag(String portalId, String flag) throws Exception {
List<Script> list = new ArrayList<>();
if (StringUtils.isBlank(portalId)) {
return list;
}
CacheCategory cacheCategory = new CacheCategory(Script.class);
CacheKey cacheKey = new CacheKey(flag, portalId, "listScriptNestedWithPortalWithFlag");
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) {
list = (List<Script>) optional.get();
} else {
List<String> names = new ArrayList<>();
names.add(flag);
while (!names.isEmpty()) {
List<String> loops = new ArrayList<>();
for (String name : names) {
Script o = this.getScriptWithPortalWithFlag(portalId, name);
if ((null != o) && (!list.contains(o))) {
list.add(o);
loops.addAll(o.getDependScriptList());
}
}
names = loops;
}
if (!list.isEmpty()) {
Collections.reverse(list);
CacheManager.put(cacheCategory, cacheKey, list);
}
}
return list;
}
private Script getScriptWithPortalWithFlag(String portalId, String flag) throws Exception {
Script script = this.getWithPortalWithId(portalId, flag);
if (null == script) {
script = this.getWithPortalWithAlias(portalId, flag);
}
if (null == script) {
script = this.getWithPortalWithName(portalId, flag);
}
return script;
}
private Script getWithPortalWithId(String portalId, String flag) throws Exception {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Script> cq = cb.createQuery(Script.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.equal(root.get(Script_.id), flag);
p = cb.and(p, cb.equal(root.get(Script_.portal), portalId));
List<Script> list = em.createQuery(cq.where(p)).setMaxResults(1).getResultList();
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
private Script getWithPortalWithAlias(String portalId, String flag) throws Exception {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Script> cq = cb.createQuery(Script.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.equal(root.get(Script_.alias), flag);
p = cb.and(p, cb.equal(root.get(Script_.portal), portalId));
List<Script> list = em.createQuery(cq.where(p)).setMaxResults(1).getResultList();
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
public Script pick(String flag) throws Exception {
return this.pick(flag, Script.class);
}
private Script getWithPortalWithName(String portalId, String flag) throws Exception {
EntityManager em = this.entityManagerContainer().get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Script> cq = cb.createQuery(Script.class);
Root<Script> root = cq.from(Script.class);
Predicate p = cb.equal(root.get(Script_.name), flag);
p = cb.and(p, cb.equal(root.get(Script_.portal), portalId));
List<Script> list = em.createQuery(cq.where(p)).setMaxResults(1).getResultList();
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
}
\ No newline at end of file
......@@ -26,131 +26,143 @@ import com.x.base.core.project.organization.OrganizationDefinition;
import com.x.base.core.project.tools.ListTools;
import com.x.processplatform.assemble.surface.Business;
import com.x.processplatform.core.entity.element.Application;
import com.x.processplatform.core.entity.element.Application_;
import com.x.processplatform.core.entity.element.Process;
import com.x.processplatform.core.entity.element.Process_;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* 2022-11-22
* 此方法用于在系统菜单->流程中显示可用应用,基于应用中设置的可用身份和可用组织确定
*
* @author ray
*
*/
class ActionListWithPerson extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionListWithPerson.class);
/**
* 1.身份在可使用列表中<br/>
* 2.组织在可使用组织中 <br/>
* 4.没有限定身份和组织 <br/>
* 5.个人在应用管理员中 <br/>
* 6.应用的创建人员 <br/>
* 7.个人有Manage权限或者ProcessPlatformManager身份
*/
@SuppressWarnings("unchecked")
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson) throws Exception {
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
ActionResult<List<Wo>> result = new ActionResult<>();
List<Wo> wos = new ArrayList<>();
CacheKey cacheKey = new CacheKey(this.getClass(), effectivePerson.getDistinguishedName());
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) {
wos = (List<Wo>) optional.get();
} else {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
List<String> identities = business.organization().identity().listWithPerson(effectivePerson);
// 去除部门以及上级部门,如果设置了一级部门可用,那么一级部门下属的二级部门也可用
List<String> units = business.organization().unit().listWithPersonSupNested(effectivePerson);
List<String> roles = business.organization().role().listWithPerson(effectivePerson);
List<String> groups = business.organization().group().listWithIdentity(identities);
List<String> ids = this.list(business, effectivePerson, roles, identities, units, groups);
for (String id : ids) {
Application o = business.application().pick(id);
if (null != o) {
wos.add(Wo.copier.copy(o));
}
}
wos = business.application().sort(wos);
CacheManager.put(cacheCategory, cacheKey, wos);
}
}
result.setData(wos);
return result;
}
@Schema(name = "com.x.processplatform.assemble.surface.jaxrs.application.ActionListWithPerson$Wo")
public static class Wo extends Application {
private static final long serialVersionUID = -4862564047240738097L;
static WrapCopier<Application, Wo> copier = WrapCopierFactory.wo(Application.class, Wo.class, null,
JpaObject.FieldsInvisible);
}
/**
* 从可见的application中获取一份ids<br/>
* 从可启动的process中获取一份ids <br/>
* 两份ids的交集,这样避免列示只有application没有可以启动process的应用
*/
private List<String> list(Business business, EffectivePerson effectivePerson, List<String> roles,
List<String> identities, List<String> units, List<String> groups) throws Exception {
return this.listFromProcess(business, effectivePerson, roles, identities, units, groups);
}
// private List<String> listFromApplication(Business business, EffectivePerson effectivePerson, List<String> roles,
// List<String> identities, List<String> units) throws Exception {
// List<String> list = new ArrayList<>();
// EntityManager em = business.entityManagerContainer().get(Application.class);
// CriteriaBuilder cb = em.getCriteriaBuilder();
// CriteriaQuery<String> cq = cb.createQuery(String.class);
// Root<Application> root = cq.from(Application.class);
// if (effectivePerson.isNotManager() && (!business.organization().person().hasRole(effectivePerson,
// OrganizationDefinition.Manager, OrganizationDefinition.ProcessPlatformManager))) {
// Predicate p = cb.and(cb.isEmpty(root.get(Application_.availableIdentityList)),
// cb.isEmpty(root.get(Application_.availableUnitList)));
// p = cb.or(p, cb.isMember(effectivePerson.getDistinguishedName(), root.get(Application_.controllerList)));
// p = cb.or(p, cb.equal(root.get(Application_.creatorPerson), effectivePerson.getDistinguishedName()));
// if (ListTools.isNotEmpty(identities)) {
// p = cb.or(p, root.get(Application_.availableIdentityList).in(identities));
// }
// if (ListTools.isNotEmpty(units)) {
// p = cb.or(p, root.get(Application_.availableUnitList).in(units));
// }
// cq.where(p);
// }
// return em.createQuery(cq.select(root.get(Application_.id))).getResultList().stream().distinct()
// .collect(Collectors.toList());
// }
/**
*
* 从Process中获取可以启动的Process的application.
*/
private List<String> listFromProcess(Business business, EffectivePerson effectivePerson, List<String> roles,
List<String> identities, List<String> units, List<String> groups) throws Exception {
EntityManager em = business.entityManagerContainer().get(Process.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Process> root = cq.from(Process.class);
Predicate p = cb.conjunction();
if (effectivePerson.isNotManager() && (!business.organization().person().hasRole(effectivePerson,
OrganizationDefinition.Manager, OrganizationDefinition.ProcessPlatformManager))) {
p = cb.and(cb.isEmpty(root.get(Process_.startableIdentityList)),
cb.isEmpty(root.get(Process_.startableUnitList)),
cb.isEmpty(root.get(Process_.startableGroupList)));
p = cb.or(p, cb.isMember(effectivePerson.getDistinguishedName(), root.get(Process_.controllerList)));
p = cb.or(p, cb.equal(root.get(Process_.creatorPerson), effectivePerson.getDistinguishedName()));
if (ListTools.isNotEmpty(identities)) {
p = cb.or(p, root.get(Process_.startableIdentityList).in(identities));
}
if (ListTools.isNotEmpty(units)) {
p = cb.or(p, root.get(Process_.startableUnitList).in(units));
}
if (ListTools.isNotEmpty(groups)) {
p = cb.or(p, root.get(Process_.startableGroupList).in(groups));
}
}
cq.select(root.get(Process_.application)).where(p);
return em.createQuery(cq).getResultList().stream().distinct().collect(Collectors.toList());
}
private static final Logger LOGGER = LoggerFactory.getLogger(ActionListWithPerson.class);
/**
* 1.身份在可使用列表中 <br/>
* 2.组织在可使用组织中 <br/>
* 4.没有限定身份和组织 <br/>
* 5.个人在应用管理员中 <br/>
* 6.应用的创建人员 <br/>
* 7.个人有Manage权限或者ProcessPlatformManager身份
*/
@SuppressWarnings("unchecked")
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson) throws Exception {
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
ActionResult<List<Wo>> result = new ActionResult<>();
List<Wo> wos = new ArrayList<>();
CacheKey cacheKey = new CacheKey(this.getClass(), effectivePerson.getDistinguishedName());
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) {
wos = (List<Wo>) optional.get();
} else {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
List<String> identities = business.organization().identity().listWithPerson(effectivePerson);
// 去除部门以及上级部门,如果设置了一级部门可用,那么一级部门下属的二级部门也可用
List<String> units = business.organization().unit().listWithPersonSupNested(effectivePerson);
List<String> roles = business.organization().role().listWithPerson(effectivePerson);
// List<String> groups =
// business.organization().group().listWithIdentity(identities);
// List<String> ids = this.list(business, effectivePerson, roles, identities, units, groups);
List<String> ids = listFromApplication(business, effectivePerson, roles, identities, units);
for (String id : ids) {
Application o = business.application().pick(id);
if (null != o) {
wos.add(Wo.copier.copy(o));
}
}
wos = business.application().sort(wos);
CacheManager.put(cacheCategory, cacheKey, wos);
}
}
result.setData(wos);
return result;
}
@Schema(name = "com.x.processplatform.assemble.surface.jaxrs.application.ActionListWithPerson$Wo")
public static class Wo extends Application {
private static final long serialVersionUID = -4862564047240738097L;
static WrapCopier<Application, Wo> copier = WrapCopierFactory.wo(Application.class, Wo.class, null,
JpaObject.FieldsInvisible);
}
/**
* 从可见的application中获取一份ids<br/>
* 从可启动的process中获取一份ids <br/>
* 两份ids的交集,这样避免列示只有application没有可以启动process的应用
*/
// private List<String> list(Business business, EffectivePerson effectivePerson, List<String> roles,
// List<String> identities, List<String> units, List<String> groups) throws Exception {
// // return this.listFromProcess(business, effectivePerson, roles, identities,
// // units, groups);
// return listFromApplication(business, effectivePerson, roles,
// identities, units);
// }
private List<String> listFromApplication(Business business, EffectivePerson effectivePerson, List<String> roles,
List<String> identities, List<String> units) throws Exception {
EntityManager em = business.entityManagerContainer().get(Application.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Application> root = cq.from(Application.class);
if (effectivePerson.isNotManager() && (!business.organization().person().hasRole(effectivePerson,
OrganizationDefinition.Manager, OrganizationDefinition.ProcessPlatformManager))) {
Predicate p = cb.and(cb.isEmpty(root.get(Application_.availableIdentityList)),
cb.isEmpty(root.get(Application_.availableUnitList)));
p = cb.or(p, cb.isMember(effectivePerson.getDistinguishedName(), root.get(Application_.controllerList)));
p = cb.or(p, cb.equal(root.get(Application_.creatorPerson), effectivePerson.getDistinguishedName()));
if (ListTools.isNotEmpty(identities)) {
p = cb.or(p, root.get(Application_.availableIdentityList).in(identities));
}
if (ListTools.isNotEmpty(units)) {
p = cb.or(p, root.get(Application_.availableUnitList).in(units));
}
cq.where(p);
}
return em.createQuery(cq.select(root.get(Application_.id))).getResultList().stream().distinct()
.collect(Collectors.toList());
}
/**
*
* 从Process中获取可以启动的Process的application.
*/
private List<String> listFromProcess(Business business, EffectivePerson effectivePerson, List<String> roles,
List<String> identities, List<String> units, List<String> groups) throws Exception {
EntityManager em = business.entityManagerContainer().get(Process.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Process> root = cq.from(Process.class);
Predicate p = cb.conjunction();
if (effectivePerson.isNotManager() && (!business.organization().person().hasRole(effectivePerson,
OrganizationDefinition.Manager, OrganizationDefinition.ProcessPlatformManager))) {
p = cb.and(cb.isEmpty(root.get(Process_.startableIdentityList)),
cb.isEmpty(root.get(Process_.startableUnitList)),
cb.isEmpty(root.get(Process_.startableGroupList)));
p = cb.or(p, cb.isMember(effectivePerson.getDistinguishedName(), root.get(Process_.controllerList)));
p = cb.or(p, cb.equal(root.get(Process_.creatorPerson), effectivePerson.getDistinguishedName()));
if (ListTools.isNotEmpty(identities)) {
p = cb.or(p, root.get(Process_.startableIdentityList).in(identities));
}
if (ListTools.isNotEmpty(units)) {
p = cb.or(p, root.get(Process_.startableUnitList).in(units));
}
if (ListTools.isNotEmpty(groups)) {
p = cb.or(p, root.get(Process_.startableGroupList).in(groups));
}
}
cq.select(root.get(Process_.application)).where(p);
return em.createQuery(cq).getResultList().stream().distinct().collect(Collectors.toList());
}
}
\ No newline at end of file
package com.x.processplatform.assemble.surface.jaxrs.form;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
......@@ -30,136 +31,217 @@ import com.x.processplatform.core.entity.content.WorkCompletedProperties.Related
import com.x.processplatform.core.entity.content.WorkCompletedProperties.RelatedScript;
import com.x.processplatform.core.entity.element.Form;
import com.x.processplatform.core.entity.element.FormProperties;
import com.x.processplatform.core.entity.element.Script;
import io.swagger.v3.oas.annotations.media.Schema;
class V2Get extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(V2Get.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, String tag) throws Exception {
LOGGER.debug("execute:{}, id:{}, tag:{}.", effectivePerson::getDistinguishedName, () -> id, () -> tag);
ActionResult<Wo> result = new ActionResult<>();
CacheKey cacheKey = new CacheKey(this.getClass(), id, tag);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) {
result.setData((Wo) optional.get());
} else {
Form form = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
form = business.form().pick(id);
}
if (null == form) {
throw new ExceptionEntityNotExist(id, Form.class);
}
Wo wo = new Wo();
final FormProperties properties = form.getProperties();
final List<String> list = new CopyOnWriteArrayList<>();
wo.setForm(new RelatedForm(form, form.getDataOrMobileData()));
CompletableFuture<Map<String, RelatedForm>> getRelatedFormFuture = this.getRelatedFormFuture(properties,
list);
CompletableFuture<Map<String, RelatedScript>> getRelatedScriptFuture = this
.getRelatedScriptFuture(properties, list);
wo.setRelatedFormMap(
getRelatedFormFuture.get(Config.processPlatform().getAsynchronousTimeout(), TimeUnit.SECONDS));
wo.setRelatedScriptMap(
getRelatedScriptFuture.get(Config.processPlatform().getAsynchronousTimeout(), TimeUnit.SECONDS));
if (StringUtils.isNotBlank(tag)) {
wo.setMaxAge(3600 * 24);
}
list.add(form.getId() + form.getUpdateTime().getTime());
List<String> sortList = list.stream().sorted().collect(Collectors.toList());
wo.setFastETag(StringUtils.join(sortList, "#"));
CacheManager.put(cacheCategory, cacheKey, wo);
result.setData(wo);
}
return result;
}
private CompletableFuture<Map<String, RelatedForm>> getRelatedFormFuture(FormProperties properties,
final List<String> list) {
return CompletableFuture.supplyAsync(() -> {
Map<String, RelatedForm> map = new TreeMap<>();
if (ListTools.isNotEmpty(properties.getRelatedFormList())) {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business bus = new Business(emc);
Form f;
for (String id : properties.getRelatedFormList()) {
f = bus.form().pick(id);
if (null != f) {
map.put(id, new RelatedForm(f, f.getDataOrMobileData()));
list.add(f.getId() + f.getUpdateTime().getTime());
}
}
} catch (Exception e) {
LOGGER.error(e);
}
}
return map;
}, ThisApplication.threadPool());
}
private CompletableFuture<Map<String, RelatedScript>> getRelatedScriptFuture(FormProperties properties,
final List<String> list) {
return CompletableFuture.supplyAsync(() -> {
Map<String, RelatedScript> map = new TreeMap<>();
if ((null != properties.getRelatedScriptMap()) && (properties.getRelatedScriptMap().size() > 0)) {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
map = convertScript(business, properties, list);
} catch (Exception e) {
LOGGER.error(e);
}
}
return map;
}, ThisApplication.threadPool());
}
private Map<String, RelatedScript> convertScript(Business bus, FormProperties properties, final List<String> list)
throws Exception {
Map<String, RelatedScript> map = new TreeMap<>();
for (Entry<String, String> entry : properties.getRelatedScriptMap().entrySet()) {
switch (entry.getValue()) {
case WorkCompletedProperties.RelatedScript.TYPE_PROCESSPLATFORM:
Script pp = bus.script().pick(entry.getKey());
if (null != pp) {
map.put(entry.getKey(),
new RelatedScript(pp.getId(), pp.getName(), pp.getAlias(), pp.getText(), entry.getValue()));
list.add(pp.getId() + pp.getUpdateTime().getTime());
}
break;
case WorkCompletedProperties.RelatedScript.TYPE_CMS:
com.x.cms.core.entity.element.Script cms = bus.cms().script().pick(entry.getKey());
if (null != cms) {
map.put(entry.getKey(), new RelatedScript(cms.getId(), cms.getName(), cms.getAlias(), cms.getText(),
entry.getValue()));
list.add(cms.getId() + cms.getUpdateTime().getTime());
}
break;
case WorkCompletedProperties.RelatedScript.TYPE_PORTAL:
com.x.portal.core.entity.Script p = bus.portal().script().pick(entry.getKey());
if (null != p) {
map.put(entry.getKey(),
new RelatedScript(p.getId(), p.getName(), p.getAlias(), p.getText(), entry.getValue()));
list.add(p.getId() + p.getUpdateTime().getTime());
}
break;
default:
break;
}
}
return map;
}
@Schema(name = "com.x.processplatform.assemble.surface.jaxrs.form.V2Get$Wo")
public static class Wo extends AbstractWo {
private static final long serialVersionUID = 2776033956637839042L;
}
private static final Logger LOGGER = LoggerFactory.getLogger(V2Get.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, String tag) throws Exception {
LOGGER.debug("execute:{}, id:{}, tag:{}.", effectivePerson::getDistinguishedName, () -> id, () -> tag);
ActionResult<Wo> result = new ActionResult<>();
CacheKey cacheKey = new CacheKey(this.getClass(), id, tag);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) {
result.setData((Wo) optional.get());
} else {
Form form = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
form = business.form().pick(id);
}
if (null == form) {
throw new ExceptionEntityNotExist(id, Form.class);
}
Wo wo = new Wo();
final FormProperties properties = form.getProperties();
final List<String> list = new CopyOnWriteArrayList<>();
wo.setForm(new RelatedForm(form, form.getDataOrMobileData()));
CompletableFuture<Map<String, RelatedForm>> getRelatedFormFuture = this.getRelatedFormFuture(properties,
list);
CompletableFuture<Map<String, RelatedScript>> getRelatedScriptFuture = this
.getRelatedScriptFuture(form.getApplication(), properties, list);
wo.setRelatedFormMap(
getRelatedFormFuture.get(Config.processPlatform().getAsynchronousTimeout(), TimeUnit.SECONDS));
wo.setRelatedScriptMap(
getRelatedScriptFuture.get(Config.processPlatform().getAsynchronousTimeout(), TimeUnit.SECONDS));
if (StringUtils.isNotBlank(tag)) {
wo.setMaxAge(3600 * 24);
}
list.add(form.getId() + form.getUpdateTime().getTime());
List<String> sortList = list.stream().sorted().collect(Collectors.toList());
wo.setFastETag(StringUtils.join(sortList, "#"));
CacheManager.put(cacheCategory, cacheKey, wo);
result.setData(wo);
}
return result;
}
private CompletableFuture<Map<String, RelatedForm>> getRelatedFormFuture(FormProperties properties,
final List<String> list) {
return CompletableFuture.supplyAsync(() -> {
Map<String, RelatedForm> map = new TreeMap<>();
if (ListTools.isNotEmpty(properties.getRelatedFormList())) {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business bus = new Business(emc);
Form f;
for (String id : properties.getRelatedFormList()) {
f = bus.form().pick(id);
if (null != f) {
map.put(id, new RelatedForm(f, f.getDataOrMobileData()));
list.add(f.getId() + f.getUpdateTime().getTime());
}
}
} catch (Exception e) {
LOGGER.error(e);
}
}
return map;
}, ThisApplication.threadPool());
}
private CompletableFuture<Map<String, RelatedScript>> getRelatedScriptFuture(String applicationId,
FormProperties properties,
final List<String> list) {
return CompletableFuture.supplyAsync(() -> {
Map<String, RelatedScript> map = new TreeMap<>();
if ((null != properties.getRelatedScriptMap()) && (properties.getRelatedScriptMap().size() > 0)) {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
map = convertScript(business, applicationId, properties, list);
} catch (Exception e) {
LOGGER.error(e);
}
}
return map;
}, ThisApplication.threadPool());
}
private Map<String, RelatedScript> convertScript(Business business, String applicationId, FormProperties properties,
final List<String> list)
throws Exception {
Map<String, RelatedScript> map = new TreeMap<>();
for (Entry<String, String> entry : properties.getRelatedScriptMap().entrySet()) {
switch (entry.getValue()) {
case WorkCompletedProperties.RelatedScript.TYPE_PROCESSPLATFORM:
com.x.processplatform.core.entity.element.Script processPlatformScript = business.script()
.pick(entry.getKey());
if (null != processPlatformScript) {
map.put(processPlatformScript.getId(),
new RelatedScript(processPlatformScript.getId(), processPlatformScript.getName(),
processPlatformScript.getAlias(),
processPlatformScriptLoad(business, processPlatformScript),
WorkCompletedProperties.RelatedScript.TYPE_PROCESSPLATFORM));
list.add(processPlatformScript.getId() + processPlatformScript.getUpdateTime().getTime());
}
break;
case WorkCompletedProperties.RelatedScript.TYPE_CMS:
com.x.cms.core.entity.element.Script cmsScript = business.cms().script().pick(entry.getKey());
if (null != cmsScript) {
map.put(cmsScript.getId(),
new RelatedScript(cmsScript.getId(), cmsScript.getName(), cmsScript.getAlias(),
cmsScriptLoad(business, cmsScript),
WorkCompletedProperties.RelatedScript.TYPE_CMS));
list.add(cmsScript.getId() + cmsScript.getUpdateTime().getTime());
}
break;
case WorkCompletedProperties.RelatedScript.TYPE_PORTAL:
com.x.portal.core.entity.Script portalScript = business.portal().script().pick(entry.getKey());
if (null != portalScript) {
map.put(portalScript.getId(),
new RelatedScript(portalScript.getId(), portalScript.getName(), portalScript.getAlias(),
portalScriptLoad(business, portalScript),
WorkCompletedProperties.RelatedScript.TYPE_PORTAL));
list.add(portalScript.getId() + portalScript.getUpdateTime().getTime());
}
break;
default:
break;
}
}
return map;
}
private String processPlatformScriptLoad(Business business, com.x.processplatform.core.entity.element.Script script)
throws Exception {
List<com.x.processplatform.core.entity.element.Script> list = new ArrayList<>();
for (com.x.processplatform.core.entity.element.Script o : business.script()
.listScriptNestedWithApplicationWithUniqueName(script.getApplication(),
script.getId())) {
list.add(o);
}
StringBuilder sb = new StringBuilder("");
List<String> imported = new ArrayList<>();
for (com.x.processplatform.core.entity.element.Script o : list) {
sb.append(o.getText());
sb.append(System.lineSeparator());
imported.add(o.getId());
if (StringUtils.isNotEmpty(o.getName())) {
imported.add(o.getName());
}
if (StringUtils.isNotEmpty(o.getAlias())) {
imported.add(o.getAlias());
}
}
return sb.toString();
}
private String cmsScriptLoad(Business business, com.x.cms.core.entity.element.Script script)
throws Exception {
List<com.x.cms.core.entity.element.Script> list = new ArrayList<>();
for (com.x.cms.core.entity.element.Script o : business.cms().script().listScriptNestedWithAppInfoWithUniqueName(
script.getAppId(),
script.getId())) {
list.add(o);
}
StringBuilder sb = new StringBuilder("");
List<String> imported = new ArrayList<>();
for (com.x.cms.core.entity.element.Script o : list) {
sb.append(o.getText());
sb.append(System.lineSeparator());
imported.add(o.getId());
if (StringUtils.isNotEmpty(o.getName())) {
imported.add(o.getName());
}
if (StringUtils.isNotEmpty(o.getAlias())) {
imported.add(o.getAlias());
}
}
return sb.toString();
}
private String portalScriptLoad(Business business, com.x.portal.core.entity.Script script)
throws Exception {
List<com.x.portal.core.entity.Script> list = new ArrayList<>();
for (com.x.portal.core.entity.Script o : business.portal().script().listScriptNestedWithPortalWithFlag(
script.getPortal(),
script.getId())) {
list.add(o);
}
StringBuilder sb = new StringBuilder("");
List<String> imported = new ArrayList<>();
for (com.x.portal.core.entity.Script o : list) {
sb.append(o.getText());
sb.append(System.lineSeparator());
imported.add(o.getId());
if (StringUtils.isNotEmpty(o.getName())) {
imported.add(o.getName());
}
if (StringUtils.isNotEmpty(o.getAlias())) {
imported.add(o.getAlias());
}
}
return sb.toString();
}
@Schema(name = "com.x.processplatform.assemble.surface.jaxrs.form.V2Get$Wo")
public static class Wo extends AbstractWo {
private static final long serialVersionUID = 2776033956637839042L;
}
}
......@@ -30,137 +30,149 @@ import com.x.processplatform.core.entity.content.WorkCompletedProperties.Related
import com.x.processplatform.core.entity.content.WorkCompletedProperties.RelatedScript;
import com.x.processplatform.core.entity.element.Form;
import com.x.processplatform.core.entity.element.FormProperties;
import com.x.processplatform.core.entity.element.Script;
import io.swagger.v3.oas.annotations.media.Schema;
class V2GetMobile extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(V2GetMobile.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, String tag) throws Exception {
LOGGER.debug("execute:{}, id:{}, tag:{}.", effectivePerson::getDistinguishedName, () -> id, () -> tag);
ActionResult<Wo> result = new ActionResult<>();
CacheKey cacheKey = new CacheKey(this.getClass(), id, tag);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) {
result.setData((Wo) optional.get());
} else {
Form form = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
form = business.form().pick(id);
}
if (null == form) {
throw new ExceptionEntityNotExist(id, Form.class);
}
Wo wo = new Wo();
final FormProperties properties = form.getProperties();
final List<String> list = new CopyOnWriteArrayList<>();
wo.setForm(new RelatedForm(form, form.getMobileDataOrData()));
CompletableFuture<Map<String, RelatedForm>> getRelatedFormFuture = this.getRelatedFormFuture(properties,
list);
CompletableFuture<Map<String, RelatedScript>> getRelatedScriptFuture = this
.getRelatedScriptFuture(properties, list);
wo.setRelatedFormMap(
getRelatedFormFuture.get(Config.processPlatform().getAsynchronousTimeout(), TimeUnit.SECONDS));
wo.setRelatedScriptMap(
getRelatedScriptFuture.get(Config.processPlatform().getAsynchronousTimeout(), TimeUnit.SECONDS));
if (StringUtils.isNotBlank(tag)) {
wo.setMaxAge(3600 * 24);
}
list.add(form.getId() + form.getUpdateTime().getTime());
List<String> sortList = list.stream().sorted().collect(Collectors.toList());
wo.setFastETag(StringUtils.join(sortList, "#"));
CacheManager.put(cacheCategory, cacheKey, wo);
result.setData(wo);
}
return result;
}
private CompletableFuture<Map<String, RelatedForm>> getRelatedFormFuture(FormProperties properties,
final List<String> list) {
return CompletableFuture.supplyAsync(() -> {
Map<String, RelatedForm> map = new TreeMap<>();
if (ListTools.isNotEmpty(properties.getMobileRelatedFormList())) {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business bus = new Business(emc);
Form f;
for (String id : properties.getMobileRelatedFormList()) {
f = bus.form().pick(id);
if (null != f) {
map.put(id, new RelatedForm(f, f.getMobileDataOrData()));
list.add(f.getId() + f.getUpdateTime().getTime());
}
}
} catch (Exception e) {
LOGGER.error(e);
}
}
return map;
}, ThisApplication.threadPool());
}
private CompletableFuture<Map<String, RelatedScript>> getRelatedScriptFuture(FormProperties properties,
final List<String> list) {
return CompletableFuture.supplyAsync(() -> {
Map<String, RelatedScript> map = new TreeMap<>();
if ((null != properties.getMobileRelatedScriptMap())
&& (properties.getMobileRelatedScriptMap().size() > 0)) {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
map = convertScript(business, properties, list);
} catch (Exception e) {
LOGGER.error(e);
}
}
return map;
}, ThisApplication.threadPool());
}
private Map<String, RelatedScript> convertScript(Business bus, FormProperties properties, final List<String> list)
throws Exception {
Map<String, RelatedScript> map = new TreeMap<>();
for (Entry<String, String> entry : properties.getMobileRelatedScriptMap().entrySet()) {
switch (entry.getValue()) {
case WorkCompletedProperties.RelatedScript.TYPE_PROCESSPLATFORM:
Script pp = bus.script().pick(entry.getKey());
if (null != pp) {
map.put(entry.getKey(),
new RelatedScript(pp.getId(), pp.getName(), pp.getAlias(), pp.getText(), entry.getValue()));
list.add(pp.getId() + pp.getUpdateTime().getTime());
}
break;
case WorkCompletedProperties.RelatedScript.TYPE_CMS:
com.x.cms.core.entity.element.Script cms = bus.cms().script().pick(entry.getKey());
if (null != cms) {
map.put(entry.getKey(), new RelatedScript(cms.getId(), cms.getName(), cms.getAlias(), cms.getText(),
entry.getValue()));
list.add(cms.getId() + cms.getUpdateTime().getTime());
}
break;
case WorkCompletedProperties.RelatedScript.TYPE_PORTAL:
com.x.portal.core.entity.Script p = bus.portal().script().pick(entry.getKey());
if (null != p) {
map.put(entry.getKey(),
new RelatedScript(p.getId(), p.getName(), p.getAlias(), p.getText(), entry.getValue()));
list.add(p.getId() + p.getUpdateTime().getTime());
}
break;
default:
break;
}
}
return map;
}
@Schema(name = "com.x.processplatform.assemble.surface.jaxrs.form.V2GetMobile$Wo")
public static class Wo extends AbstractWo {
private static final long serialVersionUID = 6413992232196084934L;
}
private static final Logger LOGGER = LoggerFactory.getLogger(V2GetMobile.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, String tag) throws Exception {
LOGGER.debug("execute:{}, id:{}, tag:{}.", effectivePerson::getDistinguishedName, () -> id, () -> tag);
ActionResult<Wo> result = new ActionResult<>();
CacheKey cacheKey = new CacheKey(this.getClass(), id, tag);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) {
result.setData((Wo) optional.get());
} else {
Form form = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
form = business.form().pick(id);
}
if (null == form) {
throw new ExceptionEntityNotExist(id, Form.class);
}
Wo wo = new Wo();
final FormProperties properties = form.getProperties();
final List<String> list = new CopyOnWriteArrayList<>();
wo.setForm(new RelatedForm(form, form.getMobileDataOrData()));
CompletableFuture<Map<String, RelatedForm>> getRelatedFormFuture = this.getRelatedFormFuture(properties,
list);
CompletableFuture<Map<String, RelatedScript>> getRelatedScriptFuture = this
.getRelatedScriptFuture(form.getApplication(), properties, list);
wo.setRelatedFormMap(
getRelatedFormFuture.get(Config.processPlatform().getAsynchronousTimeout(), TimeUnit.SECONDS));
wo.setRelatedScriptMap(
getRelatedScriptFuture.get(Config.processPlatform().getAsynchronousTimeout(), TimeUnit.SECONDS));
if (StringUtils.isNotBlank(tag)) {
wo.setMaxAge(3600 * 24);
}
list.add(form.getId() + form.getUpdateTime().getTime());
List<String> sortList = list.stream().sorted().collect(Collectors.toList());
wo.setFastETag(StringUtils.join(sortList, "#"));
CacheManager.put(cacheCategory, cacheKey, wo);
result.setData(wo);
}
return result;
}
private CompletableFuture<Map<String, RelatedForm>> getRelatedFormFuture(FormProperties properties,
final List<String> list) {
return CompletableFuture.supplyAsync(() -> {
Map<String, RelatedForm> map = new TreeMap<>();
if (ListTools.isNotEmpty(properties.getMobileRelatedFormList())) {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business bus = new Business(emc);
Form f;
for (String id : properties.getMobileRelatedFormList()) {
f = bus.form().pick(id);
if (null != f) {
map.put(id, new RelatedForm(f, f.getMobileDataOrData()));
list.add(f.getId() + f.getUpdateTime().getTime());
}
}
} catch (Exception e) {
LOGGER.error(e);
}
}
return map;
}, ThisApplication.threadPool());
}
private CompletableFuture<Map<String, RelatedScript>> getRelatedScriptFuture(String applicationId,
FormProperties properties,
final List<String> list) {
return CompletableFuture.supplyAsync(() -> {
Map<String, RelatedScript> map = new TreeMap<>();
if ((null != properties.getMobileRelatedScriptMap())
&& (properties.getMobileRelatedScriptMap().size() > 0)) {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
map = convertScript(business, applicationId, properties, list);
} catch (Exception e) {
LOGGER.error(e);
}
}
return map;
}, ThisApplication.threadPool());
}
private Map<String, RelatedScript> convertScript(Business business, String applicationId, FormProperties properties,
final List<String> list)
throws Exception {
Map<String, RelatedScript> map = new TreeMap<>();
for (Entry<String, String> entry : properties.getMobileRelatedScriptMap().entrySet()) {
switch (entry.getValue()) {
case WorkCompletedProperties.RelatedScript.TYPE_PROCESSPLATFORM:
business.script().listScriptNestedWithApplicationWithUniqueName(applicationId, entry.getKey())
.forEach(o -> {
map.put(o.getId(),
new RelatedScript(o.getId(), o.getName(), o.getAlias(), o.getText(),
WorkCompletedProperties.RelatedScript.TYPE_PROCESSPLATFORM));
list.add(o.getId() + o.getUpdateTime().getTime());
});
break;
case WorkCompletedProperties.RelatedScript.TYPE_CMS:
com.x.cms.core.entity.element.Script cmsScript = business.cms().script().pick(entry.getKey());
if (null != cmsScript) {
business.cms().script()
.listScriptNestedWithAppInfoWithUniqueName(cmsScript.getAppId(), entry.getKey())
.forEach(o -> {
map.put(o.getId(),
new RelatedScript(o.getId(), o.getName(), o.getAlias(), o.getText(),
WorkCompletedProperties.RelatedScript.TYPE_CMS));
list.add(o.getId() + o.getUpdateTime().getTime());
});
}
break;
case WorkCompletedProperties.RelatedScript.TYPE_PORTAL:
com.x.portal.core.entity.Script portalScript = business.portal().script().pick(entry.getKey());
if (null != portalScript) {
business.portal().script()
.listScriptNestedWithPortalWithFlag(portalScript.getPortal(), entry.getKey())
.forEach(o -> {
map.put(o.getId(),
new RelatedScript(o.getId(), o.getName(), o.getAlias(), o.getText(),
WorkCompletedProperties.RelatedScript.TYPE_PORTAL));
list.add(o.getId() + o.getUpdateTime().getTime());
});
}
break;
default:
break;
}
}
return map;
}
@Schema(name = "com.x.processplatform.assemble.surface.jaxrs.form.V2GetMobile$Wo")
public static class Wo extends AbstractWo {
private static final long serialVersionUID = 6413992232196084934L;
}
}
......@@ -23,110 +23,111 @@ import com.x.processplatform.core.entity.element.Script;
class ActionGetImported extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionGetImported.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag, String applicationFlag) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Wo wo = new Wo();
CacheCategory cacheCategory = new CacheCategory(Script.class);
CacheKey cacheKey = new CacheKey(this.getClass(), flag, applicationFlag);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) {
wo = (Wo) optional.get();
} else {
Business business = new Business(emc);
Application application = business.application().pick(applicationFlag);
if (null == application) {
throw new ExceptionApplicationNotExist(applicationFlag);
}
List<Script> list = new ArrayList<>();
for (Script o : business.script().listScriptNestedWithApplicationWithUniqueName(application, flag)) {
list.add(o);
}
StringBuilder sb = new StringBuilder("");
List<String> imported = new ArrayList<>();
for (Script o : list) {
sb.append(o.getText());
sb.append(System.lineSeparator());
imported.add(o.getId());
if (StringUtils.isNotEmpty(o.getName())) {
imported.add(o.getName());
}
if (StringUtils.isNotEmpty(o.getAlias())) {
imported.add(o.getAlias());
}
}
wo.setImportedList(imported);
wo.setText(sb.toString());
wo.setApplication(application.getId());
wo.setAppName(application.getName());
wo.setAppAlias(application.getAlias());
CacheManager.put(cacheCategory, cacheKey, wo);
}
result.setData(wo);
return result;
}
}
public class Wo extends GsonPropertyObject {
private static final long serialVersionUID = -7633183122160854183L;
@FieldDescribe("脚本内容")
private String text;
@FieldDescribe("应用脚本")
private List<String> importedList;
@FieldDescribe("脚本所属应用.")
private String application;
@FieldDescribe("应用名称.")
private String appName;
@FieldDescribe("应用别名.")
private String appAlias;
public List<String> getImportedList() {
return importedList;
}
public void setImportedList(List<String> importedList) {
this.importedList = importedList;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getApplication() {
return application;
}
public void setApplication(String application) {
this.application = application;
}
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public String getAppAlias() {
return appAlias;
}
public void setAppAlias(String appAlias) {
this.appAlias = appAlias;
}
}
private static Logger logger = LoggerFactory.getLogger(ActionGetImported.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag, String applicationFlag) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Wo wo = new Wo();
CacheCategory cacheCategory = new CacheCategory(Script.class);
CacheKey cacheKey = new CacheKey(this.getClass(), flag, applicationFlag);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) {
wo = (Wo) optional.get();
} else {
Business business = new Business(emc);
Application application = business.application().pick(applicationFlag);
if (null == application) {
throw new ExceptionApplicationNotExist(applicationFlag);
}
List<Script> list = new ArrayList<>();
for (Script o : business.script().listScriptNestedWithApplicationWithUniqueName(application.getId(),
flag)) {
list.add(o);
}
StringBuilder sb = new StringBuilder("");
List<String> imported = new ArrayList<>();
for (Script o : list) {
sb.append(o.getText());
sb.append(System.lineSeparator());
imported.add(o.getId());
if (StringUtils.isNotEmpty(o.getName())) {
imported.add(o.getName());
}
if (StringUtils.isNotEmpty(o.getAlias())) {
imported.add(o.getAlias());
}
}
wo.setImportedList(imported);
wo.setText(sb.toString());
wo.setApplication(application.getId());
wo.setAppName(application.getName());
wo.setAppAlias(application.getAlias());
CacheManager.put(cacheCategory, cacheKey, wo);
}
result.setData(wo);
return result;
}
}
public class Wo extends GsonPropertyObject {
private static final long serialVersionUID = -7633183122160854183L;
@FieldDescribe("脚本内容")
private String text;
@FieldDescribe("应用脚本")
private List<String> importedList;
@FieldDescribe("脚本所属应用.")
private String application;
@FieldDescribe("应用名称.")
private String appName;
@FieldDescribe("应用别名.")
private String appAlias;
public List<String> getImportedList() {
return importedList;
}
public void setImportedList(List<String> importedList) {
this.importedList = importedList;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getApplication() {
return application;
}
public void setApplication(String application) {
this.application = application;
}
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public String getAppAlias() {
return appAlias;
}
public void setAppAlias(String appAlias) {
this.appAlias = appAlias;
}
}
}
\ No newline at end of file
......@@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
......@@ -22,100 +21,99 @@ import com.x.processplatform.core.entity.element.Script;
class ActionLoad extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionLoad.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag, String applicationFlag,
JsonElement jsonElement) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
Application application = business.application().pick(applicationFlag);
if (null == application) {
throw new ExceptionApplicationNotExist(applicationFlag);
}
List<Script> list = new ArrayList<>();
for (Script o : business.script().listScriptNestedWithApplicationWithUniqueName(application, flag)) {
if ((null != wi) && (null != wi.getImportedList())
&& (!this.contains(wi.getImportedList(), o.getAlias()))
&& (!this.contains(wi.getImportedList(), o.getName()))
&& (!this.contains(wi.getImportedList(), o.getId()))) {
list.add(o);
} else {
list.add(o);
}
}
logger.debug(effectivePerson, "find {} script will import with flag:{}, application:{}, imported:{}.", "["
+ StringUtils.join(ListTools.extractProperty(list, "name", String.class, false, false), ",") + "]",
flag, applicationFlag, "[" + StringUtils.join(wi.getImportedList(), ",") + "]");
StringBuffer buffer = new StringBuffer("");
List<String> imported = new ArrayList<>();
for (Script o : list) {
buffer.append(o.getText());
buffer.append(SystemUtils.LINE_SEPARATOR);
imported.add(o.getId());
if (StringUtils.isNotEmpty(o.getName())) {
imported.add(o.getName());
}
if (StringUtils.isNotEmpty(o.getAlias())) {
imported.add(o.getAlias());
}
}
Wo wo = new Wo();
wo.setImportedList(imported);
wo.setText(buffer.toString());
result.setData(wo);
}
return result;
}
private boolean contains(List<String> list, String value) {
if (StringUtils.isEmpty(value)) {
return false;
} else {
return ListTools.contains(list, value);
}
}
public class Wi extends GsonPropertyObject {
@FieldDescribe("导入标识")
private List<String> importedList;
public List<String> getImportedList() {
return importedList;
}
public void setImportedList(List<String> importedList) {
this.importedList = importedList;
}
}
public class Wo extends GsonPropertyObject {
@FieldDescribe("脚本内容")
private String text;
@FieldDescribe("应用脚本")
private List<String> importedList;
public List<String> getImportedList() {
return importedList;
}
public void setImportedList(List<String> importedList) {
this.importedList = importedList;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
private static final Logger LOGGER = LoggerFactory.getLogger(ActionLoad.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag, String applicationFlag,
JsonElement jsonElement) throws Exception {
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
ActionResult<Wo> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
Application application = business.application().pick(applicationFlag);
if (null == application) {
throw new ExceptionApplicationNotExist(applicationFlag);
}
List<Script> list = new ArrayList<>();
for (Script o : business.script().listScriptNestedWithApplicationWithUniqueName(application.getId(),
flag)) {
if ((null != wi) && (null != wi.getImportedList())
&& (!this.contains(wi.getImportedList(), o.getAlias()))
&& (!this.contains(wi.getImportedList(), o.getName()))
&& (!this.contains(wi.getImportedList(), o.getId()))) {
list.add(o);
} else {
list.add(o);
}
}
StringBuilder sb = new StringBuilder("");
List<String> imported = new ArrayList<>();
for (Script o : list) {
sb.append(o.getText());
sb.append(System.lineSeparator());
imported.add(o.getId());
if (StringUtils.isNotEmpty(o.getName())) {
imported.add(o.getName());
}
if (StringUtils.isNotEmpty(o.getAlias())) {
imported.add(o.getAlias());
}
}
Wo wo = new Wo();
wo.setImportedList(imported);
wo.setText(sb.toString());
result.setData(wo);
}
return result;
}
private boolean contains(List<String> list, String value) {
if (StringUtils.isEmpty(value)) {
return false;
} else {
return ListTools.contains(list, value);
}
}
public class Wi extends GsonPropertyObject {
@FieldDescribe("导入标识")
private List<String> importedList;
public List<String> getImportedList() {
return importedList;
}
public void setImportedList(List<String> importedList) {
this.importedList = importedList;
}
}
public class Wo extends GsonPropertyObject {
@FieldDescribe("脚本内容")
private String text;
@FieldDescribe("应用脚本")
private List<String> importedList;
public List<String> getImportedList() {
return importedList;
}
public void setImportedList(List<String> importedList) {
this.importedList = importedList;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
}
\ No newline at end of file
{
"companyLeader": [
],
"datagrid_1": {
"data": [
{
"amountCol_1": {
"number_2": "0"
},
"countCol_1": {
"number": "0"
},
"datagrid_datagrid$Title_1": {
"textfield": "test"
},
"datagrid_datagrid$Title_2_1": {
"number_1": "0"
},
"datagrid_datagrid$Title_4": {
"textfield_2": ""
}
}
],
"total": {
"amountCol_1": "0",
"countCol_1": "0"
}
},
"departmentLeader": [
],
"explain": "",
"htmleditor": "",
"number": "0",
"number_1": "0",
"number_2": "0",
"projectMenager": [
],
"radio": "",
"riqi": "",
"select": "选项1",
"shuzi": 0.0,
"subject": "",
"tag": "",
"tagbaiwei": "",
"taggewei": "",
"tagqianwei": "",
"tagshiwei": "",
"tagwanwei": "",
"textfield": "test",
"textfield_2": ""
}
......@@ -33,6 +33,8 @@ import com.x.base.core.project.webservices.WebservicesClient;
import com.x.organization.core.express.Organization;
import com.x.processplatform.core.entity.content.Attachment;
import com.x.processplatform.core.entity.content.Data;
import com.x.processplatform.core.entity.content.DocSign;
import com.x.processplatform.core.entity.content.DocSignScrawl;
import com.x.processplatform.core.entity.content.DocumentVersion;
import com.x.processplatform.core.entity.content.Read;
import com.x.processplatform.core.entity.content.ReadCompleted;
......@@ -107,6 +109,10 @@ public class AeiObjects extends GsonPropertyObject {
// 使用用懒加载,初始为null
private List<DocumentVersion> documentVersions = null;
// 使用用懒加载,初始为null
private List<DocSignScrawl> docSignScrawls = null;
// 使用用懒加载,初始为null
private List<DocSign> docSigns = null;
// 使用用懒加载,初始为null
private List<Snap> snaps = null;
// 使用用懒加载,初始为null
private List<Record> records = null;
......@@ -173,6 +179,14 @@ public class AeiObjects extends GsonPropertyObject {
private List<DocumentVersion> updateDocumentVersions = new ArrayList<>();
private List<DocumentVersion> deleteDocumentVersions = new ArrayList<>();
private List<DocSignScrawl> createDocSignScrawls = new ArrayList<>();
private List<DocSignScrawl> updateDocSignScrawls = new ArrayList<>();
private List<DocSignScrawl> deleteDocSignScrawls = new ArrayList<>();
private List<DocSign> createDocSigns = new ArrayList<>();
private List<DocSign> updateDocSigns = new ArrayList<>();
private List<DocSign> deleteDocSigns = new ArrayList<>();
private List<Snap> createSnaps = new ArrayList<>();
private List<Snap> updateSnaps = new ArrayList<>();
private List<Snap> deleteSnaps = new ArrayList<>();
......@@ -371,6 +385,22 @@ public class AeiObjects extends GsonPropertyObject {
return this.documentVersions;
}
public List<DocSignScrawl> getDocSignScrawls() throws Exception {
if (null == this.docSignScrawls) {
this.docSignScrawls = this.business.entityManagerContainer().listEqual(DocSignScrawl.class,
DocSignScrawl.job_FIELDNAME, this.work.getJob());
}
return this.docSignScrawls;
}
public List<DocSign> getDocSigns() throws Exception {
if (null == this.docSigns) {
this.docSigns = this.business.entityManagerContainer().listEqual(DocSign.class,
DocSign.job_FIELDNAME, this.work.getJob());
}
return this.docSigns;
}
public List<Snap> getSnaps() throws Exception {
if (null == this.snaps) {
this.snaps = this.business.entityManagerContainer().listEqual(Snap.class, Snap.job_FIELDNAME,
......@@ -506,6 +536,30 @@ public class AeiObjects extends GsonPropertyObject {
return updateDocumentVersions;
}
public List<DocSignScrawl> getCreateDocSignScrawls() {
return createDocSignScrawls;
}
public List<DocSignScrawl> getDeleteDocSignScrawls() {
return deleteDocSignScrawls;
}
public List<DocSignScrawl> getUpdateDocSignScrawls() {
return updateDocSignScrawls;
}
public List<DocSign> getCreateDocSigns() {
return createDocSigns;
}
public List<DocSign> getDeleteDocSigns() {
return deleteDocSigns;
}
public List<DocSign> getUpdateDocSigns() {
return updateDocSigns;
}
public List<Snap> getCreateSnaps() {
return createSnaps;
}
......@@ -604,6 +658,8 @@ public class AeiObjects extends GsonPropertyObject {
/* review必须在task,taskCompleted,read,readCompleted之后提交,需要创建新的review */
this.commitReview();
this.commitDocumentVersion();
this.commitDocSign();
this.commitDocSignScrawl();
this.commitSnap();
this.commitRecord();
this.commitAttachment();
......@@ -1269,6 +1325,76 @@ public class AeiObjects extends GsonPropertyObject {
}
}
private void commitDocSignScrawl() throws Exception {
if (ListTools.isNotEmpty(this.getCreateDocSignScrawls())
|| ListTools.isNotEmpty(this.getDeleteDocSignScrawls())
|| ListTools.isNotEmpty(this.getUpdateDocSignScrawls())) {
this.entityManagerContainer().beginTransaction(DocSignScrawl.class);
// 保存签批涂鸦信息
this.getCreateDocSignScrawls().stream().forEach(o -> {
try {
this.business.entityManagerContainer().persist(o, CheckPersistType.all);
} catch (Exception e) {
LOGGER.error(e);
}
});
// 更新签批涂鸦信息
this.getUpdateDocSignScrawls().stream().forEach(o -> {
try {
this.business.entityManagerContainer().check(o, CheckPersistType.all);
} catch (Exception e) {
LOGGER.error(e);
}
});
// 删除签批涂鸦信息
this.getDeleteDocSignScrawls().stream().forEach(o -> {
try {
DocSignScrawl obj = this.business.entityManagerContainer().find(o.getId(), DocSignScrawl.class);
if (null != obj) {
this.business.entityManagerContainer().remove(obj, CheckRemoveType.all);
}
} catch (Exception e) {
LOGGER.error(e);
}
});
}
}
private void commitDocSign() throws Exception {
if (ListTools.isNotEmpty(this.getCreateDocSigns())
|| ListTools.isNotEmpty(this.getDeleteDocSigns())
|| ListTools.isNotEmpty(this.getUpdateDocSigns())) {
this.entityManagerContainer().beginTransaction(DocSign.class);
// 保存手写签批
this.getCreateDocSigns().stream().forEach(o -> {
try {
this.business.entityManagerContainer().persist(o, CheckPersistType.all);
} catch (Exception e) {
LOGGER.error(e);
}
});
// 更新手写签批
this.getUpdateDocSigns().stream().forEach(o -> {
try {
this.business.entityManagerContainer().check(o, CheckPersistType.all);
} catch (Exception e) {
LOGGER.error(e);
}
});
// 删除手写签批
this.getDeleteDocSigns().stream().forEach(o -> {
try {
DocSign obj = this.business.entityManagerContainer().find(o.getId(), DocSign.class);
if (null != obj) {
this.business.entityManagerContainer().remove(obj, CheckRemoveType.all);
}
} catch (Exception e) {
LOGGER.error(e);
}
});
}
}
private void commitSnap() throws Exception {
if (ListTools.isNotEmpty(this.getCreateSnaps()) || ListTools.isNotEmpty(this.getDeleteSnaps())
|| ListTools.isNotEmpty(this.getUpdateSnaps())) {
......
......@@ -30,139 +30,140 @@ import com.x.processplatform.service.processing.processor.AeiObjects;
public class CancelProcessor extends AbstractCancelProcessor {
private static final Logger LOGGER = LoggerFactory.getLogger(CancelProcessor.class);
public CancelProcessor(EntityManagerContainer entityManagerContainer) throws Exception {
super(entityManagerContainer);
}
@Override
protected Work arriving(AeiObjects aeiObjects, Cancel cancel) throws Exception {
// 发送ProcessingSignal
aeiObjects.getProcessingAttributes().push(Signal.cancelArrive(aeiObjects.getWork().getActivityToken(), cancel));
return aeiObjects.getWork();
}
@Override
protected void arrivingCommitted(AeiObjects aeiObjects, Cancel cancel) throws Exception {
// nothing
}
@Override
public List<Work> executing(AeiObjects aeiObjects, Cancel cancel) throws Exception {
// 发送ProcessingSignal
aeiObjects.getProcessingAttributes()
.push(Signal.cancelExecute(aeiObjects.getWork().getActivityToken(), cancel));
// 唯一work处理
if (aeiObjects.getWorks().size() > 1) {
aeiObjects.getDeleteWorks().add(aeiObjects.getWork());
aeiObjects.getTasks().stream().filter(o -> StringUtils.equals(o.getWork(), aeiObjects.getWork().getId()))
.forEach(o -> aeiObjects.getDeleteTasks().add(o));
} else {
aeiObjects.getTasks().stream().forEach(o -> aeiObjects.getDeleteTasks().add(o));
aeiObjects.getTaskCompleteds().stream().forEach(o -> aeiObjects.getDeleteTaskCompleteds().add(o));
aeiObjects.getReads().stream().forEach(o -> aeiObjects.getDeleteReads().add(o));
aeiObjects.getReadCompleteds().stream().forEach(o -> aeiObjects.getDeleteReadCompleteds().add(o));
aeiObjects.getReviews().stream().forEach(o -> aeiObjects.getDeleteReviews().add(o));
aeiObjects.getWorkLogs().stream().forEach(o -> aeiObjects.getDeleteWorkLogs().add(o));
aeiObjects.getDocumentVersions().stream().forEach(o -> aeiObjects.getDeleteDocumentVersions().add(o));
aeiObjects.getRecords().stream().forEach(o -> aeiObjects.getDeleteRecords().add(o));
aeiObjects.getWorkLogs().stream().forEach(o -> aeiObjects.getDeleteWorkLogs().add(o));
// 附件删除单独处理,需要删除Attachment的二进制文件
aeiObjects.getAttachments().stream().forEach(o -> aeiObjects.getDeleteAttachments().add(o));
// 如果只有一份数据,没有拆分,那么删除Data
aeiObjects.getWorkDataHelper().remove();
aeiObjects.getWorks().stream().forEach(o -> aeiObjects.getDeleteWorks().add(o));
// cancel 可以不删除快照
}
return new ArrayList<>();
}
@Override
protected void executingCommitted(AeiObjects aeiObjects, Cancel cancel, List<Work> works) throws Exception {
// 删除后再次检查,如果存在多个副本,且都已经在End状态,那么试图推动一个
if (!aeiObjects.getWorks().isEmpty()) {
Predicate<Work> p = o -> Objects.equals(ActivityType.end, o.getActivityType());
if (aeiObjects.getWorks().stream().allMatch(p)) {
touchWork(aeiObjects.getWorks().get(0).getId());
}
}
tryUpdateParentWork(aeiObjects);
}
private void tryUpdateParentWork(AeiObjects aeiObjects) {
if (StringUtils.isNotBlank(aeiObjects.getWork().getProperties().getParentWork())) {
try {
Work parent = aeiObjects.entityManagerContainer()
.find(aeiObjects.getWork().getProperties().getParentWork(), Work.class);
if ((null != parent) && Objects.equals(parent.getActivityType(), ActivityType.embed)) {
Embed embed = (Embed) aeiObjects.business().element().get(parent.getActivity(),
parent.getActivityType());
if ((null != embed) && BooleanUtils.isTrue(embed.getWaitUntilCompleted())) {
updateParentWork(aeiObjects, parent, embed);
}
}
} catch (Exception e) {
LOGGER.error(new ExceptionUpdateParentWork(e, aeiObjects.getWork().getId(),
aeiObjects.getWork().getProperties().getParentWork()));
}
}
}
private void updateParentWork(AeiObjects aeiObjects, Work parent, Embed embed) throws Exception {
// 先把状态值注入,这样脚本执行时可以取得到值.
parent.setEmbedCompleted(ActivityType.cancel.toString());
AeiObjects embedAeiObjects = new AeiObjects(aeiObjects.business(), parent, embed,
aeiObjects.getProcessingConfigurator(), aeiObjects.getProcessingAttributes());
embedAeiObjects.entityManagerContainer().beginTransaction(Work.class);
if (this.hasEmbedCompletedScript(embed) || this.hasEmbedCompletedCancelScript(embed)) {
ScriptContext scriptContext = embedAeiObjects.scriptContext();
Bindings bindings = scriptContext.getBindings(ScriptContext.ENGINE_SCOPE);
bindings.put(ScriptingFactory.BINDING_NAME_EMBEDDATA, aeiObjects.getData());
if (this.hasEmbedCompletedScript(embed)) {
CompiledScript cs = aeiObjects.business().element()
.getCompiledScript(aeiObjects.getWork().getApplication(), embed, Business.EVENT_EMBEDCOMPLETED);
JsonScriptingExecutor.eval(cs, scriptContext);
}
if (this.hasEmbedCompletedCancelScript(embed)) {
CompiledScript cs = aeiObjects.business().element().getCompiledScript(
aeiObjects.getWork().getApplication(), embed, Business.EVENT_EMBEDCOMPLETEDCANCEL);
JsonScriptingExecutor.eval(cs, scriptContext);
}
}
embedAeiObjects.commit();
touchWork(parent.getId());
}
/**
* 触发在等待状态的父文档
*
* @param parentWorkId
*/
private void touchWork(String workId) {
new Thread(CancelProcessor.class.getName() + "_touchWork") {
@Override
public void run() {
try {
new Processing(new ProcessingAttributes()).processing(workId);
} catch (Exception e) {
LOGGER.error(e);
}
}
}.start();
}
@Override
protected List<Route> inquiring(AeiObjects aeiObjects, Cancel cancel) throws Exception {
// 发送ProcessingSignal
aeiObjects.getProcessingAttributes()
.push(Signal.cancelInquire(aeiObjects.getWork().getActivityToken(), cancel));
return new ArrayList<>();
}
@Override
protected void inquiringCommitted(AeiObjects aeiObjects, Cancel cancel) throws Exception {
// nothing
}
private static final Logger LOGGER = LoggerFactory.getLogger(CancelProcessor.class);
public CancelProcessor(EntityManagerContainer entityManagerContainer) throws Exception {
super(entityManagerContainer);
}
@Override
protected Work arriving(AeiObjects aeiObjects, Cancel cancel) throws Exception {
// 发送ProcessingSignal
aeiObjects.getProcessingAttributes().push(Signal.cancelArrive(aeiObjects.getWork().getActivityToken(), cancel));
return aeiObjects.getWork();
}
@Override
protected void arrivingCommitted(AeiObjects aeiObjects, Cancel cancel) throws Exception {
// nothing
}
@Override
public List<Work> executing(AeiObjects aeiObjects, Cancel cancel) throws Exception {
// 发送ProcessingSignal
aeiObjects.getProcessingAttributes()
.push(Signal.cancelExecute(aeiObjects.getWork().getActivityToken(), cancel));
// 唯一work处理
if (aeiObjects.getWorks().size() > 1) {
aeiObjects.getDeleteWorks().add(aeiObjects.getWork());
aeiObjects.getTasks().stream().filter(o -> StringUtils.equals(o.getWork(), aeiObjects.getWork().getId()))
.forEach(o -> aeiObjects.getDeleteTasks().add(o));
} else {
aeiObjects.getTasks().stream().forEach(o -> aeiObjects.getDeleteTasks().add(o));
aeiObjects.getTaskCompleteds().stream().forEach(o -> aeiObjects.getDeleteTaskCompleteds().add(o));
aeiObjects.getReads().stream().forEach(o -> aeiObjects.getDeleteReads().add(o));
aeiObjects.getReadCompleteds().stream().forEach(o -> aeiObjects.getDeleteReadCompleteds().add(o));
aeiObjects.getReviews().stream().forEach(o -> aeiObjects.getDeleteReviews().add(o));
aeiObjects.getDocumentVersions().stream().forEach(o -> aeiObjects.getDeleteDocumentVersions().add(o));
aeiObjects.getDocSignScrawls().stream().forEach(o -> aeiObjects.getDeleteDocSignScrawls().add(o));
aeiObjects.getDocSigns().stream().forEach(o -> aeiObjects.getDeleteDocSigns().add(o));
aeiObjects.getRecords().stream().forEach(o -> aeiObjects.getDeleteRecords().add(o));
aeiObjects.getWorkLogs().stream().forEach(o -> aeiObjects.getDeleteWorkLogs().add(o));
// 附件删除单独处理,需要删除Attachment的二进制文件
aeiObjects.getAttachments().stream().forEach(o -> aeiObjects.getDeleteAttachments().add(o));
// 如果只有一份数据,没有拆分,那么删除Data
aeiObjects.getWorkDataHelper().remove();
aeiObjects.getWorks().stream().forEach(o -> aeiObjects.getDeleteWorks().add(o));
// cancel 可以不删除快照
}
return new ArrayList<>();
}
@Override
protected void executingCommitted(AeiObjects aeiObjects, Cancel cancel, List<Work> works) throws Exception {
// 删除后再次检查,如果存在多个副本,且都已经在End状态,那么试图推动一个
if (!aeiObjects.getWorks().isEmpty()) {
Predicate<Work> p = o -> Objects.equals(ActivityType.end, o.getActivityType());
if (aeiObjects.getWorks().stream().allMatch(p)) {
touchWork(aeiObjects.getWorks().get(0).getId());
}
}
tryUpdateParentWork(aeiObjects);
}
private void tryUpdateParentWork(AeiObjects aeiObjects) {
if (StringUtils.isNotBlank(aeiObjects.getWork().getProperties().getParentWork())) {
try {
Work parent = aeiObjects.entityManagerContainer()
.find(aeiObjects.getWork().getProperties().getParentWork(), Work.class);
if ((null != parent) && Objects.equals(parent.getActivityType(), ActivityType.embed)) {
Embed embed = (Embed) aeiObjects.business().element().get(parent.getActivity(),
parent.getActivityType());
if ((null != embed) && BooleanUtils.isTrue(embed.getWaitUntilCompleted())) {
updateParentWork(aeiObjects, parent, embed);
}
}
} catch (Exception e) {
LOGGER.error(new ExceptionUpdateParentWork(e, aeiObjects.getWork().getId(),
aeiObjects.getWork().getProperties().getParentWork()));
}
}
}
private void updateParentWork(AeiObjects aeiObjects, Work parent, Embed embed) throws Exception {
// 先把状态值注入,这样脚本执行时可以取得到值.
parent.setEmbedCompleted(ActivityType.cancel.toString());
AeiObjects embedAeiObjects = new AeiObjects(aeiObjects.business(), parent, embed,
aeiObjects.getProcessingConfigurator(), aeiObjects.getProcessingAttributes());
embedAeiObjects.entityManagerContainer().beginTransaction(Work.class);
if (this.hasEmbedCompletedScript(embed) || this.hasEmbedCompletedCancelScript(embed)) {
ScriptContext scriptContext = embedAeiObjects.scriptContext();
Bindings bindings = scriptContext.getBindings(ScriptContext.ENGINE_SCOPE);
bindings.put(ScriptingFactory.BINDING_NAME_EMBEDDATA, aeiObjects.getData());
if (this.hasEmbedCompletedScript(embed)) {
CompiledScript cs = aeiObjects.business().element()
.getCompiledScript(aeiObjects.getWork().getApplication(), embed, Business.EVENT_EMBEDCOMPLETED);
JsonScriptingExecutor.eval(cs, scriptContext);
}
if (this.hasEmbedCompletedCancelScript(embed)) {
CompiledScript cs = aeiObjects.business().element().getCompiledScript(
aeiObjects.getWork().getApplication(), embed, Business.EVENT_EMBEDCOMPLETEDCANCEL);
JsonScriptingExecutor.eval(cs, scriptContext);
}
}
embedAeiObjects.commit();
touchWork(parent.getId());
}
/**
* 触发在等待状态的父文档
*
* @param parentWorkId
*/
private void touchWork(String workId) {
new Thread(CancelProcessor.class.getName() + "_touchWork") {
@Override
public void run() {
try {
new Processing(new ProcessingAttributes()).processing(workId);
} catch (Exception e) {
LOGGER.error(e);
}
}
}.start();
}
@Override
protected List<Route> inquiring(AeiObjects aeiObjects, Cancel cancel) throws Exception {
// 发送ProcessingSignal
aeiObjects.getProcessingAttributes()
.push(Signal.cancelInquire(aeiObjects.getWork().getActivityToken(), cancel));
return new ArrayList<>();
}
@Override
protected void inquiringCommitted(AeiObjects aeiObjects, Cancel cancel) throws Exception {
// nothing
}
}
\ No newline at end of file
......@@ -32,7 +32,6 @@ import com.x.processplatform.core.entity.element.FormField;
import com.x.processplatform.core.entity.element.Invoke;
import com.x.processplatform.core.entity.element.Process;
import com.x.program.center.core.entity.Agent;
import com.x.query.core.entity.Reveal;
import com.x.query.core.entity.Stat;
import com.x.query.core.entity.View;
import com.x.query.core.entity.schema.Statement;
......@@ -40,115 +39,113 @@ import com.x.query.core.entity.schema.Table;
class ActionClearCache extends BaseAction {
ActionResult<Wo> execute(HttpServletRequest request, String source) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
Wo wo = new Wo();
wo.setValue(false);
if(StringUtils.isEmpty(source)){
wo.setValue(false);
}else if("all".equalsIgnoreCase(source)){
//cms
CacheManager.notify(CategoryInfo.class);
CacheManager.notify(AppDictItem.class);
CacheManager.notify(AppDict.class);
CacheManager.notify(Form.class);
CacheManager.notify(Script.class);
CacheManager.notify(AppInfo.class);
//portal
CacheManager.notify(com.x.portal.core.entity.Script.class);
CacheManager.notify(Page.class);
CacheManager.notify(Widget.class);
CacheManager.notify(Portal.class);
//query
CacheManager.notify(Reveal.class);
CacheManager.notify(Stat.class);
CacheManager.notify(View.class);
CacheManager.notify(Table.class);
CacheManager.notify(Statement.class);
//process
CacheManager.notify(ApplicationDictItem.class);
CacheManager.notify(ApplicationDict.class);
CacheManager.notify(FormField.class);
CacheManager.notify(com.x.processplatform.core.entity.element.Form.class);
CacheManager.notify(com.x.processplatform.core.entity.element.Script.class);
CacheManager.notify(Process.class);
CacheManager.notify(Application.class);
//agent
CacheManager.notify(Agent.class);
//invoke
CacheManager.notify(Invoke.class);
//org
CacheManager.notify(Identity.class);
CacheManager.notify(Unit.class);
CacheManager.notify(UnitAttribute.class);
CacheManager.notify(UnitDuty.class);
CacheManager.notify(Role.class);
CacheManager.notify(Person.class);
CacheManager.notify(PersonAttribute.class);
CacheManager.notify(Group.class);
CacheManager.notify(Empower.class);
wo.setValue(true);
}else if("cms".equalsIgnoreCase(source)){
CacheManager.notify(CategoryInfo.class);
CacheManager.notify(AppDictItem.class);
CacheManager.notify(AppDict.class);
CacheManager.notify(Form.class);
CacheManager.notify(Script.class);
CacheManager.notify(AppInfo.class);
ActionResult<Wo> execute(HttpServletRequest request, String source) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
Wo wo = new Wo();
wo.setValue(false);
if (StringUtils.isEmpty(source)) {
wo.setValue(false);
} else if ("all".equalsIgnoreCase(source)) {
// cms
CacheManager.notify(CategoryInfo.class);
CacheManager.notify(AppDictItem.class);
CacheManager.notify(AppDict.class);
CacheManager.notify(Form.class);
CacheManager.notify(Script.class);
CacheManager.notify(AppInfo.class);
// portal
CacheManager.notify(com.x.portal.core.entity.Script.class);
CacheManager.notify(Page.class);
CacheManager.notify(Widget.class);
CacheManager.notify(Portal.class);
// query
CacheManager.notify(Stat.class);
CacheManager.notify(View.class);
CacheManager.notify(Table.class);
CacheManager.notify(Statement.class);
// process
CacheManager.notify(ApplicationDictItem.class);
CacheManager.notify(ApplicationDict.class);
CacheManager.notify(FormField.class);
CacheManager.notify(com.x.processplatform.core.entity.element.Form.class);
CacheManager.notify(com.x.processplatform.core.entity.element.Script.class);
CacheManager.notify(Process.class);
CacheManager.notify(Application.class);
// agent
CacheManager.notify(Agent.class);
// invoke
CacheManager.notify(Invoke.class);
// org
CacheManager.notify(Identity.class);
CacheManager.notify(Unit.class);
CacheManager.notify(UnitAttribute.class);
CacheManager.notify(UnitDuty.class);
CacheManager.notify(Role.class);
CacheManager.notify(Person.class);
CacheManager.notify(PersonAttribute.class);
CacheManager.notify(Group.class);
CacheManager.notify(Empower.class);
wo.setValue(true);
} else if ("cms".equalsIgnoreCase(source)) {
CacheManager.notify(CategoryInfo.class);
CacheManager.notify(AppDictItem.class);
CacheManager.notify(AppDict.class);
CacheManager.notify(Form.class);
CacheManager.notify(Script.class);
CacheManager.notify(AppInfo.class);
wo.setValue(true);
}else if("portal".equalsIgnoreCase(source)){
CacheManager.notify(com.x.portal.core.entity.Script.class);
CacheManager.notify(Page.class);
CacheManager.notify(Widget.class);
CacheManager.notify(Portal.class);
wo.setValue(true);
} else if ("portal".equalsIgnoreCase(source)) {
CacheManager.notify(com.x.portal.core.entity.Script.class);
CacheManager.notify(Page.class);
CacheManager.notify(Widget.class);
CacheManager.notify(Portal.class);
wo.setValue(true);
}else if("query".equalsIgnoreCase(source)){
CacheManager.notify(Reveal.class);
CacheManager.notify(Stat.class);
CacheManager.notify(View.class);
CacheManager.notify(Table.class);
CacheManager.notify(Statement.class);
wo.setValue(true);
} else if ("query".equalsIgnoreCase(source)) {
CacheManager.notify(Stat.class);
CacheManager.notify(View.class);
CacheManager.notify(Table.class);
CacheManager.notify(Statement.class);
wo.setValue(true);
}else if("process".equalsIgnoreCase(source)){
CacheManager.notify(ApplicationDictItem.class);
CacheManager.notify(ApplicationDict.class);
CacheManager.notify(FormField.class);
CacheManager.notify(com.x.processplatform.core.entity.element.Form.class);
CacheManager.notify(com.x.processplatform.core.entity.element.Script.class);
CacheManager.notify(Process.class);
CacheManager.notify(Application.class);
wo.setValue(true);
} else if ("process".equalsIgnoreCase(source)) {
CacheManager.notify(ApplicationDictItem.class);
CacheManager.notify(ApplicationDict.class);
CacheManager.notify(FormField.class);
CacheManager.notify(com.x.processplatform.core.entity.element.Form.class);
CacheManager.notify(com.x.processplatform.core.entity.element.Script.class);
CacheManager.notify(Process.class);
CacheManager.notify(Application.class);
wo.setValue(true);
}else if("agent".equalsIgnoreCase(source)){
CacheManager.notify(Agent.class);
wo.setValue(true);
} else if ("agent".equalsIgnoreCase(source)) {
CacheManager.notify(Agent.class);
wo.setValue(true);
}else if("invoke".equalsIgnoreCase(source)){
CacheManager.notify(Invoke.class);
wo.setValue(true);
} else if ("invoke".equalsIgnoreCase(source)) {
CacheManager.notify(Invoke.class);
wo.setValue(true);
}else if("org".equalsIgnoreCase(source)){
CacheManager.notify(Identity.class);
CacheManager.notify(Unit.class);
CacheManager.notify(UnitAttribute.class);
CacheManager.notify(UnitDuty.class);
CacheManager.notify(Role.class);
CacheManager.notify(Person.class);
CacheManager.notify(PersonAttribute.class);
CacheManager.notify(Group.class);
CacheManager.notify(Empower.class);
wo.setValue(true);
} else if ("org".equalsIgnoreCase(source)) {
CacheManager.notify(Identity.class);
CacheManager.notify(Unit.class);
CacheManager.notify(UnitAttribute.class);
CacheManager.notify(UnitDuty.class);
CacheManager.notify(Role.class);
CacheManager.notify(Person.class);
CacheManager.notify(PersonAttribute.class);
CacheManager.notify(Group.class);
CacheManager.notify(Empower.class);
wo.setValue(true);
}
result.setData(wo);
return result;
}
wo.setValue(true);
}
result.setData(wo);
return result;
}
public static class Wo extends WrapBoolean {
public static class Wo extends WrapBoolean {
}
}
}
\ No newline at end of file
......@@ -7,6 +7,6 @@ class ExceptionDetailOrg extends LanguagePromptException {
private static final long serialVersionUID = 4132300948670472899L;
ExceptionDetailOrg(Integer retCode, String retMessage) {
super("政务钉钉获取组织信息失败,错误代码:{},错误消息:{}.", retCode, retMessage);
super("获取组织信息失败,错误代码:{},错误消息:{}.", retCode, retMessage);
}
}
......@@ -7,6 +7,6 @@ class ExceptionDetailUser extends LanguagePromptException {
private static final long serialVersionUID = 4132300948670472899L;
ExceptionDetailUser(Integer retCode, String retMessage) {
super("政务钉钉获取人员信息失败,错误代码:{},错误消息:{}.", retCode, retMessage);
super("获取人员信息失败,错误代码:{},错误消息:{}.", retCode, retMessage);
}
}
......@@ -7,6 +7,6 @@ class ExceptionListOrg extends LanguagePromptException {
private static final long serialVersionUID = 4132300948670472899L;
ExceptionListOrg(Integer retCode, String retMessage) {
super("政务钉钉获取下级组织失败,错误代码:{},错误消息:{}.", retCode, retMessage);
super("获取下级组织失败,错误代码:{},错误消息:{}.", retCode, retMessage);
}
}
......@@ -7,6 +7,6 @@ class ExceptionListUser extends LanguagePromptException {
private static final long serialVersionUID = 4132300948670472899L;
ExceptionListUser(Integer retCode, String retMessage) {
super("政务钉钉获取组织成员失败,错误代码:{},错误消息:{}.", retCode, retMessage);
super("获取组织成员失败,错误代码:{},错误消息:{}.", retCode, retMessage);
}
}
......@@ -48,7 +48,6 @@ import com.x.organization.core.express.Organization;
import com.x.query.assemble.designer.factory.ImportModelFactory;
import com.x.query.assemble.designer.factory.ProcessFactory;
import com.x.query.assemble.designer.factory.QueryFactory;
import com.x.query.assemble.designer.factory.RevealFactory;
import com.x.query.assemble.designer.factory.StatFactory;
import com.x.query.assemble.designer.factory.StatementFactory;
import com.x.query.assemble.designer.factory.TableFactory;
......@@ -170,15 +169,6 @@ public class Business {
return stat;
}
private RevealFactory reveal;
public RevealFactory reveal() throws Exception {
if (null == this.reveal) {
this.reveal = new RevealFactory(this);
}
return reveal;
}
private ProcessFactory process;
public ProcessFactory process() throws Exception {
......
package com.x.query.assemble.designer.factory;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.tools.StringTools;
import com.x.query.assemble.designer.AbstractFactory;
import com.x.query.assemble.designer.Business;
import com.x.query.core.entity.Reveal;
import com.x.query.core.entity.Reveal_;
public class RevealFactory extends AbstractFactory {
public RevealFactory(Business business) throws Exception {
super(business);
}
public <T extends Reveal> List<T> sort(List<T> list) {
if (null == list) {
return null;
}
list = list.stream()
.sorted(Comparator.comparing(Reveal::getAlias, StringTools.emptyLastComparator())
.thenComparing(Comparator.comparing(Reveal::getName, StringTools.emptyLastComparator())))
.collect(Collectors.toList());
return list;
}
public List<String> listWithQuery(String queryId) throws Exception {
EntityManager em = this.entityManagerContainer().get(Reveal.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Reveal> root = cq.from(Reveal.class);
Predicate p = cb.equal(root.get(Reveal_.query), queryId);
cq.select(root.get(Reveal_.id)).where(p);
List<String> os = em.createQuery(cq).getResultList();
return os;
}
public List<Reveal> listWithQueryObject(String queryId) throws Exception {
EntityManager em = this.entityManagerContainer().get(Reveal.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Reveal> cq = cb.createQuery(Reveal.class);
Root<Reveal> root = cq.from(Reveal.class);
Predicate p = cb.equal(root.get(Reveal_.query), queryId);
cq.select(root).where(p);
List<Reveal> os = em.createQuery(cq).getResultList();
return os;
}
}
\ No newline at end of file
......@@ -12,7 +12,6 @@ import com.x.query.assemble.designer.jaxrs.input.InputAction;
import com.x.query.assemble.designer.jaxrs.neural.NeuralAction;
import com.x.query.assemble.designer.jaxrs.output.OutputAction;
import com.x.query.assemble.designer.jaxrs.query.QueryAction;
import com.x.query.assemble.designer.jaxrs.reveal.RevealAction;
import com.x.query.assemble.designer.jaxrs.stat.StatAction;
import com.x.query.assemble.designer.jaxrs.statement.StatementAction;
import com.x.query.assemble.designer.jaxrs.table.TableAction;
......@@ -25,7 +24,6 @@ public class ActionApplication extends AbstractActionApplication {
classes.add(QueryAction.class);
classes.add(ViewAction.class);
classes.add(StatAction.class);
classes.add(RevealAction.class);
classes.add(IdAction.class);
classes.add(NeuralAction.class);
classes.add(OutputAction.class);
......
package com.x.query.assemble.designer.jaxrs;
import javax.servlet.annotation.WebFilter;
import com.x.base.core.project.jaxrs.AnonymousCipherManagerUserJaxrsFilter;
@WebFilter(urlPatterns = "/jaxrs/reveal/*", asyncSupported = true)
public class RevealJaxrsFilter extends AnonymousCipherManagerUserJaxrsFilter {
}
......@@ -26,14 +26,12 @@ import com.x.base.core.project.tools.ListTools;
import com.x.query.assemble.designer.Business;
import com.x.query.core.entity.ImportModel;
import com.x.query.core.entity.Query;
import com.x.query.core.entity.Reveal;
import com.x.query.core.entity.Stat;
import com.x.query.core.entity.View;
import com.x.query.core.entity.schema.Statement;
import com.x.query.core.entity.schema.Table;
import com.x.query.core.entity.wrap.WrapImportModel;
import com.x.query.core.entity.wrap.WrapQuery;
import com.x.query.core.entity.wrap.WrapReveal;
import com.x.query.core.entity.wrap.WrapStat;
import com.x.query.core.entity.wrap.WrapStatement;
import com.x.query.core.entity.wrap.WrapTable;
......@@ -90,19 +88,6 @@ class ActionPrepareCover extends BaseAction {
}
}
}
for (MatchElement<WrapReveal, Reveal> m : this.match(business, wi.getRevealList(),
ListUtils.union(this.listWithIds(business, wi.getRevealList(), Reveal.class),
business.reveal().listWithQueryObject(exist.getId())))) {
if ((null != m.getW()) && (null != m.getT())) {
if (!StringUtils.equals(m.getW().getId(), m.getT().getId())) {
if (StringUtils.equals(m.getW().getQuery(), m.getT().getQuery())) {
wos.add(new Wo(m.getW().getId(), m.getT().getId()));
} else {
wos.add(new Wo(m.getW().getId(), JpaObject.createId()));
}
}
}
}
for (MatchElement<WrapTable, Table> m : this.match(business, wi.getTableList(),
ListUtils.union(this.listWithIds(business, wi.getTableList(), Table.class),
business.table().listWithQueryObject(exist.getId())))) {
......
package com.x.query.assemble.surface.jaxrs;
import javax.servlet.annotation.WebFilter;
import com.x.base.core.project.jaxrs.CipherManagerUserJaxrsFilter;
@WebFilter(urlPatterns = "/jaxrs/reveal/*", asyncSupported = true)
public class RevealJaxrsFilter extends CipherManagerUserJaxrsFilter {
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册