@@ -0,0 +1,2975 @@
+package com.expidev.gcmapp.db;%0A%0Aimport android.content.Context;%0Aimport android.support.annotation.NonNull;%0Aimport android.util.Pair;%0A%0Aimport com.expidev.gcmapp.model.measurement.Measurement;%0Aimport com.expidev.gcmapp.utils.DatabaseOpenHelper;%0A%0Aimport org.ccci.gto.android.common.db.AbstractDao;%0Aimport org.ccci.gto.android.common.db.Mapper;%0A%0A/**%0A * Created by William.Randall on 2/17/2015.%0A */%0Apublic class MeasurementDao extends AbstractDao%0A%7B%0A    private static final Object instanceLock = new Object();%0A    private static MeasurementDao instance;%0A%0A    private static final Mapper%3CMeasurement%3E MEASUREMENT_MAPPER = new MeasurementMapper();%0A%0A    private MeasurementDao(final Context context)%0A    %7B%0A        super(DatabaseOpenHelper.getInstance(context));%0A    %7D%0A%0A    public static MeasurementDao getInstance(Context context)%0A    %7B%0A        synchronized(instanceLock)%0A        %7B%0A            if(instance == null)%0A            %7B%0A                instance = new MeasurementDao(context.getApplicationContext());%0A            %7D%0A        %7D%0A%0A        return instance;%0A    %7D%0A%0A    @NonNull%0A    @Override%0A    protected String getTable(@NonNull final Class%3C?%3E clazz)%0A    %7B%0A        if(Measurement.class.equals(clazz))%0A        %7B%0A            return Contract.Measurement.TABLE_NAME;%0A        %7D%0A%0A        return super.getTable(clazz);%0A    %7D%0A%0A    @NonNull%0A    @Override%0A    protected String%5B%5D getFullProjection(@NonNull final Class%3C?%3E clazz)%0A    %7B%0A        if(Measurement.class.equals(clazz))%0A        %7B%0A            return Contract.Measurement.PROJECTION_ALL;%0A        %7D%0A%0A        return super.getFullProjection(clazz);%0A    %7D%0A%0A    @NonNull%0A    @Override%0A    @SuppressWarnings(%22unchecked%22)%0A    protected %3CT%3E Mapper%3CT%3E getMapper(@NonNull final Class%3CT%3E clazz)%0A    %7B%0A        if(Measurement.class.equals(clazz))%0A        %7B%0A            return (Mapper%3CT%3E) MEASUREMENT_MAPPER;%0A        %7D%0A%0A        return super.getMapper(clazz);%0A    %7D%0A%0A    @NonNull%0A    @Override%0A    protected Pair%3CString, String%5B%5D%3E getPrimaryKeyWhere(@NonNull final Class%3C?%3E clazz, @NonNull final Object... key)%0A    %7B%0A        final String where;%0A%0A        if(Measurement.class.equals(clazz))%0A        %7B%0A            if(key.length != 1)%0A            %7B%0A                throw new IllegalArgumentException(%22invalid key for %22 + clazz);%0A            %7D%0A            where = Contract.Measurement.SQL_WHERE_PRIMARY_KEY;%0A        %7D%0A        else%0A        %7B%0A            return super.getPrimaryKeyWhere(clazz, key);%0A        %7D%0A%0A        return Pair.create(where, this.getBindValues(key));%0A    %7D%0A%0A    @NonNull%0A    @Override%0A    protected Pair%3CString, String%5B%5D%3E getPrimaryKeyWhere(@NonNull final Object obj)%0A    %7B%0A        if(obj instanceof Measurement)%0A        %7B%0A            return getPrimaryKeyWhere(Measurement.class, ((Measurement) obj).getMeasurementId());%0A        %7D%0A%0A        return super.getPrimaryKeyWhere(obj);%0A    %7D%0A%0A    public void saveMeasurement(Measurement measurement)%0A    %7B%0A        this.updateOrInsert(measurement, Contract.Measurement.PROJECTION_ALL);%0A    %7D%0A%7D%0A

Create dao for measurements