[graphl-cvs] graphl/src/org/mediavirus/graphl/graph/rdf RDFGraph.java
Status: Pre-Alpha
Brought to you by:
flo1
From: Flo L. <fl...@us...> - 2005-12-14 12:45:20
|
Update of /cvsroot/graphl/graphl/src/org/mediavirus/graphl/graph/rdf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24484/src/org/mediavirus/graphl/graph/rdf Modified Files: RDFGraph.java Log Message: - FEATURE: new command line flag to start "navigator" thread to zoom & pan in the graph - CODE: loading graphs returns URL[] with all loaded (+included) files - CODE: dynamically adding config-file + all included files to default filter - DOC: extended user guide Index: RDFGraph.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/graphl/graph/rdf/RDFGraph.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** RDFGraph.java 7 Sep 2005 12:29:55 -0000 1.12 --- RDFGraph.java 14 Dec 2005 12:45:08 -0000 1.13 *************** *** 14,17 **** --- 14,18 ---- import java.net.MalformedURLException; import java.net.URL; + import java.util.ArrayList; import java.util.Collection; import java.util.Collections; *************** *** 36,421 **** */ public class RDFGraph extends DefaultGraph implements RDFConsumer { ! ! private static final boolean DEBUG = false; ! boolean dirty = false; ! Hashtable allNodes = new Hashtable(); ! URL loadingURL = null; Node sourceNode = null; ! private int loadCount = 0; private float loadAlpha = 0.1f; - - public RDFNode getNodeById(String id){ - return (RDFNode)allNodes.get(id); - } - - public static void writeToRDF(Graph graph, OutputStream out, String baseURL) throws IOException { - RDFWriter writer = new RDFWriter(); - - // 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#"); - writer.addNamespacePrefix("rdfs","http://www.w3.org/2000/01/rdf-schema#"); - writer.addNamespacePrefix("owl","http://www.w3.org/2002/07/owl#"); - writer.addNamespacePrefix("map","http://fabl.net/vocabularies/geography/map/1.1/"); - writer.addNamespacePrefix("geo","http://www.w3.org/2003/01/geo/wgs84_pos#"); - writer.addNamespacePrefix("dc","http://purl.org/dc/elements/1.1/"); - writer.addNamespacePrefix("foo","http://www.mediavirus.org/foo#"); - writer.addNamespacePrefix("vs","http://www.w3.org/2003/06/sw-vocab-status/ns#"); - writer.addNamespacePrefix("wot","http://xmlns.com/wot/0.1/"); ! 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#"); ! writer.collectNamespace("http://www.w3.org/2000/01/rdf-schema#"); ! writer.collectNamespace("http://www.w3.org/2002/07/owl#"); ! writer.collectNamespace("http://fabl.net/vocabularies/geography/map/1.1/"); ! writer.collectNamespace("http://www.w3.org/2003/01/geo/wgs84_pos#"); ! writer.collectNamespace("http://purl.org/dc/elements/1.1/"); ! writer.collectNamespace("http://www.mediavirus.org/foo#"); ! writer.collectNamespace("http://www.w3.org/2003/06/sw-vocab-status/ns#"); ! writer.collectNamespace("http://xmlns.com/wot/0.1/"); ! OutputStreamWriter owriter = new OutputStreamWriter(out); ! writer.startSerialization(owriter,"","","UTF-8"); ! writer.startRDFContents(); ! ! List allNodes = graph.getNodes(); ! List allEdges = graph.getEdges(); ! ! for (Iterator iter = allNodes.iterator(); iter.hasNext();) { ! Node node = (Node) iter.next(); ! ! String id = node.getId(); ! if ((baseURL != null) && (id.startsWith(baseURL)) && (id.lastIndexOf('#')>-1)) { ! id = id.substring(id.lastIndexOf('#')); ! } ! ! for (Iterator attrs = node.getProperties().keySet().iterator(); attrs.hasNext();) { ! String attr = (String) attrs.next(); ! writer.writeStatement(id, attr, node.getProperty(attr), null, null, true); ! } ! List nodeEdges = node.getEdgesFrom(); ! for (Iterator edgeIter = nodeEdges.iterator(); edgeIter.hasNext();) { ! Edge edge = (Edge) edgeIter.next(); ! // TODO (3) this would be a reason to have a FilteredNode class that returns only filtered edges... ! if (allEdges.contains(edge)) { ! String toId = edge.getTo().getId(); ! if ((baseURL != null) && (toId.startsWith(baseURL)) && (toId.lastIndexOf('#')>-1)) { ! toId = toId.substring(toId.lastIndexOf('#')); ! } ! writer.writeStatement(id, edge.getType(), toId, null, null, false); ! } ! } ! } ! ! writer.finishRDFContents(); ! writer.cleanUp(); ! ! } ! public void writeToRDF(OutputStream out, String baseURL) throws IOException { ! writeToRDF(this, out, baseURL); ! } ! ! public synchronized void readFromFile(String filename) throws IOException { ! System.out.println("reading file " + filename); ! File f = new File(filename); ! try { ! loadingURL = new URL("file:///" + f.getAbsolutePath()); ! } ! catch (MalformedURLException e) {} ! ! sourceNode = getNodeOrNew(loadingURL.toString()); - if (sourceNode.getNeighbours(NS.graphl + "definedIn", true).size() == 0) { - Edge edge = createEdge(sourceNode, sourceNode); - edge.setSource(NS.graphl + "SYSTEM"); - edge.setType(NS.graphl + "definedIn"); - } - - InputSource input = new InputSource(new FileReader(f)); - input.setSystemId(""); - readGraph(input); - - loadingURL = null; - sourceNode = null; - } - - public synchronized void readFromURL(URL url){ - - loadingURL = url; - sourceNode = getNodeOrNew(loadingURL.toString()); - - if (sourceNode.getNeighbours(NS.graphl + "definedIn", true).size() == 0) { - Edge edge = createEdge(sourceNode, sourceNode); - edge.setSource(NS.graphl + "SYSTEM"); - edge.setType(NS.graphl + "definedIn"); - } - - InputSource input; try { input = new InputSource(url.openConnection().getInputStream()); input.setSystemId(url.toString()); readGraph(input); } ! catch (IOException e) { e.printStackTrace(); } ! loadingURL = null; ! sourceNode = null; ! } ! ! public synchronized void readGraph(InputSource input) { ! RDFParser parser = new RDFParser(); ! loading = true; try { ! parser.parse(input,this); } - catch (Exception e) { - e.printStackTrace(); - } - loading = false; - resetDirty(); - fireGraphContentsChanged(); - } ! /** ! * @see edu.unika.aifb.rdf.api.syntax.RDFConsumer#startModel(java.lang.String) ! */ ! public void startModel(String physicalURI) throws SAXException { ! if (DEBUG) System.out.println("RDF: startModel"); ! } ! /** ! * @see edu.unika.aifb.rdf.api.syntax.RDFConsumer#endModel() ! */ ! public void endModel() throws SAXException { ! if (DEBUG) System.out.println("RDF: endModel"); ! } ! /** ! * @see edu.unika.aifb.rdf.api.syntax.RDFConsumer#statementWithResourceValue(java.lang.String, java.lang.String, java.lang.String) ! */ ! public void statementWithResourceValue(String subject, String predicate, String object) throws SAXException { ! //if (predicate.equals(NS.graphl + "connectedTo")) { ! // get / create node with label subject ! ! if (loadingURL != null) { ! try { ! subject = new URL(loadingURL, subject).toString(); ! } ! catch (MalformedURLException muex) { ! // do nothing ! } ! try { ! object = new URL(loadingURL, object).toString(); ! } ! catch (MalformedURLException muex) { ! // do nothing ! } ! } ! ! Node snode; ! Node onode; ! try { ! snode = getNodeOrNew(subject); ! onode = getNodeOrNew(object); ! // get / create connection ! List edges = snode.getEdgesFrom(); ! RDFEdge edge = null; ! boolean exists = false; ! ! for (Iterator iter = edges.iterator(); iter.hasNext();) { ! edge = (RDFEdge) iter.next(); ! if ((edge.getTo() == onode) && (edge.getType().equals(predicate))) { ! exists = true; ! break; ! } ! } ! ! if (!exists) { ! 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); ! ! if (predicate.equals("http://www.w3.org/2002/07/owl#imports")) { ! try { ! URL oldBase = loadingURL; ! Node oldSource = sourceNode; ! URL importURL = new URL(loadingURL, object); ! System.out.println("importing " + importURL.toString() + " ... "); ! readFromURL(importURL); ! // restore original base url ! loadingURL = oldBase; ! sourceNode = oldSource; ! } ! catch (MalformedURLException muex) { ! System.out.println("Error importing " + object); ! } ! } ! } ! } ! catch (Exception ex) { ! if (DEBUG) System.out.println("Error while reading triple: " + subject + ", " + predicate + ", " + object); ! //ex.printStackTrace(); ! } ! ! ! } ! public Node getNodeOrNew(String uri){ ! RDFNode node = getNodeById(uri); ! if (node == null){ ! node = new RDFNode(this, uri); ! float r = 20 + loadCount; ! loadAlpha += 30/r; ! 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; ! } ! ! public Node createNode() { ! RDFNode node = new RDFNode(this); ! addElements(Collections.singleton(node), null); ! return node; ! } ! public Edge createEdge(Node from, Node to) { ! RDFEdge edge = new RDFEdge(from, to); ! if (loadingURL != null) { ! edge.setSource(loadingURL.toString()); ! } ! else { ! edge.setSource(NS.graphl + "USER"); ! } ! addElements(null, Collections.singleton(edge)); ! return edge; ! } ! /** ! * @see edu.unika.aifb.rdf.api.syntax.RDFConsumer#statementWithLiteralValue(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String) ! */ ! public void statementWithLiteralValue(String subject, String predicate, String object, String language, String datatype) throws SAXException { ! ! // get absolute URL for subject ! if (loadingURL != null) { ! try { ! subject = new URL(loadingURL, subject).toString(); ! } ! catch (MalformedURLException muex) { ! // do nothing ! } ! } ! ! Node snode; ! try { ! snode = getNodeOrNew(subject); ! snode.setProperty(predicate, object); ! if (DEBUG) System.out.println("created property " + subject + ", " + predicate + ", " + object); ! } ! catch (Exception ex) { ! if (DEBUG) System.out.println("Error while reading triple: " + subject + ", " + predicate + ", " + object); ! } ! } ! /** ! * @see edu.unika.aifb.rdf.api.syntax.RDFConsumer#logicalURI(java.lang.String) ! */ ! public void logicalURI(String logicalURI) throws SAXException { ! if (DEBUG) System.out.println("RDF: logicalURI: " + logicalURI); ! } ! /** ! * @see edu.unika.aifb.rdf.api.syntax.RDFConsumer#includeModel(java.lang.String, java.lang.String) ! */ ! public void includeModel(String logicalURI, String physicalURI) throws SAXException { ! if (DEBUG) System.out.println("RDF: includeModel: " + logicalURI + ", " + physicalURI); ! } - /** - * @see edu.unika.aifb.rdf.api.syntax.RDFConsumer#addModelAttribte(java.lang.String, java.lang.String) - */ - public void addModelAttribte(String key, String value) throws SAXException { - if (DEBUG) System.out.println("RDF: addModelAttribte" + key + ", " + value); - } - /** * @return Returns the dirty flag. */ public boolean isDirty() { return dirty; } ! /** * @param dirty New value for dirty flag. */ public void setDirty(boolean dirty) { this.dirty = dirty; } ! public void setDirty() { setDirty(true); } ! public void resetDirty() { setDirty(false); } ! /* * Overrides @see de.fzi.wim.guibase.graphview.graph.DefaultGraph#addElements(java.util.Collection, java.util.Collection) */ public synchronized void addElements(Collection nodes, Collection edges) { setDirty(); super.addElements(nodes, edges); ! if (nodes != null) { ! for (Iterator iter = nodes.iterator(); iter.hasNext();){ ! RDFNode node = (RDFNode) iter.next(); ! allNodes.put(node.getId(), node); } } } ! /* * Overrides @see de.fzi.wim.guibase.graphview.graph.DefaultGraph#clear() */ public synchronized void clear() { setDirty(); allNodes.clear(); --- 37,450 ---- */ public class RDFGraph extends DefaultGraph implements RDFConsumer { ! ! public static boolean DEBUG = false; ! boolean dirty = false; ! Hashtable allNodes = new Hashtable(); ! URL loadingURL = null; + + List<URL> loadingURLs = null; + Node sourceNode = null; ! private int loadCount = 0; private float loadAlpha = 0.1f; ! public RDFNode getNodeById(String id) { ! return (RDFNode) allNodes.get(id); ! } ! public static void writeToRDF(Graph graph, OutputStream out, String baseURL) throws IOException { ! ! RDFWriter writer = new RDFWriter(); ! ! // 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#"); ! writer.addNamespacePrefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#"); ! writer.addNamespacePrefix("owl", "http://www.w3.org/2002/07/owl#"); ! writer.addNamespacePrefix("map", "http://fabl.net/vocabularies/geography/map/1.1/"); ! writer.addNamespacePrefix("geo", "http://www.w3.org/2003/01/geo/wgs84_pos#"); ! writer.addNamespacePrefix("dc", "http://purl.org/dc/elements/1.1/"); ! writer.addNamespacePrefix("foo", "http://www.mediavirus.org/foo#"); ! writer.addNamespacePrefix("vs", "http://www.w3.org/2003/06/sw-vocab-status/ns#"); ! writer.addNamespacePrefix("wot", "http://xmlns.com/wot/0.1/"); ! ! 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#"); ! writer.collectNamespace("http://www.w3.org/2000/01/rdf-schema#"); ! writer.collectNamespace("http://www.w3.org/2002/07/owl#"); ! writer.collectNamespace("http://fabl.net/vocabularies/geography/map/1.1/"); ! writer.collectNamespace("http://www.w3.org/2003/01/geo/wgs84_pos#"); ! writer.collectNamespace("http://purl.org/dc/elements/1.1/"); ! writer.collectNamespace("http://www.mediavirus.org/foo#"); ! writer.collectNamespace("http://www.w3.org/2003/06/sw-vocab-status/ns#"); ! writer.collectNamespace("http://xmlns.com/wot/0.1/"); ! ! OutputStreamWriter owriter = new OutputStreamWriter(out); ! writer.startSerialization(owriter, "", "", "UTF-8"); ! writer.startRDFContents(); ! ! List allNodes = graph.getNodes(); ! List allEdges = graph.getEdges(); ! ! for (Iterator iter = allNodes.iterator(); iter.hasNext();) { ! Node node = (Node) iter.next(); ! ! String id = node.getId(); ! if ((baseURL != null) && (id.startsWith(baseURL)) && (id.lastIndexOf('#') > -1)) { ! id = id.substring(id.lastIndexOf('#')); ! } ! ! for (Iterator attrs = node.getProperties().keySet().iterator(); attrs.hasNext();) { ! String attr = (String) attrs.next(); ! writer.writeStatement(id, attr, node.getProperty(attr), null, null, true); ! } ! List nodeEdges = node.getEdgesFrom(); ! for (Iterator edgeIter = nodeEdges.iterator(); edgeIter.hasNext();) { ! Edge edge = (Edge) edgeIter.next(); ! // TODO (3) this would be a reason to have a FilteredNode class that returns only filtered edges... ! if (allEdges.contains(edge)) { ! String toId = edge.getTo().getId(); ! if ((baseURL != null) && (toId.startsWith(baseURL)) && (toId.lastIndexOf('#') > -1)) { ! toId = toId.substring(toId.lastIndexOf('#')); ! } ! writer.writeStatement(id, edge.getType(), toId, null, null, false); ! } ! } ! } ! ! writer.finishRDFContents(); ! writer.cleanUp(); ! ! } ! ! public void writeToRDF(OutputStream out, String baseURL) throws IOException { ! ! writeToRDF(this, out, baseURL); ! } ! ! public synchronized Iterator<URL> readFromFile(File file) throws IOException { try { + URL url = new URL("file:///" + file.getAbsolutePath()); + return readFromURL(url); + } + catch (MalformedURLException e) { + throw new IOException("Cannot construct URL from filename"); + } + + } + + public synchronized Iterator<URL> readFromURL(URL url) throws IOException{ + + try { + loadingURLs = new ArrayList<URL>(); + importFromURL(url); + + Iterator<URL> retVal = loadingURLs.iterator(); + + return retVal; + } + finally { + loadingURLs = null; + } + + } + + /** + * This is the internal method to load content from an URL. While readFromURL returns + * the URLs loaded to the caller, this one adds the loaded URL to the list of URLs + * to be returned. + * + * @param url The URL to load. + */ + protected void importFromURL(URL url) throws IOException{ + + try { + loadingURL = url; + sourceNode = getNodeOrNew(loadingURL.toString()); + + if (sourceNode.getNeighbours(NS.graphl + "definedIn", true).size() == 0) { + Edge edge = createEdge(sourceNode, sourceNode); + edge.setSource(NS.graphl + "SYSTEM"); + edge.setType(NS.graphl + "definedIn"); + } + + InputSource input; + input = new InputSource(url.openConnection().getInputStream()); input.setSystemId(url.toString()); readGraph(input); + loadingURLs.add(url); } ! finally { ! loadingURL = null; ! sourceNode = null; ! } ! } ! ! public synchronized void readGraph(InputSource input) { ! ! RDFParser parser = new RDFParser(); ! loading = true; ! try { ! parser.parse(input, this); ! } ! catch (Exception e) { e.printStackTrace(); } + loading = false; + resetDirty(); + fireGraphContentsChanged(); + } ! /** ! * @see edu.unika.aifb.rdf.api.syntax.RDFConsumer#startModel(java.lang.String) ! */ ! public void startModel(String physicalURI) throws SAXException { ! ! if (DEBUG) System.out.println("RDF: startModel"); ! } ! ! /** ! * @see edu.unika.aifb.rdf.api.syntax.RDFConsumer#endModel() ! */ ! public void endModel() throws SAXException { ! ! if (DEBUG) System.out.println("RDF: endModel"); ! } ! ! /** ! * @see edu.unika.aifb.rdf.api.syntax.RDFConsumer#statementWithResourceValue(java.lang.String, java.lang.String, java.lang.String) ! */ ! public void statementWithResourceValue(String subject, String predicate, String object) throws SAXException { ! ! //if (predicate.equals(NS.graphl + "connectedTo")) { ! // get / create node with label subject ! ! if (loadingURL != null) { ! try { ! subject = new URL(loadingURL, subject).toString(); ! } ! catch (MalformedURLException muex) { ! // do nothing ! } ! try { ! object = new URL(loadingURL, object).toString(); ! } ! catch (MalformedURLException muex) { ! // do nothing ! } ! } ! ! Node snode; ! Node onode; try { ! snode = getNodeOrNew(subject); ! onode = getNodeOrNew(object); ! ! // get / create connection ! List edges = snode.getEdgesFrom(); ! RDFEdge edge = null; ! boolean exists = false; ! ! for (Iterator iter = edges.iterator(); iter.hasNext();) { ! edge = (RDFEdge) iter.next(); ! if ((edge.getTo() == onode) && (edge.getType().equals(predicate))) { ! exists = true; ! break; ! } ! } ! ! if (!exists) { ! 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); ! ! if (predicate.equals("http://www.w3.org/2002/07/owl#imports") || predicate.equals(NS.rdfs + "seeAlso")) { ! //if (predicate.equals("http://www.w3.org/2002/07/owl#imports")) { ! URL oldBase = loadingURL; ! Node oldSource = sourceNode; ! try { ! URL importURL = new URL(loadingURL, object); ! System.out.println("importing " + importURL.toString() + " ... "); ! importFromURL(importURL); ! // restore original base url ! } ! catch (Exception ex) { ! System.out.println("Error importing " + object); ! } ! finally { ! loadingURL = oldBase; ! sourceNode = oldSource; ! } ! } ! } ! } ! catch (Exception ex) { ! if (DEBUG) System.out.println("Error while reading triple: " + subject + ", " + predicate + ", " + object); ! //ex.printStackTrace(); } + } ! public Node getNodeOrNew(String uri) { + RDFNode node = getNodeById(uri); + if (node == null) { + node = new RDFNode(this, uri); + float r = 20 + loadCount; + loadAlpha += 30 / r; + 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; + } ! public Node createNode() { + RDFNode node = new RDFNode(this); + addElements(Collections.singleton(node), null); + return node; + } ! public Edge createEdge(Node from, Node to) { ! RDFEdge edge = new RDFEdge(from, to); ! if (loadingURL != null) { ! edge.setSource(loadingURL.toString()); ! } ! else { ! edge.setSource(NS.graphl + "USER"); ! } ! addElements(null, Collections.singleton(edge)); ! return edge; ! } ! /** ! * @see edu.unika.aifb.rdf.api.syntax.RDFConsumer#statementWithLiteralValue(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String) ! */ ! public void statementWithLiteralValue(String subject, String predicate, String object, String language, String datatype) throws SAXException { ! // get absolute URL for subject ! if (loadingURL != null) { ! try { ! subject = new URL(loadingURL, subject).toString(); ! } ! catch (MalformedURLException muex) { ! // do nothing ! } ! } ! Node snode; ! try { ! snode = getNodeOrNew(subject); ! snode.setProperty(predicate, object); ! if (DEBUG) System.out.println("created property " + subject + ", " + predicate + ", " + object); ! } ! catch (Exception ex) { ! if (DEBUG) System.out.println("Error while reading triple: " + subject + ", " + predicate + ", " + object); ! } ! } ! /** ! * @see edu.unika.aifb.rdf.api.syntax.RDFConsumer#logicalURI(java.lang.String) ! */ ! public void logicalURI(String logicalURI) throws SAXException { + if (DEBUG) System.out.println("RDF: logicalURI: " + logicalURI); + } ! /** ! * @see edu.unika.aifb.rdf.api.syntax.RDFConsumer#includeModel(java.lang.String, java.lang.String) ! */ ! public void includeModel(String logicalURI, String physicalURI) throws SAXException { + if (DEBUG) System.out.println("RDF: includeModel: " + logicalURI + ", " + physicalURI); + } ! /** ! * @see edu.unika.aifb.rdf.api.syntax.RDFConsumer#addModelAttribte(java.lang.String, java.lang.String) ! */ ! public void addModelAttribte(String key, String value) throws SAXException { + if (DEBUG) System.out.println("RDF: addModelAttribte" + key + ", " + value); + } /** * @return Returns the dirty flag. */ public boolean isDirty() { + return dirty; } ! /** * @param dirty New value for dirty flag. */ public void setDirty(boolean dirty) { + this.dirty = dirty; } ! public void setDirty() { + setDirty(true); } ! public void resetDirty() { + setDirty(false); } ! /* * Overrides @see de.fzi.wim.guibase.graphview.graph.DefaultGraph#addElements(java.util.Collection, java.util.Collection) */ public synchronized void addElements(Collection nodes, Collection edges) { + setDirty(); super.addElements(nodes, edges); ! if (nodes != null) { ! for (Iterator iter = nodes.iterator(); iter.hasNext();) { ! RDFNode node = (RDFNode) iter.next(); ! allNodes.put(node.getId(), node); } } } ! /* * Overrides @see de.fzi.wim.guibase.graphview.graph.DefaultGraph#clear() */ public synchronized void clear() { + setDirty(); allNodes.clear(); *************** *** 423,431 **** loadCount = 0; } ! /* * Overrides @see de.fzi.wim.guibase.graphview.graph.DefaultGraph#deleteElements(java.util.Collection, java.util.Collection) */ public synchronized void deleteElements(Collection nodes, Collection edges) { setDirty(); super.deleteElements(nodes, edges); --- 452,461 ---- loadCount = 0; } ! /* * Overrides @see de.fzi.wim.guibase.graphview.graph.DefaultGraph#deleteElements(java.util.Collection, java.util.Collection) */ public synchronized void deleteElements(Collection nodes, Collection edges) { + setDirty(); super.deleteElements(nodes, edges); *************** *** 433,441 **** if (nodes != null) { for (Iterator iter = nodes.iterator(); iter.hasNext();) { ! RDFNode node = (RDFNode) iter.next(); ! allNodes.remove(node.getId()); } } } ! } --- 463,471 ---- if (nodes != null) { for (Iterator iter = nodes.iterator(); iter.hasNext();) { ! RDFNode node = (RDFNode) iter.next(); ! allNodes.remove(node.getId()); } } } ! } |