//(c): Tuomas J. Lukka and Matti Katila package org.fenfire.modules.pp; import com.hp.hpl.mesa.rdf.jena.model.*; //import java.util.*; import java.io.IOException; import java.rmi.*; import java.rmi.server.*; import gzz.util.URN5NameSpace; import com.hp.hpl.mesa.rdf.jena.vocabulary.RDF; /** The implementation of PPActions. */ public class PPActionsImpl extends UnicastRemoteObject implements PPActions { public static final String rcsid = "$Id: PPActionsImpl.java,v 1.1 2003/03/07 12:06:59 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); } static public Property CREATION_TIME = new PropertyImpl("http://fenfire.org/vocabularity/pp.html#creationTime"); static public Property COORD_X = new PropertyImpl("http://fenfire.org/vocabularity/pp.html#coordX"); static public Property COORD_Y = new PropertyImpl("http://fenfire.org/vocabularity/pp.html#coordY"); static public Property DEPTH = new PropertyImpl("http://fenfire.org/vocabularity/pp.html#depth"); static public Resource PAPER_TYPE = new ResourceImpl("http://fenfire.org/vocabularity/pp.html#paper_type"); static public Resource CONTAINS = new ResourceImpl("http://fenfire.org/vocabularity/pp.html#contains"); public PPActionsImpl(Model model) throws RemoteException { super(); setModel(model); } private Model model; public void setModel(Model model) { this.model = model; } // --- implement PPActions // public String newPaper() throws RemoteException { synchronized(model) { /* Cell n = center.h(d.d1, 1).N(d.d1); n.setText("Uusi paperi"); return n.getId(); */ // We need a unique uri for paper String uri = URN5NameSpace.instance().generateId(); Resource paper = model.createResource(uri); // and resource must be also paper.. paper.addProperty(RDF.type, PAPER_TYPE); // set creation time paper.addProperty(CREATION_TIME, "123"); // XXX we need iso 8601 time presentation here return uri; }} public void deletePaper(String paperURI) throws RemoteException { synchronized(model) { /* // must delete all notes first Cell paper = space.getCell(paperId).h(d.contains, -1); Cell c = paper.s(d.contains); while(c != null) { Cell c_next = c.s(d.contains, 1); deleteNote(c.getId()); c = c_next; } space.delete(paper); */ // not implemented // =============== }} public String newNote(String paperURI, int x, int y, String text) throws RemoteException { synchronized(model) { /* Cell c = space.getCell(paperId); p("New note\n"); c = c.N(d.contains); c.setText(text); // XXX null content crashes Cell arg = c.N(d.pan); arg.setText("" + x); arg = arg.N(d.pan); arg.setText("" + y); return c.getId(); */ // find the paper Resource paper = model.getResource(paperURI); // set note to paper paper.addProperty(CONTAINS, ); // We need a unique uri for note String uri = URN5NameSpace.instance().generateId(); Resource note = model.createResource(uri); // set coords note.addProperty(COORD_X, ""+x); note.addProperty(COORD_X, ""+x); // set depth... note.addProperty(DEPTH, "5"); // scale etc.. XXX }} public void deleteNote(String noteURI) throws RemoteException { synchronized(model) { /* // MUST DELETE ALL ASSOCS FIRST Cell note = space.getCell(noteId).h(d.clone); if (note.s(d.pan) == null || note.s(d.pan).t() == "") throw new Error("Not a note?!"); // Remove all occurrences Cell c = note.h(d.clone, -1).s(d.clone); while(c != null) { Cell left = c.s(d.association, -1); Cell right = c.s(d.association, 1); Cell assoc = null; int dir = 0; if (left != null) { assoc = left; dir = -1; } else if (right != null) { assoc = right; dir = 1; } Cell next = c.s(d.clone); detachNotes(c.getId(), dir, assoc.getId()); space.delete(c); c = next; } note.excise(d.pan); space.delete(note); */ // not implemented // =============== }} public void moveNote(String noteURI, int x, int y) throws RemoteException { synchronized(model) { /* Cell note = space.getCell(noteId); Cell arg = note.s(d.pan); arg.setText("" + x); arg = arg.s(d.pan); arg.setText("" + y); */ // not implemented // =============== }} 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 // =============== }} public void detachNotes(String id1, int side, String id2) throws RemoteException { synchronized(model) { /* Cell c1 = space.getCell(id1).h(d.clone); Cell c2 = space.getCell(id2).h(d.clone); for(; c1!=null; c1 = c1.s(d.clone)) { for(c2 = space.getCell(id2).h(d.clone); c2!=null; c2 = c2.s(d.clone)) { if ( c1.s(d.association, side) == c2 && c2.s(d.association, -side) == c1) { c2.disconnect(d.association, side); space.delete(c2); space.delete(c1); return; } } } */ // not implemented // =============== }} public void insertText(String noteURI, int offs, String text) throws RemoteException { synchronized(model) { /* Cell note = space.getCell(noteId); note.insertText(offs, text); */ // not implemented // =============== }} public void deleteText(String noteURI, int begin, int end) throws RemoteException { synchronized(model) { /* Cell note = space.getCell(noteId); note.deleteText(begin, end); */ // not implemented // =============== }} }