Package com._1c.g5.v8.dt.compare.core
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.
EachIComparisonParticipant
could register its own set ofIObjectComparisonContext
's during the processing.
TheComparisonContext
is being created automatically at the beginning of the object comparison process and being disposed at the end of the comparison process.
-
-
Constructor Summary
Constructors Constructor Description ComparisonContext(IComparisonSession comparisonSession)
Creates context instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addObjectContext(long topNodeId, IObjectComparisonContext objectContext)
Adds aIObjectComparisonContext
to this context for the given top comparison node.boolean
checkNode(ComparisonNode node, String... searchStrings)
Shortcut predicative method to find nodes which human/machine readta description matches the given set of substings.void
close()
Closes the context, cleaning/committing all underlying data.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.Object
getBatchSessionHandle()
Gets the batch session handle.IComparisonSession
getComparisonSession()
Gets the comparison session the context attached to.IBmTransaction
getComparisonTransaction()
Gets the comparison transaction associated with the contextComparisonDataSourceTransactionalContext
getDataSourceContext()
Gets theComparisonDataSourceTransactionalContext
associated with the current computation.IObjectComparisonContext
getObjectContext(long topNodeId)
Gets aIObjectComparisonContext
being stored in the context for the given top comparison node.void
setBatchSessionHandle(Object batchSessionHandle)
Sets the batch session handle.void
setComparisonTransaction(IBmTransaction comparisonTransaction)
Sets the comparison transaction.void
setDataSourceContext(ComparisonDataSourceTransactionalContext dataSourceContext)
Sets theComparisonDataSourceTransactionalContext
.
-
-
-
Constructor Detail
-
ComparisonContext
public ComparisonContext(IComparisonSession comparisonSession)
Creates context instance.- Parameters:
comparisonSession
- the comparison session, cannot benull
-
-
Method Detail
-
addObjectContext
public void addObjectContext(long topNodeId, IObjectComparisonContext objectContext)
Adds aIObjectComparisonContext
to this context for the given top comparison node.- Parameters:
topNodeId
- the top comparison node identifier to add object context forobjectContext
- The object context to add. Can't benull
-
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 theComparisonDataSourceTransactionalContext
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 aIObjectComparisonContext
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 benull
-
setDataSourceContext
public void setDataSourceContext(ComparisonDataSourceTransactionalContext dataSourceContext)
Sets theComparisonDataSourceTransactionalContext
.- Parameters:
dataSourceContext
- The context to set. Can benull
-
setBatchSessionHandle
public void setBatchSessionHandle(Object batchSessionHandle)
Sets the batch session handle.- Parameters:
batchSessionHandle
- the batch session handle, can benull
.- See Also:
IBmModel.beginBatchSession()
-
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 thedescribeNode(ComparisonNode, boolean)
for details.- Parameters:
node
- The node to check. May not benull
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 benull
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 interfaceAutoCloseable
-
-