use of com.orientechnologies.orient.core.db.ODatabaseDocumentInternal in project orientdb by orientechnologies.
the class OPropertyImpl method clearCustom.
public void clearCustom() {
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 custom clear", getFullNameQuoted());
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();
clearCustomInternal();
} else
clearCustomInternal();
} finally {
releaseSchemaWriteLock();
}
}
use of com.orientechnologies.orient.core.db.ODatabaseDocumentInternal in project orientdb by orientechnologies.
the class OPropertyImpl method setMin.
public OPropertyImpl setMin(final String min) {
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 min %s", getFullNameQuoted(), quoteString(min));
database.command(new OCommandSQL(cmd)).execute();
} else if (isDistributedCommand()) {
final String cmd = String.format("alter property %s min %s", getFullNameQuoted(), quoteString(min));
final OCommandSQL commandSQL = new OCommandSQL(cmd);
commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
database.command(commandSQL).execute();
setMinInternal(min);
} else
setMinInternal(min);
} finally {
releaseSchemaWriteLock();
}
return this;
}
use of com.orientechnologies.orient.core.db.ODatabaseDocumentInternal in project orientdb by orientechnologies.
the class OPropertyImpl method setType.
public OPropertyImpl setType(final OType type) {
getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE);
final ODatabaseDocumentInternal database = getDatabase();
acquireSchemaWriteLock();
try {
final OStorage storage = database.getStorage();
if (storage instanceof OStorageProxy) {
final String cmd = String.format("alter property %s type %s", getFullNameQuoted(), quoteString(type.toString()));
database.command(new OCommandSQL(cmd)).execute();
} else if (isDistributedCommand()) {
final String cmd = String.format("alter property %s type %s", getFullNameQuoted(), quoteString(type.toString()));
final OCommandSQL commandSQL = new OCommandSQL(cmd);
commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
database.command(commandSQL).execute();
setTypeInternal(type);
} else
setTypeInternal(type);
} finally {
releaseSchemaWriteLock();
}
owner.fireDatabaseMigration(database, globalRef.getName(), globalRef.getType());
return this;
}
use of com.orientechnologies.orient.core.db.ODatabaseDocumentInternal in project orientdb by orientechnologies.
the class OPropertyImpl method setMandatory.
public OPropertyImpl setMandatory(final boolean isMandatory) {
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 mandatory %s", getFullNameQuoted(), isMandatory);
database.command(new OCommandSQL(cmd)).execute();
} else if (isDistributedCommand()) {
final String cmd = String.format("alter property %s mandatory %s", getFullNameQuoted(), isMandatory);
final OCommandSQL commandSQL = new OCommandSQL(cmd);
commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
database.command(commandSQL).execute();
setMandatoryInternal(isMandatory);
} else
setMandatoryInternal(isMandatory);
} finally {
releaseSchemaWriteLock();
}
return this;
}
use of com.orientechnologies.orient.core.db.ODatabaseDocumentInternal in project orientdb by orientechnologies.
the class OClassImpl method removeClusterId.
public OClass removeClusterId(final int clusterId) {
getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE);
if (clusterIds.length == 1 && clusterId == clusterIds[0])
throw new ODatabaseException(" Impossible to remove the last cluster of class '" + getName() + "' drop the class instead");
acquireSchemaWriteLock();
try {
final ODatabaseDocumentInternal database = getDatabase();
final OStorage storage = database.getStorage();
if (storage instanceof OStorageProxy) {
final String cmd = String.format("alter class `%s` removecluster %d", name, clusterId);
database.command(new OCommandSQL(cmd)).execute();
} else if (isDistributedCommand()) {
final String cmd = String.format("alter class `%s` removecluster %d", name, clusterId);
final OCommandSQL commandSQL = new OCommandSQL(cmd);
commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
database.command(commandSQL).execute();
removeClusterIdInternal(clusterId);
} else
removeClusterIdInternal(clusterId);
} finally {
releaseSchemaWriteLock();
}
return this;
}
Aggregations