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);
}
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();
}
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);
}
Aggregations