mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Remove LDAP and Validation objects - (removing these features)
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
package com.avaje.ebeaninternal.server.ldap;
|
||||
|
||||
import com.avaje.ebean.EbeanServer;
|
||||
import com.avaje.ebean.ExpressionFactory;
|
||||
import com.avaje.ebeaninternal.server.querydefn.DefaultOrmQuery;
|
||||
|
||||
public class DefaultLdapOrmQuery<T> extends DefaultOrmQuery<T> {
|
||||
|
||||
private static final long serialVersionUID = -4344629258591773124L;
|
||||
|
||||
public DefaultLdapOrmQuery(Class<T> beanType, EbeanServer server, ExpressionFactory expressionFactory, String query) {
|
||||
super(beanType, server, expressionFactory, query);
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.avaje.ebeaninternal.server.ldap;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.naming.directory.DirContext;
|
||||
|
||||
import com.avaje.ebean.config.ldap.LdapContextFactory;
|
||||
|
||||
public class LdapOrmQueryEngine {
|
||||
|
||||
private final boolean defaultVanillaMode;
|
||||
|
||||
private final LdapContextFactory contextFactory;
|
||||
|
||||
public LdapOrmQueryEngine(boolean defaultVanillaMode, LdapContextFactory contextFactory) {
|
||||
this.defaultVanillaMode = defaultVanillaMode;
|
||||
this.contextFactory = contextFactory;
|
||||
}
|
||||
|
||||
public <T> T findId(LdapOrmQueryRequest<T> request) {
|
||||
DirContext dc = contextFactory.createContext();
|
||||
LdapOrmQueryExecute<T> exe = new LdapOrmQueryExecute<T>(request, defaultVanillaMode, dc);
|
||||
|
||||
return exe.findId();
|
||||
}
|
||||
|
||||
public <T> List<T> findList(LdapOrmQueryRequest<T> request) {
|
||||
|
||||
DirContext dc = contextFactory.createContext();
|
||||
|
||||
LdapOrmQueryExecute<T> exe = new LdapOrmQueryExecute<T>(request, defaultVanillaMode, dc);
|
||||
|
||||
return exe.findList();
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
package com.avaje.ebeaninternal.server.ldap;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.avaje.ebean.QueryIterator;
|
||||
import com.avaje.ebean.QueryResultVisitor;
|
||||
import com.avaje.ebean.bean.BeanCollection;
|
||||
import com.avaje.ebeaninternal.api.SpiQuery;
|
||||
import com.avaje.ebeaninternal.server.core.SpiOrmQueryRequest;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
|
||||
public class LdapOrmQueryRequest<T> implements SpiOrmQueryRequest<T> {
|
||||
|
||||
private final SpiQuery<T> query;
|
||||
private final BeanDescriptor<T> desc;
|
||||
private final LdapOrmQueryEngine queryEngine;
|
||||
|
||||
public LdapOrmQueryRequest(SpiQuery<T> query, BeanDescriptor<T> desc, LdapOrmQueryEngine queryEngine) {
|
||||
this.query = query;
|
||||
this.desc = desc;
|
||||
this.queryEngine = queryEngine;
|
||||
}
|
||||
|
||||
public BeanDescriptor<T> getBeanDescriptor() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public SpiQuery<T> getQuery() {
|
||||
return query;
|
||||
}
|
||||
|
||||
public Object findId() {
|
||||
return queryEngine.findId(this);
|
||||
}
|
||||
|
||||
public List<Object> findIds() {
|
||||
throw new RuntimeException("Not Implemented yet");
|
||||
}
|
||||
|
||||
public List<T> findList() {
|
||||
return queryEngine.findList(this);
|
||||
}
|
||||
|
||||
public void findVisit(QueryResultVisitor<T> visitor) {
|
||||
throw new RuntimeException("Not Implemented yet");
|
||||
}
|
||||
|
||||
public QueryIterator<T> findIterate() {
|
||||
throw new RuntimeException("Not Implemented yet");
|
||||
}
|
||||
|
||||
public Map<?, ?> findMap() {
|
||||
throw new RuntimeException("Not Implemented yet");
|
||||
}
|
||||
|
||||
public int findRowCount() {
|
||||
throw new RuntimeException("Not Implemented yet");
|
||||
}
|
||||
|
||||
public Set<?> findSet() {
|
||||
throw new RuntimeException("Not Implemented yet");
|
||||
}
|
||||
|
||||
public T getFromPersistenceContextOrCache() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public BeanCollection<T> getFromQueryCache() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void initTransIfRequired() {
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
public void rollbackTransIfRequired() {
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
public void endTransIfRequired() {
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package com.avaje.ebeaninternal.server.ldap;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.naming.ldap.LdapName;
|
||||
|
||||
import com.avaje.ebean.annotation.ConcurrencyMode;
|
||||
import com.avaje.ebeaninternal.api.SpiEbeanServer;
|
||||
import com.avaje.ebeaninternal.server.core.PersistRequestBean;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanManager;
|
||||
|
||||
public class LdapPersistBeanRequest<T> extends PersistRequestBean<T> {
|
||||
|
||||
private final DefaultLdapPersister persister;
|
||||
|
||||
public LdapPersistBeanRequest(SpiEbeanServer server, T bean, Object parentBean, BeanManager<T> mgr, DefaultLdapPersister persister) {
|
||||
|
||||
super(server, bean, parentBean, mgr, null, null);
|
||||
this.persister = persister;
|
||||
}
|
||||
|
||||
public LdapPersistBeanRequest(SpiEbeanServer server, T bean, Object parentBean, BeanManager<T> mgr, DefaultLdapPersister persister,
|
||||
Set<String> updateProps, ConcurrencyMode concurrencyMode) {
|
||||
|
||||
super(server, bean, parentBean, mgr, null, null, updateProps, concurrencyMode);
|
||||
this.persister = persister;
|
||||
}
|
||||
|
||||
public LdapName createLdapName() {
|
||||
return beanDescriptor.createLdapName(bean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int executeNow() {
|
||||
|
||||
return persister.persist(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int executeOrQueue() {
|
||||
return executeNow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initTransIfRequired() {
|
||||
// no transaction at this stage for Ldap
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commitTransIfRequired() {
|
||||
// no transaction at this stage for Ldap
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rollbackTransIfRequired() {
|
||||
// no transaction at this stage for Ldap
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.avaje.ebeaninternal.server.ldap;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
public class LdapPersistenceException extends PersistenceException {
|
||||
|
||||
private static final long serialVersionUID = -3170359404117927668L;
|
||||
|
||||
public LdapPersistenceException(Throwable e){
|
||||
super(e);
|
||||
}
|
||||
|
||||
public LdapPersistenceException(String msg, Throwable e){
|
||||
super(msg, e);
|
||||
}
|
||||
|
||||
public LdapPersistenceException(String msg){
|
||||
super(msg);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
package com.avaje.ebeaninternal.server.ldap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.avaje.ebeaninternal.api.SpiExpressionList;
|
||||
import com.avaje.ebeaninternal.api.SpiQuery;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanProperty;
|
||||
import com.avaje.ebeaninternal.server.deploy.DeployPropertyParser;
|
||||
import com.avaje.ebeaninternal.server.querydefn.OrmQueryProperties;
|
||||
import com.avaje.ebeaninternal.util.DefaultExpressionRequest;
|
||||
|
||||
public class LdapQueryDeployHelper {
|
||||
|
||||
private final LdapOrmQueryRequest<?> request;
|
||||
private final SpiQuery<?> query;
|
||||
private final BeanDescriptor<?> desc;
|
||||
|
||||
private String filterExpr;
|
||||
private Object[] filterValues;
|
||||
|
||||
public LdapQueryDeployHelper(LdapOrmQueryRequest<?> request) {
|
||||
this.request = request;
|
||||
this.query = request.getQuery();
|
||||
this.desc = request.getBeanDescriptor();
|
||||
|
||||
parse();
|
||||
}
|
||||
|
||||
public String[] getSelectedProperties() {
|
||||
|
||||
OrmQueryProperties chunk = query.getDetail().getChunk(null, false);
|
||||
if (chunk.allProperties()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// convert to array of String[] for setReturningAttributes();
|
||||
ArrayList<String> ldapSelectProps = new ArrayList<String>();
|
||||
|
||||
Iterator<String> selectProperties = chunk.getSelectProperties();
|
||||
while (selectProperties.hasNext()) {
|
||||
String propName = selectProperties.next();
|
||||
BeanProperty p = desc.getBeanProperty(propName);
|
||||
if (p != null) {
|
||||
propName = p.getDbColumn();
|
||||
}
|
||||
ldapSelectProps.add(propName);
|
||||
}
|
||||
return ldapSelectProps.toArray(new String[ldapSelectProps.size()]);
|
||||
|
||||
}
|
||||
|
||||
private void parse() {
|
||||
|
||||
DeployPropertyParser deployParser = desc.createDeployPropertyParser();
|
||||
|
||||
String baseWhere = query.getAdditionalWhere();
|
||||
if (baseWhere != null){
|
||||
baseWhere = deployParser.parse(baseWhere);
|
||||
}
|
||||
|
||||
|
||||
SpiExpressionList<?> whereExp = query.getWhereExpressions();
|
||||
if (whereExp != null) {
|
||||
|
||||
DefaultExpressionRequest expReq = new DefaultExpressionRequest(request, deployParser);
|
||||
|
||||
ArrayList<?> bindValues = whereExp.buildBindValues(expReq);
|
||||
filterValues = bindValues.toArray(new Object[bindValues.size()]);
|
||||
String exprWhere = whereExp.buildSql(expReq);
|
||||
|
||||
if (baseWhere != null){
|
||||
filterExpr = "(&"+baseWhere +exprWhere+")";
|
||||
} else {
|
||||
filterExpr = exprWhere;
|
||||
}
|
||||
} else {
|
||||
filterExpr = baseWhere;
|
||||
}
|
||||
}
|
||||
|
||||
public String getFilterExpr() {
|
||||
return filterExpr;
|
||||
}
|
||||
|
||||
public Object[] getFilterValues() {
|
||||
return filterValues;
|
||||
}
|
||||
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
package com.avaje.ebeaninternal.server.ldap.expression;
|
||||
|
||||
import com.avaje.ebeaninternal.api.ManyWhereJoins;
|
||||
import com.avaje.ebeaninternal.api.SpiExpression;
|
||||
import com.avaje.ebeaninternal.api.SpiExpressionRequest;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.ebeaninternal.server.el.ElPropertyDeploy;
|
||||
import com.avaje.ebeaninternal.server.el.ElPropertyValue;
|
||||
|
||||
/**
|
||||
* Base class for simple expressions.
|
||||
*
|
||||
* @author rbygrave
|
||||
*/
|
||||
public abstract class LdAbstractExpression implements SpiExpression {
|
||||
|
||||
private static final long serialVersionUID = 4072786211853856174L;
|
||||
|
||||
protected final String propertyName;
|
||||
|
||||
protected LdAbstractExpression(String propertyName) {
|
||||
this.propertyName = propertyName;
|
||||
}
|
||||
|
||||
protected String nextParam(SpiExpressionRequest request) {
|
||||
|
||||
int pos = request.nextParameter();
|
||||
return "{"+(pos-1)+"}";
|
||||
}
|
||||
|
||||
public void containsMany(BeanDescriptor<?> desc, ManyWhereJoins manyWhereJoin) {
|
||||
|
||||
if (propertyName != null){
|
||||
ElPropertyDeploy elProp = desc.getElPropertyDeploy(propertyName);
|
||||
if (elProp != null && elProp.containsMany()){
|
||||
manyWhereJoin.add(elProp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected ElPropertyValue getElProp(SpiExpressionRequest request) {
|
||||
|
||||
return request.getBeanDescriptor().getElGetValue(propertyName);
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.avaje.ebeaninternal.server.ldap.expression;
|
||||
|
||||
public class LdEscape {
|
||||
|
||||
|
||||
public static String forLike(String source) {
|
||||
|
||||
// not escaping '*' to "\\\\2a"
|
||||
|
||||
StringBuilder sb = new StringBuilder(source.length()+5);
|
||||
|
||||
int len = source.length();
|
||||
for (int i = 0; i < len; i++) {
|
||||
|
||||
char ch = source.charAt(i);
|
||||
switch (ch) {
|
||||
case '(':
|
||||
sb.append("\\\\28");break;
|
||||
case ')':
|
||||
sb.append("\\\\29");break;
|
||||
case '\\':
|
||||
sb.append("\\\\5c");break;
|
||||
case '/':
|
||||
sb.append("\\\\2f");break;
|
||||
case '\0':
|
||||
sb.append("\\\\0");break;
|
||||
default:
|
||||
sb.append(ch);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
package com.avaje.ebeaninternal.server.ldap.expression;
|
||||
|
||||
import com.avaje.ebean.event.BeanQueryRequest;
|
||||
import com.avaje.ebeaninternal.api.ManyWhereJoins;
|
||||
import com.avaje.ebeaninternal.api.SpiExpression;
|
||||
import com.avaje.ebeaninternal.api.SpiExpressionRequest;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanProperty;
|
||||
import com.avaje.ebeaninternal.util.DefaultExpressionRequest;
|
||||
|
||||
/**
|
||||
* Slightly redundant as Query.setId() ultimately also does the same job.
|
||||
*/
|
||||
class LdIdExpression extends LdAbstractExpression implements SpiExpression {
|
||||
|
||||
private static final long serialVersionUID = -3065936341718489843L;
|
||||
|
||||
private final Object value;
|
||||
|
||||
LdIdExpression(Object value) {
|
||||
super(null);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void containsMany(BeanDescriptor<?> desc, ManyWhereJoins manyWhereJoin) {
|
||||
|
||||
}
|
||||
|
||||
public void addBindValues(SpiExpressionRequest request) {
|
||||
|
||||
// 'flatten' EmbeddedId and multiple Id cases
|
||||
// into an array of the underlying scalar field values
|
||||
DefaultExpressionRequest r = (DefaultExpressionRequest) request;
|
||||
BeanProperty[] propertiesId = r.getBeanDescriptor().propertiesId();
|
||||
if (propertiesId.length > 1) {
|
||||
throw new RuntimeException("Only single Id property is supported for LDAP");
|
||||
}
|
||||
request.addBindValue(value);
|
||||
}
|
||||
|
||||
public void addSql(SpiExpressionRequest request) {
|
||||
|
||||
DefaultExpressionRequest r = (DefaultExpressionRequest) request;
|
||||
BeanProperty[] propertiesId = r.getBeanDescriptor().propertiesId();
|
||||
if (propertiesId.length > 1) {
|
||||
throw new RuntimeException("Only single Id property is supported for LDAP");
|
||||
}
|
||||
|
||||
String ldapProp = propertiesId[0].getDbColumn();
|
||||
request.append(ldapProp).append("=").append(nextParam(request));
|
||||
}
|
||||
|
||||
/**
|
||||
* No properties so this is just a unique static number.
|
||||
*/
|
||||
public int queryAutoFetchHash() {
|
||||
// this number is unique for a given bean type
|
||||
// which is all that is required
|
||||
return LdIdExpression.class.getName().hashCode();
|
||||
}
|
||||
|
||||
public int queryPlanHash(BeanQueryRequest<?> request) {
|
||||
return queryAutoFetchHash();
|
||||
}
|
||||
|
||||
public int queryBindHash() {
|
||||
return value.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
-421
@@ -1,421 +0,0 @@
|
||||
package com.avaje.ebeaninternal.server.ldap.expression;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.avaje.ebean.Expression;
|
||||
import com.avaje.ebean.ExpressionFactory;
|
||||
import com.avaje.ebean.ExpressionList;
|
||||
import com.avaje.ebean.FutureIds;
|
||||
import com.avaje.ebean.FutureList;
|
||||
import com.avaje.ebean.FutureRowCount;
|
||||
import com.avaje.ebean.Junction;
|
||||
import com.avaje.ebean.OrderBy;
|
||||
import com.avaje.ebean.PagingList;
|
||||
import com.avaje.ebean.QueryIterator;
|
||||
import com.avaje.ebean.QueryListener;
|
||||
import com.avaje.ebean.QueryResultVisitor;
|
||||
import com.avaje.ebean.event.BeanQueryRequest;
|
||||
import com.avaje.ebeaninternal.api.ManyWhereJoins;
|
||||
import com.avaje.ebeaninternal.api.SpiExpression;
|
||||
import com.avaje.ebeaninternal.api.SpiExpressionRequest;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.ebeaninternal.util.DefaultExpressionList;
|
||||
|
||||
/**
|
||||
* Junction implementation.
|
||||
*/
|
||||
abstract class LdJunctionExpression<T> implements Junction<T>, SpiExpression {
|
||||
|
||||
private static final long serialVersionUID = -7422204102750462677L;
|
||||
|
||||
static class Conjunction<T> extends LdJunctionExpression<T> {
|
||||
|
||||
private static final long serialVersionUID = -645619859900030679L;
|
||||
|
||||
Conjunction(com.avaje.ebean.Query<T> query, ExpressionList<T> parent) {
|
||||
super("&", query, parent);
|
||||
}
|
||||
|
||||
Conjunction(ExpressionFactory exprFactory) {
|
||||
super("&", exprFactory);
|
||||
}
|
||||
}
|
||||
|
||||
static class Disjunction<T> extends LdJunctionExpression<T> {
|
||||
|
||||
private static final long serialVersionUID = -8464470066692221414L;
|
||||
|
||||
Disjunction(com.avaje.ebean.Query<T> query, ExpressionList<T> parent) {
|
||||
super("|", query, parent);
|
||||
}
|
||||
|
||||
Disjunction(ExpressionFactory exprFactory) {
|
||||
super("|", exprFactory);
|
||||
}
|
||||
}
|
||||
|
||||
private final DefaultExpressionList<T> exprList;
|
||||
|
||||
private final String joinType;
|
||||
|
||||
LdJunctionExpression(String joinType, com.avaje.ebean.Query<T> query, ExpressionList<T> parent) {
|
||||
this.joinType = joinType;
|
||||
this.exprList = new DefaultExpressionList<T>(query, parent);
|
||||
}
|
||||
|
||||
LdJunctionExpression(String joinType, ExpressionFactory exprFactory) {
|
||||
this.joinType = joinType;
|
||||
this.exprList = new DefaultExpressionList<T>(null, exprFactory, null);
|
||||
}
|
||||
|
||||
public void containsMany(BeanDescriptor<?> desc, ManyWhereJoins manyWhereJoin) {
|
||||
|
||||
List<SpiExpression> list = exprList.internalList();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
list.get(i).containsMany(desc, manyWhereJoin);
|
||||
}
|
||||
}
|
||||
|
||||
public Junction<T> add(Expression item) {
|
||||
SpiExpression i = (SpiExpression) item;
|
||||
exprList.add(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Junction<T> addAll(ExpressionList<T> addList) {
|
||||
exprList.addAll(addList);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void addBindValues(SpiExpressionRequest request) {
|
||||
|
||||
List<SpiExpression> list = exprList.internalList();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
SpiExpression item = list.get(i);
|
||||
item.addBindValues(request);
|
||||
}
|
||||
}
|
||||
|
||||
public void addSql(SpiExpressionRequest request) {
|
||||
|
||||
List<SpiExpression> list = exprList.internalList();
|
||||
if (!list.isEmpty()) {
|
||||
request.append("(");
|
||||
request.append(joinType);
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
SpiExpression item = list.get(i);
|
||||
item.addSql(request);
|
||||
}
|
||||
|
||||
request.append(") ");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Based on Junction type and all the expression contained.
|
||||
*/
|
||||
public int queryAutoFetchHash() {
|
||||
int hc = LdJunctionExpression.class.getName().hashCode();
|
||||
hc = hc * 31 + joinType.hashCode();
|
||||
List<SpiExpression> list = exprList.internalList();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
hc = hc * 31 + list.get(i).queryAutoFetchHash();
|
||||
}
|
||||
|
||||
return hc;
|
||||
}
|
||||
|
||||
public int queryPlanHash(BeanQueryRequest<?> request) {
|
||||
int hc = LdJunctionExpression.class.getName().hashCode();
|
||||
hc = hc * 31 + joinType.hashCode();
|
||||
List<SpiExpression> list = exprList.internalList();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
hc = hc * 31 + list.get(i).queryPlanHash(request);
|
||||
}
|
||||
|
||||
return hc;
|
||||
}
|
||||
|
||||
public int queryBindHash() {
|
||||
int hc = LdJunctionExpression.class.getName().hashCode();
|
||||
List<SpiExpression> list = exprList.internalList();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
hc = hc * 31 + list.get(i).queryBindHash();
|
||||
}
|
||||
|
||||
return hc;
|
||||
}
|
||||
|
||||
public ExpressionList<T> endJunction() {
|
||||
return exprList.endJunction();
|
||||
}
|
||||
|
||||
public ExpressionList<T> allEq(Map<String, Object> propertyMap) {
|
||||
return exprList.allEq(propertyMap);
|
||||
}
|
||||
|
||||
public ExpressionList<T> and(Expression expOne, Expression expTwo) {
|
||||
return exprList.and(expOne, expTwo);
|
||||
}
|
||||
|
||||
public ExpressionList<T> between(String propertyName, Object value1, Object value2) {
|
||||
return exprList.between(propertyName, value1, value2);
|
||||
}
|
||||
|
||||
public ExpressionList<T> betweenProperties(String lowProperty, String highProperty, Object value) {
|
||||
return exprList.betweenProperties(lowProperty, highProperty, value);
|
||||
}
|
||||
|
||||
public Junction<T> conjunction() {
|
||||
return exprList.conjunction();
|
||||
}
|
||||
|
||||
public ExpressionList<T> contains(String propertyName, String value) {
|
||||
return exprList.contains(propertyName, value);
|
||||
}
|
||||
|
||||
public Junction<T> disjunction() {
|
||||
return exprList.disjunction();
|
||||
}
|
||||
|
||||
public ExpressionList<T> endsWith(String propertyName, String value) {
|
||||
return exprList.endsWith(propertyName, value);
|
||||
}
|
||||
|
||||
public ExpressionList<T> eq(String propertyName, Object value) {
|
||||
return exprList.eq(propertyName, value);
|
||||
}
|
||||
|
||||
public ExpressionList<T> exampleLike(Object example) {
|
||||
return exprList.exampleLike(example);
|
||||
}
|
||||
|
||||
public ExpressionList<T> filterMany(String prop) {
|
||||
throw new RuntimeException("filterMany not allowed on Junction expression list");
|
||||
}
|
||||
|
||||
public FutureIds<T> findFutureIds() {
|
||||
return exprList.findFutureIds();
|
||||
}
|
||||
|
||||
public FutureList<T> findFutureList() {
|
||||
return exprList.findFutureList();
|
||||
}
|
||||
|
||||
public FutureRowCount<T> findFutureRowCount() {
|
||||
return exprList.findFutureRowCount();
|
||||
}
|
||||
|
||||
public List<Object> findIds() {
|
||||
return exprList.findIds();
|
||||
}
|
||||
|
||||
public void findVisit(QueryResultVisitor<T> visitor) {
|
||||
exprList.findVisit(visitor);
|
||||
}
|
||||
|
||||
public QueryIterator<T> findIterate() {
|
||||
return exprList.findIterate();
|
||||
}
|
||||
|
||||
public List<T> findList() {
|
||||
return exprList.findList();
|
||||
}
|
||||
|
||||
public Map<?, T> findMap() {
|
||||
return exprList.findMap();
|
||||
}
|
||||
|
||||
public <K> Map<K, T> findMap(String keyProperty, Class<K> keyType) {
|
||||
return exprList.findMap(keyProperty, keyType);
|
||||
}
|
||||
|
||||
public PagingList<T> findPagingList(int pageSize) {
|
||||
return exprList.findPagingList(pageSize);
|
||||
}
|
||||
|
||||
public int findRowCount() {
|
||||
return exprList.findRowCount();
|
||||
}
|
||||
|
||||
public Set<T> findSet() {
|
||||
return exprList.findSet();
|
||||
}
|
||||
|
||||
public T findUnique() {
|
||||
return exprList.findUnique();
|
||||
}
|
||||
|
||||
public ExpressionList<T> ge(String propertyName, Object value) {
|
||||
return exprList.ge(propertyName, value);
|
||||
}
|
||||
|
||||
public ExpressionList<T> gt(String propertyName, Object value) {
|
||||
return exprList.gt(propertyName, value);
|
||||
}
|
||||
|
||||
public ExpressionList<T> having() {
|
||||
throw new RuntimeException("having() not allowed on Junction expression list");
|
||||
}
|
||||
|
||||
public ExpressionList<T> icontains(String propertyName, String value) {
|
||||
return exprList.icontains(propertyName, value);
|
||||
}
|
||||
|
||||
public ExpressionList<T> idEq(Object value) {
|
||||
return exprList.idEq(value);
|
||||
}
|
||||
|
||||
public ExpressionList<T> idIn(List<?> idValues) {
|
||||
return exprList.idIn(idValues);
|
||||
}
|
||||
|
||||
public ExpressionList<T> iendsWith(String propertyName, String value) {
|
||||
return exprList.iendsWith(propertyName, value);
|
||||
}
|
||||
|
||||
public ExpressionList<T> ieq(String propertyName, String value) {
|
||||
return exprList.ieq(propertyName, value);
|
||||
}
|
||||
|
||||
public ExpressionList<T> iexampleLike(Object example) {
|
||||
return exprList.iexampleLike(example);
|
||||
}
|
||||
|
||||
public ExpressionList<T> ilike(String propertyName, String value) {
|
||||
return exprList.ilike(propertyName, value);
|
||||
}
|
||||
|
||||
public ExpressionList<T> in(String propertyName, Collection<?> values) {
|
||||
return exprList.in(propertyName, values);
|
||||
}
|
||||
|
||||
public ExpressionList<T> in(String propertyName, Object... values) {
|
||||
return exprList.in(propertyName, values);
|
||||
}
|
||||
|
||||
public ExpressionList<T> in(String propertyName, com.avaje.ebean.Query<?> subQuery) {
|
||||
return exprList.in(propertyName, subQuery);
|
||||
}
|
||||
|
||||
public ExpressionList<T> isNotNull(String propertyName) {
|
||||
return exprList.isNotNull(propertyName);
|
||||
}
|
||||
|
||||
public ExpressionList<T> isNull(String propertyName) {
|
||||
return exprList.isNull(propertyName);
|
||||
}
|
||||
|
||||
public ExpressionList<T> istartsWith(String propertyName, String value) {
|
||||
return exprList.istartsWith(propertyName, value);
|
||||
}
|
||||
|
||||
public com.avaje.ebean.Query<T> join(String assocProperty, String assocProperties) {
|
||||
return exprList.join(assocProperty, assocProperties);
|
||||
}
|
||||
|
||||
public com.avaje.ebean.Query<T> join(String assocProperties) {
|
||||
return exprList.join(assocProperties);
|
||||
}
|
||||
|
||||
public ExpressionList<T> le(String propertyName, Object value) {
|
||||
return exprList.le(propertyName, value);
|
||||
}
|
||||
|
||||
public ExpressionList<T> like(String propertyName, String value) {
|
||||
return exprList.like(propertyName, value);
|
||||
}
|
||||
|
||||
public ExpressionList<T> lt(String propertyName, Object value) {
|
||||
return exprList.lt(propertyName, value);
|
||||
}
|
||||
|
||||
public ExpressionList<T> ne(String propertyName, Object value) {
|
||||
return exprList.ne(propertyName, value);
|
||||
}
|
||||
|
||||
public ExpressionList<T> not(Expression exp) {
|
||||
return exprList.not(exp);
|
||||
}
|
||||
|
||||
public ExpressionList<T> or(Expression expOne, Expression expTwo) {
|
||||
return exprList.or(expOne, expTwo);
|
||||
}
|
||||
|
||||
public OrderBy<T> order() {
|
||||
return exprList.order();
|
||||
}
|
||||
|
||||
public com.avaje.ebean.Query<T> order(String orderByClause) {
|
||||
return exprList.order(orderByClause);
|
||||
}
|
||||
|
||||
public OrderBy<T> orderBy() {
|
||||
return exprList.orderBy();
|
||||
}
|
||||
|
||||
public com.avaje.ebean.Query<T> orderBy(String orderBy) {
|
||||
return exprList.orderBy(orderBy);
|
||||
}
|
||||
|
||||
public com.avaje.ebean.Query<T> query() {
|
||||
return exprList.query();
|
||||
}
|
||||
|
||||
public ExpressionList<T> raw(String raw, Object value) {
|
||||
return exprList.raw(raw, value);
|
||||
}
|
||||
|
||||
public ExpressionList<T> raw(String raw, Object[] values) {
|
||||
return exprList.raw(raw, values);
|
||||
}
|
||||
|
||||
public ExpressionList<T> raw(String raw) {
|
||||
return exprList.raw(raw);
|
||||
}
|
||||
|
||||
public com.avaje.ebean.Query<T> select(String properties) {
|
||||
return exprList.select(properties);
|
||||
}
|
||||
|
||||
public com.avaje.ebean.Query<T> setBackgroundFetchAfter(int backgroundFetchAfter) {
|
||||
return exprList.setBackgroundFetchAfter(backgroundFetchAfter);
|
||||
}
|
||||
|
||||
public com.avaje.ebean.Query<T> setFirstRow(int firstRow) {
|
||||
return exprList.setFirstRow(firstRow);
|
||||
}
|
||||
|
||||
public com.avaje.ebean.Query<T> setListener(QueryListener<T> queryListener) {
|
||||
return exprList.setListener(queryListener);
|
||||
}
|
||||
|
||||
public com.avaje.ebean.Query<T> setMapKey(String mapKey) {
|
||||
return exprList.setMapKey(mapKey);
|
||||
}
|
||||
|
||||
public com.avaje.ebean.Query<T> setMaxRows(int maxRows) {
|
||||
return exprList.setMaxRows(maxRows);
|
||||
}
|
||||
|
||||
public com.avaje.ebean.Query<T> setOrderBy(String orderBy) {
|
||||
return exprList.setOrderBy(orderBy);
|
||||
}
|
||||
|
||||
public com.avaje.ebean.Query<T> setUseCache(boolean useCache) {
|
||||
return exprList.setUseCache(useCache);
|
||||
}
|
||||
|
||||
public ExpressionList<T> startsWith(String propertyName, String value) {
|
||||
return exprList.startsWith(propertyName, value);
|
||||
}
|
||||
|
||||
public ExpressionList<T> where() {
|
||||
return exprList.where();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package com.avaje.ebeaninternal.server.ldap.expression;
|
||||
|
||||
import com.avaje.ebean.event.BeanQueryRequest;
|
||||
import com.avaje.ebeaninternal.api.SpiExpressionRequest;
|
||||
|
||||
class LdLikeExpression extends LdAbstractExpression {
|
||||
|
||||
private static final long serialVersionUID = 4091359751840929076L;
|
||||
|
||||
private final String value;
|
||||
|
||||
public LdLikeExpression(String propertyName, String value) {
|
||||
super(propertyName);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getPropertyName() {
|
||||
return propertyName;
|
||||
}
|
||||
|
||||
public void addBindValues(SpiExpressionRequest request) {
|
||||
// Not using binding with wildcards
|
||||
}
|
||||
|
||||
public void addSql(SpiExpressionRequest request) {
|
||||
|
||||
String escapedValue;
|
||||
if (value == null) {
|
||||
escapedValue = "*";
|
||||
} else {
|
||||
escapedValue = LdEscape.forLike(value);
|
||||
}
|
||||
|
||||
String parsed = request.parseDeploy(propertyName);
|
||||
|
||||
request.append("(").append(parsed).append("=").append(escapedValue).append(")");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Based on the type and propertyName.
|
||||
*/
|
||||
public int queryAutoFetchHash() {
|
||||
int hc = LdLikeExpression.class.getName().hashCode();
|
||||
hc = hc * 31 + propertyName.hashCode();
|
||||
return hc;
|
||||
}
|
||||
|
||||
public int queryPlanHash(BeanQueryRequest<?> request) {
|
||||
return queryAutoFetchHash();
|
||||
}
|
||||
|
||||
public int queryBindHash() {
|
||||
return value.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
package com.avaje.ebeaninternal.server.ldap.expression;
|
||||
|
||||
import com.avaje.ebean.Expression;
|
||||
import com.avaje.ebean.event.BeanQueryRequest;
|
||||
import com.avaje.ebeaninternal.api.ManyWhereJoins;
|
||||
import com.avaje.ebeaninternal.api.SpiExpression;
|
||||
import com.avaje.ebeaninternal.api.SpiExpressionRequest;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
|
||||
/**
|
||||
* A logical And or Or for joining two expressions.
|
||||
*/
|
||||
abstract class LdLogicExpression implements SpiExpression {
|
||||
|
||||
private static final long serialVersionUID = 616860781960645251L;
|
||||
|
||||
static final String AND = "&";
|
||||
static final String OR = "|";
|
||||
|
||||
static class And extends LdLogicExpression {
|
||||
|
||||
private static final long serialVersionUID = -3832889676798526445L;
|
||||
|
||||
And(Expression expOne, Expression expTwo) {
|
||||
super(AND, expOne, expTwo);
|
||||
}
|
||||
}
|
||||
|
||||
static class Or extends LdLogicExpression {
|
||||
|
||||
private static final long serialVersionUID = -6871993143194094810L;
|
||||
|
||||
Or(Expression expOne, Expression expTwo) {
|
||||
super(OR, expOne, expTwo);
|
||||
}
|
||||
}
|
||||
|
||||
private final SpiExpression expOne;
|
||||
|
||||
private final SpiExpression expTwo;
|
||||
|
||||
private final String joinType;
|
||||
|
||||
LdLogicExpression(String joinType, Expression expOne, Expression expTwo) {
|
||||
this.joinType = joinType;
|
||||
this.expOne = (SpiExpression) expOne;
|
||||
this.expTwo = (SpiExpression) expTwo;
|
||||
}
|
||||
|
||||
public void containsMany(BeanDescriptor<?> desc, ManyWhereJoins manyWhereJoin) {
|
||||
expOne.containsMany(desc, manyWhereJoin);
|
||||
expTwo.containsMany(desc, manyWhereJoin);
|
||||
}
|
||||
|
||||
public void addBindValues(SpiExpressionRequest request) {
|
||||
expOne.addBindValues(request);
|
||||
expTwo.addBindValues(request);
|
||||
}
|
||||
|
||||
public void addSql(SpiExpressionRequest request) {
|
||||
|
||||
request.append("(");
|
||||
request.append(joinType);
|
||||
expOne.addSql(request);
|
||||
expTwo.addSql(request);
|
||||
request.append(") ");
|
||||
}
|
||||
|
||||
/**
|
||||
* Based on the joinType plus the two expressions.
|
||||
*/
|
||||
public int queryAutoFetchHash() {
|
||||
int hc = LdLogicExpression.class.getName().hashCode() + joinType.hashCode();
|
||||
hc = hc * 31 + expOne.queryAutoFetchHash();
|
||||
hc = hc * 31 + expTwo.queryAutoFetchHash();
|
||||
return hc;
|
||||
}
|
||||
|
||||
public int queryPlanHash(BeanQueryRequest<?> request) {
|
||||
int hc = LdLogicExpression.class.getName().hashCode() + joinType.hashCode();
|
||||
hc = hc * 31 + expOne.queryPlanHash(request);
|
||||
hc = hc * 31 + expTwo.queryPlanHash(request);
|
||||
return hc;
|
||||
}
|
||||
|
||||
public int queryBindHash() {
|
||||
int hc = expOne.queryBindHash();
|
||||
hc = hc * 31 + expTwo.queryBindHash();
|
||||
return hc;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package com.avaje.ebeaninternal.server.ldap.expression;
|
||||
|
||||
import com.avaje.ebean.Expression;
|
||||
import com.avaje.ebean.event.BeanQueryRequest;
|
||||
import com.avaje.ebeaninternal.api.ManyWhereJoins;
|
||||
import com.avaje.ebeaninternal.api.SpiExpression;
|
||||
import com.avaje.ebeaninternal.api.SpiExpressionRequest;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
|
||||
final class LdNotExpression implements SpiExpression {
|
||||
|
||||
private static final long serialVersionUID = 5648926732402355782L;
|
||||
|
||||
private static final String NOT = "!";
|
||||
|
||||
private final SpiExpression exp;
|
||||
|
||||
LdNotExpression(Expression exp) {
|
||||
this.exp = (SpiExpression) exp;
|
||||
}
|
||||
|
||||
public void containsMany(BeanDescriptor<?> desc, ManyWhereJoins manyWhereJoin) {
|
||||
exp.containsMany(desc, manyWhereJoin);
|
||||
}
|
||||
|
||||
public void addBindValues(SpiExpressionRequest request) {
|
||||
exp.addBindValues(request);
|
||||
}
|
||||
|
||||
public void addSql(SpiExpressionRequest request) {
|
||||
request.append("(");
|
||||
request.append(NOT);
|
||||
exp.addSql(request);
|
||||
request.append(")");
|
||||
}
|
||||
|
||||
/**
|
||||
* Based on the expression.
|
||||
*/
|
||||
public int queryAutoFetchHash() {
|
||||
int hc = LdNotExpression.class.getName().hashCode();
|
||||
hc = hc * 31 + exp.queryAutoFetchHash();
|
||||
return hc;
|
||||
}
|
||||
|
||||
public int queryPlanHash(BeanQueryRequest<?> request) {
|
||||
int hc = LdNotExpression.class.getName().hashCode();
|
||||
hc = hc * 31 + exp.queryPlanHash(request);
|
||||
return hc;
|
||||
}
|
||||
|
||||
public int queryBindHash() {
|
||||
return exp.queryBindHash();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.avaje.ebeaninternal.server.ldap.expression;
|
||||
|
||||
import com.avaje.ebean.event.BeanQueryRequest;
|
||||
import com.avaje.ebeaninternal.api.SpiExpressionRequest;
|
||||
|
||||
class LdPresentExpression extends LdAbstractExpression {
|
||||
|
||||
private static final long serialVersionUID = -4221300142054382003L;
|
||||
|
||||
public LdPresentExpression(String propertyName) {
|
||||
super(propertyName);
|
||||
}
|
||||
|
||||
public String getPropertyName() {
|
||||
return propertyName;
|
||||
}
|
||||
|
||||
public void addBindValues(SpiExpressionRequest request) {
|
||||
// no bind values
|
||||
}
|
||||
|
||||
public void addSql(SpiExpressionRequest request) {
|
||||
|
||||
String parsed = request.parseDeploy(propertyName);
|
||||
request.append("(").append(parsed).append("=*").append(")");
|
||||
}
|
||||
|
||||
/**
|
||||
* Based on the type and propertyName.
|
||||
*/
|
||||
public int queryAutoFetchHash() {
|
||||
int hc = LdPresentExpression.class.getName().hashCode();
|
||||
hc = hc * 31 + propertyName.hashCode();
|
||||
return hc;
|
||||
}
|
||||
|
||||
public int queryPlanHash(BeanQueryRequest<?> request) {
|
||||
return queryAutoFetchHash();
|
||||
}
|
||||
|
||||
public int queryBindHash() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.avaje.ebeaninternal.server.ldap.expression;
|
||||
|
||||
import com.avaje.ebean.event.BeanQueryRequest;
|
||||
import com.avaje.ebeaninternal.api.ManyWhereJoins;
|
||||
import com.avaje.ebeaninternal.api.SpiExpression;
|
||||
import com.avaje.ebeaninternal.api.SpiExpressionRequest;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
|
||||
class LdRawExpression implements SpiExpression {
|
||||
|
||||
private static final long serialVersionUID = 7973903141340334607L;
|
||||
|
||||
private final String rawExpr;
|
||||
|
||||
private final Object[] values;
|
||||
|
||||
LdRawExpression(String rawExpr, Object[] values) {
|
||||
this.rawExpr = rawExpr;
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
public void containsMany(BeanDescriptor<?> desc, ManyWhereJoins manyWhereJoin) {
|
||||
|
||||
}
|
||||
|
||||
public void addBindValues(SpiExpressionRequest request) {
|
||||
if (values != null) {
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
request.addBindValue(values[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addSql(SpiExpressionRequest request) {
|
||||
request.append(rawExpr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Based on the raw expression.
|
||||
*/
|
||||
public int queryAutoFetchHash() {
|
||||
int hc = LdRawExpression.class.getName().hashCode();
|
||||
hc = hc * 31 + rawExpr.hashCode();
|
||||
return hc;
|
||||
}
|
||||
|
||||
public int queryPlanHash(BeanQueryRequest<?> request) {
|
||||
return queryAutoFetchHash();
|
||||
}
|
||||
|
||||
public int queryBindHash() {
|
||||
return rawExpr.hashCode();
|
||||
}
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
package com.avaje.ebeaninternal.server.ldap.expression;
|
||||
|
||||
import com.avaje.ebean.event.BeanQueryRequest;
|
||||
import com.avaje.ebeaninternal.api.SpiExpressionRequest;
|
||||
import com.avaje.ebeaninternal.server.el.ElPropertyValue;
|
||||
import com.avaje.ebeaninternal.server.type.ScalarType;
|
||||
|
||||
class LdSimpleExpression extends LdAbstractExpression {
|
||||
|
||||
private static final long serialVersionUID = 4091359751840929075L;
|
||||
|
||||
enum Op {
|
||||
EQ {
|
||||
public String toString() {
|
||||
return "=";
|
||||
}
|
||||
},
|
||||
NOT_EQ {
|
||||
public String toString() {
|
||||
return "<>";
|
||||
}
|
||||
},
|
||||
LT {
|
||||
public String toString() {
|
||||
return "<";
|
||||
}
|
||||
},
|
||||
LT_EQ {
|
||||
public String toString() {
|
||||
return "<=";
|
||||
}
|
||||
},
|
||||
GT {
|
||||
public String toString() {
|
||||
return ">";
|
||||
}
|
||||
},
|
||||
GT_EQ {
|
||||
public String toString() {
|
||||
return ">=";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final Op type;
|
||||
|
||||
private final Object value;
|
||||
|
||||
public LdSimpleExpression(String propertyName, Op type, Object value) {
|
||||
super(propertyName);
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getPropertyName() {
|
||||
return propertyName;
|
||||
}
|
||||
|
||||
public void addBindValues(SpiExpressionRequest request) {
|
||||
|
||||
ElPropertyValue prop = getElProp(request);
|
||||
if (prop != null) {
|
||||
if (prop.isAssocId()) {
|
||||
Object[] ids = prop.getAssocOneIdValues(value);
|
||||
if (ids != null) {
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
request.addBindValue(ids[i]);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
ScalarType<?> scalarType = prop.getBeanProperty().getScalarType();
|
||||
Object v = scalarType.toJdbcType(value);
|
||||
request.addBindValue(v);
|
||||
} else {
|
||||
request.addBindValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
public void addSql(SpiExpressionRequest request) {
|
||||
ElPropertyValue prop = getElProp(request);
|
||||
if (prop != null) {
|
||||
if (prop.isAssocId()) {
|
||||
String rawExpr = prop.getAssocOneIdExpr(propertyName, type.toString());
|
||||
String parsed = request.parseDeploy(rawExpr);
|
||||
request.append(parsed);
|
||||
return;
|
||||
}
|
||||
}
|
||||
String parsed = request.parseDeploy(propertyName);
|
||||
|
||||
request.append("(").append(parsed).append("").append(type.toString()).append(nextParam(request)).append(")");
|
||||
}
|
||||
|
||||
/**
|
||||
* Based on the type and propertyName.
|
||||
*/
|
||||
public int queryAutoFetchHash() {
|
||||
int hc = LdSimpleExpression.class.getName().hashCode();
|
||||
hc = hc * 31 + propertyName.hashCode();
|
||||
hc = hc * 31 + type.name().hashCode();
|
||||
return hc;
|
||||
}
|
||||
|
||||
public int queryPlanHash(BeanQueryRequest<?> request) {
|
||||
return queryAutoFetchHash();
|
||||
}
|
||||
|
||||
public int queryBindHash() {
|
||||
return value.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
-249
@@ -1,249 +0,0 @@
|
||||
package com.avaje.ebeaninternal.server.ldap.expression;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.avaje.ebean.ExampleExpression;
|
||||
import com.avaje.ebean.Expression;
|
||||
import com.avaje.ebean.ExpressionFactory;
|
||||
import com.avaje.ebean.ExpressionList;
|
||||
import com.avaje.ebean.Junction;
|
||||
import com.avaje.ebean.LikeType;
|
||||
import com.avaje.ebean.Query;
|
||||
import com.avaje.ebeaninternal.server.ldap.LdapPersistenceException;
|
||||
import com.avaje.ebeaninternal.server.ldap.expression.LdSimpleExpression.Op;
|
||||
|
||||
public class LdapExpressionFactory implements ExpressionFactory {
|
||||
|
||||
public String getLang() {
|
||||
return "ldap";
|
||||
}
|
||||
|
||||
public ExpressionFactory createExpressionFactory(String path) {
|
||||
return new LdapExpressionFactory();
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
public Expression allEq(Map<String, Object> propertyMap) {
|
||||
|
||||
Junction conjunction = new LdJunctionExpression.Conjunction(this);
|
||||
|
||||
Iterator<Entry<String, Object>> it = propertyMap.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Entry<String, Object> entry = it.next();
|
||||
conjunction.add(eq(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
return conjunction;
|
||||
}
|
||||
|
||||
public Expression and(Expression expOne, Expression expTwo) {
|
||||
return new LdLogicExpression.And(expOne, expTwo);
|
||||
}
|
||||
|
||||
public Expression between(String propertyName, Object value1, Object value2) {
|
||||
Expression e1 = gt(propertyName, value1);
|
||||
Expression e2 = lt(propertyName, value2);
|
||||
return and(e1, e2);
|
||||
}
|
||||
|
||||
public Expression betweenProperties(String lowProperty, String highProperty, Object value) {
|
||||
throw new RuntimeException("Not Implemented");
|
||||
}
|
||||
|
||||
public Expression contains(String propertyName, String value) {
|
||||
if (!value.endsWith("*")){
|
||||
value = "*"+value+"*";
|
||||
}
|
||||
return new LdSimpleExpression(propertyName, Op.EQ, value);
|
||||
}
|
||||
|
||||
public <T> Junction<T> conjunction(Query<T> query) {
|
||||
return new LdJunctionExpression.Conjunction<T>(query, query.where());
|
||||
}
|
||||
|
||||
|
||||
public <T> Junction<T> disjunction(Query<T> query) {
|
||||
return new LdJunctionExpression.Disjunction<T>(query, query.where());
|
||||
}
|
||||
|
||||
public <T> Junction<T> conjunction(Query<T> query, ExpressionList<T> parent) {
|
||||
return new LdJunctionExpression.Conjunction<T>(query, parent);
|
||||
}
|
||||
|
||||
public <T> Junction<T> disjunction(Query<T> query, ExpressionList<T> parent) {
|
||||
return new LdJunctionExpression.Disjunction<T>(query, parent);
|
||||
}
|
||||
|
||||
public Expression endsWith(String propertyName, String value) {
|
||||
if (!value.startsWith("*")){
|
||||
value = "*"+value;
|
||||
}
|
||||
return new LdLikeExpression(propertyName, value);
|
||||
}
|
||||
|
||||
public Expression eq(String propertyName, Object value) {
|
||||
return new LdSimpleExpression(propertyName, Op.EQ, value);
|
||||
}
|
||||
|
||||
public Expression lucene(String propertyName, String value) {
|
||||
throw new RuntimeException("Not Implemented");
|
||||
}
|
||||
|
||||
public Expression lucene(String value) {
|
||||
throw new RuntimeException("Not Implemented");
|
||||
}
|
||||
|
||||
public ExampleExpression exampleLike(Object example, boolean caseInsensitive, LikeType likeType) {
|
||||
throw new RuntimeException("Not Implemented");
|
||||
}
|
||||
|
||||
public ExampleExpression exampleLike(Object example) {
|
||||
throw new RuntimeException("Not Implemented");
|
||||
}
|
||||
|
||||
public Expression ge(String propertyName, Object value) {
|
||||
return new LdSimpleExpression(propertyName, Op.GT_EQ, value);
|
||||
}
|
||||
|
||||
public Expression gt(String propertyName, Object value) {
|
||||
return new LdSimpleExpression(propertyName, Op.GT, value);
|
||||
}
|
||||
|
||||
public Expression icontains(String propertyName, String value) {
|
||||
if (!value.endsWith("*")){
|
||||
value = "*"+value+"*";
|
||||
}
|
||||
return new LdLikeExpression(propertyName, value);
|
||||
}
|
||||
|
||||
public Expression idEq(Object value) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public Expression idIn(List<?> idList) {
|
||||
throw new RuntimeException("Not Implemented");
|
||||
}
|
||||
|
||||
public Expression iendsWith(String propertyName, String value) {
|
||||
if (!value.startsWith("*")){
|
||||
value = "*"+value;
|
||||
}
|
||||
return new LdLikeExpression(propertyName, value);
|
||||
}
|
||||
|
||||
public Expression ieq(String propertyName, String value) {
|
||||
return new LdSimpleExpression(propertyName, Op.EQ, value);
|
||||
}
|
||||
|
||||
public ExampleExpression iexampleLike(Object example) {
|
||||
throw new RuntimeException("Not Implemented");
|
||||
}
|
||||
|
||||
public Expression ilike(String propertyName, String value) {
|
||||
return new LdLikeExpression(propertyName, value);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
public Expression in(String propertyName, Collection<?> values) {
|
||||
|
||||
if (values == null || values.isEmpty()){
|
||||
throw new LdapPersistenceException("collection can't be empty for Ldap");
|
||||
}
|
||||
|
||||
Junction disjunction = new LdJunctionExpression.Disjunction(this);
|
||||
for (Object v : values) {
|
||||
disjunction.add(eq(propertyName, v));
|
||||
}
|
||||
|
||||
return disjunction;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Expression in(String propertyName, Object[] values) {
|
||||
|
||||
if (values == null || values.length == 0){
|
||||
throw new LdapPersistenceException("values can't be empty for Ldap");
|
||||
}
|
||||
|
||||
Junction disjunction = new LdJunctionExpression.Disjunction(this);
|
||||
for (Object v : values) {
|
||||
disjunction.add(eq(propertyName, v));
|
||||
}
|
||||
|
||||
return disjunction;
|
||||
}
|
||||
|
||||
public Expression in(String propertyName, Query<?> subQuery) {
|
||||
throw new RuntimeException("Not Implemented");
|
||||
}
|
||||
|
||||
public Expression isNotNull(String propertyName) {
|
||||
return new LdPresentExpression(propertyName);
|
||||
}
|
||||
|
||||
public Expression isNull(String propertyName) {
|
||||
LdPresentExpression exp = new LdPresentExpression(propertyName);
|
||||
return new LdNotExpression(exp);
|
||||
}
|
||||
|
||||
public Expression istartsWith(String propertyName, String value) {
|
||||
if (!value.endsWith("*")){
|
||||
value = value+"*";
|
||||
}
|
||||
return new LdLikeExpression(propertyName, value);
|
||||
}
|
||||
|
||||
public Expression le(String propertyName, Object value) {
|
||||
return new LdSimpleExpression(propertyName, Op.LT_EQ, value);
|
||||
}
|
||||
|
||||
public Expression like(String propertyName, String value) {
|
||||
return new LdLikeExpression(propertyName, value);
|
||||
}
|
||||
|
||||
public Expression lt(String propertyName, Object value) {
|
||||
return new LdSimpleExpression(propertyName, Op.LT, value);
|
||||
}
|
||||
|
||||
public Expression ne(String propertyName, Object value) {
|
||||
return new LdSimpleExpression(propertyName, Op.NOT_EQ, value);
|
||||
}
|
||||
|
||||
public Expression not(Expression exp) {
|
||||
return new LdNotExpression(exp);
|
||||
}
|
||||
|
||||
public Expression or(Expression expOne, Expression expTwo) {
|
||||
return new LdLogicExpression.Or(expOne, expTwo);
|
||||
}
|
||||
|
||||
public Expression raw(String raw, Object value) {
|
||||
if (value != null){
|
||||
return new LdRawExpression(raw, new Object[]{value});
|
||||
|
||||
} else {
|
||||
return new LdRawExpression(raw, null);
|
||||
}
|
||||
}
|
||||
|
||||
public Expression raw(String raw, Object[] values) {
|
||||
return new LdRawExpression(raw, values);
|
||||
}
|
||||
|
||||
public Expression raw(String raw) {
|
||||
return new LdRawExpression(raw, null);
|
||||
}
|
||||
|
||||
public Expression startsWith(String propertyName, String value) {
|
||||
if (!value.endsWith("*")){
|
||||
value = value+"*";
|
||||
}
|
||||
return new LdLikeExpression(propertyName, value);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
package com.avaje.ebeaninternal.server.ldap.expression;
|
||||
@@ -1 +0,0 @@
|
||||
package com.avaje.ebeaninternal.server.ldap;
|
||||
Reference in New Issue
Block a user