Search in sources :

Example 31 with ProjectId

use of edu.stanford.bmir.protege.web.shared.project.ProjectId in project webprotege by protegeproject.

the class LoggedInUserProjectPermissionCheckerImpl method hasPermission.

@Override
public void hasPermission(@Nonnull ActionId actionId, @Nonnull DispatchServiceCallback<Boolean> callback) {
    Optional<ProjectId> projectId = activeProjectManager.getActiveProjectId();
    if (!projectId.isPresent()) {
        callback.onSuccess(false);
        return;
    }
    UserId userId = loggedInUserProvider.getCurrentUserId();
    GWT.log("[LoggedInUserProjectPermissionCheckerImpl] Checking permissions for: " + userId + " on " + projectId.get());
    permissionManager.hasPermissionForProject(userId, actionId, projectId.get(), callback);
}
Also used : UserId(edu.stanford.bmir.protege.web.shared.user.UserId) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId)

Example 32 with ProjectId

use of edu.stanford.bmir.protege.web.shared.project.ProjectId in project webprotege by protegeproject.

the class WebProtegeActivityMapper method getProjectPresenter.

private ProjectPresenter getProjectPresenter(ProjectViewPlace projectViewPlace) {
    if (lastProjectPresenter.isPresent()) {
        ProjectId lastProjectId = lastProjectPresenter.get().getProjectId();
        if (lastProjectId.equals(projectViewPlace.getProjectId()) && lastUser.equals(Optional.of(loggedInUserProvider.getCurrentUserId()))) {
            GWT.log("[WebProtegeActivityMapper] Presenter for place is already being displayed for current user");
            return lastProjectPresenter.get();
        } else {
            GWT.log("[WebProtegeActivityMapper] Different place.  Disposing of previous place.");
            lastProjectPresenter.get().dispose();
        }
    }
    ProjectIdProvider.setProjectId(projectViewPlace.getProjectId());
    GWT.log("[WebProtegeActivityMapper] Instantiating project presenter for " + projectViewPlace.getProjectId());
    ClientProjectComponent projectComponent = applicationComponent.getClientProjectComponent(new ClientProjectModule(projectViewPlace.getProjectId()));
    return projectComponent.getProjectPresenter();
}
Also used : ClientProjectModule(edu.stanford.bmir.protege.web.client.inject.ClientProjectModule) ClientProjectComponent(edu.stanford.bmir.protege.web.client.inject.ClientProjectComponent) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId)

Example 33 with ProjectId

use of edu.stanford.bmir.protege.web.shared.project.ProjectId in project webprotege by protegeproject.

the class ProjectDetailsConverter method fromDocument.

@Override
public ProjectDetails fromDocument(@Nonnull Document document) {
    ProjectId projectId = ProjectId.get(document.getString(PROJECT_ID));
    String displayName = document.getString(DISPLAY_NAME);
    String description = Optional.ofNullable(document.getString(DESCRIPTION)).orElse("");
    UserId owner = UserId.getUserId(document.getString(OWNER));
    boolean inTrash = document.getBoolean(IN_TRASH, false);
    long createdAt = Optional.ofNullable(document.getDate(CREATED_AT)).map(Date::getTime).orElse(0L);
    UserId createdBy = UserId.getUserId(Optional.ofNullable(document.getString(CREATED_BY)).orElse(owner.getUserName()));
    long lastModifiedAt = Optional.ofNullable(document.getDate(MODIFIED_AT)).map(Date::getTime).orElse(0L);
    UserId lastModifiedBy = UserId.getUserId(Optional.ofNullable(document.getString(MODIFIED_BY)).orElse(owner.getUserName()));
    return new ProjectDetails(projectId, displayName, description, owner, inTrash, createdAt, createdBy, lastModifiedAt, lastModifiedBy);
}
Also used : ProjectDetails(edu.stanford.bmir.protege.web.shared.project.ProjectDetails) UserId(edu.stanford.bmir.protege.web.shared.user.UserId) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId)

Example 34 with ProjectId

use of edu.stanford.bmir.protege.web.shared.project.ProjectId in project webprotege by protegeproject.

the class ProjectDetailsManagerImpl method getProjectSettings.

@Override
public ProjectSettings getProjectSettings(ProjectId projectId) throws UnknownProjectException {
    List<SlackWebhook> projectWebhooks = slackWebhookRepository.getWebhooks(projectId);
    String slackPayloadUrl = projectWebhooks.stream().findFirst().map(SlackWebhook::getPayloadUrl).orElse("");
    List<WebhookSetting> webhookSettings = webhookRepository.getProjectWebhooks(projectId).stream().map(wh -> new WebhookSetting(wh.getPayloadUrl(), new LinkedHashSet<ProjectWebhookEventType>(wh.getSubscribedToEvents()))).collect(toList());
    ProjectDetails projectDetails = getProjectDetails(projectId);
    return new ProjectSettings(projectId, projectDetails.getDisplayName(), projectDetails.getDescription(), new SlackIntegrationSettings(slackPayloadUrl), new WebhookSettings(webhookSettings));
}
Also used : UnknownProjectException(edu.stanford.bmir.protege.web.shared.project.UnknownProjectException) WebhookRepository(edu.stanford.bmir.protege.web.server.webhook.WebhookRepository) java.util(java.util) ProjectWebhook(edu.stanford.bmir.protege.web.shared.webhook.ProjectWebhook) SlackIntegrationSettings(edu.stanford.bmir.protege.web.shared.projectsettings.SlackIntegrationSettings) ProjectDetails(edu.stanford.bmir.protege.web.shared.project.ProjectDetails) WebhookSettings(edu.stanford.bmir.protege.web.shared.projectsettings.WebhookSettings) ProjectWebhookEventType(edu.stanford.bmir.protege.web.shared.webhook.ProjectWebhookEventType) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) SlackWebhookRepository(edu.stanford.bmir.protege.web.server.webhook.SlackWebhookRepository) Inject(javax.inject.Inject) UserId(edu.stanford.bmir.protege.web.shared.user.UserId) Collectors.toList(java.util.stream.Collectors.toList) NewProjectSettings(edu.stanford.bmir.protege.web.shared.project.NewProjectSettings) SlackWebhook(edu.stanford.bmir.protege.web.shared.webhook.SlackWebhook) WebhookSetting(edu.stanford.bmir.protege.web.shared.projectsettings.WebhookSetting) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) ProjectSettings(edu.stanford.bmir.protege.web.shared.projectsettings.ProjectSettings) ProjectWebhookEventType(edu.stanford.bmir.protege.web.shared.webhook.ProjectWebhookEventType) ProjectDetails(edu.stanford.bmir.protege.web.shared.project.ProjectDetails) WebhookSettings(edu.stanford.bmir.protege.web.shared.projectsettings.WebhookSettings) SlackWebhook(edu.stanford.bmir.protege.web.shared.webhook.SlackWebhook) WebhookSetting(edu.stanford.bmir.protege.web.shared.projectsettings.WebhookSetting) SlackIntegrationSettings(edu.stanford.bmir.protege.web.shared.projectsettings.SlackIntegrationSettings) NewProjectSettings(edu.stanford.bmir.protege.web.shared.project.NewProjectSettings) ProjectSettings(edu.stanford.bmir.protege.web.shared.projectsettings.ProjectSettings)

Example 35 with ProjectId

use of edu.stanford.bmir.protege.web.shared.project.ProjectId in project webprotege by protegeproject.

the class ResetPerspectiveLayoutActionHandler method execute.

@Nonnull
@Override
public ResetPerspectiveLayoutResult execute(@Nonnull ResetPerspectiveLayoutAction action, @Nonnull ExecutionContext executionContext) {
    ProjectId projectId = action.getProjectId();
    PerspectiveId perspectiveId = action.getPerspectiveId();
    PerspectiveLayout defaultLayout = store.getPerspectiveLayout(projectId, perspectiveId);
    // Only reset the perspective if there is a default for it
    UserId userId = executionContext.getUserId();
    if (defaultLayout.getRootNode().isPresent()) {
        store.clearPerspectiveLayout(projectId, userId, perspectiveId);
    }
    PerspectiveLayout perspectiveLayout = store.getPerspectiveLayout(projectId, userId, perspectiveId);
    return new ResetPerspectiveLayoutResult(perspectiveLayout);
}
Also used : UserId(edu.stanford.bmir.protege.web.shared.user.UserId) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) PerspectiveId(edu.stanford.bmir.protege.web.shared.perspective.PerspectiveId) PerspectiveLayout(edu.stanford.bmir.protege.web.shared.perspective.PerspectiveLayout) ResetPerspectiveLayoutResult(edu.stanford.bmir.protege.web.shared.perspective.ResetPerspectiveLayoutResult) Nonnull(javax.annotation.Nonnull)

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