当前位置: 首页>>代码示例>>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;未经允许,请勿转载。