use of com.orientechnologies.orient.core.exception.OCommandExecutionException in project orientdb by orientechnologies.
the class OCommandExecutorSQLCreateClass method execute.
/**
* Execute the CREATE CLASS.
*/
public Object execute(final Map<Object, Object> iArgs) {
if (className == null)
throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet");
final ODatabaseDocument database = getDatabase();
boolean alreadyExists = database.getMetadata().getSchema().existsClass(className);
if (!alreadyExists || !ifNotExists) {
if (clusters != null)
database.getMetadata().getSchema().createClass(className, clusters, superClasses.toArray(new OClass[0]));
else
database.getMetadata().getSchema().createClass(className, clusterIds, superClasses.toArray(new OClass[0]));
}
return database.getMetadata().getSchema().getClasses().size();
}
use of com.orientechnologies.orient.core.exception.OCommandExecutionException in project orientdb by orientechnologies.
the class OCommandExecutorSQLDelegate method parse.
@SuppressWarnings("unchecked")
public OCommandExecutorSQLDelegate parse(final OCommandRequest iCommand) {
if (iCommand instanceof OCommandRequestText) {
final OCommandRequestText textRequest = (OCommandRequestText) iCommand;
final String text = textRequest.getText();
if (text == null)
throw new IllegalArgumentException("Command text is null");
final String textUpperCase = upperCase(text);
delegate = OSQLEngine.getInstance().getCommand(textUpperCase);
if (delegate == null)
throw new OCommandExecutorNotFoundException("Cannot find a command executor for the command request: " + iCommand);
delegate.setContext(context);
delegate.setLimit(iCommand.getLimit());
delegate.parse(iCommand);
delegate.setProgressListener(progressListener);
if (delegate.getFetchPlan() != null)
textRequest.setFetchPlan(delegate.getFetchPlan());
} else
throw new OCommandExecutionException("Cannot find a command executor for the command request: " + iCommand);
return this;
}
use of com.orientechnologies.orient.core.exception.OCommandExecutionException in project orientdb by orientechnologies.
the class OCommandExecutorSQLDelete method result.
/**
* Deletes the current record.
*/
public boolean result(final Object iRecord) {
final ORecordAbstract record = ((OIdentifiable) iRecord).getRecord();
if (record instanceof ODocument && compiledFilter != null && !Boolean.TRUE.equals(this.compiledFilter.evaluate(record, (ODocument) record, getContext()))) {
return true;
}
try {
if (record.getIdentity().isValid()) {
if (returning.equalsIgnoreCase("BEFORE"))
allDeletedRecords.add(record);
// RESET VERSION TO DISABLE MVCC AVOIDING THE CONCURRENT EXCEPTION IF LOCAL CACHE IS NOT UPDATED
ORecordInternal.setVersion(record, -1);
if (!unsafe && record instanceof ODocument) {
// CHECK IF ARE VERTICES OR EDGES
final OClass cls = ((ODocument) record).getSchemaClass();
if (cls != null) {
if (cls.isSubClassOf("V"))
// FOUND VERTEX
throw new OCommandExecutionException("'DELETE' command cannot delete vertices. Use 'DELETE VERTEX' command instead, or apply the 'UNSAFE' keyword to force it");
else if (cls.isSubClassOf("E"))
// FOUND EDGE
throw new OCommandExecutionException("'DELETE' command cannot delete edges. Use 'DELETE EDGE' command instead, or apply the 'UNSAFE' keyword to force it");
}
}
record.delete();
recordCount++;
return true;
}
return false;
} finally {
if (lockStrategy.equalsIgnoreCase("RECORD"))
((OAbstractPaginatedStorage) getDatabase().getStorage()).releaseWriteLock(record.getIdentity());
}
}
use of com.orientechnologies.orient.core.exception.OCommandExecutionException in project orientdb by orientechnologies.
the class OCommandExecutorSQLDropIndex method execute.
/**
* Execute the REMOVE INDEX.
*/
public Object execute(final Map<Object, Object> iArgs) {
if (name == null)
throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet");
if (name.equals("*")) {
long totalIndexed = 0;
for (OIndex<?> idx : getDatabase().getMetadata().getIndexManager().getIndexes()) {
getDatabase().getMetadata().getIndexManager().dropIndex(idx.getName());
totalIndexed++;
}
return totalIndexed;
} else
getDatabase().getMetadata().getIndexManager().dropIndex(name);
return 1;
}
use of com.orientechnologies.orient.core.exception.OCommandExecutionException in project orientdb by orientechnologies.
the class OCommandExecutorSQLDropSequence method execute.
@Override
public Object execute(Map<Object, Object> iArgs) {
if (this.sequenceName == null) {
throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet");
}
final ODatabaseDocument database = getDatabase();
database.getMetadata().getSequenceLibrary().dropSequence(this.sequenceName);
return true;
}
Aggregations