package es.uv.garcosda.domain;


import org.springframework.data.annotation.Id;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class Document {
	
	@Id
	@JsonProperty("id")
	private Integer id;
	
	@JsonProperty("title")
	private String title;
	
	@JsonProperty("publisher")
	private String publisher;
	
	@JsonProperty("author")
	private String author;
	
	@JsonProperty("date_add")
	private String date_add;
	
	@JsonProperty("content")
	private String content;
	
	public Document() {}
	
	public Document(Integer id, String title, String publisher, String author, String date_add, String content) {
		this.id = id;
		this.title = title;
		this.publisher = publisher;
		this.author = author;
		this.date_add = date_add;
		this.content = content;
	}
	
	public Document(String title, String publisher, String author, String date_add, String content) {
		this.title = title;
		this.publisher = publisher;
		this.author = author;
		this.date_add = date_add;
		this.content = content;
	}

	public Integer getId() {
		return id;
	}

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

	public String getTitle() {
		return title;
	}

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

	public String getPublisher() {
		return publisher;
	}

	public void setPublisher(String publisher) {
		this.publisher = publisher;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getDateAdd() {
		return date_add;
	}

	public void setDateAdd(String date_add) {
		this.date_add = date_add;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}
	
	public String toString() {
		ObjectMapper objectMapper = new ObjectMapper();
		try {
			return objectMapper.writeValueAsString(this);
		} catch (JsonProcessingException e) {
			e.printStackTrace();
			return "";
		}
	}
	
}
