Search in sources :

Example 1 with ChoiceTagEntity

use of org.mifos.platform.questionnaire.domain.ChoiceTagEntity in project head by mifos.

the class QuestionnaireMapperImpl method mapToChoiceTags.

private void mapToChoiceTags(ChoiceDto choiceDto, Set<ChoiceTagEntity> choiceTagEntities) {
    if (isNotEmpty(choiceTagEntities)) {
        List<String> choiceTags = new ArrayList<String>();
        for (ChoiceTagEntity tag : choiceTagEntities) {
            choiceTags.add(tag.getTagText());
        }
        choiceDto.setTags(choiceTags);
    }
}
Also used : ChoiceTagEntity(org.mifos.platform.questionnaire.domain.ChoiceTagEntity) ArrayList(java.util.ArrayList)

Example 2 with ChoiceTagEntity

use of org.mifos.platform.questionnaire.domain.ChoiceTagEntity in project head by mifos.

the class QuestionnaireServiceIntegrationTest method getChoice.

private QuestionChoiceEntity getChoice(String choiceText, int choiceOrder, String... tagTexts) {
    QuestionChoiceEntity questionChoiceEntity = new QuestionChoiceEntity();
    questionChoiceEntity.setChoiceText(choiceText);
    questionChoiceEntity.setChoiceOrder(choiceOrder);
    Set<ChoiceTagEntity> tags = new HashSet<ChoiceTagEntity>();
    for (String tagText : tagTexts) {
        tags.add(getTag(tagText));
    }
    questionChoiceEntity.setTags(tags);
    return questionChoiceEntity;
}
Also used : QuestionChoiceEntity(org.mifos.platform.questionnaire.domain.QuestionChoiceEntity) ChoiceTagEntity(org.mifos.platform.questionnaire.domain.ChoiceTagEntity) HashSet(java.util.HashSet)

Example 3 with ChoiceTagEntity

use of org.mifos.platform.questionnaire.domain.ChoiceTagEntity in project head by mifos.

the class QuestionnaireServiceIntegrationTest method getTag.

private ChoiceTagEntity getTag(String tagText) {
    ChoiceTagEntity choiceTagEntity = new ChoiceTagEntity();
    choiceTagEntity.setTagText(tagText);
    return choiceTagEntity;
}
Also used : ChoiceTagEntity(org.mifos.platform.questionnaire.domain.ChoiceTagEntity)

Example 4 with ChoiceTagEntity

use of org.mifos.platform.questionnaire.domain.ChoiceTagEntity in project head by mifos.

the class QuestionnaireMapperImpl method mapToChoice.

private QuestionChoiceEntity mapToChoice(ChoiceDto choice) {
    QuestionChoiceEntity choiceEntity = new QuestionChoiceEntity(choice.getValue());
    choiceEntity.setChoiceOrder(choice.getOrder());
    List<String> tags = choice.getTags();
    if (isNotEmpty(tags)) {
        Set<ChoiceTagEntity> choiceTagEntities = new LinkedHashSet<ChoiceTagEntity>();
        for (String tag : tags) {
            ChoiceTagEntity choiceTagEntity = new ChoiceTagEntity();
            choiceTagEntity.setTagText(tag);
            choiceTagEntities.add(choiceTagEntity);
        }
        choiceEntity.setTags(choiceTagEntities);
    }
    return choiceEntity;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) QuestionChoiceEntity(org.mifos.platform.questionnaire.domain.QuestionChoiceEntity) ChoiceTagEntity(org.mifos.platform.questionnaire.domain.ChoiceTagEntity)

Example 5 with ChoiceTagEntity

use of org.mifos.platform.questionnaire.domain.ChoiceTagEntity in project head by mifos.

the class QuestionnaireMapperTest method getChoiceEntity.

private QuestionChoiceEntity getChoiceEntity(String choiceText, String... tagTexts) {
    QuestionChoiceEntity choiceEntity = new QuestionChoiceEntity(choiceText);
    Set<ChoiceTagEntity> tags = new HashSet<ChoiceTagEntity>();
    for (String tagText : tagTexts) {
        ChoiceTagEntity choiceTagEntity = new ChoiceTagEntity();
        choiceTagEntity.setTagText(tagText);
        tags.add(choiceTagEntity);
    }
    choiceEntity.setTags(tags);
    return choiceEntity;
}
Also used : QuestionChoiceEntity(org.mifos.platform.questionnaire.domain.QuestionChoiceEntity) ChoiceTagEntity(org.mifos.platform.questionnaire.domain.ChoiceTagEntity) Matchers.anyString(org.mockito.Matchers.anyString) HashSet(java.util.HashSet)

Aggregations

ChoiceTagEntity (org.mifos.platform.questionnaire.domain.ChoiceTagEntity)5 QuestionChoiceEntity (org.mifos.platform.questionnaire.domain.QuestionChoiceEntity)3 HashSet (java.util.HashSet)2 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 Matchers.anyString (org.mockito.Matchers.anyString)1