// Accessed from HA-robustness, needs to be public //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("WeakerAccess") public java.util.Collection<String> compareWith(DbRepresentation other) public virtual ICollection <string> CompareWith(DbRepresentation other) { ICollection <string> diffList = new List <string>(); DiffReport diff = new CollectionDiffReport(diffList); NodeDiff(other, diff); IndexDiff(other, diff); ConstraintDiff(other, diff); return(diffList); }
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"); } } }
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"); } } }
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"); } } }
public static DbRepresentation Of(GraphDatabaseService db, bool includeIndexes) { int retryCount = 5; while (true) { try { using (Transaction ignore = Db.beginTx()) { DbRepresentation result = new DbRepresentation(); foreach (Node node in Db.AllNodes) { NodeRep nodeRep = new NodeRep(db, node, includeIndexes); result._nodes[node.Id] = nodeRep; result._highestNodeId = Math.Max(node.Id, result._highestNodeId); result._highestRelationshipId = Math.Max(nodeRep.HighestRelationshipId, result._highestRelationshipId); } foreach (IndexDefinition indexDefinition in Db.schema().Indexes) { result._schemaIndexes.Add(indexDefinition); } foreach (ConstraintDefinition constraintDefinition in Db.schema().Constraints) { result._constraints.Add(constraintDefinition); } return(result); } } catch (TransactionFailureException e) { if (retryCount-- < 0) { throw e; } } } }