use of com.orientechnologies.orient.core.command.OCommandRequestText in project orientdb by orientechnologies.
the class OCommandExecutorSQLDropIndex method parse.
public OCommandExecutorSQLDropIndex 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);
final StringBuilder word = new StringBuilder();
int oldPos = 0;
int pos = nextWord(parserText, parserTextUpperCase, oldPos, word, true);
if (pos == -1 || !word.toString().equals(KEYWORD_DROP))
throw new OCommandSQLParsingException("Keyword " + KEYWORD_DROP + " not found. Use " + getSyntax(), parserText, oldPos);
oldPos = pos;
pos = nextWord(parserText, parserTextUpperCase, pos, word, true);
if (pos == -1 || !word.toString().equals(KEYWORD_INDEX))
throw new OCommandSQLParsingException("Keyword " + KEYWORD_INDEX + " not found. Use " + getSyntax(), parserText, oldPos);
oldPos = pos;
pos = nextWord(parserText, parserTextUpperCase, oldPos, word, false);
if (pos == -1)
throw new OCommandSQLParsingException("Expected index name. Use " + getSyntax(), parserText, oldPos);
name = word.toString();
} finally {
textRequest.setText(originalQuery);
}
return this;
}
use of com.orientechnologies.orient.core.command.OCommandRequestText in project orientdb by orientechnologies.
the class OCommandExecutorSQLDropProperty method parse.
public OCommandExecutorSQLDropProperty 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);
final StringBuilder word = new StringBuilder();
int oldPos = 0;
int pos = nextWord(parserText, parserTextUpperCase, oldPos, word, true);
if (pos == -1 || !word.toString().equals(KEYWORD_DROP))
throw new OCommandSQLParsingException("Keyword " + KEYWORD_DROP + " not found. Use " + getSyntax(), parserText, oldPos);
pos = nextWord(parserText, parserTextUpperCase, pos, word, true);
if (pos == -1 || !word.toString().equals(KEYWORD_PROPERTY))
throw new OCommandSQLParsingException("Keyword " + KEYWORD_PROPERTY + " not found. Use " + getSyntax(), parserText, oldPos);
pos = nextWord(parserText, parserTextUpperCase, pos, word, false);
if (pos == -1)
throw new OCommandSQLParsingException("Expected <class>.<property>. Use " + getSyntax(), parserText, pos);
String[] parts = word.toString().split("\\.");
if (parts.length != 2)
throw new OCommandSQLParsingException("Expected <class>.<property>. Use " + getSyntax(), parserText, pos);
className = decodeClassName(parts[0]);
if (className == null)
throw new OCommandSQLParsingException("Class not found", parserText, pos);
fieldName = decodeClassName(parts[1]);
pos = nextWord(parserText, parserTextUpperCase, pos, word, false);
if (pos != -1) {
final String forceParameter = word.toString();
if ("FORCE".equals(forceParameter)) {
force = true;
} else if ("IF".equals(word.toString())) {
pos = nextWord(parserText, parserTextUpperCase, pos, word, false);
if ("EXISTS".equals(word.toString())) {
this.ifExists = true;
} else {
throw new OCommandSQLParsingException("Wrong query parameter, expecting EXISTS after IF", parserText, pos);
}
} else {
throw new OCommandSQLParsingException("Wrong query parameter", parserText, pos);
}
}
} finally {
textRequest.setText(originalQuery);
}
return this;
}
use of com.orientechnologies.orient.core.command.OCommandRequestText in project orientdb by orientechnologies.
the class OCommandExecutorSQLDropSequence method parse.
@Override
public OCommandExecutorSQLDropSequence parse(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);
final ODatabaseDocumentInternal database = getDatabase();
final StringBuilder word = new StringBuilder();
parserRequiredKeyword("DROP");
parserRequiredKeyword("SEQUENCE");
this.sequenceName = parserRequiredWord(false, "Expected <sequence name>");
} finally {
textRequest.setText(originalQuery);
}
return this;
}
use of com.orientechnologies.orient.core.command.OCommandRequestText in project orientdb by orientechnologies.
the class OCommandExecutorSQLTruncateClass method parse.
@SuppressWarnings("unchecked")
public OCommandExecutorSQLTruncateClass parse(final OCommandRequest iRequest) {
final OCommandRequestText textRequest = (OCommandRequestText) iRequest;
String queryText = textRequest.getText();
String originalQuery = queryText;
try {
queryText = preParse(queryText, iRequest);
textRequest.setText(queryText);
final ODatabaseDocument database = getDatabase();
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_CLASS))
throw new OCommandSQLParsingException("Keyword " + KEYWORD_CLASS + " not found. Use " + getSyntax(), parserText, oldPos);
oldPos = pos;
pos = nextWord(parserText, parserText, oldPos, word, true);
if (pos == -1)
throw new OCommandSQLParsingException("Expected class name. Use " + getSyntax(), parserText, oldPos);
final String className = word.toString();
schemaClass = database.getMetadata().getSchema().getClass(className);
if (schemaClass == null)
throw new OCommandSQLParsingException("Class '" + className + "' not found", parserText, oldPos);
oldPos = pos;
pos = nextWord(parserText, parserText, oldPos, word, true);
while (pos > 0) {
String nextWord = word.toString();
if (nextWord.toUpperCase().equals(KEYWORD_UNSAFE)) {
unsafe = true;
} else if (nextWord.toUpperCase().equals(KEYWORD_POLYMORPHIC)) {
deep = true;
}
oldPos = pos;
pos = nextWord(parserText, parserText, oldPos, word, true);
}
} finally {
textRequest.setText(originalQuery);
}
return this;
}
use of com.orientechnologies.orient.core.command.OCommandRequestText 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