Search in sources :

Example 1 with ProjectWebhook

use of edu.stanford.bmir.protege.web.shared.webhook.ProjectWebhook 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);
}
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) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) ProjectWebhook(edu.stanford.bmir.protege.web.shared.webhook.ProjectWebhook) SlackWebhook(edu.stanford.bmir.protege.web.shared.webhook.SlackWebhook)

Example 2 with ProjectWebhook

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

the class WebhookRepositoryImpl_IT method setUp.

@Before
public void setUp() throws Exception {
    client = MongoTestUtils.createMongoClient();
    Morphia morphia = MongoTestUtils.createMorphia();
    datastore = morphia.createDatastore(client, MongoTestUtils.getTestDbName());
    repository = new WebhookRepositoryImpl(datastore);
    projectId = ProjectId.get(UUID.randomUUID().toString());
    subscribedToEvents = Collections.singletonList(PROJECT_CHANGED);
    webhook = new ProjectWebhook(projectId, PAYLOAD_URL, subscribedToEvents);
    repository.addProjectWebhooks(Collections.singletonList(webhook));
}
Also used : Morphia(org.mongodb.morphia.Morphia) ProjectWebhook(edu.stanford.bmir.protege.web.shared.webhook.ProjectWebhook) Before(org.junit.Before)

Aggregations

ProjectWebhook (edu.stanford.bmir.protege.web.shared.webhook.ProjectWebhook)2 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 SlackWebhookRepository (edu.stanford.bmir.protege.web.server.webhook.SlackWebhookRepository)1 WebhookRepository (edu.stanford.bmir.protege.web.server.webhook.WebhookRepository)1 NewProjectSettings (edu.stanford.bmir.protege.web.shared.project.NewProjectSettings)1 ProjectDetails (edu.stanford.bmir.protege.web.shared.project.ProjectDetails)1 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)1 UnknownProjectException (edu.stanford.bmir.protege.web.shared.project.UnknownProjectException)1 ProjectSettings (edu.stanford.bmir.protege.web.shared.projectsettings.ProjectSettings)1 SlackIntegrationSettings (edu.stanford.bmir.protege.web.shared.projectsettings.SlackIntegrationSettings)1 WebhookSetting (edu.stanford.bmir.protege.web.shared.projectsettings.WebhookSetting)1 WebhookSettings (edu.stanford.bmir.protege.web.shared.projectsettings.WebhookSettings)1 UserId (edu.stanford.bmir.protege.web.shared.user.UserId)1 ProjectWebhookEventType (edu.stanford.bmir.protege.web.shared.webhook.ProjectWebhookEventType)1 SlackWebhook (edu.stanford.bmir.protege.web.shared.webhook.SlackWebhook)1 java.util (java.util)1 Collectors.toList (java.util.stream.Collectors.toList)1 Inject (javax.inject.Inject)1 Before (org.junit.Before)1 Morphia (org.mongodb.morphia.Morphia)1