Search in sources :

Example 1 with Index

use of sonia.scm.search.Index in project scm-review-plugin by scm-manager.

the class CommentIndexer method handleEvent.

@Subscribe
public void handleEvent(CommentEvent event) {
    Comment comment = event.getItem();
    PullRequest pullRequest = event.getPullRequest();
    Repository repository = event.getRepository();
    if (event.getEventType() == HandlerEventType.CREATE || event.getEventType() == HandlerEventType.MODIFY) {
        updateIndexedComment(repository, pullRequest, IndexedComment.transform(pullRequest.getId(), comment));
    } else if (event.getEventType() == HandlerEventType.DELETE) {
        Comment deletedComment = event.getOldItem();
        searchEngine.forType(IndexedComment.class).update(index -> index.delete().byId(createCommentId(deletedComment.getId(), pullRequest.getId(), repository.getId())));
    }
}
Also used : Index(sonia.scm.search.Index) RepositoryImportEvent(sonia.scm.repository.RepositoryImportEvent) RepositoryPermissions(sonia.scm.repository.RepositoryPermissions) IndexLog(sonia.scm.search.IndexLog) Subscribe(com.github.legman.Subscribe) Extension(sonia.scm.plugin.Extension) IndexTask(sonia.scm.search.IndexTask) Repository(sonia.scm.repository.Repository) PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest) Inject(javax.inject.Inject) HandlerEventType(sonia.scm.HandlerEventType) SearchEngine(sonia.scm.search.SearchEngine) RepositoryManager(sonia.scm.repository.RepositoryManager) ServletContextEvent(javax.servlet.ServletContextEvent) SerializableIndexTask(sonia.scm.search.SerializableIndexTask) Optional(java.util.Optional) PermissionCheck(com.cloudogu.scm.review.PermissionCheck) PullRequestService(com.cloudogu.scm.review.pullrequest.service.PullRequestService) Id(sonia.scm.search.Id) IndexLogStore(sonia.scm.search.IndexLogStore) ServletContextListener(javax.servlet.ServletContextListener) Repository(sonia.scm.repository.Repository) PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest) Subscribe(com.github.legman.Subscribe)

Example 2 with Index

use of sonia.scm.search.Index in project scm-review-plugin by scm-manager.

the class CommentIndexer method handleEvent.

@Subscribe
public void handleEvent(ReplyEvent event) {
    Reply comment = event.getItem();
    PullRequest pullRequest = event.getPullRequest();
    Repository repository = event.getRepository();
    if (event.getEventType() == HandlerEventType.CREATE || event.getEventType() == HandlerEventType.MODIFY) {
        updateIndexedComment(repository, pullRequest, IndexedComment.transform(pullRequest.getId(), comment));
    } else if (event.getEventType() == HandlerEventType.DELETE) {
        Reply deletedReply = event.getOldItem();
        searchEngine.forType(IndexedComment.class).update(index -> index.delete().byId(createCommentId(deletedReply.getId(), pullRequest.getId(), repository.getId())));
    }
}
Also used : Index(sonia.scm.search.Index) RepositoryImportEvent(sonia.scm.repository.RepositoryImportEvent) RepositoryPermissions(sonia.scm.repository.RepositoryPermissions) IndexLog(sonia.scm.search.IndexLog) Subscribe(com.github.legman.Subscribe) Extension(sonia.scm.plugin.Extension) IndexTask(sonia.scm.search.IndexTask) Repository(sonia.scm.repository.Repository) PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest) Inject(javax.inject.Inject) HandlerEventType(sonia.scm.HandlerEventType) SearchEngine(sonia.scm.search.SearchEngine) RepositoryManager(sonia.scm.repository.RepositoryManager) ServletContextEvent(javax.servlet.ServletContextEvent) SerializableIndexTask(sonia.scm.search.SerializableIndexTask) Optional(java.util.Optional) PermissionCheck(com.cloudogu.scm.review.PermissionCheck) PullRequestService(com.cloudogu.scm.review.pullrequest.service.PullRequestService) Id(sonia.scm.search.Id) IndexLogStore(sonia.scm.search.IndexLogStore) ServletContextListener(javax.servlet.ServletContextListener) Repository(sonia.scm.repository.Repository) PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest) Subscribe(com.github.legman.Subscribe)

Aggregations

PermissionCheck (com.cloudogu.scm.review.PermissionCheck)2 PullRequest (com.cloudogu.scm.review.pullrequest.service.PullRequest)2 PullRequestService (com.cloudogu.scm.review.pullrequest.service.PullRequestService)2 Subscribe (com.github.legman.Subscribe)2 Optional (java.util.Optional)2 Inject (javax.inject.Inject)2 ServletContextEvent (javax.servlet.ServletContextEvent)2 ServletContextListener (javax.servlet.ServletContextListener)2 HandlerEventType (sonia.scm.HandlerEventType)2 Extension (sonia.scm.plugin.Extension)2 Repository (sonia.scm.repository.Repository)2 RepositoryImportEvent (sonia.scm.repository.RepositoryImportEvent)2 RepositoryManager (sonia.scm.repository.RepositoryManager)2 RepositoryPermissions (sonia.scm.repository.RepositoryPermissions)2 Id (sonia.scm.search.Id)2 Index (sonia.scm.search.Index)2 IndexLog (sonia.scm.search.IndexLog)2 IndexLogStore (sonia.scm.search.IndexLogStore)2 IndexTask (sonia.scm.search.IndexTask)2 SearchEngine (sonia.scm.search.SearchEngine)2