use of org.semanticweb.owlapi.model.OWLEntity in project webprotege by protegeproject.
the class HierarchyChangeComputer method prepareForOntologyChanges.
@SuppressWarnings("unchecked")
@Override
public void prepareForOntologyChanges(List<OWLOntologyChange> submittedChanges) {
for (OWLOntologyChange change : submittedChanges) {
for (OWLEntity entity : change.getSignature()) {
if (entity.isType(entityType)) {
final T t = (T) entity;
final Set<T> parentsBefore = hierarchyProvider.getParents(t);
child2ParentMap.putAll(t, parentsBefore);
}
}
}
roots.addAll(hierarchyProvider.getRoots());
}
use of org.semanticweb.owlapi.model.OWLEntity in project webprotege by protegeproject.
the class HierarchyChangeComputer method translateOntologyChanges.
@SuppressWarnings("unchecked")
@Override
public void translateOntologyChanges(Revision revision, ChangeApplicationResult<?> result, List<ProjectEvent<?>> projectEventList) {
Set<T> changeSignature = new HashSet<>();
for (OWLOntologyChange change : result.getChangeList()) {
for (OWLEntity child : change.getSignature()) {
if (child.isType(entityType)) {
final T t = (T) child;
if (!changeSignature.contains(t)) {
changeSignature.add(t);
Set<T> parentsBefore = child2ParentMap.get(t);
Set<T> parentsAfter = hierarchyProvider.getParents(t);
for (T parentBefore : parentsBefore) {
if (!parentsAfter.contains(parentBefore)) {
// Removed
projectEventList.addAll(createRemovedEvents(t, parentBefore));
}
}
for (T parentAfter : parentsAfter) {
if (!parentsBefore.contains(parentAfter)) {
// Added
projectEventList.addAll(createAddedEvents(t, parentAfter));
}
}
}
}
}
}
Set<T> rootsAfter = new HashSet<>(hierarchyProvider.getRoots());
for (T rootAfter : rootsAfter) {
if (!roots.contains(rootAfter)) {
List<GraphModelChange<EntityHierarchyNode>> changes = Collections.singletonList(new AddRootNode<>(new GraphNode<>(renderer.render(rootAfter), hierarchyProvider.getChildren(rootAfter).isEmpty())));
EntityHierarchyChangedEvent event = new EntityHierarchyChangedEvent(projectId, hierarchyId, new GraphModelChangedEvent<>(changes));
projectEventList.add(event);
projectEventList.add(new HierarchyRootAddedEvent<>(projectId, hierarchyId, rootAfter));
}
}
for (T rootBefore : roots) {
if (!rootsAfter.contains(rootBefore)) {
List<GraphModelChange<EntityHierarchyNode>> changes = Collections.singletonList(new RemoveRootNode<>(new GraphNode<>(renderer.render(rootBefore))));
EntityHierarchyChangedEvent event = new EntityHierarchyChangedEvent(projectId, hierarchyId, new GraphModelChangedEvent<>(changes));
projectEventList.add(event);
projectEventList.add(new HierarchyRootRemovedEvent<>(projectId, hierarchyId, rootBefore));
}
}
}
use of org.semanticweb.owlapi.model.OWLEntity in project webprotege by protegeproject.
the class WatchTriggeredHandlerImpl method handleWatchTriggered.
@Override
public void handleWatchTriggered(@Nonnull Set<UserId> usersToNotify, @Nonnull OWLEntity modifiedEntity, @Nonnull UserId byUser) {
List<String> emailAddresses = usersToNotify.stream().filter(u -> accessManager.hasPermission(forUser(u), forProject(projectId), VIEW_PROJECT)).map(userDetailsManager::getEmail).filter(Optional::isPresent).map(Optional::get).distinct().collect(toList());
OWLEntityData modifiedEntityData = renderingManager.getRendering(modifiedEntity);
Map<String, Object> templateObjects = TemplateObjectsBuilder.builder().withUserId(byUser).withEntity(modifiedEntityData).withProjectDetails(projectDetailsManager.getProjectDetails(projectId)).withApplicationName(applicationNameSupplier.get()).withProjectUrl(placeUrl.getProjectUrl(projectId)).build();
String displayName = projectDetailsManager.getProjectDetails(projectId).getDisplayName();
String emailSubject = String.format("[%s] Changes made to %s in %s by %s", displayName, modifiedEntityData.getBrowserText(), displayName, userDetailsManager.getUserDetails(byUser).map(d -> "by " + d.getDisplayName()).orElse(""));
String emailBody = templateEngine.populateTemplate(watchTemplate.getContents(), templateObjects);
logger.info("{} Watch triggered by {} on {}. Notifying {}", projectId, byUser, modifiedEntity, usersToNotify);
sendMail.sendMail(emailAddresses, emailSubject, emailBody, MessageHeader.inReplyTo(projectId.getId()), MessageHeader.references(projectId.getId()));
}
use of org.semanticweb.owlapi.model.OWLEntity in project webprotege by protegeproject.
the class OWLEntityReadConverter_TestCase method shouldReadOWLObjectProperty.
@Test
public void shouldReadOWLObjectProperty() {
when(dbObject.get("type")).thenReturn(EntityType.OBJECT_PROPERTY.getName());
OWLEntity entity = converter.convert(dbObject);
assertThat(entity.isOWLObjectProperty(), is(true));
assertThat(entity.getIRI(), is(iri));
}
use of org.semanticweb.owlapi.model.OWLEntity in project webprotege by protegeproject.
the class OWLEntityReadConverter_TestCase method shouldReadOWLDatatype.
@Test
public void shouldReadOWLDatatype() {
when(dbObject.get("type")).thenReturn(EntityType.DATATYPE.getName());
OWLEntity entity = converter.convert(dbObject);
assertThat(entity.isOWLDatatype(), is(true));
assertThat(entity.getIRI(), is(iri));
}
Aggregations