use of org.sirix.service.jaxrx.util.RestXPathProcessor in project sirix by sirixdb.
the class NodeIdRepresentation method performQueryOnResource.
/**
* This method is responsible to perform a XPath query expression on the XML
* resource which is addressed through a unique node id.
*
* @param resourceName
* The name of the database, the node id belongs to.
* @param nodeId
* The node id of the requested resource.
* @param query
* The XPath expression.
* @param queryParams
* The optional query parameters (output, wrap, revision).
* @return The result of the XPath query expression.
*/
public StreamingOutput performQueryOnResource(final String resourceName, final long nodeId, final String query, final Map<QueryParameter, String> queryParams) {
final StreamingOutput sOutput = new StreamingOutput() {
@Override
public void write(final OutputStream output) throws IOException, JaxRxException {
final File dbFile = new File(mStoragePath, resourceName);
final String revision = queryParams.get(QueryParameter.REVISION);
final String wrap = queryParams.get(QueryParameter.WRAP);
final String doNodeId = queryParams.get(QueryParameter.OUTPUT);
final boolean wrapResult = (wrap == null) ? true : wrap.equalsIgnoreCase(YESSTRING);
final boolean nodeid = (doNodeId == null) ? false : doNodeId.equalsIgnoreCase(YESSTRING);
final Integer rev = revision == null ? null : Integer.valueOf(revision);
final RestXPathProcessor xpathProcessor = new RestXPathProcessor(mStoragePath);
try {
xpathProcessor.getXpathResource(dbFile, nodeId, query, nodeid, rev, output, wrapResult);
} catch (final SirixException exce) {
throw new JaxRxException(exce);
}
}
};
return sOutput;
}
use of org.sirix.service.jaxrx.util.RestXPathProcessor in project sirix by sirixdb.
the class DatabaseRepresentation method performQueryOnResource.
/**
* This method is responsible to perform queries on a special database. (XPath
* queries).
*
* @param resource
* The name of the database instance.
* @param query
* The XPath expression.
* @param otherParams
* Further query parameters (output, wrap, revision) which change the
* response.
* @return The result of the XPath query expression.
*/
public StreamingOutput performQueryOnResource(final String resource, final String query, final Map<QueryParameter, String> otherParams) {
final StreamingOutput streamingOutput = new StreamingOutput() {
@Override
public void write(final OutputStream output) throws IOException, JaxRxException {
final String revision = otherParams.get(QueryParameter.REVISION);
final String wrap = otherParams.get(QueryParameter.WRAP);
final String nodeId = otherParams.get(QueryParameter.OUTPUT);
final boolean wrapResult = (wrap == null) ? true : wrap.equalsIgnoreCase(YESSTRING);
final boolean nodeid = (nodeId == null) ? false : nodeId.equalsIgnoreCase(YESSTRING);
final Integer rev = revision == null ? null : Integer.valueOf(revision);
final RestXPathProcessor xpathProcessor = new RestXPathProcessor(mStoragePath);
try {
xpathProcessor.getXpathResource(resource, query, nodeid, rev, output, wrapResult);
} catch (final SirixException exce) {
throw new JaxRxException(exce);
}
}
};
return streamingOutput;
}
Aggregations