Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Commit

Permalink
All test are OK for next release
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoît Simard committed Jul 1, 2013
1 parent 8a38499 commit 760b30c
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 193 deletions.
1 change: 1 addition & 0 deletions samples-and-tests/logisima-play-neo4j-test/conf/data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,4 @@ Relation(50):
type: ADDRESS
from: User_2
to: Address_1

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import org.junit.Test;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.tooling.GlobalGraphOperations;

import play.Logger;
import play.modules.neo4j.exception.Neo4jException;
import play.modules.neo4j.util.Fixtures;
import play.modules.neo4j.util.Neo4j;
Expand All @@ -16,20 +18,22 @@ public void importYmlTest() throws Neo4jException {
Fixtures.deleteDatabase();
Fixtures.loadYml("data.yml");
assertEquals(12, countGraphNode());
assertEquals(14, countGraphRelationType());
assertEquals(11, countGraphRelationType());
}

private int countGraphNode() {
int nb = 0;
for (Node node : Neo4j.db().getAllNodes()) {
for (Node node : GlobalGraphOperations.at(Neo4j.db()).getAllNodes()) {
Logger.info("Node " + node.getId() + " => " + node.toString());
nb++;
}
return nb;
}

private int countGraphRelationType() {
int nb = 0;
for (RelationshipType relationType : Neo4j.db().getRelationshipTypes()) {
for (RelationshipType relationType : GlobalGraphOperations.at(Neo4j.db()).getAllRelationshipTypes()) {
Logger.info("Relation " + relationType.name());
nb++;
}
return nb;
Expand Down
143 changes: 0 additions & 143 deletions samples-and-tests/logisima-play-neo4j-touiteur/.classpath

This file was deleted.

24 changes: 0 additions & 24 deletions samples-and-tests/logisima-play-neo4j-touiteur/.project

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package jobs;

import play.Logger;
import play.jobs.Job;
import play.jobs.OnApplicationStart;
import play.modules.neo4j.util.Fixtures;

@OnApplicationStart
public class Bootstrap extends Job {

public void doJob() {
// Logger.info("Delete database & load yml file");
// Fixtures.deleteDatabase();
// Fixtures.loadYml("data.yml");
Logger.info("Delete database & load yml file");
Fixtures.deleteDatabase();
Fixtures.loadYml("data.yml");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.neo4j.graphdb.Transaction;
import org.neo4j.helpers.collection.IteratorUtil;

import play.Logger;
import play.db.jpa.Blob;
import play.modules.neo4j.annotation.Neo4jIndex;
import play.modules.neo4j.annotation.Neo4jRelatedTo;
Expand Down Expand Up @@ -150,13 +151,15 @@ public void reTouite(Long key) throws Neo4jException {

// delete the previous NEXT relationship
Relationship next = this.node.getSingleRelationship(RelationType.NEXT, Direction.OUTGOING);
next.delete();
if (next != null)
next.delete();

// create next link between user & touite
this.node.createRelationshipTo(retouite.node, RelationType.NEXT);

// relink lasttouite with the new one
retouite.node.createRelationshipTo(lastTouite.node, RelationType.NEXT);
if (lastTouite != null)
retouite.node.createRelationshipTo(lastTouite.node, RelationType.NEXT);

// create author link
retouite.node.createRelationshipTo(touite.getAuthor().node, RelationType.AUTHOR);
Expand Down Expand Up @@ -190,7 +193,8 @@ public void touite(String text) throws Neo4jException {
Touite lastTouite = this.getLastTouite();
// delete the previous NEXT relationship
Relationship next = this.node.getSingleRelationship(RelationType.NEXT, Direction.OUTGOING);
next.delete();
if (next != null)
next.delete();

// create next link between user & touite
this.node.createRelationshipTo(touite.node, RelationType.NEXT);
Expand All @@ -199,7 +203,8 @@ public void touite(String text) throws Neo4jException {
touite.node.createRelationshipTo(this.node, RelationType.AUTHOR);

// relink lasttouite with the new one
touite.node.createRelationshipTo(lastTouite.node, RelationType.NEXT);
if (lastTouite != null)
touite.node.createRelationshipTo(lastTouite.node, RelationType.NEXT);

// +1
if (this.nbTouite != null) {
Expand All @@ -226,6 +231,12 @@ public List<User> getSimilarUser(User user) throws Neo4jException {
"RETURN reco, COUNT(*) " +
"ORDER BY COUNT(*) DESC, reco.key " +
"LIMIT 3");
Logger.debug("START user=node(" + user.node.getId() + ") " +
"MATCH reco-[:IS_FRIEND*1..3]->user, user-[r?:IS_FRIEND]->reco " +
"WHERE r IS NULL and not(reco.key = user.key) " +
"RETURN reco, COUNT(*) " +
"ORDER BY COUNT(*) DESC, reco.key " +
"LIMIT 3");
//@formatter:on
List<User> recos = new ArrayList<User>();
Iterator<Node> column = result.columnAs("reco");
Expand Down
Loading

0 comments on commit 760b30c

Please sign in to comment.