Search in sources :

Example 26 with AnnotationCollectionReference

use of de.catma.document.annotation.AnnotationCollectionReference in project catma by forTEXT.

the class CollectionSelectionStep method initData.

private void initData() throws Exception {
    documentData = new TreeData<>();
    @SuppressWarnings("unchecked") Set<String> documentIds = (Set<String>) context.get(AnnotationWizardContextKey.DOCUMENTIDS);
    for (String documentId : documentIds) {
        SourceDocument srcDoc = project.getSourceDocument(documentId);
        DocumentResource docResource = new DocumentResource(srcDoc, project.getProjectId(), project.hasPermission(project.getRoleForDocument(srcDoc.getUuid()), RBACPermission.DOCUMENT_WRITE));
        if (project.hasPermission(project.getRoleForDocument(srcDoc.getUuid()), RBACPermission.DOCUMENT_READ)) {
            documentData.addItem(null, docResource);
            List<AnnotationCollectionReference> collections = srcDoc.getUserMarkupCollectionRefs();
            List<Resource> readableCollectionResources = collections.stream().map(collectionRef -> (Resource) new CollectionResource(collectionRef, project.getProjectId(), project.hasPermission(project.getRoleForCollection(collectionRef.getId()), RBACPermission.COLLECTION_WRITE))).filter(colRes -> project.hasPermission(project.getRoleForCollection(colRes.getResourceId()), RBACPermission.COLLECTION_WRITE)).collect(Collectors.toList());
            if (!collections.isEmpty()) {
                documentData.addItems(docResource, readableCollectionResources);
            } else {
                // TODO: improve message
                Notification.show("Info", String.format("You do not have a writable Collection available for Document %1$s", srcDoc.toString()), Type.HUMANIZED_MESSAGE);
            }
        }
    }
    documentDataProvider = new TreeDataProvider<Resource>(documentData);
    documentGrid.setDataProvider(documentDataProvider);
}
Also used : Resource(de.catma.ui.module.project.Resource) StepChangeListener(de.catma.ui.dialog.wizard.StepChangeListener) VerticalLayout(com.vaadin.ui.VerticalLayout) UI(com.vaadin.ui.UI) HashMap(java.util.HashMap) WizardContext(de.catma.ui.dialog.wizard.WizardContext) ActionGridComponent(de.catma.ui.component.actiongrid.ActionGridComponent) ProgressStep(de.catma.ui.dialog.wizard.ProgressStep) Function(java.util.function.Function) HashSet(java.util.HashSet) EventBus(com.google.common.eventbus.EventBus) CollectionResource(de.catma.ui.module.project.CollectionResource) Notification(com.vaadin.ui.Notification) ErrorHandler(de.catma.ui.module.main.ErrorHandler) Map(java.util.Map) Label(com.vaadin.ui.Label) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) TreeGridFactory(de.catma.ui.component.TreeGridFactory) Subscribe(com.google.common.eventbus.Subscribe) SaveCancelListener(de.catma.ui.dialog.SaveCancelListener) DocumentResource(de.catma.ui.module.project.DocumentResource) TreeData(com.vaadin.data.TreeData) AnnotationCollectionReference(de.catma.document.annotation.AnnotationCollectionReference) Project(de.catma.project.Project) Set(java.util.Set) ProgressStepFactory(de.catma.ui.dialog.wizard.ProgressStepFactory) TreeGrid(com.vaadin.ui.TreeGrid) SourceDocument(de.catma.document.source.SourceDocument) Collectors(java.util.stream.Collectors) ContextMenu(com.vaadin.contextmenu.ContextMenu) List(java.util.List) Type(com.vaadin.ui.Notification.Type) ChangeType(de.catma.project.event.ChangeType) SerializablePredicate(com.vaadin.server.SerializablePredicate) HierarchicalQuery(com.vaadin.data.provider.HierarchicalQuery) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) SingleTextInputDialog(de.catma.ui.dialog.SingleTextInputDialog) WizardStep(de.catma.ui.dialog.wizard.WizardStep) CollectionChangeEvent(de.catma.project.event.CollectionChangeEvent) SelectionMode(com.vaadin.ui.Grid.SelectionMode) Collections(java.util.Collections) RBACPermission(de.catma.rbac.RBACPermission) CollectionResource(de.catma.ui.module.project.CollectionResource) HashSet(java.util.HashSet) Set(java.util.Set) SourceDocument(de.catma.document.source.SourceDocument) Resource(de.catma.ui.module.project.Resource) CollectionResource(de.catma.ui.module.project.CollectionResource) DocumentResource(de.catma.ui.module.project.DocumentResource) AnnotationCollectionReference(de.catma.document.annotation.AnnotationCollectionReference) DocumentResource(de.catma.ui.module.project.DocumentResource)

Example 27 with AnnotationCollectionReference

use of de.catma.document.annotation.AnnotationCollectionReference in project catma by forTEXT.

the class CollectionSelectionStep method handleCollectionChanged.

@Subscribe
public void handleCollectionChanged(CollectionChangeEvent collectionChangeEvent) {
    if (collectionChangeEvent.getChangeType().equals(ChangeType.CREATED)) {
        AnnotationCollectionReference collectionReference = collectionChangeEvent.getCollectionReference();
        addCollection(collectionReference);
    }
}
Also used : AnnotationCollectionReference(de.catma.document.annotation.AnnotationCollectionReference) Subscribe(com.google.common.eventbus.Subscribe)

Example 28 with AnnotationCollectionReference

use of de.catma.document.annotation.AnnotationCollectionReference in project catma by forTEXT.

the class AnalyzeResourcePanel method handleCollectionChanged.

@SuppressWarnings("unchecked")
@Subscribe
public void handleCollectionChanged(CollectionChangeEvent collectionChangeEvent) {
    if (collectionChangeEvent.getChangeType().equals(ChangeType.CREATED)) {
        SourceDocument document = collectionChangeEvent.getDocument();
        AnnotationCollectionReference collectionReference = collectionChangeEvent.getCollectionReference();
        CollectionDataItem collectionDataItem = new CollectionDataItem(collectionReference, project.hasPermission(project.getRoleForCollection(collectionReference.getId()), RBACPermission.COLLECTION_WRITE));
        documentData.getRootItems().stream().filter(item -> ((DocumentDataItem) item).getDocument().equals(document)).findAny().ifPresent(documentDataItem -> {
            documentData.addItem(documentDataItem, collectionDataItem);
            documentTree.getDataProvider().refreshAll();
        });
        if (isAttached()) {
            documentTree.expand(documentData.getParent(collectionDataItem));
            Notification.show("Info", String.format("Collection %1$s has been created!", collectionReference.toString()), Type.TRAY_NOTIFICATION);
        }
    } else if (collectionChangeEvent.getChangeType().equals(ChangeType.DELETED)) {
        Optional<DocumentTreeItem> optionalDocResource = documentData.getRootItems().stream().filter(item -> ((DocumentDataItem) item).getDocument().equals(collectionChangeEvent.getDocument())).findAny();
        if (optionalDocResource.isPresent()) {
            Optional<DocumentTreeItem> optionalCollectionResource = documentData.getChildren(optionalDocResource.get()).stream().filter(item -> ((CollectionDataItem) item).getCollectionRef().equals(collectionChangeEvent.getCollectionReference())).findAny();
            if (optionalCollectionResource.isPresent()) {
                DocumentTreeItem collectionItem = optionalCollectionResource.get();
                documentData.removeItem(collectionItem);
                documentTree.getDataProvider().refreshAll();
                // selections needs manual update...
                ((SelectionModel.Multi<DocumentTreeItem>) documentTree.getSelectionModel()).updateSelection(Collections.emptySet(), Collections.singleton(collectionItem));
            }
            corpusChangedListener.corpusChanged();
        }
    } else {
        documentTree.getDataProvider().refreshAll();
        corpusChangedListener.corpusChanged();
    }
}
Also used : Optional(java.util.Optional) SourceDocument(de.catma.document.source.SourceDocument) AnnotationCollectionReference(de.catma.document.annotation.AnnotationCollectionReference) SelectionModel(com.vaadin.data.SelectionModel) Subscribe(com.google.common.eventbus.Subscribe)

Example 29 with AnnotationCollectionReference

use of de.catma.document.annotation.AnnotationCollectionReference in project catma by forTEXT.

the class GraphWorktreeProject method commitAllChanges.

private void commitAllChanges(Function<AnnotationCollectionReference, String> collectionCcommitMsgProvider, String projectCommitMsg) throws Exception {
    List<AnnotationCollectionReference> collectionRefs = getSourceDocuments().stream().flatMap(doc -> doc.getUserMarkupCollectionRefs().stream()).collect(Collectors.toList());
    for (AnnotationCollectionReference collectionRef : collectionRefs) {
        gitProjectHandler.addCollectionToStagedAndCommit(collectionRef.getId(), collectionCcommitMsgProvider.apply(collectionRef), false);
    }
    gitProjectHandler.commitProject(projectCommitMsg);
    printStatus();
}
Also used : ArrayListMultimap(com.google.common.collect.ArrayListMultimap) Reply(de.catma.document.comment.Reply) LoadingCache(com.google.common.cache.LoadingCache) Status(org.eclipse.jgit.api.Status) UI(com.vaadin.ui.UI) IndexedProject(de.catma.indexer.IndexedProject) TermExtractor(de.catma.indexer.TermExtractor) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInfoProvider(de.catma.repository.git.graph.FileInfoProvider) ErrorHandler(de.catma.ui.module.main.ErrorHandler) Locale(java.util.Locale) Map(java.util.Map) DocumentChangeEvent(de.catma.project.event.DocumentChangeEvent) URI(java.net.URI) Path(java.nio.file.Path) CommitInfo(de.catma.project.CommitInfo) CATMAPropertyKey(de.catma.properties.CATMAPropertyKey) ExecutionListener(de.catma.backgroundservice.ExecutionListener) Collection(java.util.Collection) Set(java.util.Set) TagInstance(de.catma.tag.TagInstance) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) ProjectReference(de.catma.project.ProjectReference) TagReference(de.catma.document.annotation.TagReference) CacheLoader(com.google.common.cache.CacheLoader) List(java.util.List) PropertyChangeListener(java.beans.PropertyChangeListener) TPGraphProjectHandler(de.catma.repository.git.graph.tp.TPGraphProjectHandler) TagDefinition(de.catma.tag.TagDefinition) CacheBuilder(com.google.common.cache.CacheBuilder) ContentInfoSet(de.catma.document.source.ContentInfoSet) CollectionChangeEvent(de.catma.project.event.CollectionChangeEvent) RBACPermission(de.catma.rbac.RBACPermission) StatusPrinter(de.catma.repository.git.managers.StatusPrinter) PropertyDefinition(de.catma.tag.PropertyDefinition) TagManager(de.catma.tag.TagManager) CommentProvider(de.catma.repository.git.graph.CommentProvider) RBACRole(de.catma.rbac.RBACRole) MediaType(org.apache.tika.mime.MediaType) Multimap(com.google.common.collect.Multimap) Function(java.util.function.Function) User(de.catma.user.User) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) HashSet(java.util.HashSet) EventBus(com.google.common.eventbus.EventBus) CommentChangeEvent(de.catma.project.event.CommentChangeEvent) Comment(de.catma.document.comment.Comment) Charset(java.nio.charset.Charset) TeiTagLibrarySerializationHandler(de.catma.serialization.tei.TeiTagLibrarySerializationHandler) Member(de.catma.user.Member) StandardContentHandler(de.catma.document.source.contenthandler.StandardContentHandler) TagsetDefinition(de.catma.tag.TagsetDefinition) Pair(de.catma.util.Pair) IDGenerator(de.catma.util.IDGenerator) RBACSubject(de.catma.rbac.RBACSubject) TagLibrary(de.catma.tag.TagLibrary) PropertyChangeEvent(java.beans.PropertyChangeEvent) OpenProjectListener(de.catma.project.OpenProjectListener) TeiSerializationHandlerFactory(de.catma.serialization.tei.TeiSerializationHandlerFactory) RemovalNotification(com.google.common.cache.RemovalNotification) ProgressListener(de.catma.backgroundservice.ProgressListener) Property(de.catma.tag.Property) AnnotationCollectionReference(de.catma.document.annotation.AnnotationCollectionReference) TermInfo(de.catma.indexer.TermInfo) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) SourceDocument(de.catma.document.source.SourceDocument) AnnotationCollection(de.catma.document.annotation.AnnotationCollection) File(java.io.File) TagsetDefinitionImportStatus(de.catma.serialization.TagsetDefinitionImportStatus) TagManagerEvent(de.catma.tag.TagManager.TagManagerEvent) TagLibrarySerializationHandler(de.catma.serialization.TagLibrarySerializationHandler) Indexer(de.catma.indexer.Indexer) ChangeType(de.catma.project.event.ChangeType) GraphProjectHandler(de.catma.repository.git.graph.GraphProjectHandler) ReplyChangeEvent(de.catma.project.event.ReplyChangeEvent) Paths(java.nio.file.Paths) PropertyChangeSupport(java.beans.PropertyChangeSupport) RemovalListener(com.google.common.cache.RemovalListener) BackgroundService(de.catma.backgroundservice.BackgroundService) InputStream(java.io.InputStream) TeiUserMarkupCollectionDeserializer(de.catma.serialization.tei.TeiUserMarkupCollectionDeserializer) AnnotationCollectionReference(de.catma.document.annotation.AnnotationCollectionReference)

Example 30 with AnnotationCollectionReference

use of de.catma.document.annotation.AnnotationCollectionReference in project catma by forTEXT.

the class GraphWorktreeProject method printStatus.

@Override
public void printStatus() {
    try {
        Status status = gitProjectHandler.getStatus();
        StatusPrinter.print(projectReference.toString(), status, System.out);
        for (TagsetDefinition tagset : gitProjectHandler.getTagsets()) {
            status = gitProjectHandler.getStatus(tagset);
            StatusPrinter.print("Tagset " + tagset.getName() + " #" + tagset.getUuid(), status, System.out);
        }
        for (AnnotationCollectionReference collectionRef : gitProjectHandler.getDocuments().stream().flatMap(doc -> doc.getUserMarkupCollectionRefs().stream()).collect(Collectors.toList())) {
            status = gitProjectHandler.getStatus(collectionRef);
            StatusPrinter.print("Collection " + collectionRef.toString() + " #" + collectionRef.getId(), status, System.out);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Status(org.eclipse.jgit.api.Status) TagsetDefinitionImportStatus(de.catma.serialization.TagsetDefinitionImportStatus) ArrayListMultimap(com.google.common.collect.ArrayListMultimap) Reply(de.catma.document.comment.Reply) LoadingCache(com.google.common.cache.LoadingCache) Status(org.eclipse.jgit.api.Status) UI(com.vaadin.ui.UI) IndexedProject(de.catma.indexer.IndexedProject) TermExtractor(de.catma.indexer.TermExtractor) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInfoProvider(de.catma.repository.git.graph.FileInfoProvider) ErrorHandler(de.catma.ui.module.main.ErrorHandler) Locale(java.util.Locale) Map(java.util.Map) DocumentChangeEvent(de.catma.project.event.DocumentChangeEvent) URI(java.net.URI) Path(java.nio.file.Path) CommitInfo(de.catma.project.CommitInfo) CATMAPropertyKey(de.catma.properties.CATMAPropertyKey) ExecutionListener(de.catma.backgroundservice.ExecutionListener) Collection(java.util.Collection) Set(java.util.Set) TagInstance(de.catma.tag.TagInstance) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) ProjectReference(de.catma.project.ProjectReference) TagReference(de.catma.document.annotation.TagReference) CacheLoader(com.google.common.cache.CacheLoader) List(java.util.List) PropertyChangeListener(java.beans.PropertyChangeListener) TPGraphProjectHandler(de.catma.repository.git.graph.tp.TPGraphProjectHandler) TagDefinition(de.catma.tag.TagDefinition) CacheBuilder(com.google.common.cache.CacheBuilder) ContentInfoSet(de.catma.document.source.ContentInfoSet) CollectionChangeEvent(de.catma.project.event.CollectionChangeEvent) RBACPermission(de.catma.rbac.RBACPermission) StatusPrinter(de.catma.repository.git.managers.StatusPrinter) PropertyDefinition(de.catma.tag.PropertyDefinition) TagManager(de.catma.tag.TagManager) CommentProvider(de.catma.repository.git.graph.CommentProvider) RBACRole(de.catma.rbac.RBACRole) MediaType(org.apache.tika.mime.MediaType) Multimap(com.google.common.collect.Multimap) Function(java.util.function.Function) User(de.catma.user.User) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) HashSet(java.util.HashSet) EventBus(com.google.common.eventbus.EventBus) CommentChangeEvent(de.catma.project.event.CommentChangeEvent) Comment(de.catma.document.comment.Comment) Charset(java.nio.charset.Charset) TeiTagLibrarySerializationHandler(de.catma.serialization.tei.TeiTagLibrarySerializationHandler) Member(de.catma.user.Member) StandardContentHandler(de.catma.document.source.contenthandler.StandardContentHandler) TagsetDefinition(de.catma.tag.TagsetDefinition) Pair(de.catma.util.Pair) IDGenerator(de.catma.util.IDGenerator) RBACSubject(de.catma.rbac.RBACSubject) TagLibrary(de.catma.tag.TagLibrary) PropertyChangeEvent(java.beans.PropertyChangeEvent) OpenProjectListener(de.catma.project.OpenProjectListener) TeiSerializationHandlerFactory(de.catma.serialization.tei.TeiSerializationHandlerFactory) RemovalNotification(com.google.common.cache.RemovalNotification) ProgressListener(de.catma.backgroundservice.ProgressListener) Property(de.catma.tag.Property) AnnotationCollectionReference(de.catma.document.annotation.AnnotationCollectionReference) TermInfo(de.catma.indexer.TermInfo) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) SourceDocument(de.catma.document.source.SourceDocument) AnnotationCollection(de.catma.document.annotation.AnnotationCollection) File(java.io.File) TagsetDefinitionImportStatus(de.catma.serialization.TagsetDefinitionImportStatus) TagManagerEvent(de.catma.tag.TagManager.TagManagerEvent) TagLibrarySerializationHandler(de.catma.serialization.TagLibrarySerializationHandler) Indexer(de.catma.indexer.Indexer) ChangeType(de.catma.project.event.ChangeType) GraphProjectHandler(de.catma.repository.git.graph.GraphProjectHandler) ReplyChangeEvent(de.catma.project.event.ReplyChangeEvent) Paths(java.nio.file.Paths) PropertyChangeSupport(java.beans.PropertyChangeSupport) RemovalListener(com.google.common.cache.RemovalListener) BackgroundService(de.catma.backgroundservice.BackgroundService) InputStream(java.io.InputStream) TeiUserMarkupCollectionDeserializer(de.catma.serialization.tei.TeiUserMarkupCollectionDeserializer) TagsetDefinition(de.catma.tag.TagsetDefinition) AnnotationCollectionReference(de.catma.document.annotation.AnnotationCollectionReference) IOException(java.io.IOException)

Aggregations

AnnotationCollectionReference (de.catma.document.annotation.AnnotationCollectionReference)34 SourceDocument (de.catma.document.source.SourceDocument)23 List (java.util.List)13 Collectors (java.util.stream.Collectors)13 UI (com.vaadin.ui.UI)12 AnnotationCollection (de.catma.document.annotation.AnnotationCollection)12 ErrorHandler (de.catma.ui.module.main.ErrorHandler)12 HashSet (java.util.HashSet)12 IDGenerator (de.catma.util.IDGenerator)11 IOException (java.io.IOException)11 ArrayList (java.util.ArrayList)11 Collection (java.util.Collection)11 Set (java.util.Set)11 EventBus (com.google.common.eventbus.EventBus)10 Project (de.catma.project.Project)10 ChangeType (de.catma.project.event.ChangeType)10 RBACPermission (de.catma.rbac.RBACPermission)10 TagsetDefinition (de.catma.tag.TagsetDefinition)10 Subscribe (com.google.common.eventbus.Subscribe)9 TagReference (de.catma.document.annotation.TagReference)9