[graphl-cvs] graphl/src/org/mediavirus/graphl/graph/rdf RDFNode.java RDFGraph.java
Status: Pre-Alpha
Brought to you by:
flo1
From: Flo L. <fl...@us...> - 2005-08-17 15:53:07
|
Update of /cvsroot/graphl/graphl/src/org/mediavirus/graphl/graph/rdf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16461/src/org/mediavirus/graphl/graph/rdf Modified Files: RDFNode.java RDFGraph.java Log Message: - FEATURE: added navigator thread for update-exhibition, disabled in normal operation - FEATURE: started implementation of filtering architecture - FEATURE: creating new node opens type context menu - CODE: added NS calss for easier namespace referencing in code Index: RDFNode.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/graphl/graph/rdf/RDFNode.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** RDFNode.java 11 Jan 2005 13:26:40 -0000 1.7 --- RDFNode.java 17 Aug 2005 15:52:53 -0000 1.8 *************** *** 12,15 **** --- 12,16 ---- import org.mediavirus.graphl.graph.DefaultNode; import org.mediavirus.graphl.graph.Node; + import org.mediavirus.graphl.vocabulary.NS; import org.mediavirus.util.ParseUtils; *************** *** 50,54 **** // TODO (2, 2h) label generation mechanism has to be hooked up here public String getLabel() { ! String label = getProperty("http://www.mediavirus.org/graphl#label"); if ( label != null) return label; else { --- 51,55 ---- // TODO (2, 2h) label generation mechanism has to be hooked up here public String getLabel() { ! String label = getProperty(NS.graphl + "label"); if ( label != null) return label; else { Index: RDFGraph.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/graphl/graph/rdf/RDFGraph.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** RDFGraph.java 11 Jan 2005 13:26:41 -0000 1.8 --- RDFGraph.java 17 Aug 2005 15:52:53 -0000 1.9 *************** *** 7,10 **** --- 7,11 ---- import java.util.Iterator; + import java.io.File; import java.io.FileReader; import java.io.IOException; *************** *** 17,25 **** import java.util.Hashtable; import java.util.List; - import java.util.Map; import org.mediavirus.graphl.graph.DefaultGraph; import org.mediavirus.graphl.graph.Edge; import org.mediavirus.graphl.graph.Node; import org.xml.sax.InputSource; import org.xml.sax.SAXException; --- 18,26 ---- import java.util.Hashtable; import java.util.List; import org.mediavirus.graphl.graph.DefaultGraph; import org.mediavirus.graphl.graph.Edge; import org.mediavirus.graphl.graph.Node; + import org.mediavirus.graphl.vocabulary.NS; import org.xml.sax.InputSource; import org.xml.sax.SAXException; *************** *** 41,45 **** Hashtable allNodes = new Hashtable(); ! URL baseURL = null; private int loadCount = 0; --- 42,47 ---- Hashtable allNodes = new Hashtable(); ! URL loadingURL = null; ! Node sourceNode = null; private int loadCount = 0; *************** *** 55,59 **** // TODO (2) use vocabularies from config for prefix resolution ! writer.addNamespacePrefix("graphl","http://www.mediavirus.org/graphl#"); writer.addNamespacePrefix("foaf","http://xmlns.com/foaf/0.1/"); writer.addNamespacePrefix("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#"); --- 57,61 ---- // TODO (2) use vocabularies from config for prefix resolution ! writer.addNamespacePrefix("graphl",NS.graphl); writer.addNamespacePrefix("foaf","http://xmlns.com/foaf/0.1/"); writer.addNamespacePrefix("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#"); *************** *** 65,69 **** writer.prepareNamespaceCollection(); ! writer.collectNamespace("http://www.mediavirus.org/graphl#"); writer.collectNamespace("http://xmlns.com/foaf/0.1/"); writer.collectNamespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#"); --- 67,71 ---- writer.prepareNamespaceCollection(); ! writer.collectNamespace(NS.graphl); writer.collectNamespace("http://xmlns.com/foaf/0.1/"); writer.collectNamespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#"); *************** *** 84,88 **** writer.writeStatement(node.getId(), attr, node.getProperty(attr), null, null, true); } ! //writer.writeStatement(node.getId(), "http://www.mediavirus.org/graphl#canvasPosition", node.getCenterX() + ":" + node.getCenterY(), null, null, true); List nodeEdges = node.getEdgesFrom(); for (Iterator edgeIter = nodeEdges.iterator(); edgeIter.hasNext();) { --- 86,90 ---- writer.writeStatement(node.getId(), attr, node.getProperty(attr), null, null, true); } ! //writer.writeStatement(node.getId(), NS.graphl + "canvasPosition", node.getCenterX() + ":" + node.getCenterY(), null, null, true); List nodeEdges = node.getEdgesFrom(); for (Iterator edgeIter = nodeEdges.iterator(); edgeIter.hasNext();) { *************** *** 97,111 **** public void readFromFile(String filename) throws IOException { try { ! baseURL = new URL("file:///" + filename); } catch (MalformedURLException e) {} ! InputSource input = new InputSource(new FileReader(filename)); input.setSystemId(""); readGraph(input); } public void readFromURL(URL url){ ! baseURL = url; InputSource input; try { --- 99,123 ---- public void readFromFile(String filename) throws IOException { + File f = new File(filename); try { ! loadingURL = new URL("file:///" + f.getAbsolutePath()); } catch (MalformedURLException e) {} ! ! sourceNode = getNodeOrNew(loadingURL.toString()); ! ! InputSource input = new InputSource(new FileReader(f)); input.setSystemId(""); readGraph(input); + + loadingURL = null; + sourceNode = null; } public void readFromURL(URL url){ ! ! loadingURL = url; ! sourceNode = getNodeOrNew(loadingURL.toString()); ! InputSource input; try { *************** *** 117,121 **** e.printStackTrace(); } ! } public synchronized void readGraph(InputSource input) { --- 129,136 ---- e.printStackTrace(); } ! ! loadingURL = null; ! sourceNode = null; ! } public synchronized void readGraph(InputSource input) { *************** *** 154,158 **** */ public void statementWithResourceValue(String subject, String predicate, String object) throws SAXException { ! //if (predicate.equals("http://www.mediavirus.org/graphl#connectedTo")) { // get / create node with label subject Node snode; --- 169,173 ---- */ public void statementWithResourceValue(String subject, String predicate, String object) throws SAXException { ! //if (predicate.equals(NS.graphl + "connectedTo")) { // get / create node with label subject Node snode; *************** *** 178,181 **** --- 193,197 ---- edge = new RDFEdge(snode,onode); edge.setType(predicate); + edge.setSource(loadingURL.toString()); addElements(null, Collections.singleton(edge)); if (DEBUG) System.out.println("created edge " + subject + ", " + predicate + ", " + object); *************** *** 184,193 **** System.out.println("#### " + object); try { ! URL oldBase = baseURL; ! URL importURL = new URL(baseURL, object); System.out.println("importing " + importURL.toString() + " ... "); readFromURL(importURL); // restore original base url ! baseURL = oldBase; } catch (MalformedURLException muex) { --- 200,209 ---- System.out.println("#### " + object); try { ! URL oldBase = loadingURL; ! URL importURL = new URL(loadingURL, object); System.out.println("importing " + importURL.toString() + " ... "); readFromURL(importURL); // restore original base url ! loadingURL = oldBase; } catch (MalformedURLException muex) { *************** *** 214,221 **** node.setCenter(r*Math.sin(loadAlpha), r*Math.cos(loadAlpha)); loadCount++; - //node.setCenter(400*Math.random()-200,400*Math.random()-200); addElements(Collections.singleton(node), null); if (DEBUG) System.out.println("created node " + uri); } return node; } --- 230,251 ---- node.setCenter(r*Math.sin(loadAlpha), r*Math.cos(loadAlpha)); loadCount++; addElements(Collections.singleton(node), null); if (DEBUG) System.out.println("created node " + uri); } + if (sourceNode != null) { + boolean found = false; + for (Iterator i = node.getNeighbours(NS.graphl + "definedIn", true).iterator(); i.hasNext();) { + Node source = (Node) i.next(); + if (source.equals(sourceNode)) { + found = true; + break; + } + } + if (!found) { + Edge edge = createEdge(node, sourceNode); + edge.setSource(NS.graphl + "SYSTEM"); + edge.setType(NS.graphl + "definedIn"); + } + } return node; } *************** *** 229,232 **** --- 259,263 ---- public Edge createEdge(Node from, Node to) { RDFEdge edge = new RDFEdge(from, to); + edge.setSource(loadingURL.toString()); addElements(null, Collections.singleton(edge)); return edge; *************** *** 239,246 **** // TODO (2): for incremental loading, check if these things are already set - // in the future, all this should be properly modeled by literal nodes - // and corresponding node/edge renderer setups ! if (predicate.equals("http://www.mediavirus.org/graphl#canvasPosition")) { RDFNode snode = getNodeById(subject); if (snode != null){ --- 270,275 ---- // TODO (2): for incremental loading, check if these things are already set ! if (predicate.equals(NS.graphl + "canvasPosition")) { RDFNode snode = getNodeById(subject); if (snode != null){ *************** *** 251,255 **** } else { ! //if (predicate.equals("http://www.mediavirus.org/graphl#connectedTo")) { // get / create node with label subject Node snode; --- 280,284 ---- } else { ! //if (predicate.equals(NS.graphl + "connectedTo")) { // get / create node with label subject Node snode; *************** *** 352,358 **** } - public URL getBaseURL() { - return baseURL; - } - } --- 381,383 ---- |