use of com.orientechnologies.orient.core.storage.OStorageProxy 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.storage.OStorageProxy 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.storage.OStorageProxy 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.storage.OStorageProxy 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.storage.OStorageProxy in project orientdb by orientechnologies.
the class ORecordSerializerCSVAbstract method linkToStream.
/**
* Serialize the link.
*
* @param buffer
* @param iParentRecord
* @param iLinked
* Can be an instance of ORID or a Record<?>
* @return
*/
private static OIdentifiable linkToStream(final StringBuilder buffer, final ODocument iParentRecord, Object iLinked) {
if (iLinked == null)
// NULL REFERENCE
return null;
OIdentifiable resultRid = null;
ORID rid;
if (iLinked instanceof ORID) {
// JUST THE REFERENCE
rid = (ORID) iLinked;
assert rid.getIdentity().isValid() || (ODatabaseRecordThreadLocal.INSTANCE.get().getStorage() instanceof OStorageProxy) : "Impossible to serialize invalid link " + rid.getIdentity();
resultRid = rid;
} else {
if (iLinked instanceof String)
iLinked = new ORecordId((String) iLinked);
else if (!(iLinked instanceof ORecord)) {
// NOT RECORD: TRY TO EXTRACT THE DOCUMENT IF ANY
final String boundDocumentField = OObjectSerializerHelperManager.getInstance().getDocumentBoundField(iLinked.getClass());
if (boundDocumentField != null)
iLinked = OObjectSerializerHelperManager.getInstance().getFieldValue(iLinked, boundDocumentField);
}
if (!(iLinked instanceof OIdentifiable))
throw new IllegalArgumentException("Invalid object received. Expected a OIdentifiable but received type=" + iLinked.getClass().getName() + " and value=" + iLinked);
// RECORD
ORecord iLinkedRecord = ((OIdentifiable) iLinked).getRecord();
rid = iLinkedRecord.getIdentity();
assert rid.getIdentity().isValid() || (ODatabaseRecordThreadLocal.INSTANCE.get().getStorage() instanceof OStorageProxy) : "Impossible to serialize invalid link " + rid.getIdentity();
final ODatabaseDocument database = ODatabaseRecordThreadLocal.INSTANCE.get();
if (iParentRecord != null) {
if (!database.isRetainRecords())
// REPLACE CURRENT RECORD WITH ITS ID: THIS SAVES A LOT OF MEMORY
resultRid = iLinkedRecord.getIdentity();
}
}
if (rid.isValid())
rid.toString(buffer);
return resultRid;
}
Aggregations