Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added Client Migration for changing the validation status to Invalid #2109

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ allprojects {
maven { url "https://cloudant.github.io/cloudant-sync-eap/repository" }
maven { url 'https://maven.fabric.io/public' }
maven { url "https://s3.amazonaws.com/repo.commonsware.com" }
maven { url 'https://nexus.pentaho.org/content/groups/omni/' }
// maven { url 'https://nexus.pentaho.org/content/groups/omni/' }
maven {
url 'https://dl.bintray.com/ibm-watson-health/ibm-fhir-server-releases'
content {
Expand All @@ -74,7 +74,7 @@ subprojects {
ext.androidBuildToolsVersion = '29.0.3'
ext.androidMinSdkVersion = 19
ext.androidCompileSdkVersion = 29
ext.androidTargetSdkVersion = 29
ext.androidTargetSdkVersion = 31

ext.androidAnnotationsVersion = '3.0.1'
ext.androidAnnotationsAPIVersion = '3.0.1'
Expand Down
46 changes: 23 additions & 23 deletions opensrp-chw/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ android {
ba {
dimension = 'baseDimension'
applicationIdSuffix ".ba"
versionCode 8
versionName "1.0.8"
versionCode 9
versionName "1.0.9"
buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '10000'
buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '10000'
buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2'
Expand All @@ -244,13 +244,13 @@ android {
buildConfigField "String[]", "ALLOWED_LOCATION_LEVELS_DEBUG", '{"Ward", "MOH Jhpiego Facility Name", "Health Facility", "Village", "Village Sublocations"}'
buildConfigField "String", 'DEFAULT_LOCATION', '"Village Sublocations"'
buildConfigField "String", 'DEFAULT_LOCATION_DEBUG', '"Village"'
buildConfigField "int", "DATABASE_VERSION", '23'
buildConfigField "int", "DATABASE_VERSION", '24'
}
chad {
dimension = 'baseDimension'
applicationIdSuffix ".chad"
versionCode 3
versionName "1.0.3"
versionCode 4
versionName "1.0.4"
buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '10000'
buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '10000'
buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2'
Expand All @@ -262,18 +262,18 @@ android {
buildConfigField "String[]", "ALLOWED_LOCATION_LEVELS_DEBUG", '{"Clinic" , "CHSS" , "CHA"}'
buildConfigField "String", 'DEFAULT_LOCATION', '"Village"'
buildConfigField "String", 'DEFAULT_LOCATION_DEBUG', '"CHA"'
buildConfigField "int", "DATABASE_VERSION", '15'
buildConfigField "int", "DATABASE_VERSION", '16'
buildConfigField "int", "MAX_CONNECTION_TIMEOUT", '5'
buildConfigField "int", "MAX_READ_TIMEOUT", '5'
}
drc {
resConfigs "en", "fr"
dimension = 'baseDimension'
applicationIdSuffix ".drc"
versionCode 11
versionName "1.0.16"
buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '10000'
buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '10000'
versionCode 12
versionName "1.0.17"
buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '10'
buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '10'
buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2'
buildConfigField "String", 'opensrp_url', '"https://wcaro-cd.smartregister.org/opensrp/"'
buildConfigField "String", 'guidebooks_url', '"https://opensrp.s3.amazonaws.com/media/drc/"'
Expand All @@ -286,13 +286,13 @@ android {
buildConfigField "String", 'DEFAULT_LOCATION', '"VILLAGE/COMMUNAUTE"'
buildConfigField "int", "MAX_CONNECTION_TIMEOUT", '5'
buildConfigField "int", "MAX_READ_TIMEOUT", '5'
buildConfigField "int", "DATABASE_VERSION", '12'
buildConfigField "int", "DATABASE_VERSION", '13'
}
guinea {
dimension = 'baseDimension'
applicationIdSuffix ".guinea"
versionCode 4
versionName "1.0.3"
versionCode 5
versionName "1.0.4"
buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2'
buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '1000'
buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '500'
Expand All @@ -307,13 +307,13 @@ android {
buildConfigField "String", 'DEFAULT_LOCATION_PREVIEW', '"Village"'
buildConfigField "String", 'DEFAULT_LOCATION_DEBUG', '"CHW"'
buildConfigField "String", 'DEFAULT_LOCATION', '"Village"'
buildConfigField "int", "DATABASE_VERSION", '8'
buildConfigField "int", "DATABASE_VERSION", '9'
}
togo {
dimension = 'baseDimension'
applicationIdSuffix ".togo"
versionCode 26
versionName "1.2.7"
versionCode 27
versionName "1.2.8"
buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2'
buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '1000'
buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '500'
Expand All @@ -327,12 +327,12 @@ android {
buildConfigField "String", 'DEFAULT_LOCATION', '"Village"'
buildConfigField "int", "MAX_CONNECTION_TIMEOUT", '10'
buildConfigField "int", "MAX_READ_TIMEOUT", '10'
buildConfigField "int", "DATABASE_VERSION", '21'
buildConfigField "int", "DATABASE_VERSION", '22'
}
liberia {
dimension = 'baseDimension'
versionCode 8
versionName "1.0.1"
versionCode 9
versionName "1.0.2"
buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '10000'
Comment on lines +334 to 336
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what's the difference between liberia and LMH

buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '10000'
buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2'
Expand All @@ -346,13 +346,13 @@ android {
buildConfigField "String", 'DEFAULT_LOCATION_DEBUG', '"CHA"'
buildConfigField "int", "MAX_CONNECTION_TIMEOUT", '5'
buildConfigField "int", "MAX_READ_TIMEOUT", '5'
buildConfigField "int", "DATABASE_VERSION", '8'
buildConfigField "int", "DATABASE_VERSION", '9'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
lmh {
dimension = 'baseDimension'
applicationIdSuffix ".lmh"
versionCode 7
versionName "2.0.3"
versionCode 8
versionName "2.0.4"
buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '10000'
buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '10000'
buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '1'
Expand All @@ -364,7 +364,7 @@ android {
buildConfigField "String[]", "ALLOWED_LOCATION_LEVELS_DEBUG", '{"Country" , "County" , "District", "Clinics", "CHSS", "Village","Commune"}'
buildConfigField "String", 'DEFAULT_LOCATION', '"Commune"'
buildConfigField "String", 'DEFAULT_LOCATION_DEBUG', '"Commune"'
buildConfigField "int", "DATABASE_VERSION", '7'
buildConfigField "int", "DATABASE_VERSION", '8'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public static void onUpgrade(Context context, SQLiteDatabase db, int oldVersion,
case 23:
upgradeToVersion23(context, db);
break;
case 24:
upgradeToVersion24(db);
break;
default:
break;
}
Expand Down Expand Up @@ -371,4 +374,8 @@ private static void upgradeToVersion23(Context context, SQLiteDatabase db) {
}
}

private static void upgradeToVersion24(SQLiteDatabase db) {
RepositoryUtils.updateClientValidateStatus(db);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ public static void onUpgrade(Context context, SQLiteDatabase db, int oldVersion,
case 15:
upgradeToVersion15(db);
break;
case 16:
upgradeToVersion16(db);
break;
default:
break;
}
Expand Down Expand Up @@ -223,4 +226,8 @@ private static void initializeIndicatorDefinitions(ReportingLibrary reportingLib
reportingLibrary.readConfigFile(configFile, sqLiteDatabase);
}
}

private static void upgradeToVersion16(SQLiteDatabase db) {
RepositoryUtils.updateClientValidateStatus(db);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,15 @@ public static void onUpgrade(Context context, SQLiteDatabase db, int oldVersion,
case 12:
upgradeToVersion12(db);
break;
case 13:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make these changes for all the flavours

  • DB migrations

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ekigamba different flavors use different DB versions for instance ba is at version 23 chad using 15 drc using 13 and so on should i upgrade all the versions to the same value?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, we should upgrade all the versions but to different values

upgradeToVersion13(db);
break;
default:
break;
}
upgradeTo++;
}
RepositoryUtils.updateClientValidateStatus(db);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this since it is repetitive

}

private static void upgradeToVersion2(Context context, SQLiteDatabase db) {
Expand Down Expand Up @@ -165,4 +169,8 @@ private static void upgradeToVersion11(SQLiteDatabase db) {
private static void upgradeToVersion12(SQLiteDatabase db) {
RepositoryUtils.updateNullEventIds(db);
}

private static void upgradeToVersion13(SQLiteDatabase db) {
RepositoryUtils.updateClientValidateStatus(db);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public static void onUpgrade(Context context, SQLiteDatabase db, int oldVersion,
case 8:
upgradeToVersion8(db);
break;
case 9:
upgradeToVersion9(db);
break;
default:
break;
}
Expand Down Expand Up @@ -158,5 +161,9 @@ private static void upgradeToVersion7(SQLiteDatabase db) {
}
}

private static void upgradeToVersion9(SQLiteDatabase db) {
RepositoryUtils.updateClientValidateStatus(db);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public static void onUpgrade(Context context, SQLiteDatabase db, int oldVersion,
case 8:
upgradeToVersion8(db);
break;
case 9:
upgradeToVersion9(db);
default:
break;
}
Expand Down Expand Up @@ -152,6 +154,10 @@ private static void upgradeToVersion7(SQLiteDatabase db) {
}

private static void upgradeToVersion8(SQLiteDatabase db) {
RepositoryUtils.updateNullEventIds(db);
RepositoryUtils.updateNullEventIds(db);
}

private static void upgradeToVersion9(SQLiteDatabase db) {
RepositoryUtils.updateClientValidateStatus(db);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public static void onUpgrade(Context context, SQLiteDatabase db, int oldVersion,
case 7:
upgradeToVersion7(db);
break;
case 8:
upgradeToVersion8(db);
default:
break;
}
Expand Down Expand Up @@ -146,4 +148,8 @@ private static void upgradeToVersion7(SQLiteDatabase db) {
Timber.e(e, "upgradeToVersion7");
}
}

private static void upgradeToVersion8(SQLiteDatabase db) {
RepositoryUtils.updateClientValidateStatus(db);
}
}
13 changes: 12 additions & 1 deletion opensrp-chw/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@
android:name=".activity.ChildProfileActivity"
android:launchMode="singleTop"
android:label="@string/child_details"
android:theme="@style/ChwTheme.NoActionBar">
android:theme="@style/ChwTheme.NoActionBar"
android:exported="true">
<intent-filter>
<action android:name="org.smartregister.action.THINKMD_ASSESSMENT" />

Expand Down Expand Up @@ -170,6 +171,7 @@
android:roundIcon="@drawable/ic_launcher_round"
android:screenOrientation="portrait"
android:theme="@style/ChwTheme.Login"
android:exported="true"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down Expand Up @@ -301,6 +303,15 @@
<service android:name=".core.service.StockUsageReportService" />
<service android:name="org.smartregister.growthmonitoring.service.intent.WeightForHeightIntentService" />


<receiver android:name="io.ona.kujaku.receivers.KujakuNetworkChangeReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
</intent-filter>
</receiver>

<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public interface RepositoryUtils {

String EVENT_ID = "id";
String _ID = "_id";
String VALIDATION_STATUS = "validationStatus";
String STATUS_INVALID = "Invalid";

String ADD_MISSING_REPORTING_COLUMN = "ALTER TABLE 'indicator_queries' ADD COLUMN expected_indicators TEXT NULL;";
String FAMILY_MEMBER_ADD_REASON_FOR_REGISTRATION = "ALTER TABLE 'ec_family_member' ADD COLUMN reasons_for_registration TEXT NULL;";
Expand Down Expand Up @@ -132,4 +134,9 @@ static String getEventId(String jsonString) {
return eventId;
}

static void updateClientValidateStatus (SQLiteDatabase db)
{
db.execSQL(String.format("UPDATE client Set %s = '%s'",VALIDATION_STATUS,STATUS_INVALID));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.smartregister.chw.repository;

import net.sqlcipher.database.SQLiteDatabase;

import org.junit.Test;
import org.mockito.Mockito;
import org.smartregister.immunization.repository.VaccineRepository;

import static org.mockito.Mockito.verify;


public class ChwRepositoryFlvTest {

@Test
public void testOnUpgrade() {
SQLiteDatabase db = Mockito.mock(SQLiteDatabase.class);
ChwRepositoryFlv.onUpgrade(null, db, 1, 2);
verify(db).execSQL(VaccineRepository.UPDATE_TABLE_ADD_EVENT_ID_COL);
verify(db).execSQL(VaccineRepository.EVENT_ID_INDEX);
verify(db).execSQL(VaccineRepository.UPDATE_TABLE_ADD_FORMSUBMISSION_ID_COL);
verify(db).execSQL(VaccineRepository.FORMSUBMISSION_INDEX);
verify(db).execSQL(VaccineRepository.UPDATE_TABLE_ADD_OUT_OF_AREA_COL);
verify(db).execSQL(VaccineRepository.UPDATE_TABLE_ADD_OUT_OF_AREA_COL_INDEX);
verify(db).execSQL(VaccineRepository.UPDATE_TABLE_ADD_HIA2_STATUS_COL);


}
}
Loading