Skip to content

Commit

Permalink
separate loading of entities from references into a method
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham1g5 committed Dec 5, 2024
1 parent 17fc613 commit 36bbe67
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions app/src/org/commcare/tasks/EntityLoaderHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,22 @@ class EntityLoaderHelper(
}
}

fun loadEntities(nodeset: TreeReference): Pair<List<Entity<TreeReference>>, List<TreeReference>>? {
/**
* Loads and prepares a list of entities derived from the given nodeset
*/
fun loadEntities(nodeset: TreeReference): Pair<List<Entity<TreeReference>>, List<TreeReference>> {
val references = factory.expandReferenceList(nodeset)
val entities = loadEntitiesWithReferences(references)
factory.prepareEntities(entities)
factory.printAndClearTraces("build")
return Pair<List<Entity<TreeReference>>, List<TreeReference>>(entities, references)
}


/**
* Loads a list of entities corresponding to the given references
*/
private fun loadEntitiesWithReferences(references: List<TreeReference>): MutableList<Entity<TreeReference>>? {
val entities: MutableList<Entity<TreeReference>> = ArrayList()
focusTargetIndex = -1
var indexInFullList = 0
Expand All @@ -53,10 +67,7 @@ class EntityLoaderHelper(
indexInFullList++
}
}

factory.prepareEntities(entities)
factory.printAndClearTraces("build")
return Pair<List<Entity<TreeReference>>, List<TreeReference>>(entities, references)
return entities
}

override fun cancel() {
Expand Down

0 comments on commit 36bbe67

Please sign in to comment.