use of com.tinkerpop.blueprints.impls.orient.OrientVertexType in project orientdb by orientechnologies.
the class IndexTest method testPreservingIdentityInIndexTx.
public void testPreservingIdentityInIndexTx() {
OrientGraph graph = new OrientGraph((ODatabaseDocumentTx) database.getUnderlying(), true);
graph.setAutoScaleEdgeType(true);
OrientVertexType fieldClass = graph.getVertexType("PreservingIdentityInIndexTxChild");
if (fieldClass == null) {
fieldClass = graph.createVertexType("PreservingIdentityInIndexTxChild");
fieldClass.createProperty("name", OType.STRING);
fieldClass.createProperty("in_field", OType.LINK);
fieldClass.createIndex("nameParentIndex", OClass.INDEX_TYPE.NOTUNIQUE, "in_field", "name");
}
Vertex parent = graph.addVertex("class:PreservingIdentityInIndexTxParent");
Vertex child = graph.addVertex("class:PreservingIdentityInIndexTxChild");
parent.addEdge("preservingIdentityInIndexTxEdge", child);
child.setProperty("name", "pokus");
Vertex parent2 = graph.addVertex("class:PreservingIdentityInIndexTxParent");
Vertex child2 = graph.addVertex("class:PreservingIdentityInIndexTxChild");
parent2.addEdge("preservingIdentityInIndexTxEdge", child2);
child2.setProperty("name", "pokus2");
graph.commit();
{
fieldClass = graph.getVertexType("PreservingIdentityInIndexTxChild");
OIndex<?> index = fieldClass.getClassIndex("nameParentIndex");
OCompositeKey key = new OCompositeKey(parent.getId(), "pokus");
Set<ORecordId> h = (Set<ORecordId>) index.get(key);
for (ORecordId o : h) {
Assert.assertNotNull(graph.getVertex(o));
}
}
{
fieldClass = graph.getVertexType("PreservingIdentityInIndexTxChild");
OIndex<?> index = fieldClass.getClassIndex("nameParentIndex");
OCompositeKey key = new OCompositeKey(parent2.getId(), "pokus2");
Set<ORecordId> h = (Set<ORecordId>) index.get(key);
for (ORecordId o : h) {
Assert.assertNotNull(graph.getVertex(o));
}
}
parent.remove();
child.remove();
parent2.remove();
child2.remove();
graph.shutdown();
}
use of com.tinkerpop.blueprints.impls.orient.OrientVertexType in project orientdb by orientechnologies.
the class AbstractServerClusterSQLGraphTest method onAfterDatabaseCreation.
@Override
protected void onAfterDatabaseCreation(final OrientBaseGraph graph) {
System.out.println("Creating graph schema...");
// CREATE BASIC SCHEMA
OrientVertexType personClass = graph.createVertexType("Person");
personClass.createProperty("id", OType.STRING);
personClass.createProperty("name", OType.STRING);
personClass.createProperty("birthday", OType.DATE);
personClass.createProperty("children", OType.STRING);
OrientVertexType person = graph.getVertexType("Person");
idx = person.createIndex("Person.name", OClass.INDEX_TYPE.UNIQUE, "name");
OrientVertexType customer = graph.createVertexType("Customer", person);
customer.createProperty("totalSold", OType.DECIMAL);
OrientVertexType provider = graph.createVertexType("Provider", person);
provider.createProperty("totalPurchased", OType.DECIMAL);
OrientEdgeType knows = graph.createEdgeType("Knows");
factory = new OrientGraphFactory(graph.getRawGraph().getURL(), "admin", "admin", false);
factory.setStandardElementConstraints(false);
}
use of com.tinkerpop.blueprints.impls.orient.OrientVertexType in project orientdb by orientechnologies.
the class ServerClusterSchemaTest method executeTest.
@Override
protected void executeTest() throws Exception {
for (int s = 0; s < SERVERS; ++s) {
OrientGraphFactory factory = new OrientGraphFactory("plocal:target/server" + s + "/databases/" + getDatabaseName());
OrientGraphNoTx g = factory.getNoTx();
try {
System.out.println("Creating vertex class Client" + s + " against server " + g + "...");
OrientVertexType t = g.createVertexType("Client" + s);
t.createProperty("name", OType.STRING).setMandatory(true);
System.out.println("Creating vertex class Knows" + s + " against server " + g + "...");
g.createEdgeType("Knows" + s);
} finally {
g.shutdown();
}
}
for (int s = 0; s < SERVERS; ++s) {
System.out.println("Checking vertices classes on server " + s + "...");
OrientGraphFactory factory = new OrientGraphFactory("plocal:target/server" + s + "/databases/" + getDatabaseName());
OrientGraphNoTx g = factory.getNoTx();
try {
for (int i = 0; i < SERVERS; ++i) {
Assert.assertNotNull(g.getVertexType("Client" + i));
Assert.assertNotNull(g.getEdgeType("Knows" + i));
}
} finally {
g.shutdown();
}
}
for (int s = 0; s < SERVERS; ++s) {
System.out.println("Add vertices on server " + s + "...");
OrientGraphFactory factory = new OrientGraphFactory("plocal:target/server" + s + "/databases/" + getDatabaseName());
OrientGraphNoTx g = factory.getNoTx();
try {
for (int i = 0; i < SERVERS; ++i) {
try {
final OrientVertex v = g.addVertex("class:" + "Client" + i);
Assert.assertTrue(false);
} catch (OValidationException e) {
// EXPECTED
}
}
} finally {
g.shutdown();
}
}
for (int s = 0; s < SERVERS; ++s) {
System.out.println("Add vertices in TX on server " + s + "...");
OrientGraphFactory factory = new OrientGraphFactory("plocal:target/server" + s + "/databases/" + getDatabaseName());
OrientGraph g = factory.getTx();
try {
for (int i = 0; i < SERVERS; ++i) {
try {
final OrientVertex v = g.addVertex("class:" + "Client" + i);
g.commit();
Assert.assertTrue(false);
} catch (ONeedRetryException e) {
// EXPECTED
} catch (OValidationException e) {
// EXPECTED
}
}
} finally {
g.shutdown();
}
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientVertexType in project orientdb by orientechnologies.
the class OrientDbCreationHelper method createSchemaDB.
public static void createSchemaDB(ODatabaseDocumentTx db) {
OSchema schema = db.getMetadata().getSchema();
// item
OClass item = schema.createClass("Item");
item.createProperty("stringKey", OType.STRING).createIndex(INDEX_TYPE.UNIQUE);
item.createProperty("intKey", OType.INTEGER).createIndex(INDEX_TYPE.UNIQUE);
item.createProperty("date", OType.DATE).createIndex(INDEX_TYPE.NOTUNIQUE);
item.createProperty("time", OType.DATETIME).createIndex(INDEX_TYPE.NOTUNIQUE);
item.createProperty("text", OType.STRING);
item.createProperty("score", OType.DECIMAL);
item.createProperty("length", OType.LONG).createIndex(INDEX_TYPE.NOTUNIQUE);
item.createProperty("published", OType.BOOLEAN).createIndex(INDEX_TYPE.NOTUNIQUE);
item.createProperty("title", OType.STRING).createIndex(INDEX_TYPE.NOTUNIQUE);
item.createProperty("author", OType.STRING).createIndex(INDEX_TYPE.NOTUNIQUE);
item.createProperty("tags", OType.EMBEDDEDLIST);
// class Article
OClass article = schema.createClass("Article");
article.createProperty("uuid", OType.INTEGER).createIndex(INDEX_TYPE.UNIQUE);
article.createProperty("date", OType.DATE).createIndex(INDEX_TYPE.NOTUNIQUE);
article.createProperty("title", OType.STRING);
article.createProperty("content", OType.STRING);
// article.createProperty("attachment", OType.LINK);
// author
OClass author = schema.createClass("Author");
author.createProperty("uuid", OType.LONG).createIndex(INDEX_TYPE.UNIQUE);
author.createProperty("name", OType.STRING).setMin("3");
author.createProperty("rating", OType.DOUBLE);
author.createProperty("articles", OType.LINKLIST, article);
// link article-->author
article.createProperty("author", OType.LINK, author);
//Graph
OrientGraphNoTx graph = new OrientGraphNoTx(db);
OrientVertexType post = graph.createVertexType("Post");
post.createProperty("uuid", OType.LONG);
post.createProperty("title", OType.STRING);
post.createProperty("date", OType.DATE).createIndex(INDEX_TYPE.NOTUNIQUE);
post.createProperty("content", OType.STRING);
OrientVertexType writer = graph.createVertexType("Writer");
writer.createProperty("uuid", OType.LONG).createIndex(INDEX_TYPE.UNIQUE);
writer.createProperty("name", OType.STRING);
writer.createProperty("is_active", OType.BOOLEAN);
writer.createProperty("isActive", OType.BOOLEAN);
graph.createEdgeType("Writes");
schema.reload();
}
use of com.tinkerpop.blueprints.impls.orient.OrientVertexType in project orientdb by orientechnologies.
the class VertexIndexTest method testFullTextIndexOnvertex.
@Test
public void testFullTextIndexOnvertex() {
OrientGraph graph = new OrientGraph("memory:TestDB", "admin", "admin");
OrientVertexType vType = graph.getVertexType("V");
vType.createProperty("title", OType.STRING);
vType.createProperty("text", OType.STRING);
vType.createIndex("V.", "FULLTEXT", null, null, "LUCENE", new String[] { "title", "text" });
graph.drop();
}
Aggregations