diff --git a/app/src/org/commcare/tasks/EntityLoaderHelper.kt b/app/src/org/commcare/tasks/EntityLoaderHelper.kt index 35cd11c99..e55c75354 100644 --- a/app/src/org/commcare/tasks/EntityLoaderHelper.kt +++ b/app/src/org/commcare/tasks/EntityLoaderHelper.kt @@ -35,8 +35,22 @@ class EntityLoaderHelper( } } - fun loadEntities(nodeset: TreeReference): Pair>, List>? { + /** + * Loads and prepares a list of entities derived from the given nodeset + */ + fun loadEntities(nodeset: TreeReference): Pair>, List> { val references = factory.expandReferenceList(nodeset) + val entities = loadEntitiesWithReferences(references) + factory.prepareEntities(entities) + factory.printAndClearTraces("build") + return Pair>, List>(entities, references) + } + + + /** + * Loads a list of entities corresponding to the given references + */ + private fun loadEntitiesWithReferences(references: List): MutableList>? { val entities: MutableList> = ArrayList() focusTargetIndex = -1 var indexInFullList = 0 @@ -53,10 +67,7 @@ class EntityLoaderHelper( indexInFullList++ } } - - factory.prepareEntities(entities) - factory.printAndClearTraces("build") - return Pair>, List>(entities, references) + return entities } override fun cancel() {