gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] fenfire/org/fenfire swamp/Graphs.java swamp/Gra...


From: Matti Katila
Subject: [Gzz-commits] fenfire/org/fenfire swamp/Graphs.java swamp/Gra...
Date: Wed, 28 May 2003 12:20:22 -0400

CVSROOT:        /cvsroot/fenfire
Module name:    fenfire
Changes by:     Matti Katila <address@hidden>   03/05/28 12:20:22

Modified files:
        org/fenfire/swamp: Graphs.java Graphs.test 
        org/fenfire/view/lava: FenPDFContext.java 

Log message:
        jena cannot save urn-5 resources - org.xml.sax.SAXParseException: An 
invalid second ':' was found in the element type or attribute name.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/swamp/Graphs.java.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/swamp/Graphs.test.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/lava/FenPDFContext.java.diff?tr1=1.25&tr2=1.26&r1=text&r2=text

Patches:
Index: fenfire/org/fenfire/swamp/Graphs.java
diff -u fenfire/org/fenfire/swamp/Graphs.java:1.6 
fenfire/org/fenfire/swamp/Graphs.java:1.7
--- fenfire/org/fenfire/swamp/Graphs.java:1.6   Wed May 28 09:45:50 2003
+++ fenfire/org/fenfire/swamp/Graphs.java       Wed May 28 12:20:22 2003
@@ -29,37 +29,44 @@
 import org.fenfire.swamp.impl.*;
 import com.hp.hpl.mesa.rdf.jena.model.*;
 import com.hp.hpl.mesa.rdf.jena.mem.*;
+import com.hp.hpl.mesa.rdf.jena.common.*;
 import java.util.Iterator;
 
 public class Graphs {
-    public static boolean dbg = true;
+    public static boolean dbg = false;
     public static void p(String s) { System.out.println("swamp.Graphs:: "+s); }
 
+    final private static String urn5 = //"urn5";
+    "http://www.iana.org/assignments/urn-informal/urn-5";;
+
     public static Model toModel(ConstGraph g) {
        try {
            Model m = new ModelMem();
            for (Iterator i=g.findN_XAA_Iter(); i.hasNext();) {
                Object o = i.next();
-               Resource sub = m.createResource(Nodes.toString(o));
+               //Resource sub = m.createResource("", Nodes.toString(o));
+               Resource sub = new ResourceImpl(urn5, Nodes.toString(o), m);
 
                for (Iterator j=g.findN_1XA_Iter(o); j.hasNext();) {
                    Object p = j.next();
-                   Property prop = m.createProperty("", Nodes.toString(p));
+                   Property prop = m.createProperty(urn5, Nodes.toString(p));
 
                    for (Iterator k=g.findN_11X_Iter(o,p); k.hasNext();) {
                        Object q = k.next();
                        if(q instanceof Literal) {      
-                            p("Literal! : "+ q);
+                            if (dbg) p("Literal! : "+ q);
                             String s = ((Literal)q).getTextString();
                             sub.addProperty(prop, s);
                        } else {
-                            p("Resource! : "+ q);
-                           Resource ob = m.createResource(Nodes.toString(q));
-                           sub.addProperty(prop, o);
+                            if (dbg) p("Resource! : "+ q);
+                           //Resource ob = m.createResource("", 
Nodes.toString(q));
+                            Resource ob = new ResourceImpl(urn5, 
Nodes.toString(q), m);
+                           sub.addProperty(prop, ob);
                        }
                    }
                }
            }
+            if (dbg) m.write(new java.io.PrintWriter(System.out));
            return m;
        } catch(Exception e) {
            throw new Error("Exception converting graph "+e);
@@ -72,9 +79,10 @@
                 p("toGraph!"); 
                 StmtIterator j=m.listStatements(); 
                 while(j.hasNext()) {
-                    p("And there are: "+ 
-                      ((Statement)j.next()).getString() );
+                    p("And there are: "); 
+                    p("  "+ j.next() );
                 }
+                p("ok?!");
             }
 
            Graph g = new HashGraph();
@@ -92,7 +100,7 @@
            }
            return g;
        } catch(Exception e) {
-           throw new Error("Exception converting graph");
+           throw new Error("Exception converting graph" + e);
        }
     }
 }
Index: fenfire/org/fenfire/swamp/Graphs.test
diff -u fenfire/org/fenfire/swamp/Graphs.test:1.2 
fenfire/org/fenfire/swamp/Graphs.test:1.3
--- fenfire/org/fenfire/swamp/Graphs.test:1.2   Wed May 28 09:45:50 2003
+++ fenfire/org/fenfire/swamp/Graphs.test       Wed May 28 12:20:22 2003
@@ -7,22 +7,54 @@
 
 file = 'org.fenfire.swamp.Graphs.testFileSaveAndLoad.test.data'
 
-def testFileSaveAndLoad():
+
+def testFileSaveAndLoadSimple():
+    """ Makes resources as aesy as 'a0', 'a1' and such
+    """
+
     g = swamp.impl.HashGraph()
     n = swamp.Nodes()
+
     for i in range(0,10):
         g.add(n.get('a'+str(i)), n.get('b'+str(i)), n.get('c'+str(i)))
 
     #### Save
     m = swamp.Graphs.toModel(g)
-    # Without 'RDF/XML' this test will throw an exception!
-    m.write(java.io.FileWriter(file), 'RDF/XML')
-    m.write(java.io.PrintWriter(System.out))
+    m.write(java.io.FileWriter(file))
+    swamp.Graphs.toGraph(m)
+
+    #### Load
+    m = jena.mem.ModelMem()
+    m = m.read(java.io.FileReader(file), None)
+    g = swamp.Graphs.toGraph(m)
+    
+    iter = g.findN_XAA_Iter()
+    for i in range(0,10):
+        assert iter.hasNext()
+        assert iter.next() != None
+    
+    #### clean
+    os.system('rm '+file)
+
+
+def testFileSaveAndLoadUrn5():
+    """ Uses real urn-5 resources
+    """
+    swamp.Graphs.dbg = 1
+    
+    g = swamp.impl.HashGraph()
+    n = swamp.Nodes()
+    for i in range(0,10):
+        g.add(n.N(), n.N(), n.N() )
+
+    #### Save
+    m = swamp.Graphs.toModel(g)
+    m.write(java.io.FileWriter(file))
+    swamp.Graphs.toGraph(m)
 
     #### Load
     m = jena.mem.ModelMem()
-    # this loads nothing!
-    m.read(java.io.FileReader(file), 'RDF/XML')
+    m = m.read(java.io.FileReader(file), None)
     g = swamp.Graphs.toGraph(m)
     
     iter = g.findN_XAA_Iter()
Index: fenfire/org/fenfire/view/lava/FenPDFContext.java
diff -u fenfire/org/fenfire/view/lava/FenPDFContext.java:1.25 
fenfire/org/fenfire/view/lava/FenPDFContext.java:1.26
--- fenfire/org/fenfire/view/lava/FenPDFContext.java:1.25       Wed May 28 
07:57:19 2003
+++ fenfire/org/fenfire/view/lava/FenPDFContext.java    Wed May 28 12:20:22 2003
@@ -276,18 +276,26 @@
                fen.constgraph = fen.graph = Graphs.toGraph(m);
                 int i = 0;
                 Iterator it = fen.graph.findN_11X_Iter(SAVE.State, SAVE.point);
+                p("Going to iterate graph if iter has: " + it.hasNext());
                 while (it.hasNext() && i<mainNodes.length) {
                     Object plane = it.next();
-                    if (fen.graph.find1_11X(accursed[i], RDF.type) == 
+                    if (fen.graph.find1_11X(plane, RDF.type) == 
                         CANVAS2D.Canvas) {
                         mainNodes[i] = new MainNode2D(plane, 
                                                       ppView, 0,0,1);
+                        p("mainNode");
                     } else {
                         mainNodes[i] = new 
                             FisheyeMainNode2D(plane, 
                                               new PageScrollView2D(), 0,0);
+                        p("fishNode");
                     }
                     i++;
+                }
+
+                for (i=0; i<mainNodes.length; i++) {
+                    p("main:"+mainNodes[i]+
+                      "\n  plane: "+ mainNodes[i].getPlane()); 
                 }
                 AbstractUpdateManager.chg();
                return null;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]