source: DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/AnnotationDao.java @ 5989

Last change on this file since 5989 was 5989, checked in by olhsha@mpi.nl, 9 years ago

Javadoc are updated for the interface.

File size: 11.6 KB
Line 
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 */
18package eu.dasish.annotation.backend.dao;
19
20import eu.dasish.annotation.backend.NotInDataBaseException;
21import eu.dasish.annotation.schema.Annotation;
22import eu.dasish.annotation.schema.AnnotationBody;
23import eu.dasish.annotation.schema.AnnotationInfo;
24import eu.dasish.annotation.schema.Access;
25import java.sql.SQLException;
26import java.util.List;
27import java.util.UUID;
28
29/**
30 * Created on : Jun 27, 2013, 10:34:13 AM
31 *
32 * @author Peter Withers <peter.withers@mpi.nl>
33 */
34
35
36public interface AnnotationDao extends ResourceDao{
37   
38   
39    /**
40     * GETTERS
41     */
42   
43    /**
44     *
45     * @param headline the headline of an annotation.
46     * @return the list of uuid-s of the annotations with this headline; may be empty.
47     */
48    public List<UUID> getExternalIdFromHeadline(String headline);
49   
50    /**
51     *
52     * @param headline the headline of an annotation.
53     * @return the list of internal (database) identifiers of the annotations with this headline; may be empty.
54     */
55    public List<Number>  getInternalIDsFromHeadline(String headline);
56    /**
57     *
58     * @param annotationID the internal (database) identifier of an annotation.
59     * @return the {@link Annotation} object whose fields are filled in partially,
60     * only with the information accessible from the table "annotation".
61     * Constructing a complete {@link Annotation} object is done in the implementation of {@link DBDispatchter}.)
62     */
63    public Annotation getAnnotationWithoutTargetsAndPemissionList(Number annotationID);
64   
65    /**
66     *
67     * @param ownerID the owner of annotations we search for; if null then the owner may be any.
68     * @param text the text fragment which must occur in an annotation-body; if null, the now requirements on the annotation body.
69     * @param namespace (search on the parameter is not implemented).
70     * @param after the earliest time of creating/last-update of annotations; if null then search "from the beginning of time".
71     * @param before the latest time of creating/last-update of annotations; if null then search "till now".
72     * @return
73     */ 
74    public List<Number> getFilteredAnnotationIDs(Number ownerID, String text, String namespace, String after, String before);
75     
76    /**
77     *
78     * @param principalID the internal database ID of a principal (user or, in general, a group).
79     * @param acess access level (none, read, write, all).
80     * @return the list of internal (database) annotation identifiers to which "principalID" has access at least "acess".
81     * For instance, on access==write, the method should output id-s of the annotations to which user has "write" (update bodies),
82     * or "all" access, according to the junction table "annotations-principals-acesses".
83     */
84    public List<Number> getAnnotationIDsPermissionAtLeast(Number principalID, Access acess);
85   
86    /**
87     *
88     * @param access the value of public assess of an annotation.
89     * @return The list of internal (database identifiers to which public has at least "access" access;
90     * for instance on "write" the method should output annotations
91     * whose "public" value is "write" or "all".
92     */
93    public List<Number> getAnnotationIDsPublicAtLeast(Access access);
94   
95   
96 
97    /**
98     *
99     * @return the list of the internal (database) annotation IDs of all the annotations;
100     * used only by the developers and the admin in the debugging mode to access all the existing annotations.
101     */
102    public List<Number> getAllAnnotationIDs();
103   
104    /**
105     *
106     * @param annotationIDs the list of internal annotationIDs.
107     * @param offset the offset parameter for SELECT SQL request.
108     * @param limit the limit parameter for SELECT SQL request.
109     * @param orderedBy criterion of ordering according to the SQL syntax (by some field).
110     * @param desc direction of ordering according to the SQL syntax.
111     * @return the SELECT response on the given parameters: i.e. the list of annotationID's starting from offset and to limit,
112     * if the database rows are ordered according to "orderedBy" and "desc".
113     */
114    public List<Number> sublistOrderedAnnotationIDs(List<Number> annotationIDs, int offset, int limit, String orderedBy, String desc);
115   
116     /**
117     * @param annotationIDs
118     * @return annotationInfo for the annotation with the internal annotationID:
119     * i.e. the information which you can take only from the "annotation" table
120     * and not the junction tables connecting the annotations to permissions and targets.
121     *
122     */
123    public AnnotationInfo getAnnotationInfoWithoutTargetsAndOwner(Number annotationID);   
124   
125    /**
126     *
127     * @param annotationIDs
128     * @return list of target references where the i-th reference is constructed from the external
129     * identifier of the annotation with the i-th internal identifier from the list.
130     */
131    public List<String> getAnnotationREFs(List<Number> annotationIDs); 
132   
133 
134    /**
135     *
136     * @param annotationID
137     * @return the internal database ID of the owner of the annotation.
138     */
139    public Number  getOwner(Number annotationID);
140   
141    /**
142     *
143     * @param annotationID
144     * @param principalID
145     * @return access of the principalID w.r.t. annotationID, or Access.NONE if the access is not given.
146     */ 
147    public Access  getAccess(Number annotationID, Number principalID);
148   
149    /**
150     *
151     * @param annotationID
152     * @param principalID
153     * @return true if there is triple (annotationID, principalID, access) for some access
154     * in the corresponding junction table; false otherwise.
155     */
156    public boolean  hasExplicitAccess(Number annotationID, Number principalID);
157   
158    /**
159     *
160     * @param annotationID
161     * @return the value of the "public" field for annotationID; can be one of ACCESS values.
162     */
163    public Access getPublicAttribute(Number annotationID);
164   
165   
166    /**
167     *
168     * @param notebookID
169     * @return the list of annotationIDs of the annotations from the notebook with notebookID.
170     */
171    public List<Number> getAnnotations(Number notebookID);
172   
173    /**
174     *
175     * @param targetID
176     * @return true if at least one annotation refers to this target; false otherwise.
177     */
178    public boolean targetIsInUse(Number targetID);
179 
180    /**
181     * ADDERS
182     */
183   
184    /**
185     *
186     * @param annotationID
187     * @param targetID
188     * @return # updated rows in the joint table "annotations_targets".
189     * Connects the annotation to its target by adding the pair (annotationID, targetID)
190     * to the junction table.
191     */ 
192    public int addAnnotationTarget(Number annotationID, Number targetID);
193   
194   
195    /**
196     *
197     * @param annotationID
198     * @param principalID
199     * @param access
200     * @return # rows added to the table "annotations_principals_access".
201     * Sets the "access" for the "principalID" w.r.t. the annotation with "annotationID".
202     */
203    public int addPermission(Number annotationID, Number principalID, Access access);
204   
205   
206 
207    /**
208     *
209     * @param annotationthe the object to be added to the table "annotation".
210     * @param newOwnerID the ownerID,
211     * @return the internal ID of the added annotation, if it is added, or throws NotInDataBaseException otherwise.
212     * @throws NotInDataBaseException if the request on the internal database annotation ID for the added annotation throws this exception.
213     */
214    public Number addAnnotation(Annotation annotation, Number newOwnerID)  throws NotInDataBaseException;
215 
216     
217    /////// UPDATERS //////////////////
218   
219   /**
220    *
221    * @param annotationID the internal database ID of the annotation to be updated.
222    * @param text the new body text.
223    * @param mimeType the new mime type.
224    * @param isXml if the new body is a text body or an xml.
225    * @return # of updated rows in the table "annotation".
226    */
227    public int updateAnnotationBody(Number annotationID, String text, String mimeType, Boolean isXml);
228   
229    /**
230     *
231     * @param annotationID the internal database ID of the annotation to be updated.
232     * @param text the new headline.
233     * @return # of updated rows in the table "annotation".
234     */
235    public int updateAnnotationHeadline(Number annotationID, String text);
236   
237   
238   
239    /**
240     *
241     * @param annotation
242     * @return # of updated rows in "annotation" table after updating the annotation. Should return 1 if update  happens.
243     */
244    /**
245     *
246     * @param annotation the new annotation (including targets and permissions).
247     * @param annotationID the ID of the annotation to be updated.
248     * @param ownerID the Id of the new owner.
249     * @return # of updated rows in "annotation" table after this FULL updating the annotation. Should return 1 if update  happens.
250     */
251    public int updateAnnotation(Annotation annotation, Number annotationID, Number ownerID);
252   
253   
254     /**
255     *
256     * @param annotationID
257     * @param principalID
258     * @param access
259     * @return # rows updated to the table "annotations_principals_access".
260     * Sets the "access" for the "principalID" w.r.t. the annotation with "annotationID".
261     */
262    public int updatePermission(Number annotationID, Number principalID, Access access);
263   
264    /**
265     *
266     * @param annotationID the internal database ID of the annotation to be updated.
267     * @param access access level.
268     * @return # of updated rows in "annotation". should be "1" if updated and "0" otherwise.
269     */
270    public int updatePublicAccess(Number annotationID, Access access);
271   
272   
273   /**
274    * DELETERS
275    */
276   
277    /**
278     *
279     * @param annotationId
280     * @return # rows in the table "annotation". It should be "1" if the annotation with "annotationID" is successfully deleted, and "0" otherwise.
281     */
282   
283   
284   
285    public int deleteAnnotation(Number annotationId);
286   
287    /**
288     *
289     * @param annotationId
290     * @return # removed rows in the table "annotations_target_Targets".
291     */
292   
293    public int deleteAllAnnotationTarget(Number annotationID);
294   
295   
296   /**
297    *
298    * @param annotationID
299    * @return # removed rows in the table "annotations_principals_access".
300    */
301    public int deletePermissions(Number annotationID);
302   
303    /**
304     *
305     * @param annotationID
306     * @param principalID
307     * @return # removed rows in the table "annotations_principals_access".
308     * Should be "1" is removed and "0" otherwise.
309     */
310    public int deletePermission(Number annotationID, Number principalID);
311   
312    /**
313     *
314     * @param annotationID
315     * @return # removed rows in the table "notebookds_annotations".
316     */
317    public int deleteAnnotationFromAllNotebooks(Number annotationID);
318   
319    /*
320     * HELPERS
321     */
322   
323    /**
324     *
325     * @param annotationBody
326     * @return two string components of the annotationBody: the text/xml content and the mime type.
327     */
328    public String[] retrieveBodyComponents(AnnotationBody annotationBody);
329
330}
Note: See TracBrowser for help on using the repository browser.