本文整理了Java中org.intermine.objectstore.query.Query.setConstraint
方法的一些代码示例,展示了Query.setConstraint
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setConstraint
方法的具体详情如下:
包路径:org.intermine.objectstore.query.Query
类名称:Query
方法名:setConstraint
[英]Constrain this Query using either a single constraint or a set of constraints
[中]使用单个约束或一组约束约束此查询
代码示例来源:origin: intermine/intermine
public static Query whereClassObject() throws Exception {
QueryClass qc1 = new QueryClass(Company.class);
Company obj = (Company) data.get("CompanyA");
ClassConstraint cc1 = new ClassConstraint(qc1, ConstraintOp.EQUALS, obj);
Query q1 = new Query();
q1.addFrom(qc1);
q1.addToSelect(qc1);
q1.setConstraint(cc1);
return q1;
}
代码示例来源:origin: intermine/intermine
public static Query objectNotContainsObject() throws Exception {
Query q = new Query();
q.addToSelect(new QueryValue("hello"));
q.setConstraint(new ContainsConstraint(new QueryCollectionReference((InterMineObject) data.get("DepartmentA1"), "employees"), ConstraintOp.DOES_NOT_CONTAIN, (InterMineObject) data.get("EmployeeA1")));
q.setDistinct(false);
return q;
}
代码示例来源:origin: intermine/intermine
public static Query whereSimpleNotEquals() throws Exception {
QueryClass c1 = new QueryClass(Company.class);
QueryValue v1 = new QueryValue(new Integer(1234));
QueryField f1 = new QueryField(c1, "vatNumber");
QueryField f2 = new QueryField(c1, "name");
SimpleConstraint sc1 = new SimpleConstraint(f1, ConstraintOp.NOT_EQUALS, v1);
Query q1 = new Query();
q1.addFrom(c1);
q1.addToSelect(f2);
q1.setConstraint(sc1);
return q1;
}
代码示例来源:origin: intermine/intermine
public static Query emptyNorConstraintSet() throws Exception {
Query q = new Query();
QueryClass qc = new QueryClass(Company.class);
q.addFrom(qc);
q.addToSelect(qc);
q.setConstraint(new ConstraintSet(ConstraintOp.NOR));
return q;
}
代码示例来源:origin: intermine/intermine
public static Query emptyAndConstraintSet() throws Exception {
Query q = new Query();
QueryClass qc = new QueryClass(Company.class);
q.addFrom(qc);
q.addToSelect(qc);
q.setConstraint(new ConstraintSet(ConstraintOp.AND));
return q;
}
代码示例来源:origin: intermine/intermine
public static Query constrainClass2() throws Exception {
Query q = new Query();
QueryClass qc1 = new QueryClass(InterMineObject.class);
q.addFrom(qc1);
q.addToSelect(qc1);
QueryField qf = new QueryField(qc1, "class");
q.setConstraint(new BagConstraint(qf, ConstraintOp.IN, Arrays.asList(Employee.class, Company.class)));
q.setDistinct(false);
return q;
}
代码示例来源:origin: intermine/intermine
public static Query scientificNumber() throws Exception {
Query q = new Query();
QueryClass qc = new QueryClass(Types.class);
q.addFrom(qc);
q.addToSelect(qc);
q.setDistinct(false);
ConstraintSet cs = new ConstraintSet(ConstraintOp.AND);
q.setConstraint(cs);
cs.addConstraint(new SimpleConstraint(new QueryField(qc, "doubleType"), ConstraintOp.LESS_THAN, new QueryValue(new Double(1.3432E+24))));
cs.addConstraint(new SimpleConstraint(new QueryField(qc, "floatType"), ConstraintOp.GREATER_THAN, new QueryValue(new Float(-8.56E-32))));
return q;
}
代码示例来源:origin: intermine/intermine
public static Query scientificNumber() throws Exception {
Query q = new Query();
QueryClass qc = new QueryClass(Types.class);
q.addFrom(qc);
q.addToSelect(qc);
q.setDistinct(false);
ConstraintSet cs = new ConstraintSet(ConstraintOp.AND);
q.setConstraint(cs);
cs.addConstraint(new SimpleConstraint(new QueryField(qc, "doubleType"), ConstraintOp.LESS_THAN, new QueryValue(new Double(1.3432E+24))));
cs.addConstraint(new SimpleConstraint(new QueryField(qc, "floatType"), ConstraintOp.GREATER_THAN, new QueryValue(new Float(-8.56E-32))));
return q;
}
代码示例来源:origin: intermine/intermine
public static Query queryClassBagNot() throws Exception {
Query q = new Query();
QueryClassBag qcb = new QueryClassBag(Department.class, Arrays.asList(new Object[] {data.get("DepartmentA1"), data.get("DepartmentB1")}));
QueryClass qc = new QueryClass(Employee.class);
q.addFrom(qcb);
q.addFrom(qc);
q.addToSelect(new QueryField(qcb));
q.addToSelect(qc);
q.setConstraint(new ContainsConstraint(new QueryCollectionReference(qcb, "employees"), ConstraintOp.DOES_NOT_CONTAIN, qc));
q.setDistinct(false);
return q;
}
代码示例来源:origin: intermine/intermine
public static Query queryClassBag() throws Exception {
Query q = new Query();
QueryClassBag qcb = new QueryClassBag(Department.class, Arrays.asList(new Object[]{data.get("DepartmentA1"), data.get("DepartmentB1")}));
QueryClass qc = new QueryClass(Employee.class);
q.addFrom(qcb);
q.addFrom(qc);
q.addToSelect(new QueryField(qcb));
q.addToSelect(qc);
q.setConstraint(new ContainsConstraint(new QueryCollectionReference(qcb, "employees"), ConstraintOp.CONTAINS, qc));
q.setDistinct(false);
return q;
}
代码示例来源:origin: intermine/intermine
public static Query collectionQueryManyMany() throws Exception {
Query q1 = new Query();
QueryClass qc = new QueryClass(Secretary.class);
q1.addFrom(qc);
q1.addToSelect(qc);
q1.setConstraint(new ContainsConstraint(new QueryCollectionReference((InterMineObject) data.get("CompanyB"), "secretarys"), ConstraintOp.CONTAINS, qc));
q1.setDistinct(false);
return q1;
}
代码示例来源:origin: intermine/intermine
public static Query mergeTrue() throws Exception {
Query q = new Query();
QueryClass qc = new QueryClass(Employee.class);
q.addFrom(qc);
q.addToSelect(qc);
ConstraintSet cs1 = new ConstraintSet(ConstraintOp.AND);
cs1.addConstraint(new SimpleConstraint(new QueryField(qc, "age"), ConstraintOp.GREATER_THAN, new QueryValue(new Integer(3))));
cs1.addConstraint(new ConstraintSet(ConstraintOp.AND));
q.setConstraint(cs1);
q.setDistinct(false);
return q;
}
代码示例来源:origin: intermine/intermine
public static Query containsConstraintNull() throws Exception {
Query q1 = new Query();
QueryClass qc = new QueryClass(Employee.class);
q1.addFrom(qc);
q1.addToSelect(qc);
ContainsConstraint c = new ContainsConstraint(new QueryObjectReference(qc, "address"),
ConstraintOp.IS_NULL);
q1.setConstraint(c);
return q1;
}
代码示例来源:origin: intermine/intermine
public static Query containsConstraintNotNull() throws Exception {
Query q1 = new Query();
QueryClass qc = new QueryClass(Employee.class);
q1.addFrom(qc);
q1.addToSelect(qc);
ContainsConstraint c = new ContainsConstraint(new QueryObjectReference(qc, "address"),
ConstraintOp.IS_NOT_NULL);
q1.setConstraint(c);
return q1;
}
代码示例来源:origin: intermine/intermine
public static Query objectStoreBag() throws Exception {
ObjectStoreBag osb = new ObjectStoreBag(5);
Query q = new Query();
QueryClass qc = new QueryClass(Employee.class);
q.addFrom(qc);
q.addToSelect(qc);
q.setDistinct(false);
q.setConstraint(new BagConstraint(qc, ConstraintOp.IN, osb));
return q;
}
代码示例来源:origin: intermine/intermine
public static Query containsConstraintNotNullCollection1N() throws Exception {
Query q1 = new Query();
QueryClass qc = new QueryClass(Department.class);
q1.addFrom(qc);
q1.addToSelect(qc);
ContainsConstraint c = new ContainsConstraint(
new QueryCollectionReference(qc, "employees"), ConstraintOp.IS_NOT_NULL);
q1.setConstraint(c);
return q1;
}
代码示例来源:origin: intermine/intermine
public static Query containsConstraintNotNullCollectionMN() throws Exception {
Query q1 = new Query();
QueryClass qc = new QueryClass(Company.class);
q1.addFrom(qc);
q1.addToSelect(qc);
ContainsConstraint c = new ContainsConstraint(
new QueryCollectionReference(qc, "contractors"), ConstraintOp.IS_NOT_NULL);
q1.setConstraint(c);
return q1;
}
代码示例来源:origin: intermine/intermine
public static Query simpleConstraintNull() throws Exception {
Query q1 = new Query();
QueryClass qc = new QueryClass(Manager.class);
q1.addFrom(qc);
q1.addToSelect(qc);
SimpleConstraint c = new SimpleConstraint(new QueryField(qc, "title"), ConstraintOp.IS_NULL);
q1.setConstraint(c);
return q1;
}
代码示例来源:origin: intermine/intermine
public static Query whereNotClassClass() throws Exception {
QueryClass qc1 = new QueryClass(Company.class);
QueryClass qc2 = new QueryClass(Company.class);
ClassConstraint cc1 = new ClassConstraint(qc1, ConstraintOp.NOT_EQUALS, qc2);
Query q1 = new Query();
q1.addFrom(qc1);
q1.addFrom(qc2);
q1.addToSelect(qc1);
q1.addToSelect(qc2);
q1.setConstraint(cc1);
return q1;
}
代码示例来源:origin: intermine/intermine
public static Query notSubqueryExistsConstraint() throws Exception {
Query q1 = new Query();
q1.addToSelect(new QueryValue("hello"));
Query q2 = new Query();
QueryClass qc = new QueryClass(Company.class);
q2.addFrom(qc);
q2.addToSelect(qc);
q2.setDistinct(false);
q1.setConstraint(new SubqueryExistsConstraint(ConstraintOp.DOES_NOT_EXIST, q2));
q1.setDistinct(false);
return q1;
}
内容来源于网络,如有侵权,请联系作者删除!