package tutorial.rest.resources;

import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.ArrayList;
import java.util.HashMap;
import org.springframework.hateoas.ResourceSupport;
import tutorial.core.models.entities.ActiveIngredient;

/**
 * 
 * @author Xavier
 */
public class ActiveIngredientResource extends ResourceSupport {

    private String name;
    private String counterIndication;
    private String caution;

    private String monitoringYes;
    private String monitoringNo;
    private String adjustmentsYes;
    private String adjustmentsNo;
    private String symptoms;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCounterIndication() {
        return counterIndication;
    }

    public void setCounterIndication(String counterIndication) {
        this.counterIndication = counterIndication;
    }

    public String getCaution() {
        return caution;
    }

    public String getMonitoringYes() {
        return monitoringYes;
    }

    public void setMonitoringYes(String monitoringYes) {
        this.monitoringYes = monitoringYes;
    }

    public String getMonitoringNo() {
        return monitoringNo;
    }

    public void setMonitoringNo(String monitoringNo) {
        this.monitoringNo = monitoringNo;
    }

    public String getAdjustmentsYes() {
        return adjustmentsYes;
    }

    public void setAdjustmentsYes(String adjustmentsYes) {
        this.adjustmentsYes = adjustmentsYes;
    }

    public String getAdjustmentsNo() {
        return adjustmentsNo;
    }

    public void setAdjustmentsNo(String adjustmentsNo) {
        this.adjustmentsNo = adjustmentsNo;
    }

    public String getSymptoms() {
        return symptoms;
    }

    public void setSymptoms(String symptoms) {
        this.symptoms = symptoms;
    }

    public void setCaution(String caution) {
        this.caution = caution;
    }

    
    public ActiveIngredient toActiveIngredient() {
        ActiveIngredient activeIngredient = new ActiveIngredient();
        activeIngredient.setName(name);
        activeIngredient.setCounterIndication(counterIndication);
        activeIngredient.setCaution(caution);
        activeIngredient.setMonitoringYes(monitoringYes);
        activeIngredient.setMonitoringNo(monitoringNo);
        activeIngredient.setAdjustmentsYes(adjustmentsYes);
        activeIngredient.setAdjustmentsNo(adjustmentsNo);
        activeIngredient.setSymptoms(symptoms);
        return activeIngredient;
    }
    
    public ActiveIngredient setValuesFromHashMap(HashMap<String, String> values){
        ActiveIngredient activeIngredient = new ActiveIngredient();
        ArrayList<String> names = this.getValuesName();
        activeIngredient.setName(values.get(names.get(0)));
        activeIngredient.setCounterIndication(values.get(names.get(1)));
        activeIngredient.setCaution(values.get(names.get(2)));
        activeIngredient.setMonitoringYes(values.get(names.get(3)));
        activeIngredient.setMonitoringNo(values.get(names.get(4)));
        activeIngredient.setAdjustmentsYes(values.get(names.get(5)));
        activeIngredient.setAdjustmentsNo(values.get(names.get(6)));
        if(values.size()>7){
            activeIngredient.setSymptoms(values.get(names.get(7)));
        }
        return activeIngredient;
    }
    
    @JsonIgnore
    public ArrayList<String> getValuesName(){
        ArrayList<String> names = new ArrayList<String>();
        names.add("name");
        names.add("counterIndication");
        names.add("caution");
        names.add("monitoringYes");
        names.add("monitoringNo");
        names.add("adjustmentsYes");
        names.add("adjustmentsNo");
        names.add("symptoms");
        return names;
    }
}
