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 configurable register profile contracts #646

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
* Created by keyamn on 27/06/2018.
*/
public interface BaseRegisterContract {
interface Presenter {

interface Presenter extends ConfigurableRegisterActivityContract.Presenter {

void registerViewConfigurations(List<String> viewIdentifiers);

Expand All @@ -22,7 +23,7 @@ interface Presenter {
void updateInitials();
}

interface View {
interface View extends ConfigurableRegisterActivityContract.View {

Context getContext();

Expand All @@ -44,4 +45,8 @@ interface View {

void updateInitialsText(String initials);
}

interface Model extends ConfigurableRegisterActivityContract.Model {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public interface BaseRegisterFragmentContract {

interface View {
interface View extends ConfigurableRegisterFragmentContract.View {

void initializeQueryParams(String tableName, String countSelect, String mainSelect);

Expand All @@ -29,7 +29,7 @@ interface View {
void setTotalPatients();
}

interface Presenter {
interface Presenter extends ConfigurableRegisterFragmentContract.Presenter {

void processViewConfigurations();

Expand All @@ -41,5 +41,9 @@ interface Presenter {

}

interface Model extends ConfigurableRegisterFragmentContract.Model {

}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
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 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<String> viewIdentifiers);

void unregisterViewConfiguration(List<String> viewIdentifiers);

void saveLanguage(String language);

List<EventClient> processRegistration(String jsonString, FormTag formTag);

String getLocationId(String locationName);

String getInitials();
}

interface Interactor {

void onDestroy(boolean isChangingConfiguration);

void getNextUniqueId(Triple<String, String, String> triple, ConfigurableRegisterActivityContract.InteractorCallBack callBack);

void saveRegistration(@Nullable final List<EventClient> clientList, final String jsonString, @NonNull RegisterParams registerParams, final ConfigurableRegisterActivityContract.InteractorCallBack callBack);

}

interface InteractorCallBack {

void onUniqueIdFetched(Triple<String, String, String> triple, String entityId);

void onNoUniqueId();

void onRegistrationSaved(@NonNull RegisterParams registerParams, @Nullable List<EventClient> clientList);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.smartregister.view.contract;

import org.json.JSONArray;
import org.smartregister.domain.Response;

import java.util.List;
import java.util.Set;

public interface ConfigurableRegisterFragmentContract {

interface View {

void initializeAdapter(Set<IView> visibleColumns);

Presenter presenter();

}

interface Presenter {

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

String getMainCondition();

String getDefaultSortQuery();

String getQueryTable();
}

interface Model {

IViewConfiguration getViewConfiguration(String viewConfigurationIdentifier);

Set<IView> getRegisterActiveColumns(String viewConfigurationIdentifier);

String countSelect(String tableName, String mainCondition);

String mainSelect(String tableName, String mainCondition);

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

String getSortText(IField sortField);

JSONArray getJsonArray(Response<String> response);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.smartregister.view.contract;

/**
* Created by Ephraim Kigamba - [email protected] on 17-09-2020.
*/
public interface IBaseConfiguration {

String getLanguage();

void setLanguage(String language);

String getApplicationName();

void setApplicationName(String applicationName);

boolean isEnableJsonViews();

void setEnableJsonViews(boolean enableJsonViews);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.smartregister.view.contract;

/**
* Created by Ephraim Kigamba - [email protected] on 17-09-2020.
*/
public interface IField {


String getDisplayName();

void setDisplayName(String displayName);

String getDbAlias();

void setDbAlias(String dbAlias);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.smartregister.view.contract;

/**
* Created by Ephraim Kigamba - [email protected] 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);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.smartregister.view.contract;

import java.util.Map;

/**
* Created by Ephraim Kigamba - [email protected] 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<String, Object> getMetadata();

void setMetadata(Map<String, Object> metadata);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.smartregister.view.contract;

import java.util.List;
import java.util.Map;

/**
* Created by Ephraim Kigamba - [email protected] on 17-09-2020.
*/
public interface IViewConfiguration {


String getIdentifier();

void setIdentifier(String identifier);

IBaseConfiguration getMetadata();

void setMetadata(IBaseConfiguration metadata);

List<IView> getViews();

void setViews(List<IView> views);

Map<String, String> getLabels();

void setLabels(Map<String, String> labels);

Map getJsonView();

void setJsonView(Map jsonView);
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Loading