use of de.catma.backgroundservice.BackgroundService in project catma by forTEXT.
the class GraphWorktreeProject method synchronizeWithRemote.
@Override
public void synchronizeWithRemote(OpenProjectListener openProjectListener) throws Exception {
if (hasUncommittedChanges()) {
throw new IllegalStateException("There are uncommitted changes that need to be committed first!");
}
for (TagsetDefinition tagset : getTagsets()) {
gitProjectHandler.synchronizeTagsetWithRemote(tagset.getUuid());
}
for (SourceDocument document : getSourceDocuments()) {
gitProjectHandler.synchronizeSourceDocumentWithRemote(document.getUuid());
for (AnnotationCollectionReference collectionReference : document.getUserMarkupCollectionRefs()) {
gitProjectHandler.synchronizeCollectionWithRemote(collectionReference.getId());
}
}
gitProjectHandler.synchronizeWithRemote();
if (gitProjectHandler.hasConflicts()) {
gitProjectHandler.initAndUpdateSubmodules();
openProjectListener.conflictResolutionNeeded(new GitConflictedProject(projectReference, gitProjectHandler, documentId -> getSourceDocumentURI(documentId)));
} else {
boolean forceGraphReload = gitProjectHandler.loadRolesPerResource();
gitProjectHandler.initAndUpdateSubmodules();
gitProjectHandler.removeStaleSubmoduleDirectories();
gitProjectHandler.ensureDevBranches();
rootRevisionHash = gitProjectHandler.getRootRevisionHash();
ProgressListener progressListener = new ProgressListener() {
@Override
public void setProgress(String value, Object... args) {
openProjectListener.progress(value, args);
}
};
graphProjectHandler.ensureProjectRevisionIsLoaded(new ExecutionListener<TagManager>() {
@Override
public void error(Throwable t) {
openProjectListener.failure(t);
}
@Override
public void done(TagManager result) {
tagManager.load(result.getTagLibrary());
openProjectListener.ready(GraphWorktreeProject.this);
}
}, progressListener, rootRevisionHash, tagManager, () -> gitProjectHandler.getTagsets(), () -> gitProjectHandler.getDocuments(), (tagLibrary) -> gitProjectHandler.getCollections(tagLibrary, progressListener), forceGraphReload, backgroundService);
}
}
use of de.catma.backgroundservice.BackgroundService in project catma by forTEXT.
the class GitProjectHandlerTest method setUp.
@BeforeEach
public void setUp() throws Exception {
// create a fake CATMA user which we'll use to instantiate GitlabManagerRestricted (using the corresponding impersonation token) & JGitRepoManager
Integer randomUserId = Integer.parseInt(RandomStringUtils.randomNumeric(3));
String username = String.format("testuser-%s", randomUserId);
String email = String.format("%s@catma.de", username);
String name = String.format("Test User %s", randomUserId);
gitlabManagerPrivileged = new GitlabManagerPrivileged();
String impersonationToken = gitlabManagerPrivileged.acquireImpersonationToken(username, "catma", email, name).getSecond();
EventBus mockEventBus = mock(EventBus.class);
BackgroundService mockBackgroundService = mock(BackgroundService.class);
gitlabManagerRestricted = new GitlabManagerRestricted(mockEventBus, mockBackgroundService, impersonationToken);
}
use of de.catma.backgroundservice.BackgroundService in project catma by forTEXT.
the class GitProjectHandlerTest method create.
@Test
public void create() throws Exception {
try (ILocalGitRepositoryManager jGitRepoManager = new JGitRepoManager(CATMAPropertyKey.GitBasedRepositoryBasePath.getValue(), gitlabManagerRestricted.getUser())) {
directoriesToDeleteOnTearDown.add(jGitRepoManager.getRepositoryBasePath());
BackgroundService mockBackgroundService = mock(BackgroundService.class);
EventBus mockEventBus = mock(EventBus.class);
GitProjectManager gitProjectManager = new GitProjectManager(CATMAPropertyKey.GitBasedRepositoryBasePath.getValue(), gitlabManagerRestricted, // noop deletion handler
(projectId) -> {
}, mockBackgroundService, mockEventBus);
String projectId = gitProjectManager.create("Test CATMA Project", "This is a test CATMA project");
// we don't add the projectId to projectsToDeleteOnTearDown as deletion of the user will take care of that for us
assertNotNull(projectId);
assert projectId.startsWith("CATMA_");
// the JGitRepoManager instance should always be in a detached state after GitProjectManager calls return
assertFalse(jGitRepoManager.isAttached());
String expectedRootRepositoryName = GitProjectManager.getProjectRootRepositoryName(projectId);
File expectedRootRepositoryPath = Paths.get(jGitRepoManager.getRepositoryBasePath().getPath(), projectId, expectedRootRepositoryName).toFile();
assert expectedRootRepositoryPath.exists();
assert expectedRootRepositoryPath.isDirectory();
}
}
use of de.catma.backgroundservice.BackgroundService in project catma by forTEXT.
the class GitSourceDocumentHandlerTest method setUp.
@BeforeEach
public void setUp() throws Exception {
// create a fake CATMA user which we'll use to instantiate GitlabManagerRestricted (using the corresponding impersonation token) & JGitRepoManager
Integer randomUserId = Integer.parseInt(RandomStringUtils.randomNumeric(3));
String username = String.format("testuser-%s", randomUserId);
String email = String.format("%s@catma.de", username);
String name = String.format("Test User %s", randomUserId);
gitlabManagerPrivileged = new GitlabManagerPrivileged();
String impersonationToken = gitlabManagerPrivileged.acquireImpersonationToken(username, "catma", email, name).getSecond();
EventBus mockEventBus = mock(EventBus.class);
BackgroundService mockBackgroundService = mock(BackgroundService.class);
gitlabManagerRestricted = new GitlabManagerRestricted(mockEventBus, mockBackgroundService, impersonationToken);
}
use of de.catma.backgroundservice.BackgroundService in project catma by forTEXT.
the class GitLabServerManagerTest method setUp.
@BeforeEach
public void setUp() throws Exception {
// create a fake CATMA user which we'll use to instantiate GitlabManagerRestricted (using the corresponding impersonation token)
Integer randomUserId = Integer.parseInt(RandomStringUtils.randomNumeric(3));
String username = String.format("testuser-%s", randomUserId);
String email = String.format("%s@catma.de", username);
String name = String.format("Test User %s", randomUserId);
gitlabManagerPrivileged = new GitlabManagerPrivileged();
String impersonationToken = gitlabManagerPrivileged.acquireImpersonationToken(username, "catma", email, name).getSecond();
EventBus mockEventBus = mock(EventBus.class);
BackgroundService mockBackgroundService = mock(BackgroundService.class);
gitlabManagerRestricted = new GitlabManagerRestricted(mockEventBus, mockBackgroundService, impersonationToken);
}
Aggregations