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


Java DynamicLabel类代码示例

本文整理汇总了Java中org.neo4j.graphdb.DynamicLabel的典型用法代码示例。如果您正苦于以下问题:Java DynamicLabel类的具体用法?Java DynamicLabel怎么用?Java DynamicLabel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: computeLabels

import org.neo4j.graphdb.DynamicLabel; //导入依赖的package包/类
protected Label[] computeLabels(Object incoming) throws IllegalAccessException {
    Label[] labels = new Label[0];

    if (StringUtils.isNotEmpty(this.labelsField)) {

        String labelList = (String) this.getObjectProperty(incoming, this.labelsField);

        if (StringUtils.isNotEmpty(labelList)) {
            String[] labelTab = labelList.split(";");
            labels = new Label[labelTab.length];
            for (int i = 0; i < labelTab.length; i++) {
                labels[i] = DynamicLabel.label(labelTab[i]);
            }
        }
    }

    return labels;
}
 
开发者ID:sim51,项目名称:neo4j-talend-component,代码行数:19,代码来源:Neo4jBatchInserterNode.java

示例2: create_node_uniqueness_constraint_should_work

import org.neo4j.graphdb.DynamicLabel; //导入依赖的package包/类
@Test
public void create_node_uniqueness_constraint_should_work() {
    // Test const.
    String label = "Test";
    String property = "myProp";

    // crete the schema
    batchDb.createSchema("NODE_PROPERTY_UNIQUE", label, property);
    batchDb.shutdown();

    // Testing it with real graphdb
    GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(dbPath);
    try (Transaction tx = graphDb.beginTx()) {
        Assert.assertTrue(graphDb.schema().getConstraints(DynamicLabel.label(label)).iterator().hasNext());
    }
    graphDb.shutdown();
}
 
开发者ID:sim51,项目名称:neo4j-talend-component,代码行数:18,代码来源:Neo4jBatchDatabaseTest.java

示例3: create_node_index_should_work

import org.neo4j.graphdb.DynamicLabel; //导入依赖的package包/类
@Test
public void create_node_index_should_work() {
    // Test const.
    String label = "Test";
    String property = "myProp";

    // crete the schema
    batchDb.createSchema("NODE_PROPERTY_INDEX", label, property);
    batchDb.shutdown();

    // Testing it with real graphdb
    GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(dbPath);
    try (Transaction tx = graphDb.beginTx()) {
        Assert.assertTrue(graphDb.schema().getIndexes(DynamicLabel.label(label)).iterator().hasNext());
    }
    graphDb.shutdown();

}
 
开发者ID:sim51,项目名称:neo4j-talend-component,代码行数:19,代码来源:Neo4jBatchDatabaseTest.java

示例4: addNode

import org.neo4j.graphdb.DynamicLabel; //导入依赖的package包/类
private Node addNode(String token, String pos, String ner, String sentId) throws Exception {

		if (token == null || pos == null || ner == null) {
			throw new Exception("Invalid arguments");
		}
 
		// check for duplicate nodes
		Node node = getNode(token, pos, ner, sentId);
		if (node != null) {
			return node;
		}
		
		try (Transaction tx = graphDb.beginTx()) {
			// Database operations go here
			node = graphDb.createNode();
			node.setProperty("token", token);
			node.setProperty("pos", pos);
			node.setProperty("ner", ner);
			node.addLabel(DynamicLabel.label("S_" + sentId));

			// transaction complete
			tx.success();
		}
		
		return node;
	}
 
开发者ID:sunil3590,项目名称:artificial-guy,代码行数:27,代码来源:KnowledgeGraph.java

示例5: add

import org.neo4j.graphdb.DynamicLabel; //导入依赖的package包/类
public final Node add(Map<String, Object> properties, String... types) {
	if (null == properties)
		throw new IllegalArgumentException("Illegal 'properties' argument in Problem.add(Map<String, Object>, String...): " + properties);
	if (null == types)
		throw new IllegalArgumentException("Illegal 'types' argument in Problem.add(Map<String, Object>, String...): " + types);
	Node result = null;
	try (Transaction tx = graph.beginTx()) {
		int i = 0;
		Label[] labels = new Label[types.length];
		for (String type : types) {
			labels[i++] = DynamicLabel.label(type);
		}
		result = graph.createNode(labels);
		for (String property : properties.keySet())
			result.setProperty(property, properties.get(property));
		tx.success();
	}
	return result;
}
 
开发者ID:stefano-bragaglia,项目名称:NeoDD,代码行数:20,代码来源:Problem.java

示例6: analyzePartitions

import org.neo4j.graphdb.DynamicLabel; //导入依赖的package包/类
public void analyzePartitions() {
    // Query the nodes by label, which each set becomes a partition for analysis
    Transaction tx = graphDatabaseService.beginTx();

    Iterator<Node> partitions = GlobalGraphOperations.at(graphDatabaseService)
            .getAllNodesWithLabel(DynamicLabel.label(label))
            .iterator();

    // For each partition, query the target relationships between the partition
    partitions.forEachRemaining(partition -> {
        PartitionDescription partitionDescription = new PartitionDescription(partition.getId(), label);
        partitionDescription.setGroupRelationship(groupRelationship);
        partitionDescription.setTargetRelationship(targetRelationship);
        try {
            Path pt = Writer.exportPartitionToHDFSParallel(graphDatabaseService, partition, partitionDescription);
            if(pt != null)
                Writer.dispatchPartitionedJob(graphDatabaseService, type, partitionDescription, pt);
        } catch (IOException | URISyntaxException e) {
            e.printStackTrace();
        }
    });

    tx.success();
    tx.close();
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mazerunner,代码行数:26,代码来源:PartitionedAnalysis.java

示例7: addLabel

import org.neo4j.graphdb.DynamicLabel; //导入依赖的package包/类
private void addLabel(final Node node, final String labelString) {

		final Label label = DynamicLabel.label(labelString);
		boolean hit = false;
		final Iterable<Label> labels = node.getLabels();

		for (final Label lbl : labels) {

			if (label.equals(lbl)) {

				hit = true;
				break;
			}
		}

		if (!hit) {

			node.addLabel(label);
			addedLabels++;
		}
	}
 
开发者ID:dswarm,项目名称:dswarm-graph-neo4j,代码行数:22,代码来源:Neo4jDeltaGDMHandler.java

示例8: PropertyEnrichGDMWorker

import org.neo4j.graphdb.DynamicLabel; //导入依赖的package包/类
public PropertyEnrichGDMWorker(final String prefixedResourceUriArg, final long resourceHashArg, final GraphDatabaseService databaseArg, final
NamespaceIndex namespaceIndexArg) throws DMPGraphException {

	prefixedResourceUri = prefixedResourceUriArg;
	resourceHash = resourceHashArg;
	database = databaseArg;
	namespaceIndex = namespaceIndexArg;
	nodeHandler = new CBDNodeHandler();
	startNodeHandler = new CBDStartNodeHandler();
	relationshipHandler = new CBDRelationshipHandler();

	final String prefixedRDFTypeURI = namespaceIndex.createPrefixedURI(RDF.type.getURI());
	final String prefixedRDFSClassURI = namespaceIndex.createPrefixedURI(RDFS.Class.getURI());

	prefixedRDFType = DynamicRelationshipType.withName(prefixedRDFTypeURI);
	prefixedRDFSClass = DynamicLabel.label(prefixedRDFSClassURI);
}
 
开发者ID:dswarm,项目名称:dswarm-graph-neo4j,代码行数:18,代码来源:PropertyEnrichGDMWorker.java

示例9: createVertexBatchMode

import org.neo4j.graphdb.DynamicLabel; //导入依赖的package包/类
/**
 * used when creating nodes in batch mode
 * 
 * @param id
 * @param name
 * @param columnNames
 * @param values
 * @return
 * @throws IOException
 */
private long createVertexBatchMode(double id, String name, List<String> columnNames, List<String> values) throws IOException {
	Label entityLabel = DynamicLabel.label(name);
	//getCurrentInserter().createDeferredSchemaIndex(entityLabel).on(_ID_PROPERTY).create();

	Map<String, Object> properties = new HashMap<String, Object>();
	properties.put(_ID_PROPERTY, id);

	// fill out the properties in the columns
	for (int i = 0; i < columnNames.size(); i++) {
		String value = EMPTY_STRING;
		if (values != null && values.size() > i) {
			value = values.get(i);
		}
		properties.put(columnNames.get(i), value);
	}

	return getCurrentInserter().createNode(properties, entityLabel);
}
 
开发者ID:tchico,项目名称:dgMaster-trunk,代码行数:29,代码来源:EntityEventNodeNeo4j.java

示例10: getAllNodes

import org.neo4j.graphdb.DynamicLabel; //导入依赖的package包/类
public static List<String> getAllNodes(final GraphDatabaseService graphDb,
                                       final String labelName) {

    List<String> nodeIds = new ArrayList<>();
    Label label = DynamicLabel.label(labelName);
    ResourceIterable<Node> nodes;

    try (Transaction tx = graphDb.beginTx()) {
        nodes = GlobalGraphOperations.at(graphDb).getAllNodesWithLabel(label);

        for (Node node : nodes) {
            try {
                nodeIds.add(node.getProperty("node_id").toString());
            } catch (Exception e) {
                LOGGER.warn("Can't find a given node... skipping");
            }
        }

        tx.success();
    }

    return nodeIds;

}
 
开发者ID:inveniosoftware-contrib,项目名称:obelix,代码行数:25,代码来源:NeoHelpers.java

示例11: getOrCreateUserNode

import org.neo4j.graphdb.DynamicLabel; //导入依赖的package包/类
public static Node getOrCreateUserNode(final GraphDatabaseService graphDb,
                                       final String userID) {

    IndexManager index = graphDb.index();
    Index<Node> usersIndex = index.forNodes("users");

    Node node = usersIndex.get("node_id", userID).getSingle();

    if (node == null) {
        node = graphDb.createNode(DynamicLabel.label("User"));
        node.setProperty("node_id", userID);
        usersIndex.add(node, "node_id", userID);
    }

    return node;

}
 
开发者ID:inveniosoftware-contrib,项目名称:obelix,代码行数:18,代码来源:NeoHelpers.java

示例12: getOrCreateItemNode

import org.neo4j.graphdb.DynamicLabel; //导入依赖的package包/类
public static Node getOrCreateItemNode(final GraphDatabaseService graphDb,
                                       final String itemID) {

    IndexManager index = graphDb.index();
    Index<Node> usersIndex = index.forNodes("items");

    Node node = usersIndex.get("node_id", itemID).getSingle();

    if (node == null) {
        node = graphDb.createNode(DynamicLabel.label("Item"));
        node.setProperty("node_id", itemID);
        usersIndex.add(node, "node_id", itemID);
    }

    return node;

}
 
开发者ID:inveniosoftware-contrib,项目名称:obelix,代码行数:18,代码来源:NeoHelpers.java

示例13: createNode

import org.neo4j.graphdb.DynamicLabel; //导入依赖的package包/类
private synchronized void createNode(String labelName, Map<String, Object> properties, BatchInserterIndex idx,
		String pk) {
	idx.add(this.inserter.createNode(properties, DynamicLabel.label(labelName)),
			MapUtil.map(pk, properties.get(pk)));
	long n = this.counter.get(labelName);
	this.counter.put(labelName, ++n);
	if(n % this.flushInterval == 0)
		idx.flush();
}
 
开发者ID:bigbai0210,项目名称:Oracle2Neo4j,代码行数:10,代码来源:NeoDb.java

示例14: createSchema

import org.neo4j.graphdb.DynamicLabel; //导入依赖的package包/类
/**
 * Create schema.
 *
 * @param type     Type of schema to create (ie. constraint or index on node property)
 * @param label    Node label
 * @param property Node property
 */
public void createSchema(String type, String label, String property) {
    switch (type) {
        case "NODE_PROPERTY_UNIQUE":
            this.inserter.createDeferredConstraint(DynamicLabel.label(label)).assertPropertyIsUnique(property).create();
            break;
        case "NODE_PROPERTY_INDEX":
            this.inserter.createDeferredSchemaIndex(DynamicLabel.label(label)).on(property).create();
            break;
        default:
            // default is unique constraint
            this.inserter.createDeferredConstraint(DynamicLabel.label(label)).assertPropertyIsUnique(property).create();
            break;
    }
}
 
开发者ID:sim51,项目名称:neo4j-talend-component,代码行数:22,代码来源:Neo4jBatchDatabase.java

示例15: insert

import org.neo4j.graphdb.DynamicLabel; //导入依赖的package包/类
@Override
public String insert(Entity entity, Set<Value> values) throws ParseException, Exception {

	try (Transaction tx = graphDb.beginTx()) {

		if (values == null || values.isEmpty() || values.size() == 0)
			throw new Exception("Cannot insert an empty list");

		Node node = graphDb.createNode();
		node.addLabel(DynamicLabel.label(entity.getId()));
		node.addLabel(DynamicLabel.label(entity.getName()));

		for (Value value : values) {
			node.setProperty(value.getField().getFieldName(), value.getValue());

			if (value.getType().equals("entity")) {

				Node related = graphDb.getNodeById(Long.valueOf(value.getValue()));

				node.createRelationshipTo(related,
						DynamicRelationshipType.withName(value.getField().getFieldName()));
			}
		}

		tx.success();

		return entity.getId();
	}
}
 
开发者ID:lhzsantana,项目名称:federator,代码行数:30,代码来源:Neo4J.java


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