Search in sources :

Example 26 with ProjectId

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()));
}
Also used : SendMail(edu.stanford.bmir.protege.web.server.mail.SendMail) LoggerFactory(org.slf4j.LoggerFactory) Inject(javax.inject.Inject) RenderingManager(edu.stanford.bmir.protege.web.server.renderer.RenderingManager) UserId(edu.stanford.bmir.protege.web.shared.user.UserId) AccessManager(edu.stanford.bmir.protege.web.server.access.AccessManager) ProjectDetailsManager(edu.stanford.bmir.protege.web.server.project.ProjectDetailsManager) TemplateObjectsBuilder(edu.stanford.bmir.protege.web.server.templates.TemplateObjectsBuilder) Map(java.util.Map) Nonnull(javax.annotation.Nonnull) FileContents(edu.stanford.bmir.protege.web.server.filemanager.FileContents) UserDetailsManager(edu.stanford.bmir.protege.web.server.user.UserDetailsManager) Logger(org.slf4j.Logger) MessageHeader(edu.stanford.bmir.protege.web.server.mail.MessageHeader) PlaceUrl(edu.stanford.bmir.protege.web.server.app.PlaceUrl) Subject.forUser(edu.stanford.bmir.protege.web.server.access.Subject.forUser) VIEW_PROJECT(edu.stanford.bmir.protege.web.shared.access.BuiltInAction.VIEW_PROJECT) Set(java.util.Set) OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData) ApplicationNameSupplier(edu.stanford.bmir.protege.web.server.app.ApplicationNameSupplier) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) Optional(java.util.Optional) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) ProjectResource.forProject(edu.stanford.bmir.protege.web.server.access.ProjectResource.forProject) TemplateEngine(edu.stanford.bmir.protege.web.server.templates.TemplateEngine) Optional(java.util.Optional) OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData)

Example 27 with ProjectId

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);
}
Also used : Subject(edu.stanford.bmir.protege.web.server.access.Subject) java.util(java.util) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) RoleId(edu.stanford.bmir.protege.web.shared.access.RoleId) Collections.emptySet(java.util.Collections.emptySet) Subject.forUser(edu.stanford.bmir.protege.web.server.access.Subject.forUser) LoggerFactory(org.slf4j.LoggerFactory) PersonId(edu.stanford.bmir.protege.web.shared.sharing.PersonId) SharingSetting(edu.stanford.bmir.protege.web.shared.sharing.SharingSetting) Inject(javax.inject.Inject) UserId(edu.stanford.bmir.protege.web.shared.user.UserId) Collectors.toMap(java.util.stream.Collectors.toMap) AccessManager(edu.stanford.bmir.protege.web.server.access.AccessManager) Subject.forAnySignedInUser(edu.stanford.bmir.protege.web.server.access.Subject.forAnySignedInUser) SharingPermission(edu.stanford.bmir.protege.web.shared.sharing.SharingPermission) HasGetUserIdByUserIdOrEmail(edu.stanford.bmir.protege.web.server.user.HasGetUserIdByUserIdOrEmail) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) ProjectResource(edu.stanford.bmir.protege.web.server.access.ProjectResource) ProjectSharingSettings(edu.stanford.bmir.protege.web.shared.sharing.ProjectSharingSettings) SharingPermission(edu.stanford.bmir.protege.web.shared.sharing.SharingPermission) ProjectSharingSettings(edu.stanford.bmir.protege.web.shared.sharing.ProjectSharingSettings) SharingSetting(edu.stanford.bmir.protege.web.shared.sharing.SharingSetting) ProjectResource(edu.stanford.bmir.protege.web.server.access.ProjectResource) RoleId(edu.stanford.bmir.protege.web.shared.access.RoleId) Subject(edu.stanford.bmir.protege.web.server.access.Subject)

Example 28 with ProjectId

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);
}
Also used : ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) Test(org.junit.Test)

Example 29 with ProjectId

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)));
}
Also used : ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) Test(org.junit.Test)

Example 30 with 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);
}
Also used : CollectionId(edu.stanford.bmir.protege.web.shared.collection.CollectionId) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) CollectionViewPlace(edu.stanford.bmir.protege.web.shared.place.CollectionViewPlace) FormId(edu.stanford.bmir.protege.web.shared.form.FormId) CollectionItem(edu.stanford.bmir.protege.web.shared.collection.CollectionItem) MatchResult(com.google.gwt.regexp.shared.MatchResult)

Aggregations

ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)51 Nonnull (javax.annotation.Nonnull)19 UserId (edu.stanford.bmir.protege.web.shared.user.UserId)16 Inject (javax.inject.Inject)14 AccessManager (edu.stanford.bmir.protege.web.server.access.AccessManager)8 java.util (java.util)7 HasProjectId (edu.stanford.bmir.protege.web.shared.project.HasProjectId)6 Collectors.toList (java.util.stream.Collectors.toList)6 Nullable (javax.annotation.Nullable)6 Test (org.junit.Test)6 Logger (org.slf4j.Logger)6 LoggerFactory (org.slf4j.LoggerFactory)6 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)5 ExecutionContext (edu.stanford.bmir.protege.web.server.dispatch.ExecutionContext)5 Optional (java.util.Optional)5 OWLEntity (org.semanticweb.owlapi.model.OWLEntity)5 Subject.forUser (edu.stanford.bmir.protege.web.server.access.Subject.forUser)4 ProjectDetails (edu.stanford.bmir.protege.web.shared.project.ProjectDetails)4 List (java.util.List)4 ImmutableSet (com.google.common.collect.ImmutableSet)3