Changeset 3475
- Timestamp:
- 08/25/13 21:05:37 (11 years ago)
- Location:
- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/AnnotationDao.java
r3465 r3475 33 33 */ 34 34 35 // TODO: Getting Target Sources from Body and testing must be added!!!36 37 35 38 36 public interface AnnotationDao extends ResourceDao{ … … 44 42 * 45 43 * @param annotationID 46 * @return the Annotation object with empty list of sources 47 * constructing a complete Annotation object from the result and "retrieveSourceIDs" is done in "DaoDispatchter" 44 * @return the Annotation object with empty list of sources. 45 * 46 * (Constructing a complete Annotation object using "getAnnotationWithoutSources" and "retrieveSourceIDs" is done in "DaoDispatchter" 48 47 * 49 48 */ … … 53 52 /** 54 53 * 55 * @param annotationIDs optional56 * @param text optional57 * @param access optional58 * @param namespace optionalTODO: do not know what to do with it59 * @param ownerID optional60 * @param after optional61 * @param before optional54 * @param annotationIDs: the list of annotationID-s from which the resulting annotations are to be selected. 55 * @param text: the text which the resulting annotations' bodies must contain. 56 * @param access: the resulting annotations must have permission "access" (owner, or writer, or reader) for the currently inlogged user. 57 * @param namespace TODO: do not know what to do with it 58 * @param ownerID: the resulting annotations are owned by the owner "ownerID". 59 * @param after: the resulting annotations must have timestamp later than "after". 60 * @param before: the resulting annotations must have timestamp earlier than "before". 62 61 * @return the sub-list of internal annotation identifiers from the list "internalIDs" for annotations 63 62 * -- bodies of which contain the "text", … … 66 65 * -- added to the database between "before" and "after" time-dates. 67 66 * 68 *69 * The first step for GET api/annotations?<filters>70 67 */ 71 68 public List<Number> getFilteredAnnotationIDs(List<Number> annotationIDs, String text, String access, String namespace, Number ownerID, Timestamp after, Timestamp before); … … 74 71 * 75 72 * @param annotationIDs 76 * @return the list of annotationInfos (owner, headline, target sources, external_id) for the internal Ids from the input list77 * used on the second step for GET api/annotations?<filters>73 * @return the list of annotationInfos (owner, headline, target sources, external_id) for the annotations with the internal IDs from the input list. 74 * 78 75 */ 79 76 public List<AnnotationInfo> getAnnotationInfos(List<Number> annotationIDs); … … 83 80 * 84 81 * @param annotationIDs 85 * @return list of resource references where an i-th reference is constructed from 82 * @return list of resource references where an i-th reference is constructed from the external identifier of the annotation with the i-th internal identifier from the list. 86 83 */ 87 84 public List<ResourceREF> getAnnotationREFs(List<Number> annotationIDs); … … 90 87 * 91 88 * @param sourceIDs 92 * @return the list of annotationdIDs of the annotations that are having target sources from "sourceIDs" list89 * @return the list of annotationdIDs of the annotations which target sources are from "sourceIDs" list. 93 90 */ 94 91 public List<Number> retrieveAnnotationList(List<Number> sourceIDs); … … 98 95 * 99 96 * @param annotationID 100 * @return the list of the source's internal IDs of all the target sources of annotationID97 * @return the list of the internal IDs of all the target sources of "annotationID". 101 98 */ 102 99 public List<Number> retrieveSourceIDs(Number annotationID); … … 106 103 * 107 104 * @param annotationId 108 * @return retrieves all the pairs (user-permission) for "annotationId" from the table annotations_principals permissions105 * @return all the pairs (user-permission) for "annotationId" from the table annotations_principals permissions. 109 106 */ 110 107 public List<Map<Number, String>> retrievePermissions(Number annotationId); 111 108 112 109 110 /** 111 * 112 * @param sourceID 113 * @return true if "annotationID" is mentioned in at least one of the joint tables: 114 * "annotations_target_sources", "annotations_principals_permissions", "notebook_annotations". 115 * Otherwise return "false". 116 */ 117 public boolean annotationIsInUse(Number annotationID); 113 118 114 119 ///////////// ADDERS ///////////////////// 115 120 116 public int addAnnotationSourcePair(Number annotationID, Number sourceID) throws SQLException; 121 /** 122 * 123 * @param annotationID 124 * @param sourceID 125 * @return # updated rows in the joint table "annotations_target_sources". 126 * @throws SQLException 127 * Connects the annotation to its target source by adding the pair (annotationID, sourceID) to the joint table. 128 */ 129 public int addAnnotationSourcePair(Number annotationID, Number sourceID) throws SQLException; 117 130 118 131 … … 122 135 * @param userID 123 136 * @param permission 124 * @return the amount of rows added to the table annotations_principals_permissions 137 * @return # rows added to the table "annotations_principals_permissions" 138 * Sets the "permission" for the "userID" w.r.t. the annotation with "annotationID". 125 139 */ 126 140 public int addAnnotationPrincipalPermission(Number annotationID, Number userID, Permission permission) throws SQLException; … … 130 144 /** 131 145 * 132 * @param annotation added to the table with annotations133 * @return internal Id of the added annotation146 * @param annotation: the object to be added to the table "annotation". 147 * @return the internal ID of the added annotation, if it is added, or null otherwise. 134 148 **/ 135 149 … … 138 152 139 153 /////// UPDATERS ////////////////// 140 154 /** 155 * 156 * @param annotationID 157 * @param serializedNewBody 158 * @return # of updated rows in "annotation" table after updating the annotation's body with "serializedNewBody". Should return 1. 159 */ 141 160 public int updateBody(Number annotationID, String serializedNewBody); 142 161 … … 147 166 * 148 167 * @param annotationId 149 * @return removed annotation rows (should be 1)168 * @return # rows in the table "annotation". It should be "1" if the annotation with "annotationID" is successfully deleted, and "0" otherwise. 150 169 */ 151 170 … … 157 176 * 158 177 * @param annotationId 159 * @return # removed annotation_source rows for given annotationID178 * @return # removed rows in the table "annotations_target_sources". 160 179 */ 161 180 162 public int deleteAllAnnotationSource(Number annotationI d) throws SQLException;181 public int deleteAllAnnotationSource(Number annotationID) throws SQLException; 163 182 164 183 165 184 /** 185 * 186 * @param annotationID 187 * @return # removed rows in the table "annotations_principals_permissions". 188 * @throws SQLException 189 */ 166 190 public int deleteAnnotationPrincipalPermissions(Number annotationID) throws SQLException ; 167 191 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/CachedRepresentationDao.java
r3465 r3475 32 32 * 33 33 * @param internalID 34 * @return the object "cCachedRepresentationInfo" with the internal id "internalID"34 * @return the object of the class "CachedRepresentationInfo" with the internal id "internalID". 35 35 */ 36 36 public CachedRepresentationInfo getCachedRepresentationInfo(Number internalID); … … 40 40 * 41 41 * @param cached 42 * @return the internal I d of the just added "cached"42 * @return the internal ID of the just added "cached", or null if the cached representation is not added for some reason. 43 43 */ 44 44 public Number addCachedRepresentationInfo(CachedRepresentationInfo cached); … … 48 48 * 49 49 * @param internalID 50 * @return # deleted rows on the table "cached_representation" 50 * @return # deleted rows on the table "cached_representation". 51 51 */ 52 52 public int deleteCachedRepresentationInfo(Number internalID); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/NotebookDao.java
r3465 r3475 31 31 * @author Peter Withers <peter.withers@mpi.nl> 32 32 */ 33 34 // TODO: not yet fully updated. 35 33 36 public interface NotebookDao extends ResourceDao { 34 37 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/ResourceDao.java
r3461 r3475 28 28 29 29 public void setServiceURI(String serviceURI); 30 30 31 /** 31 32 * 32 33 * @param externalID 33 * @return internal identifier of the resource with externalID 34 * @return internal identifier of the resource with externalID, or null if there is no resource with this identifier 34 35 */ 35 36 public Number getInternalID(UUID externalId); 36 37 38 /** 39 * 40 * @param internalId 41 * @return the UUID (external ID) of the resource with the "internalID". 42 */ 37 43 public UUID getExternalID(Number internalId); 38 44 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/SourceDao.java
r3465 r3475 37 37 * 38 38 * @param inernalID 39 * @return the object containing the source with the intrenal Id "internalId"39 * @return the source with the intrenal Id "internalID". 40 40 */ 41 41 public Source getSource(Number internalID); 42 42 43 43 /** 44 * 45 * @param sources 46 * @return the list of SoirceInfo objects corresponding to the sources with the internalIds from the list "sources". 47 */ 44 48 public List<SourceInfo> getSourceInfos(List<Number> sources); 45 49 … … 47 51 * 48 52 * @param sourceID 49 * @return the list of the internal version id-s for the target source with the internal Id "sourceID"53 * @return the list of the internal version ID-s ("siblings") for the target source with the internal ID "sourceID". 50 54 */ 51 55 public List<Number> retrieveVersionList(Number sourceID); … … 55 59 * 56 60 * @param link 57 * @return the list source ID's which link-fields contain "link" as a substring61 * @return the list of source ID's which link-fields contain "link" as a substring. 58 62 */ 59 63 public List<Number> getSourcesForLink(String link); 60 64 61 65 66 /** 67 * 68 * @param sourceID 69 * @return true if "sourceID" occurs in at least one of the joint tables "annotations_target_sources" and "sources_versions". 70 */ 62 71 public boolean sourceIsInUse(Number sourceID); 63 72 … … 68 77 /** 69 78 * 70 * @param source 71 * @param versionID 72 * adds freshSource to the DB and assigns the fresh external Identifier to it 73 * @return the internal ID of the just added source 74 * return -1 id the source cannot be added because its version is not in the DB 79 * @param source: the Source-object of the source to be added to "source" table. 80 * @return the internal ID of the just added source or null if it has not been added. 75 81 */ 76 82 public Number addSource(Source source) throws SQLException; 77 83 84 /** 85 * 86 * @param sourceID 87 * @param versionID 88 * @return # added rows to the table "annotations_target_sources". Should be "1" if the pair (sourceID, versionID) has been added. 89 * @throws SQLException 90 */ 78 91 public int addSourceVersion(Number sourceID, Number versionID) throws SQLException; 79 92 … … 86 99 * 87 100 * @param internalId 88 * @return # deleted rows in "source" table 101 * @return # deleted rows in "source" table. Should be "1" if the source has been deleted. 89 102 */ 90 103 public int deleteSource(Number internalID); 91 104 92 105 93 106 /** 107 * 108 * @param sourceID 109 * @return # deleted rows in the table "sources_versions" when deleting all the pairs of the form (sourceID, *). 110 * @throws SQLException 111 */ 94 112 public int deleteAllSourceVersion(Number sourceID) throws SQLException; 95 113 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/VersionDao.java
r3465 r3475 34 34 * 35 35 * @param internalID 36 * @return the instance of Version.class with the internal Id equal to "internalID"36 * @return the Version-object build from the version with the "internalID". 37 37 * 38 38 */ … … 43 43 * 44 44 * @param versionID 45 * @return The list of the cached representation internal id-s of all the cached representations of the version with "versionID"45 * @return The list of the cached-representation internal ID-s of all the cached representations of the version with "versionID". 46 46 */ 47 47 public List<Number> retrieveCachedRepresentationList(Number versionID); 48 48 49 49 50 // Not tested 51 public boolean versionIsInUse(Number versionsID); 50 /** 51 * 52 * @param versionsID 53 * @return true if "versionID" occurs in the table "versions_cached_representations". 54 */ 55 public boolean versionIsInUse(Number versionID); 52 56 53 57 … … 56 60 **/ 57 61 58 62 /** 63 * 64 * @param versionID 65 * @param cachedID 66 * @return # rows added to the table "versions_cached_representations", when adding the pair (versionID, sourceID). Should be 1, if it has been added. 67 */ 59 68 public int addVersionCachedRepresentation(Number versionID, Number cachedID); 60 69 … … 63 72 * 64 73 * @param version 65 * @return the internal Id of the just added version74 * @return the internal Id of the just added "version", or null if it has not been added. 66 75 * 67 76 */ … … 76 85 77 86 /** @param versionID 78 * @return deleted rows in "version" table87 * @return # deleted rows in "version" table after deleting the version with "versionID". Should be "1" if the version has been deleted. 79 88 */ 80 89 81 90 public int deleteVersion(Number versionID); 82 91 83 92 /** 93 * 94 * @param versionID 95 * @param cachedID 96 * @return # deleted rows in the table "versions_cached_representations" after deleting the pair (versionID, cachedID). 97 */ 84 98 public int deleteVersionCachedRepresentation(Number versionID, Number cachedID); 85 99 86 100 87 101 /** 102 * 103 * @param versionID 104 * @return # deleted rows in the table "versions_cached_representations" after deleting all the pairs of the form (versionID, *). 105 */ 88 106 public int deleteAllVersionCachedRepresentation(Number versionID); 89 107 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcAnnotationDao.java
r3463 r3475 219 219 220 220 ///////////////////////////// 221 222 p rivate boolean annotationIsInUse(Number sourceID) {221 @Override 222 public boolean annotationIsInUse(Number annotationID) { 223 223 StringBuilder sqlNotebooks = new StringBuilder("SELECT "); 224 224 sqlNotebooks.append(notebook_id).append(" FROM ").append(notebooksAnnotationsTableName).append(" WHERE ").append(annotation_id).append("= ? LIMIT 1"); 225 List<Number> resultNotebooks = getSimpleJdbcTemplate().query(sqlNotebooks.toString(), notebookIDRowMapper, sourceID);225 List<Number> resultNotebooks = getSimpleJdbcTemplate().query(sqlNotebooks.toString(), notebookIDRowMapper, annotationID); 226 226 if (resultNotebooks.size() > 0) { 227 227 return true; … … 230 230 StringBuilder sqlSources = new StringBuilder("SELECT "); 231 231 sqlSources.append(source_id).append(" FROM ").append(annotationsSourcesTableName).append(" WHERE ").append(annotation_id).append("= ? LIMIT 1"); 232 List<Number> resultSources = getSimpleJdbcTemplate().query(sqlSources.toString(), sourceIDRowMapper, sourceID);232 List<Number> resultSources = getSimpleJdbcTemplate().query(sqlSources.toString(), sourceIDRowMapper, annotationID); 233 233 if (resultSources.size() > 0) { 234 234 return true; … … 237 237 StringBuilder sqlPermissions = new StringBuilder("SELECT "); 238 238 sqlPermissions.append(principal_id).append(" FROM ").append(permissionsTableName).append(" WHERE ").append(annotation_id).append("= ? LIMIT 1"); 239 List<Number> resultPermissions = getSimpleJdbcTemplate().query(sqlPermissions.toString(), principalIDRowMapper, sourceID);239 List<Number> resultPermissions = getSimpleJdbcTemplate().query(sqlPermissions.toString(), principalIDRowMapper, annotationID); 240 240 return (resultPermissions.size() > 0); 241 241 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcNotebookDao.java
r3463 r3475 47 47 * @author Peter Withers <peter.withers@mpi.nl> 48 48 */ 49 50 // TODO: not updated fully yet. 51 49 52 public class JdbcNotebookDao extends JdbcResourceDao implements NotebookDao { 50 53
Note: See TracChangeset
for help on using the changeset viewer.