/*
 * Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved.
 */
package com.gooddata.md.report;

import com.gooddata.md.Meta;
import com.gooddata.md.Obj;
import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.annotate.JsonTypeInfo;
import org.codehaus.jackson.annotate.JsonTypeName;
import org.codehaus.jackson.map.annotate.JsonSerialize;

import java.util.Collection;

/**
 */
@JsonTypeName("report")
@JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class Report extends Obj {

    private final Content content;

    @JsonCreator
    public Report(@JsonProperty("meta") Meta meta, @JsonProperty("content") Content content) {
        super(meta);
        this.content = content;
    }

    public Content getContent() {
        return content;
    }

    @JsonIgnoreProperties(ignoreUnknown = true)
    @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
    public static class Content {
        private final Collection<String> definitions;

        @JsonCreator
        public Content(@JsonProperty("definitions") Collection<String> definitions) {
            this.definitions = definitions;
        }

        public Collection<String> getDefinitions() {
            return definitions;
        }
    }
}

@@ -513,16 +513,56 @@
 ction;%0A%0A
+import static java.util.Arrays.asList;%0A%0A
 /**%0A */%0A
@@ -1011,24 +1011,177 @@
 ent;%0A    %7D%0A%0A
+    public Report(String title, ReportDefinition definition) %7B%0A        this(new Meta(title), new Content(asList(definition.getMeta().getUri())));%0A    %7D%0A%0A
     public C

create report from report definition