Changeset 3380
- Timestamp:
- 08/14/13 16:34:29 (11 years ago)
- Location:
- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/AnnotationDao.java
r3369 r3380 21 21 import eu.dasish.annotation.backend.identifiers.UserIdentifier; 22 22 import eu.dasish.annotation.schema.Annotation; 23 import eu.dasish.annotation.schema.AnnotationBody; 23 24 import eu.dasish.annotation.schema.AnnotationInfo; 25 import eu.dasish.annotation.schema.NewOrExistingSourceInfo; 24 26 import eu.dasish.annotation.schema.ResourceREF; 25 27 import java.sql.SQLException; 26 28 import java.sql.Timestamp; 27 29 import java.util.List; 30 import java.util.Map; 28 31 29 32 /** … … 54 57 Annotation getAnnotation(Number annotationID) throws SQLException; 55 58 56 59 57 60 /** 58 61 * 59 62 * @param annotationId 60 * @return the amount of deleted sources; removes _aid_ from the DB, together with its tagrget sources to 61 * which no other annotations refers. 63 * @return 64 * result[0] = # removed notebooks_annotations rows 65 * result[1] = # removed "annotations_principals_perissions" rows 66 * result[2] = # removed "annotatiobs_target_sources" rows 67 * result[3] = # SAFELY removed "target_sources" rows (only unused) 68 * result[4] = # removed annotation rows (should be 1) 62 69 */ 63 70 64 public int deleteAnnotation(Number annotationId) throws SQLException;71 public int[] deleteAnnotation(Number annotationId) throws SQLException; 65 72 66 73 … … 69 76 * 70 77 * @param annotation added to the table with annotations 71 * @return annotationIdentifier of the newly added annotation; returns null if something went wrong and annotation was not added or more than one row in the annotation table was affected 72 */ 73 public Annotation addAnnotation(Annotation annotation, Number ownerID) throws SQLException; 78 * @return internal Id of the added annotation 79 **/ 80 81 public Number addAnnotation(Annotation annotation, Number ownerID) throws SQLException; 74 82 75 83 … … 89 97 * -- owned by "owner", 90 98 * -- added to the database between "before" and "after" time-dates. 99 * 100 * 101 * The first step for GET api/annotations?<filters> 91 102 */ 92 103 public List<Number> getFilteredAnnotationIDs(String link, String text, String access, String namespace, UserIdentifier owner, Timestamp after, Timestamp before); … … 97 108 * @param annotationIDs 98 109 * @return the list of annotationInfos (owner, headline, target sources, external_id) for the internal Ids from the input list 99 * used on the second step for forGET api/annotations?<filters>110 * used on the second step for GET api/annotations?<filters> 100 111 */ 101 112 public List<AnnotationInfo> getAnnotationInfos(List<Number> annotationIDs); … … 113 124 114 125 126 // NOT TESTED 127 public int updateBody(Number annotationID, String serializedNewBody); 128 129 /** 130 * 131 * @param annotationID 132 * @return the list of the source's internal IDs of all the target sources of annotationID 133 */ 134 public List<Number> retrieveSourceIDs(Number annotationID); 135 136 /** 137 * 138 * @param body 139 * @return serialized body 140 */ 141 //NOT TESTED, will be changed after serialization is fixed 142 public String serializeBody(AnnotationBody body); 143 144 /** 145 * 146 * @param bodyXml 147 * @return deserialized body 148 */ 149 // NOT TESTED will be chnaged after serializaion is fixed 150 public AnnotationBody deserializeBody(String bodyXml); 151 152 /** 153 * 154 * @param serializedBody 155 * @param sourcePairs 156 * @return replaces temporary source IDs with persistent ones (after they are added) 157 */ 158 159 //NOT TESTED 160 public String updateTargetRefsInBody(String serializedBody, Map<String, String> sourceIDPairs); 115 161 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/CachedRepresentationDao.java
r3372 r3380 61 61 * 62 62 * @param cached 63 * @return copy of "cached" after "cached" is added to the DB; the internal id is set in the return copy63 * @return the internal Id of the just added "cached" 64 64 */ 65 public CachedRepresentationInfoaddCachedRepresentationInfo(CachedRepresentationInfo cached);65 public Number addCachedRepresentationInfo(CachedRepresentationInfo cached); 66 66 67 67 68 69 68 70 69 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/ResourceDao.java
r3373 r3380 33 33 public <T extends DasishIdentifier> Number getInternalID(T externalId); 34 34 35 36 /**37 * @param notebookID38 * @return false if notebookID == null or the notebook with notebookID is not in the DB;39 * @return true if the notebook with notebookID in the DB40 */41 42 35 43 36 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/SourceDao.java
r3365 r3380 40 40 public SourceIdentifier getExternalID(Number internalID); 41 41 42 /** 43 * 44 * @param annotationID 45 * @return the list of the source's internal IDs of all the target sources of annotationID 46 */ 47 public List<Number> retrieveSourceIDs(Number annotationID); 42 48 43 49 44 /** … … 53 48 */ 54 49 public Source getSource(Number internalID); 50 51 /** 52 * 53 * @param internalID 54 * @return the map "colum name" --> vale for the source form the DB 55 */ 56 public Map<String, Object> getRawSource(Number internalID); 55 57 56 58 /** … … 66 68 * @param freshSource 67 69 * adds freshSource to the DB and assigns the fresh external Identifier to it 68 * @return the copy of freshSource with the assigned external identifier 70 * @return the internal ID of the just added source 71 * return -1 id the source cannot be added because its version is not in the DB 69 72 */ 70 public SourceaddSource(Source freshSource) throws SQLException;73 public Number addSource(Source freshSource) throws SQLException; 71 74 72 75 ////////////////////////////////////////////// … … 77 80 * @return the Information about the target sources to which annotationId refers 78 81 */ 79 public List<SourceInfo> getSourceInfos( Number annotationID);82 public List<SourceInfo> getSourceInfos(List<Number> sources); 80 83 81 84 /** … … 101 104 * @param annotationID 102 105 * @param sources 103 * @return the mapping of a (possible new, freshly added) source onto the corresponding same source in the DB. 104 * The difference between the argument/key source and the value source is just their internal and external identifiers. 105 * The already existing source is mapped onto itself. 106 * @return the mapping of a (temporary source ID onto the corresponding same source persisten ID in the DB. 106 107 * The side-effect: the joint table "annotations_target_sources" is extended by the pairs (annotationID, addedSoiurceID). 108 * Also: calls "addSource" if the source is not yet in the DB. 107 109 */ 108 public Map< NewOrExistingSourceInfo, NewOrExistingSourceInfo> addTargetSources(Number annotationID, List<NewOrExistingSourceInfo> sources) throws SQLException;110 public Map<String, String> addTargetSources(Number annotationID, List<NewOrExistingSourceInfo> sources) throws SQLException; 109 111 110 112 /** -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/VersionDao.java
r3372 r3380 63 63 * 64 64 * @param version 65 * @return the copy of "version" with the new external Id set in "version" text field (for now)65 * @return the internal Id of the just added version 66 66 * 67 67 */ 68 public VersionaddVersion(Version version);68 public Number addVersion(Version version); 69 69 70 70 /** … … 89 89 */ 90 90 public int[] deleteCachedRepresentationForSource(Number sourceID, Number cachedRepresentationID); 91 92 public Number getInternalID(VersionIdentifier externalID); 91 93 } 92 94 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcAnnotationDao.java
r3370 r3380 70 70 71 71 @Override 72 public List<Number> retrieveSourceIDs(Number annotationID) { 73 String sql = "SELECT " + source_id + " FROM " + annotationsSourcesTableName + " WHERE " + annotation_id + "= ?"; 74 List<Number> result = getSimpleJdbcTemplate().query(sql, annotationSourceRowMapper, annotationID); 75 return result; 76 } 77 private final RowMapper<Number> annotationSourceRowMapper = new RowMapper<Number>() { 78 @Override 79 public Number mapRow(ResultSet rs, int rowNumber) throws SQLException { 80 Number result = rs.getInt(source_id); 81 return result; 82 } 83 }; 84 85 @Override 72 86 public List<Number> getFilteredAnnotationIDs(String link, String text, String access, String namespace, UserIdentifier owner, Timestamp after, Timestamp before) { 73 87 74 88 StringBuilder sql = new StringBuilder("SELECT DISTINCT "); 75 sql.append(annotation_id).append(" FROM ").append(annotationTableName).append(" WHERE TRUE "); 89 sql.append(annotation_id).append(" FROM ").append(annotationTableName).append(" WHERE TRUE "); 76 90 Map<String, Object> params = new HashMap<String, Object>(); 77 78 91 92 if (link != null) { 79 93 List<Number> sourceIDs = jdbcSourceDao.getSourcesForLink(link); 80 94 List<Number> annotationIDs = getAnnotationIDsForSources(sourceIDs); … … 82 96 String values = makeListOfValues(annotationIDs); 83 97 sql.append(" AND ").append(annotation_id).append(" IN ").append(values); 84 } 85 else{ 98 } else { 86 99 return new ArrayList<Number>(); 87 100 } 88 101 } 89 102 90 103 91 104 if (owner != null) { … … 101 114 102 115 if (before != null) { 103 sql.append(" AND ").append(time_stamp).append(" < :before"); 116 sql.append(" AND ").append(time_stamp).append(" < :before"); 104 117 params.put("before", before); 105 118 } … … 108 121 sql.append(" AND ").append(body_xml).append(" LIKE '%").append(text).append("%'"); 109 122 } 110 111 123 124 112 125 List<Number> result = getSimpleJdbcTemplate().query(sql.toString(), internalIDRowMapper, params); 113 126 return result; 114 127 } 115 128 116 129 ////////////////////////////// 117 118 @Override 119 public List<Number> getAnnotationIDsForSources(List<Number> sourceIDs){ 130 @Override 131 public List<Number> getAnnotationIDsForSources(List<Number> sourceIDs) { 120 132 if (sourceIDs == null) { 121 133 return null; 122 } 134 } 123 135 if (sourceIDs.isEmpty()) { 124 return new ArrayList<Number>();125 } 136 return new ArrayList<Number>(); 137 } 126 138 String values = makeListOfValues(sourceIDs); 127 139 StringBuilder query = new StringBuilder("SELECT DISTINCT "); … … 131 143 return result; 132 144 } 133 134 135 145 136 146 @Override … … 146 156 147 157 String values = makeListOfValues(annotationIDs); 148 String sql = "SELECT " + annotationStar + " FROM " + annotationTableName + " WHERE " + annotationAnnotation_id + " IN " + values;158 String sql = "SELECT DISTINCT " + annotationStar + " FROM " + annotationTableName + " WHERE " + annotationAnnotation_id + " IN " + values; 149 159 return getSimpleJdbcTemplate().query(sql, annotationInfoRowMapper); 150 160 } … … 165 175 * @return list of annotation references corresponding to the annotation-ids 166 176 * from the input list if the input list is null or empty (zero elements) 167 * returns an empty list 168 * there may be annotationIDs which are not in the DB(so that's why we need this method).177 * returns an empty list there may be annotationIDs which are not in the DB 178 * (so that's why we need this method). 169 179 */ 170 171 180 @Override 172 181 public List<ResourceREF> getAnnotationREFs(List<Number> annotationIDs) { … … 181 190 182 191 String values = makeListOfValues(annotationIDs); 183 String sql = "SELECT " + annotationAnnotation_id + " FROM " + annotationTableName + " WHERE " + annotationAnnotation_id + " IN " + values;192 String sql = "SELECT DISTINCT " + annotationAnnotation_id + " FROM " + annotationTableName + " WHERE " + annotationAnnotation_id + " IN " + values; 184 193 return getSimpleJdbcTemplate().query(sql, annotationREFRowMapper); 185 194 } … … 199 208 return null; 200 209 } 201 String sql = "SELECT " + annotationStar + " FROM " + annotationTableName + " WHERE " + annotationAnnotation_id + "= ? ";210 String sql = "SELECT " + annotationStar + " FROM " + annotationTableName + " WHERE " + annotationAnnotation_id + "= ? LIMIT 1"; 202 211 List<Annotation> result = getSimpleJdbcTemplate().query(sql, annotationRowMapper, annotationID); 203 212 … … 221 230 result.setHeadline(rs.getString(headline)); 222 231 223 result.setBody( convertToAnnotationBody(rs.getString(body_xml)));224 225 List<SourceInfo> sourceInfoList = jdbcSourceDao.getSourceInfos(r s.getInt(annotation_id));232 result.setBody(deserializeBody(rs.getString(body_xml))); 233 234 List<SourceInfo> sourceInfoList = jdbcSourceDao.getSourceInfos(retrieveSourceIDs(rs.getInt(annotation_id))); 226 235 NewOrExistingSourceInfos noeSourceInfos = jdbcSourceDao.contructNewOrExistingSourceInfo(sourceInfoList); 227 236 result.setTargetSources(noeSourceInfos); … … 241 250 }; 242 251 243 private AnnotationBody convertToAnnotationBody(String input) { 244 if (input == null) { 245 return null; 246 } 247 248 AnnotationBody result = new AnnotationBody(); 249 List<Object> element = result.getAny(); 250 element.add(input); 251 return result; 252 } 253 254 @Override 255 public int deleteAnnotation(Number annotationId) throws SQLException { 252 @Override 253 public int[] deleteAnnotation(Number annotationId) throws SQLException { 254 255 int[] result = new int[5]; 256 256 257 257 String sqlNotebooks = "DELETE FROM " + notebooksAnnotationsTableName + " where " + annotation_id + " = ?"; 258 int affectedNotebooks = getSimpleJdbcTemplate().update(sqlNotebooks, annotationId);258 result[0] = getSimpleJdbcTemplate().update(sqlNotebooks, annotationId);// removed "notebooks_annotations" rows 259 259 260 260 String sqlPermissions = "DELETE FROM " + permissionsTableName + " where " + annotation_id + " = ?"; 261 int affectedPermissions = getSimpleJdbcTemplate().update(sqlPermissions, annotationId);261 result[1] = getSimpleJdbcTemplate().update(sqlPermissions, annotationId); // removed "permission" rows 262 262 263 263 // safe removing sources 264 List<Number> sourceIDs = jdbcSourceDao.retrieveSourceIDs(annotationId);264 List<Number> sourceIDs = retrieveSourceIDs(annotationId); 265 265 String sqlTargetSources = "DELETE FROM " + annotationsSourcesTableName + " where " + annotation_id + " = ?"; 266 int affectedAnnotationsSources = getSimpleJdbcTemplate().update(sqlTargetSources, annotationId);267 int affectedSources;266 result[2] = getSimpleJdbcTemplate().update(sqlTargetSources, annotationId); // removed "annotations_target_sources" rows 267 result[3] = 0; //removed "target_source" rows 268 268 for (Number sourceID : sourceIDs) { 269 // call the method in sources DAO that handles removal of a source which is not refered by other annotations 270 affectedSources = jdbcSourceDao.deleteSource(sourceID); 269 result[3] = result[3] + jdbcSourceDao.deleteSource(sourceID); 271 270 } 272 271 273 272 String sqlAnnotation = "DELETE FROM " + annotationTableName + " where " + annotation_id + " = ?"; 274 int affectedAnnotations = getSimpleJdbcTemplate().update(sqlAnnotation, annotationId); 275 if (affectedAnnotations > 1) { 276 throw new SQLException("There was more than one annotation (" + affectedAnnotations + ") with the same ID " + annotationId); 277 } 278 return affectedAnnotations; 279 //TODO implement deleting sources (see the specification document and the interfaces' javadoc 273 result[4] = getSimpleJdbcTemplate().update(sqlAnnotation, annotationId); // removed annotations rows 274 275 return result; 280 276 } 281 277 … … 283 279 // Change it when the decision is taken!!! 284 280 @Override 285 public Annotation addAnnotation(Annotation annotation, Number ownerID) throws SQLException { 286 287 Annotation result = makeDeepCopy(annotation); 288 289 ResourceREF ownerRef = new ResourceREF(); 290 ownerRef.setRef(String.valueOf(ownerID)); 291 result.setOwner(ownerRef); 281 public Number addAnnotation(Annotation annotation, Number ownerID) throws SQLException { 292 282 293 283 // generate a new annotation ID 294 284 AnnotationIdentifier annotationIdentifier = new AnnotationIdentifier(); 295 result.setURI(annotationIdentifier.toString());296 297 285 Map<String, Object> params = new HashMap<String, Object>(); 298 286 params.put("externalId", annotationIdentifier.toString()); 299 //params.put("timeStamp", annotation.getTimeStamp()); is generated while adding the annotation in the DB as "now"300 287 params.put("ownerId", ownerID); 301 288 params.put("headline", annotation.getHeadline()); 302 289 params.put("bodyXml", annotation.getBody().getAny().get(0).toString()); 303 290 304 try { 305 306 String sql = "INSERT INTO " + annotationTableName + "(" + external_id + "," + owner_id + "," + headline + "," + body_xml + " ) VALUES (:externalId, :ownerId, :headline, :bodyXml)"; 307 final int affectedRows = getSimpleJdbcTemplate().update(sql, params); 308 309 if (affectedRows != 1) { 310 throw (new SQLException("Cannot add the annotation properly")); 311 } 312 313 Number internalID = getInternalID(annotationIdentifier); 314 315 //retrieve taime stamp for the just added annotation 316 result.setTimeStamp(retrieveTimeStamp(internalID)); 317 318 // place new target sources in the DB, when necessary, update the corresponding target source info for the result 319 // the joint annotations_target_sources" tabel is updated. 320 List<NewOrExistingSourceInfo> sources = result.getTargetSources().getTarget(); 321 Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> sourcePairs = jdbcSourceDao.addTargetSources(internalID, sources); 322 sources.clear(); 323 sources.addAll(sourcePairs.values()); 324 325 //replace the temporary sourceId-references in the body with the persistent externalId 326 String body = annotation.getBody().getAny().get(0).toString(); 327 String newBody = updateTargetRefsInBody(body, sourcePairs); 328 List<Object> bodyXML = result.getBody().getAny(); 329 bodyXML.clear(); 330 bodyXML.add(newBody); 331 String sqlUpdate = "UPDATE " + annotationTableName + " SET " + body_xml + "= ? WHERE " + annotation_id + "= " + internalID; 332 int affectedRowsBodyUpd = getSimpleJdbcTemplate().update(sqlUpdate, newBody); 333 if (affectedRows != 1) { 334 throw (new SQLException("Cannot update the body with persistent reference ID")); 335 } 336 337 return result; 338 } catch (DataAccessException exception) { 339 throw exception; 340 } 291 StringBuilder sql = new StringBuilder("INSERT INTO "); 292 sql.append(annotationTableName).append("(").append(external_id).append(",").append(owner_id); 293 sql.append(",").append(headline).append(",").append(body_xml).append(" ) VALUES (:externalId, :ownerId, :headline, :bodyXml)"); 294 int affectedRows = getSimpleJdbcTemplate().update(sql.toString(), params); 295 if (affectedRows == 1) { 296 return getInternalID(annotationIdentifier); 297 } else { 298 return null; 299 } 300 341 301 } 342 302 … … 347 307 } 348 308 309 /////////////////////////////////////////////////////////////////////// 310 @Override 311 public int updateBody(Number annotationID, String serializedNewBody) { 312 StringBuilder sql = new StringBuilder("UPDATE "); 313 sql.append(annotationTableName).append(" SET ").append(body_xml).append("= ").append(serializedNewBody).append(" WHERE ").append(annotation_id).append("= ?"); 314 return getSimpleJdbcTemplate().update(sql.toString(), annotationID); 315 } 316 349 317 //////////// helpers /////////////////////// 350 318 ///////////////////////////////////////////////// 351 private String updateTargetRefsInBody(String body, Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> sourcePairs) { 352 String result = body; 353 for (NewOrExistingSourceInfo tempSource : sourcePairs.keySet()) { 354 NewSourceInfo newSource = tempSource.getNewSource(); 355 if (newSource != null) { 356 result = result.replaceAll(newSource.getId(), sourcePairs.get(tempSource).getSource().getRef()); 357 } 319 // TODO: change when serialization mechanism for bodies is fixed 320 @Override 321 public String serializeBody(AnnotationBody body) { 322 return body.getAny().get(0).toString(); 323 } 324 325 // TODO: change when serialization mechanism for bodies is fixed 326 @Override 327 public AnnotationBody deserializeBody(String bodyXml) { 328 AnnotationBody result = new AnnotationBody(); 329 result.getAny().add(bodyXml); 330 return result; 331 } 332 333 /////////////////////////////////////// 334 @Override 335 public String updateTargetRefsInBody(String serializedBody, Map<String, String> sourceIDPairs) { 336 String result = (new StringBuilder(serializedBody)).toString(); 337 for (String tempSource : sourceIDPairs.keySet()) { 338 result = result.replaceAll(tempSource, sourceIDPairs.get(tempSource)); 358 339 } 359 340 return result; … … 367 348 } 368 349 369 ////////////////////////////////////////// 370 private Annotation makeDeepCopy(Annotation annotation) { 371 372 if (annotation == null) { 373 return null; 374 } 375 376 Annotation result = new Annotation(); 377 378 AnnotationBody body = new AnnotationBody(); 379 String bodyString = annotation.getBody().getAny().get(0).toString(); 380 body.getAny().add(bodyString); 381 result.setBody(body); 382 383 result.setHeadline(annotation.getHeadline()); 384 385 ResourceREF owner = new ResourceREF(); 386 owner.setRef(annotation.getOwner().getRef()); 387 result.setOwner(owner); 388 389 // ResourceREF permissions = new ResourceREF(); 390 // permissions.setRef(annotation.getPermissions().getRef()); 391 // result.setPermissions(permissions); 392 393 result.setPermissions(null); //we do not have permissions there 394 395 NewOrExistingSourceInfos noesi = new NewOrExistingSourceInfos(); 396 noesi.getTarget().addAll(annotation.getTargetSources().getTarget()); 397 result.setTargetSources(noesi); 398 399 result.setTimeStamp(annotation.getTimeStamp()); 400 result.setURI(annotation.getURI()); 401 402 return result; 403 } 350 /** 351 * 352 * @param annotationID 353 * @return mapping of the column names of the DB to the corresponding values 354 * used for testing 355 */ 356 //NOT TESTED 357 public Map<String, Object> getRawAnnotation(Number annotationID) throws SQLException { 358 359 360 if (annotationID == null) { 361 return null; 362 } 363 String sql = "SELECT " + annotationStar + " FROM " + annotationTableName + " WHERE " + annotationAnnotation_id + "= ? LIMIT 1"; 364 List<Map<String, Object>> result = getSimpleJdbcTemplate().query(sql, rawAnnotationRowMapper, annotationID); 365 366 if (result == null) { 367 return null; 368 } 369 if (result.isEmpty()) { 370 return null; 371 } 372 373 return result.get(0); 374 } 375 private final RowMapper<Map<String, Object>> rawAnnotationRowMapper = new RowMapper<Map<String, Object>>() { 376 @Override 377 public Map<String, Object> mapRow(ResultSet rs, int rowNumber) throws SQLException { 378 Map<String, Object> result = new HashMap<String, Object>(); 379 result.put(owner_id, rs.getInt(owner_id)); 380 result.put(headline, rs.getString(headline)); 381 result.put(body_xml, rs.getString(body_xml)); 382 result.put(external_id, rs.getString(external_id)); 383 result.put(time_stamp, rs.getTimestamp(time_stamp)); 384 return result; 385 } 386 }; 404 387 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcCachedRepresentationDao.java
r3372 r3380 70 70 result.setTool(rs.getString(tool)); 71 71 result.setType(rs.getString(type_)); 72 // TODO add where is the file when the schemis updated!!!!s72 // TODO add "where is the file when the schema" is updated!!!!s 73 73 return result; 74 74 } … … 93 93 94 94 //////////////////////////////////////////////////////////////////////////// 95 96 public CachedRepresentationInfoaddCachedRepresentationInfo(CachedRepresentationInfo cached) {95 @Override 96 public Number addCachedRepresentationInfo(CachedRepresentationInfo cached) { 97 97 98 98 CachedRepresentationIdentifier externalIdentifier = new CachedRepresentationIdentifier(); … … 105 105 String sql = "INSERT INTO " + cachedRepresentationTableName + "(" + external_id + "," + mime_type + "," + tool + "," + type_ + " ) VALUES (:externalId, :mime_type, :tool, :type)"; 106 106 final int affectedRows = getSimpleJdbcTemplate().update(sql, params); 107 108 if (affectedRows == 1) { 109 CachedRepresentationInfo cachedNew = makeFreshCopy(cached); 110 cachedNew.setRef(externalIdentifier.toString()); 111 return cachedNew; 112 } else { 113 return null; 114 } 107 return getInternalID(externalIdentifier); 115 108 } 116 109 … … 139 132 }; 140 133 141 ////////// Helpers ///////////////////142 private CachedRepresentationInfo makeFreshCopy(CachedRepresentationInfo cached) {143 CachedRepresentationInfo result = new CachedRepresentationInfo();144 result.setMimeType(cached.getMimeType());145 result.setRef(cached.getRef());146 result.setTool(cached.getTool());147 result.setType(cached.getType());148 return result;149 }150 151 134 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcPermissionsDao.java
r3303 r3380 89 89 return affectedPermissions; 90 90 } 91 /////////////////////////////////////////////////////////////////////////////////92 //TODO replace name "user" in the scheme beacuse it is misleading. E.g. replace it with93 // getUser actual gives you the list of PAIRS (user, permission) that are refferred from an annotation94 // @Override95 // public PermissionList makeFreshPermissionList(UserIdentifier owner) {96 // PermissionList result = new PermissionList();97 //98 // result.setURI((new PermissionListIdentifier()).toString());99 //100 // UserWithPermission idOwner = new UserWithPermission();101 // idOwner.setPermission(Permission.fromValue("owner"));102 // idOwner.setRef(owner.toString());103 //104 // result.getUser().add(idOwner);105 // return result;106 // }107 108 91 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcResourceDao.java
r3373 r3380 23 23 import java.sql.ResultSet; 24 24 import java.sql.SQLException; 25 import java.util.ArrayList; 25 26 import java.util.List; 26 27 import javax.xml.datatype.DatatypeConfigurationException; … … 33 34 * @author olhsha 34 35 */ 35 public class JdbcResourceDao extends SimpleJdbcDaoSupport implements ResourceDao {36 36 public class JdbcResourceDao extends SimpleJdbcDaoSupport implements ResourceDao { 37 37 38 // base string constants: resource table Names 38 39 final static protected String notebookTableName = "notebook"; 39 40 final static protected String annotationTableName = "annotation"; 40 final static protected String sourceTableName = "target_source"; 41 final static protected String sourceTableName = "target_source"; 41 42 final static protected String cachedRepresentationTableName = "cached_representation_info"; 42 43 final static protected String versionTableName = "version"; 43 44 final static protected String principalTableName = "principal"; 44 45 // joint tablenames 45 46 46 final static protected String notebooksAnnotationsTableName = "notebooks_annotations"; 47 47 final static protected String permissionsTableName = "annotations_principals_permissions"; … … 49 49 final static protected String versionsCachedRepresentationsTableName = "versions_cached_representations"; 50 50 final static protected String sourcesVersionsTableName = "sources_versions"; 51 52 51 // base string constants: field Names 53 52 final static protected String annotation_id = "annotation_id"; … … 58 57 final static protected String headline = "headline"; 59 58 final static protected String body_xml = "body_xml"; 60 final static protected String title ="title";59 final static protected String title = "title"; 61 60 final static protected String principal_id = "principal_id"; 62 61 final static protected String time_stamp = "time_stamp"; … … 70 69 final static protected String type_ = "type_"; 71 70 final static protected String where_is_the_file = "where_is_the_file"; 72 73 71 // derived string constants: table+field names 74 75 final static protected String annotationStar = annotationTableName+".*"; 76 final static protected String annotationAnnotation_id = annotationTableName+"."+annotation_id; 77 final static protected String annotationExternal_id = annotationTableName+"."+external_id; 78 79 final static protected String notebookStar = notebookTableName+".*"; 80 final static protected String notebookNotebook_id = notebookTableName+"."+notebook_id; 81 final static protected String notebookTitle=notebookTableName+"."+title; 82 final static protected String notebookExternal_id = notebookTableName+"."+external_id; 83 final static protected String notebookOwner_id = notebookTableName+"."+owner_id; 84 85 86 final static protected String notebooksAnnotationsTableNameAnnotation_id = notebooksAnnotationsTableName+"."+annotation_id; 87 88 89 final static protected String principalPrincipal_id = principalTableName+"."+principal_id; 90 final static protected String principalExternal_id = principalTableName+"."+external_id; 91 92 93 final static protected String cachedRepresentationStar = cachedRepresentationTableName+".*"; 94 final static protected String versionStar = versionTableName+".*"; 95 final static protected String sourceStar = sourceTableName+".*"; 96 72 final static protected String annotationStar = annotationTableName + ".*"; 73 final static protected String annotationAnnotation_id = annotationTableName + "." + annotation_id; 74 final static protected String annotationExternal_id = annotationTableName + "." + external_id; 75 final static protected String notebookStar = notebookTableName + ".*"; 76 final static protected String notebookNotebook_id = notebookTableName + "." + notebook_id; 77 final static protected String notebookTitle = notebookTableName + "." + title; 78 final static protected String notebookExternal_id = notebookTableName + "." + external_id; 79 final static protected String notebookOwner_id = notebookTableName + "." + owner_id; 80 final static protected String notebooksAnnotationsTableNameAnnotation_id = notebooksAnnotationsTableName + "." + annotation_id; 81 final static protected String principalPrincipal_id = principalTableName + "." + principal_id; 82 final static protected String principalExternal_id = principalTableName + "." + external_id; 83 final static protected String cachedRepresentationStar = cachedRepresentationTableName + ".*"; 84 final static protected String versionStar = versionTableName + ".*"; 85 final static protected String sourceStar = sourceTableName + ".*"; 97 86 /////////////////////////////////////////////////// 98 99 protected String internalIdName=null; 100 protected String resourceTableName=null; 101 87 protected String internalIdName = null; 88 protected String resourceTableName = null; 89 102 90 ////////////////////////////////////////////////////////////////////////////////// 103 91 @Override 104 public <T extends DasishIdentifier> Number getInternalID(T externalId) {105 if (externalId == null) {92 public <T extends DasishIdentifier> Number getInternalID(T externalId) { 93 if (externalId == null) { 106 94 return null; 107 95 } 108 String sql = "SELECT "+internalIdName+" FROM "+resourceTableName+" WHERE "+external_id +"= ? LIMIT 1";109 List<Number> sqlResult= getSimpleJdbcTemplate().query(sql, internalIDRowMapper, externalId.toString());110 111 if (sqlResult == null) {112 return null;113 }114 if (sqlResult.isEmpty()) {115 return null;116 }117 118 Number result 96 String sql = "SELECT " + internalIdName + " FROM " + resourceTableName + " WHERE " + external_id + "= ? LIMIT 1"; 97 List<Number> sqlResult = getSimpleJdbcTemplate().query(sql, internalIDRowMapper, externalId.toString()); 98 99 if (sqlResult == null) { 100 return null; 101 } 102 if (sqlResult.isEmpty()) { 103 return null; 104 } 105 106 Number result = sqlResult.get(0); 119 107 return result; 120 } 121 122 protected final RowMapper<Number> internalIDRowMapper = new RowMapper<Number>() { 108 } 109 protected final RowMapper<Number> internalIDRowMapper = new RowMapper<Number>() { 123 110 @Override 124 111 public Number mapRow(ResultSet rs, int rowNumber) throws SQLException { 125 int result = rs.getInt(internalIdName); 126 Number resultNumber = 112 int result = rs.getInt(internalIdName); 113 Number resultNumber = result; 127 114 return resultNumber; 128 115 } 129 }; 130 131 132 ///////////////////////////////////////////// 133 134 135 protected String getExternalIdentifier(Number internalId){ 136 if (internalId == null) { 116 }; 117 118 119 ///////////////////////////////////////////// 120 protected String getExternalIdentifier(Number internalId) { 121 if (internalId == null) { 137 122 return null; 138 123 } … … 149 134 return (sqlResult.get(0)); 150 135 } 151 152 136 protected final RowMapper<String> externalIDRowMapper = new RowMapper<String>() { 153 137 @Override … … 156 140 } 157 141 }; 158 159 160 161 142 162 143 ///////////////////////////////////////////////////// 163 protected XMLGregorianCalendar retrieveTimeStamp(Number internalID) {144 protected XMLGregorianCalendar retrieveTimeStamp(Number internalID) { 164 145 String sqlTime = "SELECT " + time_stamp + " FROM " + resourceTableName + " WHERE " + internalIdName + "= ? LIMIT 1"; 165 146 List<XMLGregorianCalendar> timeStamp = getSimpleJdbcTemplate().query(sqlTime, timeStampRowMapper, internalID); … … 181 162 } 182 163 }; 183 184 185 186 164 187 165 protected <T> String makeListOfValues(List<T> vals) { 188 166 189 167 if (vals == null) { 190 168 return null; 191 169 } 192 193 if (vals.isEmpty()) { 170 171 if (vals.isEmpty()) { 194 172 return null; 195 173 } 196 174 197 175 String result = "("; 198 176 int length = vals.size(); 199 for (int i =0; i<length-1; i++){200 result = result + vals.get(i).toString() + ", ";177 for (int i = 0; i < length - 1; i++) { 178 result = result + vals.get(i).toString() + ", "; 201 179 } 202 result = result + vals.get(length-1).toString()+")";180 result = result + vals.get(length - 1).toString() + ")"; 203 181 return result; 204 182 } 205 206 183 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcSourceDao.java
r3372 r3380 61 61 } 62 62 63 @Override 64 public List<Number> retrieveSourceIDs(Number annotationID) { 65 String sql = "SELECT " + source_id + " FROM " + annotationsSourcesTableName + " WHERE " + annotation_id + "= ?"; 66 List<Number> result = getSimpleJdbcTemplate().query(sql, annotationSourceRowMapper, annotationID); 67 return result; 68 } 69 private final RowMapper<Number> annotationSourceRowMapper = new RowMapper<Number>() { 70 @Override 71 public Number mapRow(ResultSet rs, int rowNumber) throws SQLException { 72 Number result = rs.getInt(source_id); 73 return result; 74 } 75 }; 76 77 /////////////////////////////////////////////////////////////////////////////// 63 /////////////////////////////////////////////////////////////////////////////// 78 64 @Override 79 65 public Source getSource(Number internalID) { 80 66 String sql = "SELECT " + sourceStar + "FROM " + sourceTableName + " WHERE " + source_id + " = ?"; 81 List<Source> result = getSimpleJdbcTemplate().query(sql, SourceRowMapper, internalID);67 List<Source> result = getSimpleJdbcTemplate().query(sql, sourceRowMapper, internalID); 82 68 return result.get(0); 83 69 } 84 private final RowMapper<Source> SourceRowMapper = new RowMapper<Source>() {70 private final RowMapper<Source> sourceRowMapper = new RowMapper<Source>() { 85 71 @Override 86 72 public Source mapRow(ResultSet rs, int rowNumber) throws SQLException { … … 97 83 } 98 84 }; 85 86 /////////////////////////////////////////////////////////////////////////////// 87 @Override 88 public Map<String, Object> getRawSource(Number internalID) { 89 String sql = "SELECT " + sourceStar + "FROM " + sourceTableName + " WHERE " + source_id + " = ?"; 90 List<Map<String, Object>> result = getSimpleJdbcTemplate().query(sql, rawSourceRowMapper, internalID); 91 return result.get(0); 92 } 93 private final RowMapper<Map<String, Object>> rawSourceRowMapper = new RowMapper<Map<String, Object>>() { 94 @Override 95 public Map<String, Object> mapRow(ResultSet rs, int rowNumber) throws SQLException { 96 Map<String, Object> result = new HashMap<String, Object>(); 97 result.put(external_id, rs.getString(external_id)); 98 result.put(link_uri, rs.getString(link_uri)); 99 result.put(version_id, rs.getInt(version_id)); 100 return result; 101 } 102 }; 99 103 100 104 /////////////////////////////////////////////////////////////////// … … 140 144 /////////////////////////////////////////////////////////////////// 141 145 @Override 142 public SourceaddSource(Source freshSource) throws SQLException{143 146 public Number addSource(Source freshSource) throws SQLException{ 147 144 148 SourceIdentifier externalIdentifier = new SourceIdentifier(); 149 Number versionID = versionDao.getInternalID(new VersionIdentifier(freshSource.getVersion())); 150 151 if (versionID == null) { 152 System.out.println("Cannot add source because there is no version for it, and no cached representation. Create them and try again."); 153 return -1; 154 } 145 155 146 156 Map<String, Object> params = new HashMap<String, Object>(); 147 157 params.put("externalId", externalIdentifier.toString()); 148 158 params.put("linkUri", freshSource.getLink()); 149 params.put("versionId", freshSource.getVersion());159 params.put("versionId", versionID); 150 160 String sql = "INSERT INTO " + sourceTableName + "(" + external_id + "," + link_uri + "," + version_id + " ) VALUES (:externalId, :linkUri, :versionId)"; 151 161 final int affectedRows = getSimpleJdbcTemplate().update(sql, params); 152 162 163 153 164 Map<String, Object> paramsJoint = new HashMap<String, Object>(); 154 165 paramsJoint.put("sourceId", getInternalID(externalIdentifier)); 155 paramsJoint.put("versionId", freshSource.getVersion()); 156 String sqlSourceVersion = "INSERT INTO " + sourcesVersionsTableName + "(" + source_id + "," + version_id + " ) VALUES (:sourceId, :versionId)"; 157 int affectedRowsJoint = getSimpleJdbcTemplate().update(sqlSourceVersion, paramsJoint); 158 159 if (affectedRows == 1 && affectedRowsJoint == 1) { 160 Source result = makeFreshCopy(freshSource); 161 result.setURI(externalIdentifier.toString()); 162 163 //retrieve taime stamp for the just added annotation 164 XMLGregorianCalendar timeStamp =this.retrieveTimeStamp(getInternalID(new SourceIdentifier(externalIdentifier.toString()))); 165 result.setTimeSatmp(timeStamp); 166 167 return result; 168 } else { 169 throw new SQLException("Cannot add the source"); 170 } 171 166 paramsJoint.put("versionId", versionID); 167 String sqlJoint = "INSERT INTO " + sourcesVersionsTableName + "(" + source_id +"," + version_id + " ) VALUES (:sourceId, :versionId)"; 168 final int affectedJointRows = getSimpleJdbcTemplate().update(sqlJoint, paramsJoint); 169 170 171 return(getInternalID(externalIdentifier)); 172 172 } 173 173 … … 175 175 /////////////////////////////////////////////////////////////////// 176 176 @Override 177 public List<SourceInfo> getSourceInfos(Number annotationID) { 178 List<Number> sources = retrieveSourceIDs(annotationID); 177 public List<SourceInfo> getSourceInfos(List<Number> sources) { 179 178 if (sources == null) { 180 179 return null; … … 228 227 //////////////////////////////////////////////////////////////////////// 229 228 @Override 230 public Map< NewOrExistingSourceInfo, NewOrExistingSourceInfo> addTargetSources(Number annotationID, List<NewOrExistingSourceInfo> sources) throws SQLException {231 232 Map< NewOrExistingSourceInfo, NewOrExistingSourceInfo> result = new HashMap<NewOrExistingSourceInfo, NewOrExistingSourceInfo>();229 public Map<String, String> addTargetSources(Number annotationID, List<NewOrExistingSourceInfo> sources) throws SQLException { 230 231 Map<String, String> result = new HashMap<String, String>(); 233 232 234 233 for (NewOrExistingSourceInfo noeSourceInfo : sources) { 235 234 SourceInfo sourceInfo = noeSourceInfo.getSource(); 236 235 if (sourceInfo != null) { 237 // this is an old source, already exists in the DB 238 result.put(noeSourceInfo, noeSourceInfo); 236 // this is an old source, already exists in the DB 239 237 addAnnotationSourcePair(annotationID, getInternalID(new SourceIdentifier(sourceInfo.getRef()))); 240 238 } else { 241 239 Source newSource = constructNewSource(noeSourceInfo.getNewSource()); 242 Source addedSource = addSource(newSource); 243 int affectedRows = addAnnotationSourcePair(annotationID, getInternalID(new SourceIdentifier(addedSource.getURI()))); 244 245 // create updated source info 246 SourceInfo updatedSourceInfo = new SourceInfo(); 247 updatedSourceInfo.setLink(addedSource.getLink()); 248 updatedSourceInfo.setRef(addedSource.getURI()); 249 updatedSourceInfo.setVersion(addedSource.getVersion()); 250 251 NewOrExistingSourceInfo updatedInfo = new NewOrExistingSourceInfo(); 252 updatedInfo.setSource(updatedSourceInfo); 253 result.put(noeSourceInfo, updatedInfo); 240 Number addedSourceID = addSource(newSource);// adding new source 241 int affectedRows = addAnnotationSourcePair(annotationID, addedSourceID); 242 result.put(noeSourceInfo.getNewSource().getId(), getExternalID(addedSourceID).toString()); 254 243 } 255 244 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcVersionDao.java
r3372 r3380 51 51 return new VersionIdentifier(super.getExternalIdentifier(internalID)); 52 52 } 53 54 ////////////////////////////////////////////////////////////////////////////////////////////////////// 55 @Override 56 public Number getInternalID(VersionIdentifier externalID) { 57 return (super.getInternalID(externalID)); 58 } 59 53 60 /////////////////////////////////////////////////////////////// 54 61 … … 158 165 ///////////////////////////////////////////////// 159 166 @Override 160 public VersionaddVersion(Version freshVersion) {167 public Number addVersion(Version freshVersion) { 161 168 VersionIdentifier externalIdentifier = new VersionIdentifier(); 162 169 String newExternalIdentifier = externalIdentifier.toString(); … … 168 175 String sql = "INSERT INTO " + versionTableName + "(" + external_id + "," + version + " ) VALUES (:externalId, :version)"; 169 176 final int affectedRows = getSimpleJdbcTemplate().update(sql, params); 170 171 if (affectedRows == 1) { 172 Version versionAdded = makeFreshCopy(freshVersion); 173 // TODO change for external identifier when the schema is fixed 174 versionAdded.setVersion(newExternalIdentifier); 175 return versionAdded; 176 } else { 177 return null; 178 } 179 180 // adding the corresponding cached representation is initiated from the separate service POST api/sources/<sid>/cached 181 // so it is not implemented here 177 return getInternalID(externalIdentifier); 182 178 } 183 179 … … 213 209 } 214 210 215 ////////////////////// HELPERS /////////////////////////////// 216 private Version makeFreshCopy(Version version) { 217 Version result = new Version(); 218 // TOD: add external ID when the schema is corrected 219 result.setVersion(version.getVersion()); 220 return result; 221 } 211 222 212 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AnnotationResource.java
r3303 r3380 22 22 import eu.dasish.annotation.backend.dao.NotebookDao; 23 23 import eu.dasish.annotation.backend.dao.PermissionsDao; 24 import eu.dasish.annotation.backend.dao.SourceDao; 24 25 import eu.dasish.annotation.backend.dao.UserDao; 25 26 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier; 26 27 import eu.dasish.annotation.backend.identifiers.UserIdentifier; 27 28 import eu.dasish.annotation.schema.Annotation; 29 import eu.dasish.annotation.schema.NewOrExistingSourceInfo; 28 30 import eu.dasish.annotation.schema.ObjectFactory; 29 31 import eu.dasish.annotation.schema.Permission; 30 32 import java.sql.SQLException; 33 import java.util.List; 34 import java.util.Map; 31 35 import javax.servlet.http.HttpServletRequest; 32 36 import javax.ws.rs.Consumes; … … 53 57 @Autowired 54 58 private AnnotationDao annotationDao; 59 @Autowired 60 private SourceDao sourceDao; 55 61 @Autowired 56 62 private UserDao userDao; … … 87 93 */ 88 94 public String deleteAnnotation(@PathParam("annotationid") String annotationIdentifier) throws SQLException { 89 Number annotationID = annotationDao.getInternalID(new AnnotationIdentifier(annotationIdentifier)); 90 String result = Integer.toString(annotationDao.deleteAnnotation(annotationID)); 95 Number annotationID = annotationDao.getInternalID(new AnnotationIdentifier(annotationIdentifier)); 96 int[] resultDelete = annotationDao.deleteAnnotation(annotationID); 97 String result = Integer.toString(resultDelete[4]); 91 98 return result; 92 99 } … … 98 105 @Path("") 99 106 public JAXBElement<Annotation> createAnnotation(Annotation annotation) throws SQLException { 100 101 107 String remoteUser = httpServletRequest.getRemoteUser(); 102 108 Number userID; 103 104 109 if (remoteUser == null) { 105 110 // happens in client testing … … 110 115 } 111 116 112 Annotation newAnnotation = annotationDao.addAnnotation(annotation, userID); 113 if (newAnnotation == null) { 117 Number annotationID = annotationDao.addAnnotation(annotation, userID); 118 119 // adding sources to the DB if necessary and updating the joint table annotations_target_sources 120 // also, since the source id-s can bementioned in the body, update the body as well 121 // Note that client provided serialization "NewOrExistingSourceInfo" (of type choice) allows to switch between 122 // new and existing sources 123 List<NewOrExistingSourceInfo> sources = annotation.getTargetSources().getTarget(); 124 Map<String, String> sourcePairs = sourceDao.addTargetSources(annotationID, sources); 125 String body = annotationDao.serializeBody(annotation.getBody()); 126 String newBody = annotationDao.updateTargetRefsInBody(body, sourcePairs); 127 if (!body.equals(newBody)) { 128 annotationDao.updateBody(annotationID, newBody); 129 }; 130 131 int affectedPermissions = permissionsDao.addAnnotationPrincipalPermission(annotationDao.getExternalID(annotationID), new UserIdentifier(remoteUser), Permission.OWNER); 132 if (affectedPermissions != 1) { 133 System.out.println("Cannot update permission table"); 114 134 return null; 115 } else {116 int affectedPermissions = permissionsDao.addAnnotationPrincipalPermission(new AnnotationIdentifier(newAnnotation.getURI()), new UserIdentifier(remoteUser), Permission.OWNER);117 return (new ObjectFactory().createAnnotation(newAnnotation));118 135 } 136 Annotation newAnnotation = annotationDao.getAnnotation(annotationID); 137 return (new ObjectFactory().createAnnotation(newAnnotation)); 119 138 } 120 139 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/TestBackendConstants.java
r3361 r3380 22 22 23 23 package eu.dasish.annotation.backend; 24 25 import java.util.UUID;26 24 27 25 public class TestBackendConstants { … … 93 91 public static final String _TEST_VERSION_2_EXT_ID = "00000000-0000-0000-0000-000000000042"; 94 92 public static final String _TEST_VERSION_3_EXT_ID = "00000000-0000-0000-0000-000000000043"; 95 93 public static final String _TEST_VERSION_NONEXIST_EXT_ID = "00000000-0000-0000-0000-000000000049"; 96 94 97 95 public static final String _TEST_TEMP_SOURCE_ID = "Barcelona-1"; -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcAnnotationDaoTest.java
r3370 r3380 43 43 import org.jmock.Mockery; 44 44 import static org.junit.Assert.*; 45 import org.junit.Ignore; 45 46 import org.junit.Test; 46 47 import org.junit.runner.RunWith; … … 76 77 * List<AnnotationInfo> getAnnotationInfos(List<Number> annotationIDs) 77 78 */ 79 80 /** 81 * Test of retrieveSourceIDs method, of class JdbcSourceDao. 82 */ 83 @Test 84 public void testRetrieveSourceIDs() { 85 System.out.println("retrieveSourceIDs"); 86 Number annotationID = 2; 87 List<Number> result = jdbcAnnotationDao.retrieveSourceIDs(annotationID); 88 assertEquals(2, result.size()); 89 assertEquals(1, result.get(0)); 90 assertEquals(2, result.get(1)); 91 } 92 78 93 @Test 79 94 public void testGetAnnotationInfos() { … … 197 212 mockery.checking(new Expectations() { 198 213 { 199 oneOf(sourceDao).getSourceInfos( testAnnotationID);214 oneOf(sourceDao).getSourceInfos(with(aNonNull(List.class))); // retrieveSourceIDs is tested, so we can put "any" instead of its result 200 215 will(returnValue(sourceInfoList)); 201 216 … … 238 253 mockery.checking(new Expectations() { 239 254 { 240 oneOf(sourceDao).retrieveSourceIDs(5);241 will(returnValue(sourceIDs));242 243 255 oneOf(sourceDao).deleteSource(sourceIDs.get(0)); 244 256 will(returnValue(0)); … … 249 261 }); 250 262 251 int result = jdbcAnnotationDao.deleteAnnotation(5); 252 assertEquals(1, result); 263 int[] result = jdbcAnnotationDao.deleteAnnotation(5); 264 // result[0] = # removed notebooks_annotations rows 265 // result[1] = # removed "annotations_principals_perissions" rows 266 // result[2] = # removed "annotatiobs_target_sources" rows 267 // result[3] = # SAFELY removed "target_sources" rows (only unused) 268 // result[4] = # removed annotation rows (should be 1) 269 270 assertEquals(1, result[0]); 271 assertEquals(3, result[1]); 272 assertEquals(2, result[2]); 273 assertEquals(1, result[3]); 274 assertEquals(1, result[4]); 275 276 277 253 278 // now, try to delete the same annotation one more time 254 279 // if it has been already deleted then the method under testing should return 0 255 256 mockery.checking(new Expectations() { 257 { 258 oneOf(sourceDao).retrieveSourceIDs(5); 259 will(returnValue(new ArrayList<Number>())); 260 } 261 }); 280 262 281 result = jdbcAnnotationDao.deleteAnnotation(5); 263 assertEquals(0, result); 282 assertEquals(0, result[0]); 283 assertEquals(0, result[1]); 284 assertEquals(0, result[2]); 285 assertEquals(0, result[3]); 286 assertEquals(0, result[4]); 264 287 } 265 288 … … 268 291 */ 269 292 @Test 270 public void testAddAnnotation ExistingSource() throws SQLException {271 System.out.println("test_addAnnotation with an existing source");272 273 Annotation annotationToAdd = testInstances.getAnnotationToAdd();// existing sources293 public void testAddAnnotation() throws SQLException { 294 System.out.println("test_addAnnotation "); 295 296 final Annotation annotationToAdd = testInstances.getAnnotationToAdd();// existing sources 274 297 assertEquals(null, annotationToAdd.getURI()); 275 298 assertEquals(null, annotationToAdd.getTimeStamp()); 276 277 NewOrExistingSourceInfo noesi = new NewOrExistingSourceInfo(); 278 SourceInfo si = new SourceInfo(); 279 si.setLink(TestBackendConstants._TEST_SOURCE_1_LINK); 280 si.setRef(TestBackendConstants._TEST_SOURCE_1_EXT_ID); 281 si.setVersion(TestBackendConstants._TEST_VERSION_1_EXT_ID); 282 noesi.setSource(si); 283 284 final Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> map = new HashMap<NewOrExistingSourceInfo, NewOrExistingSourceInfo>(); 285 map.put(noesi, noesi); 286 287 288 mockery.checking(new Expectations() { 289 { 290 oneOf(sourceDao).addTargetSources(with(aNonNull(Number.class)), with(aNonNull(List.class))); 291 will(returnValue(map)); 292 } 293 }); 294 295 Annotation result = jdbcAnnotationDao.addAnnotation(annotationToAdd, 5); 296 assertFalse(null == result.getURI()); 297 assertFalse(null == result.getTimeStamp()); 298 assertEquals(annotationToAdd.getBody().getAny().get(0), result.getBody().getAny().get(0)); 299 assertEquals(annotationToAdd.getHeadline(), result.getHeadline()); 300 assertEquals(String.valueOf(5), result.getOwner().getRef()); 301 assertEquals(annotationToAdd.getPermissions(), result.getPermissions()); 302 303 SourceInfo expectedSi = annotationToAdd.getTargetSources().getTarget().get(0).getSource(); 304 SourceInfo resultSi = result.getTargetSources().getTarget().get(0).getSource(); 305 assertEquals(expectedSi.getLink(), resultSi.getLink()); 306 assertEquals(expectedSi.getRef(), resultSi.getRef()); 307 assertEquals(expectedSi.getVersion(), resultSi.getVersion()); 308 } 309 310 /** 311 * Test of addAnnotation method, of class JdbcAnnotationDao. 312 */ 313 @Test 314 public void testAddAnnotationNewSource() throws SQLException { 315 System.out.println("test_addAnnotation with a new source"); 316 317 318 Annotation annotationToAdd = testInstances.getAnnotationToAddNewSource();// existing sources 319 assertEquals(null, annotationToAdd.getURI()); 320 assertEquals(null, annotationToAdd.getTimeStamp()); 321 322 323 NewOrExistingSourceInfo noesi = new NewOrExistingSourceInfo(); 324 NewSourceInfo nsi = new NewSourceInfo(); 325 nsi.setLink(TestBackendConstants._TEST_NEW_SOURCE_LINK); 326 nsi.setId(TestBackendConstants._TEST_TEMP_SOURCE_ID); 327 nsi.setVersion(null); 328 noesi.setNewSource(nsi); 329 330 331 NewOrExistingSourceInfo noesiTwo = new NewOrExistingSourceInfo(); 332 SourceInfo si = new SourceInfo(); 333 si.setLink(TestBackendConstants._TEST_NEW_SOURCE_LINK); 334 si.setRef((new SourceIdentifier()).toString()); 335 si.setVersion(null); 336 noesiTwo.setSource(si); 337 338 final Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> map = new HashMap<NewOrExistingSourceInfo, NewOrExistingSourceInfo>(); 339 map.put(noesi, noesiTwo); 340 341 342 mockery.checking(new Expectations() { 343 { 344 oneOf(sourceDao).addTargetSources(with(aNonNull(Number.class)), with(aNonNull(List.class))); 345 will(returnValue(map)); 346 } 347 }); 348 349 Annotation result = jdbcAnnotationDao.addAnnotation(annotationToAdd, 5); 350 assertFalse(null == result.getURI()); 351 assertFalse(null == result.getTimeStamp()); 352 assertEquals(annotationToAdd.getHeadline(), result.getHeadline()); 353 assertEquals(String.valueOf(5), result.getOwner().getRef()); 354 assertEquals(annotationToAdd.getPermissions(), result.getPermissions()); 355 356 NewSourceInfo expectedSi = annotationToAdd.getTargetSources().getTarget().get(0).getNewSource(); 357 SourceInfo resultSi = result.getTargetSources().getTarget().get(0).getSource(); 358 assertEquals(expectedSi.getLink(), resultSi.getLink()); 359 assertEquals(expectedSi.getVersion(), resultSi.getVersion()); 360 //the reference is replaced with the persistent one 361 assertEquals(si.getRef(), resultSi.getRef()); 362 ///// 363 364 // checking the bodies: the temporary reference should be replaced 365 String expBody = annotationToAdd.getBody().getAny().get(0).toString().replaceAll(TestBackendConstants._TEST_TEMP_SOURCE_ID, si.getRef()); 366 assertEquals(expBody, result.getBody().getAny().get(0).toString()); 367 } 368 369 299 300 Number newAnnotationID = jdbcAnnotationDao.addAnnotation(annotationToAdd, 5); 301 assertEquals(6, newAnnotationID); 302 303 Map<String, Object> addedAnnotation= jdbcAnnotationDao.getRawAnnotation(6); 304 assertFalse(null == addedAnnotation.get("external_id")); 305 assertFalse(null == addedAnnotation.get("time_stamp")); 306 assertEquals(5, addedAnnotation.get("owner_id")); 307 assertEquals(annotationToAdd.getBody().getAny().get(0), addedAnnotation.get("body_xml")); // TODO: to be changed after serialization is fixed 308 assertEquals(annotationToAdd.getHeadline(), addedAnnotation.get("headline")); 309 } 310 311 312 313 314 // NewOrExistingSourceInfo noesi = new NewOrExistingSourceInfo(); 315 // NewSourceInfo nsi = new NewSourceInfo(); 316 // nsi.setLink(TestBackendConstants._TEST_NEW_SOURCE_LINK); 317 // nsi.setId(TestBackendConstants._TEST_TEMP_SOURCE_ID); 318 // nsi.setVersion(null); 319 // noesi.setNewSource(nsi); 320 // 321 // 322 // NewOrExistingSourceInfo noesiTwo = new NewOrExistingSourceInfo(); 323 // SourceInfo si = new SourceInfo(); 324 // si.setLink(TestBackendConstants._TEST_NEW_SOURCE_LINK); 325 // si.setRef((new SourceIdentifier()).toString()); 326 // si.setVersion(null); 327 // noesiTwo.setSource(si); 328 // 329 // final Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> map = new HashMap<NewOrExistingSourceInfo, NewOrExistingSourceInfo>(); 330 // map.put(noesi, noesiTwo); 331 // 332 // 333 // mockery.checking(new Expectations() { 334 // { 335 // oneOf(sourceDao).addTargetSources(with(aNonNull(Number.class)), with(aNonNull(List.class))); 336 // will(returnValue(map)); 337 // } 338 // }); 339 340 370 341 /** 371 342 * testing public List<Number> getAnnotationIDsForSources(List<Number> sourceIDs); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcCachedRepresentationDaoTest.java
r3298 r3380 25 25 import org.junit.Test; 26 26 import static org.junit.Assert.*; 27 import org.junit.Ignore;28 27 import org.junit.runner.RunWith; 29 28 import org.springframework.beans.factory.annotation.Autowired; … … 38 37 @RunWith(SpringJUnit4ClassRunner.class) 39 38 @ContextConfiguration({"/spring-test-config/dataSource.xml", "/spring-test-config/mockery.xml", "/spring-test-config/mockAnnotationDao.xml", 40 "/spring-test-config/mockUserDao.xml", "/spring-test-config/mockPermissionsDao.xml", "/spring-test-config/mockNotebookDao.xml", "/spring-config/cachedRepresentationDao.xml"}) 39 "/spring-test-config/mockUserDao.xml", "/spring-test-config/mockPermissionsDao.xml", "/spring-test-config/mockNotebookDao.xml", 40 "/spring-test-config/mockSourceDao.xml", "/spring-config/cachedRepresentationDao.xml"}) 41 41 public class JdbcCachedRepresentationDaoTest extends JdbcResourceDaoTest{ 42 42 … … 150 150 cached.setTool("vi"); 151 151 cached.setType("text"); 152 cached.setRef(null); 152 153 153 CachedRepresentationInfo result = jdbcCachedRepresentationDao.addCachedRepresentationInfo(cached); 154 assertEquals("text/plain", result.getMimeType()); 155 assertEquals("vi", result.getTool()); 156 assertEquals("text", result.getType()); 157 assertFalse(result.getRef() == null); // new non-null external identifier should be assigned 154 Number result = jdbcCachedRepresentationDao.addCachedRepresentationInfo(cached); 155 CachedRepresentationInfo addedCached = jdbcCachedRepresentationDao.getCachedRepresentationInfo(result); 156 assertEquals("text/plain", addedCached.getMimeType()); 157 assertEquals("vi", addedCached.getTool()); 158 assertEquals("text", addedCached.getType()); 159 assertFalse(addedCached.getRef() == null); // new non-null external identifier should be assigned 158 160 } 159 161 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcNotebookDaoTest.java
r3218 r3380 49 49 */ 50 50 @RunWith(SpringJUnit4ClassRunner.class) 51 @ContextConfiguration({"/spring-test-config/mockery.xml", "/spring-test-config/mockAnnotationDao.xml", "/spring-test-config/mock UserDao.xml", "/spring-test-config/mockPermissionsDao.xml",51 @ContextConfiguration({"/spring-test-config/mockery.xml", "/spring-test-config/mockAnnotationDao.xml", "/spring-test-config/mockSourceDao.xml", "/spring-test-config/mockUserDao.xml", "/spring-test-config/mockPermissionsDao.xml", 52 52 "/spring-test-config/dataSource.xml", "/spring-config/notebookDao.xml"}) 53 53 public class JdbcNotebookDaoTest extends JdbcResourceDaoTest{ -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcPermissionsDaoTest.java
r3218 r3380 39 39 40 40 @RunWith(SpringJUnit4ClassRunner.class) 41 @ContextConfiguration({"/spring-test-config/mockery.xml", "/spring-test-config/dataSource.xml", "/spring-test-config/mockUserDao.xml", "/spring-test-config/mock AnnotationDao.xml", "/spring-test-config/mockNotebookDao.xml", "/spring-config/permissionsDao.xml"})41 @ContextConfiguration({"/spring-test-config/mockery.xml", "/spring-test-config/dataSource.xml", "/spring-test-config/mockUserDao.xml", "/spring-test-config/mockSourceDao.xml","/spring-test-config/mockAnnotationDao.xml", "/spring-test-config/mockNotebookDao.xml", "/spring-config/permissionsDao.xml"}) 42 42 public class JdbcPermissionsDaoTest extends JdbcResourceDaoTest{ 43 43 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcSourceDaoTest.java
r3367 r3380 81 81 } 82 82 83 /** 84 * Test of retrieveSourceIDs method, of class JdbcSourceDao. 85 */ 86 @Test 87 public void testRetrieveSourceIDs() { 88 System.out.println("retrieveSourceIDs"); 89 Number annotationID = 2; 90 List<Number> result = jdbcSourceDao.retrieveSourceIDs(annotationID); 91 assertEquals(2, result.size()); 92 assertEquals(1, result.get(0)); 93 assertEquals(2, result.get(1)); 94 } 83 95 84 96 85 /** … … 169 158 System.out.println("addSource"); 170 159 171 String link = "http://www.sagradafamilia.cat/"; 172 String version = null; 173 String timeStamp = null; 174 160 String link = "http://www.sagradafamilia.cat/"; 161 162 // existing version 175 163 Source freshSource = new Source(); 176 164 freshSource.setLink(link); 177 freshSource.setVersion(version); 178 freshSource.setVersion(timeStamp); 179 165 freshSource.setVersion(TestBackendConstants._TEST_VERSION_1_EXT_ID); 166 freshSource.setURI(null); 167 freshSource.setTimeSatmp(null); 168 169 mockery.checking(new Expectations() { 170 { 171 oneOf(versionDao).getInternalID(new VersionIdentifier(TestBackendConstants._TEST_VERSION_1_EXT_ID)); 172 will(returnValue(1)); 173 } 174 }); 175 180 176 try { 181 Source result = jdbcSourceDao.addSource(freshSource); 182 assertEquals(link, result.getLink()); 183 assertEquals(version, result.getVersion()); 184 assertEquals(6, jdbcSourceDao.getInternalID(new SourceIdentifier(result.getURI()))); 185 186 assertFalse(null==result.getTimeSatmp()); 187 177 Number result = jdbcSourceDao.addSource(freshSource); 178 assertEquals(6, result); 179 Map<String, Object> addedSource = jdbcSourceDao.getRawSource(result); 180 assertEquals(link, addedSource.get("link_uri")); 181 assertEquals(1, addedSource.get("version_id")); 182 assertFalse(null==addedSource.get("external_id")); 188 183 } catch (SQLException e) { 189 184 System.out.println(e); 190 185 } 186 187 ////////// test 2 non-existing source 188 freshSource.setVersion(TestBackendConstants._TEST_VERSION_NONEXIST_EXT_ID); 189 mockery.checking(new Expectations() { 190 { 191 oneOf(versionDao).getInternalID(new VersionIdentifier(TestBackendConstants._TEST_VERSION_NONEXIST_EXT_ID)); 192 will(returnValue(null)); 193 } 194 }); 195 196 try { 197 Number result = jdbcSourceDao.addSource(freshSource); 198 assertEquals(-1, result); 199 } catch (SQLException e) { 200 System.out.println(e); 201 } 202 191 203 } 192 204 … … 197 209 public void testGetSourceInfos() { 198 210 System.out.println("getSourceInfos"); 199 Number annotationID = 2; 211 List<Number> test = new ArrayList<Number>(); 212 test.add(1); 213 test.add(2); 200 214 201 215 mockery.checking(new Expectations() { … … 209 223 }); 210 224 211 List<SourceInfo> result = jdbcSourceDao.getSourceInfos( annotationID);225 List<SourceInfo> result = jdbcSourceDao.getSourceInfos(test); 212 226 assertEquals(2, result.size()); 213 227 assertEquals(TestBackendConstants._TEST_SOURCE_1_EXT_ID, result.get(0).getRef()); … … 270 284 271 285 try { 272 Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> result = jdbcSourceDao.addTargetSources(5, listnoesi); 273 assertEquals(1, result.size()); 274 assertEquals(result.get(noesi), noesi); 286 Map<String, String> result = jdbcSourceDao.addTargetSources(5, listnoesi); 287 assertEquals(0, result.size()); // no new peristsent source IDs are produced 275 288 } catch (SQLException e) { 276 289 System.out.println(e); … … 292 305 nsi.setLink(TestBackendConstants._TEST_NEW_SOURCE_LINK); 293 306 nsi.setId(TestBackendConstants._TEST_TEMP_SOURCE_ID); 294 nsi.setVersion( null);307 nsi.setVersion(TestBackendConstants._TEST_VERSION_1_EXT_ID); 295 308 noesi.setNewSource(nsi); 296 309 297 310 List<NewOrExistingSourceInfo> listnoesiTwo = new ArrayList<NewOrExistingSourceInfo>(); 298 311 listnoesiTwo.add(noesi); 312 313 mockery.checking(new Expectations() { 314 { 315 oneOf(versionDao).getInternalID(new VersionIdentifier(TestBackendConstants._TEST_VERSION_1_EXT_ID)); 316 will(returnValue(1)); 317 } 318 }); 299 319 300 320 try { 301 Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> result = jdbcSourceDao.addTargetSources(5, listnoesiTwo); 302 assertEquals(1, result.size()); 303 assertEquals(noesi.getNewSource().getLink(), result.get(noesi).getSource().getLink()); 304 assertEquals(noesi.getNewSource().getVersion(), result.get(noesi).getSource().getVersion()); 305 306 SourceIdentifier sourceIdentifier = new SourceIdentifier(result.get(noesi).getSource().getRef()); 321 Map<String, String> result = jdbcSourceDao.addTargetSources(5, listnoesiTwo); 322 assertEquals(1, result.size());// a new identifier must be produced 323 SourceIdentifier sourceIdentifier = new SourceIdentifier(result.get(TestBackendConstants._TEST_TEMP_SOURCE_ID)); 307 324 assertFalse(null == sourceIdentifier.getUUID()); // check if a proper uuid has been assigned 308 325 } catch (SQLException e) { -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcVersionDaoTest.java
r3372 r3380 40 40 @ContextConfiguration({"/spring-test-config/dataSource.xml", "/spring-test-config/mockery.xml", "/spring-test-config/mockAnnotationDao.xml", 41 41 "/spring-test-config/mockUserDao.xml", "/spring-test-config/mockPermissionsDao.xml", "/spring-test-config/mockNotebookDao.xml", 42 "/spring-test-config/mock CachedRepresentationDao.xml", "/spring-config/versionDao.xml"})42 "/spring-test-config/mockSourceDao.xml", "/spring-test-config/mockCachedRepresentationDao.xml", "/spring-config/versionDao.xml"}) 43 43 44 44 public class JdbcVersionDaoTest extends JdbcResourceDaoTest{ … … 169 169 Version freshVersion = new Version(); 170 170 171 Versionresult = jdbcVersionDao.addVersion(freshVersion);172 assert False(null==result.getVersion());173 174 // check if it is a good UUID. the program breaks if the string is anot a good UUID175 assertEquals(result.getVersion(), (new VersionIdentifier(result.getVersion())).toString());171 Number result = jdbcVersionDao.addVersion(freshVersion); 172 assertEquals(8, result); 173 Version addedVersion = jdbcVersionDao.getVersion(result); 174 assertFalse(null==addedVersion.getVersion()); 175 176 176 } 177 177 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationResourceTest.java
r3303 r3380 24 24 import eu.dasish.annotation.backend.dao.NotebookDao; 25 25 import eu.dasish.annotation.backend.dao.PermissionsDao; 26 import eu.dasish.annotation.backend.dao.SourceDao; 26 27 import eu.dasish.annotation.backend.dao.UserDao; 27 28 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier; 28 29 import eu.dasish.annotation.backend.identifiers.UserIdentifier; 29 30 import eu.dasish.annotation.schema.Annotation; 31 import eu.dasish.annotation.schema.NewOrExistingSourceInfo; 30 32 import eu.dasish.annotation.schema.Permission; 31 33 import eu.dasish.annotation.schema.ResourceREF; 34 import eu.dasish.annotation.schema.SourceInfo; 32 35 import java.sql.SQLException; 33 36 import javax.xml.bind.JAXBElement; … … 41 44 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 42 45 import java.lang.InstantiationException; 46 import java.util.HashMap; 47 import java.util.List; 48 import java.util.Map; 43 49 import javax.servlet.ServletException; 44 50 import org.springframework.mock.web.MockHttpServletRequest; … … 49 55 50 56 @RunWith(value = SpringJUnit4ClassRunner.class) 51 @ContextConfiguration(locations = {"/spring-test-config/dataSource.xml", "/spring-test-config/mockAnnotationDao.xml", "/spring-test-config/mockUserDao.xml", "/spring-test-config/mockPermissionsDao.xml", "/spring-test-config/mockNotebookDao.xml", "/spring-test-config/mockery.xml"}) 57 @ContextConfiguration(locations = {"/spring-test-config/dataSource.xml", "/spring-test-config/mockAnnotationDao.xml", 58 "/spring-test-config/mockSourceDao.xml", 59 "/spring-test-config/mockUserDao.xml", "/spring-test-config/mockPermissionsDao.xml", "/spring-test-config/mockNotebookDao.xml", "/spring-test-config/mockery.xml"}) 52 60 public class AnnotationResourceTest { 53 61 … … 61 69 private PermissionsDao permissionsDao; 62 70 @Autowired 63 private NotebookDao notebookDao; 71 private NotebookDao notebookDao; 72 @Autowired 73 private SourceDao sourceDao; 64 74 65 75 @Autowired … … 101 111 System.out.println("deleteAnnotation"); 102 112 113 103 114 mockery.checking(new Expectations() { 104 { 115 { 105 116 oneOf(annotationDao).getInternalID(new AnnotationIdentifier(TestBackendConstants._TEST_ANNOT_5_EXT)); 106 117 will(returnValue(5)); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/NotebookResourceTest.java
r3218 r3380 47 47 */ 48 48 @RunWith(value = SpringJUnit4ClassRunner.class) 49 @ContextConfiguration(locations = {"/spring-test-config/dataSource.xml", "/spring-test-config/mockAnnotationDao.xml", "/spring-test-config/mockUserDao.xml", "/spring-test-config/mockNotebookDao.xml", "/spring-test-config/mockPermissionsDao.xml", "/spring-test-config/mockery.xml"}) 49 @ContextConfiguration(locations = {"/spring-test-config/dataSource.xml", "/spring-test-config/mockAnnotationDao.xml", "/spring-test-config/mockUserDao.xml", 50 "/spring-test-config/mockSourceDao.xml", "/spring-test-config/mockNotebookDao.xml", "/spring-test-config/mockPermissionsDao.xml", "/spring-test-config/mockery.xml"}) 50 51 public class NotebookResourceTest { 51 52
Note: See TracChangeset
for help on using the changeset viewer.