use of com.orientechnologies.orient.core.exception.OCommandExecutionException in project orientdb by orientechnologies.
the class OCommandExecutorSQLCreateSequence 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().createSequence(this.sequenceName, this.sequenceType, this.params);
return database.getMetadata().getSequenceLibrary().getSequenceCount();
}
use of com.orientechnologies.orient.core.exception.OCommandExecutionException in project orientdb by orientechnologies.
the class OCommandExecutorSQLAlterClass method execute.
/**
* Execute the ALTER CLASS.
*/
public Object execute(final Map<Object, Object> iArgs) {
final ODatabaseDocument database = getDatabase();
if (attribute == null)
throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet");
final OClassImpl cls = (OClassImpl) database.getMetadata().getSchema().getClass(className);
if (cls == null)
throw new OCommandExecutionException("Cannot alter class '" + className + "' because not found");
if (!unsafe && attribute == ATTRIBUTES.NAME && cls.isSubClassOf("E"))
throw new OCommandExecutionException("Cannot alter class '" + className + "' because is an Edge class and could break vertices. Use UNSAFE if you want to force it");
// REMOVE CACHE OF COMMAND RESULTS
for (int clId : cls.getPolymorphicClusterIds()) getDatabase().getMetadata().getCommandCache().invalidateResultsOfCluster(getDatabase().getClusterNameById(clId));
if (value != null && attribute == ATTRIBUTES.SUPERCLASS) {
checkClassExists(database, className, decodeClassName(value));
}
if (value != null && attribute == ATTRIBUTES.SUPERCLASSES) {
List<String> classes = Arrays.asList(value.split(",\\s*"));
for (String cName : classes) {
checkClassExists(database, className, decodeClassName(cName));
}
}
if (!unsafe && value != null && attribute == ATTRIBUTES.NAME) {
if (!cls.getIndexes().isEmpty()) {
throw new OCommandExecutionException("Cannot rename class '" + className + "' because it has indexes defined on it. Drop indexes before or use UNSAFE (at your won risk)");
}
}
cls.set(attribute, value);
return Boolean.TRUE;
}
use of com.orientechnologies.orient.core.exception.OCommandExecutionException in project orientdb by orientechnologies.
the class OCommandExecutorSQLAlterCluster method execute.
/**
* Execute the ALTER CLUSTER.
*/
public Object execute(final Map<Object, Object> iArgs) {
if (attribute == null)
throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet");
final List<OCluster> clusters = getClusters();
if (clusters.isEmpty())
throw new OCommandExecutionException("Cluster '" + clusterName + "' not found");
Object result = null;
for (OCluster cluster : getClusters()) {
if (clusterId > -1 && clusterName.equals(String.valueOf(clusterId))) {
clusterName = cluster.getName();
result = getDatabase().alterCluster(clusterName, attribute, value);
} else {
clusterId = cluster.getId();
result = getDatabase().alterCluster(clusterId, attribute, value);
}
}
return result;
}
use of com.orientechnologies.orient.core.exception.OCommandExecutionException in project orientdb by orientechnologies.
the class OCommandExecutorSQLAlterDatabase method execute.
/**
* Execute the ALTER DATABASE.
*/
public Object execute(final Map<Object, Object> iArgs) {
if (attribute == null)
throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet");
final ODatabaseDocumentInternal database = getDatabase();
database.checkSecurity(ORule.ResourceGeneric.DATABASE, ORole.PERMISSION_UPDATE);
database.setInternal(attribute, value);
return null;
}
use of com.orientechnologies.orient.core.exception.OCommandExecutionException in project orientdb by orientechnologies.
the class OCommandExecutorSQLAlterProperty method execute.
/**
* Execute the ALTER PROPERTY.
*/
public Object execute(final Map<Object, Object> iArgs) {
if (attribute == null)
throw new OCommandExecutionException("Cannot execute the command because it has not yet been parsed");
final OClassImpl sourceClass = (OClassImpl) getDatabase().getMetadata().getSchema().getClass(className);
if (sourceClass == null)
throw new OCommandExecutionException("Source class '" + className + "' not found");
final OPropertyImpl prop = (OPropertyImpl) sourceClass.getProperty(fieldName);
if (prop == null)
throw new OCommandExecutionException("Property '" + className + "." + fieldName + "' not exists");
if ("null".equalsIgnoreCase(value))
prop.set(attribute, null);
else
prop.set(attribute, value);
return null;
}
Aggregations