package com.zenith.livinghistory.api.zenithlivinghistoryapi.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.joda.time.DateTime;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import java.io.Serializable;
import java.util.List;

@Document(collection = "Contents")
public class Content implements Serializable {

    /*
    * Example:
    *
  	* {
    * "contentType": "Image",
    * "title": "Bebek was not so crowded",
    * "description": "https://goo.gl/XQxhTt",
    * "tags": ["Bebek", "2015", "Seaside"],
    * "date": "2017-10-31",
    * "location": {
    * "longitude": -83.6945691,
    * "latitude": 42.25475478
    * },
    * "creator": "http://example.net/api/v1/users/pinar"
	* }
    *
    * */

    public Content() {
    }

    public Content(String contentType, String title, String description, String[] tags, DateTime date, LocationBody location, String creator) {
		this.contentType = contentType;
		this.title = title;
		this.description = description;
		this.tags = tags;
		this.date = date;
		this.location = location;
		this.creator = creator;
//		this.annotations = new ArrayList<>();
	}

    @JsonProperty("@contentType")
    private String contentType;

    @Id
    private String id;

    private String title;

    @Indexed
    private String description;

	private String[] tags;

    private DateTime date;

    private LocationBody location;

    private String creator;

//    @DBRef
//    @CascadeSave
//    @Field("annotations")
    private List<Annotation> annotations;

    public List<Annotation> getAnnotations() {
        return annotations;
    }

    public void setAnnotations(List<Annotation> annotations) {
        this.annotations = annotations;
    }

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}


	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}


    public String getCreator() {
        return creator;
    }

    public void setCreator(String creator) {
        this.creator = creator;
    }


	public String[] getTags() { return tags; }

	public void setTags(String[] tags) { this.tags = tags; }


	public DateTime getDate() {
        return date;
    }

    public void setDate(DateTime date) {
        this.date = date;
    }


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }


    public String getContentType() {
        return contentType;
    }

    public void setContentType(String contentType) {
        this.contentType = contentType;
    }


    public LocationBody getLocation() {
        return location;
    }

    public void setLocation(LocationBody location) {
        this.location = location;
    }

}

@@ -113,16 +113,94 @@
 operty;%0A
+import com.zenith.livinghistory.api.zenithlivinghistoryapi.utils.CascadeSave;%0A
 import o
@@ -329,16 +329,76 @@
 ndexed;%0A
+import org.springframework.data.mongodb.core.mapping.DBRef;%0A
 import o
@@ -456,36 +456,124 @@
 nt;%0A
-%0Aimport java.io.Serializable
+import org.springframework.data.mongodb.core.mapping.Field;%0A%0Aimport java.io.Serializable;%0Aimport java.util.ArrayList
 ;%0Aim
@@ -1434,50 +1434,8 @@
 or;%0A
-//%09%09this.annotations = new ArrayList%3C%3E();%0A
 %09%7D%0A%0A
@@ -1724,18 +1724,16 @@
 eator;%0A%0A
-//
     @DBR
@@ -1735,18 +1735,16 @@
  @DBRef%0A
-//
     @Cas
@@ -1752,18 +1752,16 @@
 adeSave%0A
-//
     @Fie
@@ -1818,16 +1818,36 @@
 otations
+ = new ArrayList%3C%3E()
 ;%0A%0A    p

Fix CascadeSave on content