@OpenApiAll
public final class MergeUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
MergeUtil.ConflictResolution
Conflict resolution for 3-way merge.
|
static class |
MergeUtil.Optimization
Performance/memory usage optimization option.
|
Constructor and Description |
---|
MergeUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
acceptChanges(java.util.Set<Change> preferredChanges,
java.util.Set<Change> changes)
Accept given changes.
|
static boolean |
applyChanges(ProjectDifference difference,
ErrorHandler<java.lang.Exception> errorHandler)
Apply project difference changes.
|
static void |
callInEsiIDSupport(java.lang.Runnable runnable)
Executes runnable where
getID(BaseElement) uses twc
server element id when comparing elements. |
static ProjectDifference |
compareProjects(Project project,
ProjectDescriptor baseProjectDescriptor,
ErrorHandler<java.lang.Exception> errorHandler,
MergeUtil.Optimization optimization)
Compare projects.
|
static java.util.Collection<java.lang.String> |
getAllIDS(Project ancestorProject) |
static java.util.Set<Change> |
getConflictingChanges(java.util.Set<Change> changes)
Filter only changes that has conflicts.
|
static ProjectDifference |
getDifference(Project targetProject,
ProjectDescriptor source,
ProjectDescriptor ancestor,
ErrorHandler<java.lang.Exception> errorHandler,
MergeUtil.Optimization optimization)
Discover project difference.
|
static ProjectDifference |
getDifference(Project targetProject,
ProjectDescriptor source,
ProjectDescriptor ancestor,
ErrorHandler<java.lang.Exception> errorHandler,
MergeUtil.Optimization optimization,
java.util.Set<com.nomagic.magicdraw.diff.ModuleInfo> modules)
Discover project difference.
|
static BaseElement |
getElementByID(Project project,
java.lang.String id)
Return element from project with given simple or derived id.
|
static java.lang.String |
getID(BaseElement be) |
static boolean |
merge(Project targetProject,
ProjectDescriptor source,
ProjectDescriptor ancestor,
MergeUtil.ConflictResolution conflictResolution,
ErrorHandler<java.lang.Exception> errorHandler,
MergeUtil.Optimization optimization)
Merge projects.
|
static void |
registerCreatedElement(java.lang.String compositeID,
ModelObject element)
Register created element by composite id.
|
static void |
resetCompositeIDSupport()
Reset known composite id support.
|
static void |
resetCompositeIDSupportCreatedElements()
Reset known created elements.
|
static void |
restore(ProjectDifference difference)
Dispose project difference.
|
static void |
setChangeState(Change change,
ChangeState state)
Set change state.
|
static void |
showDifferenceGUI(ProjectDifference projectDifference)
Show project difference GUI.
|
static boolean |
showMergeGUI(ProjectDifference projectDifference)
Show merge GUI.
|
@CheckForNull public static ProjectDifference compareProjects(@Nonnull Project project, @Nonnull ProjectDescriptor baseProjectDescriptor, @Nonnull ErrorHandler<java.lang.Exception> errorHandler, @Nonnull MergeUtil.Optimization optimization) throws java.lang.IllegalStateException
project
- target project.baseProjectDescriptor
- source project descriptor.errorHandler
- invoked if error occurs. Allows to perform custom action.optimization
- optimization option.java.lang.IllegalStateException
- if merge is not available@CheckForNull public static ProjectDifference getDifference(@Nonnull Project targetProject, @Nonnull ProjectDescriptor source, @CheckForNull ProjectDescriptor ancestor, @Nonnull ErrorHandler<java.lang.Exception> errorHandler, @Nonnull MergeUtil.Optimization optimization) throws java.lang.IllegalStateException
targetProject
- target project.source
- source project descriptor.ancestor
- ancestor project descriptor. Used only for 3-way merge, null
for 2-way merge.errorHandler
- invoked if error occurs. Allows to perform custom action.optimization
- optimization option.java.lang.IllegalStateException
- if merge is not available@CheckForNull public static ProjectDifference getDifference(@Nonnull Project targetProject, @Nonnull ProjectDescriptor source, @CheckForNull ProjectDescriptor ancestor, @Nonnull ErrorHandler<java.lang.Exception> errorHandler, @Nonnull MergeUtil.Optimization optimization, @CheckForNull java.util.Set<com.nomagic.magicdraw.diff.ModuleInfo> modules) throws java.lang.IllegalStateException
targetProject
- target project.source
- source project descriptor.ancestor
- ancestor project descriptor. Used only for 3-way merge, null
for
2-way merge.errorHandler
- invoked if error occurs. Allows to perform custom action.optimization
- optimization option.modules
- request modules for read-write merge mode. Restriction/constraints apply for
read-write module merge mode. Invoke ProjectDifference.getRejectedModules()
to find out
which modules did not qualify for read-write merge mode.java.lang.IllegalStateException
- if merge is not availablepublic static void acceptChanges(@Nonnull java.util.Set<Change> preferredChanges, @Nonnull java.util.Set<Change> changes) throws java.lang.IllegalStateException
changes
conflicts with change from preferredChanges
, it is rejected.
The result is - all preferredChanges
are accepted, and only not conflicting changes
are accepted.preferredChanges
- accept all these changes.changes
- accept only not conflicting changes.java.lang.IllegalStateException
- if merge is not availablepublic static void restore(@Nonnull ProjectDifference difference)
difference
- project difference.public static boolean showMergeGUI(ProjectDifference projectDifference) throws java.lang.IllegalStateException
projectDifference
- project difference.java.lang.IllegalStateException
- if merge is not availablepublic static boolean applyChanges(@Nonnull ProjectDifference difference, @Nonnull ErrorHandler<java.lang.Exception> errorHandler) throws java.lang.IllegalStateException
difference
- project difference.errorHandler
- invoked if error occurs.java.lang.IllegalStateException
- if merge is not available,
if changes applied on not latest teamwork project version,
or trying to merge local project with teamwork project.public static java.util.Set<Change> getConflictingChanges(@Nonnull java.util.Set<Change> changes)
changes
- changes to filter.public static void setChangeState(@Nonnull Change change, @Nonnull ChangeState state)
change
- change to modify state.state
- new change state.public static boolean merge(@Nonnull Project targetProject, @Nonnull ProjectDescriptor source, @CheckForNull ProjectDescriptor ancestor, @CheckForNull MergeUtil.ConflictResolution conflictResolution, @Nonnull ErrorHandler<java.lang.Exception> errorHandler, @Nonnull MergeUtil.Optimization optimization) throws java.lang.IllegalStateException
targetProject
- target project.source
- source project descriptor.ancestor
- ancestor project descriptor. Pass value only for 3-way merge (null
for 2-way merge).conflictResolution
- define conflict resolution. Used only in 3-way merge. null
is treated as MergeUtil.ConflictResolution.TARGET_PREFERRED
.errorHandler
- invoked if error occurs. Allows to perform custom action.optimization
- optimization option.true
if project merged, otherwise false
.java.lang.IllegalStateException
- if merge is not available,
if changes applied on not latest teamwork project version,
or trying to merge local project with teamwork project.public static void showDifferenceGUI(ProjectDifference projectDifference) throws java.lang.IllegalStateException
projectDifference
- project difference.java.lang.IllegalStateException
- if diff is not availablepublic static java.lang.String getID(BaseElement be)
@CheckForNull public static BaseElement getElementByID(Project project, java.lang.String id)
project
- projectid
- simple or derived id@Nonnull public static java.util.Collection<java.lang.String> getAllIDS(Project ancestorProject)
public static void resetCompositeIDSupportCreatedElements()
public static void resetCompositeIDSupport()
public static void callInEsiIDSupport(java.lang.Runnable runnable)
getID(BaseElement)
uses twc
server element id when comparing elements.runnable
- runnable to executepublic static void registerCreatedElement(java.lang.String compositeID, ModelObject element)
compositeID
- composite id.element
- created element.