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

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

adding two html forms and two services for updating user-annotation access and public access of an annotation

File size: 7.0 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    public List<UUID> getExternalIdFromHeadline(String headline);
44   
45    public List<Number>  getInternalIDsFromHeadline(String headline);
46    /**
47     *
48     * @param annotationID
49     * @return the pair (annotation, owner_id) with empty list of Targets.
50     *
51     * (Constructing a complete Annotation object using  "getAnnotationWithoutTargets" and "retrieveTargetIDs" is done in "DaoDispatchter".)
52     *
53     */
54    public Annotation getAnnotationWithoutTargetsAndPemissions(Number annotationID);
55   
56     
57    public List<Number> getFilteredAnnotationIDs(Number ownerID, String text, String namespace, String after, String before);
58     
59 
60    public List<Number> getAnnotationIDsForPermission(Number principalID, Access acess);
61   
62    public List<Number> getAnnotationIDsForPublicAccess(Access access);
63   
64   
65    /*
66     * Use inly in the debugging mode to acces all the existing annotations.
67     */
68    public List<Number> getAllAnnotationIDs();
69   
70    public List<Number> sublistOrderedAnnotationIDs(List<Number> annotationIDs, int offset, int limit, String orderedBy, String desc);
71   
72       /**
73     * unit test is missing
74     * @param annotationIDs
75     * @return annotationInfo  for the annotation with the internal annotationID.
76     *
77     */
78    public AnnotationInfo getAnnotationInfoWithoutTargetsAndOwner(Number annotationID);   
79   
80    /**
81     *
82     * @param annotationIDs
83     * @return list of reTarget references where an i-th reference is constructed from the external identifier of the annotation with the i-th internal identifier from the list.
84     */
85    public List<String> getAnnotationREFs(List<Number> annotationIDs); 
86   
87   
88   
89   
90   
91       /**
92     *
93     * @param annotationID
94     * @return the list of the internal IDs of all the target Targets of "annotationID".
95     */
96    //public List<Number> retrieveTargetIDs(Number annotationID);   
97   
98   
99    public Number  getOwner(Number annotationID);
100   
101    /**
102     *
103     * @param annotationID
104     * @param principalID
105     * @return access of the principalID w.r.t. annotationID, or null if the access is not given
106     */ 
107    public Access  getAccess(Number annotationID, Number principalID);
108   
109   
110    public Access getPublicAttribute(Number annotationID);
111   
112   
113   
114    public List<Number> getAnnotations(Number notebookID);
115   
116   
117    public boolean targetIsInUse(Number targetID);
118    /**
119     *
120     * @param annotationID
121     * @return true if "annotationID" is mentioned in at least one of the joint tables:
122     * "annotations_targets", "annotations_principals_accesss", "notebook_annotations".
123     * Otherwise return "false".
124     */
125    //public boolean annotationIsInUse(Number annotationID);
126   
127    /**
128     * ADDERS
129     */
130   
131    /**
132     *
133     * @param annotationID
134     * @param targetID
135     * @return # updated rows in the joint table "annotations_target_Targets".
136     * @throws SQLException
137     * Connects the annotation to its target Target by adding the pair (annotationID, TargetID) to the joint table.
138     */ 
139    public int addAnnotationTarget(Number annotationID, Number targetID);
140   
141   
142    /**
143     *
144     * @param annotationID
145     * @param principalID
146     * @param access
147     * @return # rows added to the table "annotations_principals_accesss"
148     * Sets the "access" for the "principalID" w.r.t. the annotation with "annotationID".
149     */
150    public int addAnnotationPrincipalAccess(Number annotationID, Number principalID, Access access);
151   
152   
153 
154     /**
155     *
156     * @param annotation: the object to be added to the table "annotation".
157     * @return  the internal ID of the added annotation, if it is added, or null otherwise.
158     **/
159   
160    public Number addAnnotation(Annotation annotation, Number newOwnerID)  throws NotInDataBaseException;
161 
162     
163    /////// UPDATERS //////////////////
164   
165   
166    public int updateAnnotationBody(Number annotationID, String text, String mimeType, Boolean isXml);
167   
168    public int updateAnnotationHeadline(Number annotationID, String text);
169   
170   
171   
172    /**
173     *
174     * @param annotation
175     * @return # of updated rows in "annotation" table after updating the annotation. Should return 1 if update  happens
176     * @throws SQLException
177     */
178    public int updateAnnotation(Annotation annotation, Number annotationID, Number ownerID);
179   
180   
181     /**
182     *
183     * @param annotationID
184     * @param principalID
185     * @param access
186     * @return # rows updated to the table "annotations_principals_accesss"
187     * Sets the "access" for the "principalID" w.r.t. the annotation with "annotationID".
188     */
189    public int updateAnnotationPrincipalAccess(Number annotationID, Number principalID, Access access);
190   
191   
192    public int updatePublicAttribute(Number annotationID, Access access);
193   
194   
195   /**
196    * DELETERS
197    */
198   
199    /**
200     *
201     * @param annotationId
202     * @return # rows in the table "annotation". It should be "1" if the annotation with "annotationID" is successfully deleted, and "0" otherwise.
203     */
204   
205   
206   
207    public int deleteAnnotation(Number annotationId);
208   
209    /**
210     *
211     * @param annotationId
212     * @return # removed rows in the table "annotations_target_Targets".
213     */
214   
215    public int deleteAllAnnotationTarget(Number annotationID);
216   
217   
218   /**
219    *
220    * @param annotationID
221    * @return # removed rows in the table "annotations_principals_accesss".
222    * @throws SQLException
223    */
224    public int deleteAnnotationPermissions(Number annotationID);
225   
226    public int deleteAnnotationPrincipalAccess(Number annotationID, Number principalID);
227   
228    public int deleteAnnotationFromAllNotebooks(Number annotationID);
229   
230    /*
231     * HELPERS
232     */
233   
234    public String[] retrieveBodyComponents(AnnotationBody annotationBody);
235
236}
Note: See TracBrowser for help on using the repository browser.