[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] fenfire/org/fenfire/modules/pp PPActions.java P...
From: |
Matti Katila |
Subject: |
[Gzz-commits] fenfire/org/fenfire/modules/pp PPActions.java P... |
Date: |
Sat, 08 Mar 2003 20:28:20 -0500 |
CVSROOT: /cvsroot/fenfire
Module name: fenfire
Changes by: Matti Katila <address@hidden> 03/03/08 20:28:20
Modified files:
org/fenfire/modules/pp: PPActions.java PPActionsImpl.java
PPVocab.java
Log message:
fixes + insert implemention
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/modules/pp/PPActions.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/modules/pp/PPActionsImpl.java.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/modules/pp/PPVocab.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
Patches:
Index: fenfire/org/fenfire/modules/pp/PPActions.java
diff -u fenfire/org/fenfire/modules/pp/PPActions.java:1.1
fenfire/org/fenfire/modules/pp/PPActions.java:1.2
--- fenfire/org/fenfire/modules/pp/PPActions.java:1.1 Fri Mar 7 07:06:59 2003
+++ fenfire/org/fenfire/modules/pp/PPActions.java Sat Mar 8 20:28:20 2003
@@ -21,6 +21,14 @@
void deletePaper(String paperURI)
throws RemoteException;
+ /** Create a clone note of other note.
+ * @param noteURI if null cloneNote acts like newNote()
+ * @see newNote()
+ */
+ String cloneNote(String paperURI, String noteURI,
+ int x, int y, String text)
+ throws RemoteException;
+
/** Create a new note and optionally place some text into it.
* @param text (Optional, may be null) The text to be placed
* in the new note. This parameter is given so that
Index: fenfire/org/fenfire/modules/pp/PPActionsImpl.java
diff -u fenfire/org/fenfire/modules/pp/PPActionsImpl.java:1.6
fenfire/org/fenfire/modules/pp/PPActionsImpl.java:1.7
--- fenfire/org/fenfire/modules/pp/PPActionsImpl.java:1.6 Sat Mar 8
18:32:39 2003
+++ fenfire/org/fenfire/modules/pp/PPActionsImpl.java Sat Mar 8 20:28:20 2003
@@ -12,7 +12,7 @@
/** The implementation of PPActions.
*/
public class PPActionsImpl extends UnicastRemoteObject implements PPActions {
-public static final String rcsid = "$Id: PPActionsImpl.java,v 1.6 2003/03/08
23:32:39 mudyc Exp $";
+public static final String rcsid = "$Id: PPActionsImpl.java,v 1.7 2003/03/09
01:28:20 mudyc Exp $";
public static final boolean dbg = true;
protected static void p(String s) { if(dbg) pa(s); }
protected static void pa(String s) { System.out.println(s); }
@@ -70,19 +70,19 @@
}}
-
- public String newNote(String paperURI, int x, int y, String text)
+ public String cloneNote(String paperURI, String noteURI,
+ int x, int y, String text)
throws RemoteException
- { synchronized(model) { try {
+ { synchronized(model) { try {
// find the paper
Resource paper = model.getResource(paperURI);
- // We need a unique uri for note
- String uri = URN5Namespace.instance.generateId();
- Resource note = model.createResource(uri);
+ // note doesn't exist so we need to make one
+ String note_uri = URN5Namespace.instance.generateId();
+ Resource note = model.createResource(note_uri);
note.addProperty(RDF.type, PP.Note);
-
+
// set note to paper
paper.addProperty(PP.Contains, note);
@@ -95,12 +95,46 @@
// scale etc.. XXX
- return uri;
+
+ // content
+ if (noteURI == null) {
+ // then handle as a new note
+
+ // ref to real data must be created
+ String data_uri = URN5Namespace.instance.generateId();
+ Resource data = model.createResource(data_uri);
+
+ note.addProperty(PP.LinkToContentRef, data);
+ data.addProperty(PP.Data, text);
+
+ } else {
+ // check if uri really exists?
+ // XXX maybe RDFException ?
+ Resource clone = model.getResource(noteURI);
+ Resource data = null;
+ NodeIterator iter =
+ model.listObjectsOfProperty(clone, PP.LinkToContentRef);
+ while (iter.hasNext()) {
+ data = (Resource) iter.next();
+ }
+ if (data == null)
+ throw new Error("No data available when cloning!!!");
+ note.addProperty(PP.LinkToContentRef, data);
+ }
+ return note_uri;
} catch (RDFException e) {
- pa("Fault doing a new note: "+e);
+ pa("Fault doing a clone/new note: "+e);
return "";
}}}
+
+ public String newNote(String paperURI, int x, int y, String text)
+ throws RemoteException
+ { synchronized(model) {
+ return cloneNote(paperURI, null, x,y,text);
+ }}
+
+
public void deleteNote(String noteURI)
throws RemoteException
{ synchronized(model) { try {
@@ -158,14 +192,14 @@
StmtIterator it = model.listStatements(selector);
while (it.hasNext()) {
Statement stmt = it.next();
- p("deleting "+stmt);
+ p("deleting X: "+stmt);
model.remove(stmt);
}
selector = new SelectorImpl(note, PP.CoordY, empty);
it = model.listStatements(selector);
while (it.hasNext()) {
Statement stmt = it.next();
- p("deleting "+stmt);
+ p("deleting Y"+stmt);
model.remove(stmt);
}
@@ -178,21 +212,28 @@
public void assocNotes(String noteURI, int side, String assocURI)
- throws RemoteException { synchronized(model) {
- /*
- Cell note = space.getCell(noteId);
- Cell assoc = space.getCell(assocId);
- note.zzclone().connect(d.association, side, assoc.zzclone());
- */
-
- // not implemented
- // ===============
-
+ throws RemoteException
+ { synchronized(model) { try {
+ Resource note = model.getResource(noteURI);
+ Resource assoc = model.getResource(assocURI);
+
+ // check if already associated
+ Selector slctr = new SelectorImpl(note, PP.Association, assoc);
+ StmtIterator iter = model.listStatements(slctr);
+ if (iter.hasNext()) {
+ pa("Already associated!");
+ return;
+ }
- }}
+ // assoc
+ note.addProperty(PP.Association, assoc);
+ } catch (RDFException e) {
+ pa("Fault associationing notes: "+e);
+ }}}
public void detachNotes(String id1, int side, String id2)
- throws RemoteException { synchronized(model) {
+ throws RemoteException
+ { synchronized(model) {
/*
Cell c1 = space.getCell(id1).h(d.clone);
@@ -220,16 +261,46 @@
public void insertText(String noteURI, int offs, String text)
- throws RemoteException { synchronized(model) {
+ throws RemoteException
+ { synchronized(model) { try {
/*
Cell note = space.getCell(noteId);
note.insertText(offs, text);
*/
- // not implemented
- // ===============
- }}
+ Resource note = model.getResource(noteURI);
+
+ // find actual data
+ Selector s =
+ new SelectorImpl(note, PP.LinkToContentRef, (RDFNode) null);
+ StmtIterator iter = model.listStatements(s);
+ Statement stmt = null;
+ while (iter.hasNext()) {
+ if (stmt != null) throw new Error("Too many data!!");
+ stmt = iter.next();
+ }
+
+ Resource data = (Resource) stmt.getObject();
+
+ // find literal
+ s = new SelectorImpl(data, PP.Data, (RDFNode) null);
+ iter = model.listStatements(s);
+ stmt = null;
+ while (iter.hasNext()) {
+ if (stmt != null) throw new Error("Too many data!!");
+ stmt = iter.next();
+ }
+
+ StringBuffer str = new StringBuffer(stmt.getObject().toString());
+ model.remove(stmt);
+ str.insert(offs, text);
+ data.addProperty(PP.Data, str.toString());
+
+ } catch (RDFException e) {
+ pa("Fault inserting text to note: "+e);
+ }}}
+
public void deleteText(String noteURI, int begin, int end)
throws RemoteException { synchronized(model) {
Index: fenfire/org/fenfire/modules/pp/PPVocab.java
diff -u fenfire/org/fenfire/modules/pp/PPVocab.java:1.2
fenfire/org/fenfire/modules/pp/PPVocab.java:1.3
--- fenfire/org/fenfire/modules/pp/PPVocab.java:1.2 Sat Mar 8 18:32:39 2003
+++ fenfire/org/fenfire/modules/pp/PPVocab.java Sat Mar 8 20:28:20 2003
@@ -5,7 +5,7 @@
import com.hp.hpl.mesa.rdf.jena.common.*;
public class PPVocab {
-public static final String rcsid = "$Id: PPVocab.java,v 1.2 2003/03/08
23:32:39 mudyc Exp $";
+public static final String rcsid = "$Id: PPVocab.java,v 1.3 2003/03/09
01:28:20 mudyc Exp $";
public static final boolean dbg = true;
protected static void p(String s) { if(dbg) pa(s); }
protected static void pa(String s) { System.out.println(s); }
@@ -16,10 +16,14 @@
public Property CoordX;
public Property CoordY;
public Property Depth;
+ public Property Association;
+ public Property LinkToContentRef;
+ public Property Data;
// Resources
public Resource PaperType;
public Resource Note;
+ public Resource DataType;
public PPVocab() {
String pp_voc = "http://fenfire.org/vocabulary/pp.html";
@@ -31,10 +35,18 @@
CoordX = new PropertyImpl(spatial_voc + "#coordX");
CoordY = new PropertyImpl(spatial_voc + "#coordY");
Depth = new PropertyImpl(spatial_voc + "#depth");
+ Association = new PropertyImpl(pp_voc + "#association");
+
+ LinkToContentRef =
+ new PropertyImpl(pp_voc + "#linkToContentReference");
+ Data = new PropertyImpl(pp_voc + "#realData");
+
+
// Resources
- PaperType = new ResourceImpl(pp_voc + "#paper_type");
+ PaperType = new ResourceImpl(pp_voc + "#paperType");
Note = new ResourceImpl(pp_voc + "#note");
+ DataType = new ResourceImpl(pp_voc + "#dataType");
} catch (RDFException e) {
p("Failed: "+e);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] fenfire/org/fenfire/modules/pp PPActions.java P...,
Matti Katila <=