1 |
#(c): Matti Katila |
#(c): Matti Katila |
2 |
|
|
3 |
from org.fenfire.modules.pp import * |
from org.fenfire.modules.pp import * |
4 |
from org.fenfire.view.buoy import * |
import org.fenfire.view.buoy |
5 |
from org.fenfire.util import * |
from org.fenfire.util import URN5Namespace, Pair |
6 |
|
from org.nongnu.libvob.buoy import BuoyViewNodeType,\ |
7 |
|
BuoyLinkListener |
8 |
from com.hp.hpl.mesa.rdf import jena |
from com.hp.hpl.mesa.rdf import jena |
9 |
|
|
10 |
|
from org.fenfire.test.gfx import getvs |
11 |
|
|
12 |
|
|
13 |
def setUp(): |
def setUp(): |
14 |
global model, PP |
global model, PP |
15 |
model = jena.mem.ModelMem() |
model = jena.mem.ModelMem() |
16 |
PP = PPVocab(model) |
PP = PPVocab() |
17 |
|
|
18 |
global uriA, uriB |
global uriA, uriB |
19 |
global nodeA, nodeB |
global nodeA, nodeB |
20 |
uriA = URN5Namespace.instance.generateId() |
urn = URN5Namespace() |
21 |
uriB = URN5Namespace.instance.generateId() |
uriA = urn.generateId() |
22 |
|
uriB = urn.generateId() |
23 |
nodeA = model.createResource(uriA) |
nodeA = model.createResource(uriA) |
24 |
nodeB = model.createResource(uriB) |
nodeB = model.createResource(uriB) |
25 |
|
|
26 |
# assoc |
# assoc |
27 |
noteA.addProperty(PP.Association, noteB) |
nodeA.addProperty(PP.Association, nodeB) |
28 |
|
|
29 |
|
global ppLinker |
30 |
|
ppLinker = PPLinker(model, PP) |
31 |
|
|
32 |
|
class NodeType(BuoyViewNodeType): |
33 |
|
def getSizde(self, linkId, anchor, wh): |
34 |
|
return None |
35 |
|
|
36 |
|
def renderBuoy(self, vs, into, linkId, anchor, cachedsize): |
37 |
|
return 0 |
38 |
|
|
39 |
|
def createMainNode(self, linkId, anchor, l): |
40 |
|
return None |
41 |
|
|
42 |
|
class Listener(BuoyLinkListener): |
43 |
|
def __init__(self, node, pair): |
44 |
|
self.node = node |
45 |
|
self.pair = pair |
46 |
|
|
47 |
|
def link(self, dir, anchorCS, otherNode, linkId, otherAnchor): |
48 |
|
assert self.node == otherAnchor |
49 |
|
assert self.pair == linkId |
50 |
|
|
51 |
|
|
52 |
def testPPLinking(): |
def testPPLinking(): |
53 |
""" |
""" |
54 |
Test if PPLinking works by creating on association |
Test if PPLinking works in both directions |
55 |
""" |
""" |
56 |
|
type = NodeType() |
57 |
|
|
58 |
|
# right direction |
59 |
|
listener = Listener(nodeB, Pair(nodeA,nodeB)) |
60 |
|
vs = getvs() |
61 |
|
ppLinker.doLinks(nodeA, vs, 0, type, listener) |
62 |
|
|
63 |
|
# left direction |
64 |
|
listener = Listener(nodeA, Pair(nodeA,nodeB)) |
65 |
|
ppLinker.doLinks(nodeB, vs, 0, type, listener) |
66 |
|
|