Skip to content

Commit

Permalink
remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
keski committed Sep 25, 2024
1 parent 8576ab0 commit 6416b0f
Showing 1 changed file with 9 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down Expand Up @@ -119,9 +91,14 @@ public List<TableRecord> 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());
}

Expand Down

0 comments on commit 6416b0f

Please sign in to comment.