1 |
//(c): Tuomas J. Lukka and Matti Katila |
//(c): Tuomas J. Lukka and Matti Katila |
2 |
|
|
3 |
package org.fenfire.modules.pp; |
package org.fenfire.modules.pp; |
4 |
|
import org.fenfire.util.URN5Namespace; |
|
//import java.util.*; |
|
5 |
import java.io.IOException; |
import java.io.IOException; |
6 |
import java.rmi.*; |
import java.rmi.*; |
7 |
import java.rmi.server.*; |
import java.rmi.server.*; |
|
|
|
|
//import gzz.util.URN5NameSpace; |
|
8 |
import com.hp.hpl.mesa.rdf.jena.vocabulary.RDF; |
import com.hp.hpl.mesa.rdf.jena.vocabulary.RDF; |
9 |
import com.hp.hpl.mesa.rdf.jena.model.*; |
import com.hp.hpl.mesa.rdf.jena.model.*; |
10 |
import com.hp.hpl.mesa.rdf.jena.common.*; |
import com.hp.hpl.mesa.rdf.jena.common.*; |
17 |
protected static void p(String s) { if(dbg) pa(s); } |
protected static void p(String s) { if(dbg) pa(s); } |
18 |
protected static void pa(String s) { System.out.println(s); } |
protected static void pa(String s) { System.out.println(s); } |
19 |
|
|
20 |
|
private PPVocab PP = new PPVocab(); |
21 |
class URN5NameSpace { |
private Model model; |
22 |
public String generateId() { return "foobar"; } |
public void setModel(Model model) { this.model = model; } |
|
} |
|
|
|
|
|
|
|
|
// Propertys |
|
|
static public Property CONTAINS; |
|
|
static public Property CREATION_TIME; |
|
|
static public Property COORD_X; |
|
|
static public Property COORD_Y; |
|
|
static public Property DEPTH; |
|
|
|
|
|
|
|
|
// Resources |
|
|
static public Resource PAPER_TYPE; |
|
|
static public Resource NOTE; |
|
|
|
|
|
|
|
23 |
|
|
24 |
public PPActionsImpl(Model model) throws RemoteException { |
public PPActionsImpl(Model model) throws RemoteException { |
25 |
super(); |
super(); |
26 |
setModel(model); |
setModel(model); |
|
|
|
|
String pp_voc = "http://fenfire.org/vocabulary/pp.html"; |
|
|
try { |
|
|
// Propertys |
|
|
CONTAINS = new PropertyImpl(pp_voc+"#contains"); |
|
|
CREATION_TIME = new PropertyImpl(pp_voc + "#creationTime"); |
|
|
COORD_X = new PropertyImpl(pp_voc + "#coordX"); |
|
|
COORD_Y = new PropertyImpl(pp_voc + "#coordY"); |
|
|
DEPTH = new PropertyImpl(pp_voc + "#depth"); |
|
|
|
|
|
// Resources |
|
|
PAPER_TYPE = new ResourceImpl(pp_voc + "#paper_type"); |
|
|
NOTE = new ResourceImpl(pp_voc + "#note"); |
|
|
} catch (RDFException e) { |
|
|
pa("Failed: "+e); |
|
|
} |
|
27 |
} |
} |
28 |
|
|
|
private Model model; |
|
|
public void setModel(Model model) { this.model = model; } |
|
29 |
|
|
30 |
|
|
31 |
// --- implement PPActions |
// --- implement PPActions |
32 |
// |
// |
33 |
public String newPaper() throws RemoteException |
public String newPaper() throws RemoteException |
34 |
{ synchronized(model) { |
{ synchronized(model) { try { |
|
/* |
|
|
Cell n = center.h(d.d1, 1).N(d.d1); |
|
|
n.setText("Uusi paperi"); |
|
|
return n.getId(); |
|
|
*/ |
|
|
|
|
|
try { |
|
|
|
|
|
// We need a unique uri for paper |
|
|
String uri = (new URN5NameSpace()).generateId(); |
|
|
Resource paper = model.createResource(uri); |
|
|
|
|
|
// and resource must be also paper.. |
|
|
paper.addProperty(RDF.type, PAPER_TYPE); |
|
35 |
|
|
36 |
// set creation time |
// We need a unique uri for paper |
37 |
paper.addProperty(CREATION_TIME, "123"); // XXX we need iso 8601 time presentation here |
String uri = URN5Namespace.instance.generateId(); |
38 |
|
Resource paper = model.createResource(uri); |
39 |
|
|
40 |
|
// and resource must be also paper.. |
41 |
|
paper.addProperty(RDF.type, PP.PaperType); |
42 |
|
|
43 |
|
// set creation time |
44 |
|
// XXX we need iso 8601 time presentation here |
45 |
|
paper.addProperty(PP.CreationTime, "123"); |
46 |
|
|
47 |
return uri; |
return uri; |
48 |
} catch (RDFException e) { |
} catch (RDFException e) { |
49 |
return ""; |
return ""; |
50 |
} |
}}} |
|
}} |
|
51 |
|
|
52 |
|
|
53 |
public void deletePaper(String paperURI) throws RemoteException |
public void deletePaper(String paperURI) throws RemoteException |
79 |
Resource paper = model.getResource(paperURI); |
Resource paper = model.getResource(paperURI); |
80 |
|
|
81 |
// We need a unique uri for note |
// We need a unique uri for note |
82 |
String uri = (new URN5NameSpace()).generateId(); |
String uri = URN5Namespace.instance.generateId(); |
83 |
Resource note = model.createResource(uri); |
Resource note = model.createResource(uri); |
84 |
note.addProperty(RDF.type, NOTE); |
note.addProperty(RDF.type, PP.Note); |
85 |
|
|
86 |
// set note to paper |
// set note to paper |
87 |
paper.addProperty(CONTAINS, note); |
paper.addProperty(PP.Contains, note); |
88 |
|
|
89 |
// set coords |
// set coords |
90 |
note.addProperty(COORD_X, ""+x); |
note.addProperty(PP.CoordX, ""+x); |
91 |
note.addProperty(COORD_X, ""+x); |
note.addProperty(PP.CoordX, ""+x); |
92 |
|
|
93 |
// set depth... |
// set depth... |
94 |
note.addProperty(DEPTH, "5"); |
note.addProperty(PP.Depth, "5"); |
95 |
|
|
96 |
// scale etc.. XXX |
// scale etc.. XXX |
97 |
|
|