Ejemplo n.º 1
0
        public bool LoadRelationship(SoapNodeManager nodeManager)
        {
            Metadata.Clear();
            Proxy.INodeManager nodeSetManager = Nodes;
            nodeSetManager.Clear();

            foreach (KeyValuePair <ServerObjects.MetadataContext, ServerObjects.Metadata> metadataPair in ServiceRelationship.Metadata)
            {
                if (metadataPair.Value.NodeUid.HasValue)
                {
                    Proxy.INode node = nodeManager.FindNode(metadataPair.Value.NodeUid.Value);
                    Metadata.Load(metadataPair.Value, node);
                }
                else if (metadataPair.Value.RelationshipUid.HasValue)
                {
                    Metadata.Load(metadataPair.Value, null);
                }
            }

            foreach (KeyValuePair <Guid, Guid> relationship in ServiceRelationship.Nodes)
            {
                Guid descriptorTypeId = relationship.Key;
                Guid nodeId           = relationship.Value;

                // TODO: There needs to be a proper check for the ConnectionType that will perform an appropriate operation if none exists.
                if (MapManager.ConnectionTypes.ContainsKey(descriptorTypeId))
                {
                    Proxy.INode          node;
                    Proxy.ConnectionType connectionType = MapManager.ConnectionTypes[descriptorTypeId];

                    node = nodeManager.FindNode(nodeId);

                    Proxy.ConnectionSet connectionSet = Proxy.ConnectionSetFactory.Instance.GetConnection(node, this, connectionType);

                    if (node.Status != Proxy.LoadState.None)
                    {
                        Proxy.IRelationshipManager relationshipSetManager = node.Relationships;

                        relationshipSetManager.Load(connectionSet);
                    }

                    nodeSetManager.Load(connectionSet);
                }
            }

            Status = Proxy.LoadState.Full;

            ProcessDelayedActions();

            return(true);
        }
Ejemplo n.º 2
0
        public bool LoadNode(SoapRelationshipManager relationshipManager)
        {
            switch (Status)
            {
            case Proxy.LoadState.None:
                return(false);

            case TransactionalNodeService.Proxy.LoadState.Partial:
            {
                Proxy.IRelationshipManager relationships = Relationships;
                relationships.Clear();

                break;
            }

            case TransactionalNodeService.Proxy.LoadState.Full:
                break;

            default:
                return(false);
            }

            Metadata.Clear();

            foreach (KeyValuePair <ServerObjects.MetadataContext, ServerObjects.Metadata> metadataPair in ServiceNode.Metadata)
            {
                if (metadataPair.Value.RelationshipUid.HasValue && metadataPair.Value.RelationshipUid != Guid.Empty)
                {
                    if (relationshipManager.ProxyRelationships.ContainsKey(metadataPair.Value.RelationshipUid.Value))
                    {
                        Proxy.IRelationship relationship = relationshipManager.ProxyRelationships[metadataPair.Value.RelationshipUid.Value];
                        Metadata.Load(metadataPair.Value, relationship);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (metadataPair.Value.NodeUid.HasValue && metadataPair.Value.NodeUid != Guid.Empty)
                {
                    Metadata.Load(metadataPair.Value, null);
                }
            }

            Status = Proxy.LoadState.Full;

            ProcessDelayedActions();

            return(true);
        }
        TransactionFramework.InProcessTransactionResponse IBatchOperation.BuildTransactionChain(ref TransactionFramework.TransactionChain chain)
        {
            /// TODO: The following really needs to be refactored.
            var response = new TransactionFramework.InProcessTransactionResponse();

            var mapRelationships = Node.Relationships.FindRelationships(FromConnectionType, MapContainerRelationshipType);

            var mapsToRemove = new List <Proxy.IRelationship>();

            foreach (Proxy.IRelationship relationship in mapRelationships)
            {
                var maps = relationship.Nodes.FindNodes(ToConnectionType, MapNodeType);

                if (maps != null)
                {
                    foreach (Proxy.INode mapNode in maps)
                    {
                        if (mapNode.Id == Context.Id)
                        {
                            mapsToRemove.Add(relationship);
                            break;
                        }
                    }
                }
            }

            foreach (Proxy.IRelationship relationship in mapsToRemove)
            {
                relationship.Delete(ref chain);
                /// TODO: Need to move the following operation back into the relationship class.
                Proxy.IRelationshipManager relationships = Node.Relationships;
                relationships.Remove(relationship);
                response.Relationships.Add(relationship);
            }

            IEnumerable <KeyValuePair <Proxy.ConnectionType, Proxy.IRelationship> > transclusionRelationships = Node.Relationships.FindRelationships(TransclusionRelationshipType);

            List <Proxy.IRelationship> transclusionRelationshipsToRemove = new List <Proxy.IRelationship>();

            foreach (KeyValuePair <Proxy.ConnectionType, Proxy.IRelationship> relationshipPair in transclusionRelationships)
            {
                IEnumerable <Proxy.INode> maps = relationshipPair.Value.Nodes.FindNodes(TransclusionMapConnectionType, MapNodeType);

                if (maps != null)
                {
                    foreach (Proxy.INode mapNode in maps)
                    {
                        if (mapNode.Id == Context.Id)
                        {
                            transclusionRelationshipsToRemove.Add(relationshipPair.Value);
                            break;
                        }
                    }
                }
            }

            foreach (Proxy.IRelationship relationship in transclusionRelationshipsToRemove)
            {
                relationship.Delete(ref chain);
                /// TODO: Need to move the following operation back into the relationship class.
                Proxy.IRelationshipManager relationships = Node.Relationships;
                relationships.Remove(relationship);
                response.Relationships.Add(relationship);
            }
            return(response);
        }