From 6416b0fb5dfdaff7cc1397d6a42efdfc9f33feba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20Keskis=C3=A4rkk=C3=A4?= Date: Wed, 25 Sep 2024 08:38:10 +0200 Subject: [PATCH] remove unused code --- .../lpg/conn/Neo4jConnectionFactory.java | 41 ++++--------------- 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/hefquin-pgconnector/src/main/java/se/liu/ida/hefquin/engine/wrappers/lpg/conn/Neo4jConnectionFactory.java b/hefquin-pgconnector/src/main/java/se/liu/ida/hefquin/engine/wrappers/lpg/conn/Neo4jConnectionFactory.java index d3c6f8aa7..0e51f892d 100644 --- a/hefquin-pgconnector/src/main/java/se/liu/ida/hefquin/engine/wrappers/lpg/conn/Neo4jConnectionFactory.java +++ b/hefquin-pgconnector/src/main/java/se/liu/ida/hefquin/engine/wrappers/lpg/conn/Neo4jConnectionFactory.java @@ -5,12 +5,6 @@ import se.liu.ida.hefquin.engine.wrappers.lpg.Neo4jException; import se.liu.ida.hefquin.engine.wrappers.lpg.data.TableRecord; import se.liu.ida.hefquin.engine.wrappers.lpg.query.CypherQuery; -import se.liu.ida.hefquin.engine.wrappers.lpg.query.impl.expression.AliasedExpression; -import se.liu.ida.hefquin.engine.wrappers.lpg.query.impl.expression.CypherVar; -import se.liu.ida.hefquin.engine.wrappers.lpg.query.impl.expression.TypeExpression; -import se.liu.ida.hefquin.engine.wrappers.lpg.query.impl.expression.VariableIDExpression; -import se.liu.ida.hefquin.engine.wrappers.lpg.query.impl.match.EdgeMatchClause; -import se.liu.ida.hefquin.engine.wrappers.lpg.utils.CypherQueryBuilder; import se.liu.ida.hefquin.engine.wrappers.lpg.utils.CypherUtils; import java.io.IOException; @@ -21,33 +15,11 @@ import java.net.http.HttpResponse; import java.util.List; import java.util.Base64; +import java.util.Set; public class Neo4jConnectionFactory { - public static CypherQuery buildGetEdgesQuery() { - // MATCH (n1)-[e]->(n2) - // RETURN ID(n1) AS nid1, ID(n2) AS nid2, e AS edge, TYPE(e) AS reltype - - final CypherVar n1 = new CypherVar("n1"); - final CypherVar n2 = new CypherVar("n2"); - final CypherVar e = new CypherVar("e"); - - final CypherVar nid1 = new CypherVar("nid1"); - final CypherVar nid2 = new CypherVar("nid2"); - final CypherVar edge = new CypherVar("edge"); - final CypherVar reltype = new CypherVar("reltype"); - - return new CypherQueryBuilder() - .addMatch( new EdgeMatchClause(n1, e, n2) ) - .addReturn( new AliasedExpression(new VariableIDExpression(n1), nid1) ) - .addReturn( new AliasedExpression(new VariableIDExpression(n2), nid2) ) - .addReturn( new AliasedExpression(e, edge) ) - .addReturn( new AliasedExpression(new TypeExpression(e), reltype) ) - .build(); - } - - static public Neo4jConnection connect( final String url ) { return new Neo4jConnection(url); } @@ -119,9 +91,14 @@ public List execute( final String cypherQuery ) throws Neo4jExcepti catch ( final InterruptedException e ) { throw new Neo4jConnectionException(this, "Neo4j server could not be reached.", e); } - - System.err.println("Code: " + response.statusCode()); - if ( ! ( response.statusCode() >= 200 && response.statusCode() < 300 ) ) { + + // According to the Neo4J API documentation, a query can return 200 OK or 201 + // Created when executed over the HTTP API because it wraps the request in an + // implicit transaction (i.e., the 201 can indicate that the transaction was + // successfully created, not that data was inserted/changed). It also lists 202 + // Accepted as a possible response code in some circumstances. See + // https://neo4j.com/docs/query-api/current/query/ + if ( ! (Set.of( 200, 201, 202 ).contains( response.statusCode() )) ) { throw new Neo4jConnectionException(this, "Unexpected status code in HTTP response from Neo4j server: " + response.statusCode()); }