本文整理了Java中org.neo4j.server.database.Database
类的一些代码示例,展示了Database
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Database
类的具体详情如下:
包路径:org.neo4j.server.database.Database
类名称:Database
暂无
代码示例来源:origin: neo4j/neo4j
private long createNode( Map<String, Object> properties )
{
long nodeId;
try ( Transaction tx = database.getGraph().beginTx() )
{
Node node = database.getGraph().createNode( LABEL );
for ( Map.Entry<String, Object> entry : properties.entrySet() )
{
node.setProperty( entry.getKey(), entry.getValue() );
}
nodeId = node.getId();
tx.success();
}
return nodeId;
}
代码示例来源:origin: neo4j/neo4j
private static void removeLogs( NeoServer server )
{
File logDir = new File( server.getDatabase().getLocation() + File.separator + ".." + File.separator + "log" );
try
{
FileUtils.deleteDirectory( logDir );
}
catch ( IOException e )
{
throw new RuntimeException( e );
}
}
代码示例来源:origin: neo4j/neo4j
public boolean isRunning()
{
return server != null && server.getDatabase() != null && server.getDatabase().isRunning();
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldBeAbleToGetLocation() throws Throwable
{
theDatabase.start();
assertThat( theDatabase.getLocation().getAbsolutePath(),
is( dbConfig.get( GraphDatabaseSettings.database_path ).getAbsolutePath() ) );
}
}
代码示例来源:origin: neo4j/neo4j
public Index<Node> createNodeIndex( String named )
{
try ( Transaction transaction = database.getGraph().beginTransaction( implicit, AUTH_DISABLED ) )
{
Index<Node> nodeIndex = database.getGraph().index()
.forNodes( named );
transaction.success();
return nodeIndex;
}
}
代码示例来源:origin: neo4j/neo4j
public long createNode( Label... labels )
{
try ( Transaction tx = database.getGraph().beginTransaction( implicit, AnonymousContext.writeToken() ) )
{
Node node = database.getGraph().createNode( labels );
tx.success();
return node.getId();
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldOverwriteExistingProperties() throws PropertyValueException,
NodeNotFoundException
{
long nodeId;
try ( Transaction tx = database.getGraph().beginTx() )
{
Node node = database.getGraph().createNode();
node.setProperty( "remove me", "trash" );
nodeId = node.getId();
tx.success();
}
Map<String, Object> properties = new HashMap<>();
properties.put( "foo", "bar" );
properties.put( "baz", 17 );
actions.setAllNodeProperties( nodeId, properties );
try ( Transaction tx = database.getGraph().beginTx() )
{
Node node = database.getGraph().getNodeById( nodeId );
assertHasProperties( node, properties );
assertNull( node.getProperty( "remove me", null ) );
}
}
代码示例来源:origin: neo4j/neo4j
@Override
public void start()
{
DependencyResolver resolver = database.getGraph().getDependencyResolver();
this.executionEngine = (ExecutionEngine) resolver.resolveDependency( QueryExecutionEngine.class );
this.service = resolver.resolveDependency( GraphDatabaseQueryService.class );
this.contextFactory = Neo4jTransactionalContextFactory.create( this.service, locker );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldBeAbleToRemoveNodeProperty() throws Exception
{
Map<String, Object> properties = new HashMap<>();
properties.put( "foo", "bar" );
properties.put( "number", 15 );
long nodeId = createNode( properties );
actions.removeNodeProperty( nodeId, "foo" );
try ( Transaction tx = database.getGraph().beginTx() )
{
Node node = database.getGraph().getNodeById( nodeId );
assertEquals( 15, node.getProperty( "number" ) );
assertFalse( node.hasProperty( "foo" ) );
tx.success();
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldWorkWithPoint2DArrays() throws Exception
{
HTTP.Response response =
runQuery( "create (:Node {points: [point({x:1, y:1}), point({x:2, y:2}), point({x: 3.0, y: 3.0})]})" );
assertEquals( 200, response.status() );
assertNoErrors( response );
GraphDatabaseFacade db = server().getDatabase().getGraph();
try ( Transaction tx = db.beginTx() )
{
for ( Node node : db.getAllNodes() )
{
if ( node.hasLabel( label( "Node" ) ) && node.hasProperty( "points" ) )
{
Point[] points = (Point[]) node.getProperty( "points" );
verifyPoint( points[0], Cartesian, 1.0, 1.0 );
verifyPoint( points[1], Cartesian, 2.0, 2.0 );
verifyPoint( points[2], Cartesian, 3.0, 3.0 );
}
}
tx.success();
}
}
代码示例来源:origin: neo4j/neo4j
public long createRelationship( String type, long startNodeId, long endNodeId )
{
try ( Transaction tx = database.getGraph().beginTransaction( implicit, AnonymousContext.writeToken() ) )
{
Node startNode = database.getGraph().getNodeById( startNodeId );
Node endNode = database.getGraph().getNodeById( endNodeId );
Relationship relationship = startNode.createRelationshipTo( endNode, RelationshipType.withName( type ) );
tx.success();
return relationship.getId();
}
}
代码示例来源:origin: neo4j/neo4j
public long createRelationship( String type )
{
try ( Transaction tx = database.getGraph().beginTransaction( implicit, AnonymousContext.writeToken() ) )
{
Node startNode = database.getGraph().createNode();
Node endNode = database.getGraph().createNode();
Relationship relationship = startNode.createRelationshipTo( endNode,
RelationshipType.withName( type ) );
tx.success();
return relationship.getId();
}
}
代码示例来源:origin: neo4j/neo4j
public void setNodeProperties( long nodeId, Map<String, Object> properties )
{
try ( Transaction tx = database.getGraph().beginTransaction( implicit, AnonymousContext.writeToken() ) )
{
Node node = database.getGraph().getNodeById( nodeId );
for ( Map.Entry<String, Object> propertyEntry : properties.entrySet() )
{
node.setProperty( propertyEntry.getKey(), propertyEntry.getValue() );
}
tx.success();
}
}
代码示例来源:origin: neo4j/neo4j
public Index<Relationship> createRelationshipIndex( String named )
{
try ( Transaction transaction = database.getGraph().beginTransaction( implicit, AUTH_DISABLED ) )
{
RelationshipIndex relationshipIndex = database.getGraph().index()
.forRelationships( named );
transaction.success();
return relationshipIndex;
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldBeAbleToGetPropertiesOnRelationship() throws Exception
{
long relationshipId;
Map<String, Object> properties = new HashMap<>();
properties.put( "foo", "bar" );
properties.put( "neo", "Thomas A. Anderson" );
properties.put( "number", 15L );
try ( Transaction tx = database.getGraph().beginTx() )
{
Node startNode = database.getGraph().createNode();
Node endNode = database.getGraph().createNode();
Relationship relationship = startNode.createRelationshipTo( endNode,
RelationshipType.withName( "knows" ) );
for ( Map.Entry<String, Object> entry : properties.entrySet() )
{
relationship.setProperty( entry.getKey(), entry.getValue() );
}
relationshipId = relationship.getId();
tx.success();
}
try ( Transaction transaction = graph.beginTx() )
{
assertEquals( properties, serialize( actions.getAllRelationshipProperties( relationshipId ) ) );
}
}
代码示例来源:origin: neo4j/neo4j
private long createNode()
{
GraphDatabaseService graphdb = server().getDatabase().getGraph();
try ( Transaction tx = graphdb.beginTx() )
{
Node node = graphdb.createNode();
tx.success();
return node.getId();
}
}
代码示例来源:origin: neo4j/neo4j
public void deleteNode( long id )
{
try ( Transaction tx = database.getGraph().beginTransaction( implicit, AnonymousContext.write() ) )
{
Node node = database.getGraph().getNodeById( id );
node.delete();
tx.success();
}
}
代码示例来源:origin: neo4j/neo4j
public Relationship getRelationship( long relationshipId )
{
try ( Transaction tx = database.getGraph().beginTransaction( implicit, AnonymousContext.read() ) )
{
Relationship relationship = database.getGraph().getRelationshipById( relationshipId );
tx.success();
return relationship;
}
}
代码示例来源:origin: neo4j/neo4j
public IndexDefinition createSchemaIndex( String labelName, String propertyKey )
{
try ( Transaction tx = database.getGraph().beginTransaction( implicit, AUTH_DISABLED ) )
{
IndexDefinition index = database.getGraph().schema().indexFor( label( labelName ) ).on( propertyKey ).create();
tx.success();
return index;
}
}
代码示例来源:origin: neo4j/neo4j
public void addLabelToNode( long node, String labelName )
{
try ( Transaction tx = database.getGraph().beginTransaction( implicit, AnonymousContext.writeToken() ) )
{
database.getGraph().getNodeById( node ).addLabel( label( labelName ) );
tx.success();
}
}
内容来源于网络,如有侵权,请联系作者删除!