2 |
|
|
3 |
package org.fenfire.modules.pp; |
package org.fenfire.modules.pp; |
4 |
import org.fenfire.*; |
import org.fenfire.*; |
5 |
|
import org.fenfire.swamp.*; |
6 |
import org.fenfire.view.buoy.*; |
import org.fenfire.view.buoy.*; |
7 |
import org.fenfire.util.*; |
import org.fenfire.util.*; |
8 |
import org.fenfire.vocab.*; |
import org.fenfire.vocab.*; |
9 |
import org.nongnu.libvob.*; |
import org.nongnu.libvob.*; |
10 |
import org.nongnu.libvob.buoy.*; |
import org.nongnu.libvob.buoy.*; |
11 |
import com.hp.hpl.mesa.rdf.jena.model.*; |
|
12 |
import com.hp.hpl.mesa.rdf.jena.common.*; |
import java.util.Iterator; |
13 |
|
|
14 |
/** Make the kinds of links familiar from PP structure. |
/** Make the kinds of links familiar from PP structure. |
15 |
*/ |
*/ |
18 |
public static boolean dbg = false; |
public static boolean dbg = false; |
19 |
private static void pa(String s) { System.out.println("PPLinker:"+s); } |
private static void pa(String s) { System.out.println("PPLinker:"+s); } |
20 |
|
|
21 |
private Space space; |
private Fen fen; |
22 |
public PPLinker(Space space) { |
public PPLinker(Fen fen) { |
23 |
this.space = space; |
this.fen = fen; |
24 |
} |
} |
25 |
|
|
26 |
public void doLinks(RDFNode node, VobScene vs, int cs, |
public void doLinks(Object node, VobScene vs, int cs, |
27 |
BuoyViewNodeType nodeType, |
BuoyViewNodeType nodeType, |
28 |
BuoyLinkListener l) |
BuoyLinkListener l) |
29 |
{ try { |
{ |
30 |
if (node == null) |
if (node == null) |
31 |
throw new Error("PPLinker error: node is null!"); |
throw new Error("PPLinker error: node is null!"); |
32 |
|
|
33 |
if (node instanceof Resource); |
/* check all associations */ |
|
else throw new Error("PPLinker error: node is not a resource!"); |
|
|
|
|
|
// check all associations |
|
|
Resource n = (Resource)node; |
|
34 |
|
|
35 |
// Right links! |
// Right links! |
36 |
Selector slctr = new SelectorImpl(n, PP.association, (RDFNode) null); |
Iterator iter = fen.constgraph.findN_11X_Iter(node, PP.association); |
|
StmtIterator iter = space.getModel().listStatements(slctr); |
|
|
Statement stmt = null; |
|
|
|
|
37 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
38 |
stmt = iter.next(); |
Object obj = iter.next(); |
39 |
l.link(1,cs,nodeType, |
l.link(1,cs,nodeType, new Pair(node, obj), obj); |
|
new Pair(n, stmt.getObject()), |
|
|
stmt.getObject()); |
|
40 |
} |
} |
41 |
|
|
42 |
// Left links! |
// Left links! |
43 |
slctr = new SelectorImpl(null, PP.association, n); |
iter = fen.constgraph.findN_X11_Iter(node, PP.association); |
|
iter = space.getModel().listStatements(slctr); |
|
44 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
45 |
stmt = iter.next(); |
Object sub = iter.next(); |
46 |
l.link(-1,cs,nodeType, |
l.link(-1,cs,nodeType, new Pair(sub, node), sub); |
|
new Pair(stmt.getSubject(), n), |
|
|
stmt.getSubject()); |
|
47 |
} |
} |
|
|
|
|
} catch (RDFException e) { |
|
|
pa("Exception ocurred!: "+e); |
|
|
throw new Error("PPLinker error: Failed to doLink!!"); |
|
|
} |
|
48 |
} |
} |
49 |
} |
} |