Class AnnotationService

java.lang.Object
io.skipcheck.tm1.client.service.annotation.AnnotationService

public final class AnnotationService extends Object
Annotations: comments on cube cells, as Planning Analytics Workspace makes them, and the application context facets that tie them to cubes.

What TM1 (11.8) does here that you might not expect:

  • GET Annotations lists none, even with annotations made. They're found by cube (cubeAnnotations(String, ODataQuery)), by cell (cellAnnotations(String, long, ODataQuery)), or by ID.
  • An annotation's ApplicationContext reads back empty, though the facet value given when it was made exists (facetValues(String, ODataQuery)).
  • Besides Text, an annotation carries properties $metadata doesn't declare (Annotation is an open type): objectName (the cube), commentValue, commentType and commentLocation (the cell's elements, comma-separated). They're in dynamicProperties.
  • IDs look like C}ClientGroups~B.B~7uA_4TxLwG.

Comment on a cell:

// A comment on one cell, as Planning Analytics Workspace makes it: the cell's
// elements by dimension, in the cube's dimension order
Map<String, String> cell = new LinkedHashMap<>();
cell.put("Version", "Forecast");
cell.put("Region", "North");
cell.put("Measure", "Amount");
return tm1.annotations().create("Sales", cell, "Includes the March promotion");

Read a cube's comments:

// GET Annotations lists none on TM1 11.8, so read them by cube
return tm1.annotations()
	.cubeAnnotations("Sales", ODataQuery.none())
	.map(annotation -> annotation.creator() + ": " + annotation.text());

Change what a comment says:

// TM1 keeps Text and the commentValue PAW shows apart, so change both
String text = "Includes the March and April promotions";
return tm1.annotations()
	.update(id, AnnotationPatch.builder().text(text).property("commentValue", text).build());
  • Constructor Details

    • AnnotationService

      public AnnotationService(Tm1Session session)
      A service sending its requests through session.
      Parameters:
      session - the session
  • Method Details

    • list

      @Tm1Endpoint("EntitySet Annotations") public reactor.core.publisher.Flux<Annotation> list(ODataQuery query)
      GET Annotations, streamed. TM1 (11.8) lists none here: use cubeAnnotations(String, ODataQuery) or cellAnnotations(String, long, ODataQuery).
      Parameters:
      query - what to select, expand and filter
      Returns:
      the annotations
    • get

      @Tm1Endpoint("EntitySet Annotations") public reactor.core.publisher.Mono<Annotation> get(String id, ODataQuery query)
      GET Annotations('id'). TM1 (11.8) answers 404 only for an ID it once gave out, such as a deleted annotation's. Any other text is refused as a Tm1BadRequestException (400, code 248, "Invalid annotation id!").
      Parameters:
      id - the annotation's ID
      query - what to select and expand
      Returns:
      the annotation; a Tm1NotFoundException if it's gone, or a Tm1BadRequestException for an ID that was never TM1's
    • create

      @Tm1Endpoint("EntitySet Annotations") public reactor.core.publisher.Mono<Annotation> create(String cube, Map<String,String> elements, String text)
      Annotates one cell, the way Planning Analytics Workspace does: Text and commentValue are the text, the Cubes} facet names the cube, and the dimensional context binds the cell's members.
      Parameters:
      cube - the cube
      elements - the cell's element in each dimension's same-named hierarchy, by dimension, in the cube's dimension order
      text - what the annotation says
      Returns:
      the annotation, with its ID
    • create

      @Tm1Endpoint("EntitySet Annotations") public reactor.core.publisher.Mono<Annotation> create(AnnotationPatch annotation)
      POST Annotations, for an annotation built by hand.
      Parameters:
      annotation - the annotation
      Returns:
      the annotation as made, with its ID
    • update

      @Tm1Endpoint("EntitySet Annotations") public reactor.core.publisher.Mono<Void> update(String id, AnnotationPatch patch)
      PATCH Annotations('id'). To change what it says, set both Text and the commentValue property: TM1 keeps them apart.
      Parameters:
      id - the annotation's ID
      patch - what to change
      Returns:
      completes when it's changed; TM1 records LastUpdatedBy and LastUpdated
    • delete

      @Tm1Endpoint("EntitySet Annotations") public reactor.core.publisher.Mono<Void> delete(String id)
      DELETE Annotations('id').
      Parameters:
      id - the annotation's ID
      Returns:
      completes when it's gone
    • applicationContext

      @Tm1Endpoint("Navigation Annotation/ApplicationContext") public reactor.core.publisher.Flux<ApplicationContextFacetValue> applicationContext(String id, ODataQuery query)
      ApplicationContext, streamed. TM1 (11.8) returns none.
      Parameters:
      id - the annotation's ID
      query - what to select and expand, such as Facet
      Returns:
      the facet values
    • dimensionalContext

      @Tm1Endpoint("Navigation Annotation/DimensionalContext") public reactor.core.publisher.Flux<Member> dimensionalContext(String id, ODataQuery query)
      DimensionalContext, streamed: the members of the annotated cell.
      Parameters:
      id - the annotation's ID
      query - what to select
      Returns:
      the members
    • attachments

      @Tm1Endpoint("Navigation Annotation/Attachments") public reactor.core.publisher.Flux<Attachment> attachments(String id, ODataQuery query)
      Attachments, streamed: documents attached to the annotation.
      Parameters:
      id - the annotation's ID
      query - what to select
      Returns:
      the attachments
    • cubeAnnotations

      @Tm1Endpoint("Navigation Cube/Annotations") public reactor.core.publisher.Flux<Annotation> cubeAnnotations(String cube, ODataQuery query)
      Cubes('c')/Annotations, streamed: a cube's annotations.
      Parameters:
      cube - the cube
      query - what to select, expand and filter
      Returns:
      the annotations
    • cellAnnotations

      @Tm1Endpoint("Navigation CellsetCell/Annotations") public reactor.core.publisher.Flux<Annotation> cellAnnotations(String cellset, long ordinal, ODataQuery query)
      Cellsets('id')/Cells(n)/Annotations, streamed: one cellset cell's annotations. They also come with the cells by expand("Annotations").
      Parameters:
      cellset - the cellset's ID
      ordinal - the cell's ordinal
      query - what to select
      Returns:
      the annotations
    • facets

      @Tm1Endpoint("EntitySet ApplicationContextFacets") public reactor.core.publisher.Flux<ApplicationContextFacet> facets(ODataQuery query)
      GET ApplicationContextFacets, streamed, such as Cubes}.
      Parameters:
      query - what to select and expand, such as Values
      Returns:
      the facets
    • facetValues

      @Tm1Endpoint("Navigation ApplicationContextFacet/Values") public reactor.core.publisher.Flux<ApplicationContextFacetValue> facetValues(String facet, ODataQuery query)
      A facet's Values, streamed: for Cubes}, the cubes with annotations.
      Parameters:
      facet - the facet's name
      query - what to select
      Returns:
      the values
    • facet

      @Tm1Endpoint("Navigation ApplicationContextFacetValue/Facet") public reactor.core.publisher.Mono<ApplicationContextFacet> facet(String facet, String value, ODataQuery query)
      A facet value's Facet.
      Parameters:
      facet - the facet's name
      value - the value
      query - what to select
      Returns:
      the facet
    • deleteAnnotationArtifacts

      @Tm1Endpoint("ActionImport DeleteAnnotationArtifacts") public reactor.core.publisher.Mono<Void> deleteAnnotationArtifacts()
      DeleteAnnotationArtifacts: removes every annotation in the model, with their facet values, attachments and control cubes. It can't be undone.
      Returns:
      completes when they're gone