use of edu.stanford.bmir.protege.web.shared.project.ProjectId 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 edu.stanford.bmir.protege.web.shared.project.ProjectId in project webprotege by protegeproject.
the class ProjectSharingSettingsManagerImpl method getProjectSharingSettings.
@Override
public ProjectSharingSettings getProjectSharingSettings(ProjectId projectId) {
List<SharingSetting> sharingSettings = new ArrayList<>();
ProjectResource projectResource = new ProjectResource(projectId);
Collection<Subject> subjects = accessManager.getSubjectsWithAccessToResource(projectResource);
subjects.stream().filter(s -> !s.isGuest()).filter(s -> s.getUserName().isPresent()).map(s -> UserId.getUserId(s.getUserName().get())).forEach(u -> {
Collection<RoleId> roles = accessManager.getAssignedRoles(Subject.forUser(u), projectResource);
Roles.toSharingPermission(roles).ifPresent(p -> sharingSettings.add(new SharingSetting(PersonId.of(u), p)));
});
Collection<RoleId> signedInUserRoles = accessManager.getAssignedRoles(forAnySignedInUser(), projectResource);
Optional<SharingPermission> linkSharing = Roles.toSharingPermission(signedInUserRoles);
return new ProjectSharingSettings(projectId, linkSharing, sharingSettings);
}
use of edu.stanford.bmir.protege.web.shared.project.ProjectId in project webprotege by protegeproject.
the class ProjectIdWriteConverterTestCase method convertShouldReturnSuppliedId.
@Test
public void convertShouldReturnSuppliedId() {
ProjectIdWriteConverter converter = new ProjectIdWriteConverter();
String suppliedId = UUID.randomUUID().toString();
ProjectId projectId = ProjectId.get(suppliedId);
String convertedId = converter.convert(projectId);
assertEquals(suppliedId, convertedId);
}
use of edu.stanford.bmir.protege.web.shared.project.ProjectId in project webprotege by protegeproject.
the class FileDownloadParametersTestCase method shouldParseOntologyId.
@Test
public void shouldParseOntologyId() {
ProjectId projectId = ProjectId.get("00000000-0000-0000-0000-000000000000");
when(servletRequest.getParameter(ProjectDownloadConstants.PROJECT)).thenReturn(projectId.getId());
assertThat(parameters.getProjectId(), is(equalTo(projectId)));
}
use of edu.stanford.bmir.protege.web.shared.project.ProjectId in project webprotege by protegeproject.
the class CollectionViewPlaceTokenizer method getPlace.
@Override
public CollectionViewPlace getPlace(String token) {
MatchResult result = regExp.exec(token);
ProjectId projectId = ProjectId.get(result.getGroup(1));
CollectionId collectionId = CollectionId.get(result.getGroup(2));
FormId formId = new FormId(result.getGroup(3));
String selectionString = result.getGroup(5);
GWT.log("[CollectionViewPlaceTokenizer] Selection string: " + selectionString);
Optional<CollectionItem> selection = Optional.ofNullable(selectionString).map(CollectionItem::get);
return new CollectionViewPlace(projectId, collectionId, formId, selection);
}
Aggregations