From acb01d54ddfedb03d2072dc80ada56d7d3750280 Mon Sep 17 00:00:00 2001 From: Enrico Date: Wed, 6 Dec 2023 09:50:16 +0100 Subject: [PATCH] refactor rule effects to kotlin --- .../hisp/dhis/rules/models/RuleEffect.java | 12 ------------ .../org/hisp/dhis/rules/models/RuleEffect.kt | 18 ++++++++++++++++++ .../hisp/dhis/rules/models/RuleEffects.java | 18 ------------------ .../org/hisp/dhis/rules/models/RuleEffects.kt | 19 +++++++++++++++++++ 4 files changed, 37 insertions(+), 30 deletions(-) delete mode 100644 src/main/java/org/hisp/dhis/rules/models/RuleEffect.java create mode 100644 src/main/java/org/hisp/dhis/rules/models/RuleEffect.kt delete mode 100644 src/main/java/org/hisp/dhis/rules/models/RuleEffects.java create mode 100644 src/main/java/org/hisp/dhis/rules/models/RuleEffects.kt diff --git a/src/main/java/org/hisp/dhis/rules/models/RuleEffect.java b/src/main/java/org/hisp/dhis/rules/models/RuleEffect.java deleted file mode 100644 index 44c02cd0..00000000 --- a/src/main/java/org/hisp/dhis/rules/models/RuleEffect.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.hisp.dhis.rules.models; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -public record RuleEffect( @Nonnull String ruleId, @Nonnull RuleAction ruleAction, @CheckForNull String data ) -{ - public RuleEffect( @Nonnull String ruleId, @Nonnull RuleAction ruleAction ) - { - this( ruleId, ruleAction, "" ); - } -} diff --git a/src/main/java/org/hisp/dhis/rules/models/RuleEffect.kt b/src/main/java/org/hisp/dhis/rules/models/RuleEffect.kt new file mode 100644 index 00000000..25368dbf --- /dev/null +++ b/src/main/java/org/hisp/dhis/rules/models/RuleEffect.kt @@ -0,0 +1,18 @@ +package org.hisp.dhis.rules.models + +import javax.annotation.Nonnull + +data class RuleEffect( + val ruleId: String, + val ruleAction: RuleAction, + val data: String = "" +) +{ + fun data() : String { + return data + } + + fun ruleAction() : RuleAction { + return ruleAction + } +} \ No newline at end of file diff --git a/src/main/java/org/hisp/dhis/rules/models/RuleEffects.java b/src/main/java/org/hisp/dhis/rules/models/RuleEffects.java deleted file mode 100644 index 3cf6f8d8..00000000 --- a/src/main/java/org/hisp/dhis/rules/models/RuleEffects.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.hisp.dhis.rules.models; - -import javax.annotation.Nonnull; -import java.util.List; - -public record RuleEffects( - @Nonnull TrackerObjectType trackerObjectType, - @Nonnull String trackerObjectUid, - @Nonnull List ruleEffects) -{ - public boolean isEnrollment(){ - return this.trackerObjectType == TrackerObjectType.ENROLLMENT; - } - - public boolean isEvent(){ - return this.trackerObjectType == TrackerObjectType.EVENT; - } -} diff --git a/src/main/java/org/hisp/dhis/rules/models/RuleEffects.kt b/src/main/java/org/hisp/dhis/rules/models/RuleEffects.kt new file mode 100644 index 00000000..5ceaf099 --- /dev/null +++ b/src/main/java/org/hisp/dhis/rules/models/RuleEffects.kt @@ -0,0 +1,19 @@ +package org.hisp.dhis.rules.models +data class RuleEffects( + val trackerObjectType: TrackerObjectType, + val trackerObjectUid: String, + val ruleEffects: List +) { + val isEnrollment: Boolean + get() = trackerObjectType == TrackerObjectType.ENROLLMENT + val isEvent: Boolean + get() = trackerObjectType == TrackerObjectType.EVENT + + fun ruleEffects(): List { + return ruleEffects + } + + fun trackerObjectUid(): String { + return trackerObjectUid + } +}