@Override
public OResultSet executeDDL(OCommandContext ctx) {
OInternalResultSet result = new OInternalResultSet();
List<com.orientechnologies.orient.core.storage.OCluster> clustersToUpdate = getClusters(ctx);
Object finalValue = attributeValue.execute((OIdentifiable) null, ctx);
com.orientechnologies.orient.core.storage.OCluster.ATTRIBUTES attribute;
try {
attribute = OCluster.ATTRIBUTES.valueOf(attributeName.getStringValue());
} catch (IllegalArgumentException e) {
throw OException.wrapException(new OCommandExecutionException(
"Unknown class attribute '" + attributeName + "'. Supported attributes are: " + Arrays
.toString(OCluster.ATTRIBUTES.values())), e);
}
for (com.orientechnologies.orient.core.storage.OCluster cluster : clustersToUpdate) {
if (attributeName.getStringValue().equalsIgnoreCase("status") || attributeName.getStringValue().equalsIgnoreCase("name"))
getDatabase().getMetadata().getCommandCache().invalidateResultsOfCluster(cluster.getName());
try {
cluster.set(attribute, finalValue);
} catch (IOException e) {
OException.wrapException(new OCommandExecutionException("Cannot execute alter cluster"), e);
}
OResultInternal resultItem = new OResultInternal();
resultItem.setProperty("cluster", cluster.getName());
result.add(resultItem);
}
return result;
}