Changeset 7724

Show
Ignore:
Timestamp:
06/05/09 18:03:39 (14 months ago)
Author:
ssterling
Message:

Added ability to edit the Citation and Body of an Annotation. Changed naming of classes and templates to match the rest of the schema.

Addresses Job Order 8927

Location:
head/ambra/webapp/src
Files:
4 modified
4 moved

Legend:

Unmodified
Added
Removed
  • head/ambra/webapp/src/main/java/org/topazproject/ambra/admin/action/ManageAnnotationAction.java

    r7716 r7724  
    2727import org.topazproject.ambra.annotation.service.WebAnnotation; 
    2828import org.topazproject.ambra.models.ArticleAnnotation; 
     29import org.topazproject.ambra.models.UserProfile; 
     30import org.topazproject.ambra.admin.service.CitationService; 
    2931import org.apache.commons.logging.Log; 
    3032import org.apache.commons.logging.LogFactory; 
     
    3234 
    3335@SuppressWarnings("serial") 
    34 public class EditOneAnnotationAction extends BaseAdminActionSupport { 
    35   private static final Log log = LogFactory.getLog(EditOneAnnotationAction.class); 
    36  
    37   private String annotationId; 
     36public class ManageAnnotationAction extends BaseAdminActionSupport { 
     37  private static final Log log = LogFactory.getLog(ManageAnnotationAction.class); 
     38 
     39  private String        annotationId; 
    3840  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 
    4059  private AnnotationService annotationService; 
    4160  private AnnotationConverter annotationConverter; 
     61  private CitationService citationService; 
    4262 
    4363  @Override 
     
    4969 
    5070  /** 
    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. 
    5273   * 
    5374   * @return the struts status 
     
    6384      ArticleAnnotation a = annotationService.getArticleAnnotation(annotationId); 
    6485      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 
    65143    } catch (IllegalArgumentException iae) { 
    66144      addActionError("There is no Annotation with the ID: " + annotationId); 
     
    72150 
    73151  /** 
    74    * Struts Action to save an Annotation. 
     152   * Struts Action to save an Annotation and its Citation (if the Annotation has a Citation). 
    75153   * 
    76154   * @return the struts status 
     
    79157  @Transactional(rollbackFor = { Throwable.class }) 
    80158  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 
    83252    return loadAnnotation();  //  returns SUCCESS if the Annotation query succeeded. 
    84253  } 
    85254 
     255  /** 
     256   * Perform basic action necessary for the querying and display of data through this Action class. 
     257   * @return Always return false. 
     258   */ 
    86259  private boolean setCommonFields() { 
    87260    initJournal(); // create a faux journal object for template 
     
    90263 
    91264 
     265  /** 
     266   * Get the Annotation that is to be edited. 
     267   * @return the Annotation that is to be edited 
     268   */ 
    92269  public WebAnnotation getAnnotation() { 
    93270    return annotation; 
     
    101278    return annotationId; 
    102279  } 
    103  
    104280  /** 
    105281   * Set the Annotation ID. 
     
    111287 
    112288  /** 
     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  /** 
    113304   * Get Annotation Context, meaning the x-pointer location of this Annotation inside its Article. 
    114305   * @return The annotation context, the x-pointer location of this Annotation inside its Article 
    115306   */ 
    116307  public String getAnnotationContext() { 
    117     return saveAnnotationContext; 
    118   } 
    119  
     308    return annotationContext; 
     309  } 
    120310  /** 
    121311   * Set the Annotation Context, the x-pointer location of this Annotation inside its Article. 
     
    123313   */ 
    124314  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; 
    126544  } 
    127545 
     
    139557    this.annotationConverter = converter; 
    140558  } 
     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 
    141568} 
  • head/ambra/webapp/src/main/java/org/topazproject/ambra/admin/action/ManageFlagsAction.java

    r7716 r7724  
    4444 
    4545@SuppressWarnings("serial") 
    46 public class EditAnnotationAction extends BaseAdminActionSupport { 
    47   private static final Log log = LogFactory.getLog(EditAnnotationAction.class); 
     46public class ManageFlagsAction extends BaseAdminActionSupport { 
     47  private static final Log log = LogFactory.getLog(ManageFlagsAction.class); 
    4848 
    4949  private FlagManagementService flagManagementService; 
  • head/ambra/webapp/src/main/java/org/topazproject/ambra/annotation/service/AnnotationService.java

    r7701 r7724  
    2727import java.util.List; 
    2828import java.util.Set; 
     29import java.io.UnsupportedEncodingException; 
    2930 
    3031import org.apache.commons.beanutils.BeanUtilsBean; 
     
    5354import org.topazproject.ambra.models.Citation; 
    5455import org.topazproject.ambra.models.UserProfile; 
     56import org.topazproject.ambra.models.RatingContent; 
    5557import org.topazproject.ambra.user.AmbraUser; 
    5658import org.topazproject.ambra.xacml.AbstractSimplePEP; 
     
    615617  } 
    616618 
    617  
    618   /** 
    619    * Set the annotation context. 
     619  /** 
     620   * Update the annotation body and context. 
    620621   * 
    621622   * @param id the annotation id 
     623   * @param body 
    622624   * @param context the context to set 
    623    * 
    624625   * @throws OtmException on an error 
    625626   * @throws SecurityException if a security policy prevented this operation 
     
    627628   */ 
    628629  @Transactional(rollbackFor = { Throwable.class }) 
    629   public void updateContext(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 { 
    631632 
    632633    pep.checkAccess(AnnotationsPEP.UPDATE_ANNOTATION, URI.create(id)); 
    633634 
    634     Annotation<?> a = session.get(Annotation.class, id); 
     635    ArticleAnnotation a = session.get(ArticleAnnotation.class, id); 
    635636    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())); 
    638641    a.setContext(context); 
    639642  } 
  • head/ambra/webapp/src/main/resources/struts.xml

    r7716 r7724  
    881881 
    882882    <!-- 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 editAnnotation even 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> 
    890890      </result> 
    891891    </action> 
    892892 
    893893    <!-- 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 editAnnotation even 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> 
    902902        <param name="noCache">true</param> 
    903903      </result> 
     
    905905 
    906906    <!-- 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> 
    914914      </result> 
    915915    </action> 
    916916 
    917917    <!-- 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" 
    919919      method="loadAnnotation"> 
    920920      <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" 
    929930      method="saveAnnotation"> 
    930931      <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> 
    936937      </result> 
    937938    </action> 
  • head/ambra/webapp/src/main/webapp/admin/manageAnnotation.ftl

    r7716 r7724  
    2121  <head> 
    2222    <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     
    2339  </head> 
    2440  <body> 
     
    3046    <fieldset> 
    3147      <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"> 
    3349        <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> 
    3951          <tr><td colspan="2"><@s.submit value="Load Annotation" /></td></tr> 
    4052        </table> 
     
    4456 
    4557  <#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 
    4860      <fieldset> 
    4961        <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!}"/> 
    5163        <table> 
    5264          <tr><td><b>Title</b></td> 
    5365            <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> 
    5670          <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> 
    5872          <tr><td><b>Type</b></td> 
    5973            <td>${annotation.type!"No Type"}</td></tr> 
    6074          <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> 
    6276          <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!}"/> 
    6478            <td><@s.a href="${showUser}">${annotation.creator!"No Creator"}</@s.a></td></tr> 
    6579          <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> 
    7181          <tr><td><b>Conflict of Interest</b></td> 
    7282            <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> 
    7583        </table> 
    76         <@s.submit value="Save Annotation" /> 
    7784      </fieldset> 
    7885 
     86    <br/> 
     87    <@s.submit value="Save Annotation" /> 
     88    <br/> 
     89 
    7990    <#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!}"/> 
    8095      <fieldset> 
    8196        <legend><b>Annotation Citation</b></legend> 
    8297          <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 
    85170          </table> 
    86           <@s.submit value="Save Annotation" /> 
    87171      </fieldset> 
     172      <@s.submit value="Save Annotation" /> 
    88173    </#if> 
    89  
     174    </#if> 
    90175    </@s.form> 
    91176  </#if> 
  • head/ambra/webapp/src/main/webapp/admin/manageFlags.ftl

    r7716 r7724  
    3030      <fieldset> 
    3131        <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"> 
    3333          <table width="100%"> 
    3434            <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> 
     
    3636            <#list flaggedComments as flaggedComment> 
    3737              <#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}"/> 
    3939                <#if flaggedComment.correction> 
    4040                  <#assign deleteLabel = "Delete Correction"> 
  • head/ambra/webapp/src/main/webapp/admin/templates/standardHeader.ftl

    r7716 r7724  
    1919--> 
    2020<@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"/> 
    2323<@s.url id="manageUsersURL" namespace="/admin" action="findUser" /> 
    2424<@s.url id="manageVirtualJournalsURL" namespace="/admin" action="manageVirtualJournals" /> 
     
    2727<p style="text-align: right"> 
    2828  <@s.a href="${adminTop}">Admin Top</@s.a>&nbsp;|&nbsp; 
    29   <@s.a href="${editAnnotation}">Manage Flags</@s.a>&nbsp;|&nbsp; 
    30   <@s.a href="${editOneAnnotation}">Manage Annotations</@s.a>&nbsp;|&nbsp; 
     29  <@s.a href="${manageFlags}">Manage Flags</@s.a>&nbsp;|&nbsp; 
     30  <@s.a href="${manageAnnotation}">Manage Annotations</@s.a>&nbsp;|&nbsp; 
    3131  <@s.a href="${manageUsersURL}">Manage Users</@s.a>&nbsp;|&nbsp; 
    3232  <@s.a href="${manageVirtualJournalsURL}">Manage Virtual Journals</@s.a>&nbsp;|&nbsp; 
  • head/ambra/webapp/src/test/java/org/topazproject/ambra/admin/action/ProcessFlagsActionTest.java

    r7716 r7724  
    149149    annotationService.setPermissionsService(permissionsService); 
    150150    annotationService.setAnnotationsPdp(pdp); 
    151     EditAnnotationAction action = new EditAnnotationAction(); 
     151    ManageFlagsAction action = new ManageFlagsAction(); 
    152152    action.setAnnotationService(annotationService); 
    153153    action.setAdminService(adminService);