use of com.orientechnologies.orient.core.storage.OStorageProxy in project orientdb by orientechnologies.
the class OPropertyImpl method setNotNull.
public OPropertyImpl setNotNull(final boolean isNotNull) {
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 notnull %s", getFullNameQuoted(), isNotNull);
database.command(new OCommandSQL(cmd)).execute();
} else if (isDistributedCommand()) {
final String cmd = String.format("alter property %s notnull %s", getFullNameQuoted(), isNotNull);
final OCommandSQL commandSQL = new OCommandSQL(cmd);
commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
database.command(commandSQL).execute();
setNotNullInternal(isNotNull);
} else
setNotNullInternal(isNotNull);
} finally {
releaseSchemaWriteLock();
}
return this;
}
use of com.orientechnologies.orient.core.storage.OStorageProxy 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.storage.OStorageProxy 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.storage.OStorageProxy 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.storage.OStorageProxy in project orientdb by orientechnologies.
the class IndexTest method testIndexInComplexSelectTwo.
@Test(dependsOnMethods = "populateIndexDocuments")
public void testIndexInComplexSelectTwo() {
if (database.getStorage() instanceof OStorageProxy) {
return;
}
final boolean oldRecording = Orient.instance().getProfiler().isRecording();
if (!oldRecording) {
Orient.instance().getProfiler().startRecording();
}
long indexQueries = Orient.instance().getProfiler().getCounter("db.demo.query.indexUsed");
if (indexQueries < 0) {
indexQueries = 0;
}
final List<Profile> result = database.command(new OSQLSynchQuery<Profile>("select * from Profile where " + "((name = 'Giuseppe' OR name <> 'Napoleone')" + " AND (nick is not null AND (name = 'Giuseppe' OR name <> 'Napoleone') AND (nick >= 'ZZZJayLongNickIndex3' OR nick >= 'ZZZJayLongNickIndex4')))")).execute();
if (!oldRecording) {
Orient.instance().getProfiler().stopRecording();
}
final List<String> expectedNicks = new ArrayList<String>(Arrays.asList("ZZZJayLongNickIndex3", "ZZZJayLongNickIndex4", "ZZZJayLongNickIndex5"));
Assert.assertEquals(result.size(), 3);
for (Profile profile : result) {
expectedNicks.remove(profile.getNick());
}
Assert.assertEquals(expectedNicks.size(), 0);
long newIndexQueries = Orient.instance().getProfiler().getCounter("db.demo.query.indexUsed");
Assert.assertEquals(newIndexQueries, indexQueries);
}
Aggregations