Skip to content

Commit f1404ee

Browse files
authored
chore: [ANDROSDK-2331] migrate attribute value link and indicator domain models to Kotlin (#2646)
2 parents 1948c30 + 563f146 commit f1404ee

11 files changed

Lines changed: 398 additions & 239 deletions

core/api/core.api

Lines changed: 260 additions & 51 deletions
Large diffs are not rendered by default.

core/src/main/java/org/hisp/dhis/android/core/indicator/DataSetIndicatorLink.java renamed to core/src/main/java/org/hisp/dhis/android/core/attribute/DataElementAttributeValueLink.kt

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004-2023, University of Oslo
2+
* Copyright (c) 2004-2026, University of Oslo
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -25,36 +25,29 @@
2525
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2626
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727
*/
28-
package org.hisp.dhis.android.core.indicator;
2928

30-
import androidx.annotation.Nullable;
29+
package org.hisp.dhis.android.core.attribute
3130

32-
import com.google.auto.value.AutoValue;
31+
import org.hisp.dhis.android.annotations.ModelBuilder
32+
import org.hisp.dhis.android.core.common.CoreObject
3333

34-
import org.hisp.dhis.android.core.common.CoreObject;
34+
@ModelBuilder
35+
data class DataElementAttributeValueLink(
36+
val dataElement: String,
37+
val attribute: String,
38+
val value: String?,
39+
) : CoreObject {
3540

36-
@AutoValue
37-
public abstract class DataSetIndicatorLink implements CoreObject {
41+
fun dataElement(): String = dataElement
42+
fun attribute(): String = attribute
43+
fun value(): String? = value
3844

39-
@Nullable
40-
public abstract String dataSet();
45+
fun toBuilder(): Builder = DataElementAttributeValueLinkBuilder.from(this)
4146

42-
@Nullable
43-
public abstract String indicator();
47+
class Builder : DataElementAttributeValueLinkBuilder()
4448

45-
public static Builder builder() {
46-
return new AutoValue_DataSetIndicatorLink.Builder();
47-
}
48-
49-
public abstract Builder toBuilder();
50-
51-
@AutoValue.Builder
52-
public abstract static class Builder {
53-
54-
public abstract Builder dataSet(String dataSet);
55-
56-
public abstract Builder indicator(String indicator);
57-
58-
public abstract DataSetIndicatorLink build();
49+
companion object {
50+
@JvmStatic
51+
fun builder(): Builder = Builder()
5952
}
6053
}

core/src/main/java/org/hisp/dhis/android/core/indicator/IndicatorType.java renamed to core/src/main/java/org/hisp/dhis/android/core/attribute/ProgramAttributeValueLink.kt

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004-2023, University of Oslo
2+
* Copyright (c) 2004-2026, University of Oslo
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -26,36 +26,28 @@
2626
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727
*/
2828

29-
package org.hisp.dhis.android.core.indicator;
29+
package org.hisp.dhis.android.core.attribute
3030

31-
import androidx.annotation.Nullable;
31+
import org.hisp.dhis.android.annotations.ModelBuilder
32+
import org.hisp.dhis.android.core.common.CoreObject
3233

33-
import com.google.auto.value.AutoValue;
34+
@ModelBuilder
35+
data class ProgramAttributeValueLink(
36+
val program: String,
37+
val attribute: String,
38+
val value: String?,
39+
) : CoreObject {
3440

35-
import org.hisp.dhis.android.core.common.BaseIdentifiableObAuVa;
36-
import org.hisp.dhis.android.core.common.CoreObject;
41+
fun program(): String = program
42+
fun attribute(): String = attribute
43+
fun value(): String? = value
3744

38-
@AutoValue
39-
public abstract class IndicatorType extends BaseIdentifiableObAuVa implements CoreObject {
45+
fun toBuilder(): Builder = ProgramAttributeValueLinkBuilder.from(this)
4046

41-
@Nullable
42-
public abstract Boolean number();
47+
class Builder : ProgramAttributeValueLinkBuilder()
4348

44-
@Nullable
45-
public abstract Integer factor();
46-
47-
public static Builder builder() {
48-
return new AutoValue_IndicatorType.Builder();
49-
}
50-
51-
public abstract Builder toBuilder();
52-
53-
@AutoValue.Builder
54-
public abstract static class Builder extends BaseIdentifiableObAuVa.Builder<Builder> {
55-
public abstract Builder number(Boolean number);
56-
57-
public abstract Builder factor(Integer factor);
58-
59-
public abstract IndicatorType build();
49+
companion object {
50+
@JvmStatic
51+
fun builder(): Builder = Builder()
6052
}
6153
}

core/src/main/java/org/hisp/dhis/android/core/attribute/ProgramStageAttributeValueLink.java

Lines changed: 0 additions & 65 deletions
This file was deleted.

core/src/main/java/org/hisp/dhis/android/core/attribute/ProgramAttributeValueLink.java renamed to core/src/main/java/org/hisp/dhis/android/core/attribute/ProgramStageAttributeValueLink.kt

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004-2023, University of Oslo
2+
* Copyright (c) 2004-2026, University of Oslo
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -26,42 +26,28 @@
2626
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727
*/
2828

29-
package org.hisp.dhis.android.core.attribute;
29+
package org.hisp.dhis.android.core.attribute
3030

31-
import androidx.annotation.Nullable;
31+
import org.hisp.dhis.android.annotations.ModelBuilder
32+
import org.hisp.dhis.android.core.common.CoreObject
3233

33-
import com.google.auto.value.AutoValue;
34+
@ModelBuilder
35+
data class ProgramStageAttributeValueLink(
36+
val programStage: String,
37+
val attribute: String,
38+
val value: String?,
39+
) : CoreObject {
3440

35-
import org.hisp.dhis.android.core.common.CoreObject;
41+
fun programStage(): String = programStage
42+
fun attribute(): String = attribute
43+
fun value(): String? = value
3644

37-
@AutoValue
38-
public abstract class ProgramAttributeValueLink implements CoreObject {
45+
fun toBuilder(): Builder = ProgramStageAttributeValueLinkBuilder.from(this)
3946

40-
@Nullable
41-
public abstract String program();
47+
class Builder : ProgramStageAttributeValueLinkBuilder()
4248

43-
@Nullable
44-
public abstract String attribute();
45-
46-
@Nullable
47-
public abstract String value();
48-
49-
public static Builder builder() {
50-
return new AutoValue_ProgramAttributeValueLink.Builder();
51-
}
52-
53-
public abstract Builder toBuilder();
54-
55-
@AutoValue.Builder
56-
public abstract static class Builder {
57-
58-
59-
public abstract Builder program(String program);
60-
61-
public abstract Builder attribute(String attribute);
62-
63-
public abstract Builder value(String value);
64-
65-
public abstract ProgramAttributeValueLink build();
49+
companion object {
50+
@JvmStatic
51+
fun builder(): Builder = Builder()
6652
}
6753
}

core/src/main/java/org/hisp/dhis/android/core/attribute/DataElementAttributeValueLink.java renamed to core/src/main/java/org/hisp/dhis/android/core/indicator/DataSetIndicatorLink.kt

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004-2023, University of Oslo
2+
* Copyright (c) 2004-2026, University of Oslo
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -26,42 +26,26 @@
2626
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727
*/
2828

29-
package org.hisp.dhis.android.core.attribute;
29+
package org.hisp.dhis.android.core.indicator
3030

31-
import androidx.annotation.Nullable;
31+
import org.hisp.dhis.android.annotations.ModelBuilder
32+
import org.hisp.dhis.android.core.common.CoreObject
3233

33-
import com.google.auto.value.AutoValue;
34+
@ModelBuilder
35+
data class DataSetIndicatorLink(
36+
val dataSet: String,
37+
val indicator: String,
38+
) : CoreObject {
3439

35-
import org.hisp.dhis.android.core.common.CoreObject;
40+
fun dataSet(): String = dataSet
41+
fun indicator(): String = indicator
3642

37-
@AutoValue
38-
public abstract class DataElementAttributeValueLink implements CoreObject {
43+
fun toBuilder(): Builder = DataSetIndicatorLinkBuilder.from(this)
3944

40-
@Nullable
41-
public abstract String dataElement();
45+
class Builder : DataSetIndicatorLinkBuilder()
4246

43-
@Nullable
44-
public abstract String attribute();
45-
46-
@Nullable
47-
public abstract String value();
48-
49-
public static Builder builder() {
50-
return new AutoValue_DataElementAttributeValueLink.Builder();
51-
}
52-
53-
public abstract Builder toBuilder();
54-
55-
@AutoValue.Builder
56-
public abstract static class Builder {
57-
58-
59-
public abstract Builder dataElement(String dataElement);
60-
61-
public abstract Builder attribute(String attribute);
62-
63-
public abstract Builder value(String value);
64-
65-
public abstract DataElementAttributeValueLink build();
47+
companion object {
48+
@JvmStatic
49+
fun builder(): Builder = Builder()
6650
}
6751
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright (c) 2004-2026, University of Oslo
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* Redistributions of source code must retain the above copyright notice, this
8+
* list of conditions and the following disclaimer.
9+
*
10+
* Redistributions in binary form must reproduce the above copyright notice,
11+
* this list of conditions and the following disclaimer in the documentation
12+
* and/or other materials provided with the distribution.
13+
* Neither the name of the HISP project nor the names of its contributors may
14+
* be used to endorse or promote products derived from this software without
15+
* specific prior written permission.
16+
*
17+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24+
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
*/
28+
29+
package org.hisp.dhis.android.core.indicator
30+
31+
import org.hisp.dhis.android.annotations.ModelBuilder
32+
import org.hisp.dhis.android.core.common.BaseIdentifiableObjectKt
33+
import org.hisp.dhis.android.core.common.CoreObject
34+
import java.util.Date
35+
36+
@ModelBuilder
37+
data class IndicatorType(
38+
override val uid: String,
39+
override val code: String?,
40+
override val name: String?,
41+
override val displayName: String?,
42+
override val created: Date?,
43+
override val lastUpdated: Date?,
44+
override val deleted: Boolean?,
45+
val number: Boolean?,
46+
val factor: Int?,
47+
) : BaseIdentifiableObjectKt, CoreObject {
48+
49+
fun number(): Boolean? = number
50+
fun factor(): Int? = factor
51+
52+
fun toBuilder(): Builder = IndicatorTypeBuilder.from(this)
53+
54+
class Builder : IndicatorTypeBuilder()
55+
56+
companion object {
57+
@JvmStatic
58+
fun builder(): Builder = Builder()
59+
}
60+
}

core/src/main/java/org/hisp/dhis/android/persistence/attribute/DataElementAttributeValueLinkDB.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ internal data class DataElementAttributeValueLinkDB(
4444

4545
internal fun DataElementAttributeValueLink.toDB(): DataElementAttributeValueLinkDB {
4646
return DataElementAttributeValueLinkDB(
47-
dataElement = dataElement()!!,
48-
attribute = attribute()!!,
47+
dataElement = dataElement(),
48+
attribute = attribute(),
4949
value = value(),
5050
)
5151
}

0 commit comments

Comments
 (0)