package info.nightscout.androidaps.data;

import android.content.Context;

import com.rits.cloning.Cloner;

import org.json.JSONObject;

import java.util.Date;

import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.Source;

/**
 * Created by mike on 29.05.2017.
 */

public class DetailedBolusInfo {
    public long date = System.currentTimeMillis();
    public String eventType = CareportalEvent.MEALBOLUS;
    public double insulin = 0;
    public double carbs = 0;
    public int source = Source.NONE;
    public boolean isValid = true;
    public double glucose = 0;             // Bg value in current units
    public String glucoseType = "";        // NS values: Manual, Finger, Sensor
    public int carbTime = 0;               // time shift of carbs in minutes
    public JSONObject boluscalc = null;    // additional bolus wizard info
    public Context context = null;         // context for progress dialog
    public long pumpId = 0;                // id of record if comming from pump history (not a newly created treatment)
    public boolean isSMB = false;          // is a Super-MicroBolus
    public long deliverAt = 0;             // SMB should be delivered within 1 min from this time

    public DetailedBolusInfo copy() {
        Cloner cloner = new Cloner();
        return cloner.deepClone(this);
    }

    @Override
    public String toString() {
        return new Date(date).toLocaleString() +
                " insulin: " + insulin +
                " carbs: " + carbs +
                " isValid: " + isValid +
                " carbTime: " + carbTime +
                " isSMB: " + isSMB +
                " deliverAt: " + new Date(deliverAt).toLocaleString();
    }
}

@@ -1285,75 +1285,481 @@
     
-Cloner cloner = new Cloner();%0A        return cloner.deepClone(this)
+DetailedBolusInfo n = new DetailedBolusInfo();%0A        n.date = date;%0A        n.eventType = eventType;%0A        n.insulin = insulin;%0A        n.carbs = carbs;%0A        n.source = source;%0A        n.isValid = isValid;%0A        n.glucose = glucose;%0A        n.glucoseType = glucoseType;%0A        n.carbTime = carbTime;%0A        n.boluscalc = boluscalc;%0A        n.context = context;%0A        n.pumpId = pumpId;%0A        n.isSMB = isSMB;%0A        n.deliverAt = deliverAt;%0A        return n
 ;%0A  

revert DetailedBulusInflo cloning