use of org.semanticweb.owlapi.model.OWLEntity in project webprotege by protegeproject.
the class EntityDiscussionThreadRepository_IT method shouldReplaceEntity.
@Test
public void shouldReplaceEntity() {
OWLEntity theReplacement = MockingUtils.mockOWLClass();
repository.replaceEntity(projectId, entity, theReplacement);
List<EntityDiscussionThread> threads = repository.findThreads(projectId, theReplacement);
assertThat(threads.size(), is(1));
}
use of org.semanticweb.owlapi.model.OWLEntity in project webprotege by protegeproject.
the class OWLEntityReadConverter_TestCase method shouldReadOWLNamedIndividual.
@Test
public void shouldReadOWLNamedIndividual() {
when(dbObject.get("type")).thenReturn(EntityType.NAMED_INDIVIDUAL.getName());
OWLEntity entity = converter.convert(dbObject);
assertThat(entity.isOWLNamedIndividual(), is(true));
assertThat(entity.getIRI(), is(iri));
}
use of org.semanticweb.owlapi.model.OWLEntity in project webprotege by protegeproject.
the class TagsManager method setProjectTags.
/**
* Sets the tags for the project that this manager is associated with.
*/
public void setProjectTags(@Nonnull Collection<TagData> newProjectTags) {
checkNotNull(newProjectTags);
Collection<Tag> currentProjectTags = getProjectTags();
Set<OWLEntity> modifiedEntityTags = new HashSet<>();
try {
writeLock.lock();
projectTags = null;
Set<TagId> tagIds = newProjectTags.stream().map(TagData::getTagId).filter(Optional::isPresent).map(Optional::get).collect(toSet());
// Remove current tags
currentProjectTags.stream().map(Tag::getTagId).peek(tagId -> {
if (!tagIds.contains(tagId)) {
// Record modified entity tags
entityTagsRepository.findByTagId(tagId).stream().map(EntityTags::getEntity).forEach(modifiedEntityTags::add);
// Remove tag from entity
entityTagsRepository.removeTag(projectId, tagId);
}
}).forEach(tagRepository::deleteTag);
// Set fresh tags
List<Tag> tags = newProjectTags.stream().map(tagData -> new Tag(tagData.getTagId().orElse(createTagId()), projectId, tagData.getLabel(), tagData.getDescription(), tagData.getColor(), tagData.getBackgroundColor())).peek(tag -> {
// Find the modified entities for this tag
entityTagsRepository.findByTagId(tag.getTagId()).stream().map(EntityTags::getEntity).forEach(modifiedEntityTags::add);
}).collect(toList());
tagRepository.saveTags(tags);
} finally {
writeLock.unlock();
}
Set<Tag> oldProjectTags = new HashSet<>(currentProjectTags);
Set<Tag> projectTags = new HashSet<>(getProjectTags());
if (!oldProjectTags.equals(projectTags)) {
List<ProjectEvent<?>> events = new ArrayList<>();
for (OWLEntity entity : modifiedEntityTags) {
EntityTagsChangedEvent event = new EntityTagsChangedEvent(projectId, entity, getTags(entity));
events.add(event);
}
events.add(new ProjectTagsChangedEvent(projectId, projectTags));
eventBus.postEvents(events);
}
}
use of org.semanticweb.owlapi.model.OWLEntity in project webprotege by protegeproject.
the class GetEntityTagsActionHandler method execute.
@Nonnull
@Override
public GetEntityTagsResult execute(@Nonnull GetEntityTagsAction action, @Nonnull ExecutionContext executionContext) {
ProjectId projectId = action.getProjectId();
OWLEntity entity = action.getEntity();
return new GetEntityTagsResult(tagsManager.getTags(entity), tagsManager.getProjectTags());
}
use of org.semanticweb.owlapi.model.OWLEntity in project webprotege by protegeproject.
the class CSVImportViewImpl method getImportDescriptor.
@Override
public Optional<CSVImportDescriptor> getImportDescriptor() {
List<CSVColumnDescriptor> columnDescriptors = new ArrayList<CSVColumnDescriptor>();
for (int rowIndex = 0; rowIndex < flexTable.getRowCount(); rowIndex++) {
CSVColumnRelationEditorViewImpl relView = (CSVColumnRelationEditorViewImpl) flexTable.getWidget(rowIndex, 1);
if (!relView.getProperty().isPresent()) {
continue;
}
if (!relView.getColumnType().isPresent()) {
continue;
}
final OWLEntity columnProperty = (OWLEntity) relView.getProperty().get().getObject();
final ColumnType columnType = relView.getColumnType().get();
CSVColumnDescriptor csvColumnDescriptor = CSVColumnDescriptor.create(rowIndex, columnProperty, columnType);
columnDescriptors.add(csvColumnDescriptor);
}
return Optional.of(new CSVImportDescriptor(CSVRowImportType.values()[importTypeField.getSelectedIndex()], displayNameField.getSelectedIndex(), columnDescriptors));
}
Aggregations