Join (query directive)
(→Example) |
(→Example) |
||
Line 24: | Line 24: | ||
Above example joins instances and subclasses of input. Typically the results of joins are filtered by comparing some values of the result rows. In this case only rows where the topics with roles "#instance" and XTMPSI.SUBCLASS are the same are selected (see [[Compare (query directive) |Compare]] directive). Effectively this query finds out if any of the instances of the input topic are also subclasses of it. | Above example joins instances and subclasses of input. Typically the results of joins are filtered by comparing some values of the result rows. In this case only rows where the topics with roles "#instance" and XTMPSI.SUBCLASS are the same are selected (see [[Compare (query directive) |Compare]] directive). Effectively this query finds out if any of the instances of the input topic are also subclasses of it. | ||
+ | Following example gets variant names of the input topic in various languages and joins the results. | ||
+ | |||
+ | importPackage(org.wandora.query2); | ||
+ | importPackage(org.wandora.topicmap); | ||
+ | new Join( | ||
+ | new Variant(XTMPSI.DISPLAY,XTMPSI.getLang("en")).as("#en"), | ||
+ | new Variant(XTMPSI.DISPLAY,XTMPSI.getLang("fi")).as("#fi"), | ||
+ | new Variant(XTMPSI.DISPLAY,XTMPSI.getLang("se")).as("#se"), | ||
+ | new Variant(XTMPSI.DISPLAY,XTMPSI.getLang("it")).as("#it") | ||
+ | ) | ||
[[Category:Query directives]] | [[Category:Query directives]] |
Revision as of 13:58, 21 August 2009
Contents |
Description
Joins the results of inner directives by performing a cartesian product on the results of them.
Constructor
Join(Directive d1,Directive d2,...)
Notes
This directive is best used using the join method present in every directive. Calling A.join(B) will resolve to new Join(A,B). In many cases you do not need to refer to join specifically at all. Instead you may provide several directives to from method which will implicitly join them.
Example
importPackage(org.wandora.query2); importPackage(org.wandora.topicmap); new Join( new Instances().as("#instance"), new Players( XTMPSI.SUPERCLASS_SUBCLASS, XTMPSI.SUBCLASS).whereInputIs(XTMPSI.SUPERCLASS) ).where("#instance","t=",XTMPSI.SUBCLASS)
Above example joins instances and subclasses of input. Typically the results of joins are filtered by comparing some values of the result rows. In this case only rows where the topics with roles "#instance" and XTMPSI.SUBCLASS are the same are selected (see Compare directive). Effectively this query finds out if any of the instances of the input topic are also subclasses of it.
Following example gets variant names of the input topic in various languages and joins the results.
importPackage(org.wandora.query2); importPackage(org.wandora.topicmap); new Join(
new Variant(XTMPSI.DISPLAY,XTMPSI.getLang("en")).as("#en"), new Variant(XTMPSI.DISPLAY,XTMPSI.getLang("fi")).as("#fi"), new Variant(XTMPSI.DISPLAY,XTMPSI.getLang("se")).as("#se"), new Variant(XTMPSI.DISPLAY,XTMPSI.getLang("it")).as("#it")
)