use of edu.stanford.bmir.protege.web.shared.project.ProjectDetails in project webprotege by protegeproject.
the class LoadProjectActionHandler method execute.
@Nonnull
@Override
public LoadProjectResult execute(@Nonnull final LoadProjectAction action, @Nonnull ExecutionContext executionContext) {
Stopwatch stopwatch = Stopwatch.createStarted();
logger.info("{} is being loaded due to request by {}", action.getProjectId(), executionContext.getUserId());
projectManager.getProject(action.getProjectId(), executionContext.getUserId());
stopwatch.stop();
logger.info("{} was loaded in {} ms due to request by {}", action.getProjectId(), stopwatch.elapsed(TimeUnit.MILLISECONDS), executionContext.getUserId());
MemoryMonitor memoryMonitor = new MemoryMonitor(logger);
memoryMonitor.monitorMemoryUsage();
memoryMonitor.logMemoryUsage();
final ProjectId projectId = action.getProjectId();
ProjectDetails projectDetails = projectDetailsManager.getProjectDetails(projectId);
if (!executionContext.getUserId().isGuest()) {
userActivityManager.addRecentProject(executionContext.getUserId(), action.getProjectId(), System.currentTimeMillis());
}
return new LoadProjectResult(action.getProjectId(), executionContext.getUserId(), projectDetails);
}
use of edu.stanford.bmir.protege.web.shared.project.ProjectDetails in project webprotege by protegeproject.
the class ProjectDetailsManagerImpl method setProjectSettings.
@Override
public void setProjectSettings(ProjectSettings projectSettings) {
ProjectId projectId = projectSettings.getProjectId();
Optional<ProjectDetails> record = repository.findOne(projectId);
if (!record.isPresent()) {
return;
}
ProjectDetails updatedRecord = record.get().builder().setDisplayName(projectSettings.getProjectDisplayName()).setDescription(projectSettings.getProjectDescription()).build();
repository.save(updatedRecord);
slackWebhookRepository.clearWebhooks(projectId);
String payloadUrl = projectSettings.getSlackIntegrationSettings().getPayloadUrl();
if (!payloadUrl.isEmpty()) {
slackWebhookRepository.addWebhooks(Collections.singletonList(new SlackWebhook(projectId, payloadUrl)));
}
webhookRepository.clearProjectWebhooks(projectId);
List<ProjectWebhook> projectWebhooks = projectSettings.getWebhookSettings().getWebhookSettings().stream().map(s -> new ProjectWebhook(projectId, s.getPayloadUrl(), new ArrayList<ProjectWebhookEventType>(s.getEventTypes()))).collect(toList());
webhookRepository.addProjectWebhooks(projectWebhooks);
}
use of edu.stanford.bmir.protege.web.shared.project.ProjectDetails in project webprotege by protegeproject.
the class ProjectDetailsManagerImpl method registerProject.
@Override
public void registerProject(ProjectId projectId, NewProjectSettings settings) {
long now = System.currentTimeMillis();
ProjectDetails record = new ProjectDetails(projectId, settings.getDisplayName(), settings.getProjectDescription(), settings.getProjectOwner(), false, now, settings.getProjectOwner(), now, settings.getProjectOwner());
repository.save(record);
}
use of edu.stanford.bmir.protege.web.shared.project.ProjectDetails 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.ProjectDetails 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));
}
Aggregations