|
@@ -155,8 +155,7 @@ public class ProcessFactory extends ElementFactory {
|
|
|
CriteriaQuery<String> cq = cb.createQuery(String.class);
|
|
CriteriaQuery<String> cq = cb.createQuery(String.class);
|
|
|
Root<Process> root = cq.from(Process.class);
|
|
Root<Process> root = cq.from(Process.class);
|
|
|
Predicate p = cb.equal(root.get(Process_.application), application.getId());
|
|
Predicate p = cb.equal(root.get(Process_.application), application.getId());
|
|
|
- p = cb.and(p, cb.or(cb.isTrue(root.get(Process_.editionEnable)),
|
|
|
|
|
- cb.isNull(root.get(Process_.editionEnable))));
|
|
|
|
|
|
|
+ p = cb.and(p, cb.or(cb.isTrue(root.get(Process_.editionEnable)), cb.isNull(root.get(Process_.editionEnable))));
|
|
|
cq.select(root.get(Process_.id)).where(p).distinct(true);
|
|
cq.select(root.get(Process_.id)).where(p).distinct(true);
|
|
|
list = em.createQuery(cq).getResultList();
|
|
list = em.createQuery(cq).getResultList();
|
|
|
return list;
|
|
return list;
|
|
@@ -165,7 +164,6 @@ public class ProcessFactory extends ElementFactory {
|
|
|
/* 获取用户可启动的流程,如果applicationId 为空则取到所有可启动流程 */
|
|
/* 获取用户可启动的流程,如果applicationId 为空则取到所有可启动流程 */
|
|
|
public List<String> listStartableWithApplication(EffectivePerson effectivePerson, List<String> identities,
|
|
public List<String> listStartableWithApplication(EffectivePerson effectivePerson, List<String> identities,
|
|
|
List<String> units, Application application) throws Exception {
|
|
List<String> units, Application application) throws Exception {
|
|
|
- List<String> list = new ArrayList<>();
|
|
|
|
|
EntityManager em = this.entityManagerContainer().get(Process.class);
|
|
EntityManager em = this.entityManagerContainer().get(Process.class);
|
|
|
CriteriaBuilder cb = em.getCriteriaBuilder();
|
|
CriteriaBuilder cb = em.getCriteriaBuilder();
|
|
|
CriteriaQuery<String> cq = cb.createQuery(String.class);
|
|
CriteriaQuery<String> cq = cb.createQuery(String.class);
|
|
@@ -184,11 +182,38 @@ public class ProcessFactory extends ElementFactory {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
p = cb.and(p, cb.equal(root.get(Process_.application), application.getId()));
|
|
p = cb.and(p, cb.equal(root.get(Process_.application), application.getId()));
|
|
|
- p = cb.and(p, cb.or(cb.isTrue(root.get(Process_.editionEnable)),
|
|
|
|
|
- cb.isNull(root.get(Process_.editionEnable))));
|
|
|
|
|
|
|
+ p = cb.and(p, cb.or(cb.isTrue(root.get(Process_.editionEnable)), cb.isNull(root.get(Process_.editionEnable))));
|
|
|
cq.select(root.get(Process_.id)).where(p).distinct(true);
|
|
cq.select(root.get(Process_.id)).where(p).distinct(true);
|
|
|
- list = em.createQuery(cq).getResultList();
|
|
|
|
|
- return list;
|
|
|
|
|
|
|
+ return em.createQuery(cq).getResultList();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* 获取用户可启动的流程,如果applicationId 为空则取到所有可启动流程 */
|
|
|
|
|
+ public List<String> listStartableWithApplicationTerminalMobile(EffectivePerson effectivePerson,
|
|
|
|
|
+ List<String> identities, List<String> units, Application application) throws Exception {
|
|
|
|
|
+ EntityManager em = this.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() && (!this.business().organization().person().hasRole(effectivePerson,
|
|
|
|
|
+ OrganizationDefinition.Manager, OrganizationDefinition.ProcessPlatformManager))) {
|
|
|
|
|
+ p = cb.and(cb.isEmpty(root.get(Process_.startableIdentityList)),
|
|
|
|
|
+ cb.isEmpty(root.get(Process_.startableUnitList)));
|
|
|
|
|
+ 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));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ p = cb.and(p, cb.equal(root.get(Process_.application), application.getId()));
|
|
|
|
|
+ p = cb.and(p, cb.or(cb.isTrue(root.get(Process_.editionEnable)), cb.isNull(root.get(Process_.editionEnable))));
|
|
|
|
|
+ // 不指名仅在client端可启动那么可启动
|
|
|
|
|
+ p = cb.and(p, cb.or(cb.isNull(root.get(Process_.startableTerminal)),
|
|
|
|
|
+ cb.notEqual(root.get(Process_.startableTerminal), Process.DEFAULTSTARTABLETERMINAL_CLIENT)));
|
|
|
|
|
+ cq.select(root.get(Process_.id)).where(p).distinct(true);
|
|
|
|
|
+ return em.createQuery(cq).getResultList();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* 获取用户可启动的流程,如果applicationId 为空则取到所有可启动流程 */
|
|
/* 获取用户可启动的流程,如果applicationId 为空则取到所有可启动流程 */
|
|
@@ -238,11 +263,10 @@ public class ProcessFactory extends ElementFactory {
|
|
|
Root<Process> root = cq.from(Process.class);
|
|
Root<Process> root = cq.from(Process.class);
|
|
|
Predicate p = cb.equal(root.get(Process_.application), application);
|
|
Predicate p = cb.equal(root.get(Process_.application), application);
|
|
|
p = cb.and(p, cb.equal(root.get(Process_.edition), edition));
|
|
p = cb.and(p, cb.equal(root.get(Process_.edition), edition));
|
|
|
- p = cb.and(p, cb.or(cb.isTrue(root.get(Process_.editionEnable)),
|
|
|
|
|
- cb.isNull(root.get(Process_.editionEnable))));
|
|
|
|
|
|
|
+ p = cb.and(p, cb.or(cb.isTrue(root.get(Process_.editionEnable)), cb.isNull(root.get(Process_.editionEnable))));
|
|
|
cq.select(root).where(p).orderBy(cb.desc(root.get(Process_.editionNumber)));
|
|
cq.select(root).where(p).orderBy(cb.desc(root.get(Process_.editionNumber)));
|
|
|
List<Process> list = em.createQuery(cq).getResultList();
|
|
List<Process> list = em.createQuery(cq).getResultList();
|
|
|
- if(list!=null && !list.isEmpty()){
|
|
|
|
|
|
|
+ if (list != null && !list.isEmpty()) {
|
|
|
return list.get(0);
|
|
return list.get(0);
|
|
|
}
|
|
}
|
|
|
return null;
|
|
return null;
|
|
@@ -254,12 +278,11 @@ public class ProcessFactory extends ElementFactory {
|
|
|
CriteriaQuery<Process> cq = cb.createQuery(Process.class);
|
|
CriteriaQuery<Process> cq = cb.createQuery(Process.class);
|
|
|
Root<Process> root = cq.from(Process.class);
|
|
Root<Process> root = cq.from(Process.class);
|
|
|
Predicate p = cb.equal(root.get(Process_.application), application);
|
|
Predicate p = cb.equal(root.get(Process_.application), application);
|
|
|
- p = cb.and(p, cb.or(cb.equal(root.get(Process_.id), flag),
|
|
|
|
|
- cb.equal(root.get(Process_.name), flag),
|
|
|
|
|
|
|
+ p = cb.and(p, cb.or(cb.equal(root.get(Process_.id), flag), cb.equal(root.get(Process_.name), flag),
|
|
|
cb.equal(root.get(Process_.alias), flag)));
|
|
cb.equal(root.get(Process_.alias), flag)));
|
|
|
cq.select(root).where(p).orderBy(cb.desc(root.get(Process_.editionNumber)));
|
|
cq.select(root).where(p).orderBy(cb.desc(root.get(Process_.editionNumber)));
|
|
|
List<Process> list = em.createQuery(cq).getResultList();
|
|
List<Process> list = em.createQuery(cq).getResultList();
|
|
|
- if(list!=null && !list.isEmpty()){
|
|
|
|
|
|
|
+ if (list != null && !list.isEmpty()) {
|
|
|
return list.get(0);
|
|
return list.get(0);
|
|
|
}
|
|
}
|
|
|
return null;
|
|
return null;
|
|
@@ -305,7 +328,7 @@ public class ProcessFactory extends ElementFactory {
|
|
|
Root<Process> root = cq.from(Process.class);
|
|
Root<Process> root = cq.from(Process.class);
|
|
|
Predicate p = cb.conjunction();
|
|
Predicate p = cb.conjunction();
|
|
|
p = cb.and(p, root.get(Process_.id).in(processList));
|
|
p = cb.and(p, root.get(Process_.id).in(processList));
|
|
|
- if(includeEdition){
|
|
|
|
|
|
|
+ if (includeEdition) {
|
|
|
p = cb.and(p, cb.isNull(root.get(Process_.editionEnable)));
|
|
p = cb.and(p, cb.isNull(root.get(Process_.editionEnable)));
|
|
|
Subquery<Process> subquery = cq.subquery(Process.class);
|
|
Subquery<Process> subquery = cq.subquery(Process.class);
|
|
|
Root<Process> subRoot = subquery.from(Process.class);
|
|
Root<Process> subRoot = subquery.from(Process.class);
|