use of com.orientechnologies.orient.core.storage.OStorageProxy in project orientdb by orientechnologies.
the class OPropertyImpl method setDefaultValue.
public OPropertyImpl setDefaultValue(final String defaultValue) {
getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE);
acquireSchemaWriteLock();
try {
final ODatabaseDocumentInternal database = getDatabase();
final OStorage storage = database.getStorage();
if (storage instanceof OStorageProxy) {
final String cmd = String.format("alter property %s default %s", getFullNameQuoted(), quoteString(defaultValue));
database.command(new OCommandSQL(cmd)).execute();
} else if (isDistributedCommand()) {
final String cmd = String.format("alter property %s default %s", getFullNameQuoted(), quoteString(defaultValue));
final OCommandSQL commandSQL = new OCommandSQL(cmd);
commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
database.command(commandSQL).execute();
setDefaultValueInternal(defaultValue);
} else {
setDefaultValueInternal(defaultValue);
}
} finally {
releaseSchemaWriteLock();
}
return this;
}
use of com.orientechnologies.orient.core.storage.OStorageProxy in project orientdb by orientechnologies.
the class OPropertyImpl method setCollate.
public OProperty setCollate(String collate) {
if (collate == null)
collate = ODefaultCollate.NAME;
getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE);
acquireSchemaWriteLock();
try {
final ODatabaseDocumentInternal database = getDatabase();
final OStorage storage = database.getStorage();
final String cmd = String.format("alter property %s collate %s", getFullNameQuoted(), quoteString(collate));
final OCommandSQL commandSQL = new OCommandSQL(cmd);
if (storage instanceof OStorageProxy) {
database.command(commandSQL).execute();
} else if (isDistributedCommand()) {
commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
database.command(commandSQL).execute();
setCollateInternal(collate);
} else
setCollateInternal(collate);
} finally {
releaseSchemaWriteLock();
}
return this;
}
use of com.orientechnologies.orient.core.storage.OStorageProxy in project orientdb by orientechnologies.
the class OPropertyImpl method setReadonly.
public OPropertyImpl setReadonly(final boolean isReadonly) {
getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE);
acquireSchemaWriteLock();
try {
final ODatabaseDocumentInternal database = getDatabase();
final OStorage storage = database.getStorage();
if (storage instanceof OStorageProxy) {
final String cmd = String.format("alter property %s readonly %s", getFullNameQuoted(), isReadonly);
database.command(new OCommandSQL(cmd)).execute();
} else if (isDistributedCommand()) {
final String cmd = String.format("alter property %s readonly %s", getFullNameQuoted(), isReadonly);
final OCommandSQL commandSQL = new OCommandSQL(cmd);
commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
database.command(commandSQL).execute();
setReadonlyInternal(isReadonly);
} else
setReadonlyInternal(isReadonly);
} finally {
releaseSchemaWriteLock();
}
return this;
}
use of com.orientechnologies.orient.core.storage.OStorageProxy in project orientdb by orientechnologies.
the class OPropertyImpl method setRegexp.
public OPropertyImpl setRegexp(final String regexp) {
getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE);
acquireSchemaWriteLock();
try {
final ODatabaseDocumentInternal database = getDatabase();
final OStorage storage = database.getStorage();
if (storage instanceof OStorageProxy) {
final String cmd = String.format("alter property %s regexp %s", getFullNameQuoted(), quoteString(regexp));
database.command(new OCommandSQL(cmd)).execute();
} else if (isDistributedCommand()) {
final String cmd = String.format("alter property %s regexp %s", getFullNameQuoted(), quoteString(regexp));
final OCommandSQL commandSQL = new OCommandSQL(cmd);
commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
database.command(commandSQL).execute();
setRegexpInternal(regexp);
} else
setRegexpInternal(regexp);
} finally {
releaseSchemaWriteLock();
}
return this;
}
use of com.orientechnologies.orient.core.storage.OStorageProxy in project orientdb by orientechnologies.
the class OSchemaShared method dropClass.
/*
* (non-Javadoc)
*
* @see com.orientechnologies.orient.core.metadata.schema.OSchema#dropClass(java.lang.String)
*/
public void dropClass(final String className) {
final ODatabaseDocumentInternal db = getDatabase();
final OStorage storage = db.getStorage();
final StringBuilder cmd;
acquireSchemaWriteLock();
try {
if (getDatabase().getTransaction().isActive())
throw new IllegalStateException("Cannot drop a class inside a transaction");
if (className == null)
throw new IllegalArgumentException("Class name is null");
getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_DELETE);
final String key = className.toLowerCase();
OClass cls = classes.get(key);
if (cls == null)
throw new OSchemaException("Class '" + className + "' was not found in current database");
if (!cls.getSubclasses().isEmpty())
throw new OSchemaException("Class '" + className + "' cannot be dropped because it has sub classes " + cls.getSubclasses() + ". Remove the dependencies before trying to drop it again");
cmd = new StringBuilder("drop class ");
cmd.append(className);
cmd.append(" unsafe");
if (executeThroughDistributedStorage()) {
final OAutoshardedStorage autoshardedStorage = (OAutoshardedStorage) storage;
OCommandSQL commandSQL = new OCommandSQL(cmd.toString());
commandSQL.addExcludedNode(autoshardedStorage.getNodeId());
db.command(commandSQL).execute();
dropClassInternal(className);
} else if (storage instanceof OStorageProxy) {
final OCommandSQL commandSQL = new OCommandSQL(cmd.toString());
db.command(commandSQL).execute();
final OClass classToDrop = getClass(className);
reload();
if (// really dropped, for example there may be no rights to drop a class
getClass(className) == null)
dropClassIndexes(classToDrop);
} else
dropClassInternal(className);
// FREE THE RECORD CACHE
getDatabase().getLocalCache().freeCluster(cls.getDefaultClusterId());
} finally {
releaseSchemaWriteLock();
}
}
Aggregations