This repository has been archived by the owner on Sep 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renames and refactoring around ends of line discover and handling. Re…
…moved some deprecated code
- Loading branch information
1 parent
8f716a8
commit dea4683
Showing
17 changed files
with
242 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package com.tramchester.graph; | ||
|
||
import com.tramchester.domain.id.IdSet; | ||
import com.tramchester.domain.places.RouteStation; | ||
import com.tramchester.domain.reference.TransportMode; | ||
import com.tramchester.graph.graphbuild.GraphProps; | ||
import com.tramchester.graph.graphbuild.StagedTransportGraphBuilder; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.neo4j.graphdb.Node; | ||
import org.neo4j.graphdb.Result; | ||
import org.neo4j.graphdb.Transaction; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import javax.inject.Inject; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class FindRouteEndPoints { | ||
private static final Logger logger = LoggerFactory.getLogger(FindRouteEndPoints.class); | ||
private final GraphDatabase graphDatabase; | ||
|
||
@Inject | ||
public FindRouteEndPoints(GraphDatabase graphDatabase, StagedTransportGraphBuilder.Ready readyToken) { | ||
this.graphDatabase = graphDatabase; | ||
} | ||
|
||
public IdSet<RouteStation> searchForStarts(TransportMode mode) { | ||
logger.info("Find starts for " +mode); | ||
|
||
String query = "MATCH (a:ROUTE_STATION)-[r1:ON_ROUTE]->(:ROUTE_STATION) " + | ||
"WHERE $mode in r1.transport_mode " + | ||
"AND " + | ||
"NOT EXISTS { " + | ||
"MATCH (:ROUTE_STATION)-[r2:ON_ROUTE]->(a:ROUTE_STATION) " + | ||
"WHERE $mode in r2.transport_mode AND r1.route_id=r2.route_id" + | ||
"}" + | ||
" RETURN a"; | ||
|
||
IdSet<RouteStation> stationIds = getIdFors(mode, query); | ||
|
||
logger.info("Found " + stationIds.size() + " starts "); | ||
return stationIds; | ||
} | ||
|
||
public IdSet<RouteStation> searchForEnds(TransportMode mode) { | ||
logger.info("Find ends for " +mode); | ||
|
||
String query = "MATCH (:ROUTE_STATION)-[r1:ON_ROUTE]->(a:ROUTE_STATION) " + | ||
"WHERE $mode in r1.transport_mode " + | ||
"AND " + | ||
"NOT EXISTS { " + | ||
"MATCH (a:ROUTE_STATION)-[r2:ON_ROUTE]->(:ROUTE_STATION) " + | ||
"WHERE $mode in r2.transport_mode AND r1.route_id=r2.route_id" + | ||
"}" + | ||
" RETURN a"; | ||
|
||
IdSet<RouteStation> stationIds = getIdFors(mode, query); | ||
logger.info("Found " + stationIds.size() + " ends"); | ||
return stationIds; | ||
} | ||
|
||
@NotNull | ||
private IdSet<RouteStation> getIdFors(TransportMode mode, String query) { | ||
logger.debug("Query: '" + query + '"'); | ||
|
||
Map<String, Object> params = new HashMap<>(); | ||
params.put("mode", mode.getNumber()); | ||
|
||
IdSet<RouteStation> stationIds = new IdSet<>(); | ||
try (Transaction txn = graphDatabase.beginTx()) { | ||
Result result = txn.execute(query, params); | ||
while (result.hasNext()) { | ||
Map<String, Object> row = result.next(); | ||
Node node = (Node) row.get("a"); | ||
stationIds.add(GraphProps.getRouteStationIdFrom(node)); | ||
} | ||
result.close(); | ||
} | ||
return stationIds; | ||
} | ||
|
||
} |
56 changes: 0 additions & 56 deletions
56
main/src/com/tramchester/graph/FindStationsAtEndsOfRoutes.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 0 additions & 51 deletions
51
main/src/com/tramchester/repository/EndsOfRoutesRepository.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.