use of de.catma.document.source.SourceDocument in project catma by forTEXT.
the class GitProjectHandler method getDocuments.
public List<SourceDocument> getDocuments() {
ArrayList<SourceDocument> documents = new ArrayList<>();
try (ILocalGitRepositoryManager localRepoManager = this.localGitRepositoryManager) {
localRepoManager.open(projectId, GitProjectManager.getProjectRootRepositoryName(projectId));
List<Path> paths = localRepoManager.getSubmodulePaths().stream().filter(path -> path != null && path.startsWith(SOURCE_DOCUMENT_SUBMODULES_DIRECTORY_NAME)).map(path -> Paths.get(localRepoManager.getRepositoryWorkTree().toURI()).resolve(path)).collect(Collectors.toList());
localRepoManager.detach();
GitSourceDocumentHandler gitSourceDocumentHandler = new GitSourceDocumentHandler(localRepoManager, this.remoteGitServerManager, this.credentialsProvider);
for (Path sourceDocPath : paths) {
String sourceDocumentId = sourceDocPath.getFileName().toString();
if (hasPermission(getRoleForDocument(sourceDocumentId), RBACPermission.DOCUMENT_READ)) {
try {
documents.add(gitSourceDocumentHandler.open(projectId, sourceDocumentId));
} catch (Exception e) {
logger.log(Level.SEVERE, String.format("error loading Document %1$s for project %2$s", sourceDocPath, projectId), e);
}
}
}
} catch (Exception e) {
logger.log(Level.SEVERE, String.format("error loading Documents for project %1$s", projectId), e);
}
return documents;
}
use of de.catma.document.source.SourceDocument in project catma by forTEXT.
the class GraphLoadJob method call.
@Override
public Pair<TagManager, Graph> call() throws Exception {
getProgressListener().setProgress("Start loading project %1$s...", projectReference.getName());
logger.info("Start loading " + projectReference.getName() + " " + projectReference.getProjectId());
Vertex userV = graph.addVertex(nt(User));
userV.property("userId", user.getIdentifier());
Vertex projectV = graph.addVertex(nt(Project));
projectV.property("propertyId", projectReference.getProjectId());
userV.addEdge(rt(hasProject), projectV);
Vertex projectRevV = graph.addVertex(nt(ProjectRevision));
projectRevV.property("revisionHash", revisionHash);
projectV.addEdge(rt(hasRevision), projectRevV);
List<TagsetDefinition> tagsets = tagsetsSupplier.get();
getProgressListener().setProgress("Loading Tagsets...");
tagManager.load(tagsets);
for (TagsetDefinition tagset : tagsets) {
getProgressListener().setProgress("Indexing Tagset %1$s...", tagset.getName());
Vertex tagsetV = graphWriter.addTagset(projectRevV, tagset);
graphWriter.addHasParentRelations(tagsetV, tagset);
}
final List<SourceDocument> documents = documentsSupplier.get();
for (SourceDocument document : documents) {
getProgressListener().setProgress("Indexing Document %1$s...", document.toString());
graphWriter.addDocument(projectRevV, document);
}
final List<AnnotationCollection> collections = collectionsSupplier.get(tagManager.getTagLibrary());
for (AnnotationCollection collection : collections) {
getProgressListener().setProgress("Indexing Collection %1$s...", collection.toString());
graphWriter.addCollection(revisionHash, revisionHash, collection);
}
getProgressListener().setProgress("Finished loading project %1$s", projectReference.getName());
logger.info("Finished loading " + projectReference.getName() + " " + projectReference.getProjectId());
return new Pair<>(tagManager, graph);
}
use of de.catma.document.source.SourceDocument in project catma by forTEXT.
the class AnnotateResourcePanel method initData.
private void initData(SourceDocument currentlySelectedSourceDocument, Set<String> currentlysSelectedColletionIds) {
try {
documentData = new TreeData<>();
Collection<SourceDocument> documents = project.getSourceDocuments();
final SourceDocument preselection = currentlySelectedSourceDocument;
documentData.addRootItems(documents.stream().map(document -> new DocumentDataItem(document, preselection != null && document.equals(preselection))));
DocumentTreeItem preselectedItem = null;
for (DocumentTreeItem documentDataItem : documentData.getRootItems()) {
if (documentDataItem.isSelected()) {
preselectedItem = documentDataItem;
}
for (AnnotationCollectionReference umcRef : ((DocumentDataItem) documentDataItem).getDocument().getUserMarkupCollectionRefs()) {
documentData.addItem(documentDataItem, new CollectionDataItem(umcRef, project.hasPermission(project.getRoleForCollection(umcRef.getId()), RBACPermission.COLLECTION_WRITE), (currentlysSelectedColletionIds.isEmpty() || currentlysSelectedColletionIds.contains(umcRef.getId()))));
}
}
documentTree.setDataProvider(new TreeDataProvider<>(documentData));
if (preselectedItem != null) {
documentTree.expand(preselectedItem);
}
tagsetData = new ListDataProvider<TagsetDefinition>(project.getTagsets());
tagsetGrid.setDataProvider(tagsetData);
tagsetData.getItems().forEach(tagsetGrid::select);
documentData.getRootItems().stream().filter(documentItem -> documentItem.isSelected()).findAny().ifPresent(documentItem -> documentTree.expand(documentItem));
} catch (Exception e) {
errorHandler.showAndLogError("Error loading data!", e);
}
}
Aggregations