Search in sources :

Example 1 with TagsetDefinition

use of de.catma.tag.TagsetDefinition 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 TagsetDefinition

use of de.catma.tag.TagsetDefinition in project catma by forTEXT.

the class TeiTagLibraryDeserializer method deserialize.

private void deserialize() throws ParseException {
    Nodes tagsetDefinitionElements = teiDocument.getTagsetDefinitionElements();
    for (int i = 0; i < tagsetDefinitionElements.size(); i++) {
        TeiElement tagsetDefinitionElement = (TeiElement) tagsetDefinitionElements.get(i);
        String nValue = tagsetDefinitionElement.getAttributeValue(Attribute.n);
        int dividerPos = nValue.lastIndexOf(' ');
        String tagsetName = nValue.substring(0, dividerPos);
        // version gets ignored, versioning is done via git or not at all!
        // String versionString = nValue.substring(dividerPos+1);
        TagsetDefinition tagsetDefinition = new TagsetDefinition(tagsetDefinitionElement.getID(), tagsetName, new Version());
        tagManager.addTagsetDefinition(tagsetDefinition);
        addTagDefinitions(tagsetDefinition, tagsetDefinitionElement.getChildElements(TeiElementName.fsDecl));
    }
}
Also used : TagsetDefinition(de.catma.tag.TagsetDefinition) Version(de.catma.tag.Version) Nodes(nu.xom.Nodes)

Example 3 with TagsetDefinition

use of de.catma.tag.TagsetDefinition in project catma by forTEXT.

the class XmlMarkupCollectionSerializationHandler method scanElements.

private void scanElements(StringBuilder contentBuilder, Element element, Stack<String> elementStack, TagManager tagManager, TagLibrary tagLibrary, Map<String, String> namespacePrefixToTagsetIdMap, AnnotationCollection userMarkupCollection, String docId, int docLength) throws Exception {
    int start = contentBuilder.length();
    StringBuilder pathBuilder = new StringBuilder();
    for (int j = 0; j < elementStack.size(); j++) {
        pathBuilder.append("/" + elementStack.get(j));
    }
    String parentPath = pathBuilder.toString();
    elementStack.push(element.getLocalName());
    String path = parentPath + "/" + elementStack.peek();
    String tagName = element.getLocalName();
    String prefix = element.getNamespacePrefix();
    String tagsetId = namespacePrefixToTagsetIdMap.get(prefix);
    if (tagsetId == null) {
        tagsetId = KnownTagsetDefinitionName.DEFAULT_INTRINSIC_XML.asTagsetId();
    }
    TagsetDefinition tagset = tagLibrary.getTagsetDefinition(tagsetId);
    String tagId = idGenerator.generate();
    TagDefinition tagDefinition = tagset.getTagDefinitionsByName(tagName).findFirst().orElse(null);
    String pathPropertyDefId = null;
    if (tagDefinition == null) {
        tagDefinition = new TagDefinition(tagId, elementStack.peek(), // no parent, hierarchy is collected in annotation property
        null, tagsetId);
        tagDefinition.addSystemPropertyDefinition(new PropertyDefinition(idGenerator.generate(PropertyDefinition.SystemPropertyName.catma_displaycolor.name()), PropertyDefinition.SystemPropertyName.catma_displaycolor.name(), Collections.singletonList(ColorConverter.toRGBIntAsString(ColorConverter.randomHex()))));
        tagDefinition.addSystemPropertyDefinition(new PropertyDefinition(idGenerator.generate(PropertyDefinition.SystemPropertyName.catma_markupauthor.name()), PropertyDefinition.SystemPropertyName.catma_markupauthor.name(), Collections.singletonList(author)));
        pathPropertyDefId = idGenerator.generate();
        PropertyDefinition pathDef = new PropertyDefinition(pathPropertyDefId, "path", Collections.emptyList());
        tagDefinition.addUserDefinedPropertyDefinition(pathDef);
        tagManager.addTagDefinition(tagset, tagDefinition);
    } else {
        pathPropertyDefId = tagDefinition.getPropertyDefinition("path").getUuid();
    }
    for (int idx = 0; idx < element.getChildCount(); idx++) {
        Node curChild = element.getChild(idx);
        if (curChild instanceof Text) {
            xmlContentHandler.addTextContent(contentBuilder, element, curChild.getValue());
        } else if (curChild instanceof Element) {
            // descent
            scanElements(contentBuilder, (Element) curChild, elementStack, tagManager, tagLibrary, namespacePrefixToTagsetIdMap, userMarkupCollection, docId, docLength);
        }
    }
    if (element.getChildCount() != 0) {
        xmlContentHandler.addBreak(contentBuilder, element);
    }
    int end = contentBuilder.length();
    Range range = new Range(start, end);
    if (range.isSinglePoint()) {
        int newStart = range.getStartPoint();
        if (newStart > 0) {
            newStart = newStart - 1;
        }
        int newEnd = range.getEndPoint();
        if (newEnd < docLength - 1) {
            newEnd = newEnd + 1;
        }
        range = new Range(newStart, newEnd);
    }
    TagInstance tagInstance = new TagInstance(idGenerator.generate(), tagDefinition.getUuid(), author, ZonedDateTime.now().format(DateTimeFormatter.ofPattern(Version.DATETIMEPATTERN)), tagDefinition.getUserDefinedPropertyDefinitions(), tagDefinition.getTagsetDefinitionUuid());
    for (int i = 0; i < element.getAttributeCount(); i++) {
        PropertyDefinition propertyDefinition = tagDefinition.getPropertyDefinition(element.getAttribute(i).getQualifiedName());
        if (propertyDefinition == null) {
            propertyDefinition = new PropertyDefinition(idGenerator.generate(), element.getAttribute(i).getQualifiedName(), Collections.singleton(element.getAttribute(i).getValue()));
            tagManager.addUserDefinedPropertyDefinition(tagDefinition, propertyDefinition);
        } else if (!propertyDefinition.getPossibleValueList().contains(element.getAttribute(i).getValue())) {
            List<String> newValueList = new ArrayList<>();
            newValueList.addAll(propertyDefinition.getPossibleValueList());
            newValueList.add(element.getAttribute(i).getValue());
            propertyDefinition.setPossibleValueList(newValueList);
        }
        Property property = new Property(propertyDefinition.getUuid(), Collections.singleton(element.getAttribute(i).getValue()));
        tagInstance.addUserDefinedProperty(property);
    }
    Property pathProperty = new Property(pathPropertyDefId, Collections.singletonList(path));
    tagInstance.addUserDefinedProperty(pathProperty);
    TagReference tagReference = new TagReference(tagInstance, docId, range, userMarkupCollection.getId());
    userMarkupCollection.addTagReference(tagReference);
    elementStack.pop();
}
Also used : TagDefinition(de.catma.tag.TagDefinition) Node(nu.xom.Node) Element(nu.xom.Element) Text(nu.xom.Text) Range(de.catma.document.Range) PropertyDefinition(de.catma.tag.PropertyDefinition) TagsetDefinition(de.catma.tag.TagsetDefinition) TagInstance(de.catma.tag.TagInstance) ArrayList(java.util.ArrayList) List(java.util.List) TagReference(de.catma.document.annotation.TagReference) Property(de.catma.tag.Property)

Example 4 with TagsetDefinition

use of de.catma.tag.TagsetDefinition 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 5 with TagsetDefinition

use of de.catma.tag.TagsetDefinition in project catma by forTEXT.

the class ProjectView method handleEditTagsetRequest.

private void handleEditTagsetRequest() {
    final Set<TagsetDefinition> tagsets = tagsetGrid.getSelectedItems();
    if (!tagsets.isEmpty()) {
        final TagsetDefinition tagset = tagsets.iterator().next();
        SingleTextInputDialog tagsetNameDlg = new SingleTextInputDialog("Edit Tagset", "Please enter the new Tagset name:", tagset.getName(), new SaveCancelListener<String>() {

            @Override
            public void savePressed(String result) {
                project.getTagManager().setTagsetDefinitionName(tagset, result);
            }
        });
        tagsetNameDlg.show();
    } else {
        Notification.show("Info", "Please select a Tagset first!", Type.HUMANIZED_MESSAGE);
    }
}
Also used : TagsetDefinition(de.catma.tag.TagsetDefinition) SingleTextInputDialog(de.catma.ui.dialog.SingleTextInputDialog)

Aggregations

TagsetDefinition (de.catma.tag.TagsetDefinition)61 IDGenerator (de.catma.util.IDGenerator)31 TagDefinition (de.catma.tag.TagDefinition)27 ArrayList (java.util.ArrayList)27 List (java.util.List)24 UI (com.vaadin.ui.UI)23 ErrorHandler (de.catma.ui.module.main.ErrorHandler)23 Pair (de.catma.util.Pair)23 IOException (java.io.IOException)23 Collection (java.util.Collection)23 Project (de.catma.project.Project)22 PropertyDefinition (de.catma.tag.PropertyDefinition)22 PropertyChangeEvent (java.beans.PropertyChangeEvent)22 PropertyChangeListener (java.beans.PropertyChangeListener)22 Version (de.catma.tag.Version)21 SingleTextInputDialog (de.catma.ui.dialog.SingleTextInputDialog)21 AnnotationCollection (de.catma.document.annotation.AnnotationCollection)20 Collectors (java.util.stream.Collectors)20 TagManagerEvent (de.catma.tag.TagManager.TagManagerEvent)19 Set (java.util.Set)19