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 | import eu.dasish.annotation.backend.NotInDataBaseException; |
---|
21 | import eu.dasish.annotation.schema.Target; |
---|
22 | import eu.dasish.annotation.schema.TargetInfo; |
---|
23 | import java.util.List; |
---|
24 | import java.util.Map; |
---|
25 | |
---|
26 | /** |
---|
27 | * |
---|
28 | * @author olhsha |
---|
29 | */ |
---|
30 | public interface TargetDao extends ResourceDao { |
---|
31 | |
---|
32 | /** |
---|
33 | * GETTERS |
---|
34 | * |
---|
35 | */ |
---|
36 | /** |
---|
37 | * |
---|
38 | * @param inernalID the internal database id of a target. |
---|
39 | * @return the {@link Target} object representing the target with the internal id "internalID". |
---|
40 | */ |
---|
41 | public Target getTarget(Number internalID); |
---|
42 | |
---|
43 | /** |
---|
44 | * |
---|
45 | * @param targets the list of internal database ids of targets. |
---|
46 | * @return the list of {@link TargetInfo} objects representing the targets with the internal id-s from the list "targets". |
---|
47 | */ |
---|
48 | public List<TargetInfo> getTargetInfos(List<Number> targets); |
---|
49 | |
---|
50 | /** |
---|
51 | * |
---|
52 | * @param targetID the internal database id of a target. |
---|
53 | * @return the list of pairs "cached_representation_id -> fragment_descriptor" for the target with the internal ID "targetID". |
---|
54 | */ |
---|
55 | public Map<Number, String> getCachedRepresentationFragmentPairs(Number targetID); |
---|
56 | |
---|
57 | |
---|
58 | |
---|
59 | /** |
---|
60 | * |
---|
61 | * @param targetID the internal database id of a target. |
---|
62 | * @return The link (uri) to the source to which the target refers. |
---|
63 | */ |
---|
64 | public String getLink(Number targetID); |
---|
65 | |
---|
66 | /** |
---|
67 | * |
---|
68 | * @param link a link (uri) to a target source. |
---|
69 | * @return the list of internal database target id-s whose link-fields is exactly "link". |
---|
70 | */ |
---|
71 | public List<Number> getTargetsForLink(String link); |
---|
72 | |
---|
73 | /** |
---|
74 | * |
---|
75 | * @param cachedID the internal database id of a cached representation. |
---|
76 | * @return true iff "cachedID" is connected to some target in "targets_cached_representations" table. |
---|
77 | */ |
---|
78 | boolean cachedIsInUse(Number cachedID); |
---|
79 | |
---|
80 | /** |
---|
81 | * |
---|
82 | * @param annotationID the internal database ID of an annotation. |
---|
83 | * @return the list of the internal database id's of the targets of the annotation. |
---|
84 | */ |
---|
85 | public List<Number> getTargetIDs(Number annotationID); |
---|
86 | |
---|
87 | /** |
---|
88 | * ADDERS |
---|
89 | * |
---|
90 | */ |
---|
91 | |
---|
92 | /** |
---|
93 | * |
---|
94 | * @param target a {@link Target} object representing the target to add. |
---|
95 | * @return the internal database id of the target if it is added to the database. |
---|
96 | * @throws NotInDataBaseException if adding fails. |
---|
97 | */ |
---|
98 | public Number addTarget(Target target) throws NotInDataBaseException; |
---|
99 | |
---|
100 | |
---|
101 | /** |
---|
102 | * |
---|
103 | * @param targetID the internal database id of a target. |
---|
104 | * @param cachedID the internal database id of a cached representation. |
---|
105 | * @param fragmentDescription a string representing the location of the target in the cached representation. |
---|
106 | * @return # of updated rows in the table "targets_cached_representations"; should be "1" if the row with (targetID, cachedID) has been updated. |
---|
107 | */ |
---|
108 | public int updateTargetCachedRepresentationFragment(Number targetID, Number cachedID, String fragmentDescription); |
---|
109 | |
---|
110 | /** |
---|
111 | * |
---|
112 | * @param targetID the internal database id of a target. |
---|
113 | * @param cachedID the internal database id of a cached representation. |
---|
114 | * @param fragmentDescription a string representing the location of the target in the cached representation. |
---|
115 | * @return # of added rows in the table "targets_cached_representations"; should be "1" if the row with (targetID, cachedID, fragmentDescriptor) is added. |
---|
116 | */ |
---|
117 | public int addTargetCachedRepresentation(Number targetID, Number cachedID, String fragmentDescription); |
---|
118 | |
---|
119 | /** |
---|
120 | * DELETERS |
---|
121 | * |
---|
122 | */ |
---|
123 | /** |
---|
124 | * |
---|
125 | * @param internalID the internal database id of a target. |
---|
126 | * @return # deleted rows in "target" table. Should be "1" if the target has been removed. |
---|
127 | */ |
---|
128 | public int deleteTarget(Number internalID); |
---|
129 | |
---|
130 | /** |
---|
131 | * |
---|
132 | * @param targetID the internal database id of a target. |
---|
133 | * @param cachedID the internal database id of a cached representation. |
---|
134 | * @return # of deleted rows in the table "targets_cached_representations"; should be "1" if the deletion has taken place,an "0" otherwise". |
---|
135 | */ |
---|
136 | public int deleteTargetCachedRepresentation(Number targetID, Number chachedID); |
---|
137 | } |
---|