private OClass checkOrientClass(String name) { OClass oClass = oSchema.getClass(name); checkArgument(oClass != null, "No such Orient class: %s", name); return oClass; }
public void createClass(final String className, final String superClassName) { makeActive(); OClass superClass = database.getMetadata().getSchema().getClass(superClassName); if (superClass == null) { Collection<OClass> allClasses = database.getMetadata().getSchema().getClasses(); throw new IllegalArgumentException("unable to find class " + superClassName + ". Available classes: " + allClasses); } createClass(className, superClass); }
@Override public OClass getLinkedClass() { if (linkedClassName == null) return null; if (linkedClass != null) return linkedClass; OSchema schema = ((OImmutableClass) owner).getSchema(); linkedClass = schema.getClass(linkedClassName); return linkedClass; }
private OLuceneFullTextIndex searchForIndex(OCommandContext ctx, String className) { OMetadata dbMetadata = ctx.getDatabase().activateOnCurrentThread().getMetadata(); List<OLuceneFullTextIndex> indices = dbMetadata.getSchema().getClass(className).getIndexes().stream() .filter(idx -> idx instanceof OLuceneFullTextIndex).map(idx -> (OLuceneFullTextIndex) idx).collect(Collectors.toList()); if (indices.size() > 1) { throw new IllegalArgumentException("too many full-text indices on given class: " + className); } return indices.size() == 0 ? null : indices.get(0); }
/** * retrieves a class from the schema * * @param className The class name * * @return The object representing the class in the schema. Null if the class does not exist. */ default OClass getClass(String className) { OSchema schema = getMetadata().getSchema(); return schema.getClass(className); }
private OLuceneFullTextIndex searchForIndex(String className, OCommandContext ctx, List<String> fieldNames) { OMetadata dbMetadata = ctx.getDatabase().activateOnCurrentThread().getMetadata(); List<OLuceneFullTextIndex> indices = dbMetadata.getSchema().getClass(className).getIndexes().stream() .filter(idx -> idx instanceof OLuceneFullTextIndex).map(idx -> (OLuceneFullTextIndex) idx) .filter(idx -> intersect(idx.getDefinition().getFields(), fieldNames)).collect(Collectors.toList()); if (indices.size() > 1) { throw new IllegalArgumentException("too many indices matching given field name: " + String.join(",", fieldNames)); } return indices.size() == 0 ? null : indices.get(0); }
public OrientClassVertexIterator(OrientBaseGraph graph, Iterator<Vertex> iterator, String klass) { this.iterator = iterator; this.graph = graph; this.klass = graph.getRawGraph().getMetadata().getSchema().getClass(klass); }
public ResultSet getImportedKeys(String catalog, String schema, String table) throws SQLException { database.activateOnCurrentThread(); OClass aClass = database.getMetadata().getSchema().getClass(table); aClass.declaredProperties().stream().forEach(p -> p.getType()); return getEmptyResultSet(); }
protected OClass getExpectedClass(OQueryDataProvider<ODocument> provider) { String expectedClass = getWidgetDocument().field("class"); OClass ret = expectedClass!=null?getSchema().getClass(expectedClass):null; if(ret==null) { ret = provider.probeOClass(20); } return ret; }
public final OClass getEdgeType(final String iTypeName) { final OClass cls = getRawGraph().getMetadata().getSchema() .getClass(iTypeName); if (cls != null) checkEdgeType(cls); return cls; }
/** * Returns the V persistent class as OrientVertexType instance. */ public OrientVertexType getVertexBaseType() { makeActive(); return new OrientVertexType(this, getRawGraph().getMetadata().getSchema().getClass(OrientVertexType.CLASS_NAME)); }
private boolean filterClass(String klass) { ODatabaseDocument database = getDatabase(); OSchema schema = database.getMetadata().getSchema(); OClass schemaClass = schema.getClass(klass); if (vertexStep) { return schemaClass.isSubClassOf("V"); } else { return schemaClass.isSubClassOf("E"); } }
private void createBucketNameIndex() { try (ODatabaseDocumentTx db = componentDatabaseInstance.get().connect()) { if (db.getMetadata().getIndexManager().getIndex(I_BUCKET_NAME_VERSION) == null) { OSchema schema = db.getMetadata().getSchema(); OClass type = schema.getClass(COMPONENT_CLASS); if (type != null) { type.createIndex(I_BUCKET_NAME_VERSION, INDEX_TYPE.NOTUNIQUE, new String[] { P_BUCKET, P_NAME, P_VERSION }); } } } } }
private void internalInit(ODatabaseInternal db) { if (db.getMetadata().getSchema().getClass(BASE_CLASS) == null) { db.getMetadata().getSchema().createAbstractClass(BASE_CLASS); shapeBuilder.initClazz(db); } } }
public void createClassTrigger() { final ODatabaseDocument db = ODatabaseRecordThreadLocal.instance().get(); OClass classTrigger = db.getMetadata().getSchema().getClass(OClassTrigger.CLASSNAME); if (classTrigger == null) classTrigger = db.getMetadata().getSchema().createAbstractClass(OClassTrigger.CLASSNAME); }
@Override protected OProperty doBackward(String b) { ODatabaseDocument db = OrientDbWebSession.get().getDatabase(); OSchema schema = db.getMetadata().getSchema(); String className = Strings.beforeFirst(b, '.'); String propertyName = Strings.afterFirst(b, '.'); OClass oClass = schema.getClass(className); return oClass.getProperty(propertyName); }
private void checkIndex(OIndex index) { List<String> fields = index.getDefinition().getFields(); String className = index.getDefinition().getClassName(); OClass clazz = database.getMetadata().getSchema().getClass(className); int[] clusterIds = clazz.getPolymorphicClusterIds(); for (int clusterId : clusterIds) { checkCluster(clusterId, index, fields); } }
@Override public ODocument createWidgetDocument(IWidgetType<?> widgetType) { String oClassName = widgetType.getOClassName(); if(oClassName==null) oClassName = OCLASS_WIDGET; OClass oClass = getDatabase().getMetadata().getSchema().getClass(oClassName); if(oClass==null || !oClass.isSubClassOf(OCLASS_WIDGET)) throw new WicketRuntimeException("Wrong OClass specified for widget settings: "+oClassName); ODocument widgetDoc = new ODocument(oClass); widgetDoc.field(OPROPERTY_TYPE_ID, widgetType.getId()); return widgetDoc; }
@Override public long getDistributedTimeout() { final OClass cls = getDatabase().getMetadata().getSchema().getClass(className); if (className != null && cls != null) return getDatabase().getConfiguration().getValueAsLong(OGlobalConfiguration.DISTRIBUTED_COMMAND_QUICK_TASK_SYNCH_TIMEOUT) + (2 * cls.count()); return getDatabase().getConfiguration().getValueAsLong(OGlobalConfiguration.DISTRIBUTED_COMMAND_QUICK_TASK_SYNCH_TIMEOUT); }
private static void rewriteIndexChainsAsSubqueries(QueryPlanningInfo info, OCommandContext ctx) { if (ctx == null || ctx.getDatabase() == null) { return; } if (info.whereClause != null && info.target != null && info.target.getItem().getIdentifier() != null) { OClass clazz = ctx.getDatabase().getMetadata().getSchema().getClass(info.target.getItem().getIdentifier().getStringValue()); if (clazz != null) { info.whereClause.getBaseExpression().rewriteIndexChainsAsSubqueries(ctx, clazz); } } }