mirror of https://github.com/apache/cloudstack.git
Changed SearchCriteria2 to GenericQueryBuilder to reflect the same placement
This commit is contained in:
parent
e8cac2c5d8
commit
38e69fb9f9
|
|
@ -44,6 +44,11 @@ public class GenericQueryBuilder<T, K> extends SearchBase<T, K> {
|
|||
return create(entityType, entityType);
|
||||
}
|
||||
|
||||
public GenericQueryBuilder<T, K> or() {
|
||||
constructCondition(null, " OR ", null, null);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void selectField(Object... useless) {
|
||||
assert _entity != null : "SearchBuilder cannot be modified once it has been setup";
|
||||
assert _specifiedAttrs.size() > 0 : "You didn't specify any attributes";
|
||||
|
|
@ -66,10 +71,48 @@ public class GenericQueryBuilder<T, K> extends SearchBase<T, K> {
|
|||
_specifiedAttrs.clear();
|
||||
}
|
||||
|
||||
public void and(Object useless, Op op, Object... values) {
|
||||
public GenericQueryBuilder<T, K> and(Object useless, Op op, Object... values) {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
Condition condition = constructCondition(uuid, " AND ", _specifiedAttrs.get(0), op);
|
||||
condition.setPresets(values);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GenericQueryBuilder<T, K> or(Object useless, Op op, Object... values) {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
Condition condition = constructCondition(uuid, " OR ", _specifiedAttrs.get(0), op);
|
||||
condition.setPresets(values);
|
||||
return this;
|
||||
}
|
||||
|
||||
protected GenericQueryBuilder<T, K> left(Object useless, Op op, Object... values) {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
Condition condition = constructCondition(uuid, " ( ", _specifiedAttrs.get(0), op);
|
||||
condition.setPresets(values);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GenericQueryBuilder<T, K> and() {
|
||||
constructCondition(null, " AND ", null, null);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GenericQueryBuilder<T, K> where() {
|
||||
return and();
|
||||
}
|
||||
|
||||
public GenericQueryBuilder<T, K> op(Object useless, Op op, Object... values) {
|
||||
return left(useless, op, values);
|
||||
}
|
||||
|
||||
protected GenericQueryBuilder<T, K> right() {
|
||||
Condition condition = new Condition("rp", " ) ", null, Op.RP);
|
||||
_conditions.add(condition);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GenericQueryBuilder<T, K> cp() {
|
||||
return right();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
@ -96,6 +139,4 @@ public class GenericQueryBuilder<T, K> extends SearchBase<T, K> {
|
|||
SearchCriteria sc1 = create();
|
||||
return (K)_dao.findOneBy(sc1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,6 +127,11 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T, K> {
|
|||
return this;
|
||||
}
|
||||
|
||||
public GenericSearchBuilder<T, K> and() {
|
||||
constructCondition(null, " AND ", null, null);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GenericSearchBuilder<T, K> and(Object useless, Op op, String name) {
|
||||
constructCondition(name, " AND ", _specifiedAttrs.get(0), op);
|
||||
return this;
|
||||
|
|
@ -137,24 +142,11 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T, K> {
|
|||
return new Preset(this, condition);
|
||||
}
|
||||
|
||||
public GenericSearchBuilder<T, K> and() {
|
||||
constructCondition(null, " AND ", null, null);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GenericSearchBuilder<T, K> where() {
|
||||
return and();
|
||||
}
|
||||
|
||||
public GenericSearchBuilder<T, K> or() {
|
||||
constructCondition(null, " OR ", null, null);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GenericSearchBuilder<T, K> where(String name, Object useless, Op op) {
|
||||
return and(name, useless, op);
|
||||
}
|
||||
|
||||
public GenericSearchBuilder<T, K> where(Object useless, Op op, String name) {
|
||||
return and(name, useless, op);
|
||||
}
|
||||
|
|
@ -163,17 +155,12 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T, K> {
|
|||
return and(useless, op);
|
||||
}
|
||||
|
||||
public GenericSearchBuilder<T, K> left(String name, Object useless, Op op) {
|
||||
constructCondition(name, " ( ", _specifiedAttrs.get(0), op);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GenericSearchBuilder<T, K> left(Object useless, Op op, String name) {
|
||||
protected GenericSearchBuilder<T, K> left(Object useless, Op op, String name) {
|
||||
constructCondition(name, " ( ", _specifiedAttrs.get(0), op);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Preset left(Object useless, Op op) {
|
||||
protected Preset left(Object useless, Op op) {
|
||||
Condition condition = constructCondition(UUID.randomUUID().toString(), " ( ", _specifiedAttrs.get(0), op);
|
||||
return new Preset(this, condition);
|
||||
}
|
||||
|
|
@ -187,21 +174,9 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T, K> {
|
|||
}
|
||||
|
||||
public GenericSearchBuilder<T, K> op(String name, Object useless, Op op) {
|
||||
return left(name, useless, op);
|
||||
return left(useless, op, name);
|
||||
}
|
||||
|
||||
public GenericSearchBuilder<T, K> openParen(Object useless, Op op, String name) {
|
||||
return left(name, useless, op);
|
||||
}
|
||||
|
||||
public GenericSearchBuilder<T, K> openParen(String name, Object useless, Op op) {
|
||||
return left(name, useless, op);
|
||||
}
|
||||
|
||||
public Preset openParen(Object useless, Op op) {
|
||||
return left(useless, op);
|
||||
}
|
||||
|
||||
public GroupBy<GenericSearchBuilder<T, K>, T, K> groupBy(Object... useless) {
|
||||
assert _groupBy == null : "Can't do more than one group bys";
|
||||
GroupBy<GenericSearchBuilder<T, K>, T, K> groupBy = new GroupBy<GenericSearchBuilder<T, K>, T, K>(this);
|
||||
|
|
@ -258,7 +233,7 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T, K> {
|
|||
return sc;
|
||||
}
|
||||
|
||||
public GenericSearchBuilder<T, K> right() {
|
||||
protected GenericSearchBuilder<T, K> right() {
|
||||
Condition condition = new Condition("rp", " ) ", null, Op.RP);
|
||||
_conditions.add(condition);
|
||||
return this;
|
||||
|
|
@ -268,10 +243,6 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T, K> {
|
|||
return right();
|
||||
}
|
||||
|
||||
public GenericSearchBuilder<T, K> closeParen() {
|
||||
return right();
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the SearchBuilder as completed in building the search conditions.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue