Search in sources :

Example 1 with OFunctionLibrary

use of com.orientechnologies.orient.core.metadata.function.OFunctionLibrary in project orientdb by orientechnologies.

the class OrientJdbcDatabaseMetaData method getProcedureColumns.

public ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern) throws SQLException {
    database.activateOnCurrentThread();
    final List<ODocument> records = new ArrayList<ODocument>();
    OFunctionLibrary functionLibrary = database.getMetadata().getFunctionLibrary();
    for (String functionName : functionLibrary.getFunctionNames()) {
        if (OrientJdbcUtils.like(functionName, procedureNamePattern)) {
            final OFunction f = functionLibrary.getFunction(procedureNamePattern);
            for (String p : f.getParameters()) {
                final ODocument doc = new ODocument().field("PROCEDURE_CAT", database.getName()).field("PROCEDURE_SCHEM", database.getName()).field("PROCEDURE_NAME", f.getName()).field("COLUMN_NAME", p).field("COLUMN_TYPE", procedureColumnIn).field("DATA_TYPE", java.sql.Types.OTHER).field("SPECIFIC_NAME", f.getName());
                records.add(doc);
            }
            final ODocument doc = new ODocument().field("PROCEDURE_CAT", database.getName()).field("PROCEDURE_SCHEM", database.getName()).field("PROCEDURE_NAME", f.getName()).field("COLUMN_NAME", "return").field("COLUMN_TYPE", procedureColumnReturn).field("DATA_TYPE", java.sql.Types.OTHER).field("SPECIFIC_NAME", f.getName());
            records.add(doc);
        }
    }
    return new OrientJdbcResultSet(new OrientJdbcStatement(connection), records, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
}
Also used : OFunctionLibrary(com.orientechnologies.orient.core.metadata.function.OFunctionLibrary) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) OFunction(com.orientechnologies.orient.core.metadata.function.OFunction)

Example 2 with OFunctionLibrary

use of com.orientechnologies.orient.core.metadata.function.OFunctionLibrary in project orientdb by orientechnologies.

the class OMetadataDefault method init.

private void init(final boolean iLoad) {
    final ODatabaseDocumentInternal database = getDatabase();
    schemaClusterId = database.getClusterIdByName(CLUSTER_INTERNAL_NAME);
    final AtomicBoolean schemaLoaded = new AtomicBoolean(false);
    schema = new OSchemaProxy(database.getStorage().getResource(OSchema.class.getSimpleName(), new Callable<OSchemaShared>() {

        public OSchemaShared call() {
            ODatabaseDocumentInternal database = getDatabase();
            final OSchemaShared instance = new OSchemaShared(database.getStorageVersions().classesAreDetectedByClusterId());
            if (iLoad)
                instance.load();
            schemaLoaded.set(true);
            return instance;
        }
    }), database);
    indexManager = new OIndexManagerProxy(database.getStorage().getResource(OIndexManager.class.getSimpleName(), new Callable<OIndexManager>() {

        public OIndexManager call() {
            OIndexManager instance;
            if (database.getStorage() instanceof OStorageProxy)
                instance = new OIndexManagerRemote(database);
            else
                instance = new OIndexManagerShared(database);
            if (iLoad)
                try {
                    instance.load();
                } catch (Exception e) {
                    OLogManager.instance().error(this, "[OMetadata] Error on loading index manager, reset index configuration", e);
                    instance.create();
                }
            return instance;
        }
    }), database);
    security = new OSecurityProxy(database.getStorage().getResource(OSecurity.class.getSimpleName(), new Callable<OSecurity>() {

        public OSecurity call() {
            final OSecurity instance = OSecurityManager.instance().newSecurity();
            if (iLoad) {
                security = instance;
                instance.load();
            }
            return instance;
        }
    }), database);
    commandCache = database.getStorage().getResource(OCommandCache.class.getSimpleName(), new Callable<OCommandCache>() {

        public OCommandCache call() {
            return new OCommandCacheSoftRefs(database.getName());
        }
    });
    final Class<? extends OSecurity> securityClass = (Class<? extends OSecurity>) database.getProperty(ODatabase.OPTIONS.SECURITY.toString());
    if (securityClass != null)
        // INSTALL CUSTOM WRAPPED SECURITY
        try {
            final OSecurity wrapped = security;
            security = securityClass.getDeclaredConstructor(OSecurity.class, ODatabaseDocumentInternal.class).newInstance(wrapped, database);
        } catch (Exception e) {
            throw OException.wrapException(new OSecurityException("Cannot install custom security implementation (" + securityClass + ")"), e);
        }
    functionLibrary = new OFunctionLibraryProxy(database.getStorage().getResource(OFunctionLibrary.class.getSimpleName(), new Callable<OFunctionLibrary>() {

        public OFunctionLibrary call() {
            final OFunctionLibraryImpl instance = new OFunctionLibraryImpl();
            if (iLoad && !(database.getStorage() instanceof OStorageProxy))
                instance.load();
            return instance;
        }
    }), database);
    sequenceLibrary = new OSequenceLibraryProxy(database.getStorage().getResource(OSequenceLibrary.class.getSimpleName(), new Callable<OSequenceLibrary>() {

        @Override
        public OSequenceLibrary call() throws Exception {
            final OSequenceLibraryImpl instance = new OSequenceLibraryImpl();
            if (iLoad) {
                instance.load();
            }
            return instance;
        }
    }), database);
    scheduler = new OSchedulerProxy(database.getStorage().getResource(OScheduler.class.getSimpleName(), new Callable<OScheduler>() {

        public OScheduler call() {
            final OSchedulerImpl instance = new OSchedulerImpl();
            if (iLoad && !(database.getStorage() instanceof OStorageProxy))
                instance.load();
            return instance;
        }
    }), database);
    if (schemaLoaded.get())
        schema.onPostIndexManagement();
}
Also used : OSchema(com.orientechnologies.orient.core.metadata.schema.OSchema) OIndexManagerShared(com.orientechnologies.orient.core.index.OIndexManagerShared) OIndexManagerRemote(com.orientechnologies.orient.core.index.OIndexManagerRemote) OFunctionLibraryImpl(com.orientechnologies.orient.core.metadata.function.OFunctionLibraryImpl) OSequenceLibraryProxy(com.orientechnologies.orient.core.metadata.sequence.OSequenceLibraryProxy) OStorageProxy(com.orientechnologies.orient.core.storage.OStorageProxy) OFunctionLibraryProxy(com.orientechnologies.orient.core.metadata.function.OFunctionLibraryProxy) OSecurityException(com.orientechnologies.orient.core.exception.OSecurityException) OCommandCacheSoftRefs(com.orientechnologies.orient.core.cache.OCommandCacheSoftRefs) ODatabaseDocumentInternal(com.orientechnologies.orient.core.db.ODatabaseDocumentInternal) OIndexManagerProxy(com.orientechnologies.orient.core.index.OIndexManagerProxy) Callable(java.util.concurrent.Callable) OSequenceLibrary(com.orientechnologies.orient.core.metadata.sequence.OSequenceLibrary) OSchemaProxy(com.orientechnologies.orient.core.metadata.schema.OSchemaProxy) OFunctionLibrary(com.orientechnologies.orient.core.metadata.function.OFunctionLibrary) OSchemaShared(com.orientechnologies.orient.core.metadata.schema.OSchemaShared) OSecurity(com.orientechnologies.orient.core.metadata.security.OSecurity) OSequenceLibraryImpl(com.orientechnologies.orient.core.metadata.sequence.OSequenceLibraryImpl) OSchedulerImpl(com.orientechnologies.orient.core.schedule.OSchedulerImpl) OScheduler(com.orientechnologies.orient.core.schedule.OScheduler) OException(com.orientechnologies.common.exception.OException) OSecurityException(com.orientechnologies.orient.core.exception.OSecurityException) IOException(java.io.IOException) OIndexManager(com.orientechnologies.orient.core.index.OIndexManager) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) OSecurityProxy(com.orientechnologies.orient.core.metadata.security.OSecurityProxy) OSchedulerProxy(com.orientechnologies.orient.core.schedule.OSchedulerProxy)

Example 3 with OFunctionLibrary

use of com.orientechnologies.orient.core.metadata.function.OFunctionLibrary in project orientdb by orientechnologies.

the class OrientJdbcDatabaseMetaData method getProcedures.

public ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) throws SQLException {
    database.activateOnCurrentThread();
    final List<ODocument> records = new ArrayList<ODocument>();
    OFunctionLibrary functionLibrary = database.getMetadata().getFunctionLibrary();
    for (String functionName : functionLibrary.getFunctionNames()) {
        if (OrientJdbcUtils.like(functionName, procedureNamePattern)) {
            final ODocument doc = new ODocument().field("PROCEDURE_CAT", (Object) null).field("PROCEDURE_SCHEM", (Object) null).field("PROCEDURE_NAME", functionName).field("REMARKS", "").field("PROCEDURE_TYPE", procedureResultUnknown).field("SPECIFIC_NAME", functionName);
            records.add(doc);
        }
    }
    return new OrientJdbcResultSet(new OrientJdbcStatement(connection), records, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
}
Also used : OFunctionLibrary(com.orientechnologies.orient.core.metadata.function.OFunctionLibrary) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Aggregations

OFunctionLibrary (com.orientechnologies.orient.core.metadata.function.OFunctionLibrary)3 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)2 OException (com.orientechnologies.common.exception.OException)1 OCommandCacheSoftRefs (com.orientechnologies.orient.core.cache.OCommandCacheSoftRefs)1 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)1 OSecurityException (com.orientechnologies.orient.core.exception.OSecurityException)1 OIndexManager (com.orientechnologies.orient.core.index.OIndexManager)1 OIndexManagerProxy (com.orientechnologies.orient.core.index.OIndexManagerProxy)1 OIndexManagerRemote (com.orientechnologies.orient.core.index.OIndexManagerRemote)1 OIndexManagerShared (com.orientechnologies.orient.core.index.OIndexManagerShared)1 OFunction (com.orientechnologies.orient.core.metadata.function.OFunction)1 OFunctionLibraryImpl (com.orientechnologies.orient.core.metadata.function.OFunctionLibraryImpl)1 OFunctionLibraryProxy (com.orientechnologies.orient.core.metadata.function.OFunctionLibraryProxy)1 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)1 OSchemaProxy (com.orientechnologies.orient.core.metadata.schema.OSchemaProxy)1 OSchemaShared (com.orientechnologies.orient.core.metadata.schema.OSchemaShared)1 OSecurity (com.orientechnologies.orient.core.metadata.security.OSecurity)1 OSecurityProxy (com.orientechnologies.orient.core.metadata.security.OSecurityProxy)1 OSequenceLibrary (com.orientechnologies.orient.core.metadata.sequence.OSequenceLibrary)1 OSequenceLibraryImpl (com.orientechnologies.orient.core.metadata.sequence.OSequenceLibraryImpl)1