/
Neo4jCoreQuerySwitchMonitoredInject.java
53 lines (44 loc) · 2.07 KB
/
Neo4jCoreQuerySwitchMonitoredInject.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*******************************************************************************
* Copyright (c) 2010-2015, Benedek Izso, Gabor Szarnyas, Istvan Rath and Daniel Varro
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Benedek Izso - initial API and implementation
* Gabor Szarnyas - initial API and implementation
*******************************************************************************/
package hu.bme.mit.trainbenchmark.benchmark.neo4j.queries.core;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Transaction;
import hu.bme.mit.trainbenchmark.benchmark.neo4j.driver.Neo4jDriver;
import hu.bme.mit.trainbenchmark.benchmark.neo4j.matches.Neo4jSwitchMonitoredInjectMatch;
import hu.bme.mit.trainbenchmark.constants.QueryConstants;
import hu.bme.mit.trainbenchmark.constants.RailwayQuery;
import hu.bme.mit.trainbenchmark.neo4j.Neo4jConstants;
public class Neo4jCoreQuerySwitchMonitoredInject extends Neo4jCoreQuery<Neo4jSwitchMonitoredInjectMatch> {
public Neo4jCoreQuerySwitchMonitoredInject(final Neo4jDriver driver) {
super(RailwayQuery.SWITCHMONITORED_INJECT, driver);
}
@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;
}
}