Difference between revisions of "ExistClient"
From Gcube Wiki
Lucio.lelii (Talk | contribs) (→Sample usage) |
Lucio.lelii (Talk | contribs) (→Usage Examples) |
||
Line 35: | Line 35: | ||
=== Usage Examples === | === Usage Examples === | ||
+ | |||
+ | The ISclient reference implementation makes use of Xquery Technology to query over the underneath Exist database. | ||
+ | Client/services can prepare a custom xQuery over the DB and use the Generic Query object to excecute it and going through the result: | ||
+ | |||
+ | <pre> | ||
+ | |||
+ | GCUBEGenericQuery query = client.getQuery(GCUBEGenericQuery.class); | ||
+ | query.setExpression("for $Profile in collection(\"/db/Profiles\")//Document/Data/child::*[local-name()='Profile']/Resource return $Profile/UniqueID"); | ||
+ | List<XMLResult> result =client.execute(query, scope); | ||
+ | for (String resultItem :result ) { | ||
+ | System.out.println(resultItem.evaluate("an XPath ... ")); | ||
+ | System.out.println(resultItem.toString()); | ||
+ | } | ||
+ | |||
+ | </pre> | ||
+ | |||
+ | The GCUBEGeneric | ||
+ | |||
+ | |||
+ | You can use a predefined ISQuery Object as well: | ||
+ | |||
+ | <pre> | ||
+ | |||
+ | GCUBEWSResourceEPRFromRPValuesAndNamespaceQuery query = client.getQuery(GCUBEWSResourceEPRFromRPValuesAndNamespaceQuery.class); | ||
+ | GCUBEWSProperty property = new GCUBEWSProperty("IndexTypeName","index_type_string_string"); | ||
+ | |||
+ | GCUBEWSProperty property2 = new GCUBEWSProperty("IndexID","999ba610-e9fb-11dc-b51b-84732c1e88f2"); | ||
+ | |||
+ | ArrayList <GCUBEWSProperty> properties = new ArrayList(); | ||
+ | properties.add(property); | ||
+ | properties.add(property2); | ||
+ | query.setPropertiesValuesAndNamespace(properties, "http://gcube-system.org/namespaces/index/ForwardIndexManagementService"); | ||
+ | |||
+ | List<EndpointReferenceType> result = client.execute(query, scope); | ||
+ | |||
+ | for (EndpointReferenceType resultItem :result ) { | ||
+ | System.out.println(resultItem.toString()); | ||
+ | |||
+ | } | ||
+ | </pre> |
Revision as of 15:38, 23 May 2008
Introduction
The ExistClient is a Java library that implements the ISClient interface provided by the gCoreFramework. This library allow the developer to execute queries on the Information System.
Implementation Overview
The ExistClient implements all the query defined in the ISClient Interface:
Queries over GCUBEResource:
- GCUBECollectionQuery
- GCUBECSInstanceQuery
- GCUBECSQuery
- GCUBEExternalRIQuery
- GCUBEGenericResourceQuery
- GCUBEGHNQuery
- GCUBEMCollectionQuery
- GCUBERIQuery
- GCUBEServiceQuery
- GCUBETPQuery
- GCUBEVREQuery
Queries over GCUBEWSResource:
- WSResourceQuery
Generic queries:
- GCUBEGenericQuery
Usage Examples
The ISclient reference implementation makes use of Xquery Technology to query over the underneath Exist database. Client/services can prepare a custom xQuery over the DB and use the Generic Query object to excecute it and going through the result:
GCUBEGenericQuery query = client.getQuery(GCUBEGenericQuery.class); query.setExpression("for $Profile in collection(\"/db/Profiles\")//Document/Data/child::*[local-name()='Profile']/Resource return $Profile/UniqueID"); List<XMLResult> result =client.execute(query, scope); for (String resultItem :result ) { System.out.println(resultItem.evaluate("an XPath ... ")); System.out.println(resultItem.toString()); }
The GCUBEGeneric
You can use a predefined ISQuery Object as well:
GCUBEWSResourceEPRFromRPValuesAndNamespaceQuery query = client.getQuery(GCUBEWSResourceEPRFromRPValuesAndNamespaceQuery.class); GCUBEWSProperty property = new GCUBEWSProperty("IndexTypeName","index_type_string_string"); GCUBEWSProperty property2 = new GCUBEWSProperty("IndexID","999ba610-e9fb-11dc-b51b-84732c1e88f2"); ArrayList <GCUBEWSProperty> properties = new ArrayList(); properties.add(property); properties.add(property2); query.setPropertiesValuesAndNamespace(properties, "http://gcube-system.org/namespaces/index/ForwardIndexManagementService"); List<EndpointReferenceType> result = client.execute(query, scope); for (EndpointReferenceType resultItem :result ) { System.out.println(resultItem.toString()); }