package com.creatubbles.api.model.creation;

import android.support.annotation.Nullable;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.github.jasminb.jsonapi.annotations.Id;
import com.github.jasminb.jsonapi.annotations.Type;

import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Type("creations")
public class Creation {

    @Id
    private String id;

/*    @Relationship("user")
    private User user;*/

/*    @Relationship("creators")
    private List<User> creators;*/

    @JsonProperty("name")
    private String name;

    @JsonProperty("created_at")
    private Date createdAt;

    @JsonProperty("updated_at")
    private Date updatedAt;

    @JsonProperty("image_status")
    private ImageStatus imageStatus;

    @JsonProperty("image")
    private Image image;

    @JsonProperty("bubbles_count")
    private Integer bubblesCount;

    @JsonProperty("comments_count")
    private Integer commentsCount;

    @JsonProperty("views_count")
    private Integer viewsCount;

    @JsonProperty("last_bubbled_at")
    private Date lastBubbledAt;

    @JsonProperty("last_commented_at")
    private Date lastCommentedAt;

    @JsonProperty("last_submitted_at")
    private Date lastSubmittedAt;

    @JsonProperty("translated_names")
    private List<TranslatedName> translatedNames = Collections.emptyList();

    @JsonProperty("approved")
    @Deprecated
    private Boolean approved;

    @JsonProperty("short_url")
    private String shortUrl;

    @JsonProperty("created_at_age")
    private String createdAtAge;

    @JsonProperty("approval_status")
    private ApprovalStatus approvalStatus;

    @JsonProperty("created_at_age_per_creator")
    private Map<String, String> createdAtAgePerCreator;

    @JsonProperty("reflection_text")
    private String reflectionText;

    @JsonProperty("reflection_video_url")
    private String reflectionVideoUrl;

    @JsonProperty("obj_file_url")
    private String objFileUrl;

    @JsonProperty("play_iframe_url")
    private String playIframeUrl;

    public String getName() {
        return name;
    }

    public Date getCreatedAt() {
        return createdAt;
    }

    public Date getUpdatedAt() {
        return updatedAt;
    }

    public ImageStatus getImageStatus() {
        return imageStatus;
    }

    public Image getImage() {
        return image;
    }

    public Integer getBubblesCount() {
        return bubblesCount;
    }

    public Integer getCommentsCount() {
        return commentsCount;
    }

    public Integer getViewsCount() {
        return viewsCount;
    }

    @Nullable
    public Date getLastBubbledAt() {
        return lastBubbledAt;
    }

    @Nullable
    public Date getLastCommentedAt() {
        return lastCommentedAt;
    }

    @Nullable
    public Date getLastSubmittedAt() {
        return lastSubmittedAt;
    }

    public List<TranslatedName> getTranslatedNames() {
        return translatedNames;
    }

    @Deprecated
    public Boolean getApproved() {
        return approved;
    }

    public String getShortUrl() {
        return shortUrl;
    }

    @Nullable
    public String getCreatedAtAge() {
        return createdAtAge;
    }

    public ApprovalStatus getApprovalStatus() {
        return approvalStatus;
    }

    /**
     * This is the hash of ids of creators related to creation with proper ages assigned.
     * It’s very useful for listing creators with information about how old it was when creation have been added.
     */
    public Map<String, String> getCreatedAtAgePerCreator() {
        return createdAtAgePerCreator;
    }

    /**
     * @return user’s "reflection" / "comment" about the creation
     */
    @Nullable
    public String getReflectionText() {
        return reflectionText;
    }

    /**
     * @return link to video on creation process, has to be a valid URL
     */
    @Nullable
    public String getReflectionVideoUrl() {
        return reflectionVideoUrl;
    }

    /**
     * @return url to OBJ file for 3d object
     */
    @Nullable
    public String getObjFileUrl() {
        return objFileUrl;
    }

    /**
     * @return url to 3d player which can be embedded in iframe
     */
    @Nullable
    public String getPlayIframeUrl() {
        return playIframeUrl;
    }

    @Override
    public String toString() {
        return "Creation{" +
                "id='" + id + '\'' +
                //", user=" + user +
                //", creators=" + creators +
                ", name='" + name + '\'' +
                ", createdAt=" + createdAt +
                ", updatedAt=" + updatedAt +
                ", imageStatus=" + imageStatus +
                ", image=" + image +
                ", bubblesCount=" + bubblesCount +
                ", commentsCount=" + commentsCount +
                ", viewsCount=" + viewsCount +
                ", lastBubbledAt=" + lastBubbledAt +
                ", lastCommentedAt=" + lastCommentedAt +
                ", lastSubmittedAt=" + lastSubmittedAt +
                ", translatedNames=" + translatedNames +
                ", approved=" + approved +
                ", shortUrl='" + shortUrl + '\'' +
                ", createdAtAge='" + createdAtAge + '\'' +
                ", approvalStatus=" + approvalStatus +
                ", createdAtAgePerCreator=" + createdAtAgePerCreator +
                ", reflectionText='" + reflectionText + '\'' +
                ", reflectionVideoUrl='" + reflectionVideoUrl + '\'' +
                ", objFileUrl='" + objFileUrl + '\'' +
                ", playIframeUrl='" + playIframeUrl + '\'' +
                '}';
    }
}

@@ -79,24 +79,68 @@
 .Nullable;%0A%0A
+import com.creatubbles.api.model.user.User;%0A
 import com.f
@@ -231,16 +231,76 @@
 ons.Id;%0A
+import com.github.jasminb.jsonapi.annotations.Relationship;%0A
 import c
@@ -519,18 +519,16 @@
 ng id;%0A%0A
-/*
     @Rel
@@ -571,14 +571,10 @@
 ser;
-*/%0A%0A/*
+%0A%0A
     
@@ -631,18 +631,16 @@
 reators;
-*/
 %0A%0A    @J
@@ -4398,24 +4398,204 @@
 Url;%0A    %7D%0A%0A
+    public String getId() %7B%0A        return id;%0A    %7D%0A%0A    public User getUser() %7B%0A        return user;%0A    %7D%0A%0A    public List%3CUser%3E getCreators() %7B%0A        return creators;%0A    %7D%0A%0A
     @Overrid
@@ -4596,16 +4596,16 @@
 verride%0A
-
     publ
@@ -4709,18 +4709,16 @@
         
-//
 %22, user=
@@ -4748,10 +4748,8 @@
     
-//
 %22, c

Add relationships to Creation