public OIndexManager call(ODatabaseDocumentInternal database) { return database.getMetadata().getIndexManager(); } });
/** * @return {@link OSchema} for current request */ public OSchema getSchema() { return getDatabase().getMetadata().getSchema(); }
private void fetchSchemaIfCan(ODatabaseDocumentInternal db) { if (_schema == null) { if (db != null && !db.isClosed()) { OMetadataInternal metadata = db.getMetadata(); _schema = metadata.getImmutableSchemaSnapshot(); } } }
protected OGlobalProperty getGlobalPropertyById(int id) { if (_schema == null) { OMetadataInternal metadata = getDatabase().getMetadata(); _schema = metadata.getImmutableSchemaSnapshot(); } OGlobalProperty prop = _schema.getGlobalPropertyById(id); if (prop == null) { ODatabaseDocument db = getDatabase(); if (db == null || db.isClosed()) throw new ODatabaseException( "Cannot unmarshall the document because no database is active, use detach for use the document outside the database session scope"); OMetadataInternal metadata = (OMetadataInternal) db.getMetadata(); if (metadata.getImmutableSchemaSnapshot() != null) metadata.clearThreadLocalSchemaSnapshot(); metadata.reload(); metadata.makeThreadLocalSchemaSnapshot(); _schema = metadata.getImmutableSchemaSnapshot(); prop = _schema.getGlobalPropertyById(id); } return prop; }
protected Set<String> getInvolvedClustersOfIndex(final String iIndexName) { final ODatabaseDocumentInternal db = getDatabase(); final Set<String> clusters = new HashSet<String>(); final OMetadataInternal metadata = (OMetadataInternal) db.getMetadata(); final OIndex<?> idx = metadata.getIndexManager().getIndex(iIndexName); if (idx != null && idx.getDefinition() != null) { final String clazz = idx.getDefinition().getClassName(); if (clazz != null) { final OClass cls = metadata.getImmutableSchemaSnapshot().getClass(clazz); if (cls != null) for (int clId : cls.getClusterIds()) { final String clName = db.getClusterNameById(clId); if (clName != null) clusters.add(clName.toLowerCase(Locale.ENGLISH)); } } } return clusters; }
database.getMetadata().getIndexManager().reload(); for (OIndex<?> index : database.getMetadata().getIndexManager().getIndexes()) { if (index.isAutomatic()) indexesToRebuild.add(index.getName()); database.getMetadata().reload();
public void setClassName(final String className) { _immutableClazz = null; _immutableSchemaVersion = -1; _className = className; if (className == null) { return; } final ODatabaseDocument db = getDatabaseIfDefined(); if (db != null) { OMetadataInternal metadata = (OMetadataInternal) db.getMetadata(); this._immutableClazz = (OImmutableClass) metadata.getImmutableSchemaSnapshot().getClass(className); OClass clazz; if (this._immutableClazz != null) { clazz = this._immutableClazz; } else { clazz = metadata.getSchema().getOrCreateClass(className); } if (clazz != null) { _className = clazz.getName(); convertFieldsToClass(clazz); } } }
protected void removeDefaultClusters() { listener.onMessage( "\nWARN: Exported database does not support manual index separation." + " Manual index cluster will be dropped."); // In v4 new cluster for manual indexes has been implemented. To keep database consistent we should shift back // all clusters and recreate cluster for manual indexes in the end. database.dropCluster(OMetadataDefault.CLUSTER_MANUAL_INDEX_NAME, true); final OSchema schema = database.getMetadata().getSchema(); if (schema.existsClass(OUser.CLASS_NAME)) schema.dropClass(OUser.CLASS_NAME); if (schema.existsClass(ORole.CLASS_NAME)) schema.dropClass(ORole.CLASS_NAME); if (schema.existsClass(OSecurityShared.RESTRICTED_CLASSNAME)) schema.dropClass(OSecurityShared.RESTRICTED_CLASSNAME); if (schema.existsClass(OFunction.CLASS_NAME)) schema.dropClass(OFunction.CLASS_NAME); if (schema.existsClass("ORIDs")) schema.dropClass("ORIDs"); if (schema.existsClass(OClassTrigger.CLASSNAME)) schema.dropClass(OClassTrigger.CLASSNAME); schema.save(); database.dropCluster(OStorage.CLUSTER_DEFAULT_NAME, true); database.getStorage().setDefaultClusterId(database.addCluster(OStorage.CLUSTER_DEFAULT_NAME)); // Starting from v4 schema has been moved to internal cluster. // Create a stub at #2:0 to prevent cluster position shifting. new ODocument().save(OStorage.CLUSTER_DEFAULT_NAME); database.getMetadata().getSecurity().create(); }
protected void updateDatabaseInfo() { currentDatabase.getStorage().reload(); currentDatabase.getMetadata().reload(); }
long count; currentDatabase.getMetadata().reload(); final List<OClass> classes = new ArrayList<OClass>(currentDatabase.getMetadata().getImmutableSchemaSnapshot().getClasses()); Collections.sort(classes, new Comparator<OClass>() { public int compare(OClass o1, OClass o2) {
public OUser addRole(final String iRole) { if (iRole != null) addRole(document.getDatabase().getMetadata().getSecurity().getRole(iRole)); return this; }
protected double getCustomHeuristicCost(final String functionName, final String[] vertextAxisNames, final OrientVertex start, final OrientVertex goal, final OrientVertex current, final OrientVertex parent, final long depth, double dFactor) { double heuristic = 0.0; OrientGraph ff; OFunction func = OrientGraph.getActiveGraph().getRawGraph().getMetadata().getFunctionLibrary().getFunction(functionName); Object fValue = func.executeInContext(context, vertextAxisNames, start, goal, current, parent, depth, dFactor); if (fValue != null && fValue instanceof Number) { heuristic = doubleOrDefault(fValue, heuristic); } return heuristic; }
OClass klass = ODocumentInternal.getImmutableSchemaClass(r); if (klass == null) { graph.getDatabase().getMetadata().reload(); klass = graph.getDatabase().getMetadata().getSchema().getClass(inverseFieldName); if (klass == null) { OLogManager.instance().warn(null, "Removing edge, schema class not found for " + r);
@Override public void recreateIndexes(ODatabaseDocumentInternal database) { acquireExclusiveLock(); try { if (recreateIndexesThread != null && recreateIndexesThread.isAlive()) // BUILDING ALREADY IN PROGRESS return; document = database.load(new ORecordId(database.getStorage().getConfiguration().getIndexMgrRecordId())); Runnable recreateIndexesTask = new RecreateIndexesTask(database.getStorage()); recreateIndexesThread = new Thread(recreateIndexesTask, "OrientDB rebuild indexes"); recreateIndexesThread.setUncaughtExceptionHandler(new OUncaughtExceptionHandler()); recreateIndexesThread.start(); } finally { releaseExclusiveLock(); } if (database.getConfiguration().getValueAsBoolean(OGlobalConfiguration.INDEX_SYNCHRONOUS_AUTO_REBUILD)) { waitTillIndexRestore(); database.getMetadata().reload(); } }
checkForDatabase(); currentDatabase.getMetadata().reload(); final OClass cls = currentDatabase.getMetadata().getImmutableSchemaSnapshot().getClass(iClassName);
database.getMetadata().getSecurity().allowIdentity(iDocument, f, identity); return true;
if (clzMethod != null) return clzMethod; func = database.getMetadata().getFunctionLibrary().getFunction(fieldName); if (func == null) { // check if it is rid if (OStringSerializerHelper.contains(fieldName, ORID.SEPARATOR)) { ODocument funcDoc = database.load(new ORecordId(fieldName)); if (funcDoc != null) { func = database.getMetadata().getFunctionLibrary().getFunction((String) funcDoc.field("name")); (String) ((ODocument) funcProp).field("name") : funcProp.toString(); func = database.getMetadata().getFunctionLibrary().getFunction(funcName);
public OIndexManager call(ODatabaseDocumentInternal database) { return database.getMetadata().getIndexManager(); } });
private void init(final ODatabaseDocumentInternal database) { if (database.getMetadata().getSchema().existsClass(OSequence.CLASS_NAME)) { return; } final OClassImpl sequenceClass = (OClassImpl) database.getMetadata().getSchema().createClass(OSequence.CLASS_NAME); OSequence.initClass(sequenceClass); }