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);
}
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();
}
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);
}
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));
}
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);
}
Aggregations