Skip to content

Commit

Permalink
Removing unused classes and methods
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrofsn committed Feb 26, 2019
1 parent 429325a commit e409986
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 96 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions sample/src/main/java/br/redcode/sample/data/entities/AnswerFull.kt

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,60 +5,6 @@ import br.redcode.dataform.lib.model.*
import br.redcode.sample.data.entities.*
import java.util.*

// -----------> FORM
fun Form.toEntity(): FormQuestionFull {
val entityFormSettings = settings.toEntity(idForm)
val listEntityQuestionsFull = arrayListOf<EntityQuestionFull>()
val awnserFull = arrayListOf<AnswerFull>()

questions.forEach { question ->
val entityQuestion = question.toEntity(idForm)
val currentIdQuestion = question.id

val entityLimit = question.limit?.toEntity(idQuestion = currentIdQuestion)
val entityOptionsQuestion = question.options?.fromOptionsToEntity(idQuestion = currentIdQuestion, idForm = idForm)
val entityCustomSettings = question.customSettings?.toEntity(idQuestion = currentIdQuestion, idForm = idForm)
// TODO and extra @RawValue?

val answer = answers.firstOrNull { currentIdQuestion == it.idQuestion }
if (answer != null) {
val entityAnswer = answer.toEntity(idQuestion = currentIdQuestion, idForm = idForm)

val answerIdsConfirmed = arrayListOf<String>()

val ids = answer.options?.filter { it.isNotEmpty() } ?: emptyList()
val options = entityOptionsQuestion?.filter { it.idOption in ids }?.map { it.idOption }
?: emptyList()
answerIdsConfirmed.addAll(options)

val answerFull = AnswerFull(
answer = entityAnswer,
options = answerIdsConfirmed,
images = answer.images
)

awnserFull.add(answerFull)
}

val entityQuestionFull = EntityQuestionFull(
question = entityQuestion,
limit = entityLimit,
options = entityOptionsQuestion,
customSettings = entityCustomSettings
)

listEntityQuestionsFull.add(entityQuestionFull)
}

return FormQuestionFull(
idForm = idForm,
lastUpdate = lastUpdate,
settings = entityFormSettings,
answers = awnserFull,
questions = listEntityQuestionsFull
)
}

fun FormSettings.toEntity(idForm: Long) = EntityFormSettings(
idForm = idForm,
showIndicatorError = showIndicatorError,
Expand Down

0 comments on commit e409986

Please sign in to comment.