Skip to content

Commit

Permalink
Merge pull request #28 from EyeSeeTea/fix/with_correct_uid_in_pattern…
Browse files Browse the repository at this point in the history
…_and_worng_num_props_show_display_name

If items inside token is distinct of 2 show display name
  • Loading branch information
ifoche authored Aug 19, 2020
2 parents 97a4f8b + 699da29 commit 85798f7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/src/main/assets/paperwork.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"buildTime":"2020-08-13 13:58","gitSha":"c8d8a7e9a"}
{"buildTime":"2020-08-17 11:17","gitSha":"bcc96daab"}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ package org.dhis2.usecases.eventsWithoutRegistration.eventCapture

import org.dhis2.Bindings.valueByPropName
import org.hisp.dhis.android.core.D2
import timber.log.Timber
import java.util.HashMap

class TitlePatternFormatException(message: String?) : Exception(message) {}

fun getProgramStageName(d2: D2, eventUid: String): String {
val event = d2.eventModule().events().uid(eventUid).blockingGet()
val programStage = d2.programModule().programStages().uid(event.programStage()).blockingGet()
Expand Down Expand Up @@ -78,15 +75,12 @@ fun getProgramStageNameByAttributeValue(
if (!dataElementsMap.containsKey(tokenWithBrackets)) {
val tokenItems = tokenWithBrackets.substring(2, it.value.length - 2).split(".")

if (tokenItems.size == 1) {
dataElementsMap[tokenWithBrackets] =
getDataElementValue(tokenItems[0], "displayName")
} else if (tokenItems.size == 2) {
if (tokenItems.size == 2) {
dataElementsMap[tokenWithBrackets] =
getDataElementValue(tokenItems[0], tokenItems[1])
} else {
Timber.w("Invalid TitlePattern ")
throw TitlePatternFormatException("Invalid TitlePattern")
dataElementsMap[tokenWithBrackets] =
getDataElementValue(tokenItems[0], "displayName")
}
}
}
Expand Down

0 comments on commit 85798f7

Please sign in to comment.