mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-23 07:11:55 +00:00
Remove LDAP and Validation objects - (removing these features)
This commit is contained in:
1 parent
cae8980652
commit
f04a4864e9
29 files changed
-2283
No files matched your search
@@ -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;
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.avaje.tests.ldap;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.avaje.ebean.EbeanServer;
|
||||
import com.avaje.ebean.EbeanServerFactory;
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebean.config.ldap.LdapConfig;
|
||||
import com.avaje.ebean.config.ldap.LdapContextFactory;
|
||||
|
||||
public abstract class BaseLdapTest extends TestCase {
|
||||
|
||||
public void one() {
|
||||
Assert.assertTrue(true);
|
||||
}
|
||||
|
||||
protected EbeanServer createServer() {
|
||||
|
||||
LdapContextFactory contextFactory = new MockContextFactory();
|
||||
|
||||
ServerConfig config = new ServerConfig();
|
||||
config.setName("h2");
|
||||
config.setRegister(false);
|
||||
config.setDefaultServer(false);
|
||||
config.loadFromProperties();
|
||||
|
||||
LdapConfig ldapConfig = new LdapConfig();
|
||||
|
||||
ldapConfig.setContextFactory(contextFactory);
|
||||
config.setLdapConfig(ldapConfig);
|
||||
|
||||
return EbeanServerFactory.create(config);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.avaje.tests.ldap;
|
||||
|
||||
import javax.naming.directory.DirContext;
|
||||
|
||||
import com.avaje.ebean.config.ldap.LdapContextFactory;
|
||||
|
||||
public class MockContextFactory implements LdapContextFactory {
|
||||
|
||||
public DirContext createContext() {
|
||||
return new MockDirContext();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,248 +0,0 @@
|
||||
package com.avaje.tests.ldap;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
import javax.naming.Binding;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.Name;
|
||||
import javax.naming.NameClassPair;
|
||||
import javax.naming.NameParser;
|
||||
import javax.naming.NamingEnumeration;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.Attributes;
|
||||
import javax.naming.directory.BasicAttributes;
|
||||
import javax.naming.directory.DirContext;
|
||||
import javax.naming.directory.ModificationItem;
|
||||
import javax.naming.directory.SearchControls;
|
||||
import javax.naming.directory.SearchResult;
|
||||
|
||||
public class MockDirContext implements DirContext {
|
||||
|
||||
public void bind(Name name, Object obj, Attributes attrs) throws NamingException {
|
||||
|
||||
}
|
||||
|
||||
public void bind(String name, Object obj, Attributes attrs) throws NamingException {
|
||||
|
||||
}
|
||||
|
||||
public DirContext createSubcontext(Name name, Attributes attrs) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public DirContext createSubcontext(String name, Attributes attrs) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Attributes getAttributes(Name name, String[] attrIds) throws NamingException {
|
||||
BasicAttributes a = new BasicAttributes();
|
||||
a.put("uid", "rbygraveTest01");
|
||||
return a;
|
||||
}
|
||||
|
||||
public Attributes getAttributes(Name name) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Attributes getAttributes(String name, String[] attrIds) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Attributes getAttributes(String name) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public DirContext getSchema(Name name) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public DirContext getSchema(String name) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public DirContext getSchemaClassDefinition(Name name) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public DirContext getSchemaClassDefinition(String name) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void modifyAttributes(Name name, int modOp, Attributes attrs) throws NamingException {
|
||||
|
||||
}
|
||||
|
||||
public void modifyAttributes(Name name, ModificationItem[] mods) throws NamingException {
|
||||
|
||||
}
|
||||
|
||||
public void modifyAttributes(String name, int modOp, Attributes attrs) throws NamingException {
|
||||
|
||||
}
|
||||
|
||||
public void modifyAttributes(String name, ModificationItem[] mods) throws NamingException {
|
||||
|
||||
}
|
||||
|
||||
public void rebind(Name name, Object obj, Attributes attrs) throws NamingException {
|
||||
|
||||
}
|
||||
|
||||
public void rebind(String name, Object obj, Attributes attrs) throws NamingException {
|
||||
|
||||
}
|
||||
|
||||
public NamingEnumeration<SearchResult> search(Name name, Attributes matchingAttributes, String[] attributesToReturn)
|
||||
throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public NamingEnumeration<SearchResult> search(Name name, Attributes matchingAttributes) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public NamingEnumeration<SearchResult> search(Name name, String filterExpr, Object[] filterArgs, SearchControls cons)
|
||||
throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public NamingEnumeration<SearchResult> search(Name name, String filter, SearchControls cons) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public NamingEnumeration<SearchResult> search(String name, Attributes matchingAttributes,
|
||||
String[] attributesToReturn) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public NamingEnumeration<SearchResult> search(String name, Attributes matchingAttributes) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public NamingEnumeration<SearchResult> search(String name, String filterExpr, Object[] filterArgs,
|
||||
SearchControls cons) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public NamingEnumeration<SearchResult> search(String name, String filter, SearchControls cons)
|
||||
throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object addToEnvironment(String propName, Object propVal) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void bind(Name name, Object obj) throws NamingException {
|
||||
|
||||
}
|
||||
|
||||
public void bind(String name, Object obj) throws NamingException {
|
||||
|
||||
}
|
||||
|
||||
public void close() throws NamingException {
|
||||
|
||||
}
|
||||
|
||||
public Name composeName(Name name, Name prefix) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String composeName(String name, String prefix) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Context createSubcontext(Name name) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Context createSubcontext(String name) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void destroySubcontext(Name name) throws NamingException {
|
||||
|
||||
}
|
||||
|
||||
public void destroySubcontext(String name) throws NamingException {
|
||||
|
||||
}
|
||||
|
||||
public Hashtable<?, ?> getEnvironment() throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getNameInNamespace() throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public NameParser getNameParser(Name name) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public NameParser getNameParser(String name) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object lookup(Name name) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object lookup(String name) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object lookupLink(Name name) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object lookupLink(String name) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void rebind(Name name, Object obj) throws NamingException {
|
||||
|
||||
}
|
||||
|
||||
public void rebind(String name, Object obj) throws NamingException {
|
||||
|
||||
}
|
||||
|
||||
public Object removeFromEnvironment(String propName) throws NamingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void rename(Name oldName, Name newName) throws NamingException {
|
||||
|
||||
}
|
||||
|
||||
public void rename(String oldName, String newName) throws NamingException {
|
||||
|
||||
}
|
||||
|
||||
public void unbind(Name name) throws NamingException {
|
||||
|
||||
}
|
||||
|
||||
public void unbind(String name) throws NamingException {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.avaje.tests.ldap;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.DirContext;
|
||||
import javax.naming.directory.InitialDirContext;
|
||||
|
||||
import com.avaje.ebean.config.ldap.LdapContextFactory;
|
||||
|
||||
public class SimpleContextFactory implements LdapContextFactory {
|
||||
|
||||
String url;
|
||||
String principal;
|
||||
String credentials;
|
||||
|
||||
public SimpleContextFactory(String url, String principal, String credentials) {
|
||||
this.url = url;
|
||||
this.principal = principal;
|
||||
this.credentials = credentials;
|
||||
}
|
||||
|
||||
public DirContext createContext() {
|
||||
|
||||
Hashtable<String, String> env = new Hashtable<String, String>();
|
||||
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
|
||||
env.put(Context.PROVIDER_URL, url);
|
||||
env.put(Context.SECURITY_AUTHENTICATION, "simple");
|
||||
env.put(Context.SECURITY_PRINCIPAL, principal);
|
||||
env.put(Context.SECURITY_CREDENTIALS, credentials);
|
||||
|
||||
try {
|
||||
return new InitialDirContext(env);
|
||||
} catch (NamingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.avaje.tests.ldap;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.naming.NamingEnumeration;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.Attribute;
|
||||
import javax.naming.directory.BasicAttribute;
|
||||
|
||||
import com.avaje.ebean.config.ldap.LdapAttributeAdapter;
|
||||
|
||||
public class SimpleLdapSetAdapater implements LdapAttributeAdapter {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Attribute createAttribute(Object beanPropertyValue) {
|
||||
Set<Long> set = (Set<Long>)beanPropertyValue;
|
||||
|
||||
BasicAttribute attr = new BasicAttribute("accounts");
|
||||
|
||||
for (Long accVal : set) {
|
||||
attr.add("acct="+accVal);
|
||||
}
|
||||
|
||||
return attr;
|
||||
}
|
||||
|
||||
public Object readAttribute(Attribute attribute) throws NamingException {
|
||||
|
||||
HashSet<Long> set = new HashSet<Long>();
|
||||
|
||||
NamingEnumeration<?> all = attribute.getAll();
|
||||
while (all.hasMoreElements()) {
|
||||
String s = (String)all.nextElement();
|
||||
// just trim off the first 5 characters
|
||||
s = s.substring(5);
|
||||
set.add(new Long(s));
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package com.avaje.tests.ldap;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.naming.directory.Attribute;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import com.avaje.ebean.EbeanServer;
|
||||
import com.avaje.ebean.config.GlobalProperties;
|
||||
import com.avaje.ebeaninternal.api.SpiEbeanServer;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor.EntityType;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanProperty;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanPropertySimpleCollection;
|
||||
import com.avaje.ebeaninternal.server.type.ScalarType;
|
||||
import com.avaje.ebeaninternal.server.type.ScalarTypeLdapTimestamp;
|
||||
import com.avaje.tests.model.ldap.LDPerson;
|
||||
|
||||
|
||||
public class TestLDPersonDeploy extends BaseLdapTest {
|
||||
|
||||
public void test() {
|
||||
|
||||
boolean b = true;
|
||||
if (b){
|
||||
// turn this test off for the moment
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
GlobalProperties.put("ebean.classes", LDPerson.class.toString());
|
||||
|
||||
EbeanServer server = createServer();
|
||||
SpiEbeanServer spiServer = (SpiEbeanServer)server;
|
||||
|
||||
BeanDescriptor<LDPerson> descriptor = spiServer.getBeanDescriptor(LDPerson.class);
|
||||
Assert.assertTrue(EntityType.LDAP.equals(descriptor.getEntityType()));
|
||||
|
||||
BeanProperty beanProperty = descriptor.getBeanProperty("modifiedTime");
|
||||
|
||||
Assert.assertEquals("modifiedTime", beanProperty.getName());
|
||||
Assert.assertEquals("modifiedTime", beanProperty.getDbColumn());
|
||||
|
||||
ScalarType<?> scalarType = beanProperty.getScalarType();
|
||||
Assert.assertTrue(scalarType instanceof ScalarTypeLdapTimestamp<?>);
|
||||
|
||||
BeanProperty accountsProp = descriptor.getBeanProperty("accounts");
|
||||
Assert.assertTrue(accountsProp instanceof BeanPropertySimpleCollection<?>);
|
||||
|
||||
LDPerson person = new LDPerson();
|
||||
person.addAccount(1001);
|
||||
person.addAccount(1002);
|
||||
person.addAccount(1003);
|
||||
|
||||
Attribute acctAttribute = accountsProp.createAttribute(person);
|
||||
Assert.assertTrue(acctAttribute.size() == 3);
|
||||
|
||||
LDPerson newPerson = new LDPerson();
|
||||
|
||||
accountsProp.setAttributeValue(newPerson, acctAttribute);
|
||||
Set<Long> accounts = newPerson.getAccounts();
|
||||
|
||||
Assert.assertTrue(accounts.size() == 3);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
package com.avaje.tests.ldap;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.avaje.ebean.EbeanServer;
|
||||
import com.avaje.ebean.EbeanServerFactory;
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebean.config.ldap.LdapConfig;
|
||||
import com.avaje.ebean.config.ldap.LdapContextFactory;
|
||||
import com.avaje.tests.model.ldap.LDPerson;
|
||||
import com.avaje.tests.model.ldap.LDPerson.Status;
|
||||
|
||||
public class TestLdapQuery extends TestCase {
|
||||
|
||||
public void test() throws NamingException {
|
||||
|
||||
boolean b = true;
|
||||
if (b){
|
||||
// turn this test off for the moment
|
||||
return;
|
||||
}
|
||||
|
||||
// GlobalProperties.put("ebean.ldapContextFactory", MockContextFactory.class.getName());
|
||||
|
||||
ServerConfig config = new ServerConfig();
|
||||
config.setName("ldap");
|
||||
config.setRegister(false);
|
||||
config.setDefaultServer(false);
|
||||
config.loadFromProperties();
|
||||
|
||||
// // built automatically from ebean.ldapContextFactory
|
||||
// LdapContextFactory ldapContextFactory = config.getLdapConfig().getContextFactory();
|
||||
// Assert.assertNotNull(ldapContextFactory);
|
||||
|
||||
LdapContextFactory contextFactory = new MockContextFactory();
|
||||
|
||||
LdapConfig ldapConfig = new LdapConfig();
|
||||
ldapConfig.setContextFactory(contextFactory);
|
||||
config.setLdapConfig(ldapConfig);
|
||||
config.getDataSourceConfig().setOffline(true);
|
||||
config.setDatabasePlatformName("oracle");
|
||||
|
||||
EbeanServer server = EbeanServerFactory.create(config);
|
||||
|
||||
LDPerson pRob = server.find(LDPerson.class)
|
||||
.select("userId, cn")
|
||||
.setId("rbygraveTest01")
|
||||
.findUnique();
|
||||
|
||||
Assert.assertNotNull(pRob);
|
||||
|
||||
List<LDPerson> list = server.find(LDPerson.class)
|
||||
.select("userId,status")
|
||||
.where().like("userId","lz*").eq("status", LDPerson.Status.ACTIVE)
|
||||
.findList();
|
||||
|
||||
System.out.println(list);
|
||||
|
||||
LDPerson p = new LDPerson();
|
||||
p.setUserId("rbygraveTest01");
|
||||
p.setStatus(Status.ACTIVE);
|
||||
p.setCn("Test01");
|
||||
p.setSn("Testing123");
|
||||
p.setGivenName("Ban Dana");
|
||||
p.setUserPassword("qwerty");
|
||||
|
||||
server.save(p);
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.avaje.tests.ldap;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import com.avaje.ebean.EbeanServer;
|
||||
import com.avaje.ebean.Query;
|
||||
import com.avaje.ebeaninternal.api.SpiEbeanServer;
|
||||
import com.avaje.ebeaninternal.api.SpiQuery;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.ebeaninternal.server.ldap.LdapOrmQueryRequest;
|
||||
import com.avaje.ebeaninternal.server.ldap.LdapQueryDeployHelper;
|
||||
import com.avaje.tests.model.ldap.LDPerson;
|
||||
|
||||
public class TestLdapQueryParse extends BaseLdapTest{
|
||||
|
||||
public void test() {
|
||||
|
||||
boolean b = true;
|
||||
if (b){
|
||||
// turn this test off for the moment
|
||||
return;
|
||||
}
|
||||
|
||||
EbeanServer server = createServer();
|
||||
|
||||
Query<LDPerson> query = server.createQuery(LDPerson.class);
|
||||
query.select("uid, cn, status");
|
||||
query.where("(cn=rob*)");
|
||||
query.where()
|
||||
.raw("(inetUserStatus=Banana)")
|
||||
.eq("status", LDPerson.Status.ACTIVE)
|
||||
.eq("sn", "bana");
|
||||
|
||||
SpiQuery<LDPerson> sq = (SpiQuery<LDPerson>)query;
|
||||
|
||||
SpiEbeanServer spiServer = (SpiEbeanServer)server;
|
||||
BeanDescriptor<LDPerson> desc = spiServer.getBeanDescriptor(LDPerson.class);
|
||||
LdapOrmQueryRequest<LDPerson> req = new LdapOrmQueryRequest<LDPerson>(sq, desc, null);
|
||||
|
||||
LdapQueryDeployHelper deployHelper = new LdapQueryDeployHelper(req);
|
||||
|
||||
String[] sp = deployHelper.getSelectedProperties();
|
||||
String filterExpr = deployHelper.getFilterExpr();
|
||||
Object[] filterVals = deployHelper.getFilterValues();
|
||||
|
||||
System.out.println("filterExpr: "+filterExpr);
|
||||
System.out.println("filterVals: "+Arrays.toString(filterVals));
|
||||
Assert.assertNotNull(sp);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.avaje.tests.ldap;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.joda.time.LocalDateTime;
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.avaje.ebeaninternal.server.type.ScalarTypeJodaLocalDateTime;
|
||||
import com.avaje.ebeaninternal.server.type.ScalarTypeLdapTimestamp;
|
||||
|
||||
public class TestLdapTimestamp extends TestCase {
|
||||
|
||||
|
||||
public void test() {
|
||||
|
||||
ScalarTypeJodaLocalDateTime bt = new ScalarTypeJodaLocalDateTime();
|
||||
|
||||
ScalarTypeLdapTimestamp<LocalDateTime> s = new ScalarTypeLdapTimestamp<LocalDateTime>(bt);
|
||||
|
||||
LocalDateTime now = new LocalDateTime();
|
||||
Object v = s.toJdbcType(now);
|
||||
|
||||
Assert.assertNotNull(v);
|
||||
Assert.assertTrue(v instanceof String);
|
||||
|
||||
Object convertBack = s.toBeanType(v);
|
||||
Assert.assertTrue(convertBack instanceof LocalDateTime);
|
||||
// Not equals due to loss of precision in LDAP format
|
||||
//Assert.assertEquals(now, convertBack);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
package com.avaje.tests.model.ldap;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.Id;
|
||||
|
||||
import org.joda.time.LocalDateTime;
|
||||
|
||||
import com.avaje.ebean.annotation.EnumValue;
|
||||
import com.avaje.ebean.annotation.LdapAttribute;
|
||||
import com.avaje.ebean.annotation.LdapDomain;
|
||||
import com.avaje.tests.ldap.SimpleLdapSetAdapater;
|
||||
|
||||
@LdapDomain(
|
||||
baseDn = "ou=avajepeople,o=avajecustomers,dc=avaje,dc=net,dc=nz",
|
||||
objectclass = "top,organizationalperson,avajeperson,inetadmin,inetorgperson,person,inetuser")
|
||||
@Entity
|
||||
public class LDPerson {
|
||||
|
||||
public enum Status {
|
||||
@EnumValue(value = "Active")
|
||||
ACTIVE,
|
||||
|
||||
@EnumValue(value = "Inactive")
|
||||
INACTIVE
|
||||
}
|
||||
|
||||
@Id
|
||||
@Column(name = "uid")
|
||||
private String userId;
|
||||
|
||||
@Column(name = "inetUserStatus")
|
||||
private Status status;
|
||||
|
||||
private String cn;
|
||||
|
||||
private String sn;
|
||||
|
||||
private String givenName;
|
||||
|
||||
private String userPassword;
|
||||
|
||||
@Basic(fetch=FetchType.LAZY)
|
||||
private LocalDateTime modifiedTime;
|
||||
|
||||
@Basic(fetch=FetchType.LAZY)
|
||||
@LdapAttribute(adapter=SimpleLdapSetAdapater.class)
|
||||
private Set<Long> accounts;
|
||||
|
||||
public String toString() {
|
||||
return userId + " " + status;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Status status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getCn() {
|
||||
return cn;
|
||||
}
|
||||
|
||||
public void setCn(String cn) {
|
||||
this.cn = cn;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public String getGivenName() {
|
||||
return givenName;
|
||||
}
|
||||
|
||||
public void setGivenName(String givenName) {
|
||||
this.givenName = givenName;
|
||||
}
|
||||
|
||||
public String getUserPassword() {
|
||||
return userPassword;
|
||||
}
|
||||
|
||||
public void setUserPassword(String userPassword) {
|
||||
this.userPassword = userPassword;
|
||||
}
|
||||
|
||||
public LocalDateTime getModifiedTime() {
|
||||
return modifiedTime;
|
||||
}
|
||||
|
||||
public void setModifiedTime(LocalDateTime modifiedTime) {
|
||||
this.modifiedTime = modifiedTime;
|
||||
}
|
||||
|
||||
public Set<Long> getAccounts() {
|
||||
return accounts;
|
||||
}
|
||||
|
||||
public void setAccounts(Set<Long> accounts) {
|
||||
this.accounts = accounts;
|
||||
}
|
||||
|
||||
public void addAccount(long accountNumber){
|
||||
if (accounts == null){
|
||||
accounts = new HashSet<Long>();
|
||||
}
|
||||
accounts.add(accountNumber);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user