1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package olr.toolbar;
18
19 import java.util.Iterator;
20 import java.util.List;
21
22 import olr.om.RdfToolbar;
23 import olr.om.RdfToolbarPeer;
24 import olr.om.RdfUser;
25 import olr.statementpool.OlrStatementPool;
26
27 /***
28 * @version $Id: DBToolbarSession.java,v 1.18 2004/08/02 18:38:53 roku Exp $
29 */
30 public final class DBToolbarSession extends AbstractToolbarSession {
31
32 private RdfUser user = null;
33
34 DBToolbarSession(RdfUser user, OlrStatementPool statementPool) throws Exception {
35 super(statementPool);
36 this.user = user;
37 List modelUris = RdfToolbarPeer.getAllToolbars(getUser());
38
39 for (Iterator it = modelUris.iterator(); it.hasNext();) {
40 RdfToolbar modelUri = (RdfToolbar) it.next();
41 if (modelUri.getIsSchema())
42 super.addSchema(modelUri.getUri(), modelUri.getTitle());
43 else
44 super.addInstanceFile(modelUri.getUri(), modelUri.getTitle());
45 }
46 }
47
48 public boolean addSchema(String uri, String title) throws Exception {
49 boolean ok = super.addSchema(uri, title);
50 if (ok)
51 RdfToolbarPeer.addSchema(getUser(), uri, title);
52 return ok;
53 }
54
55 public boolean addInstanceFile(String uri, String title) throws Exception {
56 boolean ok = super.addInstanceFile(uri, title);
57 if (ok)
58 RdfToolbarPeer.addInstanceFile(getUser(), uri, title);
59 return ok;
60 }
61
62 public String removeModelAt(int n) throws Exception {
63 String uri = super.removeModelAt(n);
64 if (uri != null)
65 RdfToolbarPeer.delete(getUser(), uri);
66 return uri;
67 }
68
69 private RdfUser getUser() {
70 return this.user;
71 }
72 }