當前位置: 首頁>>代碼示例>>Java>>正文


Java Vertex類代碼示例

本文整理匯總了Java中com.tinkerpop.blueprints.Vertex的典型用法代碼示例。如果您正苦於以下問題:Java Vertex類的具體用法?Java Vertex怎麽用?Java Vertex使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Vertex類屬於com.tinkerpop.blueprints包,在下文中一共展示了Vertex類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getUserIdByEmail

import com.tinkerpop.blueprints.Vertex; //導入依賴的package包/類
public String getUserIdByEmail( String email ) {
	Graph graph = (Graph) connection.get();
	logger.debug("getUserIdByEmail: " + email );
	
	try {
	
		Iterable<Vertex> iterable = graph.getVertices( GremlinDAOSpec.USER_PROPERTY_EMAIL, email );
		Iterator<Vertex> it = iterable.iterator();
		
		if( it.hasNext() ) {
			return it.next().getId().toString();
		}
		else {
			throw new UserNotFoundException( email );
		}
	}
	finally {
		graph.shutdown();
	}
}
 
開發者ID:maltesander,項目名稱:rest-jersey2-json-jwt-authentication,代碼行數:21,代碼來源:GremlinUserDAO.java

示例2: getUser

import com.tinkerpop.blueprints.Vertex; //導入依賴的package包/類
public User getUser( String id ) {
	Graph graph = (Graph) connection.get();
	logger.debug("getUser: " + id );
	
	try {
		Vertex v = graph.getVertex( id );
		
		if( v == null ) {
			throw new UserNotFoundException( id );
		}

		User user = new User( v.getId().toString(),
							  v.getProperty( GremlinDAOSpec.USER_PROPERTY_EMAIL ),
							  v.getProperty( GremlinDAOSpec.USER_PROPERTY_FIRST_NAME ).toString(),
							  v.getProperty( GremlinDAOSpec.USER_PROPERTY_LAST_NAME ).toString() 
							);
		return user;
	}
	finally {
		graph.shutdown();
	}
}
 
開發者ID:maltesander,項目名稱:rest-jersey2-json-jwt-authentication,代碼行數:23,代碼來源:GremlinUserDAO.java

示例3: getAllUsers

import com.tinkerpop.blueprints.Vertex; //導入依賴的package包/類
@Override
public List<User> getAllUsers() {
	List<User> users = new ArrayList<User>();
	Graph graph = (Graph) connection.get();
	logger.debug("getAllUsers" );
	
	try {
		Iterable<Vertex> iterable = graph.getVertices( GremlinDAOSpec.UNIVERSAL_PROPERTY_TYPE, GremlinDAOSpec.USER_CLASS );
		Iterator<Vertex> it = iterable.iterator();
		
		while( it.hasNext() ) {
			Vertex v = it.next();
			User user = new User( v.getId().toString(),
								  v.getProperty( GremlinDAOSpec.USER_PROPERTY_EMAIL ),
								  v.getProperty( GremlinDAOSpec.USER_PROPERTY_FIRST_NAME ).toString(),
								  v.getProperty( GremlinDAOSpec.USER_PROPERTY_LAST_NAME ).toString() 
								);
			users.add(user);
		}

		return users;
	}
	finally {
		graph.shutdown();
	}
}
 
開發者ID:maltesander,項目名稱:rest-jersey2-json-jwt-authentication,代碼行數:27,代碼來源:GremlinUserDAO.java

示例4: updateUser

import com.tinkerpop.blueprints.Vertex; //導入依賴的package包/類
public boolean updateUser( User user ) {
	Graph graph = (Graph) connection.get();
	logger.debug("updateUser: " + user.getId() );
	
	try{
		Vertex v = graph.getVertex( user.getId() );
		
		if( v== null ) throw new UserNotFoundException( user.getEmail() );
		
		if( user.getEmail() != null )
			v.setProperty( GremlinDAOSpec.USER_PROPERTY_EMAIL, user.getEmail() );
		if( user.getFirstname() != null )
			v.setProperty( GremlinDAOSpec.USER_PROPERTY_FIRST_NAME, user.getFirstname() );
		if( user.getLastname() != null )
			v.setProperty( GremlinDAOSpec.USER_PROPERTY_LAST_NAME, user.getLastname() );
		
		return true;
	}
	finally {
		graph.shutdown();
	}
}
 
開發者ID:maltesander,項目名稱:rest-jersey2-json-jwt-authentication,代碼行數:23,代碼來源:GremlinUserDAO.java

示例5: deleteUser

import com.tinkerpop.blueprints.Vertex; //導入依賴的package包/類
public boolean deleteUser( String id ) {
	Graph graph = (Graph) connection.get();
	logger.debug("deleteUser: " + id );
	
	try {
		Vertex v = graph.getVertex( id );
		
		if( v== null ) throw new UserNotFoundException( id );
		
		v.remove();
		return true;
	}
	finally {
		graph.shutdown();
	}
}
 
開發者ID:maltesander,項目名稱:rest-jersey2-json-jwt-authentication,代碼行數:17,代碼來源:GremlinUserDAO.java

示例6: query

import com.tinkerpop.blueprints.Vertex; //導入依賴的package包/類
/**
     * Return all record of the reference class. Devuelve todos los registros a partir de una clase base.
     *
     * @param <T> Reference class
     * @param clazz reference class
     * @return return a list of object of the refecence class.
     */
    @Override
    public <T> List<T> query(Class<T> clazz) {
        if (this.orientdbTransact == null) {
            throw new NoOpenTx();
        }
        this.flush();

        long init = System.currentTimeMillis();

        ArrayList<T> ret = new ArrayList<>();

        Iterable<Vertex> vertices = this.orientdbTransact.getVerticesOfClass(clazz.getSimpleName());
        LOGGER.log(Level.FINER, "Enlapsed ODB response: " + (System.currentTimeMillis() - init));
        for (Vertex verticesOfClas : vertices) {
            ret.add(this.get(clazz, verticesOfClas.getId().toString()));
//            LOGGER.log(Level.FINER, "vertex: " + verticesOfClas.getId().toString() + "  class: " + ((OrientVertex) verticesOfClas).getType().getName());
        }
        LOGGER.log(Level.FINER, "Enlapsed time query to List: " + (System.currentTimeMillis() - init));
        return ret;
    }
 
開發者ID:mdre,項目名稱:odbogm,代碼行數:28,代碼來源:Transaction.java

示例7: testGetGraphRelsOnly

import com.tinkerpop.blueprints.Vertex; //導入依賴的package包/類
@Test
public void testGetGraphRelsOnly() {
	LoadingSheetData rels
			= LoadingSheetData.relsheet( "Human Being", "Car", "Purchased" );
	rels.addProperties( Arrays.asList( "Price", "Date" ) );
	ValueFactory vf = new ValueFactoryImpl();
	Map<String, Value> props = new HashMap<>();
	props.put( "Price", vf.createLiteral( "3000 USD" ) );
	rels.add( "Yuri", "Yugo", props );
	rels.add( "Yuri", "Pinto" );

	Graph g = GsonWriter.getGraph( data );
	int vsize = 0;
	int esize = 0;
	for ( Vertex v : g.getVertices() ) {
		vsize++;
	}
	for ( Edge e : g.getEdges() ) {
		esize++;
	}

	assertEquals( 3, vsize );
	assertEquals( 2, esize );
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:25,代碼來源:GsonWriterTest.java

示例8: storeEvent

import com.tinkerpop.blueprints.Vertex; //導入依賴的package包/類
protected void storeEvent(Event event) {
		Set<Entry<String, String>> kvp = event.getHeaders().entrySet();
		int time = Integer.parseInt(event.getHeaders().get(MarauderParserConstants.MARAUDER_KEY_TIMESTAMP), 16);
		event.getHeaders().remove(MarauderParserConstants.MARAUDER_KEY_TIMESTAMP);
		Iterator<Entry<String, String>> itr = kvp.iterator();
		byte[] rowKey = constructDefaultRowKey(event.getHeaders(), time);
		Vertex ev = g.addVertex(rowKey);
		ev.setProperty("o", time);
		ev.setProperty("s", System.currentTimeMillis());
		while(itr.hasNext()){
			Entry<String, String> entry = itr.next();
//			ev.setProperty(entry.getKey(), entry.getValue());
			Vertex v = g.addVertex(entry.getValue());
			v.setProperty("t", entry.getKey());
			v.setProperty("n", entry.getValue());
			g.addEdge(null, ev, v, entry.getKey()+"l");
//			Iterator<Vertex> i = g.query().has("t", entry.getKey()).has("n", entry.getValue()).vertices().iterator();
//			if(i.hasNext()){
//				g.addEdge(null, ev, i.next(), entry.getKey()+"l");
//			}else{
//				
//			}
		}
		
	}
 
開發者ID:srotya,項目名稱:marauder,代碼行數:26,代碼來源:MarauderTitanSink.java

示例9: addFriend

import com.tinkerpop.blueprints.Vertex; //導入依賴的package包/類
public OrientEdge addFriend(String outName, String inName) {
    OrientGraph database = new OrientGraph(databasePool);
    try {
        Vertex outVertex = database.addVertex(null);
        Vertex inVertex = database.addVertex(null);
        outVertex.setProperty("name", outName);
        inVertex.setProperty("name", inName);
        OrientEdge edge = database.addEdge(null, outVertex, inVertex, "knows");
        database.commit();
        return edge;
    } catch (Exception e) {
        database.rollback();
    } finally {
        database.shutdown();
    }

    return null;
}
 
開發者ID:wildfly-swarm,項目名稱:wildfly-swarm,代碼行數:19,代碼來源:TestPeopleDao.java

示例10: initializeData

import com.tinkerpop.blueprints.Vertex; //導入依賴的package包/類
@Override
public void initializeData() {
    final OrientBaseGraph db = context.getConnection();

    // init only empty database
    if (db.countVertices(CLASS_NAME) > 0) {
        return;
    }

    Vertex previous = null;
    for (int i = 0; i < 10; i++) {
        // note usage of "class:" prefix - it is required to reference registered class,
        // otherwise orient could try to register new class
        final Vertex node = db.addVertex("class:" + CLASS_NAME,
                "name", "Sample" + i,
                "amount", (int) (Math.random() * 200));
        if (previous != null) {
            // bottom-up connection: second Sample BelongsTo previous sample (graph is directed)
            node.addEdge("belongsTo", previous);
        }
        previous = node;
    }
}
 
開發者ID:xvik,項目名稱:guice-persist-orient-examples,代碼行數:24,代碼來源:SampleDataInitializer.java

示例11: clear

import com.tinkerpop.blueprints.Vertex; //導入依賴的package包/類
@Override
public void clear() {
	if (log.isDebugEnabled()) {
		log.debug("Clearing graph");
	}

	OrientGraphNoTx tx2 = factory.getNoTx();
	tx2.declareIntent(new OIntentNoCache());
	try {
		for (Vertex vertex : tx2.getVertices()) {
			vertex.remove();
		}
	} finally {
		tx2.declareIntent(null);
		tx2.shutdown();
	}
	if (log.isDebugEnabled()) {
		log.debug("Cleared graph");
	}

}
 
開發者ID:gentics,項目名稱:mesh,代碼行數:22,代碼來源:OrientDBDatabase.java

示例12: testMultithreading

import com.tinkerpop.blueprints.Vertex; //導入依賴的package包/類
@Test
public void testMultithreading() {
	OrientGraph graph = factory.getTx();
	Vertex v2 = graph.addVertex(null);
	Vertex v = graph.addVertex(null);
	graph.commit();
	
	//		Object id = v.getId();
	runAndWait(() -> {
		graph.getRawGraph().activateOnCurrentThread();
		graph.attach((OrientElement) v);
		v.setProperty("sfaf", "dxgvasdg");
		v.addEdge("adadsg", v2);
		//			Vertex e = memoryGraph.getVertex(id);
		//			assertNotNull(e);
		//			assertEquals("marko", e.getProperty("name"));
		//			e.setProperty("name", "joe");
		//			memoryGraph.rollback();
	});
	//		assertEquals("marko", v.getProperty("name"));

}
 
開發者ID:gentics,項目名稱:mesh,代碼行數:23,代碼來源:OrientDBTinkerpopMultithreadingTest.java

示例13: testVertexIndex

import com.tinkerpop.blueprints.Vertex; //導入依賴的package包/類
@Test
public void testVertexIndex() {
	OrientGraph g = factory.getTx();
	System.out.println("Size: " + g.getVertexType("item").getClassIndex("item").getSize());

	try {
		long start = System.currentTimeMillis();
		for (int i = 0; i < nChecks; i++) {
			int randomDocumentId = (int) (Math.random() * nDocuments);
			Iterable<Vertex> vertices = g.getVertices("item", new String[] { "name" }, new Object[] { "item_" + randomDocumentId });
			// Iterable<Vertex> vertices = g.getVertices("item.name", "item_" + randomDocumentId);
			assertTrue(vertices.iterator().hasNext());
		}
		long dur = System.currentTimeMillis() - start;
		double perCheck = ((double) dur / (double) nChecks);
		System.out.println("[graph.getVertices] Duration per lookup: " + perCheck);
		System.out.println("[graph.getVertices] Duration: " + dur);
	} finally {
		g.shutdown();
	}
}
 
開發者ID:gentics,項目名稱:mesh,代碼行數:22,代碼來源:EdgeIndexPerformanceTest.java

示例14: testEdgeIndexViaQuery

import com.tinkerpop.blueprints.Vertex; //導入依賴的package包/類
@Test
public void testEdgeIndexViaQuery() throws Exception {
	OrientGraph g = factory.getTx();
	try {
		System.out.println("Checking edge");
		long start = System.currentTimeMillis();
		for (int i = 0; i < nChecks; i++) {
			OrientVertex randomDocument = items.get((int) (Math.random() * items.size()));

			OCommandSQL cmd = new OCommandSQL("select from index:e.has_item where key=?");
			OCompositeKey key = new OCompositeKey(root.getId(), randomDocument.getId());

			assertTrue(((Iterable<Vertex>) g.command(cmd).execute(key)).iterator().hasNext());
		}
		long dur = System.currentTimeMillis() - start;
		System.out.println("[query] Duration: " + dur);
		System.out.println("[query] Duration per lookup: " + ((double) dur / (double) nChecks));
	} finally {
		g.shutdown();
	}
}
 
開發者ID:gentics,項目名稱:mesh,代碼行數:22,代碼來源:EdgeIndexPerformanceTest.java

示例15: hasChange

import com.tinkerpop.blueprints.Vertex; //導入依賴的package包/類
/**
 * Check whether a change with the given UUID is already stored in the graph.
 * 
 * @param uuid
 * @return <tt>true</tt> if the change is already stored within the changelog root
 */
public boolean hasChange(String uuid) {
	Objects.requireNonNull(uuid, "The uuid of the change must not be null");
	for (Vertex vertex : rootVertex.getVertices(Direction.OUT, HAS_CHANGE)) {
		ChangeWrapper change = new ChangeWrapper(vertex);
		if (uuid.equals(change.getUuid())) {
			return true;
		}
		// Backport handling for legacy changelog entries
		// TODO write a changelog entry to clearup the existing changelog entries and remove this check
		String legacyUuid = "com.gentics.mesh.changelog.changes." + uuid;
		if (legacyUuid.equals(change.getUuid())) {
			return true;
		}
	}
	return false;
}
 
開發者ID:gentics,項目名稱:mesh,代碼行數:23,代碼來源:ChangelogRootWrapper.java


注:本文中的com.tinkerpop.blueprints.Vertex類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。