I'm attempting to use the API to do metadata injection in the Annotate Stream step.
I've managed to create a BlankAnnotation for a field in the stream, and from that create a ModelAnnotation. Fine.
The Step gives me the ModelAnnotationGroup, and from that I can get the list of ModelAnnotations.
So I then call add on that list, with my new ModelAnnotation, and then for good measure (unsure if it's required) i then set the ModelAnnotationGroup back on the step.
Now, here's the odd thing. That all "works" but when I come to save the XML I get an error:
Unable to save to XML file '/home/codek/projects/cop/etl/tests/annotate_injection/simple_annotate_injected.ktr'
org.pentaho.agilebi.modeler.models.annotations.ModelAnnotation cannot be cast to org.pentaho.agilebi.modeler.models.annotations.ModelAnnotation
Errm, some class can't be cast to itself? eh?
Now I got all this by reverse engineering what the step GUI itself, and the FieldSelectionDialog do - clearly I missed a crucial step somewhere, but I'm struggling to see it!
Incidentally I had to copy a couple of JARS from karaf into the PDI lib dir, because the JS or the UDJC steps don't see karaf jars. I'm not sure if that is entirely safe or not. Is it possible to make that work in a better way, I could raise a jira if it is possible..