Changeset 7724
- Timestamp:
- 06/05/09 18:03:39 (14 months ago)
- Location:
- head/ambra/webapp/src
- Files:
-
- 4 modified
- 4 moved
-
main/java/org/topazproject/ambra/admin/action/ManageAnnotationAction.java (moved) (moved from head/ambra/webapp/src/main/java/org/topazproject/ambra/admin/action/EditOneAnnotationAction.java) (11 diffs)
-
main/java/org/topazproject/ambra/admin/action/ManageFlagsAction.java (moved) (moved from head/ambra/webapp/src/main/java/org/topazproject/ambra/admin/action/EditAnnotationAction.java) (1 diff)
-
main/java/org/topazproject/ambra/annotation/service/AnnotationService.java (modified) (4 diffs)
-
main/resources/struts.xml (modified) (2 diffs)
-
main/webapp/admin/manageAnnotation.ftl (moved) (moved from head/ambra/webapp/src/main/webapp/admin/editOneAnnotation.ftl) (3 diffs)
-
main/webapp/admin/manageFlags.ftl (moved) (moved from head/ambra/webapp/src/main/webapp/admin/editAnnotation.ftl) (2 diffs)
-
main/webapp/admin/templates/standardHeader.ftl (modified) (2 diffs)
-
test/java/org/topazproject/ambra/admin/action/ProcessFlagsActionTest.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
head/ambra/webapp/src/main/java/org/topazproject/ambra/admin/action/ManageAnnotationAction.java
r7716 r7724 27 27 import org.topazproject.ambra.annotation.service.WebAnnotation; 28 28 import org.topazproject.ambra.models.ArticleAnnotation; 29 import org.topazproject.ambra.models.UserProfile; 30 import org.topazproject.ambra.admin.service.CitationService; 29 31 import org.apache.commons.logging.Log; 30 32 import org.apache.commons.logging.LogFactory; … … 32 34 33 35 @SuppressWarnings("serial") 34 public class EditOneAnnotationAction extends BaseAdminActionSupport {35 private static final Log log = LogFactory.getLog( EditOneAnnotationAction.class);36 37 private String annotationId;36 public class ManageAnnotationAction extends BaseAdminActionSupport { 37 private static final Log log = LogFactory.getLog(ManageAnnotationAction.class); 38 39 private String annotationId; 38 40 private WebAnnotation annotation; 39 private String saveAnnotationContext; 41 private String annotationBody; 42 private String annotationContext; 43 private String citationId; 44 private String citationDisplayYear; 45 private String citationVolumeNumber; 46 private String citationIssue; 47 private String citationTitle; 48 private String citationELocationId; 49 private String citationJournal; 50 private String citationDoi; 51 private String[] citationAuthorIds; 52 private String[] citationAuthorGivenNames; 53 private String[] citationAuthorSurnames; 54 private String[] citationAuthorSuffixes; 55 private int citationAuthorDeleteIndex; 56 private String[] citationCollaborativeAuthorNames; 57 private int citationCollaborativeAuthorDeleteIndex; 58 40 59 private AnnotationService annotationService; 41 60 private AnnotationConverter annotationConverter; 61 private CitationService citationService; 42 62 43 63 @Override … … 49 69 50 70 /** 51 * Struts Action to load (query from the database) an Annotation. 71 * Struts Action to load (query from the database) an Annotation and its Citation, 72 * if a Citation exists. 52 73 * 53 74 * @return the struts status … … 63 84 ArticleAnnotation a = annotationService.getArticleAnnotation(annotationId); 64 85 annotation = annotationConverter.convert(a, true, true); 86 if (annotationId == null) 87 annotationId = annotation.getId(); 88 if (annotationBody == null) 89 annotationBody = annotation.getEscapedComment(); 90 if (annotationContext == null) 91 annotationContext = annotation.getContext(); 92 if (annotation.getCitation() != null) { 93 if (citationId == null && annotation.getCitation().getId() != null) 94 citationId = annotation.getCitation().getId().toString(); 95 if (citationDisplayYear == null) 96 citationDisplayYear = annotation.getCitation().getDisplayYear(); 97 if (citationVolumeNumber == null) { 98 if (annotation.getCitation().getVolumeNumber() != null) 99 citationVolumeNumber = annotation.getCitation().getVolumeNumber().toString(); 100 if (citationVolumeNumber == null || citationVolumeNumber.trim().length() < 1) 101 citationVolumeNumber = annotation.getCitation().getVolume(); 102 } 103 if (citationIssue == null) 104 citationIssue = annotation.getCitation().getIssue(); 105 if (citationTitle == null) 106 citationTitle = annotation.getCitation().getTitle(); 107 if (citationELocationId == null) 108 citationELocationId = annotation.getCitation().getELocationId(); 109 if (citationJournal == null) 110 citationJournal = annotation.getCitation().getJournal(); 111 if (citationDoi == null) 112 citationDoi = annotation.getCitation().getDoi(); 113 114 if (annotation.getCitation().getAuthors() != null 115 && annotation.getCitation().getAuthors().size() > 0) { 116 citationAuthorIds = new String[annotation.getCitation().getAuthors().size()]; 117 citationAuthorGivenNames = new String[annotation.getCitation().getAuthors().size()]; 118 citationAuthorSurnames = new String[annotation.getCitation().getAuthors().size()]; 119 citationAuthorSuffixes = new String[annotation.getCitation().getAuthors().size()]; 120 int authorIndex = 0; 121 for (UserProfile author : annotation.getCitation().getAuthors()) { 122 if (author.getId() != null) { 123 citationAuthorIds[authorIndex] = author.getId().toString(); 124 citationAuthorGivenNames[authorIndex] = author.getGivenNames(); 125 citationAuthorSurnames[authorIndex] = author.getSurnames(); 126 citationAuthorSuffixes[authorIndex] = author.getSuffix(); 127 authorIndex++; 128 } 129 } 130 } 131 if (annotation.getCitation().getCollaborativeAuthors() != null 132 && annotation.getCitation().getCollaborativeAuthors().size() > 0) { 133 citationCollaborativeAuthorNames 134 = new String[annotation.getCitation().getCollaborativeAuthors().size()]; 135 int authorIndex = 0; 136 for (String author : annotation.getCitation().getCollaborativeAuthors()) { 137 citationCollaborativeAuthorNames[authorIndex] = author; 138 authorIndex++; 139 } 140 } 141 } 142 65 143 } catch (IllegalArgumentException iae) { 66 144 addActionError("There is no Annotation with the ID: " + annotationId); … … 72 150 73 151 /** 74 * Struts Action to save an Annotation .152 * Struts Action to save an Annotation and its Citation (if the Annotation has a Citation). 75 153 * 76 154 * @return the struts status … … 79 157 @Transactional(rollbackFor = { Throwable.class }) 80 158 public String saveAnnotation() throws Exception { 81 annotationService.updateContext(annotationId, saveAnnotationContext); 82 addActionMessage("Annotation: " + annotationId + ", Updated Context: " + saveAnnotationContext); 159 annotationService.updateBodyAndContext(annotationId, annotationBody, annotationContext); 160 addActionMessage("Annotation Context is now: " + annotationContext); 161 addActionMessage("Annotation Body is now: " + annotationBody); 162 163 // If there is a Citation, update its information. 164 if (citationId != null && citationId.trim().length() > 0) { 165 citationService.updateCitation(citationId, citationTitle, citationDisplayYear, 166 citationJournal, citationVolumeNumber, citationIssue, citationELocationId, citationDoi); 167 if (citationDisplayYear != null) 168 addActionMessage("Citation Display Year is now: " + citationDisplayYear); 169 if (citationVolumeNumber != null) 170 addActionMessage("Citation Volume Number is now: " + citationVolumeNumber); 171 if (citationIssue != null) 172 addActionMessage("Citation Issue is now: " + citationIssue); 173 if (citationTitle != null) 174 addActionMessage("Citation Title is now: " + citationTitle); 175 if (citationELocationId != null) 176 addActionMessage("Citation eLocationId is now: " + citationELocationId); 177 if (citationJournal != null) 178 addActionMessage("Citation Journal is now: " + citationJournal); 179 if (citationDoi != null) 180 addActionMessage("Citation DOI is now: " + citationDoi); 181 182 // Update all existing Citation Authors. 183 if (citationAuthorSurnames.length > 1) { 184 for (int i=0; i < citationAuthorSurnames.length - 1; i++) { 185 citationService.updateAuthor(citationAuthorIds[i].trim(), citationAuthorSurnames[i].trim(), 186 citationAuthorGivenNames[i].trim(), citationAuthorSuffixes[i].trim()); 187 if (i != citationAuthorDeleteIndex) { // No "updated" message for deleted user. 188 addActionMessage("Updated citation author: " + citationAuthorGivenNames[i].trim() + " " 189 + citationAuthorSurnames[i].trim() + " " + citationAuthorSuffixes[i].trim()); 190 } 191 } 192 } 193 194 // Delete a Citation Author if a "Delete Author" link has been clicked. 195 if (citationAuthorDeleteIndex > -1) { 196 citationService.deleteAuthor(citationId, citationAuthorIds[citationAuthorDeleteIndex]); 197 addActionMessage("Deleted citation author: " 198 + citationAuthorGivenNames[citationAuthorDeleteIndex].trim()+ " " 199 + citationAuthorSurnames[citationAuthorDeleteIndex].trim() + " " 200 + citationAuthorSuffixes[citationAuthorDeleteIndex].trim()); 201 } 202 203 // Add a new Citation Author, if one exists. 204 if (citationAuthorGivenNames[citationAuthorSurnames.length - 1].trim().length() > 0 205 || citationAuthorSurnames[citationAuthorSurnames.length - 1].trim().length() > 0) { 206 citationService.addAuthor(citationId, 207 citationAuthorSurnames[citationAuthorSurnames.length - 1].trim(), 208 citationAuthorGivenNames[citationAuthorSurnames.length - 1].trim(), 209 citationAuthorSuffixes[citationAuthorSurnames.length - 1].trim()); 210 addActionMessage("Added citation author: " 211 + citationAuthorGivenNames[citationAuthorSurnames.length - 1].trim() + " " 212 + citationAuthorSurnames[citationAuthorSurnames.length - 1].trim() + " " 213 + citationAuthorSuffixes[citationAuthorSurnames.length - 1].trim()); 214 } 215 citationAuthorIds = null; 216 citationAuthorGivenNames = null; 217 citationAuthorSurnames = null; 218 citationAuthorSuffixes = null; 219 220 221 // Update all existing Collaborative Authors. 222 if (citationCollaborativeAuthorNames.length > 0) { 223 for (int i=0; i < citationCollaborativeAuthorNames.length - 1; i++) { 224 citationService.updateCollaborativeAuthor( 225 citationId, i, citationCollaborativeAuthorNames[i].trim()); 226 if (i != citationCollaborativeAuthorDeleteIndex) { // No "updated" message for deleted user. 227 addActionMessage("Updated collaborative author: " 228 + citationCollaborativeAuthorNames[i].trim()); 229 } 230 } 231 } 232 233 // Delete a Collaborative Author if a "Delete Collaborative Author" link has been clicked. 234 if (citationCollaborativeAuthorDeleteIndex > -1) { 235 citationService.deleteCollaborativeAuthor( 236 citationId, citationCollaborativeAuthorDeleteIndex); 237 addActionMessage("Deleted collaborative author: " 238 + citationCollaborativeAuthorNames[citationCollaborativeAuthorDeleteIndex].trim()); 239 } 240 241 // Add a new Collaborative Author, if one exists. 242 if (citationCollaborativeAuthorNames[citationCollaborativeAuthorNames.length - 1].trim() 243 .length() > 0) { 244 citationService.addCollaborativeAuthor(citationId, 245 citationCollaborativeAuthorNames[citationCollaborativeAuthorNames.length - 1].trim()); 246 addActionMessage("Added collaborative author: " 247 + citationCollaborativeAuthorNames[citationCollaborativeAuthorNames.length - 1].trim()); 248 } 249 citationCollaborativeAuthorNames = null; 250 } // End if citation exists. 251 83 252 return loadAnnotation(); // returns SUCCESS if the Annotation query succeeded. 84 253 } 85 254 255 /** 256 * Perform basic action necessary for the querying and display of data through this Action class. 257 * @return Always return false. 258 */ 86 259 private boolean setCommonFields() { 87 260 initJournal(); // create a faux journal object for template … … 90 263 91 264 265 /** 266 * Get the Annotation that is to be edited. 267 * @return the Annotation that is to be edited 268 */ 92 269 public WebAnnotation getAnnotation() { 93 270 return annotation; … … 101 278 return annotationId; 102 279 } 103 104 280 /** 105 281 * Set the Annotation ID. … … 111 287 112 288 /** 289 * Get the body of the Annotation. 290 * @return The annotation body 291 */ 292 public String getAnnotationBody() { 293 return annotationBody; 294 } 295 /** 296 * Set the body of this Annotation. 297 * @param annotationBody The body of this Annotation 298 */ 299 public void setAnnotationBody(String annotationBody) { 300 this.annotationBody = annotationBody; 301 } 302 303 /** 113 304 * Get Annotation Context, meaning the x-pointer location of this Annotation inside its Article. 114 305 * @return The annotation context, the x-pointer location of this Annotation inside its Article 115 306 */ 116 307 public String getAnnotationContext() { 117 return saveAnnotationContext; 118 } 119 308 return annotationContext; 309 } 120 310 /** 121 311 * Set the Annotation Context, the x-pointer location of this Annotation inside its Article. … … 123 313 */ 124 314 public void setAnnotationContext(String annotationContext) { 125 this.saveAnnotationContext = annotationContext; 315 this.annotationContext = annotationContext; 316 } 317 318 /** 319 * Get Citation Id. 320 * @return the ID of this Citation 321 */ 322 public String getCitationId() { 323 return citationId; 324 } 325 /** 326 * Set the Citation ID. 327 * @param citationId the ID of this Citation 328 */ 329 public void setCitationId(String citationId) { 330 this.citationId = citationId; 331 } 332 333 /** 334 * Get the Display Year of this Annotation Citation. 335 * @return The Display Year of this Annotation Citation 336 */ 337 public String getCitationDisplayYear() { 338 return citationDisplayYear; 339 } 340 /** 341 * Set the Display Year of this Annotation Citation. 342 * @param citationDisplayYear The Display Year of this Annotation Citation 343 */ 344 public void setCitationDisplayYear(String citationDisplayYear) { 345 this.citationDisplayYear = citationDisplayYear; 346 } 347 348 /** 349 * Get the Volume Number of the Article to which this Annotation Citation is relevant. 350 * @return The Volume Number of the Article to which this Annotation Citation is relevant 351 */ 352 public String getCitationVolumeNumber() { 353 return citationVolumeNumber; 354 } 355 /** 356 * Set the Volume Number of the Article to which this Annotation Citation is relevant. 357 * @param citationVolumeNumber The Volume Number of the Article to 358 * which this Annotation Citation is relevant 359 */ 360 public void setCitationVolumeNumber(String citationVolumeNumber) { 361 this.citationVolumeNumber = citationVolumeNumber; 362 } 363 364 /** 365 * Get the Issue of the Article to which this Annotation Citation is relevant. 366 * @return The Issue of the Article to which this Annotation Citation is relevant 367 */ 368 public String getCitationIssue() { 369 return citationIssue; 370 } 371 /** 372 * Set the Issue of the Article to which this Annotation Citation is relevant. 373 * @param citationIssue The Issue of the Article to 374 * which this Annotation Citation is relevant 375 */ 376 public void setCitationIssue(String citationIssue) { 377 this.citationIssue = citationIssue; 378 } 379 380 /** 381 * Get the Title of this Annotation Citation. 382 * @return The Title of this Annotation Citation 383 */ 384 public String getCitationTitle() { 385 return citationTitle; 386 } 387 /** 388 * Set the Title of this Annotation Citation. 389 * @param citationTitle The Title of this Annotation Citation 390 */ 391 public void setCitationTitle(String citationTitle) { 392 this.citationTitle = citationTitle; 393 } 394 395 /** 396 * Get the eLocationId for this Annotation Citation. 397 * @return The eLocationId for this Annotation Citation 398 */ 399 public String getCitationELocationId() { 400 return citationELocationId; 401 } 402 /** 403 * Set the eLocationId for this Annotation Citation. 404 * @param citationELocationId The eLocationId for this Annotation Citation 405 */ 406 public void setCitationELocationId(String citationELocationId) { 407 this.citationELocationId = citationELocationId; 408 } 409 410 /** 411 * Get the Journal of the Article to which this Annotation Citation is relevant. 412 * @return The Journal of the Article to which this Annotation Citation is relevant 413 */ 414 public String getCitationJournal() { 415 return citationJournal; 416 } 417 /** 418 * Set the Journal of the Article to which this Annotation Citation is relevant. 419 * @param citationJournal The Journal of the Article to 420 * which this Annotation Citation is relevant 421 */ 422 public void setCitationJournal(String citationJournal) { 423 this.citationJournal = citationJournal; 424 } 425 426 /** 427 * Get the DOI of this Annotation Citation. 428 * @return The DOI of this Annotation Citation 429 */ 430 public String getCitationDoi() { 431 return citationDoi; 432 } 433 /** 434 * Set the DOI of this Annotation Citation. 435 * @param citationDoi The DOI of this Annotation Citation 436 */ 437 public void setCitationDoi(String citationDoi) { 438 this.citationDoi = citationDoi; 439 } 440 441 /** 442 * Get all of the IDs for the Authors of this Citation. 443 * @return the IDs for the Authors of this Citation 444 */ 445 public String[] getCitationAuthorIds() { 446 return citationAuthorIds; 447 } 448 /** 449 * Set all of the IDs for the Authors of this Citation. 450 * @param citationAuthorIds the IDs for the Authors of this Citation 451 */ 452 public void setCitationAuthorIds(String[] citationAuthorIds) { 453 this.citationAuthorIds = citationAuthorIds; 454 } 455 456 /** 457 * Get all of the Given Names for the Authors of this Citation. 458 * @return the Given Names for the Authors of this Citation 459 */ 460 public String[] getCitationAuthorGivenNames() { 461 return citationAuthorGivenNames; 462 } 463 /** 464 * Set all of the Given Names for the Authors of this Citation. 465 * @param citationAuthorGivenNames the Given Names for the Authors of this Citation 466 */ 467 public void setCitationAuthorGivenNames(String[] citationAuthorGivenNames) { 468 this.citationAuthorGivenNames = citationAuthorGivenNames; 469 } 470 471 /** 472 * Get all of the Surnames for the Authors of this Citation. 473 * @return the Surnames for the Authors of this Citation 474 */ 475 public String[] getCitationAuthorSurnames() { 476 return citationAuthorSurnames; 477 } 478 /** 479 * Set all of the Surnames for the Authors of this Citation. 480 * @param citationAuthorSurnames the Surnames for the Authors of this Citation 481 */ 482 public void setCitationAuthorSurnames(String[] citationAuthorSurnames) { 483 this.citationAuthorSurnames = citationAuthorSurnames; 484 } 485 486 /** 487 * Get all of the name Suffixes for the Authors of this Citation. 488 * @return the name Suffixes for the Authors of this Citation 489 */ 490 public String[] getCitationAuthorSuffixes() { 491 return citationAuthorSuffixes; 492 } 493 /** 494 * Set all of the name Suffixes for the Authors of this Citation. 495 * @param citationAuthorSuffixes the name Suffixes for the Authors of this Citation 496 */ 497 public void setCitationAuthorSuffixes(String[] citationAuthorSuffixes) { 498 this.citationAuthorSuffixes = citationAuthorSuffixes; 499 } 500 501 /** 502 * Get the Index of the Citation Author which is to be deleted from this Citation. 503 * @return The Index of the Citation Author to be deleted 504 */ 505 public int getCitationAuthorDeleteIndex() { 506 return citationAuthorDeleteIndex; 507 } 508 /** 509 * Set the Index of the Citation Author which is to be deleted from this Citation. 510 * @param citationAuthorDeleteIndex The Index of the Citation Author to be deleted 511 */ 512 public void setCitationAuthorDeleteIndex(int citationAuthorDeleteIndex) { 513 this.citationAuthorDeleteIndex = citationAuthorDeleteIndex; 514 } 515 516 /** 517 * Get all of the Names for the Collaborative Authors for this Citation. 518 * @return the Names for the Collaborative Authors for this Citation 519 */ 520 public String[] getCitationCollaborativeAuthorNames() { 521 return citationCollaborativeAuthorNames; 522 } 523 /** 524 * Set all of the Names for the Collaborative Authors for this Citation. 525 * @param citationCollaborativeAuthorNames Names for the Collaborative Authors for this Citation 526 */ 527 public void setCitationCollaborativeAuthorNames(String[] citationCollaborativeAuthorNames) { 528 this.citationCollaborativeAuthorNames = citationCollaborativeAuthorNames; 529 } 530 531 /** 532 * Get the Index of the Collaborative Author which is to be deleted from this Citation. 533 * @return The Index of the Collaborative Author to be deleted 534 */ 535 public int getCitationCollaborativeAuthorDeleteIndex() { 536 return citationCollaborativeAuthorDeleteIndex; 537 } 538 /** 539 * Set the Index of the Collaborative Author which is to be deleted from this Citation. 540 * @param citationCollaborativeAuthorDeleteIndex Index of the Collaborative Author to be deleted 541 */ 542 public void setCitationCollaborativeAuthorDeleteIndex(int citationCollaborativeAuthorDeleteIndex){ 543 this.citationCollaborativeAuthorDeleteIndex = citationCollaborativeAuthorDeleteIndex; 126 544 } 127 545 … … 139 557 this.annotationConverter = converter; 140 558 } 559 560 /** 561 * Set CitationService. 562 * @param citationService the citation service to set 563 */ 564 public void setCitationService(CitationService citationService) { 565 this.citationService = citationService; 566 } 567 141 568 } -
head/ambra/webapp/src/main/java/org/topazproject/ambra/admin/action/ManageFlagsAction.java
r7716 r7724 44 44 45 45 @SuppressWarnings("serial") 46 public class EditAnnotationAction extends BaseAdminActionSupport {47 private static final Log log = LogFactory.getLog( EditAnnotationAction.class);46 public class ManageFlagsAction extends BaseAdminActionSupport { 47 private static final Log log = LogFactory.getLog(ManageFlagsAction.class); 48 48 49 49 private FlagManagementService flagManagementService; -
head/ambra/webapp/src/main/java/org/topazproject/ambra/annotation/service/AnnotationService.java
r7701 r7724 27 27 import java.util.List; 28 28 import java.util.Set; 29 import java.io.UnsupportedEncodingException; 29 30 30 31 import org.apache.commons.beanutils.BeanUtilsBean; … … 53 54 import org.topazproject.ambra.models.Citation; 54 55 import org.topazproject.ambra.models.UserProfile; 56 import org.topazproject.ambra.models.RatingContent; 55 57 import org.topazproject.ambra.user.AmbraUser; 56 58 import org.topazproject.ambra.xacml.AbstractSimplePEP; … … 615 617 } 616 618 617 618 /** 619 * Set the annotation context. 619 /** 620 * Update the annotation body and context. 620 621 * 621 622 * @param id the annotation id 623 * @param body 622 624 * @param context the context to set 623 *624 625 * @throws OtmException on an error 625 626 * @throws SecurityException if a security policy prevented this operation … … 627 628 */ 628 629 @Transactional(rollbackFor = { Throwable.class }) 629 public void update Context(String id, String context)630 throws OtmException, SecurityException, IllegalArgumentException {630 public void updateBodyAndContext(String id, String body, String context) 631 throws OtmException, SecurityException, IllegalArgumentException, UnsupportedEncodingException { 631 632 632 633 pep.checkAccess(AnnotationsPEP.UPDATE_ANNOTATION, URI.create(id)); 633 634 634 A nnotation<?> a = session.get(Annotation.class, id);635 ArticleAnnotation a = session.get(ArticleAnnotation.class, id); 635 636 if (a == null) 636 throw new IllegalArgumentException("invalid annoation id: " + id); 637 637 throw new IllegalArgumentException("invalid annotation id: " + id); 638 639 AnnotationBlob blob = a.getBody(); 640 blob.setBody(body.getBytes(getEncodingCharset())); 638 641 a.setContext(context); 639 642 } -
head/ambra/webapp/src/main/resources/struts.xml
r7716 r7724 881 881 882 882 <!-- Navigate to the Manage Flags page without doing any processing of those flags --> 883 <action name=" editAnnotation" class="org.topazproject.ambra.admin.action.EditAnnotationAction">884 <result name="success" type="ambraFreemarker"> 885 <param name="location">/admin/ editAnnotation.ftl</param>886 </result> 887 <!-- stay in editAnnotationeven on error -->888 <result name="error" type="ambraFreemarker"> 889 <param name="location">/admin/ editAnnotation.ftl</param>883 <action name="manageFlags" class="org.topazproject.ambra.admin.action.ManageFlagsAction"> 884 <result name="success" type="ambraFreemarker"> 885 <param name="location">/admin/manageFlags.ftl</param> 886 </result> 887 <!-- stay in manageFlags even on error --> 888 <result name="error" type="ambraFreemarker"> 889 <param name="location">/admin/manageFlags.ftl</param> 890 890 </result> 891 891 </action> 892 892 893 893 <!-- Process the changes made to the flags on the Manage Flags page --> 894 <action name="processFlags" class="org.topazproject.ambra.admin.action. EditAnnotationAction" method="processFlags">895 <result name="success" type="ambraFreemarker"> 896 <param name="location">/admin/ editAnnotation.ftl</param>897 <param name="noCache">true</param> 898 </result> 899 <!-- stay in editAnnotationeven on error -->900 <result name="error" type="ambraFreemarker"> 901 <param name="location">/admin/ editAnnotation.ftl</param>894 <action name="processFlags" class="org.topazproject.ambra.admin.action.ManageFlagsAction" method="processFlags"> 895 <result name="success" type="ambraFreemarker"> 896 <param name="location">/admin/manageFlags.ftl</param> 897 <param name="noCache">true</param> 898 </result> 899 <!-- stay in manageFlags even on error --> 900 <result name="error" type="ambraFreemarker"> 901 <param name="location">/admin/manageFlags.ftl</param> 902 902 <param name="noCache">true</param> 903 903 </result> … … 905 905 906 906 <!-- Navigate to the Manage Annotation page without querying or showing an Annotation --> 907 <action name=" editOneAnnotation" class="org.topazproject.ambra.admin.action.EditOneAnnotationAction">908 <result name="success" type="ambraFreemarker"> 909 <param name="location">/admin/ editOneAnnotation.ftl</param>910 </result> 911 <!-- stay in editOneAnnotation even on error -->912 <result name="error" type="ambraFreemarker"> 913 <param name="location">/admin/ editOneAnnotation.ftl</param>907 <action name="manageAnnotation" class="org.topazproject.ambra.admin.action.ManageAnnotationAction"> 908 <result name="success" type="ambraFreemarker"> 909 <param name="location">/admin/manageAnnotation.ftl</param> 910 </result> 911 <!-- stay in manageAnnotation even on error --> 912 <result name="error" type="ambraFreemarker"> 913 <param name="location">/admin/manageAnnotation.ftl</param> 914 914 </result> 915 915 </action> 916 916 917 917 <!-- Navigate to the Manage Annotation page and query/show the Annotation indicated by annotationId --> 918 <action name=" editOneAnnotationLoad" class="org.topazproject.ambra.admin.action.EditOneAnnotationAction"918 <action name="manageAnnotationLoad" class="org.topazproject.ambra.admin.action.ManageAnnotationAction" 919 919 method="loadAnnotation"> 920 920 <result name="success" type="ambraFreemarker"> 921 <param name="location">/admin/editOneAnnotation.ftl</param> 922 </result> 923 <result name="error" type="ambraFreemarker"> 924 <param name="location">/admin/editOneAnnotation.ftl</param> 925 </result> 926 </action> 927 928 <action name="editOneAnnotationSave" class="org.topazproject.ambra.admin.action.EditOneAnnotationAction" 921 <param name="location">/admin/manageAnnotation.ftl</param> 922 </result> 923 <!-- stay in manageAnnotation even on error --> 924 <result name="error" type="ambraFreemarker"> 925 <param name="location">/admin/manageAnnotation.ftl</param> 926 </result> 927 </action> 928 929 <action name="manageAnnotationSave" class="org.topazproject.ambra.admin.action.ManageAnnotationAction" 929 930 method="saveAnnotation"> 930 931 <result name="success" type="ambraFreemarker"> 931 <param name="location">/admin/ editOneAnnotation.ftl</param>932 </result> 933 <!-- stay in editOneAnnotation even on error -->934 <result name="error" type="ambraFreemarker"> 935 <param name="location">/admin/ editOneAnnotation.ftl</param>932 <param name="location">/admin/manageAnnotation.ftl</param> 933 </result> 934 <!-- stay in manageAnnotation even on error --> 935 <result name="error" type="ambraFreemarker"> 936 <param name="location">/admin/manageAnnotation.ftl</param> 936 937 </result> 937 938 </action> -
head/ambra/webapp/src/main/webapp/admin/manageAnnotation.ftl
r7716 r7724 21 21 <head> 22 22 <title>Ambra: Administration: Edit Annotation</title> 23 24 <script type="text/javascript"> 25 function confirmToDeleteAuthor(authorIndex) { 26 if (confirm('Are you sure you want to delete this author?')) { 27 document.manageAnnotationSave.citationAuthorDeleteIndex.value = authorIndex; 28 document.manageAnnotationSave.submit(); 29 } 30 } 31 function confirmToDeleteCollaborativeAuthor(authorIndex) { 32 if (confirm('Are you sure you want to delete this collaborative author?')) { 33 document.manageAnnotationSave.citationCollaborativeAuthorDeleteIndex.value = authorIndex; 34 document.manageAnnotationSave.submit(); 35 } 36 } 37 </script> 38 23 39 </head> 24 40 <body> … … 30 46 <fieldset> 31 47 <legend><b>Load Annotation</b></legend> 32 <@s.form name=" editOneAnnotationLoad" action="editOneAnnotationLoad" namespace="/admin" method="post">48 <@s.form name="manageAnnotationLoad" action="manageAnnotationLoad" namespace="/admin" method="post"> 33 49 <table> 34 <#if annotation??> 35 <tr><td><b>Annotation ID</b></td><td><@s.textfield name="annotationId" value="${annotation.id}" required="true" size="60"/></td></tr> 36 <#else> 37 <tr><td><b>Annotation ID</b></td><td><@s.textfield name="annotationId" value="" size="60"/></td></tr> 38 </#if> 50 <tr><td><b>Annotation ID</b></td><td><@s.textfield name="annotationId" value="${annotationId!}" size="60"/></td></tr> 39 51 <tr><td colspan="2"><@s.submit value="Load Annotation" /></td></tr> 40 52 </table> … … 44 56 45 57 <#if annotation??> 46 <@s.form name=" editOneAnnotationSave" action="editOneAnnotationSave" namespace="/admin" method="post">47 58 <@s.form name="manageAnnotationSave" action="manageAnnotationSave" namespace="/admin" method="post"> 59 48 60 <fieldset> 49 61 <legend><b>Annotation Details</b></legend> 50 <@s.hidden name="annotationId" label=" Id" required="true" value="${annotation.id}"/>62 <@s.hidden name="annotationId" label="hiddenAnnotationId" required="true" value="${annotationId!}"/> 51 63 <table> 52 64 <tr><td><b>Title</b></td> 53 65 <td>${annotation.title!"No Title for this Annotation"}</td></tr> 54 <tr><td><b>Content</b></td> 55 <td>${annotation.escapedComment!"No Content for this Annotation"}</td></tr> 66 <tr><td valign="top"><b>Body</b></td> 67 <td><@s.textarea name="annotationBody" value="${annotationBody!}" rows="9" cols="100"/></td></tr> 68 <tr><td><b>Context</b></td> 69 <td><@s.textarea name="annotationContext" value="${annotationContext!}" rows="3" cols="100"/></td></tr> 56 70 <tr><td><b>Id</b></td> 57 <td><a href="${freemarker_config.context}/annotation/listThread.action?inReplyTo=${annotation .id}&root=${annotation.id}">${annotation.id}</a></td></tr>71 <td><a href="${freemarker_config.context}/annotation/listThread.action?inReplyTo=${annotationId!}&root=${annotationId!}">${annotationId!}</a></td></tr> 58 72 <tr><td><b>Type</b></td> 59 73 <td>${annotation.type!"No Type"}</td></tr> 60 74 <tr><td><b>Created</b></td> 61 <td>${annotation.created !"No Created value"}</td></tr>75 <td>${annotation.createdAsDate?string("EEEE, MMMM dd, yyyy, hh:mm:ss a '('zzz')'")!"No Creation Date"}</td></tr> 62 76 <tr><td><b>Creator</b></td> 63 <@s.url id="showUser" namespace="/user" action="showUser" userId="${annotation.creator }"/>77 <@s.url id="showUser" namespace="/user" action="showUser" userId="${annotation.creator!}"/> 64 78 <td><@s.a href="${showUser}">${annotation.creator!"No Creator"}</@s.a></td></tr> 65 79 <tr><td><b>Annotates</b></td> 66 <td><a href="${freemarker_config.context}/article/${annotation.annotates}">${annotation.annotates!"No Annotates value"}</a></td></tr> 67 <tr><td><b>Supersedes</b></td> 68 <td>${annotation.supersedes!"No Supersedes value"}</td></tr> 69 <tr><td><b>Superseded By</b></td> 70 <td>${annotation.supersededBy!"No Superseded By value"}</td></tr> 80 <td><a href="${freemarker_config.context}/article/${annotation.annotates!}">${annotation.annotates!"No Annotates value"}</a></td></tr> 71 81 <tr><td><b>Conflict of Interest</b></td> 72 82 <td>${annotation.cIStatement!"No Conflict of Interest Statement"}</td></tr> 73 <tr><td><b>Context</b></td>74 <td><@s.textarea name="annotationContext" value="${annotationContext!annotation.context}" rows="4" cols="100"/></td></tr>75 83 </table> 76 <@s.submit value="Save Annotation" />77 84 </fieldset> 78 85 86 <br/> 87 <@s.submit value="Save Annotation" /> 88 <br/> 89 79 90 <#if annotation.formalCorrection || annotation.retraction> 91 <#if ! annotation.citation??> 92 <b>No Citation for this Annotation<b> 93 <#else> 94 <@s.hidden name="citationId" label="hiddenCitationId" required="true" value="${citationId!}"/> 80 95 <fieldset> 81 96 <legend><b>Annotation Citation</b></legend> 82 97 <table> 83 <tr><td><b>Citation</b></td> 84 <td>${annotation.citation!"No Citation for this Annotation"}</td></tr> 98 <tr><td><b>Citation Title</b></td> 99 <td><@s.textfield name="citationTitle" value="${citationTitle!}" size="40"/></td></tr> 100 <tr><td><b>Year</b></td> 101 <td><@s.textfield name="citationDisplayYear" value="${citationDisplayYear!}" size="10"/></td></tr> 102 <tr><td><b>Volume</b></td> 103 <td><@s.textfield name="citationVolumeNumber" value="${citationVolumeNumber!}" size="10"/></td></tr> 104 <tr><td><b>Issue</b></td> 105 <td><@s.textfield name="citationIssue" value="${citationIssue!}" size="10"/></td></tr> 106 <tr><td><b>Journal</b></td> 107 <td><@s.textfield name="citationJournal" value="${citationJournal!}" size="20"/></td></tr> 108 <tr><td><b>eLocationId</b></td> 109 <td><@s.textfield name="citationELocationId" value="${citationELocationId!}" size="40"/></td></tr> 110 <tr><td><b>DOI</b></td> 111 <td><@s.textfield name="citationDoi" value="${citationDoi!}" size="40"/></td></tr> 112 <tr><td><b>URL</b></td> 113 <td>${annotation.citation.url!"No URL"}</td></tr> 114 <tr><td><b>Note</b></td> 115 <td>${annotation.citation.note!"No Note"}</td></tr> 116 <tr><td><b>Summary</b></td> 117 <td>${annotation.citation.summary!"No Summary"}</td></tr> 118 <tr><td colspan="2"> 119 <fieldset> 120 <legend><b>Citation Authors</b></legend> 121 <table> 122 <#if citationAuthorIds?? && (citationAuthorIds?size > 0)> 123 <tr><td><b>Given Names</b></td><td><b>Surnames</b></td><td><b>Suffixes</b></td></tr> 124 <@s.hidden name="citationAuthorDeleteIndex" label="citationAuthorDeleteIndex" required="true" value="-1"/> 125 <#list citationAuthorIds as authorId> 126 <@s.hidden name="citationAuthorIds" label="hiddenCitationAuthorIds" required="true" value="${authorId!}"/> 127 <tr><td><@s.textfield name="citationAuthorGivenNames" value="${citationAuthorGivenNames[authorId_index]!}" size="20"/></td> 128 <td><@s.textfield name="citationAuthorSurnames" value="${citationAuthorSurnames[authorId_index]!}" size="20"/></td> 129 <td><@s.textfield name="citationAuthorSuffixes" value="${citationAuthorSuffixes[authorId_index]!}" size="20"/></td> 130 <td><a href="#" onClick="confirmToDeleteAuthor(${authorId_index});return false;">Delete Author</a></td></tr> 131 </#list> 132 <tr><td><@s.textfield name="citationAuthorGivenNames" value="" size="20"/></td> 133 <td><@s.textfield name="citationAuthorSurnames" value="" size="20"/></td> 134 <td><@s.textfield name="citationAuthorSuffixes" value="" size="20"/></td> 135 <td><a href="#" onClick="document.manageAnnotationSave.submit()">Add Author</a></td></tr> 136 <#else> 137 There are currently no Authors associated to this Citation. 138 <@s.hidden name="citationAuthorDeleteIndex" label="citationAuthorDeleteIndex" required="true" value="-1"/> 139 <tr><td><@s.textfield name="citationAuthorGivenNames" value="" size="20"/></td> 140 <td><@s.textfield name="citationAuthorSurnames" value="" size="20"/></td> 141 <td><@s.textfield name="citationAuthorSuffixes" value="" size="20"/></td> 142 <td><a href="#" onClick="document.manageAnnotationSave.submit()">Add Author</a></td></tr> 143 </#if> 144 </table> 145 </fieldset> 146 </td></tr> 147 148 <tr><td colspan="2"> 149 <fieldset> 150 <legend><b>Citation Collaborative Authors</b></legend> 151 <table> 152 <#if citationCollaborativeAuthorNames?? && (citationCollaborativeAuthorNames?size > 0)> 153 <@s.hidden name="citationCollaborativeAuthorDeleteIndex" label="citationCollaborativeAuthorDeleteIndex" required="true" value="-1"/> 154 <#list citationCollaborativeAuthorNames as authorName> 155 <tr><td><@s.textfield name="citationCollaborativeAuthorNames" value="${authorName!}" size="20"/></td> 156 <td><a href="#" onClick="confirmToDeleteCollaborativeAuthor(${authorName_index});return false;">Delete Collaborative Author</a></td></tr> 157 </#list> 158 <tr><td><@s.textfield name="citationCollaborativeAuthorNames" value="" size="20"/></td> 159 <td><a href="#" onClick="document.manageAnnotationSave.submit()">Add Collaborative Author</a></td></tr> 160 <#else> 161 There are currently no Collaborative Authors associated to this Citation. 162 <@s.hidden name="citationCollaborativeAuthorDeleteIndex" label="citationCollaborativeAuthorDeleteIndex" required="true" value="-1"/> 163 <tr><td><@s.textfield name="citationCollaborativeAuthorNames" value="" size="20"/></td> 164 <td><a href="#" onClick="document.manageAnnotationSave.submit()">Add Collaborative Author</a></td></tr> 165 </#if> 166 </table> 167 </fieldset> 168 </td></tr> 169 85 170 </table> 86 <@s.submit value="Save Annotation" />87 171 </fieldset> 172 <@s.submit value="Save Annotation" /> 88 173 </#if> 89 174 </#if> 90 175 </@s.form> 91 176 </#if> -
head/ambra/webapp/src/main/webapp/admin/manageFlags.ftl
r7716 r7724 30 30 <fieldset> 31 31 <legend><b>Flagged Comments</b></legend> 32 <@s.form name=" editAnnotationAction" action="processFlags" method="post" namespace="/admin">32 <@s.form name="manageFlagsAction" action="processFlags" method="post" namespace="/admin"> 33 33 <table width="100%"> 34 34 <tr><td><b>Time</b></td><td><b>Comment</b></td><td><b>By</b></td><td><b>Refers To</b></td><td><b>Reason</b></td><td><b>Action</b></td></tr> … … 36 36 <#list flaggedComments as flaggedComment> 37 37 <#if flaggedComment.isAnnotation> 38 <@s.url id="flagURL" namespace="/admin" action=" editOneAnnotationLoad" annotationId="${flaggedComment.target}"/>38 <@s.url id="flagURL" namespace="/admin" action="manageAnnotationLoad" annotationId="${flaggedComment.target}"/> 39 39 <#if flaggedComment.correction> 40 40 <#assign deleteLabel = "Delete Correction"> -
head/ambra/webapp/src/main/webapp/admin/templates/standardHeader.ftl
r7716 r7724 19 19 --> 20 20 <@s.url id="adminTop" namespace="/admin" action="adminTop"/> 21 <@s.url id=" editAnnotation" namespace="/admin" action="editAnnotation"/>22 <@s.url id=" editOneAnnotation" namespace="/admin" action="editOneAnnotation"/>21 <@s.url id="manageFlags" namespace="/admin" action="manageFlags"/> 22 <@s.url id="manageAnnotation" namespace="/admin" action="manageAnnotation"/> 23 23 <@s.url id="manageUsersURL" namespace="/admin" action="findUser" /> 24 24 <@s.url id="manageVirtualJournalsURL" namespace="/admin" action="manageVirtualJournals" /> … … 27 27 <p style="text-align: right"> 28 28 <@s.a href="${adminTop}">Admin Top</@s.a> | 29 <@s.a href="${ editAnnotation}">Manage Flags</@s.a> | 30 <@s.a href="${ editOneAnnotation}">Manage Annotations</@s.a> | 29 <@s.a href="${manageFlags}">Manage Flags</@s.a> | 30 <@s.a href="${manageAnnotation}">Manage Annotations</@s.a> | 31 31 <@s.a href="${manageUsersURL}">Manage Users</@s.a> | 32 32 <@s.a href="${manageVirtualJournalsURL}">Manage Virtual Journals</@s.a> | -
head/ambra/webapp/src/test/java/org/topazproject/ambra/admin/action/ProcessFlagsActionTest.java
r7716 r7724 149 149 annotationService.setPermissionsService(permissionsService); 150 150 annotationService.setAnnotationsPdp(pdp); 151 EditAnnotationAction action = new EditAnnotationAction();151 ManageFlagsAction action = new ManageFlagsAction(); 152 152 action.setAnnotationService(annotationService); 153 153 action.setAdminService(adminService);
