From e69c6c8609f898f6fc82b1744390f8140743a000 Mon Sep 17 00:00:00 2001 From: Ephraim Kigamba Date: Thu, 17 Sep 2020 17:00:14 +0300 Subject: [PATCH 001/141] Add configurable register contract - Add the configurable register contract as part of the BaseRegisterContract - Implement new method in the BaseRegisterActivity --- .../view/activity/BaseRegisterActivity.java | 9 ++- .../view/contract/BaseRegisterContract.java | 9 ++- .../ConfigurableRegisterActivityContract.java | 69 +++++++++++++++++++ .../ConfigurableRegisterFragmentContract.java | 50 ++++++++++++++ 4 files changed, 134 insertions(+), 3 deletions(-) create mode 100644 opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterActivityContract.java create mode 100644 opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterFragmentContract.java diff --git a/opensrp-app/src/main/java/org/smartregister/view/activity/BaseRegisterActivity.java b/opensrp-app/src/main/java/org/smartregister/view/activity/BaseRegisterActivity.java index 41dc7be64..139d359c1 100644 --- a/opensrp-app/src/main/java/org/smartregister/view/activity/BaseRegisterActivity.java +++ b/opensrp-app/src/main/java/org/smartregister/view/activity/BaseRegisterActivity.java @@ -29,6 +29,7 @@ import org.smartregister.util.PermissionUtils; import org.smartregister.util.Utils; import org.smartregister.view.contract.BaseRegisterContract; +import org.smartregister.view.contract.ConfigurableRegisterActivityContract; import org.smartregister.view.fragment.BaseRegisterFragment; import org.smartregister.view.viewpager.OpenSRPViewPager; @@ -41,7 +42,7 @@ * Created by keyman on 26/06/2018. */ -public abstract class BaseRegisterActivity extends SecuredNativeSmartRegisterActivity implements BaseRegisterContract.View { +public abstract class BaseRegisterActivity extends SecuredNativeSmartRegisterActivity implements BaseRegisterContract.View, ConfigurableRegisterActivityContract.View { protected OpenSRPViewPager mPager; @@ -354,4 +355,10 @@ public void setSelectedBottomBarMenuItem(int itemId) { public void setSearchTerm(String searchTerm) { mBaseFragment.setSearchTerm(searchTerm); } + + @Override + public ConfigurableRegisterActivityContract.Presenter presenter() { + initializePresenter(); + return presenter; + } } diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/BaseRegisterContract.java b/opensrp-app/src/main/java/org/smartregister/view/contract/BaseRegisterContract.java index 16a235981..a217b37f1 100644 --- a/opensrp-app/src/main/java/org/smartregister/view/contract/BaseRegisterContract.java +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/BaseRegisterContract.java @@ -11,7 +11,8 @@ * Created by keyamn on 27/06/2018. */ public interface BaseRegisterContract { - interface Presenter { + + interface Presenter extends ConfigurableRegisterActivityContract.Presenter { void registerViewConfigurations(List viewIdentifiers); @@ -22,7 +23,7 @@ interface Presenter { void updateInitials(); } - interface View { + interface View extends ConfigurableRegisterActivityContract.View { Context getContext(); @@ -44,4 +45,8 @@ interface View { void updateInitialsText(String initials); } + + interface Model extends ConfigurableRegisterActivityContract.Model { + + } } diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterActivityContract.java b/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterActivityContract.java new file mode 100644 index 000000000..ad5d82d04 --- /dev/null +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterActivityContract.java @@ -0,0 +1,69 @@ +package org.smartregister.view.contract; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import org.apache.commons.lang3.tuple.Triple; +import org.json.JSONException; +import org.json.JSONObject; +import org.smartregister.domain.db.EventClient; +import org.smartregister.domain.tag.FormTag; +import org.smartregister.opensrp.configurable.register.and.profiles.pojo.RegisterParams; + +import java.util.List; + +public interface ConfigurableRegisterActivityContract { + + interface View { + Presenter presenter(); + + } + + interface Presenter { + + void saveLanguage(String language); + + void startForm(String formName, String entityId, String metadata, String currentLocationId); + + void saveForm(String jsonString, @NonNull RegisterParams registerParams); + + Interactor createInteractor(); + } + + interface Model { + + JSONObject getFormAsJson(String formName, String entityId, + String currentLocationId) throws JSONException; + + void registerViewConfigurations(List viewIdentifiers); + + void unregisterViewConfiguration(List viewIdentifiers); + + void saveLanguage(String language); + + List processRegistration(String jsonString, FormTag formTag); + + String getLocationId(String locationName); + + String getInitials(); + } + + interface Interactor { + + void onDestroy(boolean isChangingConfiguration); + + void getNextUniqueId(Triple triple, ConfigurableRegisterActivityContract.InteractorCallBack callBack); + + void saveRegistration(@Nullable final List clientList, final String jsonString, @NonNull RegisterParams registerParams, final ConfigurableRegisterActivityContract.InteractorCallBack callBack); + + } + + interface InteractorCallBack { + + void onUniqueIdFetched(Triple triple, String entityId); + + void onNoUniqueId(); + + void onRegistrationSaved(@NonNull RegisterParams registerParams, @Nullable List clientList); + } +} diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterFragmentContract.java b/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterFragmentContract.java new file mode 100644 index 000000000..1fb5c9ab6 --- /dev/null +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterFragmentContract.java @@ -0,0 +1,50 @@ +package org.smartregister.view.contract; + +import org.json.JSONArray; +import org.smartregister.configurableviews.model.Field; +import org.smartregister.configurableviews.model.ViewConfiguration; +import org.smartregister.domain.Response; +import org.smartregister.view.contract.BaseRegisterFragmentContract; + +import java.util.List; +import java.util.Set; + +public interface ConfigurableRegisterFragmentContract { + + interface View extends BaseRegisterFragmentContract.View { + + void initializeAdapter(Set visibleColumns); + + Presenter presenter(); + + } + + interface Presenter extends BaseRegisterFragmentContract.Presenter { + + void updateSortAndFilter(List filterList, Field sortField); + + String getMainCondition(); + + String getDefaultSortQuery(); + + String getQueryTable(); + } + + interface Model { + + ViewConfiguration getViewConfiguration(String viewConfigurationIdentifier); + + Set getRegisterActiveColumns(String viewConfigurationIdentifier); + + String countSelect(String tableName, String mainCondition); + + String mainSelect(String tableName, String mainCondition); + + String getFilterText(List filterList, String filter); + + String getSortText(Field sortField); + + JSONArray getJsonArray(Response response); + + } +} From 8ea7af91df348acdae5db58ac023631ec8717ba9 Mon Sep 17 00:00:00 2001 From: Ephraim Kigamba Date: Thu, 17 Sep 2020 17:32:20 +0300 Subject: [PATCH 002/141] Add View Configuration interfaces - Add RegisterParams pojo --- .../ConfigurableRegisterFragmentContract.java | 14 +++--- .../view/contract/IBaseConfiguration.java | 18 +++++++ .../smartregister/view/contract/IField.java | 16 +++++++ .../view/contract/IResidence.java | 19 ++++++++ .../smartregister/view/contract/IView.java | 40 ++++++++++++++++ .../view/contract/IViewConfiguration.java | 31 ++++++++++++ .../view/contract/RegisterParams.java | 47 +++++++++++++++++++ 7 files changed, 177 insertions(+), 8 deletions(-) create mode 100644 opensrp-app/src/main/java/org/smartregister/view/contract/IBaseConfiguration.java create mode 100644 opensrp-app/src/main/java/org/smartregister/view/contract/IField.java create mode 100644 opensrp-app/src/main/java/org/smartregister/view/contract/IResidence.java create mode 100644 opensrp-app/src/main/java/org/smartregister/view/contract/IView.java create mode 100644 opensrp-app/src/main/java/org/smartregister/view/contract/IViewConfiguration.java create mode 100644 opensrp-app/src/main/java/org/smartregister/view/contract/RegisterParams.java diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterFragmentContract.java b/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterFragmentContract.java index 1fb5c9ab6..29e0fc434 100644 --- a/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterFragmentContract.java +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterFragmentContract.java @@ -1,8 +1,6 @@ package org.smartregister.view.contract; import org.json.JSONArray; -import org.smartregister.configurableviews.model.Field; -import org.smartregister.configurableviews.model.ViewConfiguration; import org.smartregister.domain.Response; import org.smartregister.view.contract.BaseRegisterFragmentContract; @@ -13,7 +11,7 @@ public interface ConfigurableRegisterFragmentContract { interface View extends BaseRegisterFragmentContract.View { - void initializeAdapter(Set visibleColumns); + void initializeAdapter(Set visibleColumns); Presenter presenter(); @@ -21,7 +19,7 @@ interface View extends BaseRegisterFragmentContract.View { interface Presenter extends BaseRegisterFragmentContract.Presenter { - void updateSortAndFilter(List filterList, Field sortField); + void updateSortAndFilter(List filterList, IField sortField); String getMainCondition(); @@ -32,17 +30,17 @@ interface Presenter extends BaseRegisterFragmentContract.Presenter { interface Model { - ViewConfiguration getViewConfiguration(String viewConfigurationIdentifier); + IViewConfiguration getViewConfiguration(String viewConfigurationIdentifier); - Set getRegisterActiveColumns(String viewConfigurationIdentifier); + Set getRegisterActiveColumns(String viewConfigurationIdentifier); String countSelect(String tableName, String mainCondition); String mainSelect(String tableName, String mainCondition); - String getFilterText(List filterList, String filter); + String getFilterText(List filterList, String filter); - String getSortText(Field sortField); + String getSortText(IField sortField); JSONArray getJsonArray(Response response); diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/IBaseConfiguration.java b/opensrp-app/src/main/java/org/smartregister/view/contract/IBaseConfiguration.java new file mode 100644 index 000000000..c4da0fac1 --- /dev/null +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/IBaseConfiguration.java @@ -0,0 +1,18 @@ +package org.smartregister.view.contract; + +/** + * Created by Ephraim Kigamba - nek.eam@gmail.com on 17-09-2020. + */ +public interface IBaseConfiguration { + + public String getLanguage(); + + public void setLanguage(String language); + public String getApplicationName(); + + public void setApplicationName(String applicationName); + + public boolean isEnableJsonViews(); + + public void setEnableJsonViews(boolean enableJsonViews); +} diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/IField.java b/opensrp-app/src/main/java/org/smartregister/view/contract/IField.java new file mode 100644 index 000000000..0239ef48f --- /dev/null +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/IField.java @@ -0,0 +1,16 @@ +package org.smartregister.view.contract; + +/** + * Created by Ephraim Kigamba - nek.eam@gmail.com on 17-09-2020. + */ +public interface IField { + + + String getDisplayName(); + + void setDisplayName(String displayName); + + String getDbAlias(); + + void setDbAlias(String dbAlias); +} diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/IResidence.java b/opensrp-app/src/main/java/org/smartregister/view/contract/IResidence.java new file mode 100644 index 000000000..0cf859bdf --- /dev/null +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/IResidence.java @@ -0,0 +1,19 @@ +package org.smartregister.view.contract; + +/** + * Created by Ephraim Kigamba - nek.eam@gmail.com on 17-09-2020. + */ +public interface IResidence { + + String getParent(); + + void setParent(String parent); + + int getPosition(); + + void setPosition(int position); + + String getLayoutWeight(); + + void setLayoutWeight(String layoutWeight); +} diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/IView.java b/opensrp-app/src/main/java/org/smartregister/view/contract/IView.java new file mode 100644 index 000000000..1e33da386 --- /dev/null +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/IView.java @@ -0,0 +1,40 @@ +package org.smartregister.view.contract; + +import java.util.Map; + +/** + * Created by Ephraim Kigamba - nek.eam@gmail.com on 17-09-2020. + */ +public interface IView { + + + void setParent(String parent); + + String getIdentifier(); + + void setIdentifier(String identifier); + + String getType(); + + void setType(String type); + + String getOrientation(); + + void setOrientation(String orientation); + + boolean isVisible(); + + void setVisible(boolean visible); + + String getLabel(); + + void setLabel(String label); + + IResidence getResidence(); + + void setResidence(IResidence residence); + + Map getMetadata(); + + void setMetadata(Map metadata); +} diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/IViewConfiguration.java b/opensrp-app/src/main/java/org/smartregister/view/contract/IViewConfiguration.java new file mode 100644 index 000000000..c0cf9e926 --- /dev/null +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/IViewConfiguration.java @@ -0,0 +1,31 @@ +package org.smartregister.view.contract; + +import java.util.List; +import java.util.Map; + +/** + * Created by Ephraim Kigamba - nek.eam@gmail.com on 17-09-2020. + */ +public interface IViewConfiguration { + + + String getIdentifier(); + + void setIdentifier(String identifier); + + IBaseConfiguration getMetadata(); + + void setMetadata(IBaseConfiguration metadata); + + List getViews(); + + void setViews(List views); + + Map getLabels(); + + void setLabels(Map labels); + + Map getJsonView(); + + void setJsonView(Map jsonView); +} diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/RegisterParams.java b/opensrp-app/src/main/java/org/smartregister/view/contract/RegisterParams.java new file mode 100644 index 000000000..26b7de75a --- /dev/null +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/RegisterParams.java @@ -0,0 +1,47 @@ +package org.smartregister.view.contract; + +import org.smartregister.domain.tag.FormTag; +import org.smartregister.repository.BaseRepository; + +public class RegisterParams { + + private String status = BaseRepository.TYPE_Unsynced; + + private boolean editMode; + + private boolean saved; + + private FormTag formTag; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public boolean isEditMode() { + return editMode; + } + + public void setEditMode(boolean editMode) { + this.editMode = editMode; + } + + public boolean isSaved() { + return saved; + } + + public void setSaved(boolean saved) { + this.saved = saved; + } + + public FormTag getFormTag() { + return formTag; + } + + public void setFormTag(FormTag formTag) { + this.formTag = formTag; + } +} From 198bd4ccfa9824287cb0458cfacee65356198c6d Mon Sep 17 00:00:00 2001 From: Ephraim Kigamba Date: Fri, 18 Sep 2020 11:26:06 +0300 Subject: [PATCH 003/141] Include configurable register contract in base register --- .../view/contract/BaseRegisterFragmentContract.java | 8 ++++++-- .../ConfigurableRegisterActivityContract.java | 1 - .../ConfigurableRegisterFragmentContract.java | 4 ++-- .../view/contract/IBaseConfiguration.java | 13 +++++++------ .../view/fragment/BaseRegisterFragment.java | 13 +++++++++++++ 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/BaseRegisterFragmentContract.java b/opensrp-app/src/main/java/org/smartregister/view/contract/BaseRegisterFragmentContract.java index a42a50372..ea1609098 100644 --- a/opensrp-app/src/main/java/org/smartregister/view/contract/BaseRegisterFragmentContract.java +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/BaseRegisterFragmentContract.java @@ -4,7 +4,7 @@ public interface BaseRegisterFragmentContract { - interface View { + interface View extends ConfigurableRegisterFragmentContract.View { void initializeQueryParams(String tableName, String countSelect, String mainSelect); @@ -29,7 +29,7 @@ interface View { void setTotalPatients(); } - interface Presenter { + interface Presenter extends ConfigurableRegisterFragmentContract.Presenter { void processViewConfigurations(); @@ -41,5 +41,9 @@ interface Presenter { } + interface Model extends ConfigurableRegisterFragmentContract.Model { + + } + } diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterActivityContract.java b/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterActivityContract.java index ad5d82d04..1463197ad 100644 --- a/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterActivityContract.java +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterActivityContract.java @@ -8,7 +8,6 @@ import org.json.JSONObject; import org.smartregister.domain.db.EventClient; import org.smartregister.domain.tag.FormTag; -import org.smartregister.opensrp.configurable.register.and.profiles.pojo.RegisterParams; import java.util.List; diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterFragmentContract.java b/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterFragmentContract.java index 29e0fc434..27e5a0929 100644 --- a/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterFragmentContract.java +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterFragmentContract.java @@ -9,7 +9,7 @@ public interface ConfigurableRegisterFragmentContract { - interface View extends BaseRegisterFragmentContract.View { + interface View { void initializeAdapter(Set visibleColumns); @@ -17,7 +17,7 @@ interface View extends BaseRegisterFragmentContract.View { } - interface Presenter extends BaseRegisterFragmentContract.Presenter { + interface Presenter { void updateSortAndFilter(List filterList, IField sortField); diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/IBaseConfiguration.java b/opensrp-app/src/main/java/org/smartregister/view/contract/IBaseConfiguration.java index c4da0fac1..0c6088174 100644 --- a/opensrp-app/src/main/java/org/smartregister/view/contract/IBaseConfiguration.java +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/IBaseConfiguration.java @@ -5,14 +5,15 @@ */ public interface IBaseConfiguration { - public String getLanguage(); + String getLanguage(); - public void setLanguage(String language); - public String getApplicationName(); + void setLanguage(String language); - public void setApplicationName(String applicationName); + String getApplicationName(); - public boolean isEnableJsonViews(); + void setApplicationName(String applicationName); - public void setEnableJsonViews(boolean enableJsonViews); + boolean isEnableJsonViews(); + + void setEnableJsonViews(boolean enableJsonViews); } diff --git a/opensrp-app/src/main/java/org/smartregister/view/fragment/BaseRegisterFragment.java b/opensrp-app/src/main/java/org/smartregister/view/fragment/BaseRegisterFragment.java index 82f4fbafd..443891796 100644 --- a/opensrp-app/src/main/java/org/smartregister/view/fragment/BaseRegisterFragment.java +++ b/opensrp-app/src/main/java/org/smartregister/view/fragment/BaseRegisterFragment.java @@ -35,9 +35,12 @@ import org.smartregister.view.activity.BaseRegisterActivity; import org.smartregister.view.activity.SecuredNativeSmartRegisterActivity; import org.smartregister.view.contract.BaseRegisterFragmentContract; +import org.smartregister.view.contract.ConfigurableRegisterFragmentContract; +import org.smartregister.view.contract.IView; import org.smartregister.view.dialog.DialogOption; import java.util.HashMap; +import java.util.Set; import timber.log.Timber; @@ -476,6 +479,16 @@ protected void refreshSyncProgressSpinner() { } } + @Override + public void initializeAdapter(Set visibleColumns) { + // Do nothing + } + + @Override + public ConfigurableRegisterFragmentContract.Presenter presenter() { + initializePresenter(); + return presenter; + } //////////////////////////////////////////////////////////////// // Inner classes From 585bcbd4e0f8393f8c7513b2fed7cd9c7f775714 Mon Sep 17 00:00:00 2001 From: Ephraim Kigamba Date: Fri, 18 Sep 2020 14:42:15 +0300 Subject: [PATCH 004/141] Code cleanup --- .../view/contract/ConfigurableRegisterFragmentContract.java | 1 - 1 file changed, 1 deletion(-) diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterFragmentContract.java b/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterFragmentContract.java index 27e5a0929..cc02b5478 100644 --- a/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterFragmentContract.java +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterFragmentContract.java @@ -2,7 +2,6 @@ import org.json.JSONArray; import org.smartregister.domain.Response; -import org.smartregister.view.contract.BaseRegisterFragmentContract; import java.util.List; import java.util.Set; From 53ba30089306b892dfbf173eaf047414f2eca7b8 Mon Sep 17 00:00:00 2001 From: Ephraim Kigamba Date: Mon, 21 Sep 2020 15:20:09 +0300 Subject: [PATCH 005/141] Add default implementation of new presenter methods --- gradle.properties | 2 +- .../ConfigurableRegisterActivityContract.java | 17 ++++++++++++----- .../ConfigurableRegisterFragmentContract.java | 8 ++++---- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/gradle.properties b/gradle.properties index c1446212c..6aa092b2c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=2.1.2-SNAPSHOT +VERSION_NAME=2.1.2.1-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Core Application diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterActivityContract.java b/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterActivityContract.java index 1463197ad..15c393226 100644 --- a/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterActivityContract.java +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterActivityContract.java @@ -15,18 +15,25 @@ public interface ConfigurableRegisterActivityContract { interface View { Presenter presenter(); - } interface Presenter { - void saveLanguage(String language); + default void saveLanguage(String language) { + + } + + default void startForm(String formName, String entityId, String metadata, String currentLocationId) { + + } - void startForm(String formName, String entityId, String metadata, String currentLocationId); + default void saveForm(String jsonString, @NonNull RegisterParams registerParams) { - void saveForm(String jsonString, @NonNull RegisterParams registerParams); + } - Interactor createInteractor(); + default Interactor createInteractor() { + return null; + } } interface Model { diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterFragmentContract.java b/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterFragmentContract.java index cc02b5478..101377c5d 100644 --- a/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterFragmentContract.java +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterFragmentContract.java @@ -18,13 +18,13 @@ interface View { interface Presenter { - void updateSortAndFilter(List filterList, IField sortField); + default void updateSortAndFilter(List filterList, IField sortField) {} - String getMainCondition(); + default String getMainCondition() { return null; } - String getDefaultSortQuery(); + default String getDefaultSortQuery() { return null; } - String getQueryTable(); + default String getQueryTable() {return null; } } interface Model { From 7086c84c3895f6c10fe178e05d7fffd1f83eaa67 Mon Sep 17 00:00:00 2001 From: Ephraim Kigamba Date: Mon, 21 Sep 2020 16:38:46 +0300 Subject: [PATCH 006/141] Add Module metadata configuration interfaces 1. Add ModuleMetadata class 2. Add LocationTagsConfiguration that holds the location tag configuration from BuildConfig 3. Add RegisterPageRowProviderMetadata class that defines what is displayed for each of the row label UIs --- .../LocationTagsConfiguration.java | 25 +++ .../configuration/ModuleMetadata.java | 164 ++++++++++++++++++ .../RegisterPageRowProviderMetadata.java | 46 +++++ 3 files changed, 235 insertions(+) create mode 100644 opensrp-app/src/main/java/org/smartregister/configuration/LocationTagsConfiguration.java create mode 100644 opensrp-app/src/main/java/org/smartregister/configuration/ModuleMetadata.java create mode 100644 opensrp-app/src/main/java/org/smartregister/configuration/RegisterPageRowProviderMetadata.java diff --git a/opensrp-app/src/main/java/org/smartregister/configuration/LocationTagsConfiguration.java b/opensrp-app/src/main/java/org/smartregister/configuration/LocationTagsConfiguration.java new file mode 100644 index 000000000..d40a84ec8 --- /dev/null +++ b/opensrp-app/src/main/java/org/smartregister/configuration/LocationTagsConfiguration.java @@ -0,0 +1,25 @@ +package org.smartregister.configuration; + +import android.support.annotation.NonNull; + +import java.util.ArrayList; +import java.util.Arrays; + +/** + * Created by Ephraim Kigamba - nek.eam@gmail.com on 21-09-2020. + */ +public interface LocationTagsConfiguration { + + @NonNull + ArrayList getAllowedLevels(); + + @NonNull + String getDefaultLocationLevel(); + + @NonNull + ArrayList getLocationLevels(); + + @NonNull + ArrayList getHealthFacilityLevels(); + +} diff --git a/opensrp-app/src/main/java/org/smartregister/configuration/ModuleMetadata.java b/opensrp-app/src/main/java/org/smartregister/configuration/ModuleMetadata.java new file mode 100644 index 000000000..d9b979e61 --- /dev/null +++ b/opensrp-app/src/main/java/org/smartregister/configuration/ModuleMetadata.java @@ -0,0 +1,164 @@ +package org.smartregister.configuration; + + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import org.smartregister.view.activity.BaseProfileActivity; +import org.smartregister.view.activity.FormActivity; + +import java.util.ArrayList; +import java.util.Set; + +/** + * Created by Ephraim Kigamba - nek.eam@gmail.com on 21-09-2020. + */ +public class ModuleMetadata { + + private String registrationFormName; + + private String tableName; + + private String registerEventType; + + private String updateEventType; + + private String config; + + private Class formActivity; + + private Class profileActivity; + + private boolean formWizardValidateRequiredFieldsBefore; + + private ArrayList locationLevels; + + private ArrayList healthFacilityLevels; + + private Set fieldsWithLocationHierarchy; + + private LocationTagsConfiguration locationTagsConfiguration; + + private String lookUpQueryForModuleClient;/* = String.format("select id as _id, %s, %s, %s, %s, %s, %s, %s, national_id from " + getTableName() + " where [condition] ", OpdConstants.KEY.RELATIONALID, OpdConstants.KEY.FIRST_NAME, + OpdConstants.KEY.LAST_NAME, OpdConstants.KEY.GENDER, OpdConstants.KEY.DOB, OpdConstants.KEY.BASE_ENTITY_ID, OpdDbConstants.KEY.OPENSRP_ID);*/ + + public ModuleMetadata(@NonNull String registrationFormName, @NonNull String tableName, @NonNull String registerEventType, @NonNull String updateEventType, @NonNull LocationTagsConfiguration locationTagsConfiguration, + @NonNull String config, @NonNull Class formActivity, @Nullable Class profileActivity, boolean formWizardValidateRequiredFieldsBefore, @NonNull String lookUpQueryForModuleClient) { + this.registrationFormName = registrationFormName; + this.tableName = tableName; + this.registerEventType = registerEventType; + this.updateEventType = updateEventType; + this.config = config; + this.formActivity = formActivity; + this.profileActivity = profileActivity; + this.formWizardValidateRequiredFieldsBefore = formWizardValidateRequiredFieldsBefore; + this.locationTagsConfiguration = locationTagsConfiguration; + this.lookUpQueryForModuleClient = lookUpQueryForModuleClient; + } + + public String getRegistrationFormName() { + return registrationFormName; + } + + public void setRegistrationFormName(String registrationFormName) { + this.registrationFormName = registrationFormName; + } + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + public String getRegisterEventType() { + return registerEventType; + } + + public void setRegisterEventType(String registerEventType) { + this.registerEventType = registerEventType; + } + + public String getUpdateEventType() { + return updateEventType; + } + + public void setUpdateEventType(String updateEventType) { + this.updateEventType = updateEventType; + } + + public String getConfig() { + return config; + } + + public void setConfig(String config) { + this.config = config; + } + + public Class getFormActivity() { + return formActivity; + } + + public void setFormActivity(Class formActivity) { + this.formActivity = formActivity; + } + + public Class getProfileActivity() { + return profileActivity; + } + + public void setProfileActivity(Class profileActivity) { + this.profileActivity = profileActivity; + } + + public boolean isFormWizardValidateRequiredFieldsBefore() { + return formWizardValidateRequiredFieldsBefore; + } + + public void setFormWizardValidateRequiredFieldsBefore(boolean formWizardValidateRequiredFieldsBefore) { + this.formWizardValidateRequiredFieldsBefore = formWizardValidateRequiredFieldsBefore; + } + + @NonNull + public ArrayList getLocationLevels() { + if (locationLevels == null) { + locationLevels = locationTagsConfiguration.getLocationLevels(); + } + + return locationLevels; + } + + public void setLocationLevels(ArrayList locationLevels) { + this.locationLevels = locationLevels; + } + + @NonNull + public ArrayList getHealthFacilityLevels() { + if (healthFacilityLevels == null) { + healthFacilityLevels = locationTagsConfiguration.getHealthFacilityLevels(); + } + + return healthFacilityLevels; + } + + public void setHealthFacilityLevels(ArrayList healthFacilityLevels) { + this.healthFacilityLevels = healthFacilityLevels; + } + + public String getLookUpQueryForModuleClient() { + return lookUpQueryForModuleClient; + } + + public void setLookUpQueryForModuleClient(String lookUpQueryForModuleClient) { + this.lookUpQueryForModuleClient = lookUpQueryForModuleClient; + } + + public Set getFieldsWithLocationHierarchy() { + return fieldsWithLocationHierarchy; + } + + public void setFieldsWithLocationHierarchy(Set fieldsWithLocationHierarchy) { + this.fieldsWithLocationHierarchy = fieldsWithLocationHierarchy; + } +} \ No newline at end of file diff --git a/opensrp-app/src/main/java/org/smartregister/configuration/RegisterPageRowProviderMetadata.java b/opensrp-app/src/main/java/org/smartregister/configuration/RegisterPageRowProviderMetadata.java new file mode 100644 index 000000000..111412bae --- /dev/null +++ b/opensrp-app/src/main/java/org/smartregister/configuration/RegisterPageRowProviderMetadata.java @@ -0,0 +1,46 @@ +package org.smartregister.configuration; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + + +import java.util.Map; + +/** + * Created by Ephraim Kigamba - nek.eam@gmail.com on 21-09-2020. + */ + +public interface RegisterPageRowProviderMetadata { + + @NonNull + String getGuardianFirstName(@NonNull Map columnMaps); + + @NonNull + String getGuardianMiddleName(@NonNull Map columnMaps); + + @NonNull + String getGuardianLastName(@NonNull Map columnMaps); + + @NonNull + String getClientFirstName(@NonNull Map columnMaps); + + @NonNull + String getClientMiddleName(@NonNull Map columnMaps); + + @NonNull + String getClientLastName(@NonNull Map columnMaps); + + @NonNull + String getDob(@NonNull Map columnMaps); + + boolean isClientHaveGuardianDetails(@NonNull Map columnMaps); + + @Nullable + String getRegisterType(@NonNull Map columnMaps); + + @NonNull + String getHomeAddress(@NonNull Map columnMaps); + + @NonNull + String getGender(@NonNull Map columnMaps); +} From f241d411f00d05b19770694695daf518baf1277a Mon Sep 17 00:00:00 2001 From: Ephraim Kigamba Date: Thu, 24 Sep 2020 19:04:54 +0300 Subject: [PATCH 007/141] Add interfaces & default implementations for register page & library configuration - Add the RowOptions, ViewHolder & RegisterProvider interfaces that will help make the register easily configurable - Add base implementations of the configurable classes - Add ModuleConfiguration that holds everything that is configurable on a module - Add ModuleFormProcessor that enables one to define how each form should be processed based on form name - Add ModuleRegisterQueryProvider that defines the queries used for search, quickly retrieving client IDs for each page, filter query & query for retrieving client details from the base-entity-id - Add RegisterProviderMetadata that defines how to retrieve specific values from a record eg first_name, age etc --- .../res/layout/opd_register_list_row.xml | 160 +++++++++++++ opensrp-app/res/values/dimens.xml | 17 ++ opensrp-app/res/values/strings.xml | 6 + opensrp-app/res/values/tags.xml | 6 + .../java/org/smartregister/AllConstants.java | 7 + .../java/org/smartregister/CoreLibrary.java | 25 ++ .../BaseRegisterProviderMetadata.java | 91 +++++++ .../configuration/BaseRegisterRowOptions.java | 48 ++++ .../configuration/ConfigurableComponent.java | 10 + .../ConfigurableComponentImpl.java | 19 ++ .../configuration/ModuleConfiguration.java | 128 ++++++++++ .../configuration/ModuleFormProcessor.java | 11 + .../ModuleRegisterQueryProviderContract.java | 57 +++++ .../RegisterProviderMetadata.java | 45 ++++ .../configuration/RegisterRowOptions.java | 42 ++++ .../cursoradapter/RecyclerViewProvider.java | 1 + .../exception/NewInstanceException.java | 15 ++ .../holders/BaseRegisterViewHolder.java | 72 ++++++ .../holders/FooterViewHolder.java | 25 ++ .../smartregister/pojo/InnerJoinObject.java | 45 ++++ .../org/smartregister/pojo/QueryTable.java | 36 +++ .../provider/BaseRegisterProvider.java | 226 ++++++++++++++++++ .../util/ConfigurationInstancesHelper.java | 27 +++ .../smartregister/util/CoreDbConstants.java | 183 ++++++++++++++ .../util/RegisterViewConstants.java | 13 + .../java/org/smartregister/util/Utils.java | 14 ++ settings.gradle | 9 +- 27 files changed, 1337 insertions(+), 1 deletion(-) create mode 100644 opensrp-app/res/layout/opd_register_list_row.xml create mode 100644 opensrp-app/res/values/tags.xml create mode 100644 opensrp-app/src/main/java/org/smartregister/configuration/BaseRegisterProviderMetadata.java create mode 100644 opensrp-app/src/main/java/org/smartregister/configuration/BaseRegisterRowOptions.java create mode 100644 opensrp-app/src/main/java/org/smartregister/configuration/ConfigurableComponent.java create mode 100644 opensrp-app/src/main/java/org/smartregister/configuration/ConfigurableComponentImpl.java create mode 100644 opensrp-app/src/main/java/org/smartregister/configuration/ModuleConfiguration.java create mode 100644 opensrp-app/src/main/java/org/smartregister/configuration/ModuleFormProcessor.java create mode 100644 opensrp-app/src/main/java/org/smartregister/configuration/ModuleRegisterQueryProviderContract.java create mode 100644 opensrp-app/src/main/java/org/smartregister/configuration/RegisterProviderMetadata.java create mode 100644 opensrp-app/src/main/java/org/smartregister/configuration/RegisterRowOptions.java create mode 100644 opensrp-app/src/main/java/org/smartregister/exception/NewInstanceException.java create mode 100644 opensrp-app/src/main/java/org/smartregister/holders/BaseRegisterViewHolder.java create mode 100644 opensrp-app/src/main/java/org/smartregister/holders/FooterViewHolder.java create mode 100644 opensrp-app/src/main/java/org/smartregister/pojo/InnerJoinObject.java create mode 100644 opensrp-app/src/main/java/org/smartregister/pojo/QueryTable.java create mode 100644 opensrp-app/src/main/java/org/smartregister/provider/BaseRegisterProvider.java create mode 100644 opensrp-app/src/main/java/org/smartregister/util/ConfigurationInstancesHelper.java create mode 100644 opensrp-app/src/main/java/org/smartregister/util/CoreDbConstants.java create mode 100644 opensrp-app/src/main/java/org/smartregister/util/RegisterViewConstants.java diff --git a/opensrp-app/res/layout/opd_register_list_row.xml b/opensrp-app/res/layout/opd_register_list_row.xml new file mode 100644 index 000000000..6f94001b1 --- /dev/null +++ b/opensrp-app/res/layout/opd_register_list_row.xml @@ -0,0 +1,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +