예제 #1
0
 private void IndexDiff(DbRepresentation other, DiffReport diff)
 {
     foreach (IndexDefinition schemaIndex in _schemaIndexes)
     {
         if (!other._schemaIndexes.Contains(schemaIndex))
         {
             diff.Add("I have schema index " + schemaIndex + " which other doesn't");
         }
     }
     foreach (IndexDefinition otherSchemaIndex in other._schemaIndexes)
     {
         if (!_schemaIndexes.Contains(otherSchemaIndex))
         {
             diff.Add("Other has schema index " + otherSchemaIndex + " which I don't");
         }
     }
 }
예제 #2
0
 private void ConstraintDiff(DbRepresentation other, DiffReport diff)
 {
     foreach (ConstraintDefinition constraint in _constraints)
     {
         if (!other._constraints.Contains(constraint))
         {
             diff.Add("I have constraint " + constraint + " which other doesn't");
         }
     }
     foreach (ConstraintDefinition otherConstraint in other._constraints)
     {
         if (!_constraints.Contains(otherConstraint))
         {
             diff.Add("Other has constraint " + otherConstraint + " which I don't");
         }
     }
 }
예제 #3
0
            protected internal virtual void CompareWith(PropertiesRep other, DiffReport diff)
            {
                bool equals = Props.Equals(other.Props);

                if (!equals)
                {
                    diff.Add("Properties diff for " + EntityToString + " mine:" + Props + ", other:" + other.Props);
                }
            }
예제 #4
0
            /*
             * Yes, this is not the best way to do it - hash map does a deep equals. However,
             * if things go wrong, this way give the ability to check where the inequality
             * happened. If you feel strongly about this, feel free to change.
             * Admittedly, the implementation could use some cleanup.
             */
            internal virtual void CompareIndex(NodeRep other, DiffReport diff)
            {
                if (other.Index == Index)
                {
                    return;
                }
                ICollection <string> allIndexes = new HashSet <string>();

                allIndexes.addAll(Index.Keys);
                allIndexes.addAll(other.Index.Keys);
                foreach (string indexName in allIndexes)
                {
                    if (!Index.ContainsKey(indexName))
                    {
                        diff.Add(this + " isn't indexed in " + indexName + " for mine");
                        continue;
                    }
                    if (!other.Index.ContainsKey(indexName))
                    {
                        diff.Add(this + " isn't indexed in " + indexName + " for other");
                        continue;
                    }

                    IDictionary <string, Serializable> thisIndex  = Index[indexName];
                    IDictionary <string, Serializable> otherIndex = other.Index[indexName];

                    if (thisIndex.Count != otherIndex.Count)
                    {
                        diff.Add("other index had a different mapping count than me for node " + this + " mine:" + thisIndex + ", other:" + otherIndex);
                        continue;
                    }

                    foreach (KeyValuePair <string, Serializable> indexEntry in thisIndex.SetOfKeyValuePairs())
                    {
                        if (!indexEntry.Value.Equals(otherIndex[indexEntry.Key]))
                        {
                            diff.Add("other index had a different value indexed for " + indexEntry.Key + "=" + indexEntry.Value + ", namely " + otherIndex[indexEntry.Key] + " for " + this);
                        }
                    }
                }
            }
예제 #5
0
            internal virtual void CompareRelationships(NodeRep other, DiffReport diff)
            {
                foreach (PropertiesRep rel in OutRelationships.Values)
                {
                    PropertiesRep otherRel = other.OutRelationships[rel.EntityId];
                    if (otherRel == null)
                    {
                        diff.Add("I have relationship " + rel.EntityId + " which other don't");
                        continue;
                    }
                    rel.CompareWith(otherRel, diff);
                }

                foreach (long?id in other.OutRelationships.Keys)
                {
                    if (!OutRelationships.ContainsKey(id))
                    {
                        diff.Add("Other has relationship " + id + " which I don't");
                    }
                }
            }
예제 #6
0
        private void NodeDiff(DbRepresentation other, DiffReport diff)
        {
            foreach (NodeRep node in _nodes.Values)
            {
                NodeRep otherNode = other._nodes[node.Id];
                if (otherNode == null)
                {
                    diff.Add("I have node " + node.Id + " which other doesn't");
                    continue;
                }
                node.CompareWith(otherNode, diff);
            }

            foreach (long?id in other._nodes.Keys)
            {
                if (!_nodes.ContainsKey(id))
                {
                    diff.Add("Other has node " + id + " which I don't");
                }
            }
        }
예제 #7
0
 internal virtual void CompareWith(NodeRep other, DiffReport diff)
 {
     if (other.Id != Id)
     {
         diff.Add("Id differs mine:" + Id + ", other:" + other.Id);
     }
     Properties.compareWith(other.Properties, diff);
     if (Index != null && other.Index != null)
     {
         CompareIndex(other, diff);
     }
     CompareRelationships(other, diff);
 }