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 CreateTransactions(ref TransactionFramework.TransactionChain chain) { TransactionFramework.DeleteNodeTransactionLink deleteTransaction = null; TransactionFramework.UpdateNodeTransactionLink updateTransaction = null; foreach (DelayedNodeAction action in QueuedActions) { switch (action.Action) { case TransactionalNodeService.Proxy.TransactionActionType.Deleted: deleteTransaction = CreateNodeDeletionTransaction(action); if (deleteTransaction != null) { chain.AddTransaction(deleteTransaction); } return; case TransactionalNodeService.Proxy.TransactionActionType.TypeUpdated: updateTransaction = CreateNodeUpdatedTransaction(action); break; default: break; } } if (updateTransaction != null) { chain.AddTransaction(updateTransaction); } }
private void CommitCollapseState(Node node, CollapseState state, ref TransactionFramework.TransactionChain chain) { var relationships = node.Proxy.Relationships.FindRelationships(FromConnectionType, MapContainerRelationshipType); var isComplete = false; foreach (Proxy.IRelationship relationship in relationships) { var potentialMapNodes = relationship.Nodes.FindNodes(ToConnectionType); foreach (Proxy.INode mapNode in potentialMapNodes) { if (mapNode.Id == Map.Id) { isComplete = true; node.Proxy.Metadata.Add(relationship, FromConnectionType, _collapseStateKey, state.ToString(), ref chain); break; } } if (isComplete) { break; } } }
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; }
private void CommitLocation(Node node, Point location, ref TransactionFramework.TransactionChain chain) { //Replaced properties with Get methods in order to trace which property throws Null reference exception. var relationships = GetRelationships(GetProxy(node)).FindRelationships(FromConnectionType, MapContainerRelationshipType); var isComplete = false; foreach (var relationship in relationships) { var potentialMapNodes = GetNodesFromRelationship(relationship).FindNodes(ToConnectionType); foreach (Proxy.INode mapNode in potentialMapNodes) { if (mapNode.Id == GetMapId()) { isComplete = true; GetMetadataCollection(GetProxy(node)).Add(relationship, FromConnectionType, "XPosition", GetXPosition(location).ToString(), ref chain); GetMetadataCollection(GetProxy(node)).Add(relationship, FromConnectionType, "YPosition", GetYPosition(location).ToString(), ref chain); break; } } if (isComplete) { break; } } }
public override void Delete(ref TransactionFramework.TransactionChain chain) { base.Delete(ref chain); DelayedMetadataAction delayedAction = new DelayedMetadataAction(); delayedAction.Action = TransactionActionType.Deleted; DelayedActions.Enqueue(delayedAction); }
TransactionFramework.InProcessTransactionResponse IBatchOperation.BuildTransactionChain(ref TransactionFramework.TransactionChain chain) { Node.Delete(ref chain); var response = new TransactionFramework.InProcessTransactionResponse(); response.Nodes.Add(Node); return response; }
public override void Update(string name, string value, Proxy.INode node, Proxy.IRelationship relationship, Proxy.ConnectionType connectionType, ref TransactionFramework.TransactionChain chain) { base.Update(name, value, node, relationship, connectionType, ref chain); DelayedMetadataAction delayedAction = new DelayedMetadataAction(); delayedAction.Action = TransactionActionType.Updated; delayedAction.Name = Name; delayedAction.Value = Value; delayedAction.Node = Node; delayedAction.DomainId = Node.DomainId; delayedAction.Relationship = Relationship; delayedAction.ConnectionType = ConnectionType; DelayedActions.Enqueue(delayedAction); }
public void CreateTransactions(ref TransactionFramework.TransactionChain chain) { TransactionFramework.DeleteRelationshipTransactionLink deleteTransaction = null; TransactionFramework.UpdateRelationshipTransactionLink updateTransaction = null; foreach (DelayedRelationshipAction action in QueuedActions) { switch (action.Action) { case TransactionalNodeService.Proxy.TransactionActionType.Deleted: deleteTransaction = CreateRelationshipDeletionTransaction(action); if (deleteTransaction != null) { chain.AddTransaction(deleteTransaction); } return; case TransactionalNodeService.Proxy.TransactionActionType.Updated: updateTransaction = updateTransaction ?? CreateRelationshipUpdatedTransaction(action); updateTransaction.AddNode(action.ConnectionType, action.Node); break; case TransactionalNodeService.Proxy.TransactionActionType.TypeUpdated: updateTransaction = updateTransaction ?? CreateRelationshipUpdatedTransaction(action); updateTransaction.RelationshipType = action.RelationshipType; break; default: break; } } if (updateTransaction != null) { chain.AddTransaction(updateTransaction); } }
public void CreateTransactions(ref TransactionFramework.TransactionChain chain) { foreach (DelayedMetadataAction action in QueuedActions) { switch (action.Action) { case Proxy.TransactionActionType.Deleted: // As this is metadata that hasn't yet been created, we don't need to delete it, we just do nothing with it. return; case Proxy.TransactionActionType.Updated: { TransactionFramework.UpdateMetadataTransactionLink updateMetadataTransaction = CreateMetadataUpdateTransaction(action); if (updateMetadataTransaction != null) { chain.AddTransaction(updateMetadataTransaction); } break; } default: break; } } }
public void ExecuteTransaction(TransactionFramework.TransactionChain transactionChain) { /// TODO: Need to figure why this is happening for the re-alignment code. /// TODO: Probably should add a warning in the debugger to indicate there is a potential performance problem if there are too many chains with empty transactions. if (transactionChain.NumOfTransactions <= 0) { return; } TransactionFramework.ISoapTransactionLinkExecutor executor = transactionChain; if (executor == null) { throw new NotSupportedException("This is not a supported type of link. This link does not implement ISoapTransactionLinkExecutor."); } lock (_executionThreadsLock) { ExecutionThreads.AddTransactionChain(transactionChain); if (_isInProcess) { executor = null; } else { ExecutionThreads.MoveToNextChain(); _isInProcess = true; } } if (MapManagerActivityStatusUpdated != null) { Proxy.MapManagerActivityEventArgs status = new Proxy.MapManagerActivityEventArgs(); status.TransactionsLeft = ExecutionThreads.Count + 1; status.Status = Proxy.ActivityStatusEnum.Busy; MapManagerActivityStatusUpdated.Invoke(this, status); } if (executor != null) { /// TODO: Remove the following TransactionFramework.TransactionChain chain = executor as TransactionFramework.TransactionChain; if (chain != null) { System.Diagnostics.Debug.WriteLine(chain.ChainId); } /// executor.TransactionFailed += OnTransactionFailed; executor.TransactionCompleted += OnTransactionCompleted; executor.ExecuteTransaction(Guid.Empty, ServiceProxy); } }
public IMetadataSet Add(IRelationship relationship, ConnectionType connectionType, string name, string value, ref TransactionFramework.TransactionChain chain) { IMetadataSet metadataSet = null; if (connectionType != null && relationship != null) { foreach (IMetadataSet metadata in Metadata) { if (metadata.Name == name && metadata.Relationship.Id == relationship.Id && metadata.ConnectionType.Id == connectionType.Id) { metadataSet = metadata; break; } } } else if (connectionType == null && relationship != null) { foreach (IMetadataSet metadata in Metadata) { if (metadata.Name == name && metadata.Relationship.Id == relationship.Id) { metadataSet = metadata; break; } } } else { foreach (IMetadataSet metadata in Metadata) { if (metadata.Name == name) { metadataSet = metadata; break; } } } if (metadataSet != null) { //TransactionFramework.UpdateMetadataTransactionLink updateMetadataTransaction = UpdateMetadataTransaction(metadataSet, Parent, name, value); metadataSet.Update(null, value, null, null, null, ref chain); } else { TransactionFramework.AddMetadataTransactionLink addMetadataTransaction = AddMetadataTransaction(metadataSet, Parent, relationship, connectionType, name, value); metadataSet = MetadataSetFactory.GetInstance(MapManager).GetMetadata(addMetadataTransaction, addMetadataTransaction.DomainId, addMetadataTransaction.RootMapId.Value, name, value, Parent, relationship, connectionType); chain.AddTransaction(addMetadataTransaction); Metadata.Add(metadataSet); IMetadataSetManager metadataSetManager = metadataSet as IMetadataSetManager; if (metadataSetManager != null) { metadataSetManager.Container = this; } } return metadataSet; }
public void Delete(ref TransactionFramework.TransactionChain chain) { BaseMetadata.Delete(ref chain); }
public void Update(string name, string value, Proxy.INode node, Proxy.IRelationship relationship, Proxy.ConnectionType connectionType, ref TransactionFramework.TransactionChain chain) { BaseMetadata.Update(name, value, node, relationship, connectionType, ref chain); }
//public IMetadataSet GetMetadata(Guid metadataId, string name, string value, INode node, IRelationship relationship, ConnectionType connectionType) //{ // Soap.SoapMetadataSet newMetadatSet = new Soap.SoapMetadataSet(MapManager); // newMetadatSet.Id = metadataId; // newMetadatSet.Name = name; // newMetadatSet.Value = value; // newMetadatSet.Node = node; // newMetadatSet.Relationship = relationship; // newMetadatSet.ConnectionType = connectionType; // Metadata[metadataId] = newMetadatSet; // return newMetadatSet; //} public void UpgradeFacade(TransactionFramework.ISoapTransactionLink link, ServerObjects.Metadata serviceMetadata) { if (!InProcessMetadata.ContainsKey(link)) { return; } FacadeMetadataSet facadeMetadataSet = InProcessMetadata[link]; InProcess.InProcessMetadata inProcessMetadata = facadeMetadataSet.BaseMetadata as InProcess.InProcessMetadata; if (inProcessMetadata == null) { return; } Soap.SoapMetadataSet soapMetadataSet = new Soap.SoapMetadataSet(inProcessMetadata, serviceMetadata); IMetadataSetManager soapMetadataSetManager = soapMetadataSet as IMetadataSetManager; IMetadataSetManager inProcessMetadataSetManager = inProcessMetadata as IMetadataSetManager; if (soapMetadataSetManager != null && inProcessMetadataSetManager != null) { soapMetadataSetManager.Container = inProcessMetadataSetManager.Container; } facadeMetadataSet.BaseMetadata = soapMetadataSet; Metadata[soapMetadataSet.Id] = soapMetadataSet; InProcessMetadata.Remove(link); }
public virtual void Delete(ref TransactionFramework.TransactionChain chain) { IMetadataSetManager metadataSetManager = this; metadataSetManager.Container.Remove(this); /// TODO: Need to consider whether the following should be done here. //MetadataSetFactory.GetInstance(MapManager).Remove(this); }
public virtual void Update(string name, string value, Proxy.INode node, Proxy.IRelationship relationship, Proxy.ConnectionType connectionType, ref TransactionFramework.TransactionChain chain) { if (name != null) { Name = name; } if (value != null) { Value = value; } if (node != null) { Node = node; } if (relationship != null) { Relationship = relationship; } if (connectionType != null) { ConnectionType = connectionType; } }
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; }
public IMetadataSet GetMetadata(TransactionFramework.ISoapTransactionLink link, Guid domainId, Guid rootMapId, string name, string value, INode node, IRelationship relationship, ConnectionType connectionType) { /// Return a FacadeNode containing an InProcessMetadataSet InProcess.InProcessMetadata newMetadataSet = new InProcess.InProcessMetadata(MapManager); newMetadataSet.OriginLink = link; newMetadataSet.Id = Guid.Empty; newMetadataSet.DomainId = domainId; newMetadataSet.RootMapId = rootMapId; newMetadataSet.Name = name; newMetadataSet.Value = value; newMetadataSet.Node = node; newMetadataSet.Relationship = relationship; newMetadataSet.ConnectionType = connectionType; FacadeMetadataSet facadeMetadataSet = new FacadeMetadataSet(); facadeMetadataSet.BaseMetadata = newMetadataSet; newMetadataSet.Facade = facadeMetadataSet; InProcessMetadata[link] = facadeMetadataSet; return facadeMetadataSet; }
public Proxy.INode CreateNode(Guid domainId, Guid rootMapId, Proxy.NodeType nodeType, string originalId, ref TransactionFramework.TransactionChain chain) { TransactionFramework.AddNodeTransactionLink createNodeTransaction = new TransactionFramework.AddNodeTransactionLink(); createNodeTransaction.MapManager = this; createNodeTransaction.DomainId = domainId; createNodeTransaction.RootMapId = rootMapId; createNodeTransaction.NodeType = nodeType; createNodeTransaction.OriginalId = originalId; chain.AddTransaction(createNodeTransaction); Proxy.INode node = createNodeTransaction.CreateInProcessObjects(); return node; }
public void AddTransactionChain(TransactionFramework.TransactionChain transactionChain) { TransactionChains.Enqueue(transactionChain); _hasChanged = true; //Save(); }
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; }