Text Annotations

Hi,

Is there any way to get text annotations of certain task?

Thanks,
Pedro Silva

@pmanu93 refer this post

Getting Name of Element from TextAnnotation

1 Like

OK. Thanks!

Additionally this code would be helpful for you. Value can be retrieved from textAnnotation.getText().getTextContent()

@BeforeClass
  public static void parseModel() {
    modelInstance = Bpmn.readModelFromStream(TextAnnotationTest.class
      .getResourceAsStream("TextAnnotationTest.bpmn"));
  }

  @Test
  public void testGetTextAnnotationsByType() {
    Collection<TextAnnotation> textAnnotations = modelInstance.getModelElementsByType(TextAnnotation.class);
    assertThat(textAnnotations)
      .isNotNull()
      .hasSize(2);
  }

  @Test
  public void testGetTextAnnotationById() {
    TextAnnotation textAnnotation = modelInstance.getModelElementById("textAnnotation2");
    assertThat(textAnnotation).isNotNull();
    assertThat(textAnnotation.getTextFormat()).isEqualTo("text/plain");
    Text text = textAnnotation.getText();
    assertThat(text.getTextContent()).isEqualTo("Attached text annotation");
  }
1 Like