package eu.socialsensor.framework.common.domain;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

import java.util.Date;

/**
 *
 * @author etzoannos - e.tzoannos@atc.gr
 */
public class WebPage implements JSONable, Comparable<WebPage> {

    /**
	 * 
	 */
	private static final long serialVersionUID = -8783341713025378581L;
	
	// The URL of a WebPage. This is usuually a short URL
	@Expose
    @SerializedName(value = "url")
    private String url;
	
	// The expanded version of URL
    @Expose
    @SerializedName(value = "expandedUrl")
    private String expandedUrl;
    
    // The title extracted from the WebPage
    @Expose
    @SerializedName(value = "title")
    private String title;
    
    // The textual content of the web page
    @Expose
    @SerializedName(value = "text")
    private String text;
    
    // The title extracted from the WebPage
    @Expose
    @SerializedName(value = "keywords")
    private String[] keywords;
    
    // The date that a web page shared for the first time
    @Expose
    @SerializedName(value = "date")
    private Date date;
    
    // The id of the Item that share a web page for the forst time
    @Expose
    @SerializedName(value = "reference")
    private String reference;
    
    // The stream of the Item that the web page comes from 
    @Expose
    @SerializedName(value = "streamId")
    private String streamId;
    
    // The number of times a web page has been shared
    @Expose
    @SerializedName(value = "shares")
    private int shares = 0;

    // The crawling status of this web page
    @Expose
    @SerializedName(value = "status")
    private String status = "new";
    
    public WebPage(String url, String reference) {
        this.url = url;
        this.reference = reference;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getExpandedUrl() {
        return this.expandedUrl;
    }

    public void setExpandedUrl(String expandedUrl) {
        this.expandedUrl = expandedUrl;
    }

    public String getStreamId() {
        return streamId;
    }
    
    public void setStreamId(String streamId) {
        this.streamId = streamId;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }
    
    public String getTitle() {
        return title;
    }

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

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String[] getKeywords() {
        return keywords;
    }

    public void setKeywords(String[] keywords) {
        this.keywords = keywords;
    }
    
    public int getShares() {
        return shares;
    }

    public void setShares(int shares) {
        this.shares = shares;
    }

    public String getReference() {
        return reference;
    }

    public void setReference(String reference) {
        this.reference = reference;
    }

    @Override
    public String toJSONString() {
        Gson gson = new GsonBuilder()
                .excludeFieldsWithoutExposeAnnotation()
                .create();
        return gson.toJson(this);
    }

    @Override
    public int compareTo(WebPage o) {
        if (o.getShares() > getShares()) {
            return 1;
        }
        return -1;
    }

  
}

@@ -678,24 +678,138 @@
 edUrl;%0A    %0A
+%09// The expanded version of URL%0A    @Expose%0A    @SerializedName(value = %22domain%22)%0A    private String domain;%0A    %0A
     // The t
@@ -1037,24 +1037,311 @@
  text;%0A    %0A
+    // A flag that indicates whether this web page contains an article%0A    @Expose%0A    @SerializedName(value = %22article%22)%0A    private boolean article;%0A    %0A    // Number of media contained in this web page%0A    @Expose%0A    @SerializedName(value = %22media%22)%0A    private int media = 0;%0A    %0A
     // The t
@@ -2573,32 +2573,183 @@
 ndedUrl;%0A    %7D%0A%0A
+    public String getDomain() %7B%0A        return this.domain;%0A    %7D%0A%0A    public void setDomain(String domain) %7B%0A        this.domain = domain;%0A    %7D%0A    %0A
     public Strin
@@ -3278,32 +3278,316 @@
  = text;%0A    %7D%0A%0A
+    public Boolean isArticle() %7B%0A        return article;%0A    %7D%0A%0A    public void setArticle(Boolean article) %7B%0A        this.article = article;%0A    %7D%0A%0A%0A    public int getMedia() %7B%0A        return media;%0A    %7D%0A%0A    public void setMedia(int media) %7B%0A        this.media = media;%0A    %7D%0A    %0A
     public Strin
@@ -4020,32 +4020,178 @@
 ference;%0A    %7D%0A%0A
+    public String getStatus() %7B%0A        return status;%0A    %7D%0A%0A    public void setStatus(String status) %7B%0A        this.status = status;%0A    %7D%0A    %0A
     @Override%0A  

Add fields in WebPage