GraphQuery

A GraphQuery retrieves SDO object graphs that represent data held in the Service Registry. A depth parameter can be specified on the GraphQuery object that allows you to specify the depth of relationships that are resolved in the object graph that is returned.

Specifying a depth parameter of -1 (the default) means that a complete object graph is returned. For example, if a query with depth parameter of -1 returns a single WSDLService element, you can then programmatically follow all the relationships (both predefined and user-defined) from the root WSDLService object that is returned from the query.

Specifying a depth parameter of 0 implies that only the objects that have been queried for are returned and so you can access all the properties for a given object, but cannot access any related object programmatically without executing an additional query.

GraphQuery has a boolean noContent parameter. If you set noContent to true, then the content of all returned documents will be null; this is useful for improving performance when running queries on documents where you are interested only in the metadata. The contentSize property of a returned document will still be set to the full size of the document as stored in the registry.

Example

This example demonstrates the execution of a GraphQuery that retrieves all XML documents stored in the registry.
try {
    GraphQuery query = (GraphQuery) DataFactory.INSTANCE.create(
             TypeConstants.SR_URI, TypeConstants.TYPE_GRAPHQUERY);
		
    // retrieve all the XMLDocuments in the registry
    query.setQueryExpression("/WSRR/XMLDocument");

    // retrieve only the requested documents, not any related objects
    query.setDepth(0);

    // retrieve the documents without their content. 
    query.setNoContent(true); 

    List graphQueryResults = client.executeQuery(query);
    for (int i = 0; i < graphQueryResults.size(); i++) {
        XMLDocument doc = (XMLDocument) graphQueryResults.get(i);
        System.out.println(doc.getBsrURI()); 
        System.out.println(doc.getName()); 
    }

} catch (ServiceRegistryException e) {
    // handle exception
}