Search in sources :

Example 1 with DiscussionRecord

use of org.guvnor.common.services.shared.metadata.model.DiscussionRecord in project kie-wb-common by kiegroup.

the class DiscussionWidgetPresenter method setContent.

public void setContent(Metadata metadata) {
    view.clear();
    this.metadata = metadata;
    for (DiscussionRecord record : metadata.getDiscussion()) {
        view.addRow(record);
    }
    view.scrollToBottom();
}
Also used : DiscussionRecord(org.guvnor.common.services.shared.metadata.model.DiscussionRecord)

Example 2 with DiscussionRecord

use of org.guvnor.common.services.shared.metadata.model.DiscussionRecord in project kie-wb-common by kiegroup.

the class DiscussionWidgetPresenterTest method testInit.

@Test
public void testInit() throws Exception {
    Metadata metadata = new Metadata();
    metadata.getDiscussion().add(new DiscussionRecord(1234, "Toni", "Knock Knock"));
    metadata.getDiscussion().add(new DiscussionRecord(1235, "Michael", "Who is there?"));
    metadata.getDiscussion().add(new DiscussionRecord(1236, "Toni", "Can't think of anything funny :("));
    DiscussionWidgetPresenter presenter = new DiscussionWidgetPresenter(view, identity, appConfigService);
    presenter.setContent(metadata);
    ArgumentCaptor<DiscussionRecord> discussionRecordArgumentCaptor = ArgumentCaptor.forClass(DiscussionRecord.class);
    verify(view, times(3)).addRow(discussionRecordArgumentCaptor.capture());
    assertComment(discussionRecordArgumentCaptor.getAllValues().get(0), 1234, "Toni", "Knock Knock");
    assertComment(discussionRecordArgumentCaptor.getAllValues().get(1), 1235, "Michael", "Who is there?");
    assertComment(discussionRecordArgumentCaptor.getAllValues().get(2), 1236, "Toni", "Can't think of anything funny :(");
}
Also used : Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) DiscussionRecord(org.guvnor.common.services.shared.metadata.model.DiscussionRecord) DiscussionWidgetPresenter(org.kie.workbench.common.widgets.client.discussion.DiscussionWidgetPresenter) Test(org.junit.Test)

Example 3 with DiscussionRecord

use of org.guvnor.common.services.shared.metadata.model.DiscussionRecord in project kie-wb-common by kiegroup.

the class KieService method fireMetadataSocialEvents.

protected void fireMetadataSocialEvents(final Path path, final Metadata currentMetadata, final Metadata newMetadata) {
    List<DiscussionRecord> newDiscussion = newMetadata != null ? newMetadata.getDiscussion() : null;
    List<DiscussionRecord> currentDiscussion = currentMetadata != null ? currentMetadata.getDiscussion() : null;
    if (newDiscussion != null && newDiscussion.size() > 0) {
        for (DiscussionRecord newRecord : newDiscussion) {
            if (newRecord != null && (currentDiscussion == null || !currentDiscussion.contains(newRecord))) {
                commentAddedEvent.fire(new CommentAddedEvent(newRecord.getAuthor(), path, newRecord.getNote(), newRecord.getTimestamp()));
            }
        }
    }
}
Also used : CommentAddedEvent(org.kie.workbench.common.services.shared.discussion.CommentAddedEvent) DiscussionRecord(org.guvnor.common.services.shared.metadata.model.DiscussionRecord)

Example 4 with DiscussionRecord

use of org.guvnor.common.services.shared.metadata.model.DiscussionRecord in project kie-wb-common by kiegroup.

the class CommentLinePresenterTest method testVisualization.

@Test
public void testVisualization() {
    CommentLineView view = mock(CommentLineView.class);
    CommentLinePresenter presenter = new CommentLinePresenterWithNOGWTCode(view);
    Date commentDate = new Date();
    DiscussionRecord record = new DiscussionRecord(commentDate.getTime(), "test user", "test note");
    presenter.setRecord(record);
    verify(view, times(1)).setAuthor(eq(expectedAuthorFormat("test user")));
    verify(view, times(1)).setComment(eq(expectedCommentFormat("test note")));
    verify(view, times(1)).setDate(expectedDateFormat(commentDate.getTime()));
}
Also used : DiscussionRecord(org.guvnor.common.services.shared.metadata.model.DiscussionRecord) Date(java.util.Date) Test(org.junit.Test)

Example 5 with DiscussionRecord

use of org.guvnor.common.services.shared.metadata.model.DiscussionRecord in project kie-wb-common by kiegroup.

the class DiscussionWidgetPresenter method onAddComment.

@Override
public void onAddComment(final String comment) {
    if (comment != null && !comment.trim().isEmpty()) {
        appConfigService.call(new RemoteCallback<Long>() {

            @Override
            public void callback(Long timestamp) {
                DiscussionRecord record = new DiscussionRecord(timestamp, identity.getIdentifier(), comment);
                metadata.getDiscussion().add(record);
                view.addRow(record);
                view.clearCommentBox();
                view.scrollToBottom();
            }
        }).getTimestamp();
    }
}
Also used : DiscussionRecord(org.guvnor.common.services.shared.metadata.model.DiscussionRecord) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Aggregations

DiscussionRecord (org.guvnor.common.services.shared.metadata.model.DiscussionRecord)6 Test (org.junit.Test)3 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)2 DiscussionWidgetPresenter (org.kie.workbench.common.widgets.client.discussion.DiscussionWidgetPresenter)2 Date (java.util.Date)1 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)1 CommentAddedEvent (org.kie.workbench.common.services.shared.discussion.CommentAddedEvent)1 DiscussionWidgetView (org.kie.workbench.common.widgets.client.discussion.DiscussionWidgetView)1 Path (org.uberfire.backend.vfs.Path)1