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


Java GraphDatabaseService.findNodes方法代码示例

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


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

示例1: evaluate

import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
@Override
public Collection<Neo4jSwitchMonitoredInjectMatch> evaluate() {
	final Collection<Neo4jSwitchMonitoredInjectMatch> matches = new ArrayList<>();

	final GraphDatabaseService graphDb = driver.getGraphDb();
	try (final Transaction tx = graphDb.beginTx()) {
		// (sw:Switch)
		final Iterable<Node> sws = () -> graphDb.findNodes(Neo4jConstants.labelSwitch);
		for (final Node sw : sws) {
			final Map<String, Object> match = new HashMap<>();
			match.put(QueryConstants.VAR_SW, sw);
			matches.add(new Neo4jSwitchMonitoredInjectMatch(match));
		}
	}

	return matches;
}
 
开发者ID:FTSRG,项目名称:trainbenchmark,代码行数:18,代码来源:Neo4JApiQuerySwitchMonitoredInject.java

示例2: evaluate

import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
@Override
public Collection<Neo4jPosLengthMatch> evaluate() {
	final Collection<Neo4jPosLengthMatch> matches = new ArrayList<>();

	final GraphDatabaseService graphDb = driver.getGraphDb();
	try (Transaction tx = graphDb.beginTx()) {
		// (segment:Segment)
		final Iterable<Node> segments = () -> graphDb.findNodes(Neo4jConstants.labelSegment);
		for (final Node segment : segments) {
			final Number lengthNumber = (Number) segment.getProperty(LENGTH);
			final int length = Neo4jHelper.numberToInt(lengthNumber);

			// segment.length <= 0
			if (length <= 0) {
				final Map<String, Object> match = new HashMap<>();
				match.put(VAR_SEGMENT, segment);
				match.put(VAR_LENGTH, length);
				matches.add(new Neo4jPosLengthMatch(match));
			}
		}
	}

	return matches;
}
 
开发者ID:FTSRG,项目名称:trainbenchmark,代码行数:25,代码来源:Neo4JApiQueryPosLength.java

示例3: evaluate

import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
@Override
public Collection<Neo4jSemaphoreNeighborInjectMatch> evaluate() {
	final Collection<Neo4jSemaphoreNeighborInjectMatch> matches = new ArrayList<>();

	final GraphDatabaseService graphDb = driver.getGraphDb();
	try (Transaction tx = graphDb.beginTx()) {
		// (route:Route)
		final Iterable<Node> routes = () -> graphDb.findNodes(Neo4jConstants.labelRoute);
		for (final Node route : routes) {
			Iterable<Relationship> entries = route.getRelationships(Direction.OUTGOING, Neo4jConstants.relationshipTypeEntry);

			for (Relationship entry : entries) {
				final Node semaphore = entry.getEndNode();

				final Map<String, Object> match = new HashMap<>();
				match.put(QueryConstants.VAR_ROUTE, route);
				match.put(QueryConstants.VAR_SEMAPHORE, semaphore);
				matches.add(new Neo4jSemaphoreNeighborInjectMatch(match));
			}
		}
	}

	return matches;
}
 
开发者ID:FTSRG,项目名称:trainbenchmark,代码行数:25,代码来源:Neo4JApiQuerySemaphoreNeighborInject.java

示例4: evaluate

import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
@Override
public Collection<Neo4jPosLengthInjectMatch> evaluate() {
	final Collection<Neo4jPosLengthInjectMatch> matches = new ArrayList<>();

	final GraphDatabaseService graphDb = driver.getGraphDb();
	try (Transaction tx = graphDb.beginTx()) {
		// (segment:Segment)
		final Iterable<Node> segments = () -> graphDb.findNodes(Neo4jConstants.labelSegment);
		for (final Node segment : segments) {
			final Map<String, Object> match = new HashMap<>();
			match.put(VAR_SEGMENT, segment);
			matches.add(new Neo4jPosLengthInjectMatch(match));
		}
	}

	return matches;
}
 
开发者ID:FTSRG,项目名称:trainbenchmark,代码行数:18,代码来源:Neo4JApiQueryPosLengthInject.java

示例5: evaluate

import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
@Override
public Collection<Neo4jSwitchSetInjectMatch> evaluate() {
	final Collection<Neo4jSwitchSetInjectMatch> matches = new ArrayList<>();

	final GraphDatabaseService graphDb = driver.getGraphDb();
	try (Transaction tx = graphDb.beginTx()) {
		// (sw:Switch)
		final Iterable<Node> sws = () -> graphDb.findNodes(Neo4jConstants.labelSwitch);
		for (final Node sw : sws) {
			final Map<String, Object> match = new HashMap<>();
			match.put(QueryConstants.VAR_SW, sw);
			matches.add(new Neo4jSwitchSetInjectMatch(match));
		}
	}

	return matches;
}
 
开发者ID:FTSRG,项目名称:trainbenchmark,代码行数:18,代码来源:Neo4JApiQuerySwitchSetInject.java

示例6: evaluate

import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
@Override
public Collection<Neo4jRouteSensorInjectMatch> evaluate() {
	final Collection<Neo4jRouteSensorInjectMatch> matches = new ArrayList<>();

	final GraphDatabaseService graphDb = driver.getGraphDb();
	try (Transaction tx = graphDb.beginTx()) {
		// (route:Route)
		final Iterable<Node> routes = () -> graphDb.findNodes(Neo4jConstants.labelRoute);
		for (final Node route : routes) {

			final Iterable<Node> sensors = Neo4jUtil.getAdjacentNodes(route, Neo4jConstants.relationshipTypeRequires,
					Direction.OUTGOING, Neo4jConstants.labelSensor);

			for (final Node sensor : sensors) {
				final Map<String, Object> match = new HashMap<>();
				match.put(QueryConstants.VAR_ROUTE, route);
				match.put(QueryConstants.VAR_SENSOR, sensor);
				matches.add(new Neo4jRouteSensorInjectMatch(match));
			}
		}
	}

	return matches;
}
 
开发者ID:FTSRG,项目名称:trainbenchmark,代码行数:25,代码来源:Neo4JApiQueryRouteSensorInject.java

示例7: evaluate

import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
@Override
public Collection<Neo4jSwitchMonitoredMatch> evaluate() {
	final Collection<Neo4jSwitchMonitoredMatch> matches = new ArrayList<>();

	final GraphDatabaseService graphDb = driver.getGraphDb();
	try (Transaction tx = graphDb.beginTx()) {
		final Iterable<Node> sws = () -> graphDb.findNodes(Neo4jConstants.labelSwitch);
		// (sw:Switch)
		for (final Node sw : sws) {
			// (sw)-[:sensor]->(Sensor) NAC
			final Iterable<Relationship> relationshipSensors = sw.getRelationships(Direction.OUTGOING, Neo4jConstants.relationshipTypeMonitoredBy);

			boolean hasSensor = false;
			for (final Relationship relationshipSensor : relationshipSensors) {
				final Node sensor = relationshipSensor.getEndNode();
				if (sensor.hasLabel(Neo4jConstants.labelSensor)) {
					hasSensor = true;
					break;
				}
			}

			if (!hasSensor) {
				final Map<String, Object> match = new HashMap<>();
				match.put(VAR_SW, sw);
				matches.add(new Neo4jSwitchMonitoredMatch(match));
			}
		}
	}

	return matches;
}
 
开发者ID:FTSRG,项目名称:trainbenchmark,代码行数:32,代码来源:Neo4JApiQuerySwitchMonitored.java

示例8: evaluate

import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
@Override
public Collection<Neo4jConnectedSegmentsInjectMatch> evaluate() throws IOException {
	final Collection<Neo4jConnectedSegmentsInjectMatch> matches = new ArrayList<>();

	final GraphDatabaseService graphDb = driver.getGraphDb();
	try (final Transaction tx = graphDb.beginTx()) {

		// (sensor:Sensor)
		final Iterable<Node> sensors = () -> graphDb.findNodes(Neo4jConstants.labelSensor);
		for (final Node sensor : sensors) {
			// (sensor:Sensor)<-[:sensor]-(segment1:Segment)
			final Iterable<Node> segment1s = Neo4jUtil.getAdjacentNodes(sensor, Neo4jConstants.relationshipTypeMonitoredBy, Direction.INCOMING,
					Neo4jConstants.labelSegment);

			for (final Node segment1 : segment1s) {
				// (segment1:Segment)-[:connectsTo]->(segment3:Segment)
				final Iterable<Node> segment3s = Neo4jUtil.getAdjacentNodes(segment1, Neo4jConstants.relationshipTypeConnectsTo, Direction.OUTGOING,
						Neo4jConstants.labelSegment);
				for (final Node segment3 : segment3s) {
					// (segment3:Segment)-[:sensor]->(sensor:Sensor)
					if (!Neo4jUtil.isConnected(segment3, sensor, Neo4jConstants.relationshipTypeMonitoredBy)) {
						continue;
					}

					final Map<String, Object> match = new HashMap<>();
					match.put(VAR_SENSOR, sensor);
					match.put(VAR_SEGMENT1, segment1);
					match.put(VAR_SEGMENT3, segment3);
					matches.add(new Neo4jConnectedSegmentsInjectMatch(match));
				}
			}
		}
	}
	return matches;
}
 
开发者ID:FTSRG,项目名称:trainbenchmark,代码行数:36,代码来源:Neo4JApiQueryConnectedSegmentsInject.java

示例9: evaluate

import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
@Override
public Collection<Neo4jRouteSensorMatch> evaluate() {
	final Collection<Neo4jRouteSensorMatch> matches = new ArrayList<>();

	final GraphDatabaseService graphDb = driver.getGraphDb();
	try (final Transaction tx = graphDb.beginTx()) {
		final Iterable<Node> routes = () -> graphDb.findNodes(Neo4jConstants.labelRoute);
		for (final Node route : routes) {
			// (route:Route)-[:follows]->(swp:switchPosition)
			final Iterable<Node> swPs = Neo4jUtil.getAdjacentNodes(route, Neo4jConstants.relationshipTypeFollows, Direction.OUTGOING, Neo4jConstants.labelSwitchPosition);
			for (final Node swP : swPs) {
				// (swP:switchPosition)-[:target]->(sw:Switch)
				final Iterable<Node> sws = Neo4jUtil.getAdjacentNodes(swP, Neo4jConstants.relationshipTypeTarget, Direction.OUTGOING, Neo4jConstants.labelSwitch);
				for (final Node sw : sws) {
					// (sw:Switch)-[:sensor]->(sensor:Sensor)
					final Iterable<Node> sensors = Neo4jUtil.getAdjacentNodes(sw, Neo4jConstants.relationshipTypeMonitoredBy, Direction.OUTGOING, Neo4jConstants.labelSensor);
					for (final Node sensor : sensors) {
						// (sensor:Sensor)<-[:requires]-(route:Route) NAC
						if (!Neo4jUtil.isConnected(route, sensor, Neo4jConstants.relationshipTypeRequires)) {
							final Map<String, Object> match = new HashMap<>();
							match.put(VAR_ROUTE, route);
							match.put(VAR_SENSOR, sensor);
							match.put(VAR_SWP, swP);
							match.put(VAR_SW, sw);
							matches.add(new Neo4jRouteSensorMatch(match));
						}
					}
				}
			}
		}
	}

	return matches;
}
 
开发者ID:FTSRG,项目名称:trainbenchmark,代码行数:35,代码来源:Neo4JApiQueryRouteSensor.java

示例10: evaluate

import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
@Override
public Collection<Neo4jConnectedSegmentsMatch> evaluate() throws IOException {
	final Collection<Neo4jConnectedSegmentsMatch> matches = new ArrayList<>();

	final GraphDatabaseService graphDb = driver.getGraphDb();
	try (final Transaction tx = graphDb.beginTx()) {

		// (sensor:Sensor)
		final Iterable<Node> sensors = () -> graphDb.findNodes(Neo4jConstants.labelSensor);
		for (final Node sensor : sensors) {
			// (sensor:Sensor)<-[:sensor]-(segment1:Segment)
			final Iterable<Node> segment1s = Neo4jUtil.getAdjacentNodes(sensor, Neo4jConstants.relationshipTypeMonitoredBy,
					Direction.INCOMING, Neo4jConstants.labelSegment);

			for (final Node segment1 : segment1s) {
				// (segment1:Segment)-[:connectsTo]->(segment2:Segment)
				final Iterable<Node> segment2s = Neo4jUtil.getAdjacentNodes(segment1, Neo4jConstants.relationshipTypeConnectsTo,
						Direction.OUTGOING, Neo4jConstants.labelSegment);
				for (final Node segment2 : segment2s) {
					// (segment2:Segment)-[:sensor]->(sensor:Sensor)
					if (!Neo4jUtil.isConnected(segment2, sensor, Neo4jConstants.relationshipTypeMonitoredBy)) {
						continue;
					}
					// (segment2:Segment)-[:connectsTo]->(segment3:Segment)
					final Iterable<Node> segment3s = Neo4jUtil.getAdjacentNodes(segment2, Neo4jConstants.relationshipTypeConnectsTo,
							Direction.OUTGOING, Neo4jConstants.labelSegment);
					for (final Node segment3 : segment3s) {
						// (segment3:Segment)-[:sensor]->(sensor:Sensor)
						if (!Neo4jUtil.isConnected(segment3, sensor, Neo4jConstants.relationshipTypeMonitoredBy)) {
							continue;
						}
						// (segment3:Segment)-[:connectsTo]->(segment4:Segment)
						final Iterable<Node> segment4s = Neo4jUtil.getAdjacentNodes(segment3, Neo4jConstants.relationshipTypeConnectsTo,
								Direction.OUTGOING, Neo4jConstants.labelSegment);
						for (final Node segment4 : segment4s) {
							// (segment4:Segment)-[:sensor]->(sensor:Sensor)
							if (!Neo4jUtil.isConnected(segment4, sensor, Neo4jConstants.relationshipTypeMonitoredBy)) {
								continue;
							}

							// (segment4:Segment)-[:connectsTo]->(segment5:Segment)
							final Iterable<Node> segment5s = Neo4jUtil.getAdjacentNodes(segment4,
									Neo4jConstants.relationshipTypeConnectsTo, Direction.OUTGOING, Neo4jConstants.labelSegment);
							for (final Node segment5 : segment5s) {
								// (segment5:Segment)-[:sensor]->(sensor:Sensor)
								if (!Neo4jUtil.isConnected(segment5, sensor, Neo4jConstants.relationshipTypeMonitoredBy)) {
									continue;
								}

								// (segment5:Segment)-[:connectsTo]->(segment6:Segment)
								final Iterable<Node> segment6s = Neo4jUtil.getAdjacentNodes(segment5, Neo4jConstants.relationshipTypeConnectsTo, Direction.OUTGOING, Neo4jConstants.labelSegment);
								for (final Node segment6 : segment6s) {
									// (segment6:Segment)-[:sensor]->(sensor:Sensor)
									if (!Neo4jUtil.isConnected(segment6, sensor, Neo4jConstants.relationshipTypeMonitoredBy)) {
										continue;
									}

									final Map<String, Object> match = new HashMap<>();
									match.put(VAR_SENSOR, sensor);
									match.put(VAR_SEGMENT1, segment1);
									match.put(VAR_SEGMENT2, segment2);
									match.put(VAR_SEGMENT3, segment3);
									match.put(VAR_SEGMENT4, segment4);
									match.put(VAR_SEGMENT5, segment5);
									match.put(VAR_SEGMENT6, segment6);
									matches.add(new Neo4jConnectedSegmentsMatch(match));
								}
							}
						}
					}
				}
			}
		}
	}

	return matches;
}
 
开发者ID:FTSRG,项目名称:trainbenchmark,代码行数:78,代码来源:Neo4JApiQueryConnectedSegments.java

示例11: evaluate

import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
@Override
public Collection<Neo4jSwitchSetMatch> evaluate() {
	final Collection<Neo4jSwitchSetMatch> matches = new ArrayList<>();

	final GraphDatabaseService graphDb = driver.getGraphDb();
	try (final Transaction tx = graphDb.beginTx()) {
		// (route:Route)
		final Iterable<Node> routes = () -> graphDb.findNodes(Neo4jConstants.labelRoute);
		for (final Node route : routes) {
			final boolean active = (boolean) route.getProperty(ModelConstants.ACTIVE);
			if (!active) {
				continue;
			}

			// (route:Route)-[:entry]->(semaphore:Semaphore)
			final Iterable<Node> semaphores = Neo4jUtil.getAdjacentNodes(route, Neo4jConstants.relationshipTypeEntry, Direction.OUTGOING,
					Neo4jConstants.labelSemaphore);
			for (final Node semaphore : semaphores) {

				// semaphore.signal = "GO"
				final String signal = (String) semaphore.getProperty(SIGNAL);
				if (!Signal.GO.toString().equals(signal)) {
					continue;
				}

				// (route:Route)-[:follows]->(swP:SwitchPosition)
				final Iterable<Node> swPs = Neo4jUtil.getAdjacentNodes(route, Neo4jConstants.relationshipTypeFollows, Direction.OUTGOING,
						Neo4jConstants.labelSwitchPosition);
				for (final Node swP : swPs) {
					// (swP:SwitchPosition)-[:target]->(sw:Switch)
					final Iterable<Node> sws = Neo4jUtil.getAdjacentNodes(swP, Neo4jConstants.relationshipTypeTarget,
							Direction.OUTGOING, Neo4jConstants.labelSwitch);

					for (final Node sw : sws) {
						final Object currentPosition = sw.getProperty(ModelConstants.CURRENTPOSITION);
						final Object position = swP.getProperty(ModelConstants.POSITION);

						if (!currentPosition.equals(position)) {
							final Map<String, Object> match = new HashMap<>();
							match.put(QueryConstants.VAR_SEMAPHORE, semaphore);
							match.put(QueryConstants.VAR_ROUTE, route);
							match.put(QueryConstants.VAR_SWP, swP);
							match.put(QueryConstants.VAR_SW, sw);
							match.put(QueryConstants.VAR_CURRENTPOSITION, currentPosition);
							match.put(QueryConstants.VAR_POSITION, position);
							matches.add(new Neo4jSwitchSetMatch(match));
						}
					}
				}
			}
		}
	}

	return matches;
}
 
开发者ID:FTSRG,项目名称:trainbenchmark,代码行数:56,代码来源:Neo4JApiQuerySwitchSet.java

示例12: evaluate

import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
@Override
public Collection<Neo4jSemaphoreNeighborMatch> evaluate() {
	final Collection<Neo4jSemaphoreNeighborMatch> matches = new ArrayList<>();

	final GraphDatabaseService graphDb = driver.getGraphDb();
	try (final Transaction tx = graphDb.beginTx()) {
		final Iterable<Node> route1s = () -> graphDb.findNodes(Neo4jConstants.labelRoute);
		for (final Node route1 : route1s) {
			// (route1:Route)-[:exit]->(semaphore:Semaphore)
			final Iterable<Node> semaphores = Neo4jUtil.getAdjacentNodes(route1, Neo4jConstants.relationshipTypeExit,
					Direction.OUTGOING, Neo4jConstants.labelSemaphore);
			for (final Node semaphore : semaphores) {

				// (route1:Route)-[:requires]->(sensor1:Sensor)
				final Iterable<Node> sensor1s = Neo4jUtil.getAdjacentNodes(route1, Neo4jConstants.relationshipTypeRequires,
						Direction.OUTGOING, Neo4jConstants.labelSensor);
				for (final Node sensor1 : sensor1s) {
					// (sensor1:Sensor)<-[:sensor]-(te1:TrackElement)
					final Iterable<Node> te1s = Neo4jUtil.getAdjacentNodes(sensor1, Neo4jConstants.relationshipTypeMonitoredBy, Direction.INCOMING, Neo4jConstants.labelTrackElement);
					for (final Node te1 : te1s) {
						// (te1:TrackElement)-[:connectsTo]->(te2:TrackElement)
						final Iterable<Node> te2s = Neo4jUtil.getAdjacentNodes(te1, Neo4jConstants.relationshipTypeConnectsTo, Direction.OUTGOING, Neo4jConstants.labelTrackElement);
						for (final Node te2 : te2s) {
							// (te2:TrackElement)-[:sensor]->(sensor2:Sensor)
							final Iterable<Node> sensor2s = Neo4jUtil.getAdjacentNodes(te2, Neo4jConstants.relationshipTypeMonitoredBy, Direction.OUTGOING, Neo4jConstants.labelSensor);
							for (final Node sensor2 : sensor2s) {
								// (sensor2:Sensor)<-[:requires]-(route2:Route),
								final Iterable<Node> route2s = Neo4jUtil.getAdjacentNodes(sensor2, Neo4jConstants.relationshipTypeRequires, Direction.INCOMING, Neo4jConstants.labelRoute);
								for (final Node route2 : route2s) {
									// route1 != route2 --> if (route1 == route2), continue
									if (route1.equals(route2)) {
										continue;
									}

									// (route2)-[:entry]->(semaphore) NAC
									if (!Neo4jUtil.isConnected(route2, semaphore, Neo4jConstants.relationshipTypeEntry)) {
										final Map<String, Object> match = new HashMap<>();
										match.put(VAR_SEMAPHORE, semaphore);
										match.put(VAR_ROUTE1, route1);
										match.put(VAR_ROUTE2, route2);
										match.put(VAR_SENSOR1, sensor1);
										match.put(VAR_SENSOR2, sensor2);
										match.put(VAR_TE1, te1);
										match.put(VAR_TE2, te2);
										matches.add(new Neo4jSemaphoreNeighborMatch(match));
										break;
									}
								}
							}
						}
					}
				}
			}
		}
	}

	return matches;
}
 
开发者ID:FTSRG,项目名称:trainbenchmark,代码行数:59,代码来源:Neo4JApiQuerySemaphoreNeighbor.java


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