Просмотр исходного кода

增加视图关于内容管理document查询过滤条件(路径分别设置(readPersonList)、(readUnitList)、(readGroupList)表示按文档publishFor过滤查看权限,此时需要设置视图查询无权限,也可以添加document的其他参数(param)过滤查询)

o2sword 5 лет назад
Родитель
Сommit
205d088623

+ 33 - 24
o2server/x_query_core_express/src/main/java/com/x/query/core/express/plan/CmsPlan.java

@@ -1,6 +1,5 @@
 package com.x.query.core.express.plan;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Set;
@@ -35,8 +34,6 @@ import com.x.query.core.entity.Item_;
 
 public class CmsPlan extends Plan {
 
-	public final static String CMS_DOCUMENT_ACCESS_FLAG = "cmsDocumentAccessFlag";
-
 	public CmsPlan() {
 	}
 
@@ -92,7 +89,7 @@ public class CmsPlan extends Plan {
 		//根据where条件查询符合条件的所有文档ID列表
 		docIds = listBundle_document(emc);
 		
-		if (BooleanUtils.isTrue(this.where.accessible) && !this.runtime.parameter.containsKey(CMS_DOCUMENT_ACCESS_FLAG)) {
+		if (BooleanUtils.isTrue(this.where.accessible)) {
 			if (StringUtils.isNotEmpty(runtime.person)) {
 				//过滤可见范围
 				docIds = this.listBundle_accessible(emc, docIds, runtime.person );
@@ -133,7 +130,7 @@ public class CmsPlan extends Plan {
 		CriteriaBuilder cb = em.getCriteriaBuilder();
 		CriteriaQuery<String> cq = cb.createQuery(String.class);
 		Root<Document> root = cq.from(Document.class);
-		cq.select(root.get(Document_.id)).distinct(true).where(this.where.documentPredicate(cb, root, this.runtime));
+		cq.select(root.get(Document_.id)).distinct(true).where(this.where.documentPredicate(cb, root, this.runtime, this.filterList));
 		//System.out.println(">>>>>1-listBundle_document>>>>>>SQL:" + em.createQuery(cq).toString() );
 		List<String> docIds = em.createQuery(cq).getResultList();
 		return docIds;
@@ -267,12 +264,12 @@ public class CmsPlan extends Plan {
 		 * @return
 		 * @throws Exception
 		 */
-		private Predicate documentPredicate(CriteriaBuilder cb, Root<Document> root, Runtime runtime) throws Exception {
+		private Predicate documentPredicate(CriteriaBuilder cb, Root<Document> root, Runtime runtime, List<FilterEntry> filterList) throws Exception {
 			List<Predicate> ps = new TreeList<>();
 			ps.add(this.documentPredicate_creator(cb, root));
 			ps.add(this.documentPredicate_appInfo(cb, root));
 			ps.add(this.documentPredicate_date(cb, root));
-			ps.add(this.documentPredicate_accessible(cb, root, runtime));
+			ps.add(this.documentPredicate_Filter(cb, root, runtime, filterList));
 			
 			Predicate predicate = this.documentPredicate_typeScope(cb, root);
 			if( predicate != null  ) {
@@ -375,26 +372,38 @@ public class CmsPlan extends Plan {
 			return null;
 		}
 
-		private Predicate documentPredicate_accessible(CriteriaBuilder cb, Root<Document> root, Runtime runtime) throws Exception {
-			if (!BooleanUtils.isTrue(this.accessible) || !runtime.parameter.containsKey(CmsPlan.CMS_DOCUMENT_ACCESS_FLAG)) {
-				return null;
-			}
-			List<Predicate> matchEach = new ArrayList<>();
-			matchEach.add(cb.isMember("所有人", root.get(Document_.readPersonList)));
-			if(StringUtils.isNotEmpty(runtime.person)){
-				matchEach.add(cb.isMember(runtime.person, root.get(Document_.readPersonList)));
-			}
-			if(ListTools.isNotEmpty(runtime.unitAllList)){
-				for (String unit : runtime.unitAllList){
-					matchEach.add(cb.isMember(unit, root.get(Document_.readUnitList)));
+		private Predicate documentPredicate_Filter(CriteriaBuilder cb, Root<Document> root, Runtime runtime, List<FilterEntry> filterList) throws Exception {
+			boolean flag = true;
+			Predicate p = cb.disjunction();
+			for(FilterEntry filterEntry : filterList){
+				if(filterEntry.path.indexOf("(")>-1 && filterEntry.path.indexOf(")")>-1){
+					flag = false;
+					String path = StringUtils.substringBetween(filterEntry.path, "(", ")").trim();
+					if("readPersonList".equals(path)){
+						p = cb.or(p, cb.isMember("所有人", root.get(Document_.readPersonList)));
+						p = cb.or(p, cb.isMember(runtime.person, root.get(Document_.readPersonList)));
+					}else if("readUnitList".equals(path)){
+						if(ListTools.isNotEmpty(runtime.unitAllList)){
+							p = cb.or(p, root.get(Document_.readUnitList).in(runtime.unitAllList));
+						}
+					}else if("readGroupList".equals(path)){
+						if(ListTools.isNotEmpty(runtime.groupList)){
+							p = cb.or(p, root.get(Document_.readGroupList).in(runtime.groupList));
+						}
+					}else{
+						Predicate fp = filterEntry.toCmsDocumentPredicate(cb, root, runtime, path);
+						if (StringUtils.equals("and", filterEntry.logic)) {
+							p = cb.and(p, fp);
+						}else{
+							p = cb.or(p, fp);
+						}
+					}
 				}
 			}
-			if(ListTools.isNotEmpty(runtime.groupList)){
-				for (String group : runtime.groupList){
-					matchEach.add(cb.isMember(group, root.get(Document_.readGroupList)));
-				}
+			if(flag){
+				return null;
 			}
-			return cb.or(matchEach.toArray(new Predicate[] {}));
+			return p;
 
 		}
 	}

+ 384 - 0
o2server/x_query_core_express/src/main/java/com/x/query/core/express/plan/FilterEntry.java

@@ -16,6 +16,7 @@ import com.x.base.core.project.gson.GsonPropertyObject;
 import com.x.base.core.project.tools.DateTools;
 import com.x.query.core.entity.Item;
 import com.x.query.core.entity.Item_;
+import com.x.cms.core.entity.Document;
 
 public class FilterEntry extends GsonPropertyObject {
 
@@ -68,6 +69,9 @@ public class FilterEntry extends GsonPropertyObject {
 		if (StringUtils.isEmpty(path)) {
 			return false;
 		}
+		if(path.indexOf("(")>-1 && path.indexOf(")")>-1){
+			return false;
+		}
 		if (StringUtils.isEmpty(logic)) {
 			return false;
 		}
@@ -597,4 +601,384 @@ public class FilterEntry extends GsonPropertyObject {
 		return this.otherValue;
 	}
 
+	public Predicate toCmsDocumentPredicate(CriteriaBuilder cb, Root<Document> root, Runtime runtime, String paramName)
+			throws Exception {
+		Predicate p = cb.disjunction();
+		String compareValue = this.compareValue(runtime);
+		String compareOtherValue = this.compareOtherValue(runtime);
+		if (StringUtils.equals(this.formatType, FORMAT_BOOLEANVALUE)) {
+			Boolean booleanValue = BooleanUtils.toBoolean(compareValue);
+			if (null != booleanValue) {
+				if (Comparison.isNotEquals(this.comparison)) {
+					p = cb.and(p, cb.or(cb.isNull(root.get(paramName)),
+							cb.equal(root.get(paramName), !booleanValue)));
+				} else {
+					p = cb.and(p, cb.equal(root.get(paramName), booleanValue));
+				}
+			}
+		} else if (StringUtils.equals(this.formatType, FORMAT_NUMBERVALUE)) {
+			Double doubleValue = NumberUtils.toDouble(compareValue);
+			if (null != doubleValue) {
+				if (Comparison.isNotEquals(this.comparison)) {
+					p = cb.and(p, cb.or(cb.isNull(root.get(paramName)),
+							cb.not(cb.equal(root.get(paramName), doubleValue))));
+				} else if (Comparison.isGreaterThan(this.comparison)) {
+					p = cb.and(p, cb.greaterThan(root.get(paramName), doubleValue));
+				} else if (Comparison.isGreaterThanOrEqualTo(this.comparison)) {
+					p = cb.and(p, cb.greaterThanOrEqualTo(root.get(paramName), doubleValue));
+				} else if (Comparison.isLessThan(this.comparison)) {
+					p = cb.and(p, cb.lessThan(root.get(paramName), doubleValue));
+				} else if (Comparison.isLessThanOrEqualTo(this.comparison)) {
+					p = cb.and(p, cb.lessThanOrEqualTo(root.get(paramName), doubleValue));
+				} else if (Comparison.isBetween(this.comparison)) {
+					Double doubleOtherValue = NumberUtils.toDouble(compareOtherValue);
+					if (null != doubleOtherValue) {
+						p = cb.and(p, cb.between(root.get(paramName), doubleValue, doubleOtherValue));
+					}
+				} else {
+					p = cb.and(p, cb.equal(root.get(paramName), doubleValue));
+				}
+			}
+		} else if (StringUtils.equals(this.formatType, FORMAT_DATEVALUE)) {
+			/* 日期值比较 */
+			if (StringUtils.isNotEmpty(compareValue)) {
+				Date value = null;
+				Date otherValue = null;
+				if (DateTools.isDateTime(compareValue)) {
+					value = DateTools.parseDateTime(compareValue);
+				} else if (DateTools.isDate(compareValue)) {
+					value = DateTools.parseDate(compareValue);
+				}
+				if (DateTools.isDateTime(compareOtherValue)) {
+					otherValue = DateTools.parseDateTime(compareOtherValue);
+				} else if (DateTools.isDate(compareOtherValue)) {
+					otherValue = DateTools.parseDate(compareOtherValue);
+				}
+				if (null != otherValue) {
+					otherValue = DateTools.ceilDate(otherValue, 0);
+				}
+				if (null != value) {
+					value = DateTools.ceilDate(value, 0);
+					if (Comparison.isNotEquals(this.comparison)) {
+						p = cb.and(p, cb.or(cb.isNull(root.get(paramName)),
+								cb.not(cb.equal(root.get(paramName), value))));
+					} else if (Comparison.isGreaterThan(this.comparison)) {
+						p = cb.and(p, cb.greaterThan(root.get(paramName), value));
+					} else if (Comparison.isGreaterThanOrEqualTo(this.comparison)) {
+						p = cb.and(p, cb.greaterThanOrEqualTo(root.get(paramName), value));
+					} else if (Comparison.isLessThan(this.comparison)) {
+						p = cb.and(p, cb.lessThan(root.get(paramName), value));
+					} else if (Comparison.isLessThanOrEqualTo(this.comparison)) {
+						p = cb.and(p, cb.lessThanOrEqualTo(root.get(paramName), value));
+					} else if (Comparison.isBetween(this.comparison)) {
+						if (null != otherValue) {
+							p = cb.and(p, cb.between(root.get(paramName), value, otherValue));
+						} else {
+							throw new Exception("unkown comparison:" + this.comparison);
+						}
+					} else {
+						p = cb.and(p, cb.equal(root.get(paramName), value));
+					}
+				} else if (StringUtils.equals(compareValue, DEFINE_DATE)
+						|| StringUtils.equals(compareValue, DEFINE_MONTH)
+						|| StringUtils.equals(compareValue, DEFINE_SEASON)
+						|| StringUtils.equals(compareValue, DEFINE_YEAR)) {
+					Date floor = null;
+					Date ceil = null;
+					if (StringUtils.equals(compareValue, DEFINE_DATE)) {
+						floor = DateTools.floorDate(new Date(), 0);
+						ceil = DateTools.ceilDate(new Date(), 0);
+					} else if (StringUtils.equals(compareValue, DEFINE_MONTH)) {
+						floor = DateTools.floorMonth(new Date(), 0);
+						ceil = DateTools.ceilMonth(new Date(), 0);
+					} else if (StringUtils.equals(compareValue, DEFINE_SEASON)) {
+						floor = DateTools.floorSeason(new Date(), 0);
+						ceil = DateTools.ceilSeason(new Date(), 0);
+					} else {
+						floor = DateTools.floorYear(new Date(), 0);
+						ceil = DateTools.ceilYear(new Date(), 0);
+					}
+					if (Comparison.isNotEquals(this.comparison)) {
+						p = cb.and(p, cb.or(cb.isNull(root.get(paramName)),
+								cb.not(cb.between(root.get(paramName), floor, ceil))));
+					} else if (Comparison.isGreaterThan(this.comparison)) {
+						p = cb.and(p, cb.greaterThan(root.get(paramName), ceil));
+					} else if (Comparison.isGreaterThanOrEqualTo(this.comparison)) {
+						p = cb.and(p, cb.greaterThanOrEqualTo(root.get(paramName), floor));
+					} else if (Comparison.isLessThan(this.comparison)) {
+						p = cb.and(p, cb.lessThan(root.get(paramName), floor));
+					} else if (Comparison.isLessThanOrEqualTo(this.comparison)) {
+						p = cb.and(p, cb.lessThanOrEqualTo(root.get(paramName), ceil));
+					} else if (Comparison.isBetween(this.comparison)) {
+						// throw new Exception("unkown comparison:" + this.comparison);
+					} else {
+						throw new Exception("unkown comparison:" + this.comparison);
+					}
+				} else if (StringUtils.equals(compareValue, DEFINE_TIME)) {
+					if (Comparison.isNotEquals(this.comparison)) {
+						p = cb.and(p, cb.or(cb.isNull(root.get(paramName)),
+								cb.not(cb.equal(root.get(paramName), new Date()))));
+					} else if (Comparison.isGreaterThan(this.comparison)) {
+						p = cb.and(p, cb.greaterThan(root.get(paramName), new Date()));
+					} else if (Comparison.isGreaterThanOrEqualTo(this.comparison)) {
+						p = cb.and(p, cb.greaterThanOrEqualTo(root.get(paramName), new Date()));
+					} else if (Comparison.isLessThan(this.comparison)) {
+						p = cb.and(p, cb.lessThan(root.get(paramName), new Date()));
+					} else if (Comparison.isLessThanOrEqualTo(this.comparison)) {
+						p = cb.and(p, cb.lessThanOrEqualTo(root.get(paramName), new Date()));
+					} else if (Comparison.isBetween(this.comparison)) {
+						// throw new Exception("unkown comparison:" + this.comparison);
+					} else {
+						throw new Exception("unkown comparison:" + this.comparison);
+					}
+				}
+			}
+		} else if (StringUtils.equals(this.formatType, FORMAT_TIMEVALUE)) {
+			/* 时间值比较 */
+			if (StringUtils.isNotEmpty(compareValue)) {
+				Date value = null;
+				Date otherValue = null;
+				if (DateTools.isDateTime(compareValue)) {
+					value = DateTools.parseDateTime(compareValue);
+				} else if (DateTools.isTime(compareValue)) {
+					value = DateTools.parseTime(compareValue);
+				}
+				if (DateTools.isDateTime(compareOtherValue)) {
+					otherValue = DateTools.parseDateTime(compareOtherValue);
+				} else if (DateTools.isTime(compareOtherValue)) {
+					otherValue = DateTools.parseTime(compareOtherValue);
+				}
+				if (null != value) {
+					if (Comparison.isNotEquals(this.comparison)) {
+						p = cb.and(p, cb.or(cb.isNull(root.get(paramName)),
+								cb.not(cb.equal(root.get(paramName), value))));
+					} else if (Comparison.isGreaterThan(this.comparison)) {
+						p = cb.and(p, cb.greaterThan(root.get(paramName), value));
+					} else if (Comparison.isGreaterThanOrEqualTo(this.comparison)) {
+						p = cb.and(p, cb.greaterThanOrEqualTo(root.get(paramName), value));
+					} else if (Comparison.isLessThan(this.comparison)) {
+						p = cb.and(p, cb.lessThan(root.get(paramName), value));
+					} else if (Comparison.isLessThanOrEqualTo(this.comparison)) {
+						p = cb.and(p, cb.lessThanOrEqualTo(root.get(paramName), value));
+					} else if (Comparison.isBetween(this.comparison)) {
+						if (null != otherValue) {
+							p = cb.and(p, cb.between(root.get(paramName), value, otherValue));
+						}
+					} else {
+						p = cb.and(p, cb.equal(root.get(paramName), value));
+					}
+				} else if (StringUtils.equals(compareValue, DEFINE_TIME)) {
+					if (Comparison.isNotEquals(this.comparison)) {
+						p = cb.and(p, cb.or(cb.isNull(root.get(paramName)),
+								cb.not(cb.equal(root.get(paramName), new Date()))));
+					} else if (Comparison.isGreaterThan(this.comparison)) {
+						p = cb.and(p, cb.greaterThan(root.get(paramName), new Date()));
+					} else if (Comparison.isGreaterThanOrEqualTo(this.comparison)) {
+						p = cb.and(p, cb.greaterThanOrEqualTo(root.get(paramName), new Date()));
+					} else if (Comparison.isLessThan(this.comparison)) {
+						p = cb.and(p, cb.lessThan(root.get(paramName), new Date()));
+					} else if (Comparison.isLessThanOrEqualTo(this.comparison)) {
+						p = cb.and(p, cb.lessThanOrEqualTo(root.get(paramName), new Date()));
+					} else if (Comparison.isBetween(this.comparison)) {
+						throw new Exception("unkown comparison:" + this.comparison);
+					} else {
+						throw new Exception("unkown comparison:" + this.comparison);
+					}
+				}
+			}
+		} else if (StringUtils.equals(this.formatType, FORMAT_DATETIMEVALUE)) {
+			Date value = null;
+			Date otherValue = null;
+			if (DateTools.isDateTime(compareValue)) {
+				value = DateTools.parseDateTime(compareValue);
+			} else if (DateTools.isDate(compareValue)) {
+				value = DateTools.parseDate(compareValue);
+			}
+			if (DateTools.isDateTime(compareOtherValue)) {
+				otherValue = DateTools.parseDateTime(compareOtherValue);
+			} else if (DateTools.isDate(compareOtherValue)) {
+				otherValue = DateTools.parseDate(compareOtherValue);
+			}
+			if (null != value) {
+				if (Comparison.isNotEquals(this.comparison)) {
+					p = cb.and(p, cb.or(cb.isNull(root.get(paramName)),
+							cb.not(cb.equal(root.get(paramName), value))));
+				} else if (Comparison.isGreaterThan(this.comparison)) {
+					p = cb.and(p, cb.greaterThan(root.get(paramName), value));
+				} else if (Comparison.isGreaterThanOrEqualTo(this.comparison)) {
+					p = cb.and(p, cb.greaterThanOrEqualTo(root.get(paramName), value));
+				} else if (Comparison.isLessThan(this.comparison)) {
+					p = cb.and(p, cb.lessThan(root.get(paramName), value));
+				} else if (Comparison.isLessThanOrEqualTo(this.comparison)) {
+					p = cb.and(p, cb.lessThanOrEqualTo(root.get(paramName), value));
+				} else if (Comparison.isBetween(this.comparison)) {
+					if (null != otherValue) {
+						p = cb.and(p, cb.between(root.get(paramName), value, otherValue));
+					} else {
+						throw new Exception("unkown comparison:" + this.comparison);
+					}
+				} else {
+					p = cb.and(p, cb.equal(root.get(paramName), value));
+				}
+			} else if (StringUtils.equals(compareValue, DEFINE_DATE) || StringUtils.equals(compareValue, DEFINE_MONTH)
+					|| StringUtils.equals(compareValue, DEFINE_SEASON)
+					|| StringUtils.equals(compareValue, DEFINE_YEAR)) {
+				Date floor = null;
+				Date ceil = null;
+				if (StringUtils.equals(compareValue, DEFINE_DATE)) {
+					floor = DateTools.floorDate(new Date(), 0);
+					ceil = DateTools.ceilDate(new Date(), 0);
+				} else if (StringUtils.equals(compareValue, DEFINE_MONTH)) {
+					floor = DateTools.floorMonth(new Date(), 0);
+					ceil = DateTools.ceilMonth(new Date(), 0);
+				} else if (StringUtils.equals(compareValue, DEFINE_SEASON)) {
+					floor = DateTools.floorSeason(new Date(), 0);
+					ceil = DateTools.ceilSeason(new Date(), 0);
+				} else {
+					floor = DateTools.floorYear(new Date(), 0);
+					ceil = DateTools.ceilYear(new Date(), 0);
+				}
+				if (Comparison.isNotEquals(this.comparison)) {
+					p = cb.and(p, cb.or(cb.isNull(root.get(paramName)),
+							cb.not(cb.between(root.get(paramName), floor, ceil))));
+				} else if (Comparison.isGreaterThan(this.comparison)) {
+					p = cb.and(p, cb.greaterThan(root.get(paramName), ceil));
+				} else if (Comparison.isGreaterThanOrEqualTo(this.comparison)) {
+					p = cb.and(p, cb.greaterThanOrEqualTo(root.get(paramName), floor));
+				} else if (Comparison.isLessThan(this.comparison)) {
+					p = cb.and(p, cb.lessThan(root.get(paramName), floor));
+				} else if (Comparison.isLessThanOrEqualTo(this.comparison)) {
+					p = cb.and(p, cb.lessThanOrEqualTo(root.get(paramName), ceil));
+				} else if (Comparison.isBetween(this.comparison)) {
+					// p = cb.and(p, cb.between(root.get(Item_.dateTimeValue), floor, ceil));
+				} else {
+					throw new Exception("unkown comparison:" + this.comparison);
+				}
+			} else if (StringUtils.equals(compareValue, DEFINE_TIME)) {
+				if (Comparison.isNotEquals(this.comparison)) {
+					p = cb.and(p, cb.or(cb.isNull(root.get(paramName)),
+							cb.not(cb.equal(root.get(paramName), new Date()))));
+				} else if (Comparison.isGreaterThan(this.comparison)) {
+					p = cb.and(p, cb.greaterThan(root.get(paramName), new Date()));
+				} else if (Comparison.isGreaterThanOrEqualTo(this.comparison)) {
+					p = cb.and(p, cb.greaterThanOrEqualTo(root.get(paramName), new Date()));
+				} else if (Comparison.isLessThan(this.comparison)) {
+					p = cb.and(p, cb.lessThan(root.get(paramName), new Date()));
+				} else if (Comparison.isLessThanOrEqualTo(this.comparison)) {
+					p = cb.and(p, cb.lessThanOrEqualTo(root.get(paramName), new Date()));
+				} else if (Comparison.isBetween(this.comparison)) {
+					throw new Exception("unkown comparison:" + this.comparison);
+				} else {
+					throw new Exception("unkown comparison:" + this.comparison);
+				}
+			}
+		} else {
+			/* TEXT 内容值 */
+			if (StringUtils.equals(compareValue, DEFINE_PERSON)) {
+				if (Comparison.isNotEquals(this.comparison)) {
+					p = cb.and(p, cb.or(cb.isNull(root.get(paramName)),
+							cb.not(cb.equal(root.get(paramName), runtime.person))));
+				} else if (Comparison.isGreaterThan(this.comparison)) {
+					p = cb.and(p, cb.greaterThan(root.get(paramName), runtime.person));
+				} else if (Comparison.isGreaterThanOrEqualTo(this.comparison)) {
+					p = cb.and(p, cb.greaterThanOrEqualTo(root.get(paramName), runtime.person));
+				} else if (Comparison.isLessThan(this.comparison)) {
+					p = cb.and(p, cb.lessThan(root.get(paramName), runtime.person));
+				} else if (Comparison.isLessThanOrEqualTo(this.comparison)) {
+					p = cb.and(p, cb.lessThanOrEqualTo(root.get(paramName), runtime.person));
+				} else if (Comparison.isLike(this.comparison)) {
+					p = cb.and(p, cb.like(root.get(paramName), "%" + runtime.person + "%"));
+				} else if (Comparison.isNotLike(this.comparison)) {
+					p = cb.and(p, cb.notLike(root.get(paramName), "%" + runtime.person + "%"));
+				} else if (Comparison.isBetween(this.comparison)) {
+					throw new Exception("unkown comparison:" + this.comparison);
+				} else {
+					p = cb.and(p, cb.equal(root.get(paramName), runtime.person));
+				}
+			} else if (StringUtils.equals(compareValue, DEFINE_UNITLIST)) {
+				if (Comparison.isNotEquals(this.comparison)) {
+					p = cb.and(p, cb.not(root.get(paramName).in(runtime.unitList)));
+				} else if (Comparison.isGreaterThan(this.comparison)) {
+					throw new Exception("unkown comparison:" + this.comparison);
+				} else if (Comparison.isGreaterThanOrEqualTo(this.comparison)) {
+					throw new Exception("unkown comparison:" + this.comparison);
+				} else if (Comparison.isLessThan(this.comparison)) {
+					throw new Exception("unkown comparison:" + this.comparison);
+				} else if (Comparison.isLessThanOrEqualTo(this.comparison)) {
+					throw new Exception("unkown comparison:" + this.comparison);
+				} else if (Comparison.isLike(this.comparison)) {
+					throw new Exception("unkown comparison:" + this.comparison);
+				} else if (Comparison.isNotLike(this.comparison)) {
+					throw new Exception("unkown comparison:" + this.comparison);
+				} else if (Comparison.isBetween(this.comparison)) {
+					throw new Exception("unkown comparison:" + this.comparison);
+				} else {
+					p = cb.and(p, root.get(paramName).in(runtime.unitList));
+				}
+			} else if (StringUtils.equals(compareValue, DEFINE_UNITALLLIST)) {
+				if (Comparison.isNotEquals(this.comparison)) {
+					p = cb.and(p, cb.not(root.get(paramName).in(runtime.unitAllList)));
+				} else if (Comparison.isGreaterThan(this.comparison)) {
+					throw new Exception("unkown comparison:" + this.comparison);
+				} else if (Comparison.isGreaterThanOrEqualTo(this.comparison)) {
+					throw new Exception("unkown comparison:" + this.comparison);
+				} else if (Comparison.isLessThan(this.comparison)) {
+					throw new Exception("unkown comparison:" + this.comparison);
+				} else if (Comparison.isLessThanOrEqualTo(this.comparison)) {
+					throw new Exception("unkown comparison:" + this.comparison);
+				} else if (Comparison.isLike(this.comparison)) {
+					throw new Exception("unkown comparison:" + this.comparison);
+				} else if (Comparison.isNotLike(this.comparison)) {
+					throw new Exception("unkown comparison:" + this.comparison);
+				} else if (Comparison.isBetween(this.comparison)) {
+					throw new Exception("unkown comparison:" + this.comparison);
+				} else {
+					p = cb.and(p, root.get(paramName).in(runtime.unitAllList));
+				}
+			} else if (StringUtils.equals(compareValue, DEFINE_IDENTITYLIST)) {
+				if (Comparison.isNotEquals(this.comparison)) {
+					p = cb.and(p, cb.not(root.get(paramName).in(runtime.identityList)));
+				} else if (Comparison.isGreaterThan(this.comparison)) {
+					throw new Exception("unkown comparison:" + this.comparison);
+				} else if (Comparison.isGreaterThanOrEqualTo(this.comparison)) {
+					throw new Exception("unkown comparison:" + this.comparison);
+				} else if (Comparison.isLessThan(this.comparison)) {
+					throw new Exception("unkown comparison:" + this.comparison);
+				} else if (Comparison.isLessThanOrEqualTo(this.comparison)) {
+					throw new Exception("unkown comparison:" + this.comparison);
+				} else if (Comparison.isLike(this.comparison)) {
+					throw new Exception("unkown comparison:" + this.comparison);
+				} else if (Comparison.isNotLike(this.comparison)) {
+					throw new Exception("unkown comparison:" + this.comparison);
+				} else if (Comparison.isBetween(this.comparison)) {
+					throw new Exception("unkown comparison:" + this.comparison);
+				} else {
+					p = cb.and(p, root.get(paramName).in(runtime.identityList));
+				}
+			} else {
+				if (Comparison.isNotEquals(this.comparison)) {
+					p = cb.and(p, cb.or(cb.isNull(root.get(paramName)),
+							cb.not(cb.equal(root.get(paramName), compareValue))));
+				} else if (Comparison.isGreaterThan(this.comparison)) {
+					p = cb.and(p, cb.greaterThan(root.get(paramName), compareValue));
+				} else if (Comparison.isGreaterThanOrEqualTo(this.comparison)) {
+					p = cb.and(p, cb.greaterThanOrEqualTo(root.get(paramName), compareValue));
+				} else if (Comparison.isLessThan(this.comparison)) {
+					p = cb.and(p, cb.lessThan(root.get(paramName), compareValue));
+				} else if (Comparison.isLessThanOrEqualTo(this.comparison)) {
+					p = cb.and(p, cb.lessThanOrEqualTo(root.get(paramName), compareValue));
+				} else if (Comparison.isLike(this.comparison)) {
+					p = cb.and(p, cb.like(root.get(paramName), "%" + compareValue + "%"));
+				} else if (Comparison.isNotLike(this.comparison)) {
+					p = cb.and(p, cb.notLike(root.get(paramName), "%" + compareValue + "%"));
+				} else if (Comparison.isBetween(this.comparison)) {
+					p = cb.and(p, cb.between(root.get(paramName), compareValue, compareOtherValue));
+				} else {
+					p = cb.and(p, cb.equal(root.get(paramName), compareValue));
+				}
+			}
+		}
+		return p;
+	}
+
 }