1 | /* |
---|
2 | * Copyright (C) 2013 DASISH |
---|
3 | * |
---|
4 | * This program is free software; you can redistribute it and/or |
---|
5 | * modify it under the terms of the GNU General Public License |
---|
6 | * as published by the Free Software Foundation; either version 2 |
---|
7 | * of the License, or (at your option) any later version. |
---|
8 | * |
---|
9 | * This program is distributed in the hope that it will be useful, |
---|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
12 | * GNU General Public License for more details. |
---|
13 | * |
---|
14 | * You should have received a copy of the GNU General Public License |
---|
15 | * along with this program; if not, write to the Free Software |
---|
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
17 | */ |
---|
18 | package eu.dasish.annotation.backend.dao; |
---|
19 | |
---|
20 | |
---|
21 | import eu.dasish.annotation.backend.NotInDataBaseException; |
---|
22 | import eu.dasish.annotation.schema.Access; |
---|
23 | import eu.dasish.annotation.schema.Notebook; |
---|
24 | import eu.dasish.annotation.schema.NotebookInfo; |
---|
25 | import java.util.List; |
---|
26 | import java.util.UUID; |
---|
27 | |
---|
28 | /** |
---|
29 | * |
---|
30 | * |
---|
31 | * @author olhsha@mpi.nl |
---|
32 | */ |
---|
33 | |
---|
34 | // TODO: not yet fully updated. |
---|
35 | |
---|
36 | public interface NotebookDao extends ResourceDao { |
---|
37 | |
---|
38 | |
---|
39 | /** |
---|
40 | * |
---|
41 | * GETTERS |
---|
42 | * |
---|
43 | **/ |
---|
44 | |
---|
45 | /** |
---|
46 | * |
---|
47 | * @param notebookID the internal ID of a notebook. |
---|
48 | * @return the internal database Id of the owner of the notebook. |
---|
49 | */ |
---|
50 | Number getOwner(Number notebookID); |
---|
51 | |
---|
52 | |
---|
53 | /** |
---|
54 | * |
---|
55 | * @param principalID the internal database id of some principal. |
---|
56 | * @param acessMode an {@link Access} object, representing one of the access modes: |
---|
57 | * "all", "write", "read" or "none". |
---|
58 | * @return the list of internal database id's of the notebooks for which "principalID" has "accessMode" access. |
---|
59 | */ |
---|
60 | List<Number> getNotebookIDs(Number principalID, Access accessMode); |
---|
61 | |
---|
62 | /** |
---|
63 | * @param principaID the internal database id of some principal. |
---|
64 | * @return the list of internal database id's of the notebooks for which "principalID" is the owner. |
---|
65 | */ |
---|
66 | List<Number> getNotebookIDsOwnedBy(Number principaID); |
---|
67 | |
---|
68 | |
---|
69 | |
---|
70 | /** |
---|
71 | * |
---|
72 | * @param notebookID the internal database id of a notebook. |
---|
73 | * @return the {@link NotebookInfo} object representing the notebook with notebookID, built on the corresponding row |
---|
74 | * in the "notebook" table. |
---|
75 | */ |
---|
76 | NotebookInfo getNotebookInfoWithoutOwner(Number notebookID); |
---|
77 | |
---|
78 | |
---|
79 | /** |
---|
80 | * |
---|
81 | * @param notebookID the internal database id of a notebook. |
---|
82 | * @return the {@link Notebook} object representing the notebook with notebookID. |
---|
83 | */ |
---|
84 | Notebook getNotebookWithoutAnnotationsAndAccesssAndOwner(Number notebookID); |
---|
85 | |
---|
86 | |
---|
87 | |
---|
88 | |
---|
89 | /** |
---|
90 | * |
---|
91 | * UPDATERS |
---|
92 | * |
---|
93 | * |
---|
94 | */ |
---|
95 | |
---|
96 | |
---|
97 | |
---|
98 | |
---|
99 | /** |
---|
100 | * |
---|
101 | * @param notebookID the internal database id of a notebook. |
---|
102 | * @param title a new title for the notebook. |
---|
103 | * @param ownerID the internal database id of the owner principal (or possibly, a new owner principal) of the notebook. |
---|
104 | * @return true if the notebook metadata are updated, false otherwise. |
---|
105 | */ |
---|
106 | boolean updateNotebookMetadata(Number notebookID, String title, Number ownerID); |
---|
107 | |
---|
108 | |
---|
109 | /** |
---|
110 | * |
---|
111 | * @param notebookID the internal database id of a notebook. |
---|
112 | * @param ownerID the internal database id of a new owner for the notebook. |
---|
113 | * @return true if the owner_id is in "notebook" table is updated to "ownerID", false otherwise. |
---|
114 | */ |
---|
115 | boolean setOwner(Number notebookID, Number ownerID); |
---|
116 | |
---|
117 | /** |
---|
118 | * |
---|
119 | * @param notebookID the internal database id of a notebook. |
---|
120 | * @param principalID the internal database id of a principal. |
---|
121 | * @param access an {@link Access} object. |
---|
122 | * @return true iff the access mode to "notebookID" for "principalID" has been assigned to "access"'s value. |
---|
123 | */ |
---|
124 | boolean updatePrincipalAccessForNotebook(Number notebookID, Number principalID, Access access); |
---|
125 | |
---|
126 | /** |
---|
127 | * |
---|
128 | * ADDERS |
---|
129 | * |
---|
130 | * |
---|
131 | */ |
---|
132 | |
---|
133 | /** |
---|
134 | * |
---|
135 | * @param notebook the {@link Notebook} object representing a notebook to be created in the database. |
---|
136 | * @param ownerID the internal database id of the owner principal. |
---|
137 | * @return the internal id of the created notebook. |
---|
138 | * @throws NotInDataBaseException if creating the notebook fails. |
---|
139 | */ |
---|
140 | public Number createNotebookWithoutAccesssAndAnnotations(Notebook notebook, Number ownerID) throws NotInDataBaseException; |
---|
141 | |
---|
142 | /** |
---|
143 | * |
---|
144 | * @param notebookID the internal database ID of a notebook. |
---|
145 | * @param annotationID the internal database ID of an annotation. |
---|
146 | * @return true if the row for the (notebookID,annotationID) has been added to the junction table |
---|
147 | * "notebooks_annotations". |
---|
148 | */ |
---|
149 | boolean addAnnotationToNotebook(Number notebookID, Number annotationID); |
---|
150 | |
---|
151 | /** |
---|
152 | * |
---|
153 | * @param notebookID the internal database ID of a notebook. |
---|
154 | * @param principalID the internal database ID of a principal. |
---|
155 | * @param access access an {@link Access} object. |
---|
156 | * @return true iff the "access" mode to "notebookID" has been assigned for "principalID" |
---|
157 | * in the corresponding junction table. |
---|
158 | */ |
---|
159 | boolean addAccessToNotebook(Number notebookID, Number principalID, Access access); |
---|
160 | |
---|
161 | |
---|
162 | |
---|
163 | /** |
---|
164 | * |
---|
165 | * DELETERS |
---|
166 | * |
---|
167 | * |
---|
168 | */ |
---|
169 | |
---|
170 | /** |
---|
171 | * |
---|
172 | * @param notebookID the internal database ID of a notebook. |
---|
173 | * @param annotationID the internal database ID of an annotation. |
---|
174 | * @return true iff the row for the (notebookID,annotationID) has been deleted from the junction table |
---|
175 | * "notebooks_annotations". |
---|
176 | */ |
---|
177 | boolean deleteAnnotationFromNotebook(Number notebookID, Number annotationID); |
---|
178 | |
---|
179 | /** |
---|
180 | * |
---|
181 | * @param notebookID the internal database ID of a notebook. |
---|
182 | * @return true iff all the rows with "notebookID" have been removed from "notebooks_annotations" table. |
---|
183 | */ |
---|
184 | boolean deleteAllAnnotationsFromNotebook(Number notebookID); |
---|
185 | |
---|
186 | /** |
---|
187 | * |
---|
188 | * @param notebookID the internal database ID of a notebook. |
---|
189 | * @param principalID the internal database ID of a principal. |
---|
190 | * @return true iff the row for the pair (notebookID, principlaID) has been removed from the "notebooks_principals_accesses" table. |
---|
191 | */ |
---|
192 | boolean deleteNotebookPrincipalAccess(Number notebookID, Number principalID); |
---|
193 | |
---|
194 | /** |
---|
195 | * |
---|
196 | * @param notebookID the internal database ID of a notebook. |
---|
197 | * @return true iff all the rows with "notebookID" have been removed from from the "notebooks_principals_accesses" table. |
---|
198 | */ |
---|
199 | boolean deleteAllAccesssForNotebook(Number notebookID); |
---|
200 | |
---|
201 | /** |
---|
202 | * |
---|
203 | * @param notebookID the internal database ID of a notebook. |
---|
204 | * @return true iff the notebook with "notebookID" has been removed from the "notebook" table. |
---|
205 | */ |
---|
206 | boolean deleteNotebook(Number notebookID); |
---|
207 | } |
---|