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

Add F_ZEIR_ID to duplicate ids fix #902

Open
wants to merge 8 commits into
base: v5
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ opensrp-path/fabric.properties
opensrp-path/reports/
opensrp-core/reports/
opensrp-core/jacoco.exec
robolectric-deps/
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ subprojects {
ext.androidToolsBuildGradle = '4.0.0'
ext.androidBuildToolsVersion = '29.0.3'
ext.androidMinSdkVersion = 18
ext.androidCompileSdkVersion = 29
ext.androidTargetSdkVersion = 29
ext.androidCompileSdkVersion = 31
ext.androidTargetSdkVersion = 31

ext.androidAnnotationsVersion = '3.0.1'
ext.androidAnnotationsAPIVersion = '3.0.1'
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=5.1.1-SNAPSHOT
VERSION_NAME=5.1.2-SNAPSHOT
VERSION_CODE=1
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Core Application
Expand Down
7 changes: 5 additions & 2 deletions opensrp-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ afterEvaluate {
}
configurations.all {
resolutionStrategy.force 'commons-codec:commons-codec:1.10'
exclude group: 'com.evernote', module: 'android-job'
}

dependencies {
Expand All @@ -172,7 +173,9 @@ dependencies {
implementation 'org.codehaus.jackson:jackson-core-asl:1.9.13'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation "org.apache.httpcomponents:httpmime:4.5.6"
implementation ("org.apache.httpcomponents:httpmime:4.5.11"){
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
implementation group: 'commons-codec', name: 'commons-codec', version: '1.10'
implementation group: 'com.google.guava', name: 'guava', version: '24.1-jre'
implementation group: 'commons-io', name: 'commons-io', version: '2.4'
Expand Down Expand Up @@ -210,7 +213,7 @@ dependencies {
exclude group: 'com.android.support', module: 'recyclerview-v7'
}

implementation('com.evernote:android-job:1.2.6') {
implementation('com.github.devv911:android-job:1.4.5') {
exclude group: 'com.google.android', module: 'android'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public AccountAuthenticator(Context context) {

@Override
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType, String[] requiredFeatures, Bundle options) throws NetworkErrorException {

final Intent intent = new Intent(mContext, CoreLibrary.getInstance().getSyncConfiguration().getAuthenticationActivity());
intent.putExtra(AccountHelper.INTENT_KEY.ACCOUNT_TYPE, accountType);
intent.putExtra(AccountHelper.INTENT_KEY.AUTH_TYPE, authTokenType);
Expand Down Expand Up @@ -122,7 +121,6 @@ public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account

@Override
public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options) throws NetworkErrorException {

final Intent intent = new Intent(mContext, CoreLibrary.getInstance().getSyncConfiguration().getAuthenticationActivity());
intent.putExtra(AccountHelper.INTENT_KEY.AUTH_TYPE, authTokenType);
intent.putExtra(AccountHelper.INTENT_KEY.IS_NEW_ACCOUNT, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2424,6 +2424,10 @@ public DuplicateZeirIdStatus cleanDuplicateMotherIds(String[] eventTypes) throws
identifierLabel = "M_ZEIR_ID";
} else if (identifiers.has("ANC_ID")) {
identifierLabel = "ANC_ID";
} else if (identifiers.has("ANC_ID")) {
identifierLabel = "ANC_ID";
} else if (identifiers.has("F_ZEIR_ID")) {
identifierLabel = "F_ZEIR_ID";
}

identifiers.put(identifierLabel, newZeirId.replaceAll("-", ""));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ZeirIdCleanupRepository extends BaseRepository {
private static final String DUPLICATES_SQL =
"WITH duplicates AS ( " +
" WITH clients AS ( " +
" SELECT baseEntityId, COALESCE(json_extract(json, '$.identifiers.ZEIR_ID'), json_extract(json, '$.identifiers.M_ZEIR_ID'), json_extract(json, '$.identifiers.zeir_id'), json_extract(json, '$.identifiers.ANC_ID')) zeir_id " +
" SELECT baseEntityId, COALESCE(json_extract(json, '$.identifiers.ZEIR_ID'), REPLACE(json_extract(json, '$.identifiers.M_ZEIR_ID'), '-', ''), json_extract(json, '$.identifiers.zeir_id'), json_extract(json, '$.identifiers.ANC_ID'), REPLACE(json_extract(json, '$.identifiers.F_ZEIR_ID'), '-', ''), REPLACE(json_extract(json, '$.identifiers.opensrp_id'), '-', '')) zeir_id " +
" FROM client " +
" ) " +
" SELECT b.* FROM (SELECT baseEntityId, zeir_id FROM clients GROUP BY zeir_id HAVING count(zeir_id) > 1) a " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ public MatrixCursor getCursorMaxRowId() {
public void testCleanDuplicateMotherIdsShouldFixAndMarkDuplicateClientsUnSynced() throws Exception {
String DUPLICATES_SQL = "WITH duplicates AS ( " +
" WITH clients AS ( " +
" SELECT baseEntityId, COALESCE(json_extract(json, '$.identifiers.ZEIR_ID'), json_extract(json, '$.identifiers.M_ZEIR_ID'), json_extract(json, '$.identifiers.zeir_id'), json_extract(json, '$.identifiers.ANC_ID')) zeir_id " +
" SELECT baseEntityId, COALESCE(json_extract(json, '$.identifiers.ZEIR_ID'), REPLACE(json_extract(json, '$.identifiers.M_ZEIR_ID'), '-', ''), json_extract(json, '$.identifiers.zeir_id'), json_extract(json, '$.identifiers.ANC_ID'), REPLACE(json_extract(json, '$.identifiers.F_ZEIR_ID'), '-', '')) zeir_id " +
Copy link
Contributor

Choose a reason for hiding this comment

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

We should also add opensrp_id which is in use in the chw apps

" FROM client " +
" ) " +
" SELECT b.* FROM (SELECT baseEntityId, zeir_id FROM clients GROUP BY zeir_id HAVING count(zeir_id) > 1) a " +
Expand Down
3 changes: 2 additions & 1 deletion sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
android:theme="@style/AppTheme.NoActionBar"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down