本文整理汇总了Java中org.neo4j.graphdb.GraphDatabaseService.createNode方法的典型用法代码示例。如果您正苦于以下问题:Java GraphDatabaseService.createNode方法的具体用法?Java GraphDatabaseService.createNode怎么用?Java GraphDatabaseService.createNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.neo4j.graphdb.GraphDatabaseService
的用法示例。
在下文中一共展示了GraphDatabaseService.createNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: question5346011
import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
@Test
public void question5346011()
{
GraphDatabaseService service = new TestGraphDatabaseFactory().newImpermanentDatabase();
try ( Transaction tx = service.beginTx() )
{
RelationshipIndex index = service.index().forRelationships( "exact" );
// ...creation of the nodes and relationship
Node node1 = service.createNode();
Node node2 = service.createNode();
String a_uuid = "xyz";
Relationship relationship = node1.createRelationshipTo( node2, DynamicRelationshipType.withName( "related" ) );
index.add( relationship, "uuid", a_uuid );
// query
IndexHits<Relationship> hits = index.get( "uuid", a_uuid, node1, node2 );
assertEquals( 1, hits.size() );
tx.success();
}
service.shutdown();
}
示例2: concurrentIndexPopulationAndInsertsShouldNotProduceDuplicates
import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
@Test
public void concurrentIndexPopulationAndInsertsShouldNotProduceDuplicates() throws IOException
{
// Given
GraphDatabaseService db = newEmbeddedGraphDatabaseWithSlowJobScheduler();
// When
try ( Transaction tx = db.beginTx() )
{
db.schema().indexFor( label( "SomeLabel" ) ).on( "key" ).create();
tx.success();
}
Node node;
try ( Transaction tx = db.beginTx() )
{
node = db.createNode( label( "SomeLabel" ) );
node.setProperty( "key", "value" );
tx.success();
}
db.shutdown();
// Then
assertThat( nodeIdsInIndex( 1, "value" ), equalTo( singletonList( node.getId() ) ) );
}
示例3: main
import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
public static void main( String[] args )
{
GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase( args[0] );
try ( Transaction tx = db.beginTx() )
{
Index<Relationship> index = db.index().forRelationships( "myIndex" );
Node node = db.createNode();
Relationship relationship = db.createNode().createRelationshipTo( node,
DynamicRelationshipType.withName( "KNOWS" ) );
index.add( relationship, "key", "value" );
tx.success();
}
db.shutdown();
System.exit( 0 );
}
示例4: createIfAbsentWord
import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
private Node createIfAbsentWord(GraphDatabaseService database, Node verseNode, Integer index) {
Node wordNode;
// if (prev.get(VERSE) != current.get(VERSE) || prev.get(WORD) != current.get(WORD)) {
String address = NodeUtils.getNodeAddress((String) verseNode.getProperty(NodeProperties.General.address), index);
wordNode = database.index().forNodes(GraphIndices.WordIndex).get(NodeProperties.General.address, address).getSingle();
if (wordNode == null) {
wordNode = database.createNode(NodeLabels.WORD);
wordNode.setProperty(NodeProperties.General.index, index);
NodeUtils.setPropertyAndIndex(wordNode, NodeProperties.General.address, GraphIndices.WordIndex, address);
// current.put(WORD_NODE, wordNode);
verseNode.createRelationshipTo(wordNode, RelationshipTypes.CONTAINS_WORD);
}
// else {
// wordNode = (Node) current.get(WORD_NODE);
// }
return wordNode;
}
示例5: createNode
import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
public Node createNode(GraphDatabaseService db){
Node node=db.createNode();
node.addLabel(Label.label(GitExtractor.COMMIT));
node.setProperty(GitExtractor.COMMIT_ID,commitId);
node.setProperty(GitExtractor.COMMIT_DATE,createDate);
node.setProperty(GitExtractor.COMMIT_LOGMESSAGE,logMessage);
node.setProperty(GitExtractor.COMMIT_CONTENT,content);
return node;
}
示例6: getMetro
import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
private Node getMetro(@Context GraphDatabaseService db, HashMap<String, Node> metros, CSVRecord record) {
Node metro = metros.get(record.get("metro_code"));
if (metro == null) {
metro = db.createNode(Labels.Metro);
metro.setProperty("code", record.get("metro_code"));
}
return metro;
}
示例7: getTimezone
import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
private Node getTimezone(@Context GraphDatabaseService db, HashMap<String, Node> timezones, CSVRecord record) {
Node timezone = timezones.get(record.get("time_zone"));
if (timezone == null) {
timezone = db.createNode(Labels.Timezone);
timezone.setProperty("name", record.get("time_zone"));
timezones.put(record.get("time_zone"), timezone);
}
return timezone;
}
示例8: getState
import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
private Node getState(@Context GraphDatabaseService db, HashMap<String, Node> states, CSVRecord record) {
Node state = states.get(record.get("subdivision_1_iso_code"));
if (state == null) {
state = db.createNode(Labels.State);
state.setProperty("code", record.get("subdivision_1_iso_code"));
state.setProperty("name", record.get("subdivision_1_name"));
states.put(record.get("subdivision_1_iso_code"), state);
}
return state;
}
示例9: getCountry
import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
private Node getCountry(GraphDatabaseService db, HashMap<String, Node> countries, CSVRecord record) {
Node country = countries.get(record.get("country_iso_code"));
if (country == null) {
country = db.createNode(Labels.Country);
country.setProperty("code", record.get("country_iso_code"));
country.setProperty("name", record.get("country_name"));
countries.put(record.get("country_iso_code"), country);
}
return country;
}
示例10: getContinent
import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
private Node getContinent(GraphDatabaseService db, HashMap<String, Node> continents, CSVRecord record) {
Node continent = continents.get(record.get("continent_code"));
if (continent == null) {
continent = db.createNode(Labels.Continent);
continent.setProperty("code", record.get("continent_code"));
continent.setProperty("name", record.get("continent_name"));
continents.put(record.get("continent_code"), continent);
}
return continent;
}
示例11: createNode
import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
/**
*
* @param node
* @param labels
* @return
*/
public static long createNode(org.neo4art.graphdb.Node node)
{
GraphDatabaseService graphDatabaseService = getGraphDatabaseService();
Node newNode = graphDatabaseService.createNode(node.getLabels());
for (String key : node.getProperties().keySet())
{
newNode.setProperty(key, node.getProperties().get(key));
}
return newNode.getId();
}
示例12: createRedundancyRootNode
import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
/**
* @see org.neo4art.sentiment.repository.RedundancyCounterRepository#createRedundancyRootNode()
*/
@Override
public long createRedundancyRootNode()
{
GraphDatabaseService graphDatabaseService = Neo4ArtGraphDatabaseServiceSingleton.getGraphDatabaseService();
Node redundancyRootNode = graphDatabaseService.createNode(RedundancyTreeLabel.RedundancyTree);
return redundancyRootNode.getId();
}
示例13: fillInTransaction
import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
@Override
public void fillInTransaction(GraphDatabaseService database) throws ParserConfigurationException, IOException, SAXException {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(uthmaniFile);
NodeList suras = ((Element) doc.getDocumentElement()).getElementsByTagName(SURA_TAG);
for (int i = 0; i < suras.getLength(); i++) {
System.out.println("update chapter #" + (i + 1));
Node sura = suras.item(i);
int chapterIndex = Integer.parseInt(sura.getAttributes().getNamedItem(NodeProperties.General.index).getNodeValue());
org.neo4j.graphdb.Node chapterNode = database.index().forNodes(GraphIndices.ChapterIndex).get(NodeProperties.General.index, chapterIndex).getSingle();
NodeList ayas = ((Element) sura).getElementsByTagName(AYA_TAG);
for (int j = 0; j < ayas.getLength(); j++) {
Node aya = ayas.item(j);
int verseIndex = Integer.parseInt(aya.getAttributes().getNamedItem(NodeProperties.General.index).getNodeValue());
String text = aya.getAttributes().getNamedItem(NodeProperties.Verse.text).getNodeValue();
org.neo4j.graphdb.Node verseNode = database.createNode(NodeLabels.VERSE);
verseNode.setProperty(NodeProperties.General.index, verseIndex);
verseNode.setProperty(NodeProperties.Verse.text, text);
String address = NodeUtils.getNodeAddress(chapterIndex, verseIndex);
NodeUtils.setPropertyAndIndex(verseNode, NodeProperties.General.address, GraphIndices.VerseIndex, address);
chapterNode.createRelationshipTo(verseNode, RelationshipTypes.CONTAINS_VERSE);
}
}
}
示例14: processTag
import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
private void processTag(GraphDatabaseService database, Node tokenNode, String tag) {
Node tagNode = database.index().forNodes(GraphIndices.TagIndex).get(NodeProperties.General.value, tag).getSingle();
if (tagNode == null) {
tagNode = database.createNode(NodeLabels.TAG);
NodeUtils.setPropertyAndIndex(tagNode, NodeProperties.General.value, GraphIndices.TagIndex, tag);
}
tokenNode.createRelationshipTo(tagNode, RelationshipTypes.HAS_TAG);
}
示例15: createToken
import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
private Node createToken(GraphDatabaseService database, Node wordNode, Integer index, String form) {
Node tokenNode = database.createNode(NodeLabels.TOKEN);
tokenNode.setProperty(NodeProperties.General.index, index);
NodeUtils.setBuckwalterPropertyAndIndex(tokenNode, GraphIndices.TokenIndex, form);
String address = NodeUtils.getNodeAddress((String) wordNode.getProperty(NodeProperties.General.address), index);
NodeUtils.setPropertyAndIndex(tokenNode, NodeProperties.General.address, GraphIndices.TokenIndex, address);
wordNode.createRelationshipTo(tokenNode, RelationshipTypes.CONTAINS_TOKEN);
return tokenNode;
}