Search in sources :

Example 41 with ODatabaseDocumentInternal

use of com.orientechnologies.orient.core.db.ODatabaseDocumentInternal in project orientdb by orientechnologies.

the class OClassImpl method setOverSize.

public OClass setOverSize(final float overSize) {
    getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE);
    acquireSchemaWriteLock();
    try {
        final ODatabaseDocumentInternal database = getDatabase();
        final OStorage storage = database.getStorage();
        if (storage instanceof OStorageProxy) {
            // FORMAT FLOAT LOCALE AGNOSTIC
            final String cmd = String.format("alter class `%s` oversize %s", name, new Float(overSize).toString());
            database.command(new OCommandSQL(cmd)).execute();
        } else if (isDistributedCommand()) {
            // FORMAT FLOAT LOCALE AGNOSTIC
            final String cmd = String.format("alter class `%s` oversize %s", name, new Float(overSize).toString());
            final OCommandSQL commandSQL = new OCommandSQL(cmd);
            commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
            database.command(commandSQL).execute();
            setOverSizeInternal(overSize);
        } else
            setOverSizeInternal(overSize);
    } finally {
        releaseSchemaWriteLock();
    }
    return this;
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) ODatabaseDocumentInternal(com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)

Example 42 with ODatabaseDocumentInternal

use of com.orientechnologies.orient.core.db.ODatabaseDocumentInternal in project orientdb by orientechnologies.

the class OClassImpl method addClusterId.

public OClass addClusterId(final int clusterId) {
    getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE);
    if (isAbstract()) {
        throw new OSchemaException("Impossible to associate a cluster to an abstract class class");
    }
    acquireSchemaWriteLock();
    try {
        final ODatabaseDocumentInternal database = getDatabase();
        final OStorage storage = database.getStorage();
        if (storage instanceof OStorageProxy) {
            final String cmd = String.format("alter class `%s` addcluster %d", name, clusterId);
            database.command(new OCommandSQL(cmd)).execute();
        } else if (isDistributedCommand()) {
            final String cmd = String.format("alter class `%s` addcluster %d", name, clusterId);
            final OCommandSQL commandSQL = new OCommandSQL(cmd);
            commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
            database.command(commandSQL).execute();
            addClusterIdInternal(clusterId);
        } else
            addClusterIdInternal(clusterId);
    } finally {
        releaseSchemaWriteLock();
    }
    return this;
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OSchemaException(com.orientechnologies.orient.core.exception.OSchemaException) ODatabaseDocumentInternal(com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)

Example 43 with ODatabaseDocumentInternal

use of com.orientechnologies.orient.core.db.ODatabaseDocumentInternal in project orientdb by orientechnologies.

the class OClassImpl method removeSuperClass.

@Override
public OClass removeSuperClass(OClass superClass) {
    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 class `%s` superclass -`%s`", name, superClass != null ? superClass.getName() : null);
            database.command(new OCommandSQL(cmd)).execute();
        } else if (isDistributedCommand()) {
            final String cmd = String.format("alter class `%s` superclass -`%s`", name, superClass != null ? superClass.getName() : null);
            final OCommandSQL commandSQL = new OCommandSQL(cmd);
            commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
            database.command(commandSQL).execute();
            removeSuperClassInternal(superClass);
        } else
            removeSuperClassInternal(superClass);
    } finally {
        releaseSchemaWriteLock();
    }
    return this;
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) ODatabaseDocumentInternal(com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)

Example 44 with ODatabaseDocumentInternal

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;
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OAutoshardedStorage(com.orientechnologies.orient.core.storage.OAutoshardedStorage) OStorageProxy(com.orientechnologies.orient.core.storage.OStorageProxy) OStorage(com.orientechnologies.orient.core.storage.OStorage) ODatabaseDocumentInternal(com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)

Example 45 with ODatabaseDocumentInternal

use of com.orientechnologies.orient.core.db.ODatabaseDocumentInternal in project orientdb by orientechnologies.

the class OPropertyImpl method setName.

public OProperty setName(final String name) {
    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 name %s", getFullNameQuoted(), quoteString(name));
            database.command(new OCommandSQL(cmd)).execute();
        } else if (isDistributedCommand()) {
            final String cmd = String.format("alter property %s name %s", getFullNameQuoted(), quoteString(name));
            final OCommandSQL commandSQL = new OCommandSQL(cmd);
            commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
            database.command(commandSQL).execute();
            setNameInternal(name);
        } else
            setNameInternal(name);
    } finally {
        releaseSchemaWriteLock();
    }
    return this;
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OAutoshardedStorage(com.orientechnologies.orient.core.storage.OAutoshardedStorage) OStorageProxy(com.orientechnologies.orient.core.storage.OStorageProxy) OStorage(com.orientechnologies.orient.core.storage.OStorage) ODatabaseDocumentInternal(com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)

Aggregations

ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)149 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)42 OStorage (com.orientechnologies.orient.core.storage.OStorage)31 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)26 OStorageProxy (com.orientechnologies.orient.core.storage.OStorageProxy)20 OCommandExecutionException (com.orientechnologies.orient.core.exception.OCommandExecutionException)18 OAutoshardedStorage (com.orientechnologies.orient.core.storage.OAutoshardedStorage)18 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)16 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)16 ORID (com.orientechnologies.orient.core.id.ORID)14 OException (com.orientechnologies.common.exception.OException)13 IOException (java.io.IOException)13 ORecordId (com.orientechnologies.orient.core.id.ORecordId)12 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)10 OSchemaException (com.orientechnologies.orient.core.exception.OSchemaException)10 ORecord (com.orientechnologies.orient.core.record.ORecord)8 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)7 OMetadataInternal (com.orientechnologies.orient.core.metadata.OMetadataInternal)6 ODatabaseException (com.orientechnologies.orient.core.exception.ODatabaseException)5 OSecurityException (com.orientechnologies.orient.core.exception.OSecurityException)5