Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi
Tinderbox Users >> Exporting from Tinderbox >> Determine prototype ancestors
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1355945733

Message started by rtalexander on Dec 19th, 2012, 2:35pm

Title: Determine prototype ancestors
Post by rtalexander on Dec 19th, 2012, 2:35pm

Suppose I have a note X, how do I determine if there is a prototype
path from X's prototype to some other prototype node Z?

To clarify (hopefully), given a note K whose container is J, is there
anyway to determine if the prototype of J, P, is a particular note N
(i.e. P = N), or there is a path of prototypes that can be traversed
from P to reach N?

For example, consider the following containment hierarchy of notes:

- Root
 - J
   - K
 - N
 - O
 - P

Assume these notes have the following prototype relationships:

* $Prototype(J) = P
* $Prototype(P) = O
* $Prototype(O) = N

Now suppose that K is the current note during export. What I want to
do is determine if the prototype of K's container, J, is N or any other
note that can be reached by traversing a path of prototype relationships
to reach N. For this particular example, the prototype of J is P, which
is not N, but I can bet to N by traversing from P to its prototype O, and
from O to its prototype N, something like $Prototype($Prototype($Prototype(P))).

As a concrete example, I'm using Tinderbox to capture software requirements.
Each requirement is either an aggregate that contains sub-requirements, or it
is a singleton requirement. At export time, for a given requirement, I need to
determine if it is a sub-requirement of some other requirement, namely its
containing note.

To boil it down to Tinderbox terms, roughly what I need is an operator that would
return a list having path of ancestor prototypes for a given node J, ordered
starting from the J's prototype, then J's prototype's prototype, and so on.
Something perhaps like the following:

   prototypeAncestors(J) would return the list [P,O,N]

which would allow something like the following to be expressed:

   if (prototypeAncestors($Prototype($Container))).contains(N)) {...}

Any thoughts or suggestions would be greatly appreciated!

Title: Re: Determine prototype ancestors
Post by Mark Bernstein on Dec 19th, 2012, 3:12pm

This probably SHOULD be a primitive method.  I'm not sure there's a good way to do this right now.

You can extract the prototype of your prototype thusly:

     $Prototype($Path($Prototype))

This works because  $Path($Prototype) is the full path of the note’s prototype. So we're returning the prototype of the prototype.

Unless you have a vast number of prototypes -- a whole taxonomy -- or need to change prototypes all the time, you might be well served simply to add a set attribute to hold the prototype list, and enter this manually for each prototype.


Title: Re: Determine prototype ancestors
Post by Mark Anderson on Dec 19th, 2012, 5:05pm

@rtalexander - do you want a ordered list of prototypes names or a set of references ($Path) data for each? For what purpose will that data be used? Will the prototype chaining (or prototype names) change over the course of the project?

I ask because knowing these things might help with planning a practical solution (based on the latter part of Mark B's answer).

Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com) » Powered by YaBB 2.2.1!
YaBB © 2000-2008. All Rights Reserved.