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

Update Child Register implementation #191

Open
wants to merge 3 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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=0.5.0-SNAPSHOT
VERSION_NAME=0.6.0-SNAPSHOT
VERSION_CODE=1
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Child Library
Expand Down
4 changes: 2 additions & 2 deletions opensrp-child/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ allprojects {

dependencies {

api('org.smartregister:opensrp-client-core:2.1.4-SNAPSHOT@aar') {
api('org.smartregister:opensrp-client-core:2.1.2.2-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.github.bmelnychuk', module: 'atv'
exclude group: 'com.google.guava', module: 'guava'
Expand All @@ -114,7 +114,7 @@ dependencies {

implementation 'com.google.code.gson:gson:2.8.6'

api('org.smartregister:opensrp-client-configurable-views:1.1.5-SNAPSHOT@aar') {
api('org.smartregister:opensrp-client-configurable-views:1.1.5.1-SNAPSHOT@aar') {
transitive = true
exclude group: 'org.smartregister', module: 'opensrp-client-core'
exclude group: 'org.smartregister', module: 'opensrp-client-native-form'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface Presenter extends BaseRegisterContract.Presenter {

void saveLanguage(String language);

void startForm(String formName, String entityId, String metadata, String currentLocationId) throws Exception;
void startForm(String formName, String entityId, String metadata, String currentLocationId);

void startForm(String formName, String entityId, Map<String, String> metadata, String currentLocationId) throws Exception;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ public interface ChildRegisterFragmentContract {

interface View extends BaseRegisterFragmentContract.View {

void initializeAdapter(Set<org.smartregister.configurableviews.model.View> visibleColumns);

void recalculatePagination(AdvancedMatrixCursor matrixCursor);

ChildRegisterFragmentContract.Presenter presenter();
Expand All @@ -29,28 +27,20 @@ interface View extends BaseRegisterFragmentContract.View {

interface Presenter extends BaseRegisterFragmentContract.Presenter {

void updateSortAndFilter(List<Field> filterList, Field sortField);

String getMainCondition();

String getDefaultSortQuery();

}

interface Model {
interface Model extends BaseRegisterFragmentContract.Model{

RegisterConfiguration defaultRegisterConfiguration();

ViewConfiguration getViewConfiguration(String viewConfigurationIdentifier);

Set<org.smartregister.configurableviews.model.View> getRegisterActiveColumns(String viewConfigurationIdentifier);

String countSelect(String mainCondition);

String mainSelect(String mainCondition);

String getFilterText(List<Field> filterList, String filter);

String getSortText(Field sortField);

AdvancedMatrixCursor createMatrixCursor(Response<String> response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import org.smartregister.immunization.ImmunizationLibrary;
import org.smartregister.view.activity.BaseRegisterActivity;
import org.smartregister.view.activity.SecuredNativeSmartRegisterActivity;
import org.smartregister.view.contract.IView;

import java.text.ParseException;
import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -274,7 +275,7 @@ public void setupViews(View view) {
public abstract void populateSearchableFields(View view);

@Override
public void initializeAdapter(Set<org.smartregister.configurableviews.model.View> visibleColumns) {
public void initializeAdapter(Set<IView> visibleColumns) {

RepositoryHolder repoHolder = new RepositoryHolder();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.smartregister.receiver.SyncStatusBroadcastReceiver;
import org.smartregister.view.LocationPickerView;
import org.smartregister.view.activity.BaseRegisterActivity;
import org.smartregister.view.contract.IView;
import org.smartregister.view.customcontrols.CustomFontTextView;
import org.smartregister.view.fragment.BaseRegisterFragment;

Expand Down Expand Up @@ -291,7 +292,7 @@ public void showNotFoundPopup(String opensrpID) {
}

@Override
public void initializeAdapter(Set<org.smartregister.configurableviews.model.View> visibleColumns) {
public void initializeAdapter(Set<IView> visibleColumns) {
RepositoryHolder repositoryHolder = new RepositoryHolder();
repositoryHolder.setCommonRepository(commonRepository());
repositoryHolder.setVaccineRepository(ImmunizationLibrary.getInstance().vaccineRepository());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
import org.smartregister.configurableviews.ConfigurableViewsLibrary;
import org.smartregister.configurableviews.model.Field;
import org.smartregister.configurableviews.model.RegisterConfiguration;
import org.smartregister.configurableviews.model.View;
import org.smartregister.configurableviews.model.ViewConfiguration;
import org.smartregister.domain.Response;
import org.smartregister.domain.ResponseStatus;
import org.smartregister.view.contract.IField;
import org.smartregister.view.contract.IView;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -38,7 +39,7 @@ public ViewConfiguration getViewConfiguration(String viewConfigurationIdentifier
}

@Override
public Set<View> getRegisterActiveColumns(String viewConfigurationIdentifier) {
public Set<IView> getRegisterActiveColumns(String viewConfigurationIdentifier) {
return ConfigurableViewsLibrary.getInstance().getConfigurableViewsHelper().getRegisterActiveColumns(viewConfigurationIdentifier);
}

Expand All @@ -53,8 +54,8 @@ public String mainSelect(String mainCondition) {
}

@Override
public String getFilterText(List<Field> list, String filterTitle) {
List<Field> filterList = list;
public String getFilterText(List<IField> list, String filterTitle) {
List<IField> filterList = list;
if (filterList == null) {
filterList = new ArrayList<>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import org.smartregister.configurableviews.model.Field;
import org.smartregister.configurableviews.model.RegisterConfiguration;
import org.smartregister.configurableviews.model.ViewConfiguration;
import org.smartregister.view.contract.IField;
import org.smartregister.view.contract.IView;
import org.smartregister.view.contract.IViewConfiguration;

import java.lang.ref.WeakReference;
import java.util.List;
Expand All @@ -26,7 +29,7 @@ public abstract class BaseChildRegisterFragmentPresenter implements ChildRegiste

protected RegisterConfiguration config;

protected Set<org.smartregister.configurableviews.model.View> visibleColumns = new TreeSet<>();
protected Set<IView> visibleColumns = new TreeSet<>();

protected String viewConfigurationIdentifier;

Expand All @@ -49,7 +52,7 @@ public void processViewConfigurations() {
return;
}

ViewConfiguration viewConfiguration = model.getViewConfiguration(viewConfigurationIdentifier);
IViewConfiguration viewConfiguration = model.getViewConfiguration(viewConfigurationIdentifier);
if (viewConfiguration != null) {
config = (RegisterConfiguration) viewConfiguration.getMetadata();
setVisibleColumns(model.getRegisterActiveColumns(viewConfigurationIdentifier));
Expand Down Expand Up @@ -84,7 +87,7 @@ public void searchGlobally(String uniqueId) {
// TODO implement search global
}

private void setVisibleColumns(Set<org.smartregister.configurableviews.model.View> visibleColumns) {
private void setVisibleColumns(Set<IView> visibleColumns) {
this.visibleColumns = visibleColumns;
}

Expand All @@ -94,7 +97,7 @@ protected ChildRegisterFragmentContract.View getView() {
}

@Override
public void updateSortAndFilter(List<Field> filterList, Field sortField) {
public void updateSortAndFilter(List<IField> filterList, IField sortField) {
String filterText = model.getFilterText(filterList, getView().getString(R.string.filter));
String sortText = model.getSortText(sortField);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,16 @@ public void saveLanguage(String language) {
}

@Override
public void startForm(String formName, String entityId, String metadata, String currentLocationId) throws Exception {
public void startForm(String formName, String entityId, String metadata, String currentLocationId) {
Map<String, String> metadataMap = StringUtils.isBlank(metadata) ? new HashMap<String, String>() : (Map<String, String>) new Gson()
.fromJson(metadata, new TypeToken<Map<String, String>>() {
}.getType());

startForm(formName, entityId, metadataMap, currentLocationId);
try {
startForm(formName, entityId, metadataMap, currentLocationId);
} catch (Exception e) {
Timber.e(e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.smartregister.child.util.Utils;
import org.smartregister.clientandeventmodel.DateUtil;
import org.smartregister.domain.Response;
import org.smartregister.view.contract.IField;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -176,4 +177,19 @@ private Date processJsonFormatLocalDate(String dateString) {
}
return date;
}

@Override
public String countSelect(String s, String s1) {
return null;
}

@Override
public String mainSelect(String s, String s1) {
return null;
}

@Override
public String getSortText(IField iField) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.smartregister.child.cursor.AdvancedMatrixCursor;
import org.smartregister.child.model.BaseChildRegisterFragmentModel;
import org.smartregister.domain.Response;
import org.smartregister.view.contract.IField;

/**
* Created by ndegwamartin on 2019-05-27.
Expand All @@ -15,4 +16,18 @@ public AdvancedMatrixCursor createMatrixCursor(Response<String> response) {
return null;
}

@Override
public String countSelect(String s, String s1) {
return null;
}

@Override
public String mainSelect(String s, String s1) {
return null;
}

@Override
public String getSortText(IField iField) {
return null;
}
}