Class ComparisonManager

java.lang.Object
com._1c.g5.v8.dt.internal.compare.ComparisonManager
All Implemented Interfaces:
IResourcePlan, IComparisonManager, ISymlinkTranslator, IComparisonProcessController, IBatchComparisonRunner, IMergeProcessor, IManagedService

Default implementation of the comparison manager.
  • Field Details

  • Constructor Details

    • ComparisonManager

      public ComparisonManager()
      Constructs an instance of the comparison manager.
  • Method Details

    • activate

      public void activate()
      Specified by:
      activate in interface IManagedService
    • addStatusListener

      public void addStatusListener(IComparisonManager.ICompareMergeStatusListener listener)
      Description copied from interface: IComparisonManager
      Adds a comparison status listener.
      Specified by:
      addStatusListener in interface IComparisonManager
      Parameters:
      listener - the status listener, not null
    • compare

      public void compare(long topNodeId, ComparisonSession session, org.eclipse.core.runtime.IProgressMonitor monitor)
      Description copied from interface: IComparisonProcessController
      Compares the specified result node of the specified session.
      Specified by:
      compare in interface IComparisonProcessController
      Parameters:
      topNodeId - the top node id
      session - the comparison session
      monitor - the progress monitor
    • deactivate

      public void deactivate()
      Specified by:
      deactivate in interface IManagedService
    • getHandles

      public List<ComparisonProcessHandle> getHandles(IV8Project v8Project)
      Description copied from interface: IComparisonManager
      Returns handles of all sides of a comparison process with the specified V8 project.
      Specified by:
      getHandles in interface IComparisonManager
      Parameters:
      v8Project - the V8 project, not null
      Returns:
      the handles, never null
    • getStatus

      Description copied from interface: IComparisonManager
      Returns the status of a comparison process managed by this.
      Specified by:
      getStatus in interface IComparisonManager
      Parameters:
      handle - the handle of comparison, not null
      Returns:
      the status of comparison, may be null in case if the handle is not known to this
    • hasActiveComparison

      public boolean hasActiveComparison()
      Description copied from interface: IComparisonManager
      Tells if there any active comparison being executed at the moment.
      Specified by:
      hasActiveComparison in interface IComparisonManager
      Returns:
      true if any comparison is being executed, false otherwise
    • performComparisonProcess

      public org.eclipse.core.runtime.IStatus performComparisonProcess(ComparisonProcessHandle handle, org.eclipse.core.runtime.IProgressMonitor monitor)
      Description copied from interface: IComparisonProcessController
      Performs the process of comparison for the specified handle.
      Specified by:
      performComparisonProcess in interface IComparisonProcessController
      Parameters:
      handle - the comparison process handle, cannot be null
      monitor - the progress monitor, cannot be null
      Returns:
      the resulting status of the comparison process, never null
    • comparisonFinished

      public void comparisonFinished(CompareMergeProcessBatch batch)
      Description copied from interface: IComparisonProcessController
      Notifies the controller about finishing of all comparison processes of the specified batch.
      Specified by:
      comparisonFinished in interface IComparisonProcessController
      Parameters:
      batch - the batch whose comparison was finished, cannot be null
    • removeStatusListener

      public void removeStatusListener(IComparisonManager.ICompareMergeStatusListener listener)
      Description copied from interface: IComparisonManager
      Removes a comparison status listener.
      Specified by:
      removeStatusListener in interface IComparisonManager
      Parameters:
      listener - the status listener, not null
    • startComparison

      public void startComparison(CompareMergeProcessBatch batch)
      Description copied from interface: IComparisonManager
      Schedules asynchronous job that will start the comparison of projects specified by the given batch of compare/merge processes.
      Specified by:
      startComparison in interface IComparisonManager
      Parameters:
      batch - the batch of compare/merge processes to start comparison for, cannot be null or empty
    • runComparison

      public void runComparison(CompareMergeProcessBatch batch)
      Description copied from interface: IBatchComparisonRunner
      Runs the comparison of the given batch.
      Specified by:
      runComparison in interface IBatchComparisonRunner
      Parameters:
      batch - the batch to run comparison for, cannot be null or empty
    • stop

      public void stop(ComparisonProcessHandle handle)
      Description copied from interface: IComparisonManager
      Forgets the compare/merge process defined by the specified handle and discards its comparison session. Stops the whole batch of compare/merge processes this handle relates to if this batch is under active comparison. Does nothing if the process in under active merge.
      Specified by:
      stop in interface IComparisonManager
      Parameters:
      handle - the handle, not null
    • cancel

      public void cancel(ComparisonProcessHandle handle)
      Description copied from interface: IComparisonManager
      Cancels the compare/merge process defined by the specified handle and discards its comparison session. Stops the whole batch of compare/merge processes this handle relates to if this batch is under active comparison. Does nothing if the process in under active merge or merge already performed.
      Specified by:
      cancel in interface IComparisonManager
      Parameters:
      handle - the handle, not null
    • startMerge

      public org.eclipse.core.runtime.IStatus startMerge(CompareMergeProcessBatch batch, org.eclipse.core.runtime.IProgressMonitor monitor)
      Description copied from interface: IComparisonManager
      Schedules asynchronous job that will merge changes detected in the specified batch of compare/merge processes.

      NOTE that it is not possible to schedule the job if the processes in the batch have not yet been fully compared.

      Specified by:
      startMerge in interface IComparisonManager
      Parameters:
      batch - the batch of compare/merge processes to start merge for, cannot be null or empty
      monitor - the progress monitor, may be null
      Returns:
      Status.OK_STATUS if the merge job has been successfully scheduled, an error status otherwise
    • getMergeProblems

      public List<MergeProblem> getMergeProblems(ComparisonProcessHandle handle)
      Description copied from interface: IComparisonManager
      Returns a list of all merge problems found during merge validation and merge using external tool phases. The list will be empty if no problems found.

      NOTE that this method may only be called for processes that are in the ComparisonProcessStatus.MERGE_PROCESS_USING_EXTERNAL_TOOL_FINISHED or ComparisonProcessStatus.MERGE_PROCESS_VALIDATION_FINISHED state, and an exception will be thrown otherwise.

      Specified by:
      getMergeProblems in interface IComparisonManager
      Parameters:
      handle - the handle of the comparison process to get merge problems of, cannot be null
      Returns:
      a list of merge problems, never null
    • performMergeProcess

      public org.eclipse.core.runtime.IStatus performMergeProcess(CompareMergeProcessBatch batch, org.eclipse.core.runtime.IProgressMonitor monitor)
      Description copied from interface: IMergeProcessor
      Performs merging for the specified compare/merge processes batch.
      Specified by:
      performMergeProcess in interface IMergeProcessor
      Parameters:
      batch - the compare/merge processes batch to perform merge on, not null
      monitor - the progress monitor, not null
      Returns:
      the result merging status, never null
    • getComparisonSession

      public IComparisonSession getComparisonSession(ComparisonProcessHandle handle)
      Description copied from interface: IComparisonManager
      Returns the comparison session for the specified comparison process handle.
      Specified by:
      getComparisonSession in interface IComparisonManager
      Parameters:
      handle - the handle, not null
      Returns:
      the session, may be null if the handle is not known to the manager
    • getPotentialCorrespondingNodes

      public List<ComparisonNode> getPotentialCorrespondingNodes(ComparisonProcessHandle handle, ComparisonNode node, ComparisonSide sourceSide)
      Description copied from interface: IComparisonManager
      Returns a list of candidate nodes for setting as corresponding to the specified node.
      Specified by:
      getPotentialCorrespondingNodes in interface IComparisonManager
      Parameters:
      handle - the comparison process handle, not null
      node - the comparison result node to find potential correspondences for, not null
      sourceSide - the source side of the correspondence, not null
      Returns:
      a list of comparison result nodes, never null
    • ableToBreakCorrespondence

      public boolean ableToBreakCorrespondence(ComparisonProcessHandle handle, ComparisonNode node)
      Description copied from interface: IComparisonManager
      Checks if there is a participant able to break a correspondence stored in the specified node.
      Specified by:
      ableToBreakCorrespondence in interface IComparisonManager
      Parameters:
      handle - the comparison process handle, not null
      node - the node to check whether the correspondence represented by it can be broken, not null
      Returns:
      true if at least one participant is able to break the correspondence, and false otherwise
    • breakCorrespondence

      public void breakCorrespondence(ComparisonContext comparisonContext, ComparisonNode node)
      Breaks correspondence represented by the specified model node with the help of a participant supporting this operation.
      Parameters:
      comparisonContext - the comparison context, cannot be null
      node - the node with the correspondence to break, cannot be null
    • updateComparison

      public void updateComparison(ComparisonContext comparisonContext, ComparisonNode node, List<Long> newNodeIds)
      Updates the comparison results for a given object. Usually it's a reset of already available object, etc.
      Parameters:
      comparisonContext - the comparison context. Cannot be null.
      node - The node to update comparison information for. Cannot be null.
      newNodeIds - the list of created new node Ids to fill by participants, not null
    • addNewTopObjectToComparison

      public TopComparisonNode addNewTopObjectToComparison(IComparisonSession comparisonSession, String mainSymlink, org.eclipse.emf.ecore.EClass eClass)
      Adds a new object to the comparison.
      Parameters:
      comparisonSession - The session to update into. Cannot be null.
      mainSymlink - the main symlink
      eClass - the e class
      Returns:
      the new top node created.
    • combineOneSideNodes

      public void combineOneSideNodes(ComparisonContext comparisonContext, ComparisonNode mainNode, ComparisonNode otherNode, List<Long> newNodeIds)
      Combines two complementing one-side nodes with the help of a participant supporting this operation.
      Parameters:
      comparisonContext - the comparison context, cannot be null
      mainNode - the one-side MAIN node, cannot be null
      otherNode - the one-side OTHER node, cannot be null
      newNodeIds - the list of new node Ids to fill by participants, not null
    • getComparedObjects

      public IComparedObjects<?> getComparedObjects(IComparisonSession comparisonSession, ComparisonNode node, ComparisonContext comparisonContext)
      Returns compared objects for the specified node.
      Parameters:
      comparisonSession - the comparison session, cannot be null
      node - the node to get the compared objects for, cannot be null
      comparisonContext - the current comparison context, cannot be null
      Returns:
      the compared objects
    • getMatchingSymlinks

      public IMatchingSymlinks getMatchingSymlinks(ComparisonNode node, org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EReference reference, ComparisonSide sourceSide, String symlink, ComparisonContext comparisonContext, IMergeSession mergeSession)
      Description copied from interface: ISymlinkTranslator
      For the specified symbolic link in the specified context on the specified side ("source side"), returns an object with this link on the specified target side and symbolic links (within the same context) of objects corresponding to the source object in the comparison model.
      Specified by:
      getMatchingSymlinks in interface ISymlinkTranslator
      Parameters:
      node - the comparison result node
      eObject - the EObject containing the symbolic link
      reference - the reference of the link
      sourceSide - the source side
      symlink - the source symbolic link
      comparisonContext - the current comparison context, cannot be null
      mergeSession - the merge session or null
      Returns:
      an object with matching symbolic links where the source symbolic is on the source side
    • getMatchingSymlinksToTopObject

      public IMatchingSymlinks getMatchingSymlinksToTopObject(ComparisonContext comparisonContext, String symlink, ComparisonSide side, IMergeSession mergeSession)
      Description copied from interface: ISymlinkTranslator
      Returns matched symlinks to the top object with the given symlink on a given comparison side.
      Specified by:
      getMatchingSymlinksToTopObject in interface ISymlinkTranslator
      Parameters:
      comparisonContext - the comparison context, cannot be null
      symlink - the top object symlink to be matched, cannot be null
      side - the comparison side where the top object lies, cannot be null
      mergeSession - the merge session, can be null if no merge process run
      Returns:
      the triple of matched symlinks or null if no matched symlinks found
    • translateForImport

      public String translateForImport(IMergeSession mergeSession, ComparisonNode node, org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EReference reference, String symlink, ComparisonContext comparisonContext)
      Description copied from interface: ISymlinkTranslator
      Translates the specified symbolic link referencing an object on the OTHER side of comparison for the purposes of import, that is, when the reference is situated in an imported other object. An object is imported if it is present only on the OTHER side of comparison and is merged according to the merge settings. The translated symlink, if the original symlink was referencing an object having a correspondence on the MAIN side of comparison, will be the same as in the getMatchingSymlinks method. If the symlink was pointing to an object not present on the MAIN side but imported in the specified session (or an object derived from one), the result will take into account the closest existing parent correspondence.
      Specified by:
      translateForImport in interface ISymlinkTranslator
      Parameters:
      mergeSession - the merge session
      node - the comparison result node
      eObject - the EObject containing the symbolic link
      reference - the reference of the link
      symlink - the symbolic link on the other side
      comparisonContext - the current comparison context, cannot be null
      Returns:
      the symlink in terms of the main side after import
    • getDefaultMustBeMerged

      public Boolean getDefaultMustBeMerged(ComparisonNode node, IComparisonSession session)
      Returns the default must be merged value for the given node.
      Parameters:
      node - the node to get default must be merged value for, can not be null
      session - the comparison session, can not be null
      Returns:
      the default must be merged value or null if it wasn't specified
    • runComparisonTreeBmModelTask

      public <T> T runComparisonTreeBmModelTask(IComparisonSession session, IBmTask<T> task)
      Executes the given BM task in a comparison tree BM model of the specified session.
      Type Parameters:
      T - the generic type
      Parameters:
      session - the session, cannot be null
      task - the task to execute, cannot be null
      Returns:
      the result returned by IBmTask.execute(IBmTransaction, IProgressMonitor) method
    • runComparisonTreeBmModelReadonlyTask

      public <T> T runComparisonTreeBmModelReadonlyTask(IComparisonSession session, IBmTask<T> task)
      Executes the given read-only BM task in a comparison tree BM model of the specified session.
      Type Parameters:
      T - the generic type
      Parameters:
      session - the session, cannot be null
      task - the task to execute, cannot be null
      Returns:
      the result returned by IBmTask.execute(IBmTransaction, IProgressMonitor) method
    • supportsPrioritizedMerging

      public boolean supportsPrioritizedMerging(IComparisonSession session, ComparisonNode node)
      Tells whether the given node supports prioritized merging.
      Parameters:
      session - the session, cannot be null
      node - the node to check, cannot be null
      Returns:
      true if the node supports prioritized merging, false otherwise
    • supportsCustomMerging

      public boolean supportsCustomMerging(IComparisonSession session, ComparisonNode node)
      Tells whether the given node supports custom merging.
      Parameters:
      session - the session, cannot be null
      node - the node to check, cannot be null
      Returns:
      true if the node supports custom merging, false otherwise
    • supportsMergingUsingExternalTool

      public boolean supportsMergingUsingExternalTool(IComparisonSession session, ComparisonNode node)
      Tells whether the given node supports merging using external tool.
      Parameters:
      session - the comparison session, cannot be null
      node - the comparison node to check, cannot be null
      Returns:
      true if the node supports merging using external tool, false otherwise
    • breakMainSideCorrespondence

      public void breakMainSideCorrespondence(IComparisonSession comparisonSession, ComparisonNode node)
      Breaks main side correspondence represented by the specified model node with the help of a participant supporting this operation.
      Parameters:
      comparisonSession - the session in which to break correspondence, can not be {@code null{ @param node the node with the correspondence to break, can not be {@code null}
    • gatherActivities

      public Map<String,IActivityDemandsDefinition> gatherActivities()
      Description copied from interface: IResourcePlan
      Proclaim demands of resources for a given set of activities.
      Specified by:
      gatherActivities in interface IResourcePlan
      Returns:
      Returns IActivityDemandsDefinition mapped to respective name of the activity.
    • isExcludedFromComparison

      public boolean isExcludedFromComparison(org.eclipse.emf.ecore.EStructuralFeature feature, AbstractComparedEmfObjects<?> comparedContextObjects, IComparisonSession session)
      Checks whether the feature is to be excluded from the comparison via any of existing comparison participants.
      Parameters:
      feature - the feature to check, cannot be null
      comparedContextObjects - the triple of compared objects, cannot be null
      session - the comparison session, cannot be null
      Returns:
      true if the feature is to be excluded, false otherwise
    • getDefaultMergeRule

      public MergeRule getDefaultMergeRule(ComparisonNode node, IComparisonSession session)
      Returns the default merge rule for the given node.
      Parameters:
      node - the node to get default merge rule for, can not be null
      session - the comparison session, can not be null
      Returns:
      the default merge rule or null if it wasn't specified
    • isCandidateForPotentialMergeProblems

      public boolean isCandidateForPotentialMergeProblems(ComparisonNode node, IComparisonSession session)
      Tells whether the given node may break the configuration if it is merged.
      Parameters:
      node - the node to check, cannot be null
      session - the comparison session, cannot be null
      Returns:
      true if the node may break the configuration, false otherwise
    • getPotentialMergeProblemsDescriptions

      public List<PotentialMergeProblemDescription> getPotentialMergeProblemsDescriptions(ComparisonNode node, ComparisonContext comparisonContext)
      Returns human-readable descriptions of merge problems of the specified node.
      Parameters:
      node - the node to get merge problems descriptions for, cannot be null
      comparisonContext - the comparison context, cannot be null
      Returns:
      the list of descriptions, never null, can be empty if the node doesn't bring any merge problems
    • saveCustomSettings

      public void saveCustomSettings(ComparisonNode node, SerializableMergeSettings container, IComparisonSession session)
      Saves custom settings for the specified node into the given merge settings container. Does nothing if the node doesn't have any custom settings.
      Parameters:
      node - the comparison node to save custom settings for, cannot be null
      container - the container of serializable settings, cannot be null
      session - the comparison session, cannot be null
    • restoreCustomSettings

      public void restoreCustomSettings(ComparisonNode node, SerializableMergeSettings container, IComparisonSession session)
      Restores custom settings for the specified node from the given merge settings container.
      Parameters:
      node - the comparison node to restore custom settings for, cannot be null
      container - the container of serialized settings, cannot be null
      session - the comparison session, cannot be null
    • adoptMainSideFeature

      public org.eclipse.emf.ecore.EStructuralFeature adoptMainSideFeature(org.eclipse.emf.ecore.EStructuralFeature mainSideFeature, IComparisonSession session)
      Converts, if possible, the main side feature into a other supported by the other side object. Returns the given main side feature if no convert was found.
      Parameters:
      mainSideFeature - the main side feature to convert, cannot be null
      session - the comparison session, cannot be null
      Returns:
      the converted feature applicable for other side object or given main side feature if no convert was found, never null
    • checkForOverload

      public void checkForOverload()
      Checks the comparison for the memory overload. Throws a ComparisonMemoryOverloadException in case of check failure and the strict mode is being enabled.
      See Also:
    • setStrictOverloadCheckMode

      public void setStrictOverloadCheckMode(boolean strict)
      Sets/resets the strict mode for the memory overload checks.
      Parameters:
      strict - The strict mode
    • link

      @LifecycleParticipant(phase=LINKING) public void link()
      Participates the linking phase.
      Performs initialization steps only once, no matter how many times it is invoked.
    • shutdown

      public void shutdown()
      Performs the shutdown.

      We do not call this method on unlinking phase as unlinking can be executed a few times per EDT session whereas this method must be executed exactly once.

    • onResourceUnloading

      @LifecycleParticipant(phase=RESOURCE_UNLOADING, dependsOn="BM_MODEL_MANAGER") public void onResourceUnloading(ProjectContext context)
      Participates the resource unloading phase.
      For more information see LifecyclePhase.RESOURCE_UNLOADING.
      Parameters:
      context - the project context, cannot be null.
      See Also:
    • serializeMergeSettings

      public void serializeMergeSettings(Collection<ComparisonProcessHandle> handles, String mergeSettingsFileName) throws IOException
      Description copied from interface: IComparisonManager
      Serializes the merge settings for the given comparison session/-s to a zip-file.
      Specified by:
      serializeMergeSettings in interface IComparisonManager
      Parameters:
      handles - the comparison process handles to serialize merge settings for, cannot be or empty
      mergeSettingsFileName - the merge settings file name, cannot be null
      Throws:
      IOException - if a file serialization error occurred
    • deserializeMergeSettings

      public RestoredMergeSettings deserializeMergeSettings(ComparisonProcessHandle handle, String mergeSettingsFileName) throws FileNotFoundException, IOException, InvalidPreferencesFormatException
      Description copied from interface: IComparisonManager
      Reads the merge settings for the given comparison process from a xml-file or zip-file.
      Specified by:
      deserializeMergeSettings in interface IComparisonManager
      Parameters:
      handle - the comparison process handle to read merge settings for, cannot be null
      mergeSettingsFileName - the merge settings file name, may be null
      Returns:
      the restored merge settings, can be null
      Throws:
      FileNotFoundException - if the file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened forreading
      IOException - if an input/output operation was failed or interapted
      InvalidPreferencesFormatException - unsupported version of input file serialization format