use of de.catma.tag.PropertyDefinition in project catma by forTEXT.
the class TagConflict method createCombinedTagDefinition.
private TagDefinition createCombinedTagDefinition() {
TagDefinition tagDefinition = new TagDefinition(masterTagDefinition);
for (PropertyDefinition devPropertyDef : devTagDefinition.getUserDefinedPropertyDefinitions()) {
PropertyDefinition combinedPropertyDef = tagDefinition.getPropertyDefinitionByUuid(devPropertyDef.getUuid());
if (combinedPropertyDef == null) {
combinedPropertyDef = new PropertyDefinition(devPropertyDef);
tagDefinition.addUserDefinedPropertyDefinition(combinedPropertyDef);
} else {
for (String value : devPropertyDef.getPossibleValueList()) {
if (!combinedPropertyDef.getPossibleValueList().contains(value)) {
combinedPropertyDef.addValue(value);
}
}
}
}
return tagDefinition;
}
use of de.catma.tag.PropertyDefinition in project catma by forTEXT.
the class GraphWorktreeProject method initTagManagerListeners.
private void initTagManagerListeners() {
tagsetDefinitionChangedListener = new PropertyChangeListener() {
public void propertyChange(final PropertyChangeEvent evt) {
if (!tagManagerListenersEnabled) {
return;
}
try {
if (evt.getOldValue() == null) {
// insert
final TagsetDefinition tagsetDefinition = (TagsetDefinition) evt.getNewValue();
addTagsetDefinition(tagsetDefinition);
} else if (evt.getNewValue() == null) {
// delete
final TagsetDefinition tagsetDefinition = (TagsetDefinition) evt.getOldValue();
removeTagsetDefinition(tagsetDefinition);
} else {
// update
final TagsetDefinition tagsetDefinition = (TagsetDefinition) evt.getNewValue();
updateTagsetDefinition(tagsetDefinition);
}
} catch (Exception e) {
propertyChangeSupport.firePropertyChange(RepositoryChangeEvent.exceptionOccurred.name(), null, e);
}
}
};
tagManager.addPropertyChangeListener(TagManagerEvent.tagsetDefinitionChanged, tagsetDefinitionChangedListener);
tagDefinitionChangedListener = new PropertyChangeListener() {
public void propertyChange(final PropertyChangeEvent evt) {
if (!tagManagerListenersEnabled) {
return;
}
try {
if (evt.getOldValue() == null) {
@SuppressWarnings("unchecked") final Pair<TagsetDefinition, TagDefinition> args = (Pair<TagsetDefinition, TagDefinition>) evt.getNewValue();
TagsetDefinition tagsetDefinition = args.getFirst();
TagDefinition tagDefinition = args.getSecond();
addTagDefinition(tagDefinition, tagsetDefinition);
} else if (evt.getNewValue() == null) {
@SuppressWarnings("unchecked") final Pair<TagsetDefinition, TagDefinition> args = (Pair<TagsetDefinition, TagDefinition>) evt.getOldValue();
TagsetDefinition tagsetDefinition = args.getFirst();
TagDefinition tagDefinition = args.getSecond();
removeTagDefinition(tagDefinition, tagsetDefinition);
} else {
TagDefinition tag = (TagDefinition) evt.getNewValue();
TagsetDefinition tagset = (TagsetDefinition) evt.getOldValue();
updateTagDefinition(tag, tagset);
}
} catch (Exception e) {
propertyChangeSupport.firePropertyChange(RepositoryChangeEvent.exceptionOccurred.name(), null, e);
}
}
};
tagManager.addPropertyChangeListener(TagManagerEvent.tagDefinitionChanged, tagDefinitionChangedListener);
userDefinedPropertyChangedListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if (!tagManagerListenersEnabled) {
return;
}
Object oldValue = evt.getOldValue();
Object newValue = evt.getNewValue();
try {
if (oldValue == null) {
// insert
@SuppressWarnings("unchecked") Pair<PropertyDefinition, TagDefinition> newPair = (Pair<PropertyDefinition, TagDefinition>) newValue;
PropertyDefinition propertyDefinition = newPair.getFirst();
TagDefinition tagDefinition = newPair.getSecond();
addPropertyDefinition(propertyDefinition, tagDefinition);
} else if (newValue == null) {
// delete
@SuppressWarnings("unchecked") Pair<PropertyDefinition, Pair<TagDefinition, TagsetDefinition>> oldPair = (Pair<PropertyDefinition, Pair<TagDefinition, TagsetDefinition>>) oldValue;
PropertyDefinition propertyDefinition = oldPair.getFirst();
TagDefinition tagDefinition = oldPair.getSecond().getFirst();
TagsetDefinition tagsetDefinition = oldPair.getSecond().getSecond();
removePropertyDefinition(propertyDefinition, tagDefinition, tagsetDefinition);
} else {
// update
PropertyDefinition propertyDefinition = (PropertyDefinition) evt.getNewValue();
TagDefinition tagDefinition = (TagDefinition) evt.getOldValue();
updatePropertyDefinition(propertyDefinition, tagDefinition);
}
} catch (Exception e) {
propertyChangeSupport.firePropertyChange(RepositoryChangeEvent.exceptionOccurred.name(), null, e);
}
}
};
tagManager.addPropertyChangeListener(TagManagerEvent.userPropertyDefinitionChanged, userDefinedPropertyChangedListener);
}
use of de.catma.tag.PropertyDefinition in project catma by forTEXT.
the class GraphWorktreeProject method importTagsets.
@Override
public void importTagsets(List<TagsetDefinitionImportStatus> tagsetDefinitionImportStatusList) throws IOException {
for (TagsetDefinitionImportStatus tagsetDefinitionImportStatus : tagsetDefinitionImportStatusList) {
if (tagsetDefinitionImportStatus.isDoImport()) {
TagsetDefinition tagset = tagsetDefinitionImportStatus.getTagset();
// new Tagset
if (!tagsetDefinitionImportStatus.isInProjectHistory()) {
try {
tagManagerListenersEnabled = false;
try {
addTagsetDefinition(tagset);
tagManager.addTagsetDefinition(tagset);
} catch (Exception e) {
throw new IOException(String.format("Import of Tagset %1$s failed! The import has been aborted.", tagset.getName()), e);
}
} finally {
tagManagerListenersEnabled = true;
}
for (TagDefinition tag : tagset.getRootTagDefinitions()) {
tagManager.addTagDefinition(tagset, tag);
importTagHierarchy(tag, tagset, tagset);
}
} else // removed, but exists in version history
if (!tagsetDefinitionImportStatus.isCurrent()) {
String oldRootRevisionHash = this.rootRevisionHash;
Pair<TagsetDefinition, String> result = gitProjectHandler.cloneAndAddTagset(tagset.getUuid(), tagset.getName(), String.format("Re-Added Tagset %1$s with ID %2$s", tagset.getName(), tagset.getUuid()));
TagsetDefinition oldTagset = result.getFirst();
this.rootRevisionHash = result.getSecond();
// remove old Tags
for (TagDefinition tagDefinition : oldTagset.getRootTagDefinitions()) {
gitProjectHandler.removeTag(tagDefinition);
oldTagset.remove(tagDefinition);
}
try {
// add empty Tagset
graphProjectHandler.addTagset(this.rootRevisionHash, oldTagset, oldRootRevisionHash);
try {
tagManagerListenersEnabled = false;
tagManager.addTagsetDefinition(tagset);
} finally {
tagManagerListenersEnabled = true;
}
// add imported Tags
for (TagDefinition tag : tagset.getRootTagDefinitions()) {
tagManager.addTagDefinition(oldTagset, tag);
importTagHierarchy(tag, tagset, oldTagset);
}
// update meta data
oldTagset.setName(tagset.getName());
updateTagsetDefinition(oldTagset);
} catch (Exception e) {
throw new IOException(String.format("Import of Tagset %1$s failed! The import has been aborted.", tagset.getName()), e);
}
} else // exists already in project
{
try {
TagsetDefinition existingTagset = getTagManager().getTagLibrary().getTagsetDefinition(tagset.getUuid());
for (TagDefinition incomingTag : tagset) {
if (existingTagset.hasTagDefinition(incomingTag.getUuid())) {
if (tagsetDefinitionImportStatus.passesUpdateFilter(incomingTag.getUuid())) {
TagDefinition existingTag = existingTagset.getTagDefinition(incomingTag.getUuid());
for (PropertyDefinition incomingPropertyDef : incomingTag.getUserDefinedPropertyDefinitions()) {
PropertyDefinition existingPropertyDef = existingTag.getPropertyDefinitionByUuid(incomingPropertyDef.getUuid());
if (existingPropertyDef != null) {
for (String value : incomingPropertyDef.getPossibleValueList()) {
if (!existingPropertyDef.getPossibleValueList().contains(value)) {
existingPropertyDef.addValue(value);
}
}
existingPropertyDef.setName(incomingPropertyDef.getName());
updatePropertyDefinition(existingPropertyDef, existingTag);
} else {
existingTag.addUserDefinedPropertyDefinition(incomingPropertyDef);
}
existingTag.setName(incomingTag.getName());
existingTag.setColor(incomingTag.getColor());
updateTagDefinition(existingTag, existingTagset);
}
}
} else {
getTagManager().addTagDefinition(existingTagset, incomingTag);
}
}
existingTagset.setName(tagset.getName());
updateTagsetDefinition(existingTagset);
} catch (Exception e) {
throw new IOException(String.format("Import of Tagset %1$s failed! The import has been aborted.", tagset.getName()), e);
}
}
}
}
}
use of de.catma.tag.PropertyDefinition in project catma by forTEXT.
the class AnnotationConflictView method createPropertyTreeDataProvider.
private TreeDataProvider<PropertyTreeItem> createPropertyTreeDataProvider(TagInstance tagInstance, TagDefinition tag) {
TreeData<PropertyTreeItem> propertyTreeData = new TreeData<>();
for (Property property : tagInstance.getUserDefinedProperties()) {
PropertyDefinition propertyDef = tag.getPropertyDefinitionByUuid(property.getPropertyDefinitionId());
PropertyDataItem propertyDataItem = new PropertyDataItem(propertyDef, property);
propertyTreeData.addItem(null, propertyDataItem);
for (String value : property.getPropertyValueList()) {
propertyTreeData.addItem(propertyDataItem, new PropertyValueDataItem(property, value));
}
}
TreeDataProvider<PropertyTreeItem> propertyTreeDataProvider = new TreeDataProvider<>(propertyTreeData);
return propertyTreeDataProvider;
}
use of de.catma.tag.PropertyDefinition in project catma by forTEXT.
the class AnnotationPanel method showExpandedProperties.
private void showExpandedProperties(TagDataItem tagDataItem) {
TagDefinition tag = tagDataItem.getTag();
PropertyDataItem lastPropertyDataItem = null;
for (PropertyDefinition propertyDefinition : tag.getUserDefinedPropertyDefinitions()) {
lastPropertyDataItem = new PropertyDataItem(propertyDefinition);
tagsetGrid.getTreeData().addItem(tagDataItem, lastPropertyDataItem);
}
List<TagsetTreeItem> children = tagsetData.getChildren(tagDataItem).stream().filter(tagsetTreeItem -> tagsetTreeItem instanceof TagDataItem).collect(Collectors.toList());
for (int i = children.size() - 1; i >= 0; i--) {
tagsetData.moveAfterSibling(children.get(i), lastPropertyDataItem);
}
tagsetGrid.expand(tagDataItem);
}
Aggregations