package eu.socialsensor.framework.client.search.solr;

import eu.socialsensor.framework.common.domain.WebPage;

import java.net.MalformedURLException;
import java.util.Date;

import org.apache.solr.client.solrj.beans.Field;

/**
 *
 * @author etzoannos - e.tzoannos@atc.gr
 */
public class SolrWebPage {
	
	@Field(value = "url")
	private String url;

	@Field(value = "expandedUrl")
	private String expandedUrl;
	
	@Field(value = "domain")
	private String domain;
	
	@Field(value = "title")
	private String title;
	
	@Field(value = "text")
	private String text;
	
	@Field(value = "date")
	private Date date;

	@Field(value = "reference")
	private String reference;

	@Field(value = "streamId")
	private String streamId;	
	
	@Field(value = "shares")
	private int shares;	
	
	@Field(value = "media")
	private int media;	
	
	@Field(value = "mediaIds")
	private String[] mediaIds;	
	
	
	public SolrWebPage() {
		
	}

	public SolrWebPage(WebPage webPage) {
        url = webPage.getUrl();
        expandedUrl = webPage.getExpandedUrl();
        domain = webPage.getDomain();
        title = webPage.getTitle();
        text = webPage.getText();
        date = webPage.getDate();
        reference = webPage.getReference();
        streamId = webPage.getStreamId();
        shares = webPage.getShares();
        media = webPage.getMedia();
        mediaIds = webPage.getMediaIds();
    }

    public WebPage toWebPage() throws MalformedURLException {

    	WebPage webPage = new WebPage(url, reference);

    	webPage.setExpandedUrl(expandedUrl);
    	webPage.setTitle(title);
    	webPage.setText(text);
    	webPage.setStreamId(streamId);
    	webPage.setDate(date);
    	webPage.setDomain(domain);
    	webPage.setShares(shares);
    	webPage.setMedia(media);
    	webPage.setMediaIds(mediaIds);
    	
        return webPage;
    }
    
    
    public String getUrl() {
    	return url;
	}
    
    public String getTitle() {
    	return title;
	}
    
    public Date getDate() {
    	return date;
	}
    
    public String getReference() {
    	return reference;
	}

    public String getStreamId() {
    	return streamId;
	}
	
    public int getShares() {
    	return shares;
	}
    
}

@@ -226,11 +226,8 @@
 /**%0A
- *%0A
  * @
@@ -263,16 +263,16 @@
 @atc.gr%0A
+
  */%0Apubl
@@ -869,16 +869,83 @@
 Ids;%09%0A%09%0A
+%09@Field(value = %22mediaThumbnail%22)%0A%09private String mediaThumbnail;%09%0A
 %09%0A%09publi
@@ -1428,24 +1428,78 @@
 MediaIds();%0A
+        mediaThumbnail = webPage.getMediaThumbnail();%0A
     %7D%0A%0A    p
@@ -1899,24 +1899,72 @@
 (mediaIds);%0A
+    %09webPage.setMediaThumbnail(mediaThumbnail);%0A
     %09%0A      
@@ -1992,21 +1992,16 @@
  %7D%0A    %0A
-    %0A
     publ
@@ -2038,32 +2038,162 @@
 rn url;%0A%09%7D%0A    %0A
+    public String getExpandedUrl() %7B%0A    %09return expandedUrl;%0A%09%7D%0A    %0A    public String getDomain() %7B%0A    %09return domain;%0A%09%7D%0A    %0A
     public Strin
@@ -2463,15 +2463,215 @@
 res;%0A%09%7D%0A
-
     %0A
+    public int getNumberOfMedia() %7B%0A    %09return media;%0A%09%7D%0A    %0A    public String%5B%5D getMediaIds() %7B%0A    %09return mediaIds;%0A%09%7D%0A    %0A    public String getMediaThumbnail() %7B%0A    %09return mediaThumbnail;%0A%09%7D%0A
 %7D%0A

Add media thumbnail