当前位置: 首页>>代码示例>>Java>>正文


Java Graph.getVertex方法代码示例

本文整理汇总了Java中com.tinkerpop.blueprints.Graph.getVertex方法的典型用法代码示例。如果您正苦于以下问题:Java Graph.getVertex方法的具体用法?Java Graph.getVertex怎么用?Java Graph.getVertex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.tinkerpop.blueprints.Graph的用法示例。


在下文中一共展示了Graph.getVertex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUser

import com.tinkerpop.blueprints.Graph; //导入方法依赖的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

示例2: updateUser

import com.tinkerpop.blueprints.Graph; //导入方法依赖的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

示例3: deleteUser

import com.tinkerpop.blueprints.Graph; //导入方法依赖的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

示例4: testVertexEdgesWithNonVisibleVertexOnOtherEnd

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
public void testVertexEdgesWithNonVisibleVertexOnOtherEnd() {
    Graph graph = graphTest.generateGraph();

    if (!(graph instanceof VertexiumBlueprintsGraph)) {
        throw new RuntimeException("Invalid graph");
    }
    org.vertexium.Graph vertexiumGraph = ((VertexiumBlueprintsGraph) graph).getGraph();

    Authorizations aAuthorizations = vertexiumGraph.createAuthorizations("a");
    org.vertexium.Vertex v1 = vertexiumGraph.addVertex("v1", new Visibility(""), aAuthorizations);
    org.vertexium.Vertex v2 = vertexiumGraph.addVertex("v2", new Visibility("a"), aAuthorizations);
    org.vertexium.Vertex v3 = vertexiumGraph.addVertex("v3", new Visibility(""), aAuthorizations);
    vertexiumGraph.addEdge("e1to2", v1, v2, "label", new Visibility(""), aAuthorizations);
    vertexiumGraph.addEdge("e1to3", v1, v3, "label", new Visibility(""), aAuthorizations);
    vertexiumGraph.flush();

    Vertex blueV1 = graph.getVertex("v1");
    assertEquals(1, count(blueV1.getEdges(Direction.BOTH, "label")));
    assertEquals(1, count(blueV1.getVertices(Direction.BOTH, "label")));
    assertEquals(1, count((Iterable) blueV1.query().direction(Direction.BOTH).vertexIds()));

    graph.shutdown();
}
 
开发者ID:visallo,项目名称:vertexium,代码行数:24,代码来源:VertexiumBlueprintsVertexTestBase.java

示例5: copyEdge

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
private static void copyEdge(Graph graph, Edge edge)
{
	Object id = edge.getId();
	if (graph.getEdge(id) != null)
	{
		return;
	}
	Vertex src = graph.getVertex(edge.getVertex(Direction.OUT).getId());
	Vertex dst = graph.getVertex(edge.getVertex(Direction.IN).getId());
	if (src != null && dst != null)
	{
		Edge e = GraphHelper.addEdge(graph, id, src, dst, edge.getLabel());
		if (e != null)
		{
			ElementHelper.copyProperties(edge, e);
		}
	}
}
 
开发者ID:octopus-platform,项目名称:bjoern,代码行数:19,代码来源:FunctionExportPlugin.java

示例6: findOrCreateVertex

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
/**
 * Helper method to find an existing vertex. First the local cache is checked, then the in-memory (uncommitted)
 * graph object, the finally the database.
 *
 * @param g
 * @param vertexName
 * @return
 */
private Vertex findOrCreateVertex(final Graph g, final String vertexName) {
    String resolvedVertexName = classmap.resolveVertex(vertexName);
    boolean usingClasses = !vertexName.equals(resolvedVertexName);

    Vertex vertex = (Vertex) vertexCache.get(vertexName);
    if (vertex == null) {
        // FIXME Properly query for vertices in DB if getByID misses
        if (!usingClasses) {
            vertex = g.getVertex(resolvedVertexName);
        }

        if (vertex == null) {
            vertex = g.addVertex(resolvedVertexName);
            if (usingClasses) {
                vertex.setProperty(GraphSectionImpl.ELEMENT_NAME_PROPERTY, vertexName);
            }
        }
    }

    vertexProps.updateVertexProperties(vertexName, vertex);
    vertexCache.put(vertexName, vertex);
    return vertex;
}
 
开发者ID:segfly-oss,项目名称:graml,代码行数:32,代码来源:GraphSectionImpl.java

示例7: testPreloadAllProperties

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
@Test
public void testPreloadAllProperties() {
  AccumuloGraphConfiguration cfg =
      AccumuloGraphTestUtils.generateGraphConfig("preloadAllProperties");
  cfg.setPropertyCacheTimeout(null, TIMEOUT);
  cfg.setPreloadAllProperties(true);

  Graph graph = open(cfg);

  AccumuloVertex v = (AccumuloVertex) graph.addVertex("V");
  v.setProperty(NON_CACHED, true);
  v.setProperty(CACHED, true);

  v = (AccumuloVertex) graph.getVertex("V");
  assertEquals(true, v.getPropertyInMemory(NON_CACHED));
  assertEquals(true, v.getPropertyInMemory(CACHED));

  graph.shutdown();
}
 
开发者ID:JHUAPL,项目名称:AccumuloGraph,代码行数:20,代码来源:ElementPropertyCachingTest.java

示例8: testPreloadSomeProperties

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
@Test
public void testPreloadSomeProperties() {
  AccumuloGraphConfiguration cfg =
      AccumuloGraphTestUtils.generateGraphConfig("preloadSomeProperties");
  cfg.setPropertyCacheTimeout(null, TIMEOUT);
  cfg.setPreloadedProperties(new String[]{CACHED});

  Graph graph = open(cfg);

  AccumuloVertex v = (AccumuloVertex) graph.addVertex("V");
  v.setProperty(NON_CACHED, true);
  v.setProperty(CACHED, true);

  v = (AccumuloVertex) graph.getVertex("V");
  assertEquals(null, v.getPropertyInMemory(NON_CACHED));
  assertEquals(true, v.getPropertyInMemory(CACHED));

  graph.shutdown();
}
 
开发者ID:JHUAPL,项目名称:AccumuloGraph,代码行数:20,代码来源:ElementPropertyCachingTest.java

示例9: getUserAuthentication

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
@Override
public UserSecurity getUserAuthentication( String id ) throws UserNotFoundException {
	Graph graph = (Graph) connection.get();
	logger.debug("getUserAuthentication: " + id );
	
	try {
		Vertex v = graph.getVertex( id );
		
		if( v == null ) throw new UserNotFoundException( id );
		
		Object oEmail = v.getProperty( GremlinDAOSpec.USER_PROPERTY_EMAIL );
		Object oPassword = v.getProperty( GremlinDAOSpec.USER_PROPERTY_PASSWORD );
		Object oToken = v.getProperty( GremlinDAOSpec.USER_PROPERTY_TOKEN );
		Object oRole = v.getProperty( GremlinDAOSpec.USER_PROPERTY_ROLE );
		
		String email = null;
		String password = null;
		String token = null;
		String role = null;
		
		if( oEmail != null )
			email = oEmail.toString();
		if( oPassword != null )
			password = oPassword.toString();
		if( oToken != null )
			token = oToken.toString();
		if( oRole != null )
			role = oRole.toString();
		
		UserSecurity user = new UserSecurity( email, password, token, role );
		
		return user;
	}
	finally {
		graph.shutdown();
	}
}
 
开发者ID:maltesander,项目名称:rest-jersey2-json-jwt-authentication,代码行数:38,代码来源:GremlinUserDAO.java

示例10: setUserAuthentication

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
@Override
public boolean setUserAuthentication( UserSecurity user ) throws UserNotFoundException {
	Graph graph = (Graph) connection.get();
	logger.debug("setUserAuthentication: " + user.getId() );
	
	try {
		Vertex v = graph.getVertex( user.getId() );
		
		if( v == null ) throw new UserNotFoundException( user.getId() );

		if( user.getPassword() != null ) {
			v.setProperty( GremlinDAOSpec.USER_PROPERTY_PASSWORD,  user.getPassword() );
		}
		
		if( user.getToken() != null ) {
			v.setProperty(GremlinDAOSpec.USER_PROPERTY_TOKEN, user.getToken() );
		}
		
		if( user.getRole() != null ) {
			v.setProperty(GremlinDAOSpec.USER_PROPERTY_ROLE, user.getRole() );
		}
		
		return true;
	}
	finally {
		graph.shutdown();
	}
}
 
开发者ID:maltesander,项目名称:rest-jersey2-json-jwt-authentication,代码行数:29,代码来源:GremlinUserDAO.java

示例11: linkToPreviousNode

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
private void linkToPreviousNode(String baseId, int num)
{
	String previousId = createCompleteId(baseId, num - 1);
	String thisId = createCompleteId(baseId, num);

	Graph graph = importer.getGraph();

	Vertex fromNode = graph.getVertex(previousId);
	Vertex toNode = graph.getVertex(thisId);

	graph.addEdge(0, fromNode, toNode, "foo");
}
 
开发者ID:octopus-platform,项目名称:bjoern,代码行数:13,代码来源:NodeProcessor.java

示例12: copyVertex

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
private static void copyVertex(Graph graph, Vertex vertex)
{
	Object id = vertex.getId();
	if (graph.getVertex(id) != null)
	{
		return;
	}
	Vertex v = GraphHelper.addVertex(graph, id);
	if (v != null)
	{
		ElementHelper.copyProperties(vertex, v);
	}
}
 
开发者ID:octopus-platform,项目名称:bjoern,代码行数:14,代码来源:FunctionExportPlugin.java

示例13: createGraph

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
public static Graph createGraph( EngineMetaInterface meta ) {
  if ( meta == null ) {
    return null;
  }
  Graph g = new TinkerGraph();
  if ( meta instanceof TransMeta ) {
    TransMeta transMeta = (TransMeta) meta;

    // Add nodes
    List<StepMeta> steps = transMeta.getSteps();
    if ( steps != null ) {
      for ( StepMeta step : steps ) {
        Vertex v = g.addVertex( step.getName() );
        v.setProperty( PROPERTY_NAME, step.getName() );
        v.setProperty( PROPERTY_PLUGINID, step.getStepID() );
        Point location = step.getLocation();
        v.setProperty( PROPERTY_X, location.x );
        v.setProperty( PROPERTY_Y, location.y );
        v.setProperty( PROPERTY_REF, step );
      }
    }
    int numHops = transMeta.nrTransHops();
    for ( int i = 0; i < numHops; i++ ) {
      TransHopMeta hop = transMeta.getTransHop( i );
      StepMeta fromStep = hop.getFromStep();
      StepMeta toStep = hop.getToStep();
      Vertex fromV = g.getVertex( fromStep.getName() );
      Vertex toV = g.getVertex( toStep.getName() );
      g.addEdge( null, fromV, toV, EDGE_HOPSTO );
    }
  }
  return g;
}
 
开发者ID:mattyb149,项目名称:pdi-layout,代码行数:34,代码来源:GraphUtils.java

示例14: testSkipExistenceChecks

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
@Test
public void testSkipExistenceChecks() throws Exception {
  AccumuloGraphConfiguration cfg =
      AccumuloGraphTestUtils.generateGraphConfig("skipExistenceChecks");
  cfg.setSkipExistenceChecks(true);
  Graph graph = makeGraph(cfg);

  String id;

  id = "doubleAdd";
  assertNotNull(graph.addVertex(id));
  assertNotNull(graph.addVertex(id));
  Vertex vAdd = graph.getVertex(id);
  assertNotNull(vAdd);
  graph.removeVertex(vAdd);
  assertNotNull(graph.getVertex(id));


  id = "doubleRemove";
  Vertex vRemove = graph.addVertex(id);
  assertNotNull(vRemove);
  graph.removeVertex(vRemove);
  assertNotNull(graph.getVertex(id));
  // MDL 24 Dec 2014:  removeVertex still does checks.
  //graph.removeVertex(vRemove);
  //assertNotNull(graph.getVertex(id));


  id = "notExist";
  assertNotNull(graph.getVertex(id));

  graph.shutdown();
}
 
开发者ID:JHUAPL,项目名称:AccumuloGraph,代码行数:34,代码来源:ExtendedElementTest.java

示例15: lookupVertex

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
protected Vertex lookupVertex(String id, Graph batchGraph)
{
	return batchGraph.getVertex(id);
}
 
开发者ID:octopus-platform,项目名称:bjoern,代码行数:5,代码来源:EdgeProcessor.java


注:本文中的com.tinkerpop.blueprints.Graph.getVertex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。