SDN 4缺少图表中的关系

时间:2016-02-16 15:56:01

标签: neo4j spring-data-neo4j-4 neo4j-ogm

当我将Neo4j节点存储到Neo4j图形时,只存储节点(没有关系)。有没有人可以指出我正确的方向我在那里缺少什么?

这是我的节点

@NodeEntity public class Game extends AbstractEntity{

     public Long        timestamp;
     public double  total_pot_size;

     public int     flop;
     public int     turn;
     public int     river;

     @Relationship(type = "ROUND")
     public Set<Round> rounds;

     @Relationship(type = "OUTCOME")
     public Set<Outcome> outcomes;


     public Game() {
         super();
     }

     public void add(Outcome outcome) {
         if (outcomes == null) {
            outcomes = new HashSet<Outcome>();
         }
         outcomes.add(outcome);
     }

     public void add(Round round) {
         if (rounds == null) {
             rounds = new HashSet<Round>();
         }
        rounds.add(round);
     }
 }

@NodeEntity public class Player extends AbstractEntity {

    public String   name;
    public String   platform;

    @Relationship(type = "PARTICIPATION", direction = Relationship.OUTGOING)
    public Set<Participation> involved_games;

    @Relationship(type = "OWNS")
    public Set<Statistics> statistics;

    public Player() {
        super();
    }

    public void participate(Participation involved_game) {
        if (involved_games == null) {
            involved_games  = new HashSet<Participation>();
        }
        involved_games.add(involved_game);
    }

    public void add(Statistics stat) {
        if (statistics == null) {
            statistics  = new HashSet<>();
        }
        statistics.add(stat);
    }
}

这是我用来存储数据的代码。

    // create or get a new game in database
    Game    game    = gameRepo.save( DataUtil.createGame(gi) );

    // get the player involved to the game
    List<Player> players    = gi.getPlayers();
    // for each player involved to the game...
    for (Player player : players) {
        org.quazar.data.domain.Player p = store(player);
        // relationship participation
        p.participate(DataUtil.createParticipation(p, game, player));
        // set the outcome of the players
        game.add(DataUtil.createOutcome(game, p, gi, player));
        playerRepo.save(p);
    }

    gameRepo.save( game );

商店(播放器)方法保存或检索(如果不是新的话)正常工作的播放器。 DataUtil.createParticipation和DataUtil.createOutcome方法创建新关系(例如,new Outcome())并设置属性。

运行我的应用程序时,我没有任何例外,但在图表中我想念我的关系。

我没有列出所有节点(例如统计数据),因为我现在不在我的模型中使用它们,是否会导致问题?

以下是一些关系:

@RelationshipEntity(type = "PARTICIPATION")
public class Participation extends AbstractEntity {

    @StartNode
    public Player   player;

    @EndNode
    public Game     game;

    @Property
    public double   bankroll;

    @Property
    public int      holecards;
    @Property
    public byte     position;

    public Participation () {
        super();
    }

}

@RelationshipEntity(type = "OUTCOME")
public class Outcome extends AbstractEntity {

    @StartNode
    public Game     game;

    @EndNode
    public Player   player;

    @Property
    public String   type;

    @Property
    public String   round;

    @Property
    public double   pot_size;
    @Property
    public double   ante;

    @Property
    public int      holecards;
    @Property
    public String   bestHand;
    @Property
    public int      bestHandrank;

    public Outcome() {
        super();
    }
}

0 个答案:

没有答案