use of com.orientechnologies.orient.core.sql.parser.OTruncateClusterStatement in project orientdb by orientechnologies.
the class OCommandExecutorSQLTruncateCluster method parse.
@SuppressWarnings("unchecked")
public OCommandExecutorSQLTruncateCluster parse(final OCommandRequest iRequest) {
final OCommandRequestText textRequest = (OCommandRequestText) iRequest;
String queryText = textRequest.getText();
String originalQuery = queryText;
try {
queryText = preParse(queryText, iRequest);
textRequest.setText(queryText);
init((OCommandRequestText) iRequest);
StringBuilder word = new StringBuilder();
int oldPos = 0;
int pos = nextWord(parserText, parserTextUpperCase, oldPos, word, true);
if (pos == -1 || !word.toString().equals(KEYWORD_TRUNCATE))
throw new OCommandSQLParsingException("Keyword " + KEYWORD_TRUNCATE + " not found. Use " + getSyntax(), parserText, oldPos);
oldPos = pos;
pos = nextWord(parserText, parserTextUpperCase, oldPos, word, true);
if (pos == -1 || !word.toString().equals(KEYWORD_CLUSTER))
throw new OCommandSQLParsingException("Keyword " + KEYWORD_CLUSTER + " not found. Use " + getSyntax(), parserText, oldPos);
oldPos = pos;
pos = nextWord(parserText, parserText, oldPos, word, true);
if (pos == -1)
throw new OCommandSQLParsingException("Expected cluster name. Use " + getSyntax(), parserText, oldPos);
clusterName = decodeClusterName(word.toString());
if (preParsedStatement != null) {
// new parser, this will be removed and implemented with the new executor
OIdentifier name = ((OTruncateClusterStatement) preParsedStatement).clusterName;
if (name != null) {
clusterName = name.getStringValue();
}
}
final ODatabaseDocument database = getDatabase();
if (database.getClusterIdByName(clusterName) == -1)
throw new OCommandSQLParsingException("Cluster '" + clusterName + "' not found", parserText, oldPos);
} finally {
textRequest.setText(originalQuery);
}
return this;
}
Aggregations