コード例 #1
0
        private MutableIntObjectMap <MutableLongSet> GetTypeToRelMapForDirection(RelationshipDirection direction)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.map.primitive.MutableIntObjectMap<org.eclipse.collections.api.set.primitive.MutableLongSet> relTypeToRelsMap;
            MutableIntObjectMap <MutableLongSet> relTypeToRelsMap;

            switch (direction)
            {
            case RelationshipDirection.INCOMING:
                relTypeToRelsMap = Incoming();
                break;

            case RelationshipDirection.OUTGOING:
                relTypeToRelsMap = Outgoing();
                break;

            case RelationshipDirection.LOOP:
                relTypeToRelsMap = Loops();
                break;

            default:
                throw new System.ArgumentException("Unknown direction: " + direction);
            }
            return(relTypeToRelsMap);
        }
コード例 #2
0
        public void RemoveRelationship(RelationshipType relationshipType, RelationshipDirection relationshipDirection, GameBaseObject relationshipTo)
        {
            // if null instanciate Relationships
            if (Relationships == null)
            {
                Relationships = new List <GameObjectRelationship>();
            }

            // if relationshipTo's Relationships is null instanciate Relationships
            if (relationshipTo.Relationships == null)
            {
                relationshipTo.Relationships = new List <GameObjectRelationship>();
            }

            // remove new relationship
            Relationships.Remove(new GameObjectRelationship(relationshipType, relationshipDirection, relationshipTo));

            // remove other type of relationship
            if (relationshipDirection == RelationshipDirection.ParentToChild)
            {
                relationshipTo.Relationships.Remove(new GameObjectRelationship(relationshipType, RelationshipDirection.ChildToParent, this));
            }
            else if (relationshipDirection == RelationshipDirection.ChildToParent)
            {
                relationshipTo.Relationships.Remove(new GameObjectRelationship(relationshipType, RelationshipDirection.ParentToChild, this));
            }
        }
コード例 #3
0
        public virtual int AugmentDegree(RelationshipDirection direction, int degree, int typeId)
        {
            switch (direction)
            {
            case RelationshipDirection.INCOMING:
                if (_incoming != null && _incoming.containsKey(typeId))
                {
                    return(_diffStrategy.augmentDegree(degree, _incoming.get(typeId).size()));
                }
                break;

            case RelationshipDirection.OUTGOING:
                if (_outgoing != null && _outgoing.containsKey(typeId))
                {
                    return(_diffStrategy.augmentDegree(degree, _outgoing.get(typeId).size()));
                }
                break;

            case RelationshipDirection.LOOP:
                if (_loops != null && _loops.containsKey(typeId))
                {
                    return(_diffStrategy.augmentDegree(degree, _loops.get(typeId).size()));
                }
                break;

            default:
                throw new System.ArgumentException("Unknown direction: " + direction);
            }

            return(degree);
        }
コード例 #4
0
 public Neo4JRelationshipAttribute(
     string name,
     RelationshipDirection direction)
 {
     Name      = name;
     Direction = direction;
 }
コード例 #5
0
        private int DegreeForDirectionAndType(StorageNodeCursor cursor, RelationshipDirection direction, int relType)
        {
            int degree = 0;

            using (StorageRelationshipGroupCursor groups = StorageReader.allocateRelationshipGroupCursor())
            {
                groups.Init(cursor.EntityReference(), cursor.RelationshipGroupReference());
                while (groups.Next())
                {
                    if (relType == ANY_RELATIONSHIP_TYPE || relType == groups.Type())
                    {
                        switch (direction)
                        {
                        case RelationshipDirection.OUTGOING:
                            degree += groups.OutgoingCount() + groups.LoopCount();
                            break;

                        case RelationshipDirection.INCOMING:
                            degree += groups.IncomingCount() + groups.LoopCount();
                            break;

                        case RelationshipDirection.LOOP:
                            degree += groups.OutgoingCount() + groups.IncomingCount() + groups.LoopCount();
                            break;

                        default:
                            throw new System.ArgumentException(direction.name());
                        }
                    }
                }
            }
            return(degree);
        }
コード例 #6
0
 public virtual void AddRelationship(long relId, int typeId, RelationshipDirection direction)
 {
     if (!HasAddedRelationships())
     {
         _relationshipsAdded = new RelationshipChangesForNode(DiffStrategy.ADD);
     }
     _relationshipsAdded.addRelationship(relId, typeId, direction);
 }
コード例 #7
0
 public RelationshipPatternExpression(
     [NotNull] RelationshipDirection direction,
     [NotNull] RelationshipDetailExpression details
     )
 {
     Direction = direction;
     Details   = details;
 }
コード例 #8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.server.rest.repr.ListRepresentation getNodeRelationships(long nodeId, RelationshipDirection direction, java.util.Collection<String> types) throws NodeNotFoundException
        public override ListRepresentation GetNodeRelationships(long nodeId, RelationshipDirection direction, ICollection <string> types)
        {
            using (Transaction transaction = _graph.beginTx())
            {
                ListRepresentation nodeRelationships = base.GetNodeRelationships(nodeId, direction, types);
                transaction.Success();
                return(nodeRelationships);
            }
        }
コード例 #9
0
        /// <summary>
        /// Gets all the relationships regardless of submodel
        /// </summary>
        /// <param name="direction"></param>
        /// <param name="includeInherited"></param>
        /// <returns></returns>
        public IEnumerable <Relationship> GetRelationships(RelationshipDirection direction, bool includeInherited)
        {
            if (Model == null)
            {
                throw new InvalidOperationException("Cannot get relationship of nodes when model is not set.");
            }

            return(Model.GetRelationships(this, includeInherited));
        }
コード例 #10
0
 public RestTraversal RelationShips(RelationshipDirection relationShipDirection, string relationShipType)
 {
     if (_relationShipFilter == null)
     {
         _relationShipFilter = new RelationShipFilter();
         this.Add(_relationShipFilter);
     }
     _relationShipFilter.Add(new RelationFilter(relationShipDirection, relationShipType));
     return(this);
 }
コード例 #11
0
ファイル: RestTraversal.cs プロジェクト: sonyarouje/Neo4jD
 public RestTraversal RelationShips(RelationshipDirection relationShipDirection, string relationShipType)
 {
     if (_relationShipFilter == null)
     {
         _relationShipFilter = new RelationShipFilter();
         this.Add(_relationShipFilter);
     }
     _relationShipFilter.Add(new RelationFilter(relationShipDirection,relationShipType));
     return this;
 }
コード例 #12
0
        public void DetermineRelationshipDirectionShouldReturnExplicitDirection(RelationshipDirection direction)
        {
            // Arrange
            var relationship = new TestRelationship(new NodeReference(0))
            {
                Direction = direction
            };
            var calculatedDirection = Relationship.DetermineRelationshipDirection(null, relationship);

            Assert.AreEqual(direction, calculatedDirection);
        }
コード例 #13
0
 public override int AugmentDegree(RelationshipDirection direction, int degree, int typeId)
 {
     if (HasAddedRelationships())
     {
         degree = _relationshipsAdded.augmentDegree(direction, degree, typeId);
     }
     if (HasRemovedRelationships())
     {
         degree = _relationshipsRemoved.augmentDegree(direction, degree, typeId);
     }
     return(degree);
 }
コード例 #14
0
        public virtual void AddRelationship(long relId, int typeId, RelationshipDirection direction)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.map.primitive.MutableIntObjectMap<org.eclipse.collections.api.set.primitive.MutableLongSet> relTypeToRelsMap = getTypeToRelMapForDirection(direction);
            MutableIntObjectMap <MutableLongSet> relTypeToRelsMap = GetTypeToRelMapForDirection(direction);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.set.primitive.MutableLongSet rels = relTypeToRelsMap.getIfAbsentPut(typeId, org.eclipse.collections.impl.set.mutable.primitive.LongHashSet::new);
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
            MutableLongSet rels = relTypeToRelsMap.getIfAbsentPut(typeId, LongHashSet::new);

            rels.add(relId);
        }
コード例 #15
0
ファイル: Modeller.cs プロジェクト: j-prox/blueprint41
        /// <summary>
        /// Gets all the relationships of the Entity regardless of submodel
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="includeInherited"></param>
        /// <returns></returns>
        public IEnumerable <Relationship> GetRelationships(Entity entity, RelationshipDirection direction = RelationshipDirection.Both, bool includeInherited = false)
        {
            Dictionary <string, Relationship> relationships = new Dictionary <string, Relationship>();
            Entity current = entity;

            Func <Relationship, bool> func;

            switch (direction)
            {
            case RelationshipDirection.Out:
                func = RelationshipOut;
                break;

            case RelationshipDirection.Both:
                func = RelationshipBoth;
                break;

            case RelationshipDirection.In:
            default:
                func = RelationshipIn;
                break;
            }

            do
            {
                foreach (Relationship rel in Relationships.Relationship.Where(func).ToList())
                {
                    if (relationships.ContainsKey(rel.Name) == false)
                    {
                        relationships.Add(rel.Name, rel);
                    }
                }

                current = current.ParentEntity;
            } while (current != null && includeInherited);

            return(relationships.Select(x => x.Value).ToList());

            bool RelationshipIn(Relationship item)
            {
                return(item.Source.Label == current.Label);
            }

            bool RelationshipOut(Relationship item)
            {
                return(item.Target?.Label == current.Label);
            }

            bool RelationshipBoth(Relationship item)
            {
                return(item.Source.Label == current.Label || item.Target?.Label == current.Label);
            }
        }
コード例 #16
0
 private RelationshipDetails(
     RelationshipDirection relationshipDirection,
     SymbolicName?symbolicName,
     RelationshipTypes?relationshipTypes,
     RelationshipLength?length,
     Properties?properties)
 {
     Direction    = relationshipDirection;
     SymbolicName = symbolicName;
     Types        = relationshipTypes;
     Length       = length;
     Properties   = properties;
 }
コード例 #17
0
 public virtual void RemoveRelationship(long relId, int typeId, RelationshipDirection direction)
 {
     if (HasAddedRelationships())
     {
         if (_relationshipsAdded.removeRelationship(relId, typeId, direction))
         {
             // This was a rel that was added in this tx, no need to add it to the remove list, instead we just
             // remove it from added relationships.
             return;
         }
     }
     if (!HasRemovedRelationships())
     {
         _relationshipsRemoved = new RelationshipChangesForNode(DiffStrategy.REMOVE);
     }
     _relationshipsRemoved.addRelationship(relId, typeId, direction);
 }
コード例 #18
0
        public virtual LongIterator getRelationships(RelationshipDirection direction, int type)
        {
            switch (direction)
            {
            case RelationshipDirection.INCOMING:
                return(_incoming != null?PrimitiveIdsByType(_incoming, type) : ImmutableEmptyLongIterator.INSTANCE);

            case RelationshipDirection.OUTGOING:
                return(_outgoing != null?PrimitiveIdsByType(_outgoing, type) : ImmutableEmptyLongIterator.INSTANCE);

            case RelationshipDirection.LOOP:
                return(_loops != null?PrimitiveIdsByType(_loops, type) : ImmutableEmptyLongIterator.INSTANCE);

            default:
                throw new System.ArgumentException("Unknown direction: " + direction);
            }
        }
コード例 #19
0
        public virtual bool RemoveRelationship(long relId, int typeId, RelationshipDirection direction)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.map.primitive.MutableIntObjectMap<org.eclipse.collections.api.set.primitive.MutableLongSet> relTypeToRelsMap = getTypeToRelMapForDirection(direction);
            MutableIntObjectMap <MutableLongSet> relTypeToRelsMap = GetTypeToRelMapForDirection(direction);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.set.primitive.MutableLongSet rels = relTypeToRelsMap.get(typeId);
            MutableLongSet rels = relTypeToRelsMap.get(typeId);

            if (rels != null && rels.remove(relId))
            {
                if (rels.Empty)
                {
                    relTypeToRelsMap.remove(typeId);
                }
                return(true);
            }
            return(false);
        }
コード例 #20
0
        public static PropertyDeclarationSyntax AddNeo4JRelationshipAttribute(
            this PropertyDeclarationSyntax methodSyntax,
            string name,
            RelationshipDirection direction)
        {
            AttributeSyntax attribute =
                Attribute(IdentifierName(Global(Neo4JRelationshipAttribute)))
                .AddArgumentListArguments(
                    AttributeArgument(
                        LiteralExpression(
                            SyntaxKind.NumericLiteralExpression,
                            Literal(name)))
                    .WithNameColon(
                        NameColon(IdentifierName(nameof(name)))),
                    AttributeArgument(
                        MemberAccessExpression(
                            SyntaxKind.SimpleMemberAccessExpression,
                            IdentifierName(Global(Neo4JRelationshipDirection)),
                            IdentifierName(MapDirection(direction))))
                    .WithNameColon(
                        NameColon(IdentifierName(nameof(direction)))));

            return(methodSyntax.AddAttributeLists(AttributeList(SingletonSeparatedList(attribute))));
        }
コード例 #21
0
 public static string GetSymbol(this RelationshipDirection val)
 {
     return(GetEnumDesc(val));
 }
コード例 #22
0
ファイル: RelationFilter.cs プロジェクト: sonyarouje/Neo4jD
 public RelationFilter(RelationshipDirection relationShipDirection, string relationShipTypeFilter)
 {
     _direction=relationShipDirection;
     _relationShipTypeFilter = relationShipTypeFilter;
 }
コード例 #23
0
        public static HttpStatusCode GetRelationshipsOnNode(string dbUrl, long nodeId, RelationshipDirection direction, IEnumerable <string> relationships, out string response)
        {
            if (direction == null)
            {
                direction = RelationshipDirection.All;
            }

            if (relationships == null || !relationships.Any())
            {
                return
                    (HttpRest.Get(
                         string.Concat(Connection.GetServiceRoot(dbUrl).Node, "/", nodeId.ToString(), "/relationships/", direction.ToString()),
                         out response));
            }

            return
                (HttpRest.Get(
                     string.Concat(Connection.GetServiceRoot(dbUrl).Node, "/", nodeId.ToString(), "/relationships/", direction.ToString(), "/",
                                   string.Join("&", relationships)), out response));
        }
コード例 #24
0
ファイル: client-impl.cs プロジェクト: emrul/CmisSync
        public IItemEnumerable<IRelationship> GetRelationships(IObjectId objectId, bool includeSubRelationshipTypes,
                RelationshipDirection? relationshipDirection, IObjectType type, IOperationContext context)
        {
            if (objectId == null || objectId.Id == null)
            {
                throw new ArgumentException("Invalid object id!");
            }

            string id = objectId.Id;
            string typeId = (type == null ? null : type.Id);
            IRelationshipService service = Binding.GetRelationshipService();
            IOperationContext ctxt = new OperationContext(context);

            PageFetcher<IRelationship>.FetchPage fetchPageDelegate = delegate(long maxNumItems, long skipCount)
            {
                // fetch the relationships
                IObjectList relList = service.GetObjectRelationships(RepositoryId, id, includeSubRelationshipTypes, relationshipDirection,
                    typeId, ctxt.FilterString, ctxt.IncludeAllowableActions, maxNumItems, skipCount, null);

                // convert relationship objects
                IList<IRelationship> page = new List<IRelationship>();
                if (relList.Objects != null)
                {
                    foreach (IObjectData rod in relList.Objects)
                    {
                        IRelationship relationship = GetObject(CreateObjectId(rod.Id), ctxt) as IRelationship;
                        if (relationship == null)
                        {
                            throw new CmisRuntimeException("Repository returned an object that is not a relationship!");
                        }

                        page.Add(relationship);
                    }
                }

                return new PageFetcher<IRelationship>.Page<IRelationship>(page, relList.NumItems, relList.HasMoreItems);
            };

            return new CollectionEnumerable<IRelationship>(new PageFetcher<IRelationship>(DefaultContext.MaxItemsPerPage, fetchPageDelegate));
        }
コード例 #25
0
ファイル: RelationFilter.cs プロジェクト: khoadd/Neo4jD
 public RelationFilter(RelationshipDirection relationShipDirection, string relationShipTypeFilter)
 {
     _direction = relationShipDirection;
     _relationShipTypeFilter = relationShipTypeFilter;
 }
コード例 #26
0
 public NeoRelationship(string type, RelationshipDirection direction)
 {
     Type      = type;
     Direction = direction;
 }
コード例 #27
0
 private static string MapDirection(RelationshipDirection direction) =>
 direction switch
 {
コード例 #28
0
 public RelatedResource(EntityRef relationshipType, RelationshipDirection direction)
 {
     RelationshipTypeId    = relationshipType;
     RelationshipDirection = direction;
 }
コード例 #29
0
ファイル: webservices.cs プロジェクト: emrul/CmisSync
        public IObjectList GetObjectRelationships(string repositoryId, string objectId, bool? includeSubRelationshipTypes,
            RelationshipDirection? relationshipDirection, string typeId, string filter, bool? includeAllowableActions,
            long? maxItems, long? skipCount, IExtensionsData extension)
        {
            RelationshipServicePortClient port = Provider.GetRelationshipService();

            try
            {
                return Converter.Convert(port.getObjectRelationships(repositoryId, objectId,
                    includeSubRelationshipTypes == null ? true : (bool)includeSubRelationshipTypes,
                    (enumRelationshipDirection?)CmisValue.CmisToSerializerEnum(relationshipDirection), typeId, filter, includeAllowableActions,
                    maxItems.ToString(), skipCount.ToString(), Converter.ConvertExtension(extension)));
            }
            catch (FaultException<cmisFaultType> fe)
            {
                throw ConvertException(fe);
            }
            catch (Exception e)
            {
                throw new CmisRuntimeException("Error: " + e.Message, e);
            }
        }
コード例 #30
0
 public LongIterator getAddedRelationships(RelationshipDirection direction, int relType)
 {
     return(ImmutableEmptyLongIterator.INSTANCE);
 }
コード例 #31
0
        /// <summary>
        /// Applies the related resource condition to the structured query.
        /// </summary>
        /// <param name="structuredQuery">The structured query.</param>
        /// <param name="relationshipSettings">The relationship settings.</param>
        private static void ApplyRelatedResourceCondition(StructuredQuery structuredQuery, ReportRelationshipSettings relationshipSettings, QuerySettings querySettings)
        {
            RelationshipDirection direction = relationshipSettings.Direction == ReportRelationshipSettings.ReportRelationshipDirection.Forward ? RelationshipDirection.Forward : RelationshipDirection.Reverse;

            // Find existing equivalent relation.
            RelatedResource relation = (
                from related in structuredQuery.RootEntity.RelatedEntities
                let rr = related as RelatedResource
                         where rr != null && rr.RelationshipTypeId.Id == relationshipSettings.RelationshipId && rr.RelationshipDirection == direction && rr.Recursive == RecursionMode.None
                         select rr).FirstOrDefault( );

            if (relation == null)
            {
                // Add if not already found
                relation = new RelatedResource
                {
                    NodeId = Guid.NewGuid( ),
                    RelationshipDirection = direction,
                    RelationshipTypeId    = new Model.EntityRef(relationshipSettings.RelationshipId),
                    ResourceMustExist     = true,
                };
                List <Entity> relatedEntities = new List <Entity>( );
                if (structuredQuery.RootEntity.RelatedEntities != null)
                {
                    relatedEntities.AddRange(structuredQuery.RootEntity.RelatedEntities);
                }
                relatedEntities.Add(relation);
                structuredQuery.RootEntity.RelatedEntities = relatedEntities;
            }

            // Add in the unsaved changes prior to the SQL generation and report run
            if (relationshipSettings.EntityId != 0 ||
                (relationshipSettings.IncludedEntityIds != null && relationshipSettings.IncludedEntityIds.Count > 0) ||
                (relationshipSettings.ExcludedEntityIds != null && relationshipSettings.ExcludedEntityIds.Count > 0))
            {
                relation.FauxRelationships = new FauxRelationships
                {
                    HasTargetResource         = relationshipSettings.EntityId != 0,
                    IsTargetResourceTemporary = Model.EntityId.IsTemporary(relationshipSettings.EntityId),
                    HasIncludedResources      = relationshipSettings.IncludedEntityIds != null && relationshipSettings.IncludedEntityIds.Count > 0,
                    HasExcludedResources      = relationshipSettings.ExcludedEntityIds != null && relationshipSettings.ExcludedEntityIds.Count > 0
                };
            }

            // Set execute-time information into query settings object
            querySettings.TargetResource   = relationshipSettings.EntityId;
            querySettings.IncludeResources = relationshipSettings.IncludedEntityIds?.Distinct();
            querySettings.ExcludeResources = relationshipSettings.ExcludedEntityIds?.Distinct();

            // In the event that the entity that is passed into us has yet to be actually created then it will be 0 and should not be used in the query condition.
            if (relationshipSettings.EntityId != 0)
            {
                var condition = new QueryCondition
                {
                    Expression = new IdExpression {
                        NodeId = relation.NodeId
                    },
                    Operator  = ConditionType.Equal,
                    Parameter = "@targetResource"
                };
                List <QueryCondition> queryConditions = new List <QueryCondition>( );
                if (structuredQuery.Conditions != null)
                {
                    queryConditions.AddRange(structuredQuery.Conditions);
                }
                queryConditions.Add(condition);
                structuredQuery.Conditions = queryConditions;
            }
        }
コード例 #32
0
 public virtual LongIterator getAddedRelationships(RelationshipDirection direction, int relType)
 {
     return(_relationshipsAdded != null?_relationshipsAdded.getRelationships(direction, relType) : ImmutableEmptyLongIterator.INSTANCE);
 }
コード例 #33
0
ファイル: DataService.cs プロジェクト: yog-it/Dnn.Platform
 /// <inheritdoc/>
 public IDataReader GetUserRelationship(int userId, int relatedUserId, int relationshipId, RelationshipDirection relationshipDirection)
 {
     return(this._provider.ExecuteReader("GetUserRelationshipsByMultipleIDs", userId, relatedUserId, relationshipId, relationshipDirection));
 }
コード例 #34
0
 public int augmentDegree(RelationshipDirection direction, int degree, int typeId)
 {
     return(degree);
 }