use of de.catma.tag.PropertyDefinition in project catma by forTEXT.
the class EditAnnotationPropertiesDialog method createComponents.
private void createComponents(Project project) {
propertyTabSheet = new TabSheet();
propertyTabSheet.setSizeFull();
String tagId = annotation.getTagInstance().getTagDefinitionId();
TagDefinition tag = project.getTagManager().getTagLibrary().getTagDefinition(tagId);
for (PropertyDefinition propertyDef : tag.getUserDefinedPropertyDefinitions()) {
Property property = annotation.getTagInstance().getUserDefinedPropetyByUuid(propertyDef.getUuid());
if (property == null) {
property = new Property(propertyDef.getUuid(), Collections.emptySet());
}
propertyTabSheet.addTab(new EditPropertyTab(property, propertyDef.getPossibleValueList()), propertyDef.getName());
}
}
use of de.catma.tag.PropertyDefinition in project catma by forTEXT.
the class AnnotationDetailsPanel method addAnnotation.
public void addAnnotation(Annotation annotation) throws IOException {
Optional<AnnotationDataItem> optionalItem = findAnnotationDataItem(annotation.getTagInstance().getUuid());
if (optionalItem.isPresent() && isAttached()) {
annotationDetailsTree.collapse(annotationDetailData.getRootItems());
annotationDetailsTree.select(optionalItem.get());
annotationDetailsTree.expand(optionalItem.get());
int itemIdx = annotationDetailData.getRootItems().indexOf(optionalItem.get());
if (itemIdx >= 0) {
annotationDetailsTree.scrollTo(itemIdx, ScrollDestination.START);
}
} else {
AnnotationDataItem annotationDataItem = new AnnotationDataItem(annotation, project.getTagManager().getTagLibrary().getTagsetDefinition(annotation.getTagInstance().getTagsetId()), kwicProvider, project.hasPermission(project.getRoleForCollection(annotation.getUserMarkupCollection().getId()), RBACPermission.COLLECTION_WRITE), () -> isCurrentEditedCollection.apply(annotation.getUserMarkupCollection().getUuid()));
annotationDetailsTree.collapse(annotationDetailData.getRootItems());
annotationDetailData.addItem(null, annotationDataItem);
String tagId = annotation.getTagInstance().getTagDefinitionId();
for (Property property : annotation.getTagInstance().getUserDefinedProperties()) {
TagDefinition tag = project.getTagManager().getTagLibrary().getTagDefinition(tagId);
if (tag != null) {
// may be deleted already
PropertyDefinition propertyDef = tag.getPropertyDefinitionByUuid(property.getPropertyDefinitionId());
if (propertyDef != null) {
// may be deleted already
AnnotationPropertyDataItem propertyDataItem = new AnnotationPropertyDataItem(property, () -> propertyDef.getName());
annotationDetailData.addItem(annotationDataItem, propertyDataItem);
for (String value : property.getPropertyValueList()) {
AnnotationPropertyValueDataItem valueDataItem = new AnnotationPropertyValueDataItem(value);
annotationDetailData.addItem(propertyDataItem, valueDataItem);
}
}
}
}
annotationDetailsProvider.refreshAll();
if (isAttached()) {
List<AnnotationTreeItem> items = new ArrayList<>();
items.add(annotationDataItem);
items.addAll(annotationDetailData.getChildren(annotationDataItem));
annotationDetailsTree.expand(items);
annotationDetailsTree.select(annotationDataItem);
int itemIdx = annotationDetailData.getRootItems().size() - 1;
if (itemIdx >= 0) {
annotationDetailsTree.scrollTo(itemIdx, ScrollDestination.START);
}
}
}
}
use of de.catma.tag.PropertyDefinition in project catma by forTEXT.
the class AnnotationPanel method handleSingleEditProperties.
private void handleSingleEditProperties(List<PropertyDefinition> editedPropertyDefs, TagDefinition tag) {
TagsetDefinition tagset = project.getTagManager().getTagLibrary().getTagsetDefinition(tag);
for (PropertyDefinition existingPropertyDef : new ArrayList<>(tag.getUserDefinedPropertyDefinitions())) {
// handle deleted PropertyDefs
if (!editedPropertyDefs.contains(existingPropertyDef)) {
project.getTagManager().removeUserDefinedPropertyDefinition(existingPropertyDef, tag, tagset);
} else // handle updated PropertyDefs
{
editedPropertyDefs.stream().filter(possiblyChangedPd -> possiblyChangedPd.getUuid().equals(existingPropertyDef.getUuid())).findFirst().ifPresent(editedPropertyDef -> {
existingPropertyDef.setName(editedPropertyDef.getName());
existingPropertyDef.setPossibleValueList(editedPropertyDef.getPossibleValueList());
});
project.getTagManager().updateUserDefinedPropertyDefinition(tag, existingPropertyDef);
}
}
// handle created PropertyDefs
for (PropertyDefinition pd : editedPropertyDefs) {
if (tag.getPropertyDefinitionByUuid(pd.getUuid()) == null) {
PropertyDefinition createdPropertyDefinition = new PropertyDefinition(pd);
pd.setUuid(idGenerator.generate());
project.getTagManager().addUserDefinedPropertyDefinition(tag, createdPropertyDefinition);
}
}
}
use of de.catma.tag.PropertyDefinition in project catma by forTEXT.
the class PropertySelectionStep method setTag.
public void setTag(TagDefinition tag) {
propertyTabSheet.removeAllComponents();
for (PropertyDefinition propertyDef : tag.getUserDefinedPropertyDefinitions()) {
Property property = new Property(propertyDef.getUuid(), Collections.emptySet());
EditPropertyTab editPropertyTab = new EditPropertyTab(property, propertyDef.getPossibleValueList());
editPropertyTab.addSelectionListener(event -> handleSelection());
propertyTabSheet.addTab(editPropertyTab, propertyDef.getName());
}
}
use of de.catma.tag.PropertyDefinition in project catma by forTEXT.
the class JsonLdWebAnnotationTest method toTagReferenceList.
@Test
public void toTagReferenceList() throws Exception {
try (JGitRepoManager jGitRepoManager = new JGitRepoManager(this.catmaProperties.getProperty(RepositoryPropertyKey.GitBasedRepositoryBasePath.name()), this.catmaUser)) {
this.directoriesToDeleteOnTearDown.add(jGitRepoManager.getRepositoryBasePath());
// TODO: test with a hierarchy of tag definitions
HashMap<String, Object> getJsonLdWebAnnotationResult = JsonLdWebAnnotationTest.getJsonLdWebAnnotation(jGitRepoManager, this.gitLabServerManager, this.catmaUser);
JsonLdWebAnnotation jsonLdWebAnnotation = (JsonLdWebAnnotation) getJsonLdWebAnnotationResult.get("jsonLdWebAnnotation");
this.projectsToDeleteOnTearDown.add((String) getJsonLdWebAnnotationResult.get("projectUuid"));
assertNotNull(jsonLdWebAnnotation);
List<TagReference> tagReferences = jsonLdWebAnnotation.toTagReferenceList((String) getJsonLdWebAnnotationResult.get("projectUuid"), (String) getJsonLdWebAnnotationResult.get("userMarkupCollectionUuid"), jGitRepoManager, this.gitLabServerManager);
assertEquals(2, tagReferences.size());
for (TagReference tagReference : tagReferences) {
TagDefinition tagDefinition = tagReference.getTagDefinition();
TagInstance tagInstance = tagReference.getTagInstance();
assertEquals(getJsonLdWebAnnotationResult.get("tagsetDefinitionUuid"), tagDefinition.getTagsetDefinitionUuid());
assertEquals(getJsonLdWebAnnotationResult.get("tagDefinitionUuid"), tagDefinition.getUuid());
assertEquals("TAG_DEF", tagDefinition.getName());
assertEquals("", tagDefinition.getParentUuid());
PropertyDefinition[] systemPropertyDefinitions = tagDefinition.getSystemPropertyDefinitions().toArray(new PropertyDefinition[0]);
assertEquals(1, systemPropertyDefinitions.length);
assertEquals(getJsonLdWebAnnotationResult.get("systemPropertyDefinitionUuid"), systemPropertyDefinitions[0].getName());
assertEquals("catma_displaycolor", systemPropertyDefinitions[0].getName());
List<String> possibleSystemPropertyValues = systemPropertyDefinitions[0].getPossibleValueList();
assertEquals(2, possibleSystemPropertyValues.size());
assertArrayEquals(new String[] { "SYSPROP_VAL_1", "SYSPROP_VAL_2" }, possibleSystemPropertyValues.toArray(new String[0]));
PropertyDefinition[] userPropertyDefinitions = tagDefinition.getUserDefinedPropertyDefinitions().toArray(new PropertyDefinition[0]);
assertEquals(1, userPropertyDefinitions.length);
assertEquals(getJsonLdWebAnnotationResult.get("userPropertyDefinitionUuid"), userPropertyDefinitions[0].getName());
assertEquals("UPROP_DEF", userPropertyDefinitions[0].getName());
List<String> possibleUserPropertyValues = userPropertyDefinitions[0].getPossibleValueList();
assertEquals(2, possibleUserPropertyValues.size());
assertArrayEquals(new String[] { "UPROP_VAL_1", "UPROP_VAL_2" }, possibleUserPropertyValues.toArray(new String[0]));
assertEquals(getJsonLdWebAnnotationResult.get("tagInstanceUuid"), tagInstance.getUuid());
Property[] systemProperties = tagInstance.getSystemProperties().toArray(new Property[0]);
assertEquals(1, systemProperties.length);
assertEquals(systemPropertyDefinitions[0], systemProperties[0].getPropertyDefinition());
List<String> systemPropertyValues = systemProperties[0].getPropertyValueList();
assertEquals(1, systemPropertyValues.size());
assertEquals("SYSPROP_VAL_1", systemPropertyValues.get(0));
Property[] userProperties = tagInstance.getUserDefinedProperties().toArray(new Property[0]);
assertEquals(1, userProperties.length);
assertEquals(userPropertyDefinitions[0], userProperties[0].getPropertyDefinition());
List<String> userPropertyValues = userProperties[0].getPropertyValueList();
assertEquals(1, userPropertyValues.size());
assertEquals("UPROP_VAL_2", userPropertyValues.get(0));
}
assertEquals(new URI(String.format("http://catma.de/gitlab/%s/%s/%s", getJsonLdWebAnnotationResult.get("projectRootRepositoryName"), GitProjectHandler.SOURCE_DOCUMENT_SUBMODULES_DIRECTORY_NAME, getJsonLdWebAnnotationResult.get("sourceDocumentUuid"))), tagReferences.get(0).getTarget());
assertEquals(new Range(12, 18), tagReferences.get(0).getRange());
assertEquals(new URI(String.format("http://catma.de/gitlab/%s/%s/%s", getJsonLdWebAnnotationResult.get("projectRootRepositoryName"), GitProjectHandler.SOURCE_DOCUMENT_SUBMODULES_DIRECTORY_NAME, getJsonLdWebAnnotationResult.get("sourceDocumentUuid"))), tagReferences.get(1).getTarget());
assertEquals(new Range(41, 47), tagReferences.get(1).getRange());
}
}
Aggregations