public OrientVertexProperty createEdgeProperty(final Direction iDirection, String iEdgeClassName) { return createEdgeProperty(iDirection, iEdgeClassName, OType.ANY); }
@Override public OrientVertexType getSuperClass() { return new OrientVertexType(graph, super.getSuperClass()); }
private String[] allSubClassesLabels() { String[] classes = null; if (labels != null && labels.length > 0) { List<String> tmpClasses = new ArrayList<String>(); for (String label : labels) { OrientVertexType vertexType = ((OrientBaseGraph) graph).getVertexType(label); tmpClasses.add(vertexType.getName()); Collection<OClass> allSubclasses = vertexType.getAllSubclasses(); for (OClass klass : allSubclasses) { tmpClasses.add(klass.getName()); } } classes = tmpClasses.toArray(new String[tmpClasses.size()]); } return classes; }
@Override public void addVertexIndex(String indexName, Class<?> clazzOfVertices, boolean unique, String fieldKey, FieldType fieldType) { if (log.isDebugEnabled()) { log.debug("Adding vertex index for class {" + clazzOfVertices.getName() + "}"); } OrientGraphNoTx noTx = rawNoTx(); try { String name = clazzOfVertices.getSimpleName(); OrientVertexType v = noTx.getVertexType(name); if (v == null) { throw new RuntimeException("Vertex type {" + name + "} is unknown. Can't create index {" + indexName + "}"); } if (v.getProperty(fieldKey) == null) { OType type = toType(fieldType); OType subType = toSubType(fieldType); if (subType != null) { v.createProperty(fieldKey, type, subType); } else { v.createProperty(fieldKey, type); } } if (v.getClassIndex(indexName) == null) { v.createIndex(indexName, unique ? OClass.INDEX_TYPE.UNIQUE_HASH_INDEX.toString() : OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX.toString(), null, new ODocument().fields("ignoreNullValues", true), new String[] { fieldKey }); } } finally { noTx.shutdown(); } }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public Object call(final OrientBaseGraph g) { OrientVertexType v = g.getVertexBaseType(); if(!v.existsProperty(NODE_ID)) { // TODO fix schema detection hack later v.createProperty(NODE_ID, OType.INTEGER); g.createKeyIndex(NODE_ID, Vertex.class, new Parameter("type", "UNIQUE_HASH_INDEX"), new Parameter( "keytype", "INTEGER")); v.createEdgeProperty(Direction.OUT, SIMILAR, OType.LINKBAG); v.createEdgeProperty(Direction.IN, SIMILAR, OType.LINKBAG); OrientEdgeType similar = g.createEdgeType(SIMILAR); similar.createProperty("out", OType.LINK, v); similar.createProperty("in", OType.LINK, v); g.createKeyIndex(COMMUNITY, Vertex.class, new Parameter("type", "NOTUNIQUE_HASH_INDEX"), new Parameter("keytype", "INTEGER")); g.createKeyIndex(NODE_COMMUNITY, Vertex.class, new Parameter("type", "NOTUNIQUE_HASH_INDEX"), new Parameter("keytype", "INTEGER")); } return null; } });
status.createProperty("host", OType.STRING); status.createProperty("app", OType.STRING); status.createProperty("map", OType.EMBEDDEDMAP); config.createProperty("configId", OType.STRING); config.createProperty("description", OType.STRING); config.createProperty("properties", OType.EMBEDDEDMAP); config.createProperty("createDate", OType.DATETIME); config.createProperty("updateDate", OType.DATETIME); graph.createKeyIndex("configId", Vertex.class, new Parameter("type", "UNIQUE"), new Parameter("class", "Config")); hostConfig.createProperty("host", OType.STRING); hostConfig.createProperty("configId", OType.STRING); hostConfig.createProperty("description", OType.STRING); hostConfig.createProperty("properties", OType.EMBEDDEDMAP); hostConfig.createProperty("createDate", OType.DATETIME); hostConfig.createProperty("updateDate", OType.DATETIME); hostConfig.createIndex("configHostIdIdx", OClass.INDEX_TYPE.UNIQUE, "host", "configId"); role.createProperty("roleId", OType.STRING); role.createProperty("host", OType.STRING); role.createProperty("description", OType.STRING); role.createProperty("createDate", OType.DATETIME); role.createProperty("updateDate", OType.DATETIME); graph.createKeyIndex("roleId", Vertex.class, new Parameter("type", "UNIQUE"), new Parameter("class", "Role")); user.createProperty("host", OType.STRING); user.createProperty("userId", OType.STRING); user.createProperty("email", OType.STRING);
/** * Returns the persistent class for type iTypeName as OrientVertexType instance. * * @param iTypeName Vertex class name */ public OrientVertexType getVertexType(final String iTypeName) { makeActive(); final OClass cls = getRawGraph().getMetadata().getSchema().getClass(iTypeName); if (cls == null) return null; OrientVertexType.checkType(cls); return new OrientVertexType(this, cls); }
/** * Creates a new Vertex persistent class specifying the super class. * * @param iClassName Vertex class name * @param iSuperClass OClass Vertex to extend * * @return OrientVertexType instance representing the persistent class */ public OrientVertexType createVertexType(final String iClassName, final OClass iSuperClass) { makeActive(); OrientVertexType.checkType(iSuperClass); return executeOutsideTx(new OCallable<OrientVertexType, OrientBaseGraph>() { @Override public OrientVertexType call(final OrientBaseGraph g) { return new OrientVertexType(g, getRawGraph().getMetadata().getSchema().createClass(iClassName, iSuperClass)); } }, "create vertex type '", iClassName, "' as subclass of '", iSuperClass.getName(), "'"); }
@Override public void removeVertexIndex(String indexName, Class<? extends VertexFrame> clazz) { if (log.isDebugEnabled()) { log.debug("Removing vertex index for class {" + clazz.getName() + "}"); } OrientGraphNoTx noTx = rawNoTx(); try { String name = clazz.getSimpleName(); OrientVertexType v = noTx.getVertexType(name); if (v == null) { throw new RuntimeException("Vertex type {" + name + "} is unknown. Can't remove index {" + indexName + "}"); } OIndex<?> index = v.getClassIndex(indexName); if (index != null) { noTx.dropIndex(index.getName()); } } finally { noTx.shutdown(); } }
public OrientMassiveInsertion(final String url) { super(GraphDatabaseType.ORIENT_DB, null /* resultsPath */); OGlobalConfiguration.ENVIRONMENT_CONCURRENT.setValue(false); OrientGraphNoTx transactionlessGraph = new OrientGraphNoTx(url); for (int i = 0; i < NUMBER_OF_ORIENT_CLUSTERS; ++i) { transactionlessGraph.getVertexBaseType().addCluster("v_" + i); transactionlessGraph.getEdgeBaseType().addCluster("e_" + i); } transactionlessGraph.shutdown(); graph = new OGraphBatchInsertBasic(url); graph.setAverageEdgeNumberPerNode(AVERAGE_NUMBER_OF_EDGES_PER_NODE); graph.setEstimatedEntries(ESTIMATED_ENTRIES); graph.setIdPropertyName("nodeId"); graph.begin(); }
/** * Creates a new Vertex persistent class specifying the super class. * * @param iClassName Vertex class name * @param iSuperClass OClass Vertex to extend * * @return OrientVertexType instance representing the persistent class */ public OrientVertexType createVertexType(final String iClassName, final OClass iSuperClass, final int clusters) { makeActive(); OrientVertexType.checkType(iSuperClass); return executeOutsideTx(new OCallable<OrientVertexType, OrientBaseGraph>() { @Override public OrientVertexType call(final OrientBaseGraph g) { return new OrientVertexType(g, getRawGraph().getMetadata().getSchema().createClass(iClassName, clusters, iSuperClass)); } }, "create vertex type '", iClassName, "' as subclass of '", iSuperClass.getName(), "' (clusters=" + clusters + ")"); }
@Override public <T extends MeshElement> T checkIndexUniqueness(String indexName, Class<T> classOfT, Object key) { FramedGraph graph = Tx.getActive().getGraph(); Graph baseGraph = ((DelegatingFramedOrientGraph) graph).getBaseGraph(); OrientBaseGraph orientBaseGraph = ((OrientBaseGraph) baseGraph); OrientVertexType vertexType = orientBaseGraph.getVertexType(classOfT.getSimpleName()); if (vertexType != null) { OIndex<?> index = vertexType.getClassIndex(indexName); if (index != null) { Object recordId = index.get(key); if (recordId != null) { return (T) graph.getFramedVertexExplicit(classOfT, recordId); } } } return null; }
/** * (Blueprints Extension) Returns the Vertex type as OrientVertexType object. */ @Override public OrientVertexType getType() { final OrientBaseGraph graph = getGraph(); return new OrientVertexType(graph, getRecord().getSchemaClass()); }
@Override public OrientVertexType call(final OrientBaseGraph g) { return new OrientVertexType(g, getRawGraph().getMetadata().getSchema().createClass(iClassName, clusters, iSuperClass)); } }, "create vertex type '", iClassName, "' as subclass of '", iSuperClass.getName(), "' (clusters=" + clusters + ")");
@Override public OrientVertexType call(final OrientBaseGraph g) { return new OrientVertexType(g, getRawGraph().getMetadata().getSchema().createClass(iClassName, iSuperClass)); } }, "create vertex type '", iClassName, "' as subclass of '", iSuperClass.getName(), "'");
/** * Returns the V persistent class as OrientVertexType instance. */ public OrientVertexType getVertexBaseType() { makeActive(); return new OrientVertexType(this, getRawGraph().getMetadata().getSchema().getClass(OrientVertexType.CLASS_NAME)); }