org.intermine.objectstore.query.Query.toString()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.intermine.objectstore.query.Query.toString方法的一些代码示例,展示了Query.toString的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.toString方法的具体详情如下:
包路径:org.intermine.objectstore.query.Query
类名称:Query
方法名:toString

Query.toString介绍

[英]Returns a string representation of this Query object
[中]返回此查询对象的字符串表示形式

代码示例

代码示例来源:origin: intermine/intermine

/**
   * {@inheritDoc}
   */
  public int compareTo(Job job) {
    long thisTime = info.getComplete();
    long otherTime = job.info.getComplete();
    return (otherTime > thisTime ? 1 : (otherTime < thisTime ? -1
          : query.toString().compareTo(job.query.toString())));
  }
}

代码示例来源:origin: org.intermine/intermine-objectstore

/**
   * {@inheritDoc}
   */
  public int compareTo(Job job) {
    long thisTime = info.getComplete();
    long otherTime = job.info.getComplete();
    return (otherTime > thisTime ? 1 : (otherTime < thisTime ? -1
          : query.toString().compareTo(job.query.toString())));
  }
}

代码示例来源:origin: intermine/intermine

public void testGetPrecomputeQuery2() throws Exception {
    TemplateQuery t = (TemplateQuery) templates.get("InnerInsideOuter");
    assertEquals("SELECT DISTINCT a1_, a1_.departments(SELECT default, a1_, a1_.name FROM org.intermine.model.testmodel.Manager AS a1_ WHERE default.manager CONTAINS a1_) AS a2_, a1_.name AS a3_ FROM org.intermine.model.testmodel.Company AS a1_ ORDER BY a1_.name", TemplatePrecomputeHelper.getPrecomputeQuery(t, new ArrayList<Object>()).toString());
  }
}

代码示例来源:origin: intermine/intermine

public void testGetPrecomputeLookup() throws Exception {
  Reader reader = new StringReader("<template name=\"ManagerLookup\" title=\"Search for Managers\" longDescription=\"Use a LOOKUP constraint to search for Managers.\" comment=\"\">\n" +
  "  <query name=\"ManagerLookup\" model=\"testmodel\" view=\"Manager.name Manager.title\">\n" +
  "    <constraint path=\"Manager\" editable=\"true\" code=\"A\" op=\"LOOKUP\" value=\"Mr.\"/>\n" +
  "  </query>\n" +
  "</template>");
  TemplateQuery t =
    (TemplateQuery) TemplateQueryBinding.unmarshalTemplates(reader, PathQuery.USERPROFILE_VERSION).values().iterator().next();
  Query precomputeQuery = TemplatePrecomputeHelper.getPrecomputeQuery(t, new ArrayList<Object>());
  String expected = "SELECT DISTINCT a1_, a1_.id AS a2_, a1_.name AS a3_, a1_.title AS a4_ FROM org.intermine.model.testmodel.Manager AS a1_ ORDER BY a1_.name, a1_.title, a1_.id";
  assertEquals(expected, precomputeQuery.toString());
}

代码示例来源:origin: org.intermine/intermine-api

private void buildBag() throws InternalBagOperationException {
  ObjectStoreBagCombination osbc = combineBags();
  Query q = new Query();
  q.addToSelect(osbc);
  LOG.debug(q.toString());
  try {
    combined.addToBagFromQuery(q);
  } catch (ObjectStoreException e) {
    cleanUp();
    throw new InternalBagOperationException("Error constructing bag", e);
  }
}

代码示例来源:origin: intermine/intermine

private void buildBag() throws InternalBagOperationException {
  ObjectStoreBagCombination osbc = combineBags();
  Query q = new Query();
  q.addToSelect(osbc);
  LOG.debug(q.toString());
  try {
    combined.addToBagFromQuery(q);
  } catch (ObjectStoreException e) {
    cleanUp();
    throw new InternalBagOperationException("Error constructing bag", e);
  }
}

代码示例来源:origin: intermine/intermine

public void testLoopConstraint() throws Exception {
  Map<String, PathQuery> queries = readQueries();
  PathQuery pq = queries.get("loopConstraint");
  Query q = MainHelper.makeQuery(pq, new HashMap(), null, bagQueryRunner, new HashMap());
  String got = q.toString();
  String iql = "SELECT DISTINCT a1_ FROM org.intermine.model.testmodel.Company AS a1_, org.intermine.model.testmodel.Department AS a2_ WHERE (a1_.departments CONTAINS a2_ AND a2_.company CONTAINS a1_) ORDER BY a1_.name";
  assertEquals("Expected: " + iql + ", got: " + got, iql, got);
}

代码示例来源:origin: intermine/intermine

public void testSafeFunctions() throws Exception {
  Query q = IqlQueryParser.parse(new IqlQuery("select count(*) as a, sum(Company.vatNumber + 3) as b, avg(Company.vatNumber) as c, min(Company.vatNumber) as d, substr('flibble', 3, max(Company.vatNumber)) as e, Company.vatNumber % 10 as f, ceil(Broke.interestRate) as g, floor(Broke.interestRate) as h from Company, Broke", "org.intermine.model.testmodel"));
  assertEquals("SELECT COUNT(*) AS a, SUM(Company.vatNumber + 3) AS b, AVG(Company.vatNumber) AS c, MIN(Company.vatNumber) AS d, SUBSTR('flibble', 3, MAX(Company.vatNumber)) AS e, Company.vatNumber % 10 AS f, CEIL(Broke.interestRate) AS g, FLOOR(Broke.interestRate) AS h FROM org.intermine.model.testmodel.Company AS Company, org.intermine.model.testmodel.Broke AS Broke", q.toString());
}

代码示例来源:origin: intermine/intermine

public void testCreateDefaultBagQueryMultiple() throws Exception {
    Query q = BagQueryHelper.createDefaultBagQuery(model.getPackageName() + ".Manager",
                             bagQueryConfig, model, classKeys, input);
    String expected = "SELECT DISTINCT a1_.id AS a2_, a1_.name AS a3_, a1_.title AS a4_ " +
        "FROM org.intermine.model.testmodel.Manager AS a1_ " +
        "WHERE (LOWER(a1_.name), LOWER(a1_.title)) IN ? 1: [employeea1, employeea2]";
    assertEquals(expected, q.toString());
  }
}

代码示例来源:origin: intermine/intermine

public void testValidConstraints() throws Exception {
  Query q = IqlQueryParser.parse(new IqlQuery("select c_, d_, e_ from Company as c_, Department as d_, CEO as e_ where c_.departments does not contain d_ and c_.CEO contains e_ and (c_.vatNumber < 5 or c_.name like 'fish%') and e_.salary is not null and c_.vatNumber > e_.age and c_.name in (select Company.name as name from Company)", "org.intermine.model.testmodel"));
  assertEquals("SELECT c_, d_, e_ FROM org.intermine.model.testmodel.Company AS c_, org.intermine.model.testmodel.Department AS d_, org.intermine.model.testmodel.CEO AS e_ WHERE (c_.departments DOES NOT CONTAIN d_ AND c_.CEO CONTAINS e_ AND (c_.vatNumber < 5 OR c_.name LIKE 'fish%') AND e_.salary IS NOT NULL AND c_.vatNumber > e_.age AND c_.name IN (SELECT Company.name AS name FROM org.intermine.model.testmodel.Company AS Company))", q.toString());
}

代码示例来源:origin: intermine/intermine

public void testCreateDefaultBagQuerySingle() throws Exception {
  Query q = BagQueryHelper.createDefaultBagQuery(model.getPackageName() + ".Employee",
                         bagQueryConfig, model, classKeys, input);
  String expected = "SELECT DISTINCT a1_.id AS a2_, a1_.name AS a3_ " +
      "FROM org.intermine.model.testmodel.Employee AS a1_ " +
      "WHERE LOWER(a1_.name) IN ? 1: [employeea1, employeea2]";
  assertEquals(expected, q.toString());
}

代码示例来源: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 void testNormalExpressions() throws Exception {
  Query q = IqlQueryParser.parse(new IqlQuery("select 1 + Company.vatNumber as a, 3 - 4 as b, 5 * 6 as c, 7 / 8 as d from Company", "org.intermine.model.testmodel"));
  assertEquals("SELECT 1 + Company.vatNumber AS a, 3 - 4 AS b, 5 * 6 AS c, 7 / 8 AS d FROM org.intermine.model.testmodel.Company AS Company", q.toString());
}

代码示例来源:origin: intermine/intermine

public void testToString() {
    Query q = new Query();
    QueryClass qc = new QueryClass(Employee.class);
    q.addFrom(qc);
    q.addToSelect(qc);
    q.setDistinct(true);
    assertEquals("SELECT DISTINCT a1_ FROM org.intermine.model.testmodel.Employee AS a1_", q.toString());
    q.setDistinct(false);
    assertEquals("SELECT a1_ FROM org.intermine.model.testmodel.Employee AS a1_", q.toString());
  }
}

代码示例来源:origin: intermine/intermine

public void testCreateDefaultBagQueryWithExtra() throws Exception {
  BagQuery bq = new BagQuery(bagQueryConfigWithExtraConstraint,
      model, classKeys, model.getPackageName() + ".Employee");
  String expected = "SELECT DISTINCT a1_.id AS a2_, a1_.name AS a3_ " +
      "FROM org.intermine.model.testmodel.Employee AS a1_, " +
         "org.intermine.model.testmodel.Department AS a4_ " +
      "WHERE (LOWER(a1_.name) IN ? AND a1_.department CONTAINS a4_ " +
       "AND a4_.name = \'DepartmentB1\') 1: [employeea1, employeea2]";
  assertEquals(expected, bq.getQuery(input, "DepartmentB1").toString());
}

代码示例来源:origin: intermine/intermine

@Test
  public void testCreateQuery() throws Exception {
    String clsName = "Department.employees.class";
    Assert.assertEquals("SELECT DISTINCT a2_.class AS a3_ FROM org.intermine.model.testmodel.Department AS a1_, org.intermine.model.testmodel.Employee AS a2_ WHERE a1_.employees CONTAINS a2_", QueryGenUtil.createClassFindingQuery(os.getModel(), clsName).getQuery().toString());
  }
}

代码示例来源:origin: intermine/intermine

@Test
public void nonNullPathQueryCollections() {
  PathQuery pq = new PathQuery(osw.getModel());
  pq.addView("Department.name");
  pq.addConstraint(Constraints.eq("Department.name", "temp-*"));
  pq.addConstraint(Constraints.isNotNull("Department.employees"));
  Query q = makeQuery(pq);
  System.out.println(q.toString());
  doNonNullCollectionTests(q);
}

代码示例来源:origin: intermine/intermine

@Test
public void nullPathQueryCollections() {
  PathQuery pq = new PathQuery(osw.getModel());
  pq.addView("Department.name");
  pq.addConstraint(Constraints.eq("Department.name", "temp-*"));
  pq.addConstraint(Constraints.isNull("Department.employees"));
  Query q = makeQuery(pq);
  System.out.println(q.toString());
  doNullCollectionTests(q);
}

代码示例来源:origin: intermine/intermine

@Test
public void nullPathQueryCollectionsSynonyms() {
  PathQuery pq = new PathQuery(osw.getModel());
  pq.addView("Department.name");
  pq.addConstraint(Constraints.eq("Department.name", "temp-*"));
  pq.addConstraint(new PathConstraintNull("Department.employees", ConstraintOp.IS_EMPTY));
  Query q = makeQuery(pq);
  System.out.println(q.toString());
  doNullCollectionTests(q);
}

代码示例来源:origin: intermine/intermine

public void testAlias() throws Exception {
    Query orig = new Query();
    QueryClass c = new QueryClass(Company.class);
    orig.addFrom(c);
    orig.addToSelect(c);

    Query cloned = QueryCloner.cloneQuery(orig);

    QueryClass c2 = new QueryClass(Department.class);
    cloned.addFrom(c2);
    cloned.addToSelect(c2);

    assertEquals("SELECT DISTINCT a1_, a2_ FROM org.intermine.model.testmodel.Company AS a1_, org.intermine.model.testmodel.Department AS a2_", cloned.toString());
  }
}

相关文章