TransactionFramework.InProcessTransactionResponse IBatchOperation.BuildTransactionChain(ref TransactionFramework.TransactionChain chain)
        {
            var response = new TransactionFramework.InProcessTransactionResponse();

            if (NewMap.Id != OriginalMap.Id)
            {
                Proxy.IRelationship newTransclusionRelationship = MapManager.CreateRelationship(NewMap.DomainId, NewMap.RootMapId.Value, MapContainerRelationshipType, string.Empty, ref chain);

                newTransclusionRelationship.ConnectNode(FromConnectionType, OriginalNode, ref chain);
                newTransclusionRelationship.ConnectNode(ToConnectionType, NewMap, ref chain);

                OriginalNode.Metadata.Add(newTransclusionRelationship, FromConnectionType, "XPosition", Location.X.ToString(), ref chain);
                OriginalNode.Metadata.Add(newTransclusionRelationship, FromConnectionType, "YPosition", Location.Y.ToString(), ref chain);

                IEnumerable <KeyValuePair <Proxy.ConnectionType, Proxy.IRelationship> > relationships = OriginalNode.Relationships.FindRelationships(MapManager.RelationshipTypes["FromToRelationship"]);

                foreach (KeyValuePair <Proxy.ConnectionType, Proxy.IRelationship> relationshipPair in relationships)
                {
                    Proxy.IRelationship relationshipToUpdate = relationshipPair.Value;
                    relationshipToUpdate.Update(MapManager.RelationshipTypes["TransclusionFromToRelationship"], ref chain);
                    relationshipToUpdate.ConnectNode(MapManager.ConnectionTypes["TransclusionMap"], OriginalMap, ref chain);
                }


                response.Relationships.Add(newTransclusionRelationship);
            }
            return(response);
        }
        TransactionFramework.InProcessTransactionResponse IBatchOperation.BuildTransactionChain(ref TransactionFramework.TransactionChain chain)
        {
            var response = new TransactionFramework.InProcessTransactionResponse();

            Proxy.IRelationship newTransclusionRelationship = MapManager.CreateRelationship(From.DomainId, From.RootMapId.Value, TransclusionRelationshipType, string.Empty, ref chain);
            var relationships = Context.Relationships.FindRelationships(TransclusionRelationshipType);

            foreach (var keyValuePair in relationships)
            {
                var from = keyValuePair.Value.Nodes.FindNodes(FromConnectionType);
                var to   = keyValuePair.Value.Nodes.FindNodes(ToConnectionType);

                if (from == null || to == null || From == null || To == null)
                {
                    continue;
                }

                ///TODO Chris: following lines causing Bug 71
                if (from.Contains(From) && to.Contains(To))
                {
                    return(response);
                }
            }

            newTransclusionRelationship.ConnectNode(TransclusionMapConnectionType, Context, ref chain);
            newTransclusionRelationship.ConnectNode(FromConnectionType, From, ref chain);
            newTransclusionRelationship.ConnectNode(ToConnectionType, To, ref chain);



            response.Relationships.Add(newTransclusionRelationship);
            return(response);
        }
        public void ExecuteOperation()
        {
            var chain = new TransactionFramework.TransactionChain();

            _inProcessRelationship = MapManager.CreateRelationship(From.DomainId, From.RootMapId.Value, FromToRelationshipType, string.Empty, ref chain);

            _inProcessRelationship.ConnectNode(FromConnectionType, From, ref chain);
            _inProcessRelationship.ConnectNode(ToConnectionType, To, ref chain);
            Response = new TransactionFramework.InProcessTransactionResponse();
            Response.Relationships.Add(_inProcessRelationship);
            chain.TransactionCompleted += ChainOnTransactionCompleted;
            MapManager.ExecuteTransaction(chain);
        }
        public void ExecuteOperation()
        {
            var chain = new TransactionFramework.TransactionChain();

            _inProcessRelationship = MapManager.CreateRelationship(From.DomainId, From.RootMapId.Value, FromToRelationshipType, string.Empty, ref chain);

            _inProcessRelationship.ConnectNode(FromConnectionType, From, ref chain);
            _inProcessRelationship.ConnectNode(ToConnectionType, To, ref chain);
            Response = new TransactionFramework.InProcessTransactionResponse();
            Response.Relationships.Add(_inProcessRelationship);
            chain.TransactionCompleted += ChainOnTransactionCompleted;
            MapManager.ExecuteTransaction(chain);
        }
        public Proxy.IMetadataSet Add(Proxy.IRelationship relationship, Proxy.ConnectionType connectionType, string name, string value, ref TransactionFramework.TransactionChain chain)
        {
            Proxy.IMetadataSet newMetadataSet = ParentNode.Proxy.Metadata.Add(relationship, connectionType, name, value, ref chain);

            if (!Metadata.ContainsKey(name))
            {
                IMetadata newMetadata = ParentNode.ViewModelMetadataFactory.CreateMetadata(newMetadataSet);

                Add(name, newMetadata);
                return(newMetadata.MetadataSet);
            }
            return(newMetadataSet);
        }
Beispiel #6
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);
        }
Beispiel #7
0
        public Proxy.IRelationship CreateRelationship(Guid domainId, Guid rootMapId, Proxy.RelationshipType relationshipType, string originalId, ref TransactionFramework.TransactionChain chain)
        {
            TransactionFramework.AddRelationshipTransactionLink createRelationshipTransaction = new TransactionFramework.AddRelationshipTransactionLink();
            createRelationshipTransaction.MapManager       = this;
            createRelationshipTransaction.DomainId         = domainId;
            createRelationshipTransaction.RootMapId        = rootMapId;
            createRelationshipTransaction.RelationshipType = relationshipType;
            createRelationshipTransaction.OriginalId       = originalId;

            chain.AddTransaction(createRelationshipTransaction);

            Proxy.IRelationship relationship = createRelationshipTransaction.CreateInProcessObjects();

            return(relationship);
        }
Beispiel #8
0
            private void BuildRootViewRelationships(ref Queue <TransactionFramework.TransactionChain> transactionQueue)
            {
                TransactionFramework.TransactionChain chain = new TransactionFramework.TransactionChain();

                foreach (CompendiumViewRelationship viewRelationship in RootViews)
                {
                    Proxy.INode proxyNode = ProxyNodes[viewRelationship.FromNode.Id];

                    Proxy.IRelationship newRelationship = MapManager.CreateRelationship(Map.DomainId, Map.RootMapId.Value, MapManager.RelationshipTypes["MapContainerRelationship"], string.Empty, ref chain);
                    newRelationship.ConnectNode(MapManager.ConnectionTypes["To"], Map, ref chain);
                    newRelationship.ConnectNode(MapManager.ConnectionTypes["From"], proxyNode, ref chain);

                    proxyNode.Metadata.Add(newRelationship, MapManager.ConnectionTypes["From"], "XPosition", viewRelationship.XPosition.ToString(), ref chain);
                    proxyNode.Metadata.Add(newRelationship, MapManager.ConnectionTypes["From"], "YPosition", viewRelationship.YPosition.ToString(), ref chain);

                    //MapManager.ExecuteTransaction(chain);
                }

                transactionQueue.Enqueue(chain);
            }
Beispiel #9
0
        public void LoadRelationship(TNSProxy.IRelationship relationship)
        {
            Proxy = relationship;

            if (relationship.Status == TNSProxy.LoadState.Full)
            {
                IEnumerable <TNSProxy.NodeTuple> nodes = relationship.Nodes.FindNodes();

                foreach (TNSProxy.NodeTuple nodeTuple in relationship.Nodes.FindNodes())
                {
                    if (nodeTuple.ConnectionType.Name == "To")
                    {
                        To = nodeTuple.Node.ClientId;
                    }
                    else if (nodeTuple.ConnectionType.Name == "From")
                    {
                        From = nodeTuple.Node.ClientId;
                    }
                }
            }
        }
 private Proxy.NodeSet GetNodesFromRelationship(Proxy.IRelationship relationship)
 {
     return(relationship.Nodes);
 }
        public void ExecuteOperation()
        {
            Proxy.NodeType nodeTypeToChangeTo;

            switch (ChangedTo)
            {
            case ViewModel.ChangeNodeTypeEnum.Question:
                nodeTypeToChangeTo = MapManager.NodeTypes["CompendiumQuestionNode"];
                break;

            case ViewModel.ChangeNodeTypeEnum.Idea:
                nodeTypeToChangeTo = MapManager.NodeTypes["CompendiumIdeaNode"];
                break;

            case ViewModel.ChangeNodeTypeEnum.Pro:
                nodeTypeToChangeTo = MapManager.NodeTypes["CompendiumProNode"];
                break;

            case ViewModel.ChangeNodeTypeEnum.Con:
                nodeTypeToChangeTo = MapManager.NodeTypes["CompendiumConNode"];
                break;

            case ViewModel.ChangeNodeTypeEnum.Map:
                nodeTypeToChangeTo = MapManager.NodeTypes["CompendiumMapNode"];
                break;

            case ViewModel.ChangeNodeTypeEnum.Note:
                nodeTypeToChangeTo = MapManager.NodeTypes["CompendiumNoteNode"];
                break;

            case ViewModel.ChangeNodeTypeEnum.Decision:
                nodeTypeToChangeTo = MapManager.NodeTypes["CompendiumDecisionNode"];
                break;

            default:
                return;
            }

            TransactionFramework.TransactionChain chain = new TransactionFramework.TransactionChain();
            chain.TransactionCompleted += ChainOnTransactionCompleted;
            if (Node.Proxy.NodeType == MapManager.NodeTypes["CompendiumMapNode"])
            {
                IEnumerable <Proxy.IRelationship> relationships = Node.Proxy.Relationships.FindRelationships(MapManager.ConnectionTypes["To"], MapManager.RelationshipTypes["MapContainerRelationship"]);

                foreach (Proxy.IRelationship relationship in relationships)
                {
                    relationship.ConnectNode(MapManager.ConnectionTypes["To"], Context, ref chain);

                    IEnumerable <Proxy.INode> childNodes = relationship.Nodes.FindNodes(MapManager.ConnectionTypes["From"]);

                    foreach (Proxy.INode childNode in childNodes)
                    {
                        IEnumerable <KeyValuePair <Proxy.ConnectionType, Proxy.IRelationship> > transclusionRelationshipConnections = childNode.Relationships.FindRelationships(MapManager.RelationshipTypes["TransclusionFromToRelationship"]);

                        foreach (KeyValuePair <Proxy.ConnectionType, Proxy.IRelationship> transclusionRelationshipConnection in transclusionRelationshipConnections)
                        {
                            Proxy.IRelationship transclusionRelationship = transclusionRelationshipConnection.Value;

                            IEnumerable <Proxy.INode> transclusionMapNodes = transclusionRelationship.Nodes.FindNodes(MapManager.ConnectionTypes["TransclusionMap"]);

                            foreach (Proxy.INode transclusionMapNode in transclusionMapNodes)
                            {
                                if (transclusionMapNode.Id == Node.Proxy.Id)
                                {
                                    transclusionRelationship.ConnectNode(MapManager.ConnectionTypes["TransclusionMap"], Context, ref chain);

                                    break;
                                }
                            }
                        }
                    }
                }
            }

            Node.Proxy.Update(nodeTypeToChangeTo, ref chain);

            MapManager.ExecuteTransaction(chain);
        }
Beispiel #12
0
        public void LoadNode(TNSProxy.IRelationship relationship, TNSProxy.INode node)
        {
            Proxy = node;
            if (node.Status == TNSProxy.LoadState.Full)
            {
                /// Check that there isn't more than one MapContainerRelationship. If there is then this node is transcluded.
                IEnumerable <TNSProxy.IRelationship> mapContainerRelationships = node.Relationships.FindRelationships(MapManager.ConnectionTypes["From"], MapManager.RelationshipTypes["MapContainerRelationship"]);
                NumTranclusions = mapContainerRelationships.Count(rel => rel.MapManager.RelationshipFactory.FindRelationship(rel.Id) != null);
                IsTranscluded   = (NumTranclusions > 1); //BUG: value changes based on the current view, possibly incorrect as the node is either transcluded or not transcluded regardless of the view

                TNSProxy.NodeMetadataCollection metadata = node.Metadata;

                string xPositionAsString = "0";
                string yPositionAsString = "0";

                if (metadata.FindMetadata(relationship, "XPosition") != null)
                {
                    xPositionAsString = metadata.FindMetadata(relationship, "XPosition").Value;
                }

                if (metadata.FindMetadata(relationship, "YPosition") != null)
                {
                    yPositionAsString = metadata.FindMetadata(relationship, "YPosition").Value;
                }

                if (metadata.FindMetadata(relationship, "CollapseState") != null)
                {
                    _viewerCollapseState = (CollapseState)Enum.Parse(typeof(CollapseState), metadata.FindMetadata(relationship, "CollapseState").Value, true);
                }
                else
                {
                    _viewerCollapseState = CollapseState.None;
                }

                if (metadata.FindMetadata(relationship, "Visibility") != null)
                {
                    _viewerVisibility = metadata.FindMetadata(relationship, "Visibility").Value.Equals("visible", StringComparison.OrdinalIgnoreCase)
                        ? Visibility.Visible
                        : Visibility.Collapsed;
                }
                else
                {
                    _viewerVisibility = Visibility.Visible;
                }

                if (metadata.FindMetadata(relationship, "AuthorCollapseState") != null)
                {
                    _authorCollapseState = (CollapseState)Enum.Parse(typeof(CollapseState), metadata.FindMetadata(relationship, "AuthorCollapseState").Value, true);
                }
                else
                {
                    _authorCollapseState = CollapseState.None;
                }

                if (metadata.FindMetadata(relationship, "AuthorVisibility") != null)
                {
                    _authorVisibility = metadata.FindMetadata(relationship, "AuthorVisibility").Value.Equals("visible", StringComparison.OrdinalIgnoreCase)
                        ? Visibility.Visible
                        : Visibility.Collapsed;
                }
                else
                {
                    _authorVisibility = Visibility.Visible;
                }

                if (!string.IsNullOrEmpty(xPositionAsString) && !string.IsNullOrEmpty(yPositionAsString))
                {
                    double xPosition;
                    double yPosition;

                    if (double.TryParse(xPositionAsString, out xPosition) && double.TryParse(yPositionAsString, out yPosition))
                    {
                        _location = new Point(xPosition, yPosition);
                    }
                }

                IDictionary <string, TNSProxy.IMetadataSet> nodeMetadata = metadata.FindMetadata(null, (TNSProxy.ConnectionType)null);
                foreach (TNSProxy.IMetadataSet metadataSet in nodeMetadata.Values)
                {
                    IMetadata viewModelMetadata = ViewModelMetadataFactory.CreateMetadata(metadataSet);
                    viewModelMetadata.PropertyChanged += OnMetadataPropertyChanged;
                    Metadata.Add(viewModelMetadata.Name, viewModelMetadata);
                    NodeProperties.UIMetadata.Add(viewModelMetadata.Name, viewModelMetadata.Value);
                }

                if (!_isMetadataChangeRegistered)
                {
                    Metadata.CollectionChanged += OnCollectionChanged;
                    _isMetadataChangeRegistered = true;
                }
            }
        }
Beispiel #13
0
            private void BuildRelationships(ref Queue <TransactionFramework.TransactionChain> transactionQueue)
            {
                int transactionCounts = 0;

                TransactionFramework.TransactionChain chain = new TransactionFramework.TransactionChain();

                foreach (XmlModel.INode node in Nodes)
                {
                    foreach (XmlModel.IDescriptor descriptor in node.Descriptors)
                    {
                        if (descriptor.DescriptorType == null || descriptor.DescriptorType.Name == "From")
                        {
                            continue;
                        }

                        XmlModel.IRelationship relationship  = descriptor.Relationship;
                        XmlModel.INode         connectedNode = null;

                        foreach (XmlModel.IDescriptor linkedDescriptor in relationship.Descriptors)
                        {
                            if (linkedDescriptor != descriptor)
                            {
                                connectedNode = linkedDescriptor.Node;
                                break;
                            }
                        }

                        if (connectedNode == null)
                        {
                            // This means that there was no connected nodes or there may have been a circular reference.
                            continue;
                        }

                        Proxy.INode proxyNode;

                        if (ProxyNodes.ContainsKey(node.Id))
                        {
                            proxyNode = ProxyNodes[node.Id];
                        }
                        else
                        {
                            continue;
                        }

                        Proxy.INode proxyConnectedNode;

                        if (ProxyNodes.ContainsKey(connectedNode.Id))
                        {
                            proxyConnectedNode = ProxyNodes[connectedNode.Id];
                        }
                        else
                        {
                            continue;
                        }

                        if (proxyNode.NodeType == MapManager.NodeTypes["DomainNode"] || proxyConnectedNode.NodeType == MapManager.NodeTypes["DomainNode"])
                        {
                            continue;
                        }

                        if (transactionCounts >= 150)
                        {
                            transactionQueue.Enqueue(chain);
                            chain             = new TransactionFramework.TransactionChain();
                            transactionCounts = 0;
                        }
                        else
                        {
                            transactionCounts++;
                        }

                        if (relationship is CompendiumLinkRelationship)
                        {
                            CompendiumLinkRelationship linkRelationship = relationship as CompendiumLinkRelationship;

                            if (!linkRelationship.IsTransclusion)
                            {
                                // In this situation the relationship is between two nodes in a map.
                                Proxy.IRelationship newRelationship = MapManager.CreateRelationship(Map.DomainId, Map.RootMapId.Value, MapManager.RelationshipTypes["FromToRelationship"], string.Empty, ref chain);
                                newRelationship.ConnectNode(MapManager.ConnectionTypes["To"], proxyNode, ref chain);
                                newRelationship.ConnectNode(MapManager.ConnectionTypes["From"], proxyConnectedNode, ref chain);
                            }
                            else
                            {
                                Proxy.INode proxyMap = ProxyNodes[linkRelationship.Map.Id];

                                // In this situation the relationship is a transclusion so we'll need to handle it slightly differently.
                                //Proxy.IRelationship newTranscludedNodeRelationship = MapManager.CreateRelationship(Map.DomainId, MapManager.RelationshipTypes["MapContainerRelationship"], string.Empty, ref chain);
                                //newTranscludedNodeRelationship.ConnectNode(MapManager.ConnectionTypes["To"], proxyMap, ref chain);
                                //newTranscludedNodeRelationship.ConnectNode(MapManager.ConnectionTypes["From"], transclusionNode, ref chain);

                                //transclusionNode.Metadata.Add(newTranscludedNodeRelationship, MapManager.ConnectionTypes["From"], "XPosition", transclusionRelationship.XPosition.ToString(), ref chain);
                                //transclusionNode.Metadata.Add(newTranscludedNodeRelationship, MapManager.ConnectionTypes["From"], "YPosition", transclusionRelationship.YPosition.ToString(), ref chain);

                                Proxy.IRelationship newTransclusionRelationship = MapManager.CreateRelationship(Map.DomainId, Map.RootMapId.Value, MapManager.RelationshipTypes["TransclusionFromToRelationship"], string.Empty, ref chain);

                                newTransclusionRelationship.ConnectNode(MapManager.ConnectionTypes["TransclusionMap"], proxyMap, ref chain);
                                newTransclusionRelationship.ConnectNode(MapManager.ConnectionTypes["To"], proxyNode, ref chain);
                                newTransclusionRelationship.ConnectNode(MapManager.ConnectionTypes["From"], proxyConnectedNode, ref chain);
                            }
                        }
                        else if (relationship is CompendiumViewRelationship)
                        {
                            CompendiumViewRelationship viewRelationship = relationship as CompendiumViewRelationship;

                            if (!viewRelationship.IsRootView)
                            {
                                // In this situation the relationship is between a node and a map node.
                                Proxy.IRelationship newRelationship = MapManager.CreateRelationship(Map.DomainId, Map.RootMapId.Value, MapManager.RelationshipTypes["MapContainerRelationship"], string.Empty, ref chain);
                                newRelationship.ConnectNode(MapManager.ConnectionTypes["To"], proxyNode, ref chain);
                                newRelationship.ConnectNode(MapManager.ConnectionTypes["From"], proxyConnectedNode, ref chain);

                                proxyConnectedNode.Metadata.Add(newRelationship, MapManager.ConnectionTypes["From"], "XPosition", viewRelationship.XPosition.ToString(), ref chain);
                                proxyConnectedNode.Metadata.Add(newRelationship, MapManager.ConnectionTypes["From"], "YPosition", viewRelationship.YPosition.ToString(), ref chain);
                            }
                        }
                        else
                        {
                            // In this situation the relationship is of an unknown type so lets just skip it.
                            continue;
                        }
                    }
                    //chains.Enqueue(chain);

                    //MapManager.ExecuteTransaction(chain);
                    ///
                }
                if (chain != null && chain.NumOfTransactions > 0)
                {
                    transactionQueue.Enqueue(chain);
                }
            }