package eu.dnetlib.data.claims.entity;

import eu.dnetlib.data.claims.utils.ClaimUtils;

import java.util.TreeMap;

/**
 * Created by kiatrop on 20/11/2015.
 */
public class Result implements  OpenaireEntity{
    private String title;
    private TreeMap<String, String> authors = new TreeMap<String, String>();

//external url: url+doi (if doi exists) or url from websources
    private String externalUrl;
    private String openaireId;
    private String doi;
    private String orcidworkid;
    private String pmcid;
    //accessRights : set by user
    private String accessRights;
    //bestLicence : from search
    private String bestLicense;

    private String collectedFrom;
    private String metadataRecord;

//for the metadataRecord file
    private String recordPath;
    private String recordFormat;

    private String resultType;
//    private boolean found=false;
    private String embargoEndDate;

//Used for Datacite
    private String oai;
    private String provenanceaction;

    public TreeMap<String, String> getAuthors() {
        return authors;
    }

    public void setAuthors(TreeMap<String, String> authors) {
        this.authors = authors;
    }

    public String getDoi() {
		return doi;
	}

	public void setDoi(String doi) {
		this.doi = doi;
	}

	public String getTitle() {
        return title;
    }

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

    public String getExternalUrl() {
        return externalUrl;
    }

    public void setExternalUrl(String externalUrl) {
        this.externalUrl = externalUrl;
    }

    public String getOpenaireId() {
        return openaireId;
    }

    public void setOpenaireId(String openaire_id) {
        this.openaireId = openaire_id;
    }

    public String getAccessRights() {
        return accessRights;
    }

    public void setAccessRights(String accessRights) {
        this.accessRights = accessRights;
    }

    public String getBestLicense() {
        return bestLicense;
    }

    public void setBestLicense(String bestLicense) {
        this.bestLicense = bestLicense;
    }

    public String getCollectedFrom() {
        return collectedFrom;
    }

    public void setCollectedFrom(String collectedFrom) {
        if(!collectedFrom.contains("____::")) {
            if (collectedFrom.equals("Datacite")) {
                collectedFrom = ClaimUtils.COLLECTED_FROM_DATACITE;

            } else if (collectedFrom.equals("Crossref")) {
                collectedFrom = ClaimUtils.COLLECTED_FROM_CROSSREF;

            } else if (collectedFrom.equals("Orcid")) {
                collectedFrom = ClaimUtils.COLLECTED_FROM_ORCID;

            } else {
                collectedFrom = ClaimUtils.COLLECTED_FROM_OPENAIRE;
            }
        }
        this.collectedFrom = collectedFrom;
    }

    public String getMetadataRecord() {
        return metadataRecord;
    }

    public void setMetadataRecord(String metadataRecord) {
        this.metadataRecord = metadataRecord;
    }

    public String getResultType() {
        return resultType;
    }

    public void setResultType(String resultType) {
        this.resultType = resultType;
    }



/*    public boolean isFound() {
        return found;
    }

    public void setFound(boolean found) {
        this.found = found;
    }*/

    public String getPmcid() {
        return pmcid;
    }

    public void setPmcid(String pmcid) {
        this.pmcid = pmcid;
    }

    public String getOrcidworkid() {
        return orcidworkid;
    }

    public void setOrcidworkid(String orcidworkid) {
        this.orcidworkid = orcidworkid;
    }

    public String getEmbargoEndDate() {
        return embargoEndDate;
    }

    public void setEmbargoEndDate(String embargoEndDate) {
        this.embargoEndDate = embargoEndDate;
    }

    public String getOai() {
        return oai;
    }

    public void setOai(String oai) {
        this.oai = oai;
    }

    public String getProvenanceaction() {
        return provenanceaction;
    }

    public void setProvenanceaction(String provenanceaction) {
        this.provenanceaction = provenanceaction;
    }

    public String getRecordPath() {
        return recordPath;
    }

    public void setRecordPath(String recordPath) {
        this.recordPath = recordPath;
    }

    public String getRecordFormat() {
        return recordFormat;
    }

    public void setRecordFormat(String recordFormat) {
        this.recordFormat = recordFormat;
    }

    @Override
    public String toString() {
        return "\nResult{" +
                "title='" + title + '\'' +
                ",\n external_url='" + externalUrl + '\'' +
                ",\n openaire_id='" + openaireId + '\'' +
                ",\n doi='" + doi + '\'' +
                ",\n pmcid='" + pmcid + '\'' +
                ",\n orcidworkid='" + orcidworkid + '\'' +
                ",\n accessRights='" + accessRights + '\'' +
                ",\n embargoEndDate='" + embargoEndDate + '\'' +
                ",\n bestLicense='" + bestLicense + '\'' +
                ",\n collectedFrom='" + collectedFrom + '\'' +
                ",\n oai='" + oai + '\'' +
                ",\n provenanceaction='" + provenanceaction + '\'' +
                ",\n metadataRecord='" + ((metadataRecord!=null)?metadataRecord.substring(0,60):null) + "...\'" +
                ",\n recordPath='" + recordPath + '\'' +
                ",\n recordFormat='" + recordFormat + '\'' +
                ",\n resultType='" + resultType + '\'' +
                ",\n authors='" + authors + '\'' +
                '}';
    }
//method to ask from API of search to get the metadataRecord
    //then parse the fields
}
