? {
return when (val dataItem = evaluationItem.dimensionItems.first()) {
is DimensionItem.DataItem.DataElementOperandItem -> {
- val dataElement = visitor.indicatorContext.dataElementStore.selectByUid(dataItem.dataElement)
+ val dataElement = visitor.indicatorContext!!.dataElementStore.selectByUid(dataItem.dataElement)
val coc = visitor.indicatorContext.categoryOptionComboStore.selectByUid(dataItem.categoryOptionCombo)
if (dataElement == null || coc == null) {
@@ -110,13 +112,13 @@ internal interface IndicatorDataItem : ExpressionItem {
}
is DimensionItem.DataItem.DataElementItem -> {
val dataElement =
- visitor.indicatorContext.dataElementStore.selectByUid(dataItem.uid)
+ visitor.indicatorContext!!.dataElementStore.selectByUid(dataItem.uid)
?: throw AnalyticsException.InvalidDataElement(dataItem.uid)
dataItem.uid to MetadataItem.DataElementItem(dataElement)
}
is DimensionItem.DataItem.ProgramIndicatorItem -> {
- val programIndicator = visitor.indicatorContext.programIndicatorRepository
+ val programIndicator = visitor.indicatorContext!!.programIndicatorRepository
.withAnalyticsPeriodBoundaries()
.uid(dataItem.uid)
.blockingGet()
@@ -125,7 +127,7 @@ internal interface IndicatorDataItem : ExpressionItem {
dataItem.uid to MetadataItem.ProgramIndicatorItem(programIndicator)
}
is DimensionItem.DataItem.EventDataItem.DataElement -> {
- val program = visitor.indicatorContext.programStore.selectByUid(dataItem.program)
+ val program = visitor.indicatorContext!!.programStore.selectByUid(dataItem.program)
?: throw AnalyticsException.InvalidProgram(dataItem.program)
val dataElement = visitor.indicatorContext.dataElementStore.selectByUid(dataItem.dataElement)
@@ -135,7 +137,7 @@ internal interface IndicatorDataItem : ExpressionItem {
metadataItem.id to metadataItem
}
is DimensionItem.DataItem.EventDataItem.Attribute -> {
- val program = visitor.indicatorContext.programStore.selectByUid(dataItem.program)
+ val program = visitor.indicatorContext!!.programStore.selectByUid(dataItem.program)
?: throw AnalyticsException.InvalidProgram(dataItem.program)
val attribute = visitor.indicatorContext.trackedEntityAttributeStore.selectByUid(dataItem.attribute)
diff --git a/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/internal/evaluator/indicatorengine/dataitem/ProgramAttributeItem.kt b/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/internal/evaluator/indicatorengine/dataitem/ProgramAttributeItem.kt
index ed6f92ed1e..c71de31e64 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/internal/evaluator/indicatorengine/dataitem/ProgramAttributeItem.kt
+++ b/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/internal/evaluator/indicatorengine/dataitem/ProgramAttributeItem.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -47,6 +47,6 @@ internal class ProgramAttributeItem : IndicatorDataItem {
}
override fun getEvaluator(visitor: CommonExpressionVisitor): AnalyticsEvaluator {
- return visitor.indicatorContext.eventDataItemEvaluator
+ return visitor.indicatorContext!!.eventDataItemEvaluator
}
}
diff --git a/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/internal/evaluator/indicatorengine/dataitem/ProgramDataElementItem.kt b/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/internal/evaluator/indicatorengine/dataitem/ProgramDataElementItem.kt
index 9863077216..293da147b0 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/internal/evaluator/indicatorengine/dataitem/ProgramDataElementItem.kt
+++ b/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/internal/evaluator/indicatorengine/dataitem/ProgramDataElementItem.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -47,6 +47,6 @@ internal class ProgramDataElementItem : IndicatorDataItem {
}
override fun getEvaluator(visitor: CommonExpressionVisitor): AnalyticsEvaluator {
- return visitor.indicatorContext.eventDataItemEvaluator
+ return visitor.indicatorContext!!.eventDataItemEvaluator
}
}
diff --git a/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/internal/evaluator/indicatorengine/dataitem/ProgramIndicatorItem.kt b/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/internal/evaluator/indicatorengine/dataitem/ProgramIndicatorItem.kt
index 4a58b7868f..e4c46d0e56 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/internal/evaluator/indicatorengine/dataitem/ProgramIndicatorItem.kt
+++ b/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/internal/evaluator/indicatorengine/dataitem/ProgramIndicatorItem.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -45,6 +45,6 @@ internal class ProgramIndicatorItem : IndicatorDataItem {
}
override fun getEvaluator(visitor: CommonExpressionVisitor): AnalyticsEvaluator {
- return visitor.indicatorContext.programIndicatorEvaluator
+ return visitor.indicatorContext!!.programIndicatorEvaluator
}
}
diff --git a/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/mock/AggregatedSamples.kt b/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/mock/AggregatedSamples.kt
index 6f6da13047..4081690317 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/mock/AggregatedSamples.kt
+++ b/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/mock/AggregatedSamples.kt
@@ -1,19 +1,19 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
- *
+ *
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of the HISP project nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
diff --git a/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/mock/DimensionalResponseSamples.kt b/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/mock/DimensionalResponseSamples.kt
index 3efe23163d..17b5411d52 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/mock/DimensionalResponseSamples.kt
+++ b/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/mock/DimensionalResponseSamples.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/mock/GridAnalyticsResponseSamples.kt b/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/mock/GridAnalyticsResponseSamples.kt
index edfe2601d2..32843d5a40 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/mock/GridAnalyticsResponseSamples.kt
+++ b/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/mock/GridAnalyticsResponseSamples.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/mock/MockAnalyticsRepository.kt b/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/mock/MockAnalyticsRepository.kt
index d7298b6867..377a36e413 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/mock/MockAnalyticsRepository.kt
+++ b/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/mock/MockAnalyticsRepository.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/mock/MockAnalyticsVisualizationsRepository.kt b/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/mock/MockAnalyticsVisualizationsRepository.kt
index 72a273376c..ccc2475635 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/mock/MockAnalyticsVisualizationsRepository.kt
+++ b/core/src/main/java/org/hisp/dhis/android/core/analytics/aggregated/mock/MockAnalyticsVisualizationsRepository.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/EventLineListParams.kt b/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/EventLineListParams.kt
index 6fb67a7d41..4980972a13 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/EventLineListParams.kt
+++ b/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/EventLineListParams.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/EventLineListRepository.kt b/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/EventLineListRepository.kt
index 92170fe48a..e3dd11109c 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/EventLineListRepository.kt
+++ b/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/EventLineListRepository.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/EventLineListRepositoryImpl.kt b/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/EventLineListRepositoryImpl.kt
index ff2642d542..5224c85f72 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/EventLineListRepositoryImpl.kt
+++ b/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/EventLineListRepositoryImpl.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/EventLineListService.kt b/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/EventLineListService.kt
index 35c0481f8a..9217e97dff 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/EventLineListService.kt
+++ b/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/EventLineListService.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/EventLineListServiceImpl.kt b/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/EventLineListServiceImpl.kt
index d3f05e7696..183dcd7974 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/EventLineListServiceImpl.kt
+++ b/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/EventLineListServiceImpl.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/LineListEntityDIModule.kt b/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/LineListEntityDIModule.kt
index 08a9aea0dd..0e66324117 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/LineListEntityDIModule.kt
+++ b/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/LineListEntityDIModule.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/LineListResponse.kt b/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/LineListResponse.kt
index a7553f08df..b229813f91 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/LineListResponse.kt
+++ b/core/src/main/java/org/hisp/dhis/android/core/analytics/linelist/LineListResponse.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/core/src/main/java/org/hisp/dhis/android/core/arch/api/authentication/internal/CookieAuthenticatorHelper.kt b/core/src/main/java/org/hisp/dhis/android/core/arch/api/authentication/internal/CookieAuthenticatorHelper.kt
index 0b66ec75e7..9b17016790 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/arch/api/authentication/internal/CookieAuthenticatorHelper.kt
+++ b/core/src/main/java/org/hisp/dhis/android/core/arch/api/authentication/internal/CookieAuthenticatorHelper.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/core/src/main/java/org/hisp/dhis/android/core/arch/api/authentication/internal/OpenIDConnectAuthenticator.kt b/core/src/main/java/org/hisp/dhis/android/core/arch/api/authentication/internal/OpenIDConnectAuthenticator.kt
index 4a83ba9db4..22b5f7c6d6 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/arch/api/authentication/internal/OpenIDConnectAuthenticator.kt
+++ b/core/src/main/java/org/hisp/dhis/android/core/arch/api/authentication/internal/OpenIDConnectAuthenticator.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/core/src/main/java/org/hisp/dhis/android/core/arch/api/authentication/internal/ParentAuthenticator.kt b/core/src/main/java/org/hisp/dhis/android/core/arch/api/authentication/internal/ParentAuthenticator.kt
index 7c118b0a94..fd7617df9e 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/arch/api/authentication/internal/ParentAuthenticator.kt
+++ b/core/src/main/java/org/hisp/dhis/android/core/arch/api/authentication/internal/ParentAuthenticator.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/core/src/main/java/org/hisp/dhis/android/core/arch/api/authentication/internal/PasswordAndCookieAuthenticator.kt b/core/src/main/java/org/hisp/dhis/android/core/arch/api/authentication/internal/PasswordAndCookieAuthenticator.kt
index 88d8cc026f..dac0bce87e 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/arch/api/authentication/internal/PasswordAndCookieAuthenticator.kt
+++ b/core/src/main/java/org/hisp/dhis/android/core/arch/api/authentication/internal/PasswordAndCookieAuthenticator.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/core/src/main/java/org/hisp/dhis/android/core/arch/api/authentication/internal/UserIdAuthenticatorHelper.kt b/core/src/main/java/org/hisp/dhis/android/core/arch/api/authentication/internal/UserIdAuthenticatorHelper.kt
index f5aa10d450..932173cacb 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/arch/api/authentication/internal/UserIdAuthenticatorHelper.kt
+++ b/core/src/main/java/org/hisp/dhis/android/core/arch/api/authentication/internal/UserIdAuthenticatorHelper.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APICallErrorCatcher.kt b/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APICallErrorCatcher.kt
index 3fdb80e27f..0379ca7650 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APICallErrorCatcher.kt
+++ b/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APICallErrorCatcher.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APICallExecutor.java b/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APICallExecutor.java
index 4d45ff343d..15c755b618 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APICallExecutor.java
+++ b/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APICallExecutor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APICallExecutorImpl.java b/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APICallExecutorImpl.java
index 026757a156..08d6789edb 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APICallExecutorImpl.java
+++ b/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APICallExecutorImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APIDownloader.kt b/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APIDownloader.kt
index ce6c113d0c..be42f57b5f 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APIDownloader.kt
+++ b/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APIDownloader.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APIDownloaderImpl.kt b/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APIDownloaderImpl.kt
index 409cff780f..92cd5058d0 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APIDownloaderImpl.kt
+++ b/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APIDownloaderImpl.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APIErrorMapper.kt b/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APIErrorMapper.kt
index 56a2d08b2a..adf53ffbcd 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APIErrorMapper.kt
+++ b/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APIErrorMapper.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -109,13 +109,18 @@ internal class APIErrorMapper @Inject constructor() {
.build()
}
- val rxObjectErrorBuilder: D2Error.Builder
- get() = D2Error.builder()
- .errorComponent(D2ErrorComponent.Server)
-
fun getBaseErrorBuilder(call: Call<*>): D2Error.Builder {
- return D2Error.builder()
+ return getBaseErrorBuilder()
.url(getUrl(call.request()))
+ }
+
+ fun getBaseErrorBuilder(response: Response<*>): D2Error.Builder {
+ return getBaseErrorBuilder()
+ .url(getUrl(response.raw().request()))
+ }
+
+ fun getBaseErrorBuilder(): D2Error.Builder {
+ return D2Error.builder()
.errorComponent(D2ErrorComponent.Server)
}
diff --git a/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APIExecutorsDIModule.java b/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APIExecutorsDIModule.java
index 8142ee7bf0..7628b6ecd7 100644
--- a/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APIExecutorsDIModule.java
+++ b/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/APIExecutorsDIModule.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2022, University of Oslo
+ * Copyright (c) 2004-2023, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -47,6 +47,12 @@ RxAPICallExecutor rxApiCallExecutor(RxAPICallExecutorImpl impl) {
return impl;
}
+ @Provides
+ @Reusable
+ CoroutineAPICallExecutor coroutineAPICallExecutor(CoroutineAPICallExecutorImpl impl) {
+ return impl;
+ }
+
@Provides
@Reusable
APIDownloader apiDownloader(APIDownloaderImpl impl) {
diff --git a/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/CoroutineAPICallExecutor.kt b/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/CoroutineAPICallExecutor.kt
new file mode 100644
index 0000000000..b00c663bdd
--- /dev/null
+++ b/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/CoroutineAPICallExecutor.kt
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2004-2023, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.android.core.arch.api.executors.internal
+
+import org.hisp.dhis.android.core.arch.helpers.Result
+import org.hisp.dhis.android.core.maintenance.D2Error
+
+internal interface CoroutineAPICallExecutor {
+ suspend fun wrap(
+ storeError: Boolean = true,
+ acceptedErrorCodes: List? = null,
+ errorCatcher: APICallErrorCatcher? = null,
+ errorClass: Class? = null,
+ block: suspend () -> P
+ ): Result
+
+ suspend fun
wrapTransactionally(
+ cleanForeignKeyErrors: Boolean = true,
+ block: suspend () -> P
+ ): P
+}
diff --git a/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/CoroutineAPICallExecutorImpl.kt b/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/CoroutineAPICallExecutorImpl.kt
new file mode 100644
index 0000000000..280fc55c20
--- /dev/null
+++ b/core/src/main/java/org/hisp/dhis/android/core/arch/api/executors/internal/CoroutineAPICallExecutorImpl.kt
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2004-2023, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.android.core.arch.api.executors.internal
+
+import dagger.Reusable
+import javax.inject.Inject
+import kotlinx.coroutines.*
+import org.hisp.dhis.android.core.arch.db.access.DatabaseAdapter
+import org.hisp.dhis.android.core.arch.db.access.Transaction
+import org.hisp.dhis.android.core.arch.db.stores.internal.ObjectStore
+import org.hisp.dhis.android.core.arch.helpers.Result
+import org.hisp.dhis.android.core.arch.json.internal.ObjectMapperFactory
+import org.hisp.dhis.android.core.maintenance.D2Error
+import org.hisp.dhis.android.core.maintenance.internal.ForeignKeyCleaner
+import org.hisp.dhis.android.core.user.internal.UserAccountDisabledErrorCatcher
+import retrofit2.HttpException
+import retrofit2.Response
+
+@Reusable
+internal class CoroutineAPICallExecutorImpl @Inject constructor(
+ private val errorMapper: APIErrorMapper,
+ private val userAccountDisabledErrorCatcher: UserAccountDisabledErrorCatcher,
+ private val errorStore: ObjectStore