One of Transformations' big strengths is that it knows the structure of the data that it operates on. An operation could, for example, take any kind of structured object and expose its child elements via (mappable) operation outputs. In fact, the TfSimpleMappingOutputsFromStructure operation (in transformations/operations.mapping.inc) does that already, but it needs a second input that tells the operation how the data is structured.
Now if an operation is assigned an input schema (e.g. "you operation, you'll receive a structured object with 'uid' and 'username' properties - guess which operation that'll be :P ) then it could determine the set of outputs by itself. In order to do that though, there needs to be a way to ask for the input schema's child elements, and the challenge in doing that is that schemas might be more complicated than just parent/child relations. (For example, a schema can also specify "I've either a 'uid' integer or a 'username' string child element, plus any number of children with 'jpetso_*' as key".)
In technical terms, the member of a schema collection (= elements inside another schema element) can be either a TfSchemaElement (straightforward piece of data) or another collection (set/sequence/union). In order to reliably determine the actual set of direct children of a collection, we first need a way to traverse the schema tree. I'm fairly sure the Visitor pattern is the way to go here.
So, this issue can be split into two tasks:
1. Implement a TfSchemaVisitor class that offers a set of methods to simply traverse the schema tree, and nothing else.
2. Implement a TfSchemaChildExtractor (extends TfSchemaVisitor) that adds TfSchemaElement objects to a "childrenElements" array, and stops traversing when such a TfSchemaElement is encountered.
Try this if you love OOP. Leave this out if you're afraid of abstraction.
Comments
Comment #1
jpetso commentedRevoking this task, will not get implemented. Instead, we're going to throw out schemas altogether.