use of edu.stanford.bmir.protege.web.shared.webhook.ProjectWebhookEventType 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.webhook.ProjectWebhookEventType 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