// 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 java.util.Date;
import java.util.Set;
import java.util.UUID;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import com.datastax.driver.mapping.annotations.Column;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
import killrvideo.search.SearchServiceOuterClass.SearchResultsVideoPreview;
import killrvideo.search.SearchServiceOuterClass.SearchResultsVideoPreview.Builder;
import killrvideo.suggested_videos.SuggestedVideosService.SuggestedVideoPreview;
import killrvideo.utils.EmptyCollectionIfNull;
import killrvideo.utils.TypeConverter;
import killrvideo.video_catalog.VideoCatalogServiceOuterClass.GetVideoResponse;
import killrvideo.video_catalog.VideoCatalogServiceOuterClass.VideoLocationType;
import killrvideo.video_catalog.VideoCatalogServiceOuterClass.VideoPreview;
package killrvideo.entity;






/**
 * Pojo representing DTO for table 'videos'.
 *
 * @author DataStax evangelist team.
 */
@Table(keyspace = Schema.KEYSPACE, name = Schema.TABLENAME_VIDEOS)
public class Video extends AbstractVideo {

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

    @PartitionKey
    private UUID videoid;

    @NotNull
    @Column
    private UUID userid;

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

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

    @Column(name = "location_type")
    private int locationType;

    @Column
    @EmptyCollectionIfNull
    private Set<String> tags;

    @NotNull
    @Column(name = "added_date")
    private Date addedDate;

    /**
     * Default Constructor allowing reflection.
     */
    public Video() {}
    
    /**
     * Constructor wihout location nor preview.
     */
    public Video(UUID videoid, UUID userid, String name, String description, int locationType, Set<String> tags, Date addedDate) {
        this(videoid, userid, name, description, null, locationType, null, tags, addedDate);
    }

    /**
     * All attributes constructor.
     */
    public Video(UUID videoid, UUID userid, String name, String description, String location, int locationType, String previewImageLocation, Set<String> tags, Date addedDate) {
        super(name, previewImageLocation);
        this.videoid = videoid;
        this.userid = userid;
        this.description = description;
        this.location = location;
        this.locationType = locationType;
        this.tags = tags;
        this.addedDate = addedDate;
    }
    
    /**
     * Mapping to generated GPRC beans (Full detailed)
     */
    public GetVideoResponse toVideoResponse() {
        final GetVideoResponse videoResponse = GetVideoResponse
                .newBuilder()
// 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/Video.java
import java.util.Date;
import java.util.Set;
import java.util.UUID;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import com.datastax.driver.mapping.annotations.Column;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
import killrvideo.search.SearchServiceOuterClass.SearchResultsVideoPreview;
import killrvideo.search.SearchServiceOuterClass.SearchResultsVideoPreview.Builder;
import killrvideo.suggested_videos.SuggestedVideosService.SuggestedVideoPreview;
import killrvideo.utils.EmptyCollectionIfNull;
import killrvideo.utils.TypeConverter;
import killrvideo.video_catalog.VideoCatalogServiceOuterClass.GetVideoResponse;
import killrvideo.video_catalog.VideoCatalogServiceOuterClass.VideoLocationType;
import killrvideo.video_catalog.VideoCatalogServiceOuterClass.VideoPreview;

package killrvideo.entity;






/**
 * Pojo representing DTO for table 'videos'.
 *
 * @author DataStax evangelist team.
 */
@Table(keyspace = Schema.KEYSPACE, name = Schema.TABLENAME_VIDEOS)
public class Video extends AbstractVideo {

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

    @PartitionKey
    private UUID videoid;

    @NotNull
    @Column
    private UUID userid;

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

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

    @Column(name = "location_type")
    private int locationType;

    @Column
    @EmptyCollectionIfNull
    private Set<String> tags;

    @NotNull
    @Column(name = "added_date")
    private Date addedDate;

    /**
     * Default Constructor allowing reflection.
     */
    public Video() {}
    
    /**
     * Constructor wihout location nor preview.
     */
    public Video(UUID videoid, UUID userid, String name, String description, int locationType, Set<String> tags, Date addedDate) {
        this(videoid, userid, name, description, null, locationType, null, tags, addedDate);
    }

    /**
     * All attributes constructor.
     */
    public Video(UUID videoid, UUID userid, String name, String description, String location, int locationType, String previewImageLocation, Set<String> tags, Date addedDate) {
        super(name, previewImageLocation);
        this.videoid = videoid;
        this.userid = userid;
        this.description = description;
        this.location = location;
        this.locationType = locationType;
        this.tags = tags;
        this.addedDate = addedDate;
    }
    
    /**
     * Mapping to generated GPRC beans (Full detailed)
     */
    public GetVideoResponse toVideoResponse() {
        final GetVideoResponse videoResponse = GetVideoResponse
                .newBuilder()
                .setAddedDate(TypeConverter.dateToTimestamp(addedDate))