String[] contents = StringUtils.split(StringUtils.replace(patternContent, " and ", "$"), "$");
StringBuilder singleConBuf = new StringBuilder("(");
for (int i = 0; i < contents.length; i++) {
String content = contents[i];
Condition c = new Condition(content);
List<String> params = c.getParamNames();
for (final String paramName : params) {
UserProperty up = profile.getProperty(paramName);
PropertyMeta prop = up.getMeta();
String value = null == up ? null : up.getValue();
if (StringUtils.isNotEmpty(value)) {
if (value.equals(Restriction.ALL)) {
content = "";
} else {
content = StringUtils.replace(content, ":" + prop.getName(), ":" + prop.getName()
+ index);
paramValues.add(unmarshal(value, prop));
}
} else {
throw new RuntimeException(paramName + " had not been initialized");
}
}
if (singleConBuf.length() > 1 && content.length() > 0) {
singleConBuf.append(" and ");
}
singleConBuf.append(content);
}
if (singleConBuf.length() > 1) {
singleConBuf.append(')');
if (conBuffer.length() > 0) {
conBuffer.append(" or ");
}
conBuffer.append(singleConBuf.toString());
}
index++;
}
if (conBuffer.length() > 0) {
Condition con = new Condition(conBuffer.toString());
con.params(paramValues);
query.where(con);
}
}