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); }
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); }
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); }
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); }
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); }
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); } }