diff --git a/app/src/main/java/org/dhis2/data/forms/EnrollmentFormRepository.kt b/app/src/main/java/org/dhis2/data/forms/EnrollmentFormRepository.kt deleted file mode 100644 index a97016ff3ec..00000000000 --- a/app/src/main/java/org/dhis2/data/forms/EnrollmentFormRepository.kt +++ /dev/null @@ -1,92 +0,0 @@ -package org.dhis2.data.forms - -import io.reactivex.Flowable -import io.reactivex.Single -import io.reactivex.schedulers.Schedulers -import org.dhis2.commons.rules.RuleEngineContextData -import org.dhis2.form.data.RulesRepository -import org.hisp.dhis.android.core.D2 -import org.hisp.dhis.rules.api.RuleEngineContext - -class EnrollmentFormRepository( - private val rulesRepository: RulesRepository, - private val enrollmentUid: String, - private val d2: D2, -) : FormRepository { - private var cachedRuleEngineFlowable: Flowable - private var enrollmentOrgUnitUid: String? = null - - init { - enrollmentOrgUnitUid = if (enrollmentUid.isNotEmpty()) { - d2.enrollmentModule().enrollments().uid(enrollmentUid).blockingGet()!! - .organisationUnit() - } else { - "" - } - // We don't want to rebuild RuleEngine on each request, since metadata of - // the event is not changing throughout lifecycle of FormComponent. - cachedRuleEngineFlowable = enrollmentProgram() - .switchMap { program -> - Single.zip( - rulesRepository.rulesNew(program, null).subscribeOn(Schedulers.io()), - rulesRepository.ruleVariables(program).subscribeOn(Schedulers.io()), - rulesRepository.enrollmentEvents(enrollmentUid).subscribeOn(Schedulers.io()), - rulesRepository.queryConstants().subscribeOn(Schedulers.io()), - rulesRepository.supplementaryData(enrollmentOrgUnitUid!!) - .subscribeOn(Schedulers.io()), - ) { rules, variables, events, constants, supplementaryData -> - - val ruleEngineContext = RuleEngineContext( - rules, - variables, - supplementaryData, - constants, - ) - RuleEngineContextData( - ruleEngineContext = ruleEngineContext, - ruleEnrollment = null, - ruleEvents = events, - ) - }.toFlowable() - } - .cacheWithInitialCapacity(1) - } - - override fun restartRuleEngine(): Flowable { - val orgUnit = d2.enrollmentModule().enrollments().uid(enrollmentUid).blockingGet()!! - .organisationUnit() - return enrollmentProgram() - .switchMap { program -> - Single.zip( - rulesRepository.rulesNew(program, null), - rulesRepository.ruleVariables(program), - rulesRepository.enrollmentEvents(enrollmentUid), - rulesRepository.queryConstants(), - rulesRepository.supplementaryData(orgUnit!!), - ) { rules, variables, events, constants, supplementaryData -> - val ruleEngineContext = RuleEngineContext( - rules, - variables, - supplementaryData, - constants, - ) - RuleEngineContextData( - ruleEngineContext = ruleEngineContext, - ruleEnrollment = null, - ruleEvents = events, - ) - }.toFlowable() - } - .cacheWithInitialCapacity(1).also { cachedRuleEngineFlowable = it } - } - - override fun ruleEngine(): Flowable { - return cachedRuleEngineFlowable - } - - private fun enrollmentProgram(): Flowable { - return d2.enrollmentModule().enrollments().uid(enrollmentUid).get() - .map { it.program()!! } - .toFlowable() - } -} diff --git a/app/src/main/java/org/dhis2/data/forms/EventRepository.java b/app/src/main/java/org/dhis2/data/forms/EventRepository.java deleted file mode 100644 index ff5e99b0fac..00000000000 --- a/app/src/main/java/org/dhis2/data/forms/EventRepository.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.dhis2.data.forms; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -import org.dhis2.commons.rules.RuleEngineContextData; -import org.dhis2.form.data.RulesRepository; -import org.hisp.dhis.android.core.D2; -import org.hisp.dhis.rules.api.RuleEngineContext; - -import io.reactivex.Flowable; -import io.reactivex.Single; - -public class EventRepository implements FormRepository { - - private final String programUid; - private final String orgUnit; - - @NonNull - private Flowable cachedRuleEngineFlowable; - - private RuleEngineContextData ruleEngineContextData = null; - - @Nullable - private final String eventUid; - private final RulesRepository rulesRepository; - - public EventRepository( - @NonNull RulesRepository rulesRepository, - @Nullable String eventUid, - @NonNull D2 d2) { - this.eventUid = eventUid != null ? eventUid : ""; - this.rulesRepository = rulesRepository; - this.programUid = eventUid != null ? d2.eventModule().events().uid(eventUid).blockingGet().program() : ""; - this.orgUnit = !this.eventUid.isEmpty() ? d2.eventModule().events().uid(eventUid).blockingGet().organisationUnit() : ""; - // We don't want to rebuild RuleEngine on each request, since metadata of - // the event is not changing throughout lifecycle of FormComponent. - this.cachedRuleEngineFlowable = Single.zip( - rulesRepository.rulesNew(programUid, eventUid), - rulesRepository.ruleVariables(programUid), - rulesRepository.otherEvents(this.eventUid), - rulesRepository.enrollment(this.eventUid), - rulesRepository.queryConstants(), - rulesRepository.supplementaryData(orgUnit), - (rules, variables, events, enrollment, constants, supplementaryData) -> { - RuleEngineContext ruleEngineContext = new RuleEngineContext( - rules, - variables, - supplementaryData, - constants - ); - - return new RuleEngineContextData( - ruleEngineContext, - enrollment.getEnrollment().isEmpty() ? null : enrollment, - events - ); - }) - .doOnSuccess(contextData -> this.ruleEngineContextData = contextData) - .toFlowable() - .cacheWithInitialCapacity(1); - } - - - @Override - public Flowable restartRuleEngine() { - return this.cachedRuleEngineFlowable = Single.zip( - rulesRepository.rulesNew(programUid, eventUid), - rulesRepository.ruleVariables(programUid), - rulesRepository.otherEvents(this.eventUid), - rulesRepository.enrollment(this.eventUid), - rulesRepository.queryConstants(), - rulesRepository.supplementaryData(orgUnit), - (rules, variables, events, enrollment, constants, supplementaryData) -> { - RuleEngineContext ruleEngineContext = new RuleEngineContext( - rules, - variables, - supplementaryData, - constants - ); - - return new RuleEngineContextData( - ruleEngineContext, - enrollment.getEnrollment().isEmpty() ? null : enrollment, - events - ); - }) - .doOnSuccess(contextData -> this.ruleEngineContextData = contextData) - .toFlowable() - .cacheWithInitialCapacity(1); - } - - @NonNull - @Override - public Flowable ruleEngine() { - return ruleEngineContextData != null ? Flowable.just(ruleEngineContextData) : cachedRuleEngineFlowable; - } -} \ No newline at end of file diff --git a/app/src/main/java/org/dhis2/data/forms/FormRepository.java b/app/src/main/java/org/dhis2/data/forms/FormRepository.java deleted file mode 100644 index 78425ea42f5..00000000000 --- a/app/src/main/java/org/dhis2/data/forms/FormRepository.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.dhis2.data.forms; - -import androidx.annotation.NonNull; - -import org.dhis2.commons.rules.RuleEngineContextData; - -import io.reactivex.Flowable; - -public interface FormRepository { - - Flowable restartRuleEngine(); - - @NonNull - Flowable ruleEngine(); - -} \ No newline at end of file diff --git a/app/src/main/java/org/dhis2/data/forms/ReportStatus.java b/app/src/main/java/org/dhis2/data/forms/ReportStatus.java deleted file mode 100644 index febd75857e3..00000000000 --- a/app/src/main/java/org/dhis2/data/forms/ReportStatus.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.dhis2.data.forms; - -import org.hisp.dhis.android.core.enrollment.EnrollmentStatus; -import org.hisp.dhis.android.core.event.EventStatus; - -enum ReportStatus { - ACTIVE, COMPLETED; - - static ReportStatus fromEnrollmentStatus(EnrollmentStatus enrollmentStatus) { - if (enrollmentStatus == EnrollmentStatus.ACTIVE) { - return ACTIVE; - } - return COMPLETED; - } - - static ReportStatus fromEventStatus(EventStatus eventStatus) { - if (eventStatus == EventStatus.COMPLETED) { - return COMPLETED; - } - return ACTIVE; - } - - static EventStatus toEventStatus(ReportStatus reportStatus) { - if (reportStatus == ACTIVE) { - return EventStatus.ACTIVE; - } - return EventStatus.COMPLETED; - } - - static EnrollmentStatus toEnrollmentStatus(ReportStatus reportStatus) { - if (reportStatus == ACTIVE) { - return EnrollmentStatus.ACTIVE; - } - return EnrollmentStatus.COMPLETED; - } -} \ No newline at end of file diff --git a/app/src/main/java/org/dhis2/data/forms/dataentry/DataEntryArguments.java b/app/src/main/java/org/dhis2/data/forms/dataentry/DataEntryArguments.java deleted file mode 100644 index fc75dbfbb75..00000000000 --- a/app/src/main/java/org/dhis2/data/forms/dataentry/DataEntryArguments.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.dhis2.data.forms.dataentry; - -import android.os.Parcelable; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class DataEntryArguments implements Parcelable { - - @NonNull - public abstract String event(); - - @NonNull - public abstract String section(); - - @NonNull - public abstract String enrollment(); - - @Nullable - public abstract String renderType(); - - @NonNull - public static DataEntryArguments forEvent(@NonNull String event,String renderType) { - return new AutoValue_DataEntryArguments(event, "", "",renderType); - } - - @NonNull - public static DataEntryArguments forEventSection(@NonNull String event, @NonNull String section, String renderType) { - return new AutoValue_DataEntryArguments(event, section, "",renderType); - } - - @NonNull - public static DataEntryArguments forEnrollment(@NonNull String enrollment) { - return new AutoValue_DataEntryArguments("", "", enrollment,null); - } -} diff --git a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/datetime/OnDateSelected.java b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/datetime/OnDateSelected.java deleted file mode 100644 index ddbe163c460..00000000000 --- a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/datetime/OnDateSelected.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.dhis2.data.forms.dataentry.tablefields.datetime; - -import java.util.Date; - -/** - * QUADRAM. Created by ppajuelo on 23/04/2018. - */ - -public interface OnDateSelected { - void onDateSelected(Date date); -} diff --git a/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventCapture/EventCaptureModule.java b/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventCapture/EventCaptureModule.java index cfc80799f20..3bb64863408 100644 --- a/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventCapture/EventCaptureModule.java +++ b/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventCapture/EventCaptureModule.java @@ -14,18 +14,16 @@ import org.dhis2.commons.resources.ResourceManager; import org.dhis2.commons.schedulers.SchedulerProvider; import org.dhis2.data.dhislogic.DhisEnrollmentUtils; -import org.dhis2.data.forms.EventRepository; -import org.dhis2.data.forms.FormRepository; import org.dhis2.data.forms.dataentry.SearchTEIRepository; import org.dhis2.data.forms.dataentry.SearchTEIRepositoryImpl; -import org.dhis2.mobileProgramRules.EvaluationType; -import org.dhis2.mobileProgramRules.RuleEngineHelper; import org.dhis2.form.data.FileController; import org.dhis2.form.data.FormValueStore; import org.dhis2.form.data.RulesRepository; import org.dhis2.form.data.UniqueAttributeController; import org.dhis2.form.model.RowAction; import org.dhis2.form.ui.FieldViewModelFactory; +import org.dhis2.mobileProgramRules.EvaluationType; +import org.dhis2.mobileProgramRules.RuleEngineHelper; import org.dhis2.usescases.eventsWithoutRegistration.eventCapture.domain.ConfigureEventCompletionDialog; import org.dhis2.usescases.eventsWithoutRegistration.eventCapture.provider.EventCaptureResourcesProvider; import org.dhis2.utils.customviews.navigationbar.NavigationPageConfigurator; @@ -86,20 +84,13 @@ RulesRepository rulesRepository(@NonNull D2 d2) { @Provides @PerActivity RuleEngineHelper ruleEngineRepository(D2 d2) { - if(eventUid == null) return null; + if (eventUid == null) return null; return new RuleEngineHelper( new EvaluationType.Event(eventUid), new org.dhis2.mobileProgramRules.RulesRepository(d2) ); } - @Provides - @PerActivity - FormRepository formRepository(@NonNull RulesRepository rulesRepository, - @NonNull D2 d2) { - return new EventRepository(rulesRepository, eventUid, d2); - } - @Provides @PerActivity FormValueStore valueStore( diff --git a/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventInitial/EventInitialModule.java b/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventInitial/EventInitialModule.java index 949159bca43..4a981c72d19 100644 --- a/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventInitial/EventInitialModule.java +++ b/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventInitial/EventInitialModule.java @@ -11,12 +11,10 @@ import org.dhis2.commons.prefs.PreferenceProvider; import org.dhis2.commons.prefs.PreferenceProviderImpl; import org.dhis2.commons.resources.ColorUtils; -import org.dhis2.commons.resources.MetadataIconProvider; import org.dhis2.commons.resources.DhisPeriodUtils; +import org.dhis2.commons.resources.MetadataIconProvider; import org.dhis2.commons.resources.ResourceManager; import org.dhis2.commons.schedulers.SchedulerProvider; -import org.dhis2.data.forms.EventRepository; -import org.dhis2.data.forms.FormRepository; import org.dhis2.form.data.RulesRepository; import org.dhis2.form.data.RulesUtilsProvider; import org.dhis2.form.data.metadata.FileResourceConfiguration; @@ -118,12 +116,6 @@ FieldViewModelFactory fieldFactory( ); } - @Provides - FormRepository formRepository(@NonNull RulesRepository rulesRepository, - @NonNull D2 d2) { - return new EventRepository(rulesRepository, eventUid, d2); - } - @Provides RulesRepository rulesRepository(@NonNull D2 d2) { return new RulesRepository(d2); diff --git a/app/src/main/java/org/dhis2/usescases/teiDashboard/TeiDashboardModule.kt b/app/src/main/java/org/dhis2/usescases/teiDashboard/TeiDashboardModule.kt index 617c21cfc29..b340d397188 100644 --- a/app/src/main/java/org/dhis2/usescases/teiDashboard/TeiDashboardModule.kt +++ b/app/src/main/java/org/dhis2/usescases/teiDashboard/TeiDashboardModule.kt @@ -9,8 +9,6 @@ import org.dhis2.commons.prefs.PreferenceProvider import org.dhis2.commons.resources.MetadataIconProvider import org.dhis2.commons.schedulers.SchedulerProvider import org.dhis2.commons.viewmodel.DispatcherProvider -import org.dhis2.data.forms.EnrollmentFormRepository -import org.dhis2.data.forms.FormRepository import org.dhis2.form.data.RulesRepository import org.dhis2.mobileProgramRules.EvaluationType import org.dhis2.mobileProgramRules.RuleEngineHelper @@ -79,20 +77,6 @@ class TeiDashboardModule( return RulesRepository(d2) } - @Provides - @PerActivity - fun formRepository( - rulesRepository: RulesRepository, - d2: D2, - ): FormRepository { - val enrollmentUidToUse = enrollmentUid ?: "" - return EnrollmentFormRepository( - rulesRepository, - enrollmentUidToUse, - d2, - ) - } - @Provides @PerActivity fun ruleEngineRepository( diff --git a/app/src/main/java/org/dhis2/utils/CatComboAdapter.java b/app/src/main/java/org/dhis2/utils/CatComboAdapter.java deleted file mode 100644 index 4a1f271f9fb..00000000000 --- a/app/src/main/java/org/dhis2/utils/CatComboAdapter.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.dhis2.utils; - -import android.content.Context; -import androidx.databinding.DataBindingUtil; -import androidx.annotation.ColorRes; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.core.content.ContextCompat; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; - -import org.dhis2.R; -import org.dhis2.databinding.SpinnerLayoutBinding; - -import org.hisp.dhis.android.core.category.CategoryOptionCombo; -import java.util.List; - -/** - * Created by ppajuelo on 12/02/2018. - * - */ - -public class CatComboAdapter extends ArrayAdapter { - - private List options; - private String catComboName; - private @ColorRes int textColor; - - public CatComboAdapter(@NonNull Context context, int resource, int textViewResourceId, - @NonNull List objects, - String categoryOptionName, - @ColorRes int textColor) { - super(context, resource, textViewResourceId, objects); - this.options = objects; - this.catComboName = categoryOptionName; - this.textColor = textColor; - } - - @NonNull - @Override - public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { - - LayoutInflater inflater = LayoutInflater.from(parent.getContext()); - SpinnerLayoutBinding binding = SpinnerLayoutBinding.inflate(inflater,parent,false); - if (position != 0) - binding.setOption(options.get(position - 1).displayName()); - binding.setOptionSetName(catComboName); - binding.spinnerText.setTextColor(ContextCompat.getColor(binding.spinnerText.getContext(), textColor)); - return binding.getRoot(); - - } - - @Override - public View getDropDownView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { - LayoutInflater inflater = LayoutInflater.from(parent.getContext()); - SpinnerLayoutBinding binding = DataBindingUtil.inflate(inflater, R.layout.spinner_layout, parent, false); - if (position != 0) - binding.setOption(options.get(position - 1).displayName()); - - binding.setOptionSetName(catComboName); - return binding.getRoot(); - } - - @Override - public int getCount() { - return super.getCount() + 1; - } -} \ No newline at end of file diff --git a/commons/src/main/java/org/dhis2/commons/data/tuples/Quartet.java b/commons/src/main/java/org/dhis2/commons/data/tuples/Quartet.java deleted file mode 100644 index eddcf04fd0e..00000000000 --- a/commons/src/main/java/org/dhis2/commons/data/tuples/Quartet.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.dhis2.commons.data.tuples; - -import androidx.annotation.NonNull; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class Quartet { - - @NonNull - public abstract A val0(); - - @NonNull - public abstract B val1(); - - @NonNull - public abstract C val2(); - - @NonNull - public abstract D val3(); - - @NonNull - public static Quartet create(@NonNull A val0, @NonNull B val1, - @NonNull C val2, @NonNull D val3) { - return new AutoValue_Quartet<>(val0, val1, val2, val3); - } -} diff --git a/commons/src/main/java/org/dhis2/commons/data/tuples/Quintet.java b/commons/src/main/java/org/dhis2/commons/data/tuples/Quintet.java deleted file mode 100644 index a262c85c485..00000000000 --- a/commons/src/main/java/org/dhis2/commons/data/tuples/Quintet.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.dhis2.commons.data.tuples; - -import androidx.annotation.NonNull; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class Quintet { - - @NonNull - public abstract A val0(); - - @NonNull - public abstract B val1(); - - @NonNull - public abstract C val2(); - - @NonNull - public abstract D val3(); - - @NonNull - public abstract E val4(); - - @NonNull - public static Quintet create(@NonNull A val0, - @NonNull B val1, @NonNull C val2, - @NonNull D val3, @NonNull E val4) { - return new AutoValue_Quintet<>(val0, val1, val2, val3, val4); - } -} diff --git a/commons/src/main/java/org/dhis2/commons/data/tuples/Septet.java b/commons/src/main/java/org/dhis2/commons/data/tuples/Septet.java deleted file mode 100644 index 7590b72d39f..00000000000 --- a/commons/src/main/java/org/dhis2/commons/data/tuples/Septet.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.dhis2.commons.data.tuples; - -import androidx.annotation.NonNull; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class Septet { - - @NonNull - public abstract A val0(); - - @NonNull - public abstract B val1(); - - @NonNull - public abstract C val2(); - - @NonNull - public abstract D val3(); - - @NonNull - public abstract E val4(); - - @NonNull - public abstract F val5(); - - @NonNull - public abstract G val6(); - - @NonNull - public static Septet create(@NonNull A val0, - @NonNull B val1, @NonNull C val2, - @NonNull D val3, @NonNull E val4, - @NonNull F val5, @NonNull G val6) { - return new AutoValue_Septet<>(val0, val1, val2, val3, val4, val5, val6); - } -} diff --git a/commons/src/main/java/org/dhis2/commons/data/tuples/Sextet.java b/commons/src/main/java/org/dhis2/commons/data/tuples/Sextet.java deleted file mode 100644 index adeb28ca7c9..00000000000 --- a/commons/src/main/java/org/dhis2/commons/data/tuples/Sextet.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.dhis2.commons.data.tuples; - -import androidx.annotation.NonNull; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class Sextet { - - @NonNull - public abstract A val0(); - - @NonNull - public abstract B val1(); - - @NonNull - public abstract C val2(); - - @NonNull - public abstract D val3(); - - @NonNull - public abstract E val4(); - - @NonNull - public abstract F val5(); - - @NonNull - public static Sextet create(@NonNull A val0, - @NonNull B val1, @NonNull C val2, - @NonNull D val3, @NonNull E val4, @NonNull F val5) { - return new AutoValue_Sextet<>(val0, val1, val2, val3, val4, val5); - } -} diff --git a/commons/src/main/java/org/dhis2/commons/data/tuples/Single.java b/commons/src/main/java/org/dhis2/commons/data/tuples/Single.java deleted file mode 100644 index 3225e92c4d3..00000000000 --- a/commons/src/main/java/org/dhis2/commons/data/tuples/Single.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.dhis2.commons.data.tuples; - -import androidx.annotation.NonNull; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class Single { - - @NonNull - public abstract A val0(); - - @NonNull - public static Single create(@NonNull A val) { - return new AutoValue_Single<>(val); - } -}