// BUG ALERT: according to the spec, we should say "SELECT o.id",
// but the implementation currently requires us to also get the objectType...
Query query = dqm.createQuery(Query.QUERY_TYPE_SQL,
"SELECT * FROM Organization o, Name_ nm " +
"WHERE nm.value LIKE '%ei%' AND " +
"nm.parent = o.id");
BulkResponse res = dqm.executeQuery(query);
// Process exceptions (if any)
Collection exceptions = res.getExceptions();
if (exceptions != null && !exceptions.isEmpty()){
System.out.println("Error during query");
Iterator iter = exceptions.iterator();
while (iter.hasNext()) {
((Exception)iter.next()).printStackTrace(System.out);
}
}
// Process results (if any)
Collection coll = res.getCollection();
System.out.println("Query found " + coll.size());
Iterator iter = coll.iterator();
while (iter.hasNext()) {
Organization org = (Organization)iter.next();
System.out.println("\t" + org.getName().getValue());
// Get the classifications for this organization
Query classQuery = dqm.createQuery(Query.QUERY_TYPE_SQL,
"SELECT * FROM Classification c WHERE id IN " +
"(RegistryObject_classifications('" +
org.getKey().getId() + "'))");
BulkResponse cRes = dqm.executeQuery(classQuery);
// Process exceptions (if any)
exceptions = cRes.getExceptions();
if (exceptions != null && !exceptions.isEmpty()){
System.out.println("Error during classification query");
iter = exceptions.iterator();
while (iter.hasNext()) {
((Exception)iter.next()).printStackTrace(System.out);
}
}
// Process results (if any)
Collection classColl = cRes.getCollection();
Iterator classIter = classColl .iterator();
while (classIter.hasNext()) {
Classification cls = (Classification)classIter.next();
System.out.print(" " + cls.getName().getValue());
}
System.out.println();
}