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);
}
}
Aggregations