/** * Returns the fullclubreference of a club given a clubID * * @param clubID * @return */ public String getClubRef(final String clubID) { String reference = ""; final long clubId = Long.parseLong(clubID); try (Transaction tx = DataControl_Neo4j_Singleton.getTx()) { final Map<String, Object> properties = new HashMap<>(); properties.put("clubId", clubId); final Query query = QueryBuilder.newQuery().match().clubHasId().complete("club AS n"); final Node node = DataControl_Neo4j_Singleton.getNodeForQuery(query.get(), properties); if (node != null) { reference = (String) node.getProperty("fullclubref", -1L); } tx.success(); } return reference; }
/** * Returns the id of a club given a fullclubreference * * @param clubID * @return */ public String getClubID(final String fullclubref) { long _id = -1l; try (Transaction tx = DataControl_Neo4j_Singleton.getTx()) { final Map<String, Object> properties = new HashMap<>(); properties.put("reference", fullclubref); final Query query = QueryBuilder.newQuery() .append("MATCH (club:Club{fullclubref: {reference}})") .complete("club AS n"); final Node node = DataControl_Neo4j_Singleton.getNodeForQuery(query.get(), properties); if (node != null) { _id = (long) node.getProperty("_id", -1L); } tx.success(); } return "" + _id; }
@Override public boolean delete() { if ((this._sessionId == -1L) || (this._childId == -1L)) { return false; } final String cypher = " " + " MATCH (child:Child{_id: {_childId}})-[attended:ATTENDED]->(session:Session{_id: {_sessionId}}) " + " DELETE attended "; final Map<String, Object> params = new HashMap<>(); params.put("_sessionId", this._sessionId); params.put("_childId", this._childId); DataControl_Neo4j_Singleton.execute(cypher, params); return true; }