Search in sources :

Example 1 with RouteToProjectEvent

use of de.catma.ui.events.routing.RouteToProjectEvent in project catma by forTEXT.

the class ConflictedProjectView method showNextConflict.

// TODO: refactor! (consider implementing a state machine)
private void showNextConflict() {
    try {
        if (// tag/tagset conflict resolution not applied yet
        (this.tagManager == null) && // all tagset conflicts resolved by the user
        ((tagsetConflictsIterator == null) || !this.tagsetConflictsIterator.hasNext()) && ((tagConflictIterator == null) || !this.tagConflictIterator.hasNext())) {
            // all tag conflicts resolved by the user
            // apply tag/tagset conflict resolutions
            conflictedProject.resolveTagsetConflicts(this.tagsetConflicts);
            // load tagsets
            this.tagManager = new TagManager(new TagLibrary());
            conflictedProject.getTagsets().stream().forEach(tagset -> tagManager.addTagsetDefinition(tagset));
        }
        if ((tagConflictIterator != null) && tagConflictIterator.hasNext()) {
            showNextTagConflict();
        } else if ((tagsetConflictsIterator != null) && tagsetConflictsIterator.hasNext()) {
            showNextTagsetConflict();
        } else if (annotationConflictIterator != null && annotationConflictIterator.hasNext()) {
            showNextAnnotationConflict();
        } else if (collectionConflictIterator != null && collectionConflictIterator.hasNext()) {
            showNextCollectionConflict();
        } else {
            conflictedProject.resolveCollectionConflict(this.collectionConflicts, this.tagManager.getTagLibrary());
            // TODO: this may not be the right place to be doing this
            conflictedProject.resolveSourceDocumentConflicts(sourceDocumentConflicts);
            try {
                Collection<DeletedResourceConflict> deletedReourceConflicts = conflictedProject.resolveRootConflicts();
                if (!deletedReourceConflicts.isEmpty()) {
                    showDeletedResourceConflicts(deletedReourceConflicts);
                    return;
                }
            } catch (Exception e) {
                if (ExceptionUtil.stackTraceContains(CommitMissingException.class.getName(), e)) {
                    Notification.show("Error", ExceptionUtil.getMessageFor(CommitMissingException.class.getName(), e), Type.ERROR_MESSAGE);
                    eventBus.post(new RouteToDashboardEvent());
                    return;
                } else {
                    // rethrow unexpected error
                    throw new Exception(e);
                }
            }
            // TODO: check if there everything is pushed, remote state might have prevented a push
            eventBus.post(new RouteToProjectEvent(conflictedProject.getProjectReference(), true));
        }
    } catch (Exception e) {
        ((ErrorHandler) UI.getCurrent()).showAndLogError("Error showing next conflict!", e);
    }
}
Also used : CommitMissingException(de.catma.repository.git.CommitMissingException) TagLibrary(de.catma.tag.TagLibrary) RouteToProjectEvent(de.catma.ui.events.routing.RouteToProjectEvent) TagManager(de.catma.tag.TagManager) Collection(java.util.Collection) RouteToDashboardEvent(de.catma.ui.events.routing.RouteToDashboardEvent) CommitMissingException(de.catma.repository.git.CommitMissingException) IOException(java.io.IOException)

Aggregations

CommitMissingException (de.catma.repository.git.CommitMissingException)1 TagLibrary (de.catma.tag.TagLibrary)1 TagManager (de.catma.tag.TagManager)1 RouteToDashboardEvent (de.catma.ui.events.routing.RouteToDashboardEvent)1 RouteToProjectEvent (de.catma.ui.events.routing.RouteToProjectEvent)1 IOException (java.io.IOException)1 Collection (java.util.Collection)1