use of com.orientechnologies.orient.core.db.ODatabaseDocumentInternal in project orientdb by orientechnologies.
the class OPropertyImpl method setMax.
public OPropertyImpl setMax(final String max) {
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 max %s", getFullNameQuoted(), quoteString(max));
database.command(new OCommandSQL(cmd)).execute();
} else if (isDistributedCommand()) {
final String cmd = String.format("alter property %s max %s", getFullNameQuoted(), quoteString(max));
final OCommandSQL commandSQL = new OCommandSQL(cmd);
commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
database.command(commandSQL).execute();
setMaxInternal(max);
} else
setMaxInternal(max);
} finally {
releaseSchemaWriteLock();
}
return this;
}
use of com.orientechnologies.orient.core.db.ODatabaseDocumentInternal in project orientdb by orientechnologies.
the class OPropertyImpl method setLinkedType.
public OProperty setLinkedType(final OType linkedType) {
getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE);
checkLinkTypeSupport(getType());
acquireSchemaWriteLock();
try {
final ODatabaseDocumentInternal database = getDatabase();
final OStorage storage = database.getStorage();
if (storage instanceof OStorageProxy) {
final String cmd = String.format("alter property %s linkedtype %s", getFullNameQuoted(), linkedType);
database.command(new OCommandSQL(cmd)).execute();
} else if (isDistributedCommand()) {
final String cmd = String.format("alter property %s linkedtype %s", getFullNameQuoted(), linkedType);
final OCommandSQL commandSQL = new OCommandSQL(cmd);
commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
database.command(commandSQL).execute();
setLinkedTypeInternal(linkedType);
} else
setLinkedTypeInternal(linkedType);
} finally {
releaseSchemaWriteLock();
}
return this;
}
use of com.orientechnologies.orient.core.db.ODatabaseDocumentInternal in project orientdb by orientechnologies.
the class OPropertyImpl method setCustom.
public OPropertyImpl setCustom(final String name, final String value) {
getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE);
acquireSchemaWriteLock();
try {
final String cmd = String.format("alter property %s custom %s=%s", getFullNameQuoted(), name, quoteString(value));
final ODatabaseDocumentInternal database = getDatabase();
final OStorage storage = database.getStorage();
if (storage instanceof OStorageProxy) {
database.command(new OCommandSQL(cmd)).execute();
} else if (isDistributedCommand()) {
final OCommandSQL commandSQL = new OCommandSQL(cmd);
commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
database.command(commandSQL).execute();
setCustomInternal(name, value);
} else
setCustomInternal(name, value);
} finally {
releaseSchemaWriteLock();
}
return this;
}
use of com.orientechnologies.orient.core.db.ODatabaseDocumentInternal in project orientdb by orientechnologies.
the class OClassImpl method renameCluster.
private void renameCluster(String oldName, String newName) {
oldName = oldName.toLowerCase();
newName = newName.toLowerCase();
final ODatabaseDocumentInternal database = getDatabase();
final OStorage storage = database.getStorage();
if (storage.getClusterIdByName(newName) != -1)
return;
final int clusterId = storage.getClusterIdByName(oldName);
if (clusterId == -1)
return;
if (!hasClusterId(clusterId))
return;
database.command(new OCommandSQL("alter cluster `" + oldName + "` name `" + newName + "`")).execute();
}
use of com.orientechnologies.orient.core.db.ODatabaseDocumentInternal in project orientdb by orientechnologies.
the class OClassImpl method dropProperty.
public void dropProperty(final String propertyName) {
if (getDatabase().getTransaction().isActive())
throw new IllegalStateException("Cannot drop a property inside a transaction");
getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_DELETE);
final String lowerName = propertyName.toLowerCase();
acquireSchemaWriteLock();
try {
if (!properties.containsKey(lowerName))
throw new OSchemaException("Property '" + propertyName + "' not found in class " + name + "'");
final ODatabaseDocumentInternal database = getDatabase();
final OStorage storage = database.getStorage();
if (storage instanceof OStorageProxy) {
if (getDatabase().getStorage().getConfiguration().isStrictSql()) {
database.command(new OCommandSQL("drop property " + name + ".`" + propertyName + "`")).execute();
} else {
database.command(new OCommandSQL("drop property " + name + '.' + propertyName)).execute();
}
} else if (isDistributedCommand()) {
OScenarioThreadLocal.executeAsDistributed(new Callable<OProperty>() {
@Override
public OProperty call() throws Exception {
dropPropertyInternal(propertyName);
return null;
}
});
String stm;
if (getDatabase().getStorage().getConfiguration().isStrictSql()) {
stm = "drop property " + name + ".`" + propertyName + "`";
} else {
stm = "drop property " + name + "." + propertyName;
}
final OCommandSQL commandSQL = new OCommandSQL(stm);
commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
database.command(commandSQL).execute();
} else
OScenarioThreadLocal.executeAsDistributed(new Callable<OProperty>() {
@Override
public OProperty call() throws Exception {
dropPropertyInternal(propertyName);
return null;
}
});
} finally {
releaseSchemaWriteLock();
}
}
Aggregations