Package org.neo4j.graphdb

Examples of org.neo4j.graphdb.RelationshipType


      // use temporary map to avoid frequent construction of Long values when increasing..
      Map<RelationshipType, LongValueHolder> values = new LinkedHashMap<>();
      for (Relationship r : rels) {

        RelationshipType relType = r.getType();
        LongValueHolder count = values.get(relType);
        if(count == null) {
          count = new LongValueHolder();
          values.put(relType, count);
        }
        count.inc();
      }

      // create results from temporary map
      for(Entry<RelationshipType, LongValueHolder> entry : values.entrySet()) {
        RelationshipType key = entry.getKey();
        LongValueHolder value = entry.getValue();
        statistics.put(key, value.getValue());
      }

    } catch (RuntimeException e) {
View Full Code Here


  public <A extends NodeInterface, B extends NodeInterface, S extends Source, T extends Target, R extends Relation<A, B, S, T>> Iterable<R> getRelationships(final Class<R> type) {

    final RelationshipFactory<R> factory = new RelationshipFactory<>(securityContext);
    final R template                     = getRelationshipForType(type);
    final Direction direction            = template.getDirectionForType(entityType);
    final RelationshipType relType       = template;

    return new IterableAdapter<>(dbNode.getRelationships(relType, direction), factory);
  }
View Full Code Here

              Node endNode   = uuidMap.get(endId);
              Node startNode = uuidMap.get(startId);

              if (startNode != null && endNode != null) {

                RelationshipType relType = DynamicRelationshipType.withName(relTypeName);
                currentObject = startNode.createRelationshipTo(endNode, relType);

                // store for later use
                rels.add((Relationship)currentObject);
              }
View Full Code Here

        .getOrCreateRootNode("secretRootId");

    LOG.debug(String.format("Added %s with grapId: %s to neo4j db",
        rootNode, rootNode.getGraphId()));
   
    RelationshipType referenceNodeRelationship = new RelationshipType() {
     
      @Override
      public String name() {
        return "REFERENCE_NODE";
      }
View Full Code Here

        long nextRel = nodeRecord.getNextRel();
        List<BatchRelationship> rels = new ArrayList<BatchRelationship>();
        while ( nextRel != Record.NO_NEXT_RELATIONSHIP.intValue() )
        {
            RelationshipRecord relRecord = getRelationshipRecord( nextRel );
            RelationshipType type = new RelationshipTypeImpl(
                typeHolder.getName( relRecord.getType() ) );
            rels.add( new BatchRelationship( relRecord.getId(),
                relRecord.getFirstNode(), relRecord.getSecondNode(), type ) );
            long firstNode = relRecord.getFirstNode();
            long secondNode = relRecord.getSecondNode();
View Full Code Here

        long nextRel = nodeRecord.getNextRel();
        List<SimpleRelationship> rels = new ArrayList<SimpleRelationship>();
        while ( nextRel != Record.NO_NEXT_RELATIONSHIP.intValue() )
        {
            RelationshipRecord relRecord = getRelationshipRecord( nextRel );
            RelationshipType type = new RelationshipTypeImpl(
                    typeHolder.getName( relRecord.getType() ) );
            rels.add( new SimpleRelationship( relRecord.getId(),
                    relRecord.getFirstNode(), relRecord.getSecondNode(), type ) );
            long firstNode = relRecord.getFirstNode();
            long secondNode = relRecord.getSecondNode();
View Full Code Here

    @Override
    public BatchRelationship getRelationshipById( long relId )
    {
        RelationshipRecord record = getRelationshipRecord( relId );
        RelationshipType type = new RelationshipTypeImpl(
            typeHolder.getName( record.getType() ) );
        return new BatchRelationship( record.getId(), record.getFirstNode(),
            record.getSecondNode(), type );
    }
View Full Code Here

    }

    public SimpleRelationship getSimpleRelationshipById( long relId )
    {
        RelationshipRecord record = getRelationshipRecord( relId );
        RelationshipType type = new RelationshipTypeImpl(
                typeHolder.getName( record.getType() ) );
        return new SimpleRelationship( record.getId(), record.getFirstNode(),
                record.getSecondNode(), type );
    }
View Full Code Here

    private  WeightedPath findPaths( Double lat1, Double lon1, Double lat2, Double lon2, Double time )
    {
        Node start = setupStart( lat1, lon1, time );
        Node end = setupEnd( lat2, lon2 );
        RelationshipType lat2lon2 = DynamicRelationshipType.withName( lat2.toString() + lon2.toString() );
        WaitingTimeCostEvaluator eval = new WaitingTimeCostEvaluator(Connection.COST, lat2lon2);
        Dijkstra dijkstra = new Dijkstra( expander, eval, time );
        return dijkstra.findSinglePath( start, end );
    }
View Full Code Here

    private  Node setupEnd( Double lat2, Double lon2 )
    {
        Node endNode = db.createNode();
        endNode.setProperty( Hub.LATITUDE, lat2);
        endNode.setProperty( Hub.LONGITUDE, lon2 )
        RelationshipType lat2lon2 = DynamicRelationshipType.withName( lat2.toString() + lon2.toString() );
        expander = Traversal.expanderForTypes(
                Type.WALK1, Direction.OUTGOING,
                Type.HUBBUS1, Direction.OUTGOING,
                Type.TRANSFER, Direction.OUTGOING,
                Type.WALK2, Direction.OUTGOING,
                lat2lon2, Direction.OUTGOING );  
       
        Set<String> hubSet = new HashSet<String>();
        Map<Node, Double> hits = spatialService.queryWithinDistance( lat2, lon2 );
        int i = 0;
        for ( Entry<Node, Double> entry : hits.entrySet() )    
        {                   
            String hubID = (String) entry.getKey().getProperty( Stop.FROMHUB  );
            if ( !hubSet.contains( hubID ) )
            {
                for(Node endHub : hubLayer2.query( Hub.HUBID, hubID ) )
                {         
                    Relationship walk = endHub.createRelationshipTo( endNode, lat2lon2);
                    double distanceInKm = (entry.getValue() );
                    double distanceInMins = Math.round( 20 * distanceInKm * 1e2 ) / 1e2;
                    walk.setProperty( Connection.COST, distanceInMins*);
                    walk.setProperty( Connection.DISTANCE, distanceInKm );
                    walk.setProperty( Stop.STOPID, (String)entry.getKey().getProperty( Stop.STOPID )  );
                    walk.setProperty( Stop.LATITUDE, (Double)entry.getKey().getProperty( Stop.LATITUDE )  );
                    walk.setProperty( Stop.LONGITUDE, (Double)entry.getKey().getProperty( Stop.LONGITUDE )  );
                    RelationshipType routeId = DynamicRelationshipType.withName((String) entry.getKey().getProperty( Stop.ROUTEID  ));
                    expander = expander.add( routeId, Direction.OUTGOING );                  
                    hubSet.add( hubID );  
                    if ( ++i == 50 ) break;
                }

View Full Code Here

TOP

Related Classes of org.neo4j.graphdb.RelationshipType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.