Skip to content

Commit

Permalink
Merge pull request #129 from eclipse-researchlabs/136-dont-wrap-commi…
Browse files Browse the repository at this point in the history
…tmessage-in-dlemessage

don't wrap CommitMessage in DleMessage
  • Loading branch information
schlotze authored May 23, 2022
2 parents d0a9ace + a6b8623 commit 6d6c424
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package eu.smartclide.contexthandling.dle.listener;

import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeoutException;

/*-
* #%L
* SmartCLIDE Monitoring
Expand All @@ -15,6 +19,10 @@
*/

import com.rabbitmq.client.Channel;

import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.document.Document;

import de.atb.context.monitoring.config.models.datasources.GitlabDataSource;
import de.atb.context.monitoring.config.models.datasources.MessageBrokerDataSourceOptions;
import de.atb.context.monitoring.events.MonitoringProgressListener;
Expand All @@ -24,13 +32,6 @@
import de.atb.context.monitoring.models.IWebService;
import de.atb.context.monitoring.monitors.messagebroker.util.MessageBrokerUtil;
import eu.smartclide.contexthandling.dle.model.CommitMessage;
import eu.smartclide.contexthandling.dle.model.DleMessage;
import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.document.Document;

import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeoutException;

public class DleGitlabCommitMonitorProgressListener
implements MonitoringProgressListener<IWebService, IMonitoringDataModel<?, ?>> {
Expand Down Expand Up @@ -74,27 +75,25 @@ public void documentAnalysed(final List<IMonitoringDataModel<?, ?>> analysed,
.filter(iMonitoringDataModel -> iMonitoringDataModel instanceof GitlabCommitDataModel)
.map(iMonitoringDataModel -> (GitlabCommitDataModel) iMonitoringDataModel)
.flatMap(gitlabCommitDataModel -> gitlabCommitDataModel.getGitlabCommitMessages().stream())
.map(this::convertToDleMessage)
.map(this::convertToCommitMessage)
.forEach(this::send);
}

private DleMessage convertToDleMessage(final GitlabCommitMessage gitlabCommitMessage) {
return DleMessage.builder()
.monitor(CommitMessage.builder()
private CommitMessage convertToCommitMessage(final GitlabCommitMessage gitlabCommitMessage) {
return CommitMessage.builder()
.repoId(gitlabCommitMessage.getRepository())
.user(gitlabCommitMessage.getUser())
.branch(gitlabCommitMessage.getBranch())
.timeSinceLastCommit(gitlabCommitMessage.getTimeSinceLastCommit())
.numberOfFilesModified(gitlabCommitMessage.getNoOfModifiedFiles())
.build())
.numberOfFilesModified(gitlabCommitMessage.getNoOfModifiedFiles())
.build();
}

private void send(final DleMessage dleMessage) {
private void send(final CommitMessage commitMessage) {
if (useTopic) {
MessageBrokerUtil.convertAndSendToTopic(channel, exchange, topic, dleMessage);
MessageBrokerUtil.convertAndSendToTopic(channel, exchange, topic, commitMessage);
} else {
MessageBrokerUtil.convertAndSendToQueue(channel, queue, dleMessage);
MessageBrokerUtil.convertAndSendToQueue(channel, queue, commitMessage);
}
}

Expand Down

This file was deleted.

0 comments on commit 6d6c424

Please sign in to comment.