-
Notifications
You must be signed in to change notification settings - Fork 16
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
fix: Fix native trigger environment #135
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
package org.hisp.dhis.rules | ||
|
||
expect fun getEnvironment(): String | ||
import org.hisp.dhis.rules.models.TriggerEnvironment | ||
|
||
expect fun getEnvironment(): TriggerEnvironment |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
package org.hisp.dhis.rules.api | ||
|
||
import org.hisp.dhis.rules.engine.DefaultRuleEngine | ||
import org.hisp.dhis.rules.getEnvironment | ||
import org.hisp.dhis.rules.models.* | ||
import org.hisp.dhis.rules.models.TriggerEnvironment.SERVER | ||
import kotlin.jvm.JvmOverloads | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, after a second thought, I do think we need to annotate the methods as overloaded if we want to make it optional in Java. In Kotlin, the last parameter would be optional, but in Java it will be mandatory unless the methods are mark as overloaded There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately, @jvmoverloads is not allowed on interfaces and default parameters are not allowed on overriding methods. |
||
import kotlin.jvm.JvmStatic | ||
|
||
interface RuleEngine { | ||
fun validate(expression: String, dataItemStore: Map<String, DataItem>): RuleValidationResult | ||
fun validateDataFieldExpression(expression: String, dataItemStore: Map<String, DataItem>): RuleValidationResult | ||
fun evaluateAll(enrollmentTarget: RuleEnrollment?, eventsTarget: List<RuleEvent>, executionContext: RuleEngineContext): List<RuleEffects> | ||
fun evaluate(target: RuleEnrollment, ruleEvents: List<RuleEvent>, executionContext: RuleEngineContext): List<RuleEffect> | ||
fun evaluate(target: RuleEvent, ruleEnrollment: RuleEnrollment?, ruleEvents: List<RuleEvent>, executionContext: RuleEngineContext): List<RuleEffect> | ||
fun evaluateAll(enrollmentTarget: RuleEnrollment?, eventsTarget: List<RuleEvent>, executionContext: RuleEngineContext, triggerEnvironment: TriggerEnvironment = getEnvironment()): List<RuleEffects> | ||
fun evaluate(target: RuleEnrollment, ruleEvents: List<RuleEvent>, executionContext: RuleEngineContext, triggerEnvironment: TriggerEnvironment = getEnvironment()): List<RuleEffect> | ||
fun evaluate(target: RuleEvent, ruleEnrollment: RuleEnrollment?, ruleEvents: List<RuleEvent>, executionContext: RuleEngineContext, triggerEnvironment: TriggerEnvironment = getEnvironment()): List<RuleEffect> | ||
|
||
companion object { | ||
@JvmStatic | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package org.hisp.dhis.rules | ||
|
||
actual fun getEnvironment(): String { | ||
return "WEBCLIENT" | ||
import org.hisp.dhis.rules.models.TriggerEnvironment | ||
|
||
actual fun getEnvironment(): TriggerEnvironment { | ||
return TriggerEnvironment.WEBCLIENT | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package org.hisp.dhis.rules | ||
|
||
actual fun getEnvironment(): String { | ||
return "SERVER" | ||
import org.hisp.dhis.rules.models.TriggerEnvironment | ||
|
||
actual fun getEnvironment(): TriggerEnvironment { | ||
return TriggerEnvironment.SERVER | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package org.hisp.dhis.rules | ||
|
||
actual fun getEnvironment(): String { | ||
return "ANDROIDCLIENT" | ||
import org.hisp.dhis.rules.models.TriggerEnvironment | ||
|
||
actual fun getEnvironment(): TriggerEnvironment { | ||
return TriggerEnvironment.NATIVE | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two imports are not used and could be removed