Changeset 4491
- Timestamp:
- 02/10/14 15:26:08 (10 years ago)
- Location:
- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/AnnotationDao.java
r4429 r4491 51 51 public Annotation getAnnotationWithoutTargetsAndPermissions(Number annotationID); 52 52 53 54 /** 55 * 56 * @param annotationIDs: the list of annotationID-s from which the resulting annotations are to be selected. 57 * @param text: the text which the resulting annotations' bodies must contain.* @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". 61 * @return the sub-list of internal annotation identifiers from the list "internalIDs" for annotations 62 * -- bodies of which contain the "text", 63 * -- to which inlogged user has "access", 64 * -- owned by "owner", 65 * -- added to the database between "before" and "after" time-dates. 66 * 67 */ 68 public List<Number> getFilteredAnnotationIDs(List<Number> annotationIDs, Number ownerID, String text, String namespace, String after, String before); 53 54 public List<Number> getFilteredAnnotationIDs(Number ownerID, String text, String namespace, String after, String before); 69 55 56 57 public List<Number> getAnnotationIDsForUserWithPermission(Number userID, String acess); 58 59 60 public List<Number> getAnnotationIDsForTargets(List<Number> TargetIDs); 61 62 /* 63 * Use inly in the debugging mode to acces all the existing annotations. 64 */ 70 65 public List<Number> getAllAnnotationIDs(); 71 66 … … 85 80 public List<String> getAnnotationREFs(List<Number> annotationIDs); 86 81 87 /** 88 * 89 * @param TargetIDs 90 * @return the list of annotationdIDs of the annotations which target Targets are from "TargetIDs" list. 91 */ 92 public List<Number> retrieveAnnotationList(List<Number> TargetIDs); 93 82 83 84 94 85 95 86 /** … … 117 108 */ 118 109 public Permission getPermission(Number annotationID, Number userID); 119 120 public List<Number> getAnnotationIDsForUserWithPermission(Number userID, String[] permissionStrings);121 110 122 111 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/DBIntegrityService.java
r4429 r4491 87 87 * -- created after time-samp "after and before time-stamp "before". 88 88 */ 89 List<Number> getFilteredAnnotationIDs(UUID ownerId, String link, String text, Number inloggedUserID, String [] accessModes, String namespace, String after, String before);89 List<Number> getFilteredAnnotationIDs(UUID ownerId, String link, String text, Number inloggedUserID, String access, String namespace, String after, String before); 90 90 91 91 AnnotationInfoList getAllAnnotationInfos(); … … 108 108 * -- created after time-samp "after and before time-stamp "before". 109 109 */ 110 AnnotationInfoList getFilteredAnnotationInfos(UUID ownerId, String word, String text, Number inloggedUserID, String[] accessModes, String namespace, String after, String before);110 AnnotationInfoList getFilteredAnnotationInfos(UUID ownerId, String word, String text, Number inloggedUserID, String access, String namespace, String after, String before); 111 111 112 112 /** … … 237 237 public String getTypeOfUserAccount(Number userID); 238 238 239 public boolean canRead(Number userID, Number annotationID); 240 241 public boolean canWrite(Number userID, Number annotationID); 242 239 243 /** 240 244 * UPDATERS -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/DBIntegrityServiceImlp.java
r4429 r4491 65 65 @Autowired 66 66 AnnotationDao annotationDao; 67 68 final static protected String admin = "admin"; 67 69 private static final Logger logger = LoggerFactory.getLogger(AnnotationResource.class); 68 70 ////////////////////////////////// … … 152 154 } 153 155 } 154 156 155 157 @Override 156 158 public Number getAnnotationOwner(Number annotationID) { … … 186 188 //////////////////////////////////////////////////////////////////////// 187 189 @Override 188 public List<Number> getFilteredAnnotationIDs(UUID ownerId, String link, String text, Number inloggedUserID, String[] accessModes, String namespace, String after, String before) { 189 190 if (accessModes == null) { 191 return null; 192 } 193 194 List<Number> annotationIDs = annotationDao.getAnnotationIDsForUserWithPermission(inloggedUserID, accessModes); 195 190 public List<Number> getFilteredAnnotationIDs(UUID ownerId, String link, String text, Number inloggedUserID, String access, String namespace, String after, String before) { 191 192 Number ownerID = (ownerId != null) ? userDao.getInternalID(ownerId) : null; 193 if (ownerID != null) { 194 if ("owner".equals(access) && !inloggedUserID.equals(ownerID)) { 195 logger.info("The inlogged user cannot be the owner of the annotations owned by " + ownerId.toString()); 196 return null; 197 } 198 } 199 200 //filtering on tables "target" and "annotations_targets" 201 List<Number> annotationIDsForTargets = null; 196 202 if (link != null) { 197 203 List<Number> targetIDs = targetDao.getTargetsReferringTo(link); 198 List<Number> annotationIDsForTargets = annotationDao.retrieveAnnotationList(targetIDs); 199 annotationIDs.retainAll(annotationIDsForTargets); 200 } 201 202 Number ownerID = (ownerId != null) ? userDao.getInternalID(ownerId) : null; 203 return annotationDao.getFilteredAnnotationIDs(annotationIDs, ownerID, text, namespace, after, before); 204 annotationIDsForTargets = annotationDao.getAnnotationIDsForTargets(targetIDs); 205 if (annotationIDsForTargets == null) { 206 logger.info("There are no annotations for the targets referring to " + link + "."); 207 return null; 208 } 209 } 210 211 // filtering in the table "annotation" 212 if (ownerID == null && "owner".equals(access)) { 213 ownerID = inloggedUserID; 214 } 215 List<Number> annotationIDs = annotationDao.getFilteredAnnotationIDs(ownerID, text, namespace, after, before); 216 if (annotationIDs != null) { 217 if (annotationIDsForTargets != null) { 218 annotationIDs.retainAll(annotationIDsForTargets); 219 } else { 220 // nothing to filter on link == null 221 } 222 } else { 223 logger.info("There are no annotations for the given filters on the annotation table."); 224 return null; 225 } 226 227 // filtering on table "annotations_principals_permissions" 228 if ("reader".equals(access) || "writer".equals(access)) { 229 // owner != inloggedUser 230 List<Number> annotationIDsPermission = annotationDao.getAnnotationIDsForUserWithPermission(inloggedUserID, access); 231 if (annotationIDsPermission != null) { 232 annotationIDs.retainAll(annotationIDsPermission); 233 } else { 234 logger.info("There are no annotations for which the inlogged user has access " + access); 235 return null; 236 } 237 } else { 238 // inloggedUser == owner 239 } 240 return annotationIDs; 204 241 } 205 242 … … 256 293 257 294 @Override 258 public AnnotationInfoList getFilteredAnnotationInfos(UUID ownerId, String word, String text, Number inloggedUserID, String [] accessModes, String namespace, String after, String before) {259 List<Number> annotationIDs = this.getFilteredAnnotationIDs(ownerId, word, text, inloggedUserID, access Modes, namespace, after, before);295 public AnnotationInfoList getFilteredAnnotationInfos(UUID ownerId, String word, String text, Number inloggedUserID, String access, String namespace, String after, String before) { 296 List<Number> annotationIDs = this.getFilteredAnnotationIDs(ownerId, word, text, inloggedUserID, access, namespace, after, before); 260 297 if (annotationIDs != null) { 261 298 AnnotationInfoList result = new AnnotationInfoList(); … … 366 403 return userDao.getTypeOfUserAccount(userID); 367 404 } 405 406 @Override 407 public boolean canRead(Number userID, Number annotationID) { 408 if (userID.equals(annotationDao.getOwner(annotationID)) || userDao.getTypeOfUserAccount(userID).equals(admin)) { 409 return true; 410 } 411 412 final Permission permission = annotationDao.getPermission(annotationID, userID); 413 if (permission != null) { 414 return (permission.value().equals(Permission.WRITER.value()) || permission.value().equals(Permission.READER.value())); 415 } else { 416 return false; 417 } 418 } 419 420 @Override 421 public boolean canWrite(Number userID, Number annotationID) { 422 if (userID.equals(annotationDao.getOwner(annotationID)) || userDao.getTypeOfUserAccount(userID).equals(admin)) { 423 return true; 424 } 425 final Permission permission = annotationDao.getPermission(annotationID, userID); 426 if (permission != null) { 427 return (permission.value().equals(Permission.WRITER.value())); 428 } else { 429 return false; 430 } 431 } 368 432 369 433 ///// UPDATERS ///////////////// -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcAnnotationDao.java
r4429 r4491 94 94 }; 95 95 96 97 96 98 @Override 97 99 public Permission getPermission(Number annotationID, Number userID) { … … 126 128 }; 127 129 128 @Override 129 public List<Number> getAnnotationIDsForUserWithPermission(Number userID, String[] permissionStrings) { 130 if (permissionStrings == null) { 131 loggerAnnotationDao.debug("premissionStrings: " + nullArgument); 132 return null; 133 } 134 135 if (userID == null) { 136 loggerAnnotationDao.debug("userID: " + nullArgument); 137 return null; 138 } 139 140 String values = stringsToValuesString(permissionStrings); 141 142 StringBuilder sql = new StringBuilder("SELECT "); 143 sql.append(annotation_id).append(" FROM ").append(permissionsTableName).append(" WHERE "). 144 append(principal_id).append(" = ?").append(" AND "). 145 append(permission).append(" IN ").append(values); 146 return getSimpleJdbcTemplate().query(sql.toString(), internalIDRowMapper, userID); 147 } 148 149 private String stringsToValuesString(String[] strings) { 150 if (strings == null) { 151 return null; 152 } 153 154 int length = strings.length; 155 if (length == 0) { 156 return null; 157 } 158 String result = "("; 159 for (int i = 0; i < length - 1; i++) { 160 result = result + "'" + strings[i] + "', "; 161 } 162 result = result + "'" + strings[length - 1] + "')"; 163 return result; 164 } 165 130 131 132 166 133 //////////////////////////////////////////////////////////////////////// 167 134 @Override 168 public List<Number> getFilteredAnnotationIDs( List<Number> annotationIDs,Number ownerID, String text, String namespace, String after, String before) {135 public List<Number> getFilteredAnnotationIDs(Number ownerID, String text, String namespace, String after, String before) { 169 136 170 137 StringBuilder sql = new StringBuilder("SELECT DISTINCT "); 171 138 sql.append(annotation_id).append(" FROM ").append(annotationTableName).append(" WHERE TRUE "); 172 139 Map<String, Object> params = new HashMap<String, Object>(); 173 174 if (annotationIDs == null) {175 loggerAnnotationDao.debug("annotationIDs: " + nullArgument);176 return null;177 } else {178 if (annotationIDs.isEmpty()) {179 return new ArrayList<Number>();180 }181 }182 183 String values = makeListOfValues(annotationIDs);184 sql.append(" AND ").append(annotation_id).append(" IN ").append(values);185 140 186 141 if (ownerID != null) { … … 206 161 } 207 162 208 ///////////////////////////////////////// 209 @Override 210 public List<Number> getAllAnnotationIDs() { 163 /////////////////////////////////////////////////////////////////////////////////// 164 @Override 165 public List<Number> getAnnotationIDsForUserWithPermission(Number userID, String access) { 166 167 if (userID == null) { 168 loggerAnnotationDao.debug("userID: " + nullArgument); 169 return null; 170 } 171 172 if (access == null) { 173 logger.info("The access argument is null. I assign it a default value 'reader'."); 174 access = "reader"; 175 } 176 177 211 178 StringBuilder sql = new StringBuilder("SELECT "); 212 sql.append(annotation_id).append(" , ").append(last_modified).append(" FROM ").append(annotationTableName).append(" ORDER BY ").append(last_modified).append(" DESC"); 213 return getSimpleJdbcTemplate().query(sql.toString(), internalIDRowMapper); 214 } 179 sql.append(annotation_id).append(" FROM ").append(permissionsTableName).append(" WHERE "). 180 append(principal_id).append(" = ?").append(" AND "). 181 append(permission).append(" = ").append(access); 182 return getSimpleJdbcTemplate().query(sql.toString(), internalIDRowMapper, userID); 183 } 184 185 186 187 215 188 216 189 ////////////////////////////// 217 190 @Override 218 public List<Number> retrieveAnnotationList(List<Number> targetIDs) {191 public List<Number> getAnnotationIDsForTargets(List<Number> targetIDs) { 219 192 if (targetIDs == null) { 220 193 loggerAnnotationDao.debug("targetIDs: " + nullArgument); … … 229 202 query.append(values); 230 203 return getSimpleJdbcTemplate().query(query.toString(), internalIDRowMapper); 204 } 205 206 207 208 209 ///////////////////////////////////////// 210 @Override 211 public List<Number> getAllAnnotationIDs() { 212 StringBuilder sql = new StringBuilder("SELECT "); 213 sql.append(annotation_id).append(" , ").append(last_modified).append(" FROM ").append(annotationTableName).append(" ORDER BY ").append(last_modified).append(" DESC"); 214 return getSimpleJdbcTemplate().query(sql.toString(), internalIDRowMapper); 231 215 } 232 216 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcResourceDao.java
r4429 r4491 96 96 final static protected String targetStar = targetTableName + ".*"; 97 97 final static protected String principalStar = principalTableName + ".*"; 98 99 //////////////////////////////// 100 101 98 102 /////////////////////////////////////////////////// 99 103 protected String internalIdName = null; -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcUserDao.java
r4461 r4491 78 78 public User getUserByInfo(String eMail) { 79 79 StringBuilder sql = new StringBuilder("SELECT "); 80 sql.append(principalStar).append(" FROM ").append(principalTableName).append(" WHERE ").append( e_mail).append("= ? LIMIT 1");80 sql.append(principalStar).append(" FROM ").append(principalTableName).append(" WHERE ").append("LOWER(").append(e_mail).append(")").append("= ? LIMIT 1"); 81 81 List<User> result = getSimpleJdbcTemplate().query(sql.toString(), userRowMapper, eMail.toLowerCase()); 82 82 return (!result.isEmpty() ? result.get(0) : null); … … 198 198 params.put("externalId", newExternalIdentifier); 199 199 params.put("principalName", user.getDisplayName()); 200 params.put("email", user.getEMail() .toLowerCase());200 params.put("email", user.getEMail()); 201 201 params.put("remoteID", remoteID); 202 202 params.put("accountType", this.user); … … 261 261 StringBuilder sql = new StringBuilder("UPDATE "); 262 262 sql.append(principalTableName).append(" SET "). 263 append(e_mail).append("= '").append(user.getEMail() .toLowerCase()).append("',").263 append(e_mail).append("= '").append(user.getEMail()).append("',"). 264 264 append(principal_name).append("= '").append(user.getDisplayName()).append("' "). 265 265 append(" WHERE ").append(principal_id).append("= ?"); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AnnotationResource.java
r4429 r4491 83 83 @Context 84 84 private ServletContext context; 85 final String default_permission = "reader";85 86 86 private final Logger logger = LoggerFactory.getLogger(AnnotationResource.class); 87 87 public static final Logger loggerServer = LoggerFactory.getLogger(HttpServletResponse.class); … … 123 123 final Number userID = dbIntegrityService.getUserInternalIDFromRemoteID(remoteUser); 124 124 if (userID != null) { 125 if (dbIntegrityService. getTypeOfUserAccount(userID).equals(admin) ||canRead(userID, annotationID)) {125 if (dbIntegrityService.canRead(userID, annotationID)) { 126 126 final Annotation annotation = dbIntegrityService.getAnnotation(annotationID); 127 127 JAXBElement<Annotation> rootElement = new ObjectFactory().createAnnotation(annotation); … … 164 164 final Number userID = dbIntegrityService.getUserInternalIDFromRemoteID(remoteUser); 165 165 if (userID != null) { 166 if (dbIntegrityService. getTypeOfUserAccount(userID).equals(admin) ||canRead(userID, annotationID)) {166 if (dbIntegrityService.canRead(userID, annotationID)) { 167 167 final ReferenceList TargetList = dbIntegrityService.getAnnotationTargets(annotationID); 168 168 logger.info("getAnnotationTargets method: OK"); … … 197 197 public JAXBElement<AnnotationInfoList> getFilteredAnnotations(@QueryParam("link") String link, 198 198 @QueryParam("text") String text, 199 @QueryParam("access") String permission,199 @QueryParam("access") String access, 200 200 @QueryParam("namespace") String namespace, 201 201 @QueryParam("owner") String ownerExternalId, … … 209 209 try { 210 210 UUID ownerExternalUUID = (ownerExternalId != null) ? UUID.fromString(ownerExternalId) : null; 211 String access = (permission != null) ? permission : default_permission;212 final AnnotationInfoList annotationInfoList = dbIntegrityService.getFilteredAnnotationInfos(ownerExternalUUID, link, text, userID, this.makeAccessModeChain(access), namespace, after, before);211 212 final AnnotationInfoList annotationInfoList = dbIntegrityService.getFilteredAnnotationInfos(ownerExternalUUID, link, text, userID, access, namespace, after, before); 213 213 return new ObjectFactory().createAnnotationInfoList(annotationInfoList); 214 214 } catch (IllegalArgumentException e) { … … 238 238 if (userID != null) { 239 239 if (annotationID != null) { 240 if (dbIntegrityService. getTypeOfUserAccount(userID).equals(admin) ||canRead(userID, annotationID)) {240 if (dbIntegrityService.canRead(userID, annotationID)) { 241 241 final UserWithPermissionList permissionList = dbIntegrityService.getPermissionsForAnnotation(annotationID); 242 242 logger.debug("getAnnotationPermissions method: OK"); … … 276 276 if (userID != null) { 277 277 if (annotationID != null) { 278 if (userID.equals(dbIntegrityService.getAnnotationOwner(annotationID)) ) {278 if (userID.equals(dbIntegrityService.getAnnotationOwner(annotationID)) || dbIntegrityService.getTypeOfUserAccount(userID).equals(admin)) { 279 279 int[] resultDelete = dbIntegrityService.deleteAnnotation(annotationID); 280 280 String result = Integer.toString(resultDelete[0]); … … 348 348 Number userID = dbIntegrityService.getUserInternalIDFromRemoteID(remoteUser); 349 349 if (userID != null) { 350 if (userID.equals(dbIntegrityService.getAnnotationOwner(annotationID)) ) {350 if (userID.equals(dbIntegrityService.getAnnotationOwner(annotationID)) || dbIntegrityService.getTypeOfUserAccount(userID).equals(admin)) { 351 351 int updatedRows = dbIntegrityService.updateAnnotation(annotation); 352 352 return new ObjectFactory().createResponseBody(makeAnnotationResponseEnvelope(annotationID)); … … 387 387 if (userID != null) { 388 388 if (annotationID != null) { 389 if ( canWrite(userID, annotationID)) {389 if (dbIntegrityService.canWrite(userID, annotationID)) { 390 390 int updatedRows = dbIntegrityService.updateAnnotationBody(annotationID, annotationBody); 391 391 return new ObjectFactory().createResponseBody(makeAnnotationResponseEnvelope(annotationID)); … … 428 428 final Number annotationID = dbIntegrityService.getAnnotationInternalIdentifier(UUID.fromString(annotationExternalId)); 429 429 if (annotationID != null) { 430 if ( userID.equals(dbIntegrityService.getAnnotationOwner(annotationID))) {430 if (remoteUserID.equals(dbIntegrityService.getAnnotationOwner(annotationID)) || dbIntegrityService.getTypeOfUserAccount(remoteUserID).equals(admin)) { 431 431 int result = (dbIntegrityService.getPermission(annotationID, userID) != null) 432 432 ? dbIntegrityService.updateAnnotationPrincipalPermission(annotationID, userID, permission) … … 480 480 if (remoteUserID != null) { 481 481 if (annotationID != null) { 482 if (remoteUserID.equals(dbIntegrityService.getAnnotationOwner(annotationID)) ) {482 if (remoteUserID.equals(dbIntegrityService.getAnnotationOwner(annotationID)) || dbIntegrityService.getTypeOfUserAccount(remoteUserID).equals(admin)) { 483 483 int updatedRows = dbIntegrityService.updatePermissions(annotationID, permissions); 484 484 return new ObjectFactory().createResponseBody(makePermissionResponseEnvelope(annotationID)); … … 517 517 if (remoteUserID != null) { 518 518 if (annotationID != null) { 519 if (remoteUserID.equals(dbIntegrityService.getAnnotationOwner(annotationID)) ) {519 if (remoteUserID.equals(dbIntegrityService.getAnnotationOwner(annotationID)) || dbIntegrityService.getTypeOfUserAccount(remoteUserID).equals(admin)) { 520 520 Number userID = dbIntegrityService.getUserInternalIdentifier(UUID.fromString(userId)); 521 521 if (userID != null) { … … 596 596 } 597 597 598 private boolean canRead(Number userID, Number annotationID) {599 if (userID.equals(dbIntegrityService.getAnnotationOwner(annotationID))) {600 return true;601 }602 603 final Permission permission = dbIntegrityService.getPermission(annotationID, userID);604 if (permission != null) {605 return (permission.value().equals(Permission.WRITER.value()) || permission.value().equals(Permission.READER.value()));606 } else {607 return false;608 }609 }610 611 private boolean canWrite(Number userID, Number annotationID) {612 if (userID.equals(dbIntegrityService.getAnnotationOwner(annotationID))) {613 return true;614 }615 final Permission permission = dbIntegrityService.getPermission(annotationID, userID);616 if (permission != null) {617 return (permission.value().equals(Permission.WRITER.value()));618 } else {619 return false;620 }621 }622 623 private String[] makeAccessModeChain(String accessMode) {624 if (accessMode != null) {625 if (accessMode.equals(Permission.READER.value())) {626 String[] result = new String[1];627 result[0] = Permission.READER.value();628 return result;629 } else {630 if (accessMode.equals(Permission.WRITER.value())) {631 String[] result = new String[2];632 result[0] = Permission.READER.value();633 result[1] = Permission.WRITER.value();634 return result;635 } else {636 logger.error("Invalide access " + accessMode);637 return null;638 }639 640 }641 642 } else {643 return null;644 }645 }646 598 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/webapp/index.jsp
r4407 r4491 49 49 GET <a href="api/users/00000000-0000-0000-0000-0000000000112">api/users/00000000-0000-0000-0000-0000000000112</a> <br> 50 50 GET <a href="api/users/00000000-0000-0000-0000-0000000000112/current">api/users/00000000-0000-0000-0000-0000000000112/current</a> !Problem: how to ask the servlet if the given user is logged in, may be by some other running somewhere client<br> 51 GET <a href="api/users/info?email= twagoo@mpi.nl">api/users/info?email=twagoo@mpi.nl</a> <br>51 GET <a href="api/users/info?email=Twan.Goosen@mpi.nl">api/users/info?email=Twan.Goosen@mpi.nl</a> <br> 52 52 GET <a href="api/annotations?link=Sagrada">api/annotations/info?link=Sagrada</a> <br> 53 53 GET <a href="api/annotations?link=Gaud">api/annotations/info?link=Gaud</a> <br> 54 GET <a href="api/annotations?after=2014-0 1-28 15:57:58.046908&before=2014-01-30 10:08:16.213186">api/annotations?after=2014-01-28 15:57:58.046908&before=2014-01-3010:08:16.213186</a> <br>54 GET <a href="api/annotations?after=2014-02-04 15:57:58.046908&before=2014-02-06 10:08:16.213186">api/annotations?after=2014-02-04 15:57:58.046908&before=2014-02-06 10:08:16.213186</a> <br> 55 55 !Comment: What is "namespace" query parameter? Must be implemented and tested <br> 56 56 GET <a href="api/annotations/00000000-0000-0000-0000-000000000021">api/annotations/00000000-0000-0000-0000-000000000021</a> </br> -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/DBIntegrityServiceTest.java
r4464 r4491 278 278 final List<Number> mockAnnotationIDs1 = new ArrayList<Number>(); 279 279 mockAnnotationIDs1.add(1); 280 mockAnnotationIDs1.add(2);281 280 282 281 final List<Number> mockAnnotationIDs2 = new ArrayList<Number>(); … … 290 289 mockRetval.add(1); 291 290 292 final String[] accessModes = new String[2]; 293 accessModes[0] = "reader"; 294 accessModes[1] = "writer"; 295 291 296 292 mockeryDao.checking(new Expectations() { 297 293 { 298 294 oneOf(targetDao).getTargetsReferringTo("nl.wikipedia.org"); 299 295 will(returnValue(mockTargetIDs)); 300 301 oneOf(annotationDao).getAnnotationIDsForUserWithPermission(3, accessModes); 296 297 oneOf(annotationDao).getAnnotationIDsForTargets(mockTargetIDs); 298 will(returnValue(mockAnnotationIDs2)); 299 300 oneOf(annotationDao).getFilteredAnnotationIDs(null, "some html 1", null, after, before); 302 301 will(returnValue(mockAnnotationIDs1)); 303 302 304 305 oneOf(annotationDao).retrieveAnnotationList(mockTargetIDs); 306 will(returnValue(mockAnnotationIDs2)); 307 308 309 oneOf(annotationDao).getFilteredAnnotationIDs(mockAnnotationIDs1, null, "some html 1", null, after, before); 310 will(returnValue(mockRetval)); 311 312 } 313 }); 314 315 316 List result = dbIntegrityService.getFilteredAnnotationIDs(null, "nl.wikipedia.org", "some html 1", 3, accessModes, null, after, before); 303 oneOf(annotationDao).getAnnotationIDsForUserWithPermission(3, "reader"); 304 will(returnValue(mockAnnotationIDs1)); 305 306 307 308 } 309 }); 310 311 312 List result = dbIntegrityService.getFilteredAnnotationIDs(null, "nl.wikipedia.org", "some html 1", 3, "reader", null, after, before); 317 313 assertEquals(1, result.size()); 318 314 assertEquals(1, result.get(0)); … … 368 364 final List<Number> mockAnnotationIDs1 = new ArrayList<Number>(); 369 365 mockAnnotationIDs1.add(1); 370 mockAnnotationIDs1.add(2);371 366 372 367 final List<Number> mockAnnotationIDs2 = new ArrayList<Number>(); … … 391 386 targetIDs.add(2); 392 387 393 final String[] accessModes = new String[2]; 394 accessModes[0] = "reader"; 395 accessModes[1] = "writer"; 396 397 mockeryDao.checking(new Expectations() { 398 { 399 oneOf(userDao).getInternalID(ownerUUID); 400 will(returnValue(1)); 401 402 oneOf(annotationDao).getAnnotationIDsForUserWithPermission(3, accessModes); 403 will(returnValue(mockAnnotationIDs1)); 404 405 // getFilteredAnnotationIds 388 389 390 mockeryDao.checking(new Expectations() { 391 { 392 oneOf(userDao).getInternalID(ownerUUID); 393 will(returnValue(1)); 394 406 395 oneOf(targetDao).getTargetsReferringTo("nl.wikipedia.org"); 407 396 will(returnValue(mockTargetIDs)); 408 397 409 oneOf(annotationDao). retrieveAnnotationList(mockTargetIDs);410 will(returnValue(mockAnnotationIDs2)); 398 oneOf(annotationDao).getAnnotationIDsForTargets(mockTargetIDs); 399 will(returnValue(mockAnnotationIDs2)); 411 400 401 oneOf(annotationDao).getFilteredAnnotationIDs(1, "some html 1", null, after, before); 402 will(returnValue(mockAnnotationIDs1)); 403 404 oneOf(annotationDao).getAnnotationIDsForUserWithPermission(3, "reader"); 405 will(returnValue(mockAnnotationIDs1)); 406 412 407 413 oneOf(annotationDao).getFilteredAnnotationIDs(mockAnnotationIDs1, 1, "some html 1", null, after, before);414 will(returnValue(mockAnnotIDs));415 416 417 408 // /////////////////////////////////// 418 409 // … … 442 433 443 434 444 AnnotationInfoList result = dbIntegrityService.getFilteredAnnotationInfos(ownerUUID, "nl.wikipedia.org", "some html 1", 3, accessModes, null, after, before);435 AnnotationInfoList result = dbIntegrityService.getFilteredAnnotationInfos(ownerUUID, "nl.wikipedia.org", "some html 1", 3, "reader", null, after, before); 445 436 assertEquals(1, result.getAnnotationInfo().size()); 446 437 AnnotationInfo resultAnnotInfo = result.getAnnotationInfo().get(0); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcAnnotationDaoTest.java
r4461 r4491 297 297 targets.add(1); 298 298 targets.add(2); 299 List<Number> result = jdbcAnnotationDao. retrieveAnnotationList(targets);299 List<Number> result = jdbcAnnotationDao.getAnnotationIDsForTargets(targets); 300 300 assertEquals (2, result.size()); 301 301 assertEquals(1, result.get(0)); … … 326 326 public void testGetFilteredAnnotationIDs(){ 327 327 System.out.println(" test getFilteredAnnotationIDs"); 328 329 330 ////////////////////////////////////////// 331 // TEST 1 332 //final String link = "nl.wikipedia.org"; 333 final List<Number> annotationIDs = new ArrayList<Number>(); 334 annotationIDs.add(1); 335 annotationIDs.add(2); 336 337 List<Number> result_1 = jdbcAnnotationDao.getFilteredAnnotationIDs(annotationIDs, null, null, null, null, null); 338 assertEquals(2, result_1.size()); 328 329 List<Number> result_1 = jdbcAnnotationDao.getFilteredAnnotationIDs(null, "some html", null, null, null); 330 assertEquals(3, result_1.size()); 339 331 assertEquals(1, result_1.get(0)); 340 332 assertEquals(2, result_1.get(1)); 341 342 343 List<Number> result_2 = jdbcAnnotationDao.getFilteredAnnotationIDs(annotationIDs, null, "some html", null, null, null); 344 assertEquals(2, result_2.size()); 345 assertEquals(1, result_2.get(0)); 346 assertEquals(2, result_2.get(1)); 347 333 assertEquals(4, result_1.get(2)); 348 334 349 335 … … 351 337 final String before = (new Timestamp(System.currentTimeMillis())).toString(); 352 338 353 List<Number> result_ 4 = jdbcAnnotationDao.getFilteredAnnotationIDs(annotationIDs,1, "some html", null, after, before);354 assertEquals(1, result_ 4.size());355 assertEquals(1, result_ 4.get(0));339 List<Number> result_2 = jdbcAnnotationDao.getFilteredAnnotationIDs(1, "some html", null, after, before); 340 assertEquals(1, result_2.size()); 341 assertEquals(1, result_2.get(0)); 356 342 357 343 final String after_1 = (new Timestamp(System.currentTimeMillis())).toString();// no annotations added after "now" 358 List<Number> result_ 5 = jdbcAnnotationDao.getFilteredAnnotationIDs(annotationIDs,4, "some html", null, after_1, null);359 assertEquals(0, result_ 5.size());344 List<Number> result_3 = jdbcAnnotationDao.getFilteredAnnotationIDs(4, "some html", null, after_1, null); 345 assertEquals(0, result_3.size()); 360 346 361 347 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationResourceTest.java
r4461 r4491 110 110 will(returnValue(3)); 111 111 112 oneOf(mockDbIntegrityService).canRead(3, 2); 113 will(returnValue(true)); 114 112 115 oneOf(mockDbIntegrityService).getAnnotationInternalIdentifier(with(any(UUID.class))); 113 116 will(returnValue(2)); 114 115 oneOf(mockDbIntegrityService).getTypeOfUserAccount(3);116 will(returnValue("developer"));117 118 oneOf(mockDbIntegrityService).getAnnotationOwner(2);119 will(returnValue(3));120 117 121 118 oneOf(mockDbIntegrityService).getAnnotation(2);
Note: See TracChangeset
for help on using the changeset viewer.