/[fenfire]/fenfire/org/fenfire/modules/pp/PPActionsImpl.java
ViewVC logotype

Diff of /fenfire/org/fenfire/modules/pp/PPActionsImpl.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by mudyc, Sat Mar 8 23:32:39 2003 UTC revision 1.7 by mudyc, Sun Mar 9 01:28:20 2003 UTC
# Line 70  public static final String rcsid = "$Id$ Line 70  public static final String rcsid = "$Id$
70      }}      }}
71    
72    
73        public String cloneNote(String paperURI, String noteURI,
74      public String newNote(String paperURI, int x, int y, String text)                              int x, int y, String text)
75          throws RemoteException          throws RemoteException
76      { synchronized(model) { try {      { synchronized(model) {  try {
77    
78          // find the paper          // find the paper
79          Resource paper = model.getResource(paperURI);          Resource paper = model.getResource(paperURI);
80                    
81          // We need a unique uri for note                  // note doesn't exist so we need to make one
82          String uri = URN5Namespace.instance.generateId();          String note_uri = URN5Namespace.instance.generateId();
83          Resource note = model.createResource(uri);          Resource note = model.createResource(note_uri);
84          note.addProperty(RDF.type, PP.Note);          note.addProperty(RDF.type, PP.Note);
85            
86          // set note to paper          // set note to paper
87          paper.addProperty(PP.Contains, note);          paper.addProperty(PP.Contains, note);
88    
# Line 95  public static final String rcsid = "$Id$ Line 95  public static final String rcsid = "$Id$
95    
96          // scale etc..  XXX          // scale etc..  XXX
97    
98          return uri;  
99            // content
100            if (noteURI == null) {
101                // then handle as a new note
102                
103                // ref to real data must be created
104                String data_uri = URN5Namespace.instance.generateId();
105                Resource data = model.createResource(data_uri);
106    
107                note.addProperty(PP.LinkToContentRef, data);
108                data.addProperty(PP.Data, text);
109    
110                } else {
111                // check if uri really exists?
112                // XXX maybe RDFException ?
113                Resource clone = model.getResource(noteURI);
114                Resource data = null;
115                NodeIterator iter =
116                    model.listObjectsOfProperty(clone, PP.LinkToContentRef);
117                while (iter.hasNext()) {
118                    data = (Resource) iter.next();
119                }
120                if (data == null)
121                    throw new Error("No data available when cloning!!!");
122                note.addProperty(PP.LinkToContentRef, data);
123            }
124            return note_uri;
125      } catch (RDFException e) {      } catch (RDFException e) {
126          pa("Fault doing a new note: "+e);          pa("Fault doing a clone/new note: "+e);
127          return "";          return "";
128      }}}      }}}
129    
130    
131        public String newNote(String paperURI, int x, int y, String text)  
132            throws RemoteException
133        { synchronized(model) {
134            return cloneNote(paperURI, null, x,y,text);
135        }}
136    
137    
138      public void deleteNote(String noteURI)      public void deleteNote(String noteURI)
139                      throws RemoteException                      throws RemoteException
140      { synchronized(model) { try {      { synchronized(model) { try {
# Line 158  public static final String rcsid = "$Id$ Line 192  public static final String rcsid = "$Id$
192          StmtIterator it = model.listStatements(selector);          StmtIterator it = model.listStatements(selector);
193          while (it.hasNext()) {          while (it.hasNext()) {
194              Statement stmt = it.next();              Statement stmt = it.next();
195              p("deleting "+stmt);              p("deleting X: "+stmt);
196              model.remove(stmt);              model.remove(stmt);
197          }          }
198          selector = new SelectorImpl(note, PP.CoordY, empty);          selector = new SelectorImpl(note, PP.CoordY, empty);
199          it = model.listStatements(selector);          it = model.listStatements(selector);
200          while (it.hasNext()) {          while (it.hasNext()) {
201              Statement stmt = it.next();              Statement stmt = it.next();
202              p("deleting "+stmt);              p("deleting Y"+stmt);
203              model.remove(stmt);              model.remove(stmt);
204          }          }
205    
# Line 178  public static final String rcsid = "$Id$ Line 212  public static final String rcsid = "$Id$
212    
213    
214      public void assocNotes(String noteURI, int side, String assocURI)      public void assocNotes(String noteURI, int side, String assocURI)
215          throws RemoteException { synchronized(model) {          throws RemoteException
216              /*      { synchronized(model) { try {
217          Cell note = space.getCell(noteId);          Resource note = model.getResource(noteURI);
218          Cell assoc = space.getCell(assocId);          Resource assoc = model.getResource(assocURI);
219          note.zzclone().connect(d.association, side, assoc.zzclone());              
220              */          // check if already associated
221            Selector slctr = new SelectorImpl(note, PP.Association, assoc);
222          // not implemented          StmtIterator iter = model.listStatements(slctr);
223          // ===============          if (iter.hasNext()) {
224                pa("Already associated!");
225                return;
226            }
227    
228      }}          // assoc
229            note.addProperty(PP.Association, assoc);
230        } catch (RDFException e) {
231            pa("Fault associationing notes: "+e);
232        }}}
233    
234      public void detachNotes(String id1, int side, String id2)      public void detachNotes(String id1, int side, String id2)
235          throws RemoteException { synchronized(model) {          throws RemoteException
236        { synchronized(model) {
237    
238              /*              /*
239          Cell c1 = space.getCell(id1).h(d.clone);          Cell c1 = space.getCell(id1).h(d.clone);
# Line 220  public static final String rcsid = "$Id$ Line 261  public static final String rcsid = "$Id$
261    
262    
263      public void insertText(String noteURI, int offs, String text)      public void insertText(String noteURI, int offs, String text)
264          throws RemoteException { synchronized(model) {          throws RemoteException
265        { synchronized(model) { try {
266              /*              /*
267          Cell note = space.getCell(noteId);          Cell note = space.getCell(noteId);
268          note.insertText(offs, text);          note.insertText(offs, text);
269              */              */
270    
         // not implemented  
         // ===============  
271    
272      }}          Resource note = model.getResource(noteURI);
273            
274            // find actual data
275            Selector s =
276                new SelectorImpl(note, PP.LinkToContentRef, (RDFNode) null);
277            StmtIterator iter = model.listStatements(s);
278            Statement stmt = null;
279            while (iter.hasNext()) {
280                if (stmt != null) throw new Error("Too many data!!");
281                stmt = iter.next();
282            }
283    
284            Resource data = (Resource) stmt.getObject();
285    
286            // find literal
287            s = new SelectorImpl(data, PP.Data, (RDFNode) null);
288            iter = model.listStatements(s);
289            stmt = null;
290            while (iter.hasNext()) {
291                if (stmt != null) throw new Error("Too many data!!");
292                stmt = iter.next();
293            }
294    
295            StringBuffer str = new StringBuffer(stmt.getObject().toString());
296            model.remove(stmt);
297            str.insert(offs, text);
298            data.addProperty(PP.Data, str.toString());
299    
300        } catch (RDFException e) {
301            pa("Fault inserting text to note: "+e);
302        }}}
303    
304    
305      public void deleteText(String noteURI, int begin, int end)      public void deleteText(String noteURI, int begin, int end)
306          throws RemoteException { synchronized(model) {          throws RemoteException { synchronized(model) {

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26