use of com.orientechnologies.orient.core.query.OQueryAbstract in project orientdb by orientechnologies.
the class OAbstractPaginatedStorage method command.
/**
* Executes the command request and return the result back.
*/
public Object command(final OCommandRequestText iCommand) {
while (true) {
try {
final OCommandExecutor executor = OCommandManager.instance().getExecutor(iCommand);
// COPY THE CONTEXT FROM THE REQUEST
executor.setContext(iCommand.getContext());
executor.setProgressListener(iCommand.getProgressListener());
executor.parse(iCommand);
return executeCommand(iCommand, executor);
} catch (ORetryQueryException e) {
if (iCommand instanceof OQueryAbstract) {
final OQueryAbstract query = (OQueryAbstract) iCommand;
query.reset();
}
continue;
}
}
}
use of com.orientechnologies.orient.core.query.OQueryAbstract in project orientdb by orientechnologies.
the class OServerCommandGetQuery method execute.
@Override
@SuppressWarnings("unchecked")
public boolean execute(final OHttpRequest iRequest, OHttpResponse iResponse) throws Exception {
String[] urlParts = checkSyntax(iRequest.url, 4, "Syntax error: query/<database>/sql/<query-text>[/<limit>][/<fetchPlan>].<br>Limit is optional and is set to 20 by default. Set to 0 to have no limits.");
final int limit = urlParts.length > 4 ? Integer.parseInt(urlParts[4]) : 20;
String fetchPlan = urlParts.length > 5 ? urlParts[5] : null;
final String text = urlParts[3];
final String accept = iRequest.getHeader("accept");
iRequest.data.commandInfo = "Query";
iRequest.data.commandDetail = text;
ODatabaseDocument db = null;
final List<OIdentifiable> response;
try {
db = getProfiledDatabaseInstance(iRequest);
final OQueryAbstract command = new OSQLSynchQuery<ODocument>(text, limit).setFetchPlan(fetchPlan);
// REQUEST CAN'T MODIFY THE RESULT, SO IT'S CACHEABLE
command.setCacheableResult(true);
response = (List<OIdentifiable>) db.query(command);
fetchPlan = command.getFetchPlan();
Map<String, Object> additionalContent = null;
final List<String> tips = (List<String>) command.getContext().getVariable("tips");
if (tips != null) {
additionalContent = new HashMap<String, Object>(1);
additionalContent.put("warnings", tips);
}
iResponse.writeRecords(response, fetchPlan, null, accept, additionalContent);
} finally {
if (db != null)
db.close();
}
return false;
}
Aggregations