A PropertyQuery returns only a subset of the properties of the objects that match the query expression. The properties to be returned are specified as the values of user-defined properties on the PropertyQuery object.
For example, to return the name and description properties, add two user-defined properties to the instance of PropertyQuery, one with the value "name" and the other with the value "description". The properties to be returned must be specified in property values because query objects extend BaseObject and therefore have their own properties such as name and description.
If you want to define properties that are to be considered as properties of the PropertyQuery object itself, rather than properties to be used in the search, prefix the names of these properties with an underscore ("_").
If you request just the property "_count", the query will return a single row containing the number of objects that match the query.
To request the object type (for example, WSDLService, SCAModule), add the property "_sdoType". For compatibility with earlier versions of WSRR, you can also use the property "sdoType", without the underscore; however, the use of "sdoType" is deprecated and might be removed in a future release.
try {
PropertyQuery query = (PropertyQuery)DataFactory.INSTANCE.create(
TypeConstants.SR_URI, TypeConstants.TYPE_PROPERTYQUERY);
// retrieve all the XMLDocuments in the registry
query.setQueryExpression("/WSRR/XMLDocument");
// return the "description" and "name" properties in the objects found in the search
BSRSDOHelper.INSTANCE.addProperty(query, "p1", "description");
BSRSDOHelper.INSTANCE.addProperty(query, "p2", "name");
// add a property to the PropertyQuery - this property will not be included in the search
BSRSDOHelper.INSTANCE.addProperty(query, "_queryStatus", "Test");
// execute the query
List<PropertyQueryResult> propertyQueryResults =
(List<PropertyQueryResult>)client.executeQuery(query);
// process each PropertyQueryResultObject found in the list
for (PropertyQueryResult propertyQueryResult : propertyQueryResults) {
// get the name
String name = BSRSDOHelper.INSTANCE.getPropertyQueryResultValue
(propertyQueryResult,"name");
// get the description
String description = BSRSDOHelper.INSTANCE.getPropertyQueryResultValue
(propertyQueryResult,"description");
}
} catch (ServiceRegistryException e) {
// handle exception
}