Search in sources :

Example 1 with Project

use of de.catma.project.Project in project catma by forTEXT.

the class ProjectResourceExportApiRequestHandler method serializeProjectResources.

private String serializeProjectResources() {
    try {
        Export export = new Export();
        for (SourceDocument sourceDocument : project.getSourceDocuments()) {
            ArrayList<AnnotationCollection> annotationCollections = new ArrayList<>();
            for (AnnotationCollectionReference annotationCollectionReference : sourceDocument.getUserMarkupCollectionRefs()) {
                annotationCollections.add(project.getUserMarkupCollection(annotationCollectionReference));
            }
            ArrayList<TagDefinition> tagDefinitions = new ArrayList<>();
            ArrayList<TagReference> tagReferences = new ArrayList<>();
            for (AnnotationCollection annotationCollection : annotationCollections) {
                for (TagsetDefinition tagsetDefinition : annotationCollection.getTagLibrary().getTagsetDefinitions()) {
                    tagDefinitions.addAll(tagsetDefinition.stream().collect(Collectors.toList()));
                }
                tagReferences.addAll(annotationCollection.getTagReferences());
            }
            ExportDocument exportDocument = new ExportDocument(new PreApiSourceDocument(sourceDocument, String.format("%s%s/doc/%s", BASE_URL, handlerPath.substring(1), sourceDocument.getUuid().toLowerCase())), tagDefinitions.stream().map(PreApiTagDefinition::new).collect(Collectors.toList()), tagReferences.stream().map((TagReference tagReference) -> {
                try {
                    return new PreApiAnnotation(tagReference, tagDefinitions.stream().filter(td -> td.getUuid().equals(tagReference.getTagDefinitionId())).findFirst().get(), sourceDocument);
                } catch (IOException e) {
                    logger.log(Level.WARNING, String.format("Error serializing TagReference: %s", tagReference), e);
                    return null;
                }
            }).collect(Collectors.toList()));
            export.addExportDocument(exportDocument);
        }
        return new SerializationHelper<Export>().serialize(export);
    } catch (Exception e) {
        logger.log(Level.SEVERE, "Failed to serialize project resources", e);
        return "{\"error\": \"Failed to serialize project resources, please contact CATMA support\"}";
    }
}
Also used : RequestHandler(com.vaadin.server.RequestHandler) ExportDocument(de.catma.api.pre.serialization.models.ExportDocument) VaadinRequest(com.vaadin.server.VaadinRequest) PreApiAnnotation(de.catma.api.pre.serialization.model_wrappers.PreApiAnnotation) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) Export(de.catma.api.pre.serialization.models.Export) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) TagsetDefinition(de.catma.tag.TagsetDefinition) IDGenerator(de.catma.util.IDGenerator) NoSuchElementException(java.util.NoSuchElementException) OutputStream(java.io.OutputStream) PreApiSourceDocument(de.catma.api.pre.serialization.model_wrappers.PreApiSourceDocument) CATMAPropertyKey(de.catma.properties.CATMAPropertyKey) VaadinResponse(com.vaadin.server.VaadinResponse) AnnotationCollectionReference(de.catma.document.annotation.AnnotationCollectionReference) Project(de.catma.project.Project) IOException(java.io.IOException) SourceDocument(de.catma.document.source.SourceDocument) PreApiTagDefinition(de.catma.api.pre.serialization.model_wrappers.PreApiTagDefinition) AnnotationCollection(de.catma.document.annotation.AnnotationCollection) SerializationHelper(de.catma.repository.git.serialization.SerializationHelper) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) TagReference(de.catma.document.annotation.TagReference) VaadinSession(com.vaadin.server.VaadinSession) TagDefinition(de.catma.tag.TagDefinition) PreApiTagDefinition(de.catma.api.pre.serialization.model_wrappers.PreApiTagDefinition) TagDefinition(de.catma.tag.TagDefinition) AnnotationCollection(de.catma.document.annotation.AnnotationCollection) PreApiSourceDocument(de.catma.api.pre.serialization.model_wrappers.PreApiSourceDocument) PreApiSourceDocument(de.catma.api.pre.serialization.model_wrappers.PreApiSourceDocument) SourceDocument(de.catma.document.source.SourceDocument) ArrayList(java.util.ArrayList) AnnotationCollectionReference(de.catma.document.annotation.AnnotationCollectionReference) IOException(java.io.IOException) ExportDocument(de.catma.api.pre.serialization.models.ExportDocument) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) NoSuchElementException(java.util.NoSuchElementException) IOException(java.io.IOException) PreApiTagDefinition(de.catma.api.pre.serialization.model_wrappers.PreApiTagDefinition) TagsetDefinition(de.catma.tag.TagsetDefinition) PreApiAnnotation(de.catma.api.pre.serialization.model_wrappers.PreApiAnnotation) Export(de.catma.api.pre.serialization.models.Export) TagReference(de.catma.document.annotation.TagReference)

Example 2 with Project

use of de.catma.project.Project in project catma by forTEXT.

the class ProjectView method initActions.

private void initActions() {
    documentGridComponent.setSearchFilterProvider(searchInput -> createSearchFilter(searchInput));
    documentGrid.addItemClickListener(itemClickEvent -> handleResourceItemClick(itemClickEvent));
    ContextMenu addContextMenu = documentGridComponent.getActionGridBar().getBtnAddContextMenu();
    MenuItem addDocumentBtn = addContextMenu.addItem("Add Document", clickEvent -> handleAddDocumentRequest());
    addDocumentBtn.setEnabled(false);
    rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> (project.hasPermission(role, RBACPermission.DOCUMENT_CREATE_OR_UPLOAD)), () -> addDocumentBtn.setEnabled(true)));
    MenuItem addCollectionBtn = addContextMenu.addItem("Add Annotation Collection", e -> handleAddCollectionRequest());
    addCollectionBtn.setEnabled(false);
    rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> (project.hasPermission(role, RBACPermission.COLLECTION_CREATE)), () -> addCollectionBtn.setEnabled(true)));
    ContextMenu documentsGridMoreOptionsContextMenu = documentGridComponent.getActionGridBar().getBtnMoreOptionsContextMenu();
    MenuItem editDocBtn = documentsGridMoreOptionsContextMenu.addItem("Edit Documents / Collections", (menuItem) -> handleEditResources());
    editDocBtn.setEnabled(false);
    rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> (project.hasPermission(role, RBACPermission.COLLECTION_DELETE_OR_EDIT) || project.hasPermission(role, RBACPermission.DOCUMENT_DELETE_OR_EDIT)), () -> editDocBtn.setEnabled(true)));
    MenuItem deleteDocsBtn = documentsGridMoreOptionsContextMenu.addItem("Delete Documents / Collections", (menuItem) -> handleDeleteResources(menuItem, documentGrid));
    deleteDocsBtn.setEnabled(false);
    rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> (project.hasPermission(role, RBACPermission.COLLECTION_DELETE_OR_EDIT) || project.hasPermission(role, RBACPermission.DOCUMENT_DELETE_OR_EDIT)), () -> deleteDocsBtn.setEnabled(true)));
    documentsGridMoreOptionsContextMenu.addItem("Analyze Documents / Collections", (menuItem) -> handleAnalyzeResources(menuItem, documentGrid));
    documentsGridMoreOptionsContextMenu.addItem("Import a Collection", mi -> handleImportCollectionRequest());
    MenuItem miExportCollections = documentsGridMoreOptionsContextMenu.addItem("Export Documents & Collections");
    StreamResource collectionXmlExportResource = new StreamResource(new CollectionXMLExportStreamSource(() -> getSelectedDocuments(), () -> documentGrid.getSelectedItems().stream().filter(resource -> resource.isCollection()).map(resource -> ((CollectionResource) resource).getCollectionReference()).collect(Collectors.toList()), () -> project), "CATMA-Corpus_Export-" + LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME) + ".tar.gz");
    collectionXmlExportResource.setCacheTime(0);
    collectionXmlExportResource.setMIMEType("application/gzip");
    FileDownloader collectionXmlExportFileDownloader = new FileDownloader(collectionXmlExportResource);
    collectionXmlExportFileDownloader.extend(miExportCollections);
    documentsGridMoreOptionsContextMenu.addItem("Select filtered entries", mi -> handleSelectFilteredDocuments());
    tagsetGridComponent.getActionGridBar().addBtnAddClickListener(click -> handleAddTagsetRequest());
    tagsetGridComponent.getActionGridBar().setAddBtnEnabled(false);
    rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> project.hasPermission(role, RBACPermission.TAGSET_CREATE_OR_UPLOAD), () -> tagsetGridComponent.getActionGridBar().setAddBtnEnabled(true)));
    ContextMenu moreOptionsMenu = tagsetGridComponent.getActionGridBar().getBtnMoreOptionsContextMenu();
    MenuItem editTagset = moreOptionsMenu.addItem("Edit Tagset", mi -> handleEditTagsetRequest());
    editTagset.setEnabled(false);
    rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> (project.hasPermission(role, RBACPermission.TAGSET_DELETE_OR_EDIT)), () -> editTagset.setEnabled(true)));
    MenuItem deleteTagSetBtn = moreOptionsMenu.addItem("Delete Tagset", mi -> handleDeleteTagsetRequest());
    deleteTagSetBtn.setEnabled(false);
    rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> (project.hasPermission(role, RBACPermission.TAGSET_DELETE_OR_EDIT)), () -> deleteTagSetBtn.setEnabled(true)));
    MenuItem importTagSetBtn = moreOptionsMenu.addItem("Import Tagsets", mi -> handleImportTagsetsRequest());
    importTagSetBtn.setEnabled(false);
    rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> (project.hasPermission(role, RBACPermission.TAGSET_CREATE_OR_UPLOAD)), () -> importTagSetBtn.setEnabled(true)));
    MenuItem miExportTagsets = moreOptionsMenu.addItem("Export Tagsets");
    MenuItem miExportTagsetsAsXML = miExportTagsets.addItem("as XML");
    StreamResource tagsetXmlExportResource = new StreamResource(new TagsetXMLExportStreamSource(() -> tagsetGrid.getSelectedItems(), () -> project), "CATMA-Tag-Library_Export-" + LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME) + ".xml");
    tagsetXmlExportResource.setCacheTime(0);
    tagsetXmlExportResource.setMIMEType("text/xml");
    FileDownloader tagsetXmlExportFileDownloader = new FileDownloader(tagsetXmlExportResource);
    tagsetXmlExportFileDownloader.extend(miExportTagsetsAsXML);
    MenuItem miExportTagsetsAsCSV = miExportTagsets.addItem("as CSV");
    StreamResource tagsetCsvExportResource = new StreamResource(new TagsetCSVExportStreamSource(() -> tagsetGrid.getSelectedItems(), () -> project), "CATMA-Tag-Library_Export-" + LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME) + ".csv");
    tagsetCsvExportResource.setCacheTime(0);
    tagsetCsvExportResource.setMIMEType("text/comma-separated-values");
    FileDownloader tagsetCsvExportFileDownloader = new FileDownloader(tagsetCsvExportResource);
    tagsetCsvExportFileDownloader.extend(miExportTagsetsAsCSV);
    moreOptionsMenu.addItem("Fork Tagsets into another Project", miForkTagset -> handleForkTagsetRequest());
    ContextMenu hugeCardMoreOptions = getMoreOptionsContextMenu();
    hugeCardMoreOptions.addItem("Commit all changes", mi -> handleCommitRequest());
    hugeCardMoreOptions.addItem("Synchronize with the team", mi -> handleSynchronizeRequest());
    hugeCardMoreOptions.addSeparator();
    hugeCardMoreOptions.addItem("Share project resources (experimental API)", mi -> handleShareProjectResources());
    MenuItem miImportCorpus = hugeCardMoreOptions.addItem("Import CATMA 5 Corpus", mi -> handleCorpusImport());
    miImportCorpus.setVisible(CATMAPropertyKey.EXPERT.getValue(false) || Boolean.valueOf(((CatmaApplication) UI.getCurrent()).getParameter(Parameter.EXPERT, Boolean.FALSE.toString())));
    btSynchBell.addClickListener(event -> handleBtSynchBellClick(event));
    // TODO:
    // hugeCardMoreOptions.addItem("Print status", e -> project.printStatus());
    tagsetGridComponent.setSearchFilterProvider(new SearchFilterProvider<TagsetDefinition>() {

        @Override
        public SerializablePredicate<TagsetDefinition> createSearchFilter(final String searchInput) {
            return new SerializablePredicate<TagsetDefinition>() {

                @Override
                public boolean test(TagsetDefinition t) {
                    if (t != null) {
                        String name = t.getName();
                        if (name != null) {
                            return name.toLowerCase().contains(searchInput.toLowerCase());
                        }
                    }
                    return false;
                }
            };
        }
    });
    tagsetGrid.addItemClickListener(clickEvent -> handleTagsetClick(clickEvent));
}
Also used : ArrayListMultimap(com.google.common.collect.ArrayListMultimap) BackgroundServiceProvider(de.catma.backgroundservice.BackgroundServiceProvider) HTMLNotification(de.catma.ui.component.HTMLNotification) Alignment(com.vaadin.ui.Alignment) IndexedProject(de.catma.indexer.IndexedProject) MembersChangedEvent(de.catma.ui.events.MembersChangedEvent) HeaderContextChangeEvent(de.catma.ui.events.HeaderContextChangeEvent) RouteToTagsEvent(de.catma.ui.events.routing.RouteToTagsEvent) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) TagsetImport(de.catma.ui.module.project.documentwizard.TagsetImport) DocumentChangeEvent(de.catma.project.event.DocumentChangeEvent) CorpusImporter(de.catma.ui.module.project.corpusimport.CorpusImporter) CommitInfo(de.catma.project.CommitInfo) ExecutionListener(de.catma.backgroundservice.ExecutionListener) MenuBar(com.vaadin.ui.MenuBar) VerticalFlexLayout(de.catma.ui.layout.VerticalFlexLayout) Set(java.util.Set) RBACConstraint(de.catma.rbac.RBACConstraint) TagInstance(de.catma.tag.TagInstance) CorpusImportDocumentMetadata(de.catma.ui.module.project.corpusimport.CorpusImportDocumentMetadata) ItemClick(com.vaadin.ui.Grid.ItemClick) Stream(java.util.stream.Stream) Type(com.vaadin.ui.Notification.Type) PropertyChangeListener(java.beans.PropertyChangeListener) SingleTextInputDialog(de.catma.ui.dialog.SingleTextInputDialog) CollectionChangeEvent(de.catma.project.event.CollectionChangeEvent) CanReloadAll(de.catma.ui.module.main.CanReloadAll) SelectionMode(com.vaadin.ui.Grid.SelectionMode) DocumentWizard(de.catma.ui.module.project.documentwizard.DocumentWizard) HugeCard(de.catma.ui.component.hugecard.HugeCard) ProjectChangedEvent(de.catma.ui.events.ProjectChangedEvent) DefaultProgressCallable(de.catma.backgroundservice.DefaultProgressCallable) TagManager(de.catma.tag.TagManager) com.vaadin.server(com.vaadin.server) LocalDateTime(java.time.LocalDateTime) WizardContext(de.catma.ui.dialog.wizard.WizardContext) ActionGridComponent(de.catma.ui.component.actiongrid.ActionGridComponent) ArrayList(java.util.ArrayList) Member(de.catma.user.Member) Pair(de.catma.util.Pair) TreeGridFactory(de.catma.ui.component.TreeGridFactory) SaveCancelListener(de.catma.ui.dialog.SaveCancelListener) Collator(java.text.Collator) ProgressListener(de.catma.backgroundservice.ProgressListener) XML2ContentHandler(de.catma.document.source.contenthandler.XML2ContentHandler) Property(de.catma.tag.Property) TreeData(com.vaadin.data.TreeData) IOException(java.io.IOException) SourceDocument(de.catma.document.source.SourceDocument) ProjectReadyEvent(de.catma.project.event.ProjectReadyEvent) AnnotationCollection(de.catma.document.annotation.AnnotationCollection) File(java.io.File) TagManagerEvent(de.catma.tag.TagManager.TagManagerEvent) Button(com.vaadin.ui.Button) ChangeType(de.catma.project.event.ChangeType) CRC32(java.util.zip.CRC32) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) Grid(com.vaadin.ui.Grid) MenuItem(com.vaadin.ui.MenuBar.MenuItem) GenericUploadDialog(de.catma.ui.dialog.GenericUploadDialog) URISyntaxException(java.net.URISyntaxException) UI(com.vaadin.ui.UI) FlexWrap(de.catma.ui.layout.FlexLayout.FlexWrap) ConfirmDialog(org.vaadin.dialogs.ConfirmDialog) SearchFilterProvider(de.catma.ui.component.actiongrid.SearchFilterProvider) RouteToAnalyzeEvent(de.catma.ui.events.routing.RouteToAnalyzeEvent) TikaContentHandler(de.catma.document.source.contenthandler.TikaContentHandler) ByteArrayInputStream(java.io.ByteArrayInputStream) HorizontalFlexLayout(de.catma.ui.layout.HorizontalFlexLayout) ErrorHandler(de.catma.ui.module.main.ErrorHandler) Locale(java.util.Locale) CatmaApplication(de.catma.ui.CatmaApplication) VaadinIcons(com.vaadin.icons.VaadinIcons) Version(de.catma.tag.Version) RouteToConflictedProjectEvent(de.catma.ui.events.routing.RouteToConflictedProjectEvent) ProgressBar(com.vaadin.ui.ProgressBar) IconButton(de.catma.ui.component.IconButton) CATMAPropertyKey(de.catma.properties.CATMAPropertyKey) Collection(java.util.Collection) TreeGrid(com.vaadin.ui.TreeGrid) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) SourceDocumentInfo(de.catma.document.source.SourceDocumentInfo) ProjectReference(de.catma.project.ProjectReference) TagReference(de.catma.document.annotation.TagReference) List(java.util.List) CloseSafe(de.catma.util.CloseSafe) Corpus(de.catma.document.corpus.Corpus) TagDefinition(de.catma.tag.TagDefinition) RBACConstraintEnforcer(de.catma.rbac.RBACConstraintEnforcer) RouteToAnnotateEvent(de.catma.ui.events.routing.RouteToAnnotateEvent) Optional(java.util.Optional) FileType(de.catma.document.source.FileType) RBACPermission(de.catma.rbac.RBACPermission) CorpusImportDialog(de.catma.ui.module.project.corpusimport.CorpusImportDialog) ProjectManager(de.catma.project.ProjectManager) PropertyDefinition(de.catma.tag.PropertyDefinition) UploadFile(de.catma.ui.module.project.documentwizard.UploadFile) RBACRole(de.catma.rbac.RBACRole) Multimap(com.google.common.collect.Multimap) Function(java.util.function.Function) User(de.catma.user.User) Level(java.util.logging.Level) HashSet(java.util.HashSet) EventBus(com.google.common.eventbus.EventBus) Charset(java.nio.charset.Charset) Notification(com.vaadin.ui.Notification) Label(com.vaadin.ui.Label) TagsetDefinition(de.catma.tag.TagsetDefinition) IDGenerator(de.catma.util.IDGenerator) Subscribe(com.google.common.eventbus.Subscribe) TagLibrary(de.catma.tag.TagLibrary) PropertyChangeEvent(java.beans.PropertyChangeEvent) OpenProjectListener(de.catma.project.OpenProjectListener) ListDataProvider(com.vaadin.data.provider.ListDataProvider) FileOSType(de.catma.document.source.FileOSType) ClickEvent(com.vaadin.ui.Button.ClickEvent) AnnotationCollectionReference(de.catma.document.annotation.AnnotationCollectionReference) Project(de.catma.project.Project) RepositoryChangeEvent(de.catma.project.Project.RepositoryChangeEvent) ConflictedProject(de.catma.project.conflict.ConflictedProject) TagsetDefinitionImportStatus(de.catma.serialization.TagsetDefinitionImportStatus) ContextMenu(com.vaadin.contextmenu.ContextMenu) SourceContentHandler(de.catma.document.source.contenthandler.SourceContentHandler) TagsetImportState(de.catma.ui.module.project.documentwizard.TagsetImportState) BOMFilterInputStream(de.catma.document.source.contenthandler.BOMFilterInputStream) DateTimeFormatter(java.time.format.DateTimeFormatter) HierarchicalQuery(com.vaadin.data.provider.HierarchicalQuery) Parameter(de.catma.ui.Parameter) Comparator(java.util.Comparator) Collections(java.util.Collections) BackgroundService(de.catma.backgroundservice.BackgroundService) InputStream(java.io.InputStream) Component(com.vaadin.ui.Component) ContextMenu(com.vaadin.contextmenu.ContextMenu) MenuItem(com.vaadin.ui.MenuBar.MenuItem) TagsetDefinition(de.catma.tag.TagsetDefinition)

Example 3 with Project

use of de.catma.project.Project in project catma by forTEXT.

the class ProjectView method reloadProject.

/**
 * @param projectReference
 */
public void reloadProject(ProjectReference projectReference) {
    if (this.project == null) {
        setProjectReference(projectReference);
    } else {
        setEnabled(false);
        setProgressBarVisible(true);
        final UI ui = UI.getCurrent();
        this.project.open(new OpenProjectListener() {

            @Override
            public void progress(String msg, Object... params) {
                ui.access(() -> {
                    if (params != null) {
                        progressBar.setCaption(String.format(msg, params));
                    } else {
                        progressBar.setCaption(msg);
                    }
                    ui.push();
                });
            }

            @Override
            public void ready(Project project) {
                setProgressBarVisible(false);
                ProjectView.this.project = project;
                ProjectView.this.project.addPropertyChangeListener(RepositoryChangeEvent.exceptionOccurred, projectExceptionListener);
                ProjectView.this.project.getTagManager().addPropertyChangeListener(TagManagerEvent.tagsetDefinitionChanged, tagsetChangeListener);
                ProjectView.this.project.addPropertyChangeListener(RepositoryChangeEvent.tagReferencesChanged, tagReferencesChangedListener);
                setEnabled(true);
                reloadAll();
                checkForUnsynchronizedCommits();
            }

            @Override
            public void conflictResolutionNeeded(ConflictedProject conflictedProject) {
                setProgressBarVisible(false);
                setEnabled(true);
                eventBus.post(new RouteToConflictedProjectEvent(conflictedProject));
            }

            @Override
            public void failure(Throwable t) {
                setProgressBarVisible(false);
                setEnabled(true);
                errorHandler.showAndLogError("error opening project", t);
            }
        });
    }
}
Also used : IndexedProject(de.catma.indexer.IndexedProject) Project(de.catma.project.Project) ConflictedProject(de.catma.project.conflict.ConflictedProject) UI(com.vaadin.ui.UI) OpenProjectListener(de.catma.project.OpenProjectListener) ConflictedProject(de.catma.project.conflict.ConflictedProject) RouteToConflictedProjectEvent(de.catma.ui.events.routing.RouteToConflictedProjectEvent)

Example 4 with Project

use of de.catma.project.Project in project catma by forTEXT.

the class ProjectView method buildResourceDataProvider.

private TreeDataProvider<Resource> buildResourceDataProvider() throws Exception {
    if (project != null) {
        TreeData<Resource> treeData = new TreeData<>();
        Collection<SourceDocument> srcDocs = project.getSourceDocuments();
        Locale locale = Locale.getDefault();
        for (SourceDocument srcDoc : srcDocs) {
            locale = srcDoc.getSourceContentHandler().getSourceDocumentInfo().getIndexInfoSet().getLocale();
            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)) {
                treeData.addItem(null, docResource);
                List<AnnotationCollectionReference> collections = srcDoc.getUserMarkupCollectionRefs();
                List<Resource> readableCollectionResources = collections.stream().filter(collectionRef -> project.hasPermission(project.getRoleForCollection(collectionRef.getId()), RBACPermission.COLLECTION_READ)).map(collectionRef -> new CollectionResource(collectionRef, project.getProjectId(), project.hasPermission(project.getRoleForCollection(collectionRef.getId()), RBACPermission.COLLECTION_WRITE))).collect(Collectors.toList());
                if (!collections.isEmpty()) {
                    treeData.addItems(docResource, readableCollectionResources);
                }
            }
        }
        Collator collator = Collator.getInstance(locale);
        collator.setStrength(Collator.PRIMARY);
        documentGrid.getColumn(DocumentGridColumn.NAME.name()).setComparator((r1, r2) -> collator.compare(r1.getName(), r2.getName()));
        tagsetGrid.getColumn(TagsetGridColumn.NAME.name()).setComparator((t1, t2) -> collator.compare(t1.getName(), t2.getName()));
        return new TreeDataProvider<>(treeData);
    }
    return new TreeDataProvider<>(new TreeData<>());
}
Also used : Locale(java.util.Locale) ArrayListMultimap(com.google.common.collect.ArrayListMultimap) BackgroundServiceProvider(de.catma.backgroundservice.BackgroundServiceProvider) HTMLNotification(de.catma.ui.component.HTMLNotification) Alignment(com.vaadin.ui.Alignment) IndexedProject(de.catma.indexer.IndexedProject) MembersChangedEvent(de.catma.ui.events.MembersChangedEvent) HeaderContextChangeEvent(de.catma.ui.events.HeaderContextChangeEvent) RouteToTagsEvent(de.catma.ui.events.routing.RouteToTagsEvent) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) TagsetImport(de.catma.ui.module.project.documentwizard.TagsetImport) DocumentChangeEvent(de.catma.project.event.DocumentChangeEvent) CorpusImporter(de.catma.ui.module.project.corpusimport.CorpusImporter) CommitInfo(de.catma.project.CommitInfo) ExecutionListener(de.catma.backgroundservice.ExecutionListener) MenuBar(com.vaadin.ui.MenuBar) VerticalFlexLayout(de.catma.ui.layout.VerticalFlexLayout) Set(java.util.Set) RBACConstraint(de.catma.rbac.RBACConstraint) TagInstance(de.catma.tag.TagInstance) CorpusImportDocumentMetadata(de.catma.ui.module.project.corpusimport.CorpusImportDocumentMetadata) ItemClick(com.vaadin.ui.Grid.ItemClick) Stream(java.util.stream.Stream) Type(com.vaadin.ui.Notification.Type) PropertyChangeListener(java.beans.PropertyChangeListener) SingleTextInputDialog(de.catma.ui.dialog.SingleTextInputDialog) CollectionChangeEvent(de.catma.project.event.CollectionChangeEvent) CanReloadAll(de.catma.ui.module.main.CanReloadAll) SelectionMode(com.vaadin.ui.Grid.SelectionMode) DocumentWizard(de.catma.ui.module.project.documentwizard.DocumentWizard) HugeCard(de.catma.ui.component.hugecard.HugeCard) ProjectChangedEvent(de.catma.ui.events.ProjectChangedEvent) DefaultProgressCallable(de.catma.backgroundservice.DefaultProgressCallable) TagManager(de.catma.tag.TagManager) com.vaadin.server(com.vaadin.server) LocalDateTime(java.time.LocalDateTime) WizardContext(de.catma.ui.dialog.wizard.WizardContext) ActionGridComponent(de.catma.ui.component.actiongrid.ActionGridComponent) ArrayList(java.util.ArrayList) Member(de.catma.user.Member) Pair(de.catma.util.Pair) TreeGridFactory(de.catma.ui.component.TreeGridFactory) SaveCancelListener(de.catma.ui.dialog.SaveCancelListener) Collator(java.text.Collator) ProgressListener(de.catma.backgroundservice.ProgressListener) XML2ContentHandler(de.catma.document.source.contenthandler.XML2ContentHandler) Property(de.catma.tag.Property) TreeData(com.vaadin.data.TreeData) IOException(java.io.IOException) SourceDocument(de.catma.document.source.SourceDocument) ProjectReadyEvent(de.catma.project.event.ProjectReadyEvent) AnnotationCollection(de.catma.document.annotation.AnnotationCollection) File(java.io.File) TagManagerEvent(de.catma.tag.TagManager.TagManagerEvent) Button(com.vaadin.ui.Button) ChangeType(de.catma.project.event.ChangeType) CRC32(java.util.zip.CRC32) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) Grid(com.vaadin.ui.Grid) MenuItem(com.vaadin.ui.MenuBar.MenuItem) GenericUploadDialog(de.catma.ui.dialog.GenericUploadDialog) URISyntaxException(java.net.URISyntaxException) UI(com.vaadin.ui.UI) FlexWrap(de.catma.ui.layout.FlexLayout.FlexWrap) ConfirmDialog(org.vaadin.dialogs.ConfirmDialog) SearchFilterProvider(de.catma.ui.component.actiongrid.SearchFilterProvider) RouteToAnalyzeEvent(de.catma.ui.events.routing.RouteToAnalyzeEvent) TikaContentHandler(de.catma.document.source.contenthandler.TikaContentHandler) ByteArrayInputStream(java.io.ByteArrayInputStream) HorizontalFlexLayout(de.catma.ui.layout.HorizontalFlexLayout) ErrorHandler(de.catma.ui.module.main.ErrorHandler) Locale(java.util.Locale) CatmaApplication(de.catma.ui.CatmaApplication) VaadinIcons(com.vaadin.icons.VaadinIcons) Version(de.catma.tag.Version) RouteToConflictedProjectEvent(de.catma.ui.events.routing.RouteToConflictedProjectEvent) ProgressBar(com.vaadin.ui.ProgressBar) IconButton(de.catma.ui.component.IconButton) CATMAPropertyKey(de.catma.properties.CATMAPropertyKey) Collection(java.util.Collection) TreeGrid(com.vaadin.ui.TreeGrid) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) SourceDocumentInfo(de.catma.document.source.SourceDocumentInfo) ProjectReference(de.catma.project.ProjectReference) TagReference(de.catma.document.annotation.TagReference) List(java.util.List) CloseSafe(de.catma.util.CloseSafe) Corpus(de.catma.document.corpus.Corpus) TagDefinition(de.catma.tag.TagDefinition) RBACConstraintEnforcer(de.catma.rbac.RBACConstraintEnforcer) RouteToAnnotateEvent(de.catma.ui.events.routing.RouteToAnnotateEvent) Optional(java.util.Optional) FileType(de.catma.document.source.FileType) RBACPermission(de.catma.rbac.RBACPermission) CorpusImportDialog(de.catma.ui.module.project.corpusimport.CorpusImportDialog) ProjectManager(de.catma.project.ProjectManager) PropertyDefinition(de.catma.tag.PropertyDefinition) UploadFile(de.catma.ui.module.project.documentwizard.UploadFile) RBACRole(de.catma.rbac.RBACRole) Multimap(com.google.common.collect.Multimap) Function(java.util.function.Function) User(de.catma.user.User) Level(java.util.logging.Level) HashSet(java.util.HashSet) EventBus(com.google.common.eventbus.EventBus) Charset(java.nio.charset.Charset) Notification(com.vaadin.ui.Notification) Label(com.vaadin.ui.Label) TagsetDefinition(de.catma.tag.TagsetDefinition) IDGenerator(de.catma.util.IDGenerator) Subscribe(com.google.common.eventbus.Subscribe) TagLibrary(de.catma.tag.TagLibrary) PropertyChangeEvent(java.beans.PropertyChangeEvent) OpenProjectListener(de.catma.project.OpenProjectListener) ListDataProvider(com.vaadin.data.provider.ListDataProvider) FileOSType(de.catma.document.source.FileOSType) ClickEvent(com.vaadin.ui.Button.ClickEvent) AnnotationCollectionReference(de.catma.document.annotation.AnnotationCollectionReference) Project(de.catma.project.Project) RepositoryChangeEvent(de.catma.project.Project.RepositoryChangeEvent) ConflictedProject(de.catma.project.conflict.ConflictedProject) TagsetDefinitionImportStatus(de.catma.serialization.TagsetDefinitionImportStatus) ContextMenu(com.vaadin.contextmenu.ContextMenu) SourceContentHandler(de.catma.document.source.contenthandler.SourceContentHandler) TagsetImportState(de.catma.ui.module.project.documentwizard.TagsetImportState) BOMFilterInputStream(de.catma.document.source.contenthandler.BOMFilterInputStream) DateTimeFormatter(java.time.format.DateTimeFormatter) HierarchicalQuery(com.vaadin.data.provider.HierarchicalQuery) Parameter(de.catma.ui.Parameter) Comparator(java.util.Comparator) Collections(java.util.Collections) BackgroundService(de.catma.backgroundservice.BackgroundService) InputStream(java.io.InputStream) Component(com.vaadin.ui.Component) SourceDocument(de.catma.document.source.SourceDocument) AnnotationCollectionReference(de.catma.document.annotation.AnnotationCollectionReference) Collator(java.text.Collator) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) TreeData(com.vaadin.data.TreeData)

Example 5 with Project

use of de.catma.project.Project in project catma by forTEXT.

the class ProjectView method synchronizeProject.

private void synchronizeProject() throws Exception {
    setProgressBarVisible(true);
    final UI ui = UI.getCurrent();
    project.synchronizeWithRemote(new OpenProjectListener() {

        @Override
        public void progress(String msg, Object... params) {
            ui.access(() -> {
                if (params != null) {
                    progressBar.setCaption(String.format(msg, params));
                } else {
                    progressBar.setCaption(msg);
                }
                ui.push();
            });
        }

        @Override
        public void ready(Project project) {
            setProgressBarVisible(false);
            reloadAll();
            setEnabled(true);
            Notification.show("Info", "Your Project has been synchronized!", Type.HUMANIZED_MESSAGE);
            checkForUnsynchronizedCommits();
        }

        @Override
        public void conflictResolutionNeeded(ConflictedProject conflictedProject) {
            setProgressBarVisible(false);
            setEnabled(true);
            eventBus.post(new RouteToConflictedProjectEvent(conflictedProject));
        }

        @Override
        public void failure(Throwable t) {
            setProgressBarVisible(false);
            setEnabled(true);
            errorHandler.showAndLogError("error opening project", t);
        }
    });
}
Also used : IndexedProject(de.catma.indexer.IndexedProject) Project(de.catma.project.Project) ConflictedProject(de.catma.project.conflict.ConflictedProject) UI(com.vaadin.ui.UI) OpenProjectListener(de.catma.project.OpenProjectListener) ConflictedProject(de.catma.project.conflict.ConflictedProject) RouteToConflictedProjectEvent(de.catma.ui.events.routing.RouteToConflictedProjectEvent)

Aggregations

Project (de.catma.project.Project)36 UI (com.vaadin.ui.UI)26 SourceDocument (de.catma.document.source.SourceDocument)23 IDGenerator (de.catma.util.IDGenerator)22 Collectors (java.util.stream.Collectors)22 TagDefinition (de.catma.tag.TagDefinition)21 ErrorHandler (de.catma.ui.module.main.ErrorHandler)21 List (java.util.List)21 Notification (com.vaadin.ui.Notification)20 Type (com.vaadin.ui.Notification.Type)20 ArrayList (java.util.ArrayList)20 Set (java.util.Set)20 Collection (java.util.Collection)19 HtmlRenderer (com.vaadin.ui.renderers.HtmlRenderer)18 AnnotationCollectionReference (de.catma.document.annotation.AnnotationCollectionReference)18 EventBus (com.google.common.eventbus.EventBus)17 ContextMenu (com.vaadin.contextmenu.ContextMenu)17 Label (com.vaadin.ui.Label)17 RBACPermission (de.catma.rbac.RBACPermission)17 ActionGridComponent (de.catma.ui.component.actiongrid.ActionGridComponent)17