Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Query all notes with particular outbound link type (Read 2502 times)
SteveS
Full Member
*
Offline



Posts: 15

Query all notes with particular outbound link type
Sep 12th, 2013, 10:49pm
 
Hi All,

Just bought Tinderbox a few days ago, and LOVE it.  Most amazing piece of software that I have used in a long long time.

So, here is what I have on my hands.  I have created a link type "is influenced by?", and as an example lets say I have created the following notes/links { notes enclosed by [], link types enclosed by () }

   [DowJones] ---(is influenced by?)--> [FedInterestRate]
   [NewHousesBuilds] --(is influenced by?)--> [FedInterestRate]

Now, I would like to create an agent that will find all candidates for research based on the link type "is influenced by?" and the source and destination.  So for the example above I would like a way (via agents, display options, etc) to express the following:

RESEARCH CANDIDATES
   Is DowJones influenced by FedInterestRates?
   Is NewHouseBuilds influenced by FedInterest Rates?

The general idea is as I build out my maps, and create lots of "is influenced by?" link type, my collection of potential research candidates will grow accordingly. I can see that I need to query notes for a particular link type, and if a note has one or more of those link types, I need to iterate through the list of links of that type, and find the destination note, so I can build the expressions above.

Is this possible?

Cheers!
Steve
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Query all notes with particular outbound link type
Reply #1 - Sep 13th, 2013, 4:11am
 
The action codes you'll find most pertinent for this are linkedTo(), linkedFrom(), and links(); see the linked pages for more detail. Tinderbox links are unidirectional, so if you aren't detecting expected links check their direction matches the linkedTo/linkFrom logic you are testing.

An agent query to test if "DowJones" is influenced by "FedInterestRates", would use the query:

$Name=="DowJones" & linkedTo("FedInterestRate","is influenced by")

The name ensure you test only the specific "DowJones" note. To find all notes linking to "FedInterestRate" via a link of type "is influenced by" is a simple step. Query code:

linkedTo("FedInterestRate","is influenced by")

For your example data, this finds both the "DowJones" and "NewHouseBuilds" notes. Fine, but perhaps you might want to know "what are all the influences on DowJones?". Using your link logic, you want a list of all the notes with an "is influenced by" type link coming from "DowJones":

$Name=="DowJones" & linkedTo("*","is influenced by")

See linkedTo() for an explanation of the asterisk wildcard. The latter usage is worth noting as in general Tinderbox does not use such an approach for filtering; linkedTo and linkedFrom are two egregious examples.

Taking a different route, you can make a note run the same test as the original agent query above. For this, we'll add a new User attribute to your document, of Boolean data type. In my example we'll call it MyBoolean. Now try this rule in the notes "DowJones", "FedInterestRate" and "NewHouseBuilds":

$MyBoolean = linkedTo("FedInterestRate","is influenced by");

In "DowJones" and "NewHouseBuilds", $MyBoolean will now be 'true' (i.e. ticked). But, the attribute will remain as the default 'false' (un-ticked) in "FedInterestRate" because although it has "is influenced by" links attached to it, they are all incoming; we are testing for outgoing links of that type. Of course, with more complex data, "FedInterestRate" might have an outgoing link of that type so you'd need a more complex query.

Now you know how to make a note test for such a link you could use it with many notes, setting it via a prototype. That is, you set the rule code in the prototype and all notes set to use that prototype then inherit the rule. That might be useful in a map as you might test $MyBoolean and alter the note's visualisation slightly based on this:

$MyBoolean = linkedTo("FedInterestRate","is influenced by");
if($MyBoolean){$Color="bright blue"}else{$Color=;};


Now if a note is influenced by the Fed, it turns itself bright blue; if not $Color is reset to its previous inherited value. You don't have to change colour. It could be a shape, fill, patter, border, border pattern - Tinderbox offers a lot of scope for such visual hinting. Subtle changes are good if you want to track a lot of different issue visually on a Map at the same time. Simply setting a bright colour for $Color is great for basic testing, a set of training wheels as it were. Once you get the general code concept, more subtle changes tend to work better.

Hopefully that gives you a few ideas. The links here all take to you to aTbRef. It's a free resource which you may find useful to browse if looking for what code allows you to do with Tinderbox. Disclosure: I am aTbRef's author.
Back to top
 
« Last Edit: Sep 13th, 2013, 4:16am by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Query all notes with particular outbound link type
Reply #2 - Sep 13th, 2013, 7:37am
 
Looking at the visualisation side & agents, here are some other things to consider:



Both agents shown in the picture use the same query. It is the second example agent query in the last post above.

The first example is pretty plain vanilla. I've added a Display Expression so as to show the $ChildCount of the agent, i.e. the current number of matches to the query. In the agent viewport we can see some of the matched items (which have been given badges by the agent's action, to indicate they are research candidates.

The second example is a copy of the first with additions. We've now hidden the viewport by dragging the top of the title bar upwards. Subtitle text has been added. A table expression has been used to list data about the agent's matches. Here we assume 'Added' is a date attribute - perhaps set by the agent showing when the item first became of interest). The agent itself is reverse sorted on this attribute so the most recent target is tested first. The date attribute has been called using .format() so as to show the local short date format (in d/m/y order as I'm in UK). The 'Words' might be something like a word count for the item. As I say, here the data is mocked up but it gives an idea.

~~~~~~~~~

When starting out on a dashboard approach it's probably a good idea to use a separate small file to test out visualisation ideas and querying methods. This saves littering your main document with the litter of failed ideas. Tinderbox is actually very tolerant of such things but cleaning house can still take time, so in the long run it helps to leave most trash outside your min doc(s), and implementing into them ideas debugged in other TBXs. Still, if you prefer to dive in and do everything in the current document, that's OK too!
Back to top
 
« Last Edit: Sep 13th, 2013, 7:40am by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1
Send Topic Print