@@ -0,0 +1,3273 @@
+package org.hisp.dhis.android.core.datavalue;%0A%0Aimport android.database.Cursor;%0Aimport android.database.sqlite.SQLiteStatement;%0A%0Aimport org.hisp.dhis.android.core.common.State;%0Aimport org.hisp.dhis.android.core.data.database.DatabaseAdapter;%0Aimport org.hisp.dhis.android.core.utils.StoreUtils;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Collection;%0A%0Apublic class DataValueSetStore %7B%0A%0A    private static final String QUERY_WITH_STATE = %22SELECT %22 +%0A            DataValueModel.Columns.DATA_ELEMENT + %22,%22 +%0A            DataValueModel.Columns.PERIOD + %22,%22 +%0A            DataValueModel.Columns.ORGANISATION_UNIT + %22,%22 +%0A            DataValueModel.Columns.VALUE +%0A            %22 FROM %22 +%0A            DataValueModel.TABLE +%0A            %22 WHERE %22 +%0A            DataValueModel.Columns.STATE +%0A            %22 = ':state'%22;%0A%0A    private static final String UPDATE_STATE = %22UPDATE %22%0A            + DataValueModel.TABLE +%0A            %22 SET %22 +%0A            DataValueModel.Columns.STATE + %22 = ? %22 +%0A            %22 WHERE %22 +%0A            DataValueModel.Columns.DATA_ELEMENT + %22 = ?;%22;%0A%0A%0A    private final DatabaseAdapter databaseAdapter;%0A    private final SQLiteStatement updateStateStatement;%0A%0A%0A    public DataValueSetStore(DatabaseAdapter databaseAdapter) %7B%0A%0A        this.databaseAdapter = databaseAdapter;%0A        this.updateStateStatement = databaseAdapter.compileStatement(UPDATE_STATE);%0A    %7D%0A%0A    public Collection%3CDataValue%3E getDataValuesWithState(State state) %7B%0A        return queryDataValuesWithState(state);%0A    %7D%0A%0A    private Collection%3CDataValue%3E queryDataValuesWithState(State state) %7B%0A%0A        String query = QUERY_WITH_STATE.replace(%22:state%22, state.name());%0A%0A        Cursor cursor = databaseAdapter.query(query);%0A%0A        return map(cursor);%0A    %7D%0A%0A    private Collection%3CDataValue%3E map(Cursor cursor) %7B%0A%0A        Collection%3CDataValue%3E dataValues = new ArrayList%3C%3E();%0A%0A        cursor.moveToFirst();%0A%0A        if (cursor.getCount() %3E 0) %7B%0A%0A            do %7B%0A%0A                DataValue dataValue = DataValue.create(%0A                        cursor.getString(0),%0A                        cursor.getString(1),%0A                        cursor.getString(2),%0A                        null,%0A                        null,%0A                        cursor.getString(3),%0A                        null,%0A                        null,%0A                        null,%0A                        null,%0A                        null,%0A                        null%0A                );%0A%0A                dataValues.add(dataValue);%0A%0A            %7D while(cursor.moveToNext());%0A        %7D%0A%0A        return dataValues;%0A    %7D%0A%0A    /**%0A     * @param dataElementUid UID from the DataElement related to the DataValue you want to set%0A     * @param newState The new state to be set for the DataValue%0A     *%0A     * @return True if any DataValue has been updated%0A     */%0A    @SuppressWarnings(%22PMD.UselessParentheses%22)%0A    public boolean setState(String dataElementUid, State newState) %7B%0A%0A        StoreUtils.sqLiteBind(updateStateStatement, 1, newState.name());%0A        StoreUtils.sqLiteBind(updateStateStatement, 2, dataElementUid);%0A%0A        int updatedRows = databaseAdapter.executeUpdateDelete(DataValueModel.TABLE, updateStateStatement);%0A        updateStateStatement.clearBindings();%0A%0A        return (updatedRows %3E 0);%0A    %7D%0A%7D%0A

Add DB store for DataValueSets