本文整理了Java中org.intermine.objectstore.query.Query.addToOrderBy
方法的一些代码示例,展示了Query.addToOrderBy
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.addToOrderBy
方法的具体详情如下:
包路径:org.intermine.objectstore.query.Query
类名称:Query
方法名:addToOrderBy
[英]Add a QueryOrderable to the ORDER BY clause of this Query
[中]将QueryOrderable添加到此查询的ORDER BY子句中
代码示例来源:origin: intermine/intermine
/**
* Return a List containing clones of the given Query, but with all permutations
* of order by for the QueryClass objects on the from list.
*
* @param q the Query
* @return clones of the Query with all permutations of orderBy
*/
private static List<Query> getOrderedQueries(Query q) {
List<Query> queryList = new ArrayList<Query>();
Set<int[]> permutations = permutations(q.getEffectiveOrderBy().size());
for (int[] order : permutations) {
Query newQuery = QueryCloner.cloneQuery(q);
List<Object> orderBy = new ArrayList<Object>(newQuery.getEffectiveOrderBy());
newQuery.clearOrderBy();
for (int i = 0; i < order.length; i++) {
newQuery.addToOrderBy((QueryClass) orderBy.get(order[i]));
}
queryList.add(newQuery);
}
return queryList;
}
代码示例来源:origin: org.intermine/intermine-objectstore
/**
* Return a List containing clones of the given Query, but with all permutations
* of order by for the QueryClass objects on the from list.
*
* @param q the Query
* @return clones of the Query with all permutations of orderBy
*/
private static List<Query> getOrderedQueries(Query q) {
List<Query> queryList = new ArrayList<Query>();
Set<int[]> permutations = permutations(q.getEffectiveOrderBy().size());
for (int[] order : permutations) {
Query newQuery = QueryCloner.cloneQuery(q);
List<Object> orderBy = new ArrayList<Object>(newQuery.getEffectiveOrderBy());
newQuery.clearOrderBy();
for (int i = 0; i < order.length; i++) {
newQuery.addToOrderBy((QueryClass) orderBy.get(order[i]));
}
queryList.add(newQuery);
}
return queryList;
}
代码示例来源:origin: intermine/intermine
/**
* Processes an AST node that describes a ORDER BY clause.
*
* @param ast an AST node to process
* @param modelPackage the package for unqualified class names
* @param iterator an iterator through the list of parameters of the IqlQuery
*/
private static void processOrderClause(AST ast, Query q, String modelPackage,
Iterator<?> iterator) {
do {
QueryOrderable qo = (QueryOrderable) processNewQueryNodeOrReference(ast, q, false,
modelPackage, iterator);
for (QuerySelectable qs : q.getSelect()) {
if (qo.equals(qs)) {
qo = (QueryOrderable) qs;
break;
}
}
q.addToOrderBy(qo);
ast = ast.getNextSibling();
} while (ast != null);
}
代码示例来源:origin: intermine/intermine
public void testMakeQueryOneField() throws Exception {
Map<String, PathQuery> queries = readQueries();
PathQuery pq = queries.get("employeeName");
Query q = new Query();
QueryClass qc1 = new QueryClass(Employee.class);
q.addToSelect(qc1);
q.addFrom(qc1);
q.addToOrderBy(new QueryField(qc1, "name"));
assertEquals(q.toString(), MainHelper.makeQuery(pq, new HashMap(), null, bagQueryRunner, new HashMap()).toString());
}
代码示例来源:origin: intermine/intermine
public static Query selectClassAndSubClasses() throws Exception {
QueryClass qc1 = new QueryClass(Employee.class);
Query q1 = new Query();
q1.addToSelect(qc1);
q1.addFrom(qc1);
QueryField f1 = new QueryField(qc1, "name");
q1.addToOrderBy(f1);
return q1;
}
代码示例来源:origin: intermine/intermine
public static Query orderByReference() throws Exception {
Query q = new Query();
QueryClass qc = new QueryClass(Employee.class);
q.addFrom(qc);
q.addToSelect(qc);
q.addToOrderBy(new QueryObjectReference(qc, "department"));
return q;
}
代码示例来源:origin: intermine/intermine
public static Query orderByReference() throws Exception {
Query q = new Query();
QueryClass qc = new QueryClass(Employee.class);
q.addFrom(qc);
q.addToSelect(qc);
q.addToOrderBy(new QueryObjectReference(qc, "department"));
return q;
}
代码示例来源:origin: intermine/intermine
public static Query selectClassAndSubClasses() throws Exception {
QueryClass qc1 = new QueryClass(Employee.class);
Query q1 = new Query();
q1.addToSelect(qc1);
q1.addFrom(qc1);
QueryField f1 = new QueryField(qc1, "name");
q1.addToOrderBy(f1);
return q1;
}
代码示例来源:origin: intermine/intermine
public static Query orderDescending() throws Exception {
Query q = new Query();
q.setDistinct(false);
QueryClass qc = new QueryClass(Employee.class);
q.addFrom(qc);
q.addToSelect(qc);
q.addToOrderBy(new OrderDescending(qc));
return q;
}
代码示例来源:origin: intermine/intermine
public static Query orderDescending() throws Exception {
Query q = new Query();
q.setDistinct(false);
QueryClass qc = new QueryClass(Employee.class);
q.addFrom(qc);
q.addToSelect(qc);
q.addToOrderBy(new OrderDescending(qc));
return q;
}
代码示例来源:origin: intermine/intermine
public static Query failDistinctOrder() throws Exception {
Query q = new Query();
QueryClass qc = new QueryClass(Employee.class);
q.addFrom(qc);
q.addToSelect(new QueryField(qc, "name"));
q.addToOrderBy(new QueryField(qc, "age"));
q.setDistinct(true);
return q;
}
代码示例来源:origin: intermine/intermine
public static Query failDistinctOrder() throws Exception {
Query q = new Query();
QueryClass qc = new QueryClass(Employee.class);
q.addFrom(qc);
q.addToSelect(new QueryField(qc, "name"));
q.addToOrderBy(new QueryField(qc, "age"));
q.setDistinct(true);
return q;
}
代码示例来源:origin: intermine/intermine
public void testGetOrderBy() {
Query q = new Query();
QueryClass qc1 = new QueryClass(Employee.class);
QueryClass qc2 = new QueryClass(Department.class);
QueryField qf1 = new QueryField(qc1, "name");
QueryField qf2 = new QueryField(qc1, "age");
QueryField qf3 = new QueryField(qc2, "id");
QueryField qf4 = new QueryField(qc2, "name");
q.addFrom(qc1);
q.addFrom(qc2);
q.addToOrderBy(qf1);
q.addToSelect(qc1);
q.addToSelect(qf2);
q.addToSelect(qf3);
q.addToSelect(qc2);
q.addToSelect(qf4);
List expected = new ArrayList();
expected.add(qf1);
expected.add(qc1);
expected.add(qf3);
assertEquals(expected, q.getEffectiveOrderBy());
}
代码示例来源:origin: intermine/intermine
public static Query failDistinctOrder2() throws Exception {
Query q = new Query();
QueryClass qc1 = new QueryClass(Employee.class);
QueryClass qc2 = new QueryClass(Department.class);
q.addFrom(qc1);
q.addFrom(qc2);
q.addToSelect(qc1);
q.addToOrderBy(qc2);
q.setConstraint(new ContainsConstraint(new QueryObjectReference(qc1, "department"), ConstraintOp.CONTAINS, qc2));
q.setDistinct(true);
return q;
}
代码示例来源:origin: intermine/intermine
public static Query failDistinctOrder2() throws Exception {
Query q = new Query();
QueryClass qc1 = new QueryClass(Employee.class);
QueryClass qc2 = new QueryClass(Department.class);
q.addFrom(qc1);
q.addFrom(qc2);
q.addToSelect(qc1);
q.addToOrderBy(qc2);
q.setConstraint(new ContainsConstraint(new QueryObjectReference(qc1, "department"), ConstraintOp.CONTAINS, qc2));
q.setDistinct(true);
return q;
}
代码示例来源:origin: intermine/intermine
public void testNullReference() throws Exception {
PathQuery pq = new PathQuery(os.getModel());
pq.addView("Department.name");
pq.addConstraint(new PathConstraintNull("Department.company", ConstraintOp.IS_NULL));
Query expected = new Query();
QueryClass qc = new QueryClass(Department.class);
expected.addFrom(qc);
expected.addToSelect(qc);
QueryObjectReference ref = new QueryObjectReference(qc, "company");
ContainsConstraint cc = new ContainsConstraint(ref, ConstraintOp.IS_NULL);
expected.setConstraint(cc);
expected.addToOrderBy(new QueryField(qc, "name"));
Query actual = MainHelper.makeQuery(pq, new HashMap(), null, bagQueryRunner, new HashMap());
assertEquals(expected.toString(), actual.toString());
// Same test for IS_NOT_NULL
pq = new PathQuery(os.getModel());
pq.addView("Department.name");
pq.addConstraint(new PathConstraintNull("Department.company", ConstraintOp.IS_NOT_NULL));
cc = new ContainsConstraint(ref, ConstraintOp.IS_NOT_NULL);
expected.setConstraint(cc);
actual = MainHelper.makeQuery(pq, new HashMap(), null, bagQueryRunner, new HashMap());
assertEquals(expected.toString(), actual.toString());
}
代码示例来源:origin: intermine/intermine
public static Query whereSubQueryField() throws Exception {
QueryClass c1 = new QueryClass(Department.class);
QueryField f1 = new QueryField(c1, "name");
Query q1 = new Query();
q1.addFrom(c1);
q1.addToSelect(f1);
QueryClass c2 = new QueryClass(Department.class);
QueryField f2 = new QueryField(c2, "name");
SubqueryConstraint sqc1 = new SubqueryConstraint(f2, ConstraintOp.IN, q1);
Query q2 = new Query();
q2.addFrom(c2);
q2.addToSelect(c2);
q2.setConstraint(sqc1);
q2.addToOrderBy(f2);
return q2;
}
代码示例来源:origin: intermine/intermine
public static Query whereSubQueryField() throws Exception {
QueryClass c1 = new QueryClass(Department.class);
QueryField f1 = new QueryField(c1, "name");
Query q1 = new Query();
q1.addFrom(c1);
q1.addToSelect(f1);
QueryClass c2 = new QueryClass(Department.class);
QueryField f2 = new QueryField(c2, "name");
SubqueryConstraint sqc1 = new SubqueryConstraint(f2, ConstraintOp.IN, q1);
Query q2 = new Query();
q2.addFrom(c2);
q2.addToSelect(c2);
q2.setConstraint(sqc1);
q2.addToOrderBy(f2);
return q2;
}
代码示例来源:origin: intermine/intermine
public void testRegisterOffset4() throws Exception {
DatabaseSchema schema = getSchema();
Query q = new Query();
QueryClass qc = new QueryClass(Employee.class);
q.addFrom(qc);
QueryField f = new QueryField(qc, "name");
q.addToSelect(f);
q.addToOrderBy(new OrderDescending(f));
assertEquals("SELECT DISTINCT a1_.name AS a2_ FROM " + getRegisterOffset3() + " ORDER BY a1_.name DESC", SqlGenerator.generate(q, 0, Integer.MAX_VALUE, schema, db, Collections.EMPTY_MAP));
SqlGenerator.registerOffset(q, 5, schema, db, "flibble", Collections.EMPTY_MAP);
assertEquals("SELECT DISTINCT a1_.name AS a2_ FROM " + getRegisterOffset3() + " " + getRegisterOffset4() + " a1_.name < 'flibble' ORDER BY a1_.name DESC OFFSET 5", SqlGenerator.generate(q, 10, Integer.MAX_VALUE, schema, db, Collections.EMPTY_MAP));
}
代码示例来源:origin: intermine/intermine
public final void setUp() throws Exception {
query = new Query();
assertNotNull("Problem creating Query instance", query);
// set up three queries for testing .equals() and .hashCode()
QueryClass qc1 = new QueryClass(Company.class);
QueryField qf1 = new QueryField(qc1, "name");
QueryField qf2 = new QueryField(qc1, "vatNumber");
QueryFunction f1 = new QueryFunction(); // count(*)
QueryValue qv1 = new QueryValue("CompanyA");
SimpleConstraint sc1 = new SimpleConstraint(qf1, ConstraintOp.NOT_EQUALS, qv1);
clearQuery = new Query();
clearQuery.addToSelect(qc1);
clearQuery.addToSelect(f1);
clearQuery.setConstraint(sc1);
clearQuery.addToGroupBy(qc1);
clearQuery.addToOrderBy(qf1);
}
内容来源于网络,如有侵权,请联系作者删除!