package  eu.dnetlib.data.claims.migration;

import com.google.gson.annotations.SerializedName;

import java.util.Date;

public class ClaimGenerics<S extends Object, T extends Object> {

	@SerializedName("@context")
	private final String context = "https://dl.dropboxusercontent.com/u/19168406/oa-openaire.jsonld";

	@SerializedName("@type")
	private final String type = "oa:Annotation";
			
	@SerializedName("@id")
	private String id;
	
	@SerializedName("annotatedBy")
	private Person person = new Person();

	private Date date;
    private String sourceType;
    private String targetType;

	@SerializedName("hasTarget")
	private T target;
	@SerializedName("hasSource")
	private S body;
	
	public T getTarget() {
		return target;
	}

	public void setTarget(T target) {
		this.target = target;
	}

	public S getBody() {
		return body;
	}

	public void setBody(S body) {
		this.body = body;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = "http://www.openaire.eu/annotations/" + id;
	}

//	public String getUserMail() {
//		return userMail;
//	}

	public void setUserMail(String userMail) {
//		this.userMail = userMail;
		this.person.setId(userMail.split("@")[0]);
		this.person.getMbox().setId(userMail);
	}
    public String getUserMail() {
        return this.person.getMbox().getId();
    }
	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

    public String getSourceType() {
        return sourceType;
    }

    public void setSourceType(String sourceType) {
        this.sourceType = sourceType;
    }

    public String getTargetType() {
        return targetType;
    }

    public void setTargetType(String targetType) {
        this.targetType = targetType;
    }

    public void getClaimFromDB() {
		// query rel2action
		// parse to get ids;
	}

    @Override
    public String toString() {
        return "ClaimGenerics{" +
                "\ntarget=" + target.toString() +
                ",\n body=" + body.toString() +
                ", \nid='" + id + '\'' +
//                ", userMail='" + userMail + '\'' +
                ", date=" + date +
                '}';
    }
    private class Person {
    	@SerializedName("@id")
    	private String id;
    	
    	@SerializedName("@type")
    	private final String type = "foaf:Person";
    	
    	private Mbox mbox = new Mbox();
    	
		public String getId() {
			return id;
		}

		public void setId(String id) {
			this.id = "http://www.openaire.eu/people/"+id;
		}

		public Mbox getMbox() {
			return mbox;
		}
		
		public void setMbox(Mbox mbox) {
			this.mbox = mbox;
		}
    	
    	private class Mbox {
    		
    		@SerializedName("@id")
    		private String id;

			public String getId() {
				return id;
			}

			public void setId(String id) {
				this.id = "mailto:" + id;
			}
    		
    	}
    }
    
}

