Ignore:
Timestamp:
12/07/11 10:24:43 (12 years ago)
Author:
jeafer
Message:

Jean-Charles branch ComponentRegistry commit4,
Changes regarding comment on the ComponentRegistry.

Modification of classes Comment, CommentsDao?
Improvement of validation process for comments
Improvement of ComponentRegistryRestService?
Functionnal implementation of class test (RegisterHelper? and RestServiceTest?)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/model/Comment.java

    r1635 r1639  
    1 /*
    2  * To change this template, choose Tools | Templates
    3  * and open the template in the editor.
    4  */
    51package clarin.cmdi.componentregistry.model;
    62
     
    84import clarin.cmdi.componentregistry.IdSequence;
    95import java.text.ParseException;
    10 import java.util.ArrayList;
    116import java.util.Date;
    12 import java.util.List;
    137import javax.xml.bind.annotation.XmlAccessType;
    148import javax.xml.bind.annotation.XmlAccessorType;
    15 import javax.xml.bind.annotation.XmlElement;
    169import javax.xml.bind.annotation.XmlRootElement;
    1710import org.apache.commons.lang.time.DateFormatUtils;
     
    2013/**
    2114 *
    22  * @author jeafer
     15 * @author jean-charles FerriÚres <jean-charles.ferrieres@mpi.nl>
    2316 */
    2417@XmlRootElement(name = "comment")
    2518@XmlAccessorType(XmlAccessType.FIELD)
    2619public class Comment {
    27         @XmlElement(name = "Comment_Type")
    28     protected List<Comment> commentType;
    29         private String comments;
    30         private String commentDate;
    31         private String componentDescriptionId;
    32         private String profileDescriptionId;
    33         private String userId;
    34         private String id;
    3520
    36        
    37         public List<Comment> getComments() {
    38         if (commentType == null) {
    39             commentType = new ArrayList<Comment>();
    40         }
    41         return this.commentType;
     21    private String comments;
     22    private String commentDate;
     23    private String componentDescriptionId;
     24    private String profileDescriptionId;
     25    private String userId;
     26    private String id;
     27
     28    public void setComment(String comment) {
     29        this.comments = comment;
    4230    }
    43        
    44         public void setComment(String comment) {
    45             this.comments = comment;
    46         }
    4731
    48         public String getComment() {
    49             return comments;
    50         }
     32    public String getComment() {
     33        return comments;
     34    }
    5135
    52         public void setCommentDate(String commentDate) {
    53             this.commentDate = commentDate;
    54         }
     36    public void setCommentDate(String commentDate) {
     37        this.commentDate = commentDate;
     38    }
    5539
    56         public String getCommentDate() {
    57             return commentDate;
    58         }
     40    public String getCommentDate() {
     41        return commentDate;
     42    }
    5943
    60         public void setId(String commentId) {
    61             this.id = commentId;
    62         }
     44    public void setId(String commentId) {
     45        this.id = commentId;
     46    }
    6347
    64         public String getId() {
    65             return id;
    66         }
     48    public String getId() {
     49        return id;
     50    }
    6751
    68         public String getComponentDescriptionId() {
    69             return componentDescriptionId;
    70         }
     52    public String getComponentDescriptionId() {
     53        return componentDescriptionId;
     54    }
    7155
    72         public void setComponentDescriptionId(String ComponentDescriptionId) {
    73             this.componentDescriptionId = ComponentDescriptionId;
    74         }
     56    public void setComponentDescriptionId(String ComponentDescriptionId) {
     57        this.componentDescriptionId = ComponentDescriptionId;
     58    }
    7559
    76         public void setProfileDescriptionId(String profileDescriptionId) {
    77             this.profileDescriptionId = profileDescriptionId;
    78         }
     60    public void setProfileDescriptionId(String profileDescriptionId) {
     61        this.profileDescriptionId = profileDescriptionId;
     62    }
    7963
    80         public String getProfileDescriptionId() {
    81             return profileDescriptionId;
    82         }
     64    public String getProfileDescriptionId() {
     65        return profileDescriptionId;
     66    }
    8367
    84         public void setUserId(String userId) {
    85             this.userId = userId;
    86         }
     68    public void setUserId(String userId) {
     69        this.userId = userId;
     70    }
    8771
    88         public String getUserId() {
    89             return userId;
    90         }
     72    public String getUserId() {
     73        return userId;
     74    }
    9175
    92         public static String createNewDate() {
    93             return createNewDate(new Date().getTime());
    94         }
     76    public static Date getDate(String registrationDate) throws ParseException {
     77        return DateUtils.parseDate(registrationDate, new String[]{DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern()});
     78    }
    9579
    96         public static Date getDate(String registrationDate) throws ParseException {
    97             return DateUtils.parseDate(registrationDate, new String[]{DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern()});
    98         }
     80    /*
     81     * Helper method to set the Date
     82     */
     83    public static String createNewDate() {
     84        return createNewDate(new Date().getTime());
     85    }
     86   
     87    /*
     88     * Helper method to set the Date in the same format
     89     * @param time, long that contains the time to be set
     90     */
    9991
    100         public static String createNewDate(long time) {
    101             return DateFormatUtils.formatUTC(time, DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern());
    102         }
    103        
    104             public static Comment createANewComment() {
    105         String descriptionId = ComponentRegistry.REGISTRY_ID+ "p_" + IdSequence.get();
    106         Comment com = new Comment();
    107         com.setComment("Actual");
    108         com.setProfileDescriptionId(descriptionId);       
    109         com.setCommentDate(createNewDate());
    110         return com;
     92    public static String createNewDate(long time) {
     93        return DateFormatUtils.formatUTC(time, DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern());
    11194    }
     95
     96    public static Comment createANewComment() {
     97        String Id = ComponentRegistry.REGISTRY_ID + IdSequence.get();
     98        Comment com = new Comment();
     99        com.setId(Id);
     100        com.setCommentDate(createNewDate());
     101        return com;
    112102    }
     103}
Note: See TracChangeset for help on using the changeset viewer.