コード例 #1
0
ファイル: NodeMergeExecutor.cs プロジェクト: nemanjazz/iog
        public void ChangeObject(Guid nodeId, Node<Guid, object, EdgeData> changedNode, Node<Guid, object, EdgeData> node, MergeRecursiveDelegate mergeRecursive, InsertRecursiveDelegate insertRecursive, RecursiveResolutionParameters parameters)
        {
            // Consolidate the values
            foreach (var item in changedNode.Values)
            {
                node.Values[item.Key] = item.Value;
            }

            // Consolidate the edges
            foreach (var edge in changedNode.Edges)
            {
                Guid newReference = edge.Value.ToNodeId;

                NodeState nodeState = NodeState.None;
                parameters.ChangeSet.NodeStates.TryGetValue(newReference, out nodeState);

                // If changed node is a new node go into the changed node recursion
                if (nodeState == NodeState.Created)
                {
                    // Set the new reference
                    node.SetEdgeToNode(edge.Value.Data, newReference);
                    // Insert the new nodes
                    insertRecursive(newReference, parameters);
                }
                else
                {
                    // Set the new reference
                    node.SetEdgeToNode(edge.Value.Data, newReference);
                    // Follow the new reference and see changes
                    mergeRecursive(newReference, parameters);
                }
            }
        }
コード例 #2
0
        private void MergeObjectsStatic(Guid nodeId, Guid typeId, Node <Guid, object, EdgeData> originalNode, Node <Guid, object, EdgeData> changedNode, Node <Guid, object, EdgeData> node, MergeRecursiveDelegate mergeRecursive, InsertRecursiveDelegate insertRecursive, RecursiveResolutionParameters parameters)
        {
            // Consolidate the values
            foreach (var item in originalNode.Values)
            {
                // Value was changed compared to previous version
                if (!changedNode.Values[item.Key].Equals(item.Value))
                {
                    // Try setting value in the node, if it is still the same
                    if (node.Values[item.Key].Equals(item.Value))
                    {
                        node.Values[item.Key] = changedNode.Values[item.Key];
                    }
                    else
                    {
                        if (objectAttributeProvider.IsMemberOverride(typeId, item.Key))
                        {
                            // Override with changed value
                            node.Values[item.Key] = changedNode.Values[item.Key];
                        }
                        else
                        {
                            throw new ConcurrentModificationException("Concurrent modification of scalar value not allowed in type:" + typesService.GetTypeFromId(typeId).ToString() + " for member " + typesService.GetMemberName(typeId, item.Key));
                        }
                    }
                }
            }

            // Consolidate the edges
            foreach (var edge in originalNode.Edges)
            {
                // Value was changed compared to previous version
                if (!changedNode.Edges[edge.Key].ToNodeId.Equals(edge.Value.ToNodeId))
                {
                    // Was member set to override?
                    bool isOverride = objectAttributeProvider.IsMemberOverride(typeId, (Guid)edge.Key.Data);

                    // Try setting value in the node, if it is still the same or if override is set
                    if (node.Edges[edge.Key].ToNodeId.Equals(edge.Value.ToNodeId) || isOverride)
                    {
                        Guid newReference        = changedNode.Edges[edge.Key].ToNodeId;
                        Guid newReferenceUpdated = Guid.Empty;

                        // Is there an intermediate change?
                        if (parameters.IntermediateChanges.TryGetValue(newReference, out newReferenceUpdated))
                        {
                            // Set edge to node from the changed node
                            node.SetEdgeToNode(edge.Value.Data, newReferenceUpdated);
                            // See about the new object
                            mergeRecursive(newReferenceUpdated, parameters);
                        }
                        else
                        {
                            NodeState nodeState = NodeState.None;
                            parameters.ChangeSet.NodeStates.TryGetValue(newReference, out nodeState);

                            // If changed node is a new node go into the changed node recursion
                            if (nodeState == NodeState.Created)
                            {
                                // Set the new reference
                                node.SetEdgeToNode(edge.Value.Data, newReference);
                                // Insert the new nodes
                                insertRecursive(newReference, parameters);
                            }
                            else
                            {
                                // Set the new reference
                                node.SetEdgeToNode(edge.Value.Data, newReference);
                                // Follow the new reference and see changes
                                mergeRecursive(newReference, parameters);
                            }
                        }
                    }
                    else
                    {
                        throw new ConcurrentModificationException("Concurrent modification of referenced item not allowed in type:" + typesService.GetTypeFromId(typeId).ToString() + " for member " + typesService.GetMemberName(typeId, (Guid)edge.Key.Data));
                    }
                }
                else
                {
                    mergeRecursive(node.Edges[edge.Key].ToNodeId, parameters);
                }
            }
        }
コード例 #3
0
        public void ChangeObject(Guid nodeId, Node <Guid, object, EdgeData> changedNode, Node <Guid, object, EdgeData> node, MergeRecursiveDelegate mergeRecursive, InsertRecursiveDelegate insertRecursive, RecursiveResolutionParameters parameters)
        {
            // Consolidate the values
            foreach (var item in changedNode.Values)
            {
                node.Values[item.Key] = item.Value;
            }

            // Consolidate the edges
            foreach (var edge in changedNode.Edges)
            {
                Guid newReference = edge.Value.ToNodeId;

                NodeState nodeState = NodeState.None;
                parameters.ChangeSet.NodeStates.TryGetValue(newReference, out nodeState);

                // If changed node is a new node go into the changed node recursion
                if (nodeState == NodeState.Created)
                {
                    // Set the new reference
                    node.SetEdgeToNode(edge.Value.Data, newReference);
                    // Insert the new nodes
                    insertRecursive(newReference, parameters);
                }
                else
                {
                    // Set the new reference
                    node.SetEdgeToNode(edge.Value.Data, newReference);
                    // Follow the new reference and see changes
                    mergeRecursive(newReference, parameters);
                }
            }
        }
コード例 #4
0
        public void MergeObjects(Guid nodeId, Node <Guid, object, EdgeData> originalNode, Node <Guid, object, EdgeData> changedNode, Node <Guid, object, EdgeData> node, MergeRecursiveDelegate mergeRecursive, InsertRecursiveDelegate insertRecursive, RecursiveResolutionParameters parameters)
        {
            Guid typeId = typesService.GetInstanceTypeId(originalNode);

            if (!objectAttributeProvider.IsConcurrent(typeId))
            {
                var instanceType = typesService.GetTypeFromId(typesService.GetInstanceTypeId(nodeId));
                throw new ConcurrentModificationException("Concurrent modification not allowed for entity type:" + instanceType.ToString());
            }

            if (objectAttributeProvider.IsStaticConcurrency(typeId))
            {
                MergeObjectsStatic(nodeId, typeId, originalNode, changedNode, node, mergeRecursive, insertRecursive, parameters);
            }
            else
            {
                throw new NotImplementedException("Dynamic concurrency not implemented");
            }
        }
コード例 #5
0
ファイル: NodeMergeExecutor.cs プロジェクト: nemanjazz/iog
        public void MergeObjects(Guid nodeId, Node<Guid, object, EdgeData> originalNode, Node<Guid, object, EdgeData> changedNode, Node<Guid, object, EdgeData> node, MergeRecursiveDelegate mergeRecursive, InsertRecursiveDelegate insertRecursive, RecursiveResolutionParameters parameters)
        {
            Guid typeId = typesService.GetInstanceTypeId(originalNode);
            if (!objectAttributeProvider.IsConcurrent(typeId))
            {
                var instanceType = typesService.GetTypeFromId(typesService.GetInstanceTypeId(nodeId));
                throw new ConcurrentModificationException("Concurrent modification not allowed for entity type:" + instanceType.ToString());
            }

            if (objectAttributeProvider.IsStaticConcurrency(typeId))
            {
                MergeObjectsStatic(nodeId, typeId, originalNode, changedNode, node, mergeRecursive, insertRecursive, parameters);
            }
            else
            {
                throw new NotImplementedException("Dynamic concurrency not implemented");
            }
        }
コード例 #6
0
ファイル: NodeMergeExecutor.cs プロジェクト: nemanjazz/iog
        private void MergeObjectsStatic(Guid nodeId, Guid typeId, Node<Guid, object, EdgeData> originalNode, Node<Guid, object, EdgeData> changedNode, Node<Guid, object, EdgeData> node, MergeRecursiveDelegate mergeRecursive, InsertRecursiveDelegate insertRecursive, RecursiveResolutionParameters parameters)
        {
            // Consolidate the values
            foreach (var item in originalNode.Values)
            {
                // Value was changed compared to previous version
                if (!changedNode.Values[item.Key].Equals(item.Value))
                {
                    // Try setting value in the node, if it is still the same
                    if (node.Values[item.Key].Equals(item.Value))
                    {
                        node.Values[item.Key] = changedNode.Values[item.Key];
                    }
                    else
                    {
                        if (objectAttributeProvider.IsMemberOverride(typeId, item.Key))
                        {
                            // Override with changed value
                            node.Values[item.Key] = changedNode.Values[item.Key];
                        }
                        else
                        {
                            throw new ConcurrentModificationException("Concurrent modification of scalar value not allowed in type:" + typesService.GetTypeFromId(typeId).ToString() + " for member " + typesService.GetMemberName(typeId, item.Key));
                        }
                    }
                }
            }

            // Consolidate the edges
            foreach (var edge in originalNode.Edges)
            {
                // Value was changed compared to previous version
                if (!changedNode.Edges[edge.Key].ToNodeId.Equals(edge.Value.ToNodeId))
                {
                    // Was member set to override?
                    bool isOverride = objectAttributeProvider.IsMemberOverride(typeId, (Guid)edge.Key.Data);

                    // Try setting value in the node, if it is still the same or if override is set
                    if (node.Edges[edge.Key].ToNodeId.Equals(edge.Value.ToNodeId) || isOverride)
                    {
                        Guid newReference = changedNode.Edges[edge.Key].ToNodeId;
                        Guid newReferenceUpdated = Guid.Empty;

                        // Is there an intermediate change?
                        if (parameters.IntermediateChanges.TryGetValue(newReference, out newReferenceUpdated))
                        {
                            // Set edge to node from the changed node
                            node.SetEdgeToNode(edge.Value.Data, newReferenceUpdated);
                            // See about the new object
                            mergeRecursive(newReferenceUpdated, parameters);
                        }
                        else
                        {
                            NodeState nodeState = NodeState.None;
                            parameters.ChangeSet.NodeStates.TryGetValue(newReference, out nodeState);

                            // If changed node is a new node go into the changed node recursion
                            if (nodeState == NodeState.Created)
                            {
                                // Set the new reference
                                node.SetEdgeToNode(edge.Value.Data, newReference);
                                // Insert the new nodes
                                insertRecursive(newReference, parameters);
                            }
                            else
                            {
                                // Set the new reference
                                node.SetEdgeToNode(edge.Value.Data, newReference);
                                // Follow the new reference and see changes
                                mergeRecursive(newReference, parameters);
                            }
                        }
                    }
                    else
                    {
                        throw new ConcurrentModificationException("Concurrent modification of referenced item not allowed in type:" + typesService.GetTypeFromId(typeId).ToString() + " for member " + typesService.GetMemberName(typeId, (Guid)edge.Key.Data));
                    }
                }
                else
                {
                    mergeRecursive(node.Edges[edge.Key].ToNodeId, parameters);
                }
            }
        }