Class ComparisonContext

java.lang.Object
com._1c.g5.v8.dt.compare.core.ComparisonContext
All Implemented Interfaces:
AutoCloseable

public class ComparisonContext extends Object implements AutoCloseable
ComparisonContext is able to store comparison-specific information for a single object comparison computation being performed at the moment. As comparison algorithms could affect other objects, the context is not limited to store data related to the main target of the comparison process.
Each IComparisonParticipant could register its own set of IObjectComparisonContext's during the processing.
The ComparisonContext is being created automatically at the beginning of the object comparison process and being disposed at the end of the comparison process.
  • Constructor Details

    • ComparisonContext

      public ComparisonContext(IComparisonSession comparisonSession)
      Creates context instance.
      Parameters:
      comparisonSession - the comparison session, cannot be null
  • Method Details

    • addObjectContext

      public void addObjectContext(long topNodeId, IObjectComparisonContext objectContext)
      Adds a IObjectComparisonContext to this context for the given top comparison node.
      Parameters:
      topNodeId - the top comparison node identifier to add object context for
      objectContext - The object context to add. Can't be null
    • getComparisonTransaction

      public IBmTransaction getComparisonTransaction()
      Gets the comparison transaction associated with the context
      Returns:
      The transaction for the current comparison. Can be null
    • getComparisonSession

      public IComparisonSession getComparisonSession()
      Gets the comparison session the context attached to.
      Returns:
      the comparison session, cannot be null
    • getDataSourceContext

      public ComparisonDataSourceTransactionalContext getDataSourceContext()
      Gets the ComparisonDataSourceTransactionalContext associated with the current computation. The context should be used while accessing the data source objects to ensure the transactional integrity.
      Returns:
      The context. Can be null during certain stages of the lifecycle
    • getObjectContext

      public IObjectComparisonContext getObjectContext(long topNodeId)
      Gets a IObjectComparisonContext being stored in the context for the given top comparison node.
      Parameters:
      topNodeId - the top comparison node identifier to get object context for
      Returns:
      The stored object context. Can be null
    • getBatchSessionHandle

      public Object getBatchSessionHandle()
      Gets the batch session handle.
      Returns:
      the batch session handle. Can be null.
    • setComparisonTransaction

      public void setComparisonTransaction(IBmTransaction comparisonTransaction)
      Sets the comparison transaction.
      Parameters:
      The - transaction for the current comparison. Can be null
    • setDataSourceContext

      public void setDataSourceContext(ComparisonDataSourceTransactionalContext dataSourceContext)
      Parameters:
      dataSourceContext - The context to set. Can be null
    • setBatchSessionHandle

      public void setBatchSessionHandle(Object batchSessionHandle)
      Sets the batch session handle.
      Parameters:
      batchSessionHandle - the batch session handle, can be null.
      See Also:
    • checkNode

      public boolean checkNode(ComparisonNode node, String... searchStrings)
      Shortcut predicative method to find nodes which human/machine readta description matches the given set of substings. See the describeNode(ComparisonNode, boolean) for details.
      Parameters:
      node - The node to check. May not be null
      searchStrings - The set of search strings to check against the desription of the node
      Returns:
      True if all given strings are contained in the end result
    • describeNode

      public String describeNode(ComparisonNode node, boolean showFullPath)
      Gives human/machine-readable description of the comparison for debug purposes: RT - root node TP:linkMain,linkOther,linkAncestor - root node. TP:linkMain,+, - other link is the same as the main, the ancestor link is empty FT:featureName - feature link CE:featureName(1,2,3) - collection element, with indexes for main,other and acestor
      Parameters:
      node - The node to describe. May not be null
      showFullPath - Optionally show the full path for all containment/feature nodes
      Returns:
      The description of the node. May not be null
    • close

      public void close()
      Closes the context, cleaning/committing all underlying data.
      Specified by:
      close in interface AutoCloseable