// Path: src/main/java/killrvideo/utils/TypeConverter.java
// public class TypeConverter {
// 
//     public static Timestamp instantToTimeStamp(Instant instant) {
//         return Timestamp.newBuilder()
//                 .setSeconds(instant.getEpochSecond())
//                 .setNanos(instant.getNano()).build();
//     }
//     
//     public static Timestamp epochTimeToTimeStamp(long epoch) {
//         return Timestamp.newBuilder().setSeconds(epoch).build();
//     }
// 
//     public static Timestamp dateToTimestamp(Date date) {
//         return instantToTimeStamp(date.toInstant());
//     }
// 
//     public static Date dateFromTimestamp(Timestamp timestamp) {
//         return Date.from(Instant.ofEpochSecond(timestamp.getSeconds()));
//     }
// 
//     public static TimeUuid uuidToTimeUuid(UUID uuid) {
//         return TimeUuid.newBuilder()
//                 .setValue(uuid.toString())
//                 .build();
//     }
// 
//     public static Uuid uuidToUuid(UUID uuid) {
//         return Uuid.newBuilder()
//                 .setValue(uuid.toString())
//                 .build();
//     }
// 
//     /**
//      * This method is useful when debugging as an easy way to get a traversal
//      * string to use in gremlin or DSE Studio from bytecode.
//      * @param traversal
//      * @return
//      */
//     public static String bytecodeToTraversalString(KillrVideoTraversal<Vertex, Vertex> traversal) {
//         return org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyTranslator.of("g").translate(traversal.getBytecode());
//     }
// }


import static java.util.UUID.fromString;
import java.io.Serializable;
import java.util.Date;
import java.util.UUID;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import com.datastax.driver.mapping.annotations.ClusteringColumn;
import com.datastax.driver.mapping.annotations.Column;
import com.datastax.driver.mapping.annotations.Computed;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
import killrvideo.comments.CommentsServiceOuterClass;
import killrvideo.comments.CommentsServiceOuterClass.CommentOnVideoRequest;
import killrvideo.utils.TypeConverter;
package killrvideo.entity;







/**
 * Pojo representing DTO for table 'comments_by_user'
 *
 * @author DataStax evangelist team.
 */
@Table(keyspace = Schema.KEYSPACE, name = Schema.TABLENAME_COMMENTS_BY_USER)
public class CommentsByUser implements Serializable, Schema {

    /** Serial. */
    private static final long serialVersionUID = -4443951809189156563L;

    @PartitionKey
    private UUID userid;

    @ClusteringColumn
    private UUID commentid;

    @NotNull
    @Column
    private UUID videoid;

    @Length(min = 1, message = "The comment must not be empty")
    @Column
    private String comment;

    /**
     * In order to properly use the @Computed annotation for dateOfComment
     * you must execute a query using the mapper with this entity, NOT QueryBuilder.
     * If QueryBuilder is used you must use a call to fcall() and pass the CQL function
     * needed to it directly.  Here is an example pulled from CommentsByVideo.getVideoComments().
     * fcall("toTimestamp", QueryBuilder.column("commentid")).as("comment_timestamp")
     * This will execute the toTimeStamp() function against the commentid column and return the
     * result with an alias of comment_timestamp.  Again, reference CommentService.getUserComments()
     * or CommentService.getVideoComments() for examples of how to implement.
     */
    @NotNull
    @Computed("toTimestamp(commentid)")
    private Date dateOfComment;

    /**
     * Default constructor (reflection)
     */
    public CommentsByUser() {}

    /**
     * Constructor with all parameters.
     */
    public CommentsByUser(UUID userid, UUID commentid, UUID videoid, String comment) {
        this.userid = userid;
        this.commentid = commentid;
        this.videoid = videoid;
        this.comment = comment;
    }

    /**
     * Constructor from GRPC generated request.
     */
    public CommentsByUser(CommentOnVideoRequest request) {
        this.userid = fromString(request.getUserId().getValue());
        this.commentid = fromString(request.getCommentId().getValue());
        this.videoid = fromString(request.getVideoId().getValue());
        this.comment = request.getComment();
    }

    /**
     * Mapping to GRPC generated classes.
     */
// Path: src/main/java/killrvideo/utils/TypeConverter.java
// public class TypeConverter {
// 
//     public static Timestamp instantToTimeStamp(Instant instant) {
//         return Timestamp.newBuilder()
//                 .setSeconds(instant.getEpochSecond())
//                 .setNanos(instant.getNano()).build();
//     }
//     
//     public static Timestamp epochTimeToTimeStamp(long epoch) {
//         return Timestamp.newBuilder().setSeconds(epoch).build();
//     }
// 
//     public static Timestamp dateToTimestamp(Date date) {
//         return instantToTimeStamp(date.toInstant());
//     }
// 
//     public static Date dateFromTimestamp(Timestamp timestamp) {
//         return Date.from(Instant.ofEpochSecond(timestamp.getSeconds()));
//     }
// 
//     public static TimeUuid uuidToTimeUuid(UUID uuid) {
//         return TimeUuid.newBuilder()
//                 .setValue(uuid.toString())
//                 .build();
//     }
// 
//     public static Uuid uuidToUuid(UUID uuid) {
//         return Uuid.newBuilder()
//                 .setValue(uuid.toString())
//                 .build();
//     }
// 
//     /**
//      * This method is useful when debugging as an easy way to get a traversal
//      * string to use in gremlin or DSE Studio from bytecode.
//      * @param traversal
//      * @return
//      */
//     public static String bytecodeToTraversalString(KillrVideoTraversal<Vertex, Vertex> traversal) {
//         return org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyTranslator.of("g").translate(traversal.getBytecode());
//     }
// }


// Path: src/main/java/killrvideo/entity/CommentsByUser.java
import static java.util.UUID.fromString;
import java.io.Serializable;
import java.util.Date;
import java.util.UUID;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import com.datastax.driver.mapping.annotations.ClusteringColumn;
import com.datastax.driver.mapping.annotations.Column;
import com.datastax.driver.mapping.annotations.Computed;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
import killrvideo.comments.CommentsServiceOuterClass;
import killrvideo.comments.CommentsServiceOuterClass.CommentOnVideoRequest;
import killrvideo.utils.TypeConverter;

package killrvideo.entity;







/**
 * Pojo representing DTO for table 'comments_by_user'
 *
 * @author DataStax evangelist team.
 */
@Table(keyspace = Schema.KEYSPACE, name = Schema.TABLENAME_COMMENTS_BY_USER)
public class CommentsByUser implements Serializable, Schema {

    /** Serial. */
    private static final long serialVersionUID = -4443951809189156563L;

    @PartitionKey
    private UUID userid;

    @ClusteringColumn
    private UUID commentid;

    @NotNull
    @Column
    private UUID videoid;

    @Length(min = 1, message = "The comment must not be empty")
    @Column
    private String comment;

    /**
     * In order to properly use the @Computed annotation for dateOfComment
     * you must execute a query using the mapper with this entity, NOT QueryBuilder.
     * If QueryBuilder is used you must use a call to fcall() and pass the CQL function
     * needed to it directly.  Here is an example pulled from CommentsByVideo.getVideoComments().
     * fcall("toTimestamp", QueryBuilder.column("commentid")).as("comment_timestamp")
     * This will execute the toTimeStamp() function against the commentid column and return the
     * result with an alias of comment_timestamp.  Again, reference CommentService.getUserComments()
     * or CommentService.getVideoComments() for examples of how to implement.
     */
    @NotNull
    @Computed("toTimestamp(commentid)")
    private Date dateOfComment;

    /**
     * Default constructor (reflection)
     */
    public CommentsByUser() {}

    /**
     * Constructor with all parameters.
     */
    public CommentsByUser(UUID userid, UUID commentid, UUID videoid, String comment) {
        this.userid = userid;
        this.commentid = commentid;
        this.videoid = videoid;
        this.comment = comment;
    }

    /**
     * Constructor from GRPC generated request.
     */
    public CommentsByUser(CommentOnVideoRequest request) {
        this.userid = fromString(request.getUserId().getValue());
        this.commentid = fromString(request.getCommentId().getValue());
        this.videoid = fromString(request.getVideoId().getValue());
        this.comment = request.getComment();
    }

    /**
     * Mapping to GRPC generated classes.
     */
    public CommentsServiceOuterClass.UserComment toUserComment() {