text:
package org.mifos.platform.questionnaire.mappers;

import java.util.HashMap;
import org.mifos.platform.questionnaire.domain.AnswerType;
import org.mifos.platform.questionnaire.domain.ChoiceTagEntity;
import org.mifos.platform.questionnaire.domain.EventSourceEntity;
import org.mifos.platform.questionnaire.domain.QuestionChoiceEntity;
import org.mifos.platform.questionnaire.domain.QuestionEntity;
import org.mifos.platform.questionnaire.domain.QuestionGroup;
import org.mifos.platform.questionnaire.domain.QuestionGroupInstance;
import org.mifos.platform.questionnaire.domain.QuestionGroupLink;
import org.mifos.platform.questionnaire.domain.QuestionGroupResponse;
import org.mifos.platform.questionnaire.domain.QuestionGroupState;
import org.mifos.platform.questionnaire.domain.QuestionState;
import org.mifos.platform.questionnaire.domain.Section;
import org.mifos.platform.questionnaire.domain.SectionLink;
import org.mifos.platform.questionnaire.domain.SectionQuestion;
import org.mifos.platform.questionnaire.domain.SectionQuestionLink;
import org.mifos.platform.questionnaire.persistence.EventSourceDao;
import org.mifos.platform.questionnaire.persistence.QuestionDao;
import org.mifos.platform.questionnaire.persistence.QuestionGroupDao;
import org.mifos.platform.questionnaire.persistence.QuestionGroupInstanceDao;
import org.mifos.platform.questionnaire.persistence.SectionDao;
import org.mifos.platform.questionnaire.persistence.SectionLinkDao;
import org.mifos.platform.questionnaire.persistence.SectionQuestionDao;
import org.mifos.platform.questionnaire.persistence.SectionQuestionLinkDao;
import org.mifos.platform.questionnaire.service.SelectionDetail;
import org.mifos.platform.questionnaire.service.dtos.ChoiceDto;
import org.mifos.platform.questionnaire.service.dtos.EventSourceDto;
import org.mifos.platform.questionnaire.service.QuestionDetail;
import org.mifos.platform.questionnaire.service.QuestionGroupDetail;
import org.mifos.platform.questionnaire.service.QuestionGroupDetails;
import org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail;
import org.mifos.platform.questionnaire.service.QuestionLinkDetail;
import org.mifos.platform.questionnaire.service.QuestionType;
import org.mifos.platform.questionnaire.service.SectionDetail;
import org.mifos.platform.questionnaire.service.SectionLinkDetail;
import org.mifos.platform.questionnaire.service.SectionQuestionDetail;
import org.mifos.platform.questionnaire.service.dtos.QuestionDto;
import org.mifos.platform.questionnaire.service.dtos.QuestionGroupDto;
import org.mifos.platform.questionnaire.service.dtos.QuestionGroupInstanceDto;
import org.mifos.platform.questionnaire.service.dtos.QuestionGroupResponseDto;
import org.mifos.platform.questionnaire.service.dtos.SectionDto;
import org.mifos.platform.util.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import static org.mifos.platform.util.CollectionUtils.asMap;
import static org.mifos.platform.util.CollectionUtils.isNotEmpty;
import static org.mifos.platform.util.MapEntry.makeEntry;

@SuppressWarnings({"PMD", "UnusedDeclaration"})
public class QuestionnaireMapperImpl implements QuestionnaireMapper {
    private Map<AnswerType, QuestionType> answerToQuestionType;
    private Map<QuestionType, AnswerType> questionToAnswerType;

    @Autowired
    private EventSourceDao eventSourceDao;

    @Autowired
    private QuestionDao questionDao;

    @Autowired
    private QuestionGroupDao questionGroupDao;

    @Autowired
    private SectionQuestionDao sectionQuestionDao;

    @Autowired
    private SectionDao sectionDao;

    @Autowired
    private QuestionGroupInstanceDao questionGroupInstanceDao;

    @Autowired
    private SectionLinkDao sectionLinkDao;

    @Autowired
    private SectionQuestionLinkDao sectionQuestionLinkDao;

    public QuestionnaireMapperImpl() {
        this(null, null, null, null,null, null,null,null);
    }

    public QuestionnaireMapperImpl(EventSourceDao eventSourceDao, QuestionDao questionDao, QuestionGroupDao questionGroupDao,
            SectionQuestionDao sectionQuestionDao, QuestionGroupInstanceDao questionGroupInstanceDao, SectionDao sectionDao, SectionLinkDao sectionLinkDao, SectionQuestionLinkDao sectionQuestionLinkDao) {
        populateAnswerToQuestionTypeMap();
        populateQuestionToAnswerTypeMap();
        this.eventSourceDao = eventSourceDao;
        this.questionDao = questionDao;
        this.questionGroupDao = questionGroupDao;
        this.sectionQuestionDao = sectionQuestionDao;
        this.questionGroupInstanceDao = questionGroupInstanceDao;
        this.sectionDao = sectionDao;
        this.sectionLinkDao = sectionLinkDao;
        this.sectionQuestionLinkDao = sectionQuestionLinkDao;
    }

    @Override
    public List<QuestionDetail> mapToQuestionDetails(List<QuestionEntity> questions) {
        List<QuestionDetail> questionDetails = new ArrayList<QuestionDetail>();
        for (QuestionEntity question : questions) {
            questionDetails.add(mapToQuestionDetail(question));
        }
        return questionDetails;
    }

    @Override
    public QuestionDetail mapToQuestionDetail(QuestionEntity question) {
        return mapToQuestionDetail(question, mapToQuestionType(question.getAnswerTypeAsEnum()));
    }

    private List<ChoiceDto> mapToQuestionChoices(List<QuestionChoiceEntity> choices) {
        List<ChoiceDto> questionChoices = new LinkedList<ChoiceDto>();
        for (QuestionChoiceEntity questionChoice : choices) {
            questionChoices.add(mapToChoiceDetail(questionChoice));
        }
        return questionChoices;
    }

    private ChoiceDto mapToChoiceDetail(QuestionChoiceEntity questionChoice) {
        ChoiceDto choiceDto = new ChoiceDto(questionChoice.getChoiceText());
        mapToChoiceTags(choiceDto, questionChoice.getTags());
        return choiceDto;
    }

    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);
        }
    }

    @Override
    public QuestionEntity mapToQuestion(QuestionDetail questionDetail) {
        QuestionEntity question = getQuestion(questionDetail);
        question.setQuestionId(questionDetail.getId() > 0 ? questionDetail.getId() : 0);
        question.setNickname(questionDetail.getNickname());
        question.setQuestionText(questionDetail.getText());
        question.setAnswerType(mapToAnswerType(questionDetail.getType()));
        question.setChoices(mapToChoices(questionDetail.getAnswerChoices()));
        question.setQuestionState(QuestionState.getQuestionStateEnum(questionDetail.isActive(), questionDetail.isEditable()));
        mapBoundsForNumericQuestionDetail(questionDetail, question);
        return question;
    }

    private QuestionEntity getQuestion(QuestionDetail questionDetail) {
        return questionDetail.isNewQuestion() ? new QuestionEntity() : questionDao.getDetails(questionDetail.getId());
    }

    private void mapBoundsForNumericQuestionDetail(QuestionDetail questionDetail, QuestionEntity question) {
        if (questionDetail.getType() == QuestionType.NUMERIC) {
            question.setNumericMin(questionDetail.getNumericMin());
            question.setNumericMax(questionDetail.getNumericMax());
        }
    }

    private List<QuestionChoiceEntity> mapToChoices(List<ChoiceDto> choices) {
        List<QuestionChoiceEntity> questionChoices = new LinkedList<QuestionChoiceEntity>();
        if (CollectionUtils.isNotEmpty(choices)) {
            for (ChoiceDto choice : choices) {
                questionChoices.add(mapToChoice(choice));
            }
        }
        return questionChoices;
    }

    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;
    }

    @Override
    public QuestionGroup mapToQuestionGroup(QuestionGroupDetail questionGroupDetail) {
        QuestionGroup questionGroup = getQuestionGroup(questionGroupDetail);
        questionGroup.setTitle(questionGroupDetail.getTitle());
        questionGroup.setState(QuestionGroupState.getQuestionGroupStateAsEnum(questionGroupDetail.isActive()));
        questionGroup.setDateOfCreation(getCurrentDateTime());
        questionGroup.setSections(mapToSections(questionGroupDetail));
        questionGroup.setEventSources(mapEventSourceDtoToEntity(questionGroupDetail.getEventSources()));
        questionGroup.setEditable(questionGroupDetail.isEditable());
        questionGroup.setActivityId(questionGroupDetail.getActivityId());
        return questionGroup;
    }

    private QuestionGroup getQuestionGroup(QuestionGroupDetail questionGroupDetail) {
        return questionGroupDetail.isNewQuestionGroup() ? new QuestionGroup() : questionGroupDao.getDetails(questionGroupDetail.getId());
    }

    private Set<EventSourceEntity> mapEventSourceDtoToEntity(List<EventSourceDto> eventSourceDtos) {
        Set<EventSourceEntity> eventSources = new HashSet<EventSourceEntity>();
        for (EventSourceDto eventSourceDto : eventSourceDtos) {
            List list = eventSourceDao.retrieveByEventAndSource(eventSourceDto.getEvent(), eventSourceDto.getSource());
            for (Object obj : list) {
                eventSources.add((EventSourceEntity) obj);
            }
        }
        return eventSources;
    }

    private List<Section> mapToSections(QuestionGroupDetail questionGroupDetail) {
        List<Section> sections = new ArrayList<Section>();
        for (SectionDetail sectionDetail : questionGroupDetail.getSectionDetails()) {
            sections.add(mapToSection(questionGroupDetail, sectionDetail));
        }
        return sections;
    }

    private Section mapToSection(QuestionGroupDetail questionGroupDetail, SectionDetail sectionDetail) {
        Section section = getSection(questionGroupDetail, sectionDetail);
        section.setQuestions(mapToSectionQuestions(sectionDetail.getQuestions(), section));
        if (sectionDetail.getSequenceNumber() != null) {
            section.setSequenceNumber(sectionDetail.getSequenceNumber());
        }
        return section;
    }

    private Section getSection(QuestionGroupDetail questionGroupDetail, SectionDetail sectionDetail) {
        String sectionName = sectionDetail.getName();
        Section section = new Section(sectionName);
        if (!questionGroupDetail.isNewQuestionGroup()) {
            List<Section> sections = questionGroupDao.retrieveSectionByNameAndQuestionGroupId(sectionName, questionGroupDetail.getId());
            if (isNotEmpty(sections)) {
                section = sections.get(0);
            }
        }
        return section;
    }

    private List<SectionQuestion> mapToSectionQuestions(List<SectionQuestionDetail> sectionQuestionDetails, Section section) {
        List<SectionQuestion> sectionQuestions = new ArrayList<SectionQuestion>();
        for (int i = 0, sectionQuestionDetailsSize = sectionQuestionDetails.size(); i < sectionQuestionDetailsSize; i++) {
            SectionQuestionDetail sectionQuestionDetail = sectionQuestionDetails.get(i);
            sectionQuestions.add(mapToSectionQuestion(sectionQuestionDetail, i, section));
        }
        return sectionQuestions;
    }

    private SectionQuestion mapToSectionQuestion(SectionQuestionDetail sectionQuestionDetail, int seqNum, Section section) {
        QuestionDetail questionDetail = sectionQuestionDetail.getQuestionDetail();
        SectionQuestion sectionQuestion = getSectionQuestion(questionDetail, section);
        sectionQuestion.setRequired(sectionQuestionDetail.isMandatory());
        sectionQuestion.setShowOnPage(sectionQuestionDetail.isShowOnPage());
        sectionQuestion.setSequenceNumber(sectionQuestionDetail.getSequenceNumber());
        if (sectionQuestion.isNewSectionQuestion()) {
            sectionQuestion.setQuestion(mapToQuestion(questionDetail));
            sectionQuestion.setSequenceNumber(seqNum);
            sectionQuestion.setSection(section);
        }
        return sectionQuestion;
    }

    private SectionQuestion getSectionQuestion(QuestionDetail questionDetail, Section section) {
        SectionQuestion sectionQuestion = new SectionQuestion();
        if (!questionDetail.isNewQuestion() && !section.isNewSection()) {
            List<SectionQuestion> sectionQuestions = sectionQuestionDao.retrieveFromQuestionIdSectionId(section.getId(), questionDetail.getId());
            if (isNotEmpty(sectionQuestions)) {
                sectionQuestion = sectionQuestions.get(0);
            }
        }
        return sectionQuestion;
    }

    @Override
    public QuestionGroupDetail mapToQuestionGroupDetail(QuestionGroup questionGroup) {
        List<SectionDetail> sectionDetails = mapToSectionDetails(questionGroup.getSections());
        List<SectionLink> sectionLinks = new ArrayList<SectionLink>();
        List<SectionQuestionLink> sectionQuestionLinks = new ArrayList<SectionQuestionLink>();

        for(SectionDetail sectionDetail : sectionDetails){
            for(SectionQuestionDetail sectionQuestionDetail : sectionDetail.getQuestionDetails()){
                if(!sectionLinkDao.retrieveDependentSectionLinksFromQuestion(sectionQuestionDetail.getId()).isEmpty())
                    sectionLinks.addAll(sectionLinkDao.retrieveDependentSectionLinksFromQuestion(sectionQuestionDetail.getId()));
                if(!sectionQuestionLinkDao.retrieveDependentSectionQuestionLinksFromQuestion(sectionQuestionDetail.getId()).isEmpty())
                    sectionQuestionLinks.addAll(sectionQuestionLinkDao.retrieveDependentSectionQuestionLinksFromQuestion(sectionQuestionDetail.getId()));
            }
        }
        List<EventSourceDto> eventSourceDtos = mapToEventSource(questionGroup.getEventSources());
        return new QuestionGroupDetail(questionGroup.getId(), questionGroup.getTitle(),
                eventSourceDtos, sectionDetails, questionGroup.isEditable(),
                QuestionGroupState.ACTIVE.equals(questionGroup.getState()), questionGroup.isPpi(), mapToQuestionLinkDetails(sectionQuestionLinks), mapToSectionLinkDetails(sectionLinks));
    }

    private List<EventSourceDto> mapToEventSource(Set<EventSourceEntity> eventSources) {
        if (eventSources == null || eventSources.isEmpty()) {
            return null;
        }
        List<EventSourceDto> eventSourceDtos = new ArrayList<EventSourceDto>();
        for (EventSourceEntity eventSourceEntity : eventSources) {
            eventSourceDtos.add(new EventSourceDto(eventSourceEntity.getEvent().getName(), eventSourceEntity.getSource().getEntityType(), eventSourceEntity.getDescription()));
        }

        return eventSourceDtos;
    }

    private List<SectionDetail> mapToSectionDetails(List<Section> sections) {
        List<SectionDetail> sectionDetails = new ArrayList<SectionDetail>();
        for (Section section : sections) {
            sectionDetails.add(mapToSectionDetail(section));
        }
        return sectionDetails;
    }

    private SectionDetail mapToSectionDetail(Section section) {
        SectionDetail sectionDetail = new SectionDetail();
        sectionDetail.setId(section.getId());
        sectionDetail.setName(section.getName());
        if (section.getSequenceNumber() != null) {
            sectionDetail.setSequenceNumber(section.getSequenceNumber());
        }
        for (SectionQuestion sectionQuestion : section.getQuestions()) {
            QuestionEntity question = sectionQuestion.getQuestion();
            QuestionType type = mapToQuestionType(question.getAnswerTypeAsEnum());
            boolean required = sectionQuestion.isRequired();
            QuestionDetail questionDetail = mapToQuestionDetail(question, type);
            sectionDetail.addQuestion(mapToSectionQuestionDetail(sectionQuestion, required, sectionQuestion.isShowOnPage(), questionDetail));
        }
        return sectionDetail;
    }

    private SectionQuestionDetail mapToSectionQuestionDetail(SectionQuestion sectionQuestion, boolean required, boolean showOnPage, QuestionDetail questionDetail) {
        if (sectionQuestion.getSequenceNumber() != null) {
            return new SectionQuestionDetail(sectionQuestion.getId(), questionDetail, required, showOnPage, sectionQuestion.getSequenceNumber());
        }
        return new SectionQuestionDetail(sectionQuestion.getId(), questionDetail, required);
    }

    private QuestionDetail mapToQuestionDetail(QuestionEntity question, QuestionType type) {
        List<ChoiceDto> answerChoices = mapToQuestionChoices(question.getChoices());
        QuestionDetail questionDetail = new QuestionDetail(question.getQuestionId(), question.getQuestionText(), type, question.isActive(), question.isEditable());
        questionDetail.setNickname(question.getNickname());
        questionDetail.setAnswerChoices(answerChoices);
        mapBoundsForNumericQuestion(question, questionDetail);
        return questionDetail;
    }

    private void mapBoundsForNumericQuestion(QuestionEntity question, QuestionDetail questionDetail) {
        if (question.getAnswerTypeAsEnum() == AnswerType.NUMBER) {
            questionDetail.setNumericMin(question.getNumericMin());
            questionDetail.setNumericMax(question.getNumericMax());
        }
    }

    @Override
    public List<QuestionGroupDetail> mapToQuestionGroupDetails(List<QuestionGroup> questionGroups) {
        List<QuestionGroupDetail> questionGroupDetails = new ArrayList<QuestionGroupDetail>();
        for (QuestionGroup questionGroup : questionGroups) {
            questionGroupDetails.add(mapToQuestionGroupDetail(questionGroup));
        }
        return questionGroupDetails;
    }

    @Override
    public List<EventSourceDto> mapToEventSources(List<EventSourceEntity> eventSourceEntities) {
        List<EventSourceDto> eventSourceDtos = new ArrayList<EventSourceDto>();
        for (EventSourceEntity eventSourceEntity : eventSourceEntities) {
            eventSourceDtos.add(mapEventSource(eventSourceEntity));
        }
        return eventSourceDtos;
    }

    @Override
    public List<QuestionGroupInstance> mapToQuestionGroupInstances(QuestionGroupDetails questionGroupDetails) {
        List<QuestionGroupInstance> questionGroupInstances = new ArrayList<QuestionGroupInstance>();
        for (QuestionGroupDetail questionGroupDetail : questionGroupDetails.getDetails()) {
            questionGroupInstances.add(mapToQuestionGroupInstance(questionGroupDetails.getCreatorId(),
                    questionGroupDetails.getEntityId(), questionGroupDetails.getEventSourceId(), questionGroupDetail));
        }
        return questionGroupInstances;
    }

    @Override
    public List<QuestionGroupInstanceDetail> mapToQuestionGroupInstanceDetails(List<QuestionGroupInstance> questionGroupInstances) {
        List<QuestionGroupInstanceDetail> questionGroupInstanceDetails = new ArrayList<QuestionGroupInstanceDetail>();
        for (QuestionGroupInstance questionGroupInstance : questionGroupInstances) {
            questionGroupInstanceDetails.add(mapToQuestionGroupInstanceDetail(questionGroupInstance));
        }
        return questionGroupInstanceDetails;
    }

    @Override
    public QuestionGroupInstanceDetail mapToQuestionGroupInstanceDetail(QuestionGroupInstance questionGroupInstance) {
        QuestionGroupDetail questionGroupDetail = mapToQuestionGroupDetail(questionGroupInstance.getQuestionGroup());
        QuestionGroupInstanceDetail questionGroupInstanceDetail = new QuestionGroupInstanceDetail();
        questionGroupInstanceDetail.setId(questionGroupInstance.getId());
        questionGroupInstanceDetail.setDateCompleted(questionGroupInstance.getDateConducted());
        questionGroupInstanceDetail.setQuestionGroupDetail(questionGroupDetail);
        mapQuestionResponses(questionGroupInstance.getQuestionGroupResponses(), questionGroupInstanceDetail.getQuestionGroupDetail());
        return questionGroupInstanceDetail;
    }

    @Override
    public void mapToQuestionResponse(SectionQuestionDetail sectionQuestionDetail, List<QuestionGroupResponse> questionGroupResponses) {
        if (sectionQuestionDetail.isMultiSelectQuestion()) {
            setMultiChoiceResponses(questionGroupResponses, sectionQuestionDetail);
        } else {
            setResponse(questionGroupResponses, sectionQuestionDetail);
        }
    }

    @Override
    public QuestionGroupInstanceDetail mapToEmptyQuestionGroupInstanceDetail(QuestionGroup questionGroup) {
        QuestionGroupInstanceDetail questionGroupInstanceDetail = new QuestionGroupInstanceDetail();
        questionGroupInstanceDetail.setId(0);
        questionGroupInstanceDetail.setQuestionGroupDetail(mapToQuestionGroupDetail(questionGroup));
        return questionGroupInstanceDetail;
    }

    @Override
    public QuestionGroup mapToQuestionGroup(QuestionGroupDto questionGroupDto) {
        QuestionGroup questionGroup = new QuestionGroup();
        questionGroup.setEditable(questionGroupDto.isEditable());
        questionGroup.setDateOfCreation(getCurrentDateTime());
        questionGroup.setPpi(questionGroupDto.isPpi());
        questionGroup.setEventSources(mapEventSourceDtoToEntity(questionGroupDto.getEventSourceDtos()));
        questionGroup.setTitle(questionGroupDto.getTitle());
        questionGroup.setState(questionGroupDto.isActive() ? QuestionGroupState.ACTIVE : QuestionGroupState.INACTIVE);
        questionGroup.setSections(mapToSectionsFromDtos(questionGroupDto.getSections()));
        questionGroup.setActivityId(questionGroupDto.getActivityId());
        return questionGroup;
    }

    @Override
    public QuestionGroupInstance mapToQuestionGroupInstance(QuestionGroupInstanceDto questionGroupInstanceDto) {
        QuestionGroupInstance questionGroupInstance = new QuestionGroupInstance();
        questionGroupInstance.setCompletedStatus(questionGroupInstanceDto.isCompleted());
        questionGroupInstance.setCreatorId(questionGroupInstanceDto.getCreatorId());
        questionGroupInstance.setEventSourceId(questionGroupInstanceDto.getEventSourceId());
        questionGroupInstance.setDateConducted(questionGroupInstanceDto.getDateConducted());
        questionGroupInstance.setEntityId(questionGroupInstanceDto.getEntityId());
        questionGroupInstance.setVersionNum(questionGroupInstanceDto.getVersion());
        questionGroupInstance.setQuestionGroup(questionGroupDao.getDetails(questionGroupInstanceDto.getQuestionGroupId()));
        questionGroupInstance.setQuestionGroupResponses(mapToQuestionGroupResponses(questionGroupInstance, questionGroupInstanceDto.getQuestionGroupResponseDtos()));
        return questionGroupInstance;
    }

    private List<QuestionGroupResponse> mapToQuestionGroupResponses(QuestionGroupInstance questionGroupInstance, List<QuestionGroupResponseDto> questionGroupResponseDtos) {
        List<QuestionGroupResponse> questionGroupResponses = new ArrayList<QuestionGroupResponse>();
        if (isNotEmpty(questionGroupResponseDtos)) {
            for (QuestionGroupResponseDto questionGroupResponseDto : questionGroupResponseDtos) {
                questionGroupResponses.add(mapToQuestionGroupResponse(questionGroupInstance, questionGroupResponseDto));
            }
        }
        return questionGroupResponses;
    }

    private Map<Integer, SectionQuestion> sectionQuestionMap = new HashMap<Integer, SectionQuestion>();

    private QuestionGroupResponse mapToQuestionGroupResponse(QuestionGroupInstance questionGroupInstance, QuestionGroupResponseDto questionGroupResponseDto) {
        QuestionGroupResponse questionGroupResponse = new QuestionGroupResponse();
        questionGroupResponse.setResponse(questionGroupResponseDto.getResponse());
        questionGroupResponse.setQuestionGroupInstance(questionGroupInstance);

        SectionQuestion sq;
        if (sectionQuestionMap.containsKey(questionGroupResponseDto.getSectionQuestionId())) {
            sq = sectionQuestionMap.get(questionGroupResponseDto.getSectionQuestionId());
        } else {
            sq = sectionQuestionDao.getDetails(questionGroupResponseDto.getSectionQuestionId());
            sectionQuestionMap.put(questionGroupResponseDto.getSectionQuestionId(), sq);
        }
        questionGroupResponse.setSectionQuestion(sq);
        return questionGroupResponse;
    }

    private List<Section> mapToSectionsFromDtos(List<SectionDto> sectionDtos) {
        List<Section> sections = new ArrayList<Section>();
        for (SectionDto sectionDto : sectionDtos) {
            sections.add(mapToSection(sectionDto));
        }
        return sections;
    }

    private Section mapToSection(SectionDto sectionDto) {
        Section section = new Section();
        section.setName(sectionDto.getName());
        section.setSequenceNumber(sectionDto.getOrder());
        section.setQuestions(mapToSectionQuestionsFromDtos(sectionDto.getQuestions(), section));
        return section;
    }

    private List<SectionQuestion> mapToSectionQuestionsFromDtos(List<QuestionDto> questions, Section section) {
        List<SectionQuestion> sectionQuestions = new ArrayList<SectionQuestion>();
        for (QuestionDto questionDto : questions) {
            sectionQuestions.add(mapToSectionQuestion(questionDto, section));
        }
        return sectionQuestions;
    }

    private SectionQuestion mapToSectionQuestion(QuestionDto questionDto, Section section) {
        SectionQuestion sectionQuestion = new SectionQuestion();
        sectionQuestion.setSection(section);
        sectionQuestion.setSequenceNumber(questionDto.getOrder());
        sectionQuestion.setRequired(questionDto.isMandatory());
        sectionQuestion.setShowOnPage(questionDto.isShowOnPage());
        sectionQuestion.setQuestion(mapToQuestion(questionDto));
        return sectionQuestion;
    }

    @Override
    public QuestionEntity mapToQuestion(QuestionDto questionDto) {
        QuestionEntity questionEntity = new QuestionEntity();
        questionEntity.setQuestionText(questionDto.getText());
        questionEntity.setNickname(questionDto.getNickname());
        questionEntity.setAnswerType(mapToAnswerType(questionDto.getType()));
        questionEntity.setNumericMin(questionDto.getMinValue());
        questionEntity.setNumericMax(questionDto.getMaxValue());
        questionEntity.setQuestionState(questionDto.isActive() ?
                questionDto.isEditable() ? QuestionState.ACTIVE : QuestionState.ACTIVE_NOT_EDITABLE :
                questionDto.isEditable() ? QuestionState.INACTIVE : QuestionState.INACTIVE_NOT_EDITABLE);
        questionEntity.setChoices(mapToChoices(questionDto.getChoices()));
        return questionEntity;
    }

    private Date getCurrentDateTime() {
        return Calendar.getInstance().getTime();
    }

    private void mapQuestionResponses(List<QuestionGroupResponse> questionGroupResponses, QuestionGroupDetail questionGroupDetail) {
        if (isNotEmpty(questionGroupResponses)) {
            for (SectionDetail sectionDetail : questionGroupDetail.getSectionDetails()) {
                for (SectionQuestionDetail sectionQuestionDetail : sectionDetail.getQuestions()) {
                    mapToQuestionResponse(sectionQuestionDetail, questionGroupResponses);
                }
            }
        }
    }

    private void setResponse(List<QuestionGroupResponse> questionGroupResponses, SectionQuestionDetail sectionQuestionDetail) {
        for (QuestionGroupResponse questionGroupResponse : questionGroupResponses) {
            if (questionGroupResponse.getSectionQuestion().getId() == sectionQuestionDetail.getId()) {
                sectionQuestionDetail.setValue(questionGroupResponse.getResponse());
            }
        }
    }

    private void setMultiChoiceResponses(List<QuestionGroupResponse> questionGroupResponses, SectionQuestionDetail sectionQuestionDetail) {
        List<SelectionDetail> answers = new ArrayList<SelectionDetail>();
        for (QuestionGroupResponse questionGroupResponse : questionGroupResponses) {
            if (questionGroupResponse.getSectionQuestion().getId() == sectionQuestionDetail.getId()) {
                answers.add(mapToSelectionDetail(questionGroupResponse));
            }
        }
        sectionQuestionDetail.setSelections(answers);
    }

    private SelectionDetail mapToSelectionDetail(QuestionGroupResponse questionGroupResponse) {
        SelectionDetail selectionDetail = new SelectionDetail();
        selectionDetail.setSelectedChoice(questionGroupResponse.getResponse());
        selectionDetail.setSelectedTag(questionGroupResponse.getTag());
        return selectionDetail;
    }

    private QuestionGroupInstance mapToQuestionGroupInstance(int creatorId, int entityId, int eventSourceId, QuestionGroupDetail questionGroupDetail) {
        QuestionGroupInstance questionGroupInstance = new QuestionGroupInstance();
        questionGroupInstance.setDateConducted(getCurrentDateTime());
        questionGroupInstance.setCompletedStatus(1);
        Integer questionGroupId = questionGroupDetail.getId();
        questionGroupInstance.setVersionNum(
                nextQuestionGroupInstanceVersion(entityId, questionGroupId));
        questionGroupInstance.setCreatorId(creatorId);
        questionGroupInstance.setEventSourceId(eventSourceId);
        questionGroupInstance.setEntityId(entityId);
        questionGroupInstance.setQuestionGroup(questionGroupDao.getDetails(questionGroupId));
        questionGroupInstance.setQuestionGroupResponses(mapToQuestionGroupResponses(questionGroupDetail, questionGroupInstance));
        return questionGroupInstance;
    }

    private int nextQuestionGroupInstanceVersion(int entityId, Integer questionGroupId) {
        int nextVersion = 0;
        List questionGroupInstances = questionGroupInstanceDao.retrieveLatestQuestionGroupInstanceByQuestionGroupAndEntity(entityId, questionGroupId);
        if (isNotEmpty(questionGroupInstances)) {
            nextVersion = ((QuestionGroupInstance) questionGroupInstances.get(0)).getVersionNum() + 1;
        }
        return nextVersion;
    }

    private List<QuestionGroupResponse> mapToQuestionGroupResponses(QuestionGroupDetail questionGroupDetail, QuestionGroupInstance questionGroupInstance) {
        List<QuestionGroupResponse> questionGroupResponses = new LinkedList<QuestionGroupResponse>();
        for (SectionDetail sectionDetail : questionGroupDetail.getSectionDetails()) {
            for (SectionQuestionDetail sectionQuestionDetail : sectionDetail.getQuestions()) {
                SectionQuestion sectionQuestion = sectionQuestionDao.getDetails(sectionQuestionDetail.getId());
                if (sectionQuestionDetail.hasAnswer()) {
                    mapToQuestionGroupResponse(questionGroupInstance, questionGroupResponses, sectionQuestionDetail, sectionQuestion);
                }
            }
        }
        return questionGroupResponses;
    }

    private void mapToQuestionGroupResponse(QuestionGroupInstance questionGroupInstance, List<QuestionGroupResponse> questionGroupResponses, SectionQuestionDetail sectionQuestionDetail, SectionQuestion sectionQuestion) {
        if (sectionQuestionDetail.isMultiSelectQuestion()) {
            for (SelectionDetail selectionDetail : sectionQuestionDetail.getSelections()) {
                questionGroupResponses.add(mapToQuestionGroupResponse(questionGroupInstance, sectionQuestion, selectionDetail));
            }
        } else {
            questionGroupResponses.add(mapToQuestionGroupResponse(questionGroupInstance, sectionQuestion, sectionQuestionDetail.getValue()));
        }
    }

    private QuestionGroupResponse mapToQuestionGroupResponse(QuestionGroupInstance questionGroupInstance, SectionQuestion sectionQuestion, SelectionDetail selectionDetail) {
        QuestionGroupResponse questionGroupResponse = mapToQuestionGroupResponse(questionGroupInstance, sectionQuestion, selectionDetail.getSelectedChoice());
        questionGroupResponse.setTag(selectionDetail.getSelectedTag());
        return questionGroupResponse;
    }

    private QuestionGroupResponse mapToQuestionGroupResponse(QuestionGroupInstance questionGroupInstance, SectionQuestion sectionQuestion, String value) {
        QuestionGroupResponse questionGroupResponse = new QuestionGroupResponse();
        questionGroupResponse.setSectionQuestion(sectionQuestion);
        questionGroupResponse.setResponse(value);
        questionGroupResponse.setQuestionGroupInstance(questionGroupInstance);
        return questionGroupResponse;
    }

    private EventSourceDto mapEventSource(EventSourceEntity eventSourceEntity) {
        return new EventSourceDto(eventSourceEntity.getEvent().getName(), eventSourceEntity.getSource().getEntityType(),
                eventSourceEntity.getDescription());
    }

    private QuestionType mapToQuestionType(AnswerType answerType) {
        return answerToQuestionType.get(answerType);
    }

    private AnswerType mapToAnswerType(QuestionType questionType) {
        return questionToAnswerType.get(questionType);
    }

    private void populateAnswerToQuestionTypeMap() {
        answerToQuestionType = CollectionUtils.asMap(makeEntry(AnswerType.INVALID, QuestionType.INVALID),
                makeEntry(AnswerType.FREETEXT, QuestionType.FREETEXT),
                makeEntry(AnswerType.DATE, QuestionType.DATE),
                makeEntry(AnswerType.NUMBER, QuestionType.NUMERIC),
                makeEntry(AnswerType.SINGLESELECT, QuestionType.SINGLE_SELECT),
                makeEntry(AnswerType.CHOICE, QuestionType.SINGLE_SELECT),
                makeEntry(AnswerType.SMARTSELECT, QuestionType.SMART_SELECT),
                makeEntry(AnswerType.MULTISELECT, QuestionType.MULTI_SELECT),
                makeEntry(AnswerType.SMARTSINGLESELECT, QuestionType.SMART_SINGLE_SELECT));
    }

    private void populateQuestionToAnswerTypeMap() {
        questionToAnswerType = asMap(makeEntry(QuestionType.INVALID, AnswerType.INVALID),
                makeEntry(QuestionType.FREETEXT, AnswerType.FREETEXT),
                makeEntry(QuestionType.DATE, AnswerType.DATE),
                makeEntry(QuestionType.NUMERIC, AnswerType.NUMBER),
                makeEntry(QuestionType.SINGLE_SELECT, AnswerType.SINGLESELECT),
                makeEntry(QuestionType.SMART_SELECT, AnswerType.SMARTSELECT),
                makeEntry(QuestionType.MULTI_SELECT, AnswerType.MULTISELECT),
                makeEntry(QuestionType.SMART_SINGLE_SELECT, AnswerType.SMARTSINGLESELECT));
    }
    public SectionQuestion getSectionQuestionById (Integer sectionQuestionId){
        return sectionQuestionDao.retrieveFromSectionQuestionId(sectionQuestionId).get(0);
    }

    public Section getSectionById (Integer sectionId){
        return sectionDao.retrieveFromSectionId(sectionId).get(0);
    }

    public QuestionGroupLink mapToQuestionGroupLink(QuestionLinkDetail questionLinkDetail, SectionLinkDetail sectionLinkDetail){
        QuestionGroupLink questionGroupLink = new QuestionGroupLink();
        if(questionLinkDetail != null){
            questionGroupLink.setValue(questionLinkDetail.getValue());
            questionGroupLink.setAdditionalValue(questionLinkDetail.getAdditionalValue());
            questionGroupLink.setSourceSectionQuestion(getSectionQuestionById(questionLinkDetail.getSourceQuestion().getId()));
            questionGroupLink.setConditionTypeId(questionLinkDetail.getLinkType());
            questionGroupLink.setId(questionLinkDetail.getQuestionGroupLinkId());
        } else {
            questionGroupLink.setValue(sectionLinkDetail.getValue());
            questionGroupLink.setAdditionalValue(sectionLinkDetail.getAdditionalValue());
            questionGroupLink.setSourceSectionQuestion(getSectionQuestionById(sectionLinkDetail.getSourceQuestion().getId()));
            questionGroupLink.setConditionTypeId(sectionLinkDetail.getLinkType());
            questionGroupLink.setId(sectionLinkDetail.getQuestionGroupLinkId());
        }
        return questionGroupLink;
    }

    public SectionQuestionLink mapToQuestionLink(QuestionLinkDetail questionLinkDetail, QuestionGroupLink questionGroupLink) {
        SectionQuestionLink sectionQuestionLink = new SectionQuestionLink();
        sectionQuestionLink.setQuestionGroupLink(questionGroupLink);
        sectionQuestionLink.setAffectedSectionQuestion(getSectionQuestionById(questionLinkDetail.getAffectedQuestion().getId()));
        sectionQuestionLink.setId(questionLinkDetail.getLinkId());
        return sectionQuestionLink;
    }

    public SectionLink mapToSectionLink(SectionLinkDetail sectionLinkDetail, QuestionGroupLink questionGroupLink) {
        SectionLink sectionLink = new SectionLink();
        sectionLink.setAffectedSection(getSectionById(sectionLinkDetail.getAffectedSection().getId()));
        sectionLink.setQuestionGroupLink(questionGroupLink);
        sectionLink.setId(sectionLinkDetail.getLinkId());
        return sectionLink;
    }

    public List<QuestionLinkDetail> mapToQuestionLinkDetails(List<SectionQuestionLink> sectionQuestionLinks) {
        List<QuestionLinkDetail> questionLinkDetails = new ArrayList<QuestionLinkDetail>();
        for(SectionQuestionLink sectionQuestionLink : sectionQuestionLinks){
            QuestionLinkDetail questionLinkDetail = new QuestionLinkDetail();
            questionLinkDetail.setValue(sectionQuestionLink.getQuestionGroupLink().getValue());
            questionLinkDetail.setAdditionalValue(sectionQuestionLink.getQuestionGroupLink().getAdditionalValue());
            questionLinkDetail.setLinkType(sectionQuestionLink.getQuestionGroupLink().getConditionTypeId());
            questionLinkDetail.setProperLinkTypeDisplay(sectionQuestionLink.getQuestionGroupLink().getConditionType());
            questionLinkDetail.setLinkId(sectionQuestionLink.getId());
            questionLinkDetail.setQuestionGroupLinkId(sectionQuestionLink.getQuestionGroupLink().getId());
            questionLinkDetail.setState(true);
            SectionQuestion sectionQuestion = sectionQuestionLink.getQuestionGroupLink().getSourceSectionQuestion();
            questionLinkDetail.setSourceQuestion(mapToSectionQuestionDetail(sectionQuestion,
                    sectionQuestion.isRequired(), sectionQuestion.isShowOnPage(),
                    (mapToQuestionDetail(sectionQuestion.getQuestion(), mapToQuestionType(sectionQuestion.getQuestion().getAnswerTypeAsEnum())))));
            sectionQuestion = sectionQuestionLink.getAffectedSectionQuestion();
            questionLinkDetail.setAffectedQuestion(mapToSectionQuestionDetail(sectionQuestion,
                    sectionQuestion.isRequired(), sectionQuestion.isShowOnPage(),
                    (mapToQuestionDetail(sectionQuestion.getQuestion(), mapToQuestionType(sectionQuestion.getQuestion().getAnswerTypeAsEnum())))));
            questionLinkDetails.add(questionLinkDetail);
        }
        return questionLinkDetails;
    }

    public List<SectionLinkDetail> mapToSectionLinkDetails(List<SectionLink> sectionLinks) {
        List<SectionLinkDetail> sectionLinkDetails = new ArrayList<SectionLinkDetail>();
        for(SectionLink sectionLink : sectionLinks){
            SectionLinkDetail sectionLinkDetail = new SectionLinkDetail();
            sectionLinkDetail.setValue(sectionLink.getQuestionGroupLink().getValue());
            sectionLinkDetail.setAdditionalValue(sectionLink.getQuestionGroupLink().getAdditionalValue());
            sectionLinkDetail.setLinkType(sectionLink.getQuestionGroupLink().getConditionTypeId());
            sectionLinkDetail.setProperLinkTypeDisplay(sectionLink.getQuestionGroupLink().getConditionType());
            sectionLinkDetail.setLinkId(sectionLink.getId());
            sectionLinkDetail.setQuestionGroupLinkId(sectionLink.getQuestionGroupLink().getId());
            sectionLinkDetail.setState(true);
            SectionQuestion sectionQuestion = sectionLink.getQuestionGroupLink().getSourceSectionQuestion();
            sectionLinkDetail.setSourceQuestion(mapToSectionQuestionDetail(sectionQuestion,
                    sectionQuestion.isRequired(), sectionQuestion.isShowOnPage(),
                    (mapToQuestionDetail(sectionQuestion.getQuestion(), mapToQuestionType(sectionQuestion.getQuestion().getAnswerTypeAsEnum())))));
            sectionLinkDetail.setAffectedSection(mapToSectionDetail(sectionLink.getAffectedSection()));
            sectionLinkDetails.add(sectionLinkDetail);
        }
        return sectionLinkDetails;
    }
}

redpajama_set_name: RedPajamaGithub


Why do you need Lua?
Lua is a powerful, fast, lightweight, embeddable scripting language. It combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is ideal for configuration, scripting, and rapid prototyping. Lua is extremely popular among game developers.
Lua has been ported from C++ to Flash Platform with Crossbridge compiler. So, you can download the latest swc file here and connect it to your project. Now, you can create a main LuaAlchemy object.
How do you can to operate with as3 objects inside Lua scripts?
I prefer to use sugar interface because it's more readable.
Also, often you need to use a lua virtual file system, where you can store your assets, lua scripts and access to it through lua functions like loadfile(), dofile(), require() you can read more about it here(CoreLuaLibraries) and here(AutoAssets). I will provide a simple example which explains how to do that inside as3.
//place lua file in virtualFilesystemRoot default is "builtin://"
How to work with as3 objects in lua?
I think it's really great to have a such nice opportunity to use Lua in Flash Platform, because now you can easily equip your game tools with Lua script support!
Good article, the Sugar version does look very nice!
…how does its performance impact a mobile game?
I would assume it would be a bit slower than running code directly from the swf right?
What are the use case? Sergey Gonchar what are you using this cool thing for.


text:
Susan Gross Sholinsky
Subscribe to Susan Gross Sholinsky
Supreme Court Blocks OSHA Vax-or-Test ETS for Large Employers, Allows CMS Health Care Vax Rule
By Robert J. O'Hara, Susan Gross Sholinsky, Steven M. Swirsky, Frank C. Morris Jr., Nathaniel M. Glasser & Nancy Gunzenhauser Popper on January 14, 2022
As explained in greater detail by our colleague Stuart M. Gerson, the Supreme Court of the United States handed down two major, and quickly decided, rulings on January 13, 2022. After hearing oral arguments only six days earlier, the Court issued two unsigned decisions per curiam. A 5-4 decision in Biden v. Missouri dissolved a preliminary injunction against enforcement of an interim final rule ("Rule") promulgated by the Centers for Medicare & Medicaid Services (CMS), requiring recipients of federal Medicare and Medicaid funding to ensure that their employees are vaccinated against COVID-19.
Continue Reading Supreme Court Blocks OSHA Vax-or-Test ETS for Large Employers, Allows CMS Health Care Vax Rule
EEOC Updates Guidance on COVID-19 Vaccination Policies, Including Mandates, Incentives, and Accommodations
By Epstein Becker Green on June 3, 2021
Our colleagues Susan Gross Sholinsky, Lauri F. Rasnick, Jennifer Barna, Gretchen Harders, Nathaniel M. Glasser, and Nancy Gunzenhauser Popper of Epstein Becker Green have recently published an Act Now Advisory that will be of interest to our readers: "EEOC Updates Guidance on COVID-19 Vaccination Policies, Including Mandates, Incentives, and…
New York City Council Establishes Board to Assess Employers' COVID-19 Workplace Health and Safety Protocols and Training
By Epstein Becker Green on March 5, 2021
Our colleagues Susan Gross Sholinsky, Nancy Guzenhauser Popper, Eric Emanuelson, and Christopher Shur of Epstein Becker Green have a new post on the Workforce Bulletin blog that will be of interest to our readers: "New York City Council Establishes Board to Assess Employers' COVID-19 Workplace Health and Safety Protocols and Training…
Make Sure It's a Good Fit: The CDC Issues Revised COVID-19 Mask Guidance
By Susan Gross Sholinsky & Jenna D. Russell on February 16, 2021
On February 10, 2021, the Centers for Disease Control and Prevention ("CDC") issued updated guidance and a report emphasizing the importance of a wearing a mask that fits tightly over the face to slow the spread of COVID-19. The report, which provides the basis for the CDC's updated guidance, is based on CDC experiments that…
Guidance on Employers' Obligations Under the New York City's Disability Discrimination Laws Issued
By Epstein Becker Green on September 19, 2018
Our colleagues Susan Gross Sholinsky, Nancy Gunzenhauser Popper, and Amanda M. Gómez at Epstein Becker Green has a post on the Retail Labor and Employment Law blog that will be of interest to our readers in the health care industry: "NYC Commission on Human Rights Issues Guidance on Employers' Obligations Under the City's…
Proposed Bill Would Amend State and Local Paid Sick Leave Laws
By Epstein Becker Green on November 13, 2017
Our colleagues Susan Gross Sholinsky, Nancy Gunzenhauser Popper, and Judah L. Rosenblatt, at Epstein Becker Green, have a post on the Retail Labor and Employment Law blog that will be of interest to many of our readers in the health care industry: "Proposed Federal Bill Would Pre-Empt State and Local Paid…
Governor Andrew D. Cuomo Introduces Employee Protective Mandates in New York State
By Epstein Becker Green on January 17, 2017
Our colleagues Judah L. Rosenblatt, Jeffrey H. Ruzal, and Susan Gross Sholinsky, at Epstein Becker Green, have a post on the Hospitality Labor and Employment Law Blog that will be of interest to many of our readers in the health care industry: "Where Federal Expectations Are Low Governor Cuomo Introduces Employee…
DOL Releases New Poster and Employer's Guide to FMLA
By Nancy Gunzenhauser Popper, Susan Gross Sholinsky, Alexandra Bruno Carlo & Marc-Joseph Gansah on May 3, 2016
Health care employers should note that the Department of Labor's Wage and Hour Division ("DOL") has just released a new Family Medical Leave Act ("FMLA") poster and The Employer's Guide to The Family and Medical Leave Act ("Guide").
New FMLA Poster
The FMLA requires covered employers to display a copy of the General FMLA Notice…
October 15: Attend Epstein Becker Green's Workforce Management Briefing – High Stakes and High Priorities
By Epstein Becker Green on October 8, 2015
Posted in HEAL®: Employment and Labor, Uncategorized
When: Thursday, October 15, 2015 8:00 a.m. – 3:00 p.m.
Where: New York Hilton Midtown, 1335 Avenue of the Americas, New York, NY 10019
This year, Epstein Becker Green's Annual Workforce Management Briefing focuses on the latest developments that impact employers nationwide, featuring senior officials from the U.S. Department of Labor and the…
Act Now Advisory – Protecting Your Workforce: What You Need to Know About Ebola
By Epstein Becker Green on November 6, 2014
By Frank C. Morris, Jr.
The Ebola virus disease ("Ebola") has become a worldwide threat, which, among many other effects, has forced employers to think about how to protect their employees. Employers also must consider how Ebola might impact employment policies and procedures, including, but not limited to, those addressing attendance, leaves of absence, discipline,…

redpajama_set_name: RedPajamaCommonCrawl


Welcome to the 2018-2019 online membership system for Desert Ice Skating Club of Arizona. The club membership year runs from July 1, 2018 to June 30, 2019. Unfortunately, we cannot accept prorated membership fees if you join later in the membership year.
We are also using this system to sign up for test sessions hosted by DISCOA. Club members, sign into this system using the 'Existing Members' button to register for test sessions. Members of other clubs should use the Non Members button at the top lefthand side of the page to register.
Allow time for processing within USFS - memberships must be manually entered into the US Figure Skating database.


text:
Saucy pasta bar with a twist is opening on Tottenham Court Road
What: Saucy
In a nutshell: Pasta with a twist
Summing it all up: Dublin chef sets her sights on London with this Tottenham Court Road pasta bar that has a distinctly healthy range of options
The cafe where you can sub pasta with spiralised veg...
Tottenham Court Road has seen a lot of new restaurants and cafes opening there over the past year. But look out this summer for a rather interesting new pasta bar with a twist, Saucy. The key twist being, that you can replace the pasta in any of their dishes with a spiralised vegetable instead.
The chef involved is Grainne O Keefe who, as the Irish Times explains has a very interesting background in Dublin restaurants. She's been a chef in Dublin for 9 years, currently working in Bastible restaurant (run by ex-Harwood Arms and Etto chef Barry FitzGerald) and will be starting a new Head Chef position in a brand new restaurant opening in Dublin in August this year.
Grainne has teamed up with British friend George Wells who's just back in the UK from a spell in Melbourne playing cricket. "We both agreed London's the perfect city to launch our first restaurant," Grainne told Hot Dinners. "For George, opening in London was always the plan. He knows the market and the area well, and it's his home. Personally, I've always been drawn to London's amazing food scene, and we feel as though Saucy belongs here."
So what's going to be on the menu? "Our lunch menu is a blend of classic Italian pasta dishes, with some more modern elements thrown in, using less conventional ingredients. The menu consists of a 3-step process, in which the customer will choose which pasta to match with their sauce, and finally pick from a range of optional additions.
"To accompany our lunch menu, we have both artisan cheese and charcuterie boards that our customers have the options of taking away."
Saucy will be open from breakfast, serving up protein balls, bircher muesli and natural yoghurts as well as in-house smoothies, juices and their own granola. "We know from personal experience that a good cup of coffee is like gold dust," says Grainne. "We did a lot of research to find the best possible supplier, and have teamed up with specialty coffee roasters, Mission Coffee Works."
As for that pasta, it'll be made on site every day with options like squid ink linguine and a gluten free pasta option too. The site itself has room for 30 to eat in or take away. Sauces might be njuja with tomato and basil or beef ragu or maybe a more healthy avo, sundried tomato and cashew nut pesto.
More about Saucy
Where: 52 Tottenham Court Road, Fitzrovia, London, W1T 2EH
When: Opens mid-late August 2017
Opening hours: 7am-9pm (to be confirmed)
How to book: Walk-ins only
Keep up with their news on Instagram & Twitter @saucyldn


text:
Dozens of Kaiser Permanente pediatricians in Northern California screening three-year-olds for ACEs
ACE/Adverse Childhood Experiences, Child Abuse, Children's Mental Health, Parenting, Studies & Research
"Safe, stable, nurturing relationships & environments are essential to prevent child maltreatment and to assure that children reach their full potential" — CDC
A Note from American SPCC:
Adverse childhood experiences (ACEs) are potentially traumatic events that can have negative, lasting effects on health and well-being. These experiences occur in a child's life before the age of 18 and are remembered by that child as an adult.
Children who are abused, neglected or exposed to traumatic events, are at higher risk for health problems as adults. These problems include alcoholism, depression, drug abuse, eating disorders, obesity, high-risk sexual behaviors, smoking, suicide, and certain chronic diseases.
American SPCC believes that as a nation of educated adults, we have a responsibility to protect our country's children. Join us as we promote the positive care of our nation's most vulnerable and give them the opportunity for a happy, healthy and productive life.
www.acestoohigh.com
Since August 2016, more than 300 three-year-olds who visit Kaiser Permanente's pediatric clinics in Hayward and San Leandro have been screened for adverse childhood experiences (ACEs), such as living with a family member who is an alcoholic or losing a parent to separation or divorce. But when the idea to screen toddlers and their families for ACEs was first broached at the Kaiser Permanente Hayward Medical Center, the staff were, in a word, "angsty," says Dr. Paul Espinas, who led the effort.
The staff was worried that if they screened for ACEs, their interactions with patients would be negative. However, an off-site weekend training for pediatricians in October 2015 changed all that.
One of the most significant takeaways from the training – which included an Alameda County public health expert and area experts in domestic violence, toxic stress, resilience and community health from the Kaiser system — was learning about the important connections between high ACEs scores and health outcomes, Espinas explained.
"ACEs are the new cholesterol," he said. "If you don't screen for it, and you don't look for it, you'll never find it, but it has more health impacts than you imagine."
Dr Paul Espinas
ACEs comes from the CDC-Kaiser Permanente Adverse Childhood Experiences Study (ACE Study), groundbreaking research that looked at how 10 types of childhood trauma affect long-term health. They include: physical, emotional and sexual abuse; physical and emotional neglect; living with a family member who's addicted to alcohol or other substances, or who's depressed or has other mental illnesses; experiencing parental divorce or separation; having a family member who's incarcerated, and witnessing a mother being abused.
Subsequent ACE surveys include racism, witnessing violence outside the home, bullying, spanking, losing a parent to deportation, living in an unsafe neighborhood, and involvement with the foster care system. Other types of childhood adversity can also include being homeless, living in a war zone, being an immigrant, moving many times, witnessing a sibling being abused, witnessing a father or other caregiver or extended family member being abused, involvement with the criminal justice system, attending a school that enforces a zero-tolerance discipline policy, etc.
Thirty-eight percent of children in every state have at least one ACE, according to an analysis of the 2016 National Children's Health Survey by the Child & Adolescent Health Measurement Initiative (CAHMI) at the Johns Hopkins Bloomberg School of Public Health.
The epidemiology of ACEs — i.e., the ACE Study and other surveys — is one of five parts of ACEs science, which also includes how toxic stress from ACEs damage children's developing brains; how toxic stress from ACEs affects health; and how it affects our genes and be passed from one generation to another (epigenetics); and resilience research, which shows the brain is plastic and the body wants to heal. Resilience research focuses on what happens when individuals, organizations and systems integrate trauma-informed and resilience-building practices, for example in education and in the family court system.
The ACE Study found that the higher someone's ACE score – the more types of childhood adversity a person experienced – the higher their risk of chronic disease, mental illness, violence, being a victim of violence and several other consequences. The study found that most people (64%) have at least one ACE; 12% of the population has an ACE score of 4. Having an ACE score of 4 nearly doubles the risk of heart disease and cancer. It increases the likelihood of becoming an alcoholic by 700 percent and the risk of attempted suicide by 1200 percent. (For more information, go to ACEs Science 101. To calculate your ACE and resilience scores, go to: Got Your ACE Score?)
Equally important was that the pediatricians attending the training had the opportunity to talk about ACEs and look inward: "It gave physicians time to process their own feelings about how they regard their own lives and their families' lives," said Espinas.
He said that although Kaiser Hayward and San Leandro's pediatric clinics have not done confidential ACEs surveys of their own staff, giving staff time to reflect on the adversity that they may have experienced and the resources to deal with it – as had been provided at the off-site training — is essential.
"From my perspective, to become more trauma-informed, you have to give your staff physicians space to deal with whatever trauma they may have experienced in their lives," said Espinas. "I think it makes them more empowered to help treat this if they've processed all that stuff first."
Espinas said that the offsite training also won over the clinics' leadership in supporting the effort to introduce ACEs screening into practice. The chief physician, who attended the offsite training, was excited about it, he explained. Without buy-in in an organization as large as Kaiser, said Espinas, such an effort could easily get "lost in the shuffle" among numerous other competing interests.
With support from decision-makers, Espinas said the clinic decided to introduce the screening during the three-year-old wellness visit. They chose that time because there are few forms to fill out and shots to be injected, and "a lot of developmental issues have calmed down." However, unlike The Children's Clinic in Portland, OR, they are notasking parents to complete ACE or resilience surveys about their own childhoods.
Parents complete an ACEs survey for their children in the exam room while waiting for the doctor. The survey asks them to tally up their children's ACE score without indicating the specific adverse childhood experience, said Espinas, who said it was adapted from the 10-question ACEs survey developed by the San Francisco-based Center for Youth Wellness.
When 32 pediatricians began screening in 2016, they were surprised by their patients' reactions. "We actually found that families found the screening to be beneficial," Espinas said, who explained they were all given information about resiliency. "So many said, 'I'm so glad you're asking about this.'"
For those with scores of 4 or higher, the pediatricians took a slightly different approach. "We wanted them to express concern, thank them for filling out the survey, link them up with resources about ACEs and then arrange for a follow up call – I think our patient population wants us to ask these questions. They want resources," he added. Because pediatricians see about 25 patients a day, said Espinas, there's not really enough time to have a detailed conversation about ACEs with patients, said Espinas. But he said if his colleagues get the sense that patients want to talk about specific ACEs, we gave them the go ahead to engage parents in these conversations."
Of the hundreds of children screened, only about 10 children had ACE scores over 4, explained Espinas. Those families were referred to psychiatric services at Kaiser and also to Help Me Grow, Oakland's First Five organization, which has helped to link them up with services in the community. Those patients also receive follow up calls to make sure they're engaging in the services they have been referred to, said Espinas. The two agencies share information and Espinas said that six out of the 10 referrals to Help Me Grow are continuing with community-based services they have been provided.
Help Me Grow talks to patients who have been referred by Kaiser about their children's ACE scores, according to Deb Turner, the program administrator. Some of those families, she said, are in the midst of high-conflict divorces. "Sometimes parents will come in a little panicked wondering what it means to have a high ACE score," said Turner. "They'll ask, 'is my child damaged?" Turner says that the staff reassures them that they're being proactive by seeking assistance, gives them information about child development and links them up with supportive services such as parenting resources, legal help, or help with basic necessities.
Espinas said that while they didn't have the staffing to do an exact count of how many children were screened in the first year, they now have a grant that will afford them that opportunity. Over the next two years, he explained, they'll also look at how patients, staff, and doctors are responding to the ACE screening, the demographics of those screened, and how the screening affects workflow.
"We've achieved the goal of making it [ACEs screening] mundane, part of muscle memory," said Espinas, adding that Kaiser San Jose has also followed their lead and began screening three-year-olds. The next step, he said, will be expanding screening to all ages from birth to 5.
"Just as families are messaged around nutrition every visit," he said, "they will be messaged around ACEs for the first five years so that questions about ACEs will be as routine as talking to parents each time about nutrition."
Kids are being raised in a chaotic world exposed to abuse, neglect and injustice. They don't feel safe and protected. They need our help like never before.
American SPCC encourages you to join us as we help create a brighter future for kids.
Through education, awareness and advocacy, we inspire a positive cycle leading to a better human race. We envision a future where all children are given a voice and are nurtured to live happy, healthy, and productive lives.
Let kids know they are heard and protected. TAKE ACTION and start making a positive difference in the life of a child.
There are so many ways that you can be a hero!
Give a little…no matter how large or small, every donation actively impacts the positive care of children to help end abuse. Give now.
Because children matter…Get involved. Social impact to end abuse. So many simple ways to make a difference & give back. Get started today.
Be an inspiration…share your story of hope about your experience with child abuse, neglect, bullying or parenting? Share now.
Advocate for children & raise awareness. Spread the word. Tell the world. Speak up for children, because they can't. Let's go viral! Start now!
American SPCC is a 501(c) 3 top-rated nonprofit organization (federal tax ID 27-4621515). Charitable donations are tax deductible.
Tags: #ACE Prevention Adverse Childhood Experiences
Got Your ACE Score or Even Know What It Is?
American SPCC: It's Time to End Child Marriage in the U.S.


What a beautiful day we had today for commencement today. Everything was perfect... lots of friends and family to celebrate the day with us. Here are some of my favorite shots from the 192 pictures that I took today. I did edit it down to about 110 pictures.
Well okay so it wasn't perfect if you take into account the seating went wrong after all the kids came out and they were 3 seats short which being Chelsea is at the end of the alphabet she was one of the three, Chelsea slipping on the way down, after throwing her cap she didn't find the tassel right away... Look how high one of the kids threw the orange cap in last picture!
All in all I feel so grateful!
the wonderful day we had in every way possible. The weather was beautiful, all the family and friends that joined us to celebrate were amazing with plenty of laughter to share.
The accomplishment that Chelsea made this year. Graduating with a 4.0... especially when we had a few years through school where she changed some of her grades to stay out of trouble with mom and dad.


Erik Pina, 54, of Marion, died March 17, 2019 after an illness.
Visiting hours are from 4 to 7 pm on Thursday, March 21, 2019 at the Chapman, Cole & Gleason Funeral Home, 2599 Cranberry Hwy., Wareham.
His funeral will be held at 9:00 am on Friday, March 22, 2019 from the funeral home, followed by a Funeral Mass at 10:00 a.m. in St. Anthony's Church, Gault Rd., West Wareham.


text:
Backpage
Mini-Feature
H & L
November 3Breaking News! Check out the latest online edition here!
Beginning Journalism
Seniors lead hopes for state soccer
Senior Janessa Klein winds up to kick a ball during a game against Iowa City High on Tuesday, April 24. Photo Submitted.
William Hanigan, Sports Writer
"Practice makes perfect" is what every aspiring athlete is told from a young age. This saying applies to the Xavier girls' soccer team, who, after several losses to start the season, have started to improve and make progress on the quality of their play. Beginning the season with losses against Dowling Catholic, Linn Mar, Prairie, and North Scott, the team have notched two wins in succession against Iowa City High and Dubuque Wahlert. A team with a mix of experience and youth is always expected to take a period to gel together. Xavier has five seniors starting, but on the other side of the coin, have three freshman starting, and a large amount of underclassmen playing significant minutes.
"We are working better as a team with a lot of new players this year. Our team chemistry is starting to show on the field, and we are hoping for a winning season from here on out," senior forward/midfielder Elena Minor said. "Our goals still remain making state and continuing the great tradition that Xavier girls' soccer has in Iowa."
The senior class, many of who have played varsity since they were freshman or sophomores, has yet to win a state title. The program's last title came in 2013, the year before they arrived at Xavier. The Xavier girls' soccer program's widely known streak of eight straight state titles from 2006 to 2013 is now a thing of the past in the minds of the Xavier community. The senior class is ready for a state title, and many of the underclassmen can see how much they want that at practice, and would love to help deliver that come June.
"Having watched the seniors the past two years, I can really see how much they want to win this year. We are working very hard every practice to get better as a team," sophomore forward Quinn Hanigan said. "The senior class has helped me adjust to the team the past two years, and all of the underclassmen want nothing more than to win them a state title."
The Xavier girls continued their season with a home game against Cedar Rapids Jefferson on May 1. They play May 4 against Dubuque Senior in Dubuque. They hope to keep getting better as a team and make it back to the state tournament: this time to win.
William Hanigan
Sports Writer
Burritos are better than tacos • 37 Views
Downfall of Rory Gilmore • 22 Views
"To hold a pen is to be at war" • 18 Views
Let the grass grow • 18 Views
Backpage, Feature and Mini, Health and Lifestyle, and Student Life pages
Stella Bernhard, Jaleah Klein, and Kate Weiss
Prom Court 2022
Favorite school lunches
Siblings Saints
Advice to the seniors from their parents
Meet the '21-'22 School Directors
April 15 Cover
Senior friend group glowups
Local Coffee Shops
4/1 Cover
Eggstra Cute Saints
The student news site of Xavier High School


"You'll only be staying here until one of the paddies shoots you." The blunt caution given to Private Gary Hook on his arrival in Belfast sets the tone for the army's attitude towards where he's been posted, and the tone of locals towards an army any of them might ostensibly join. The breathlessly hard-hitting '71 not only captures these tensions with flair, but does so from the incompatible, irreconcilable points of view of those caught up in and sucked into them.
'71 is the first feature film directed by Yann Demange, whose most recent television credit was the first series of Top Boy. The similarities between the two are clear: a gritty urban setting with a dehumanising estate; outlaw groups in conflict with each other – a conflict which spills from the underworld onto the streets. Instead of East London and the present, '71 is set in the Belfast of the early Seventies as violence reached such levels that the mainland forces charged with keeping the peace had no idea how to restore order. The local police, as depicted in the film, weren't interested in stability and the floundering, beyond-the-law army received contempt and worse from all sides.
Gary Hook is a new recruit. He thinks he's about to be posted to Germany from mainland Britain. Instead, he's told "because of the deteriorating security situation in Belfast, your regiment is now being deployed there on an emergency basis." After saying farewell to his younger brother at the children's home where they were both brought up, he and his platoon are dumped in a Belfast school billet with camp beds to sleep on. The next morning, they are tasked with accompanying the Royal Ulster Constabulary on a house search mission. It's already apparent their Lieutenant is green, with no idea of the lie of the land. Hook has also seen shadowy figures from the secret, plain-clothes army unit the MRF (Military Reaction Force) buzzing around. The patrol is a disaster and Hook is pitched onto the streets alone and spends the hours until his rescue the following dawn, running, trying to protect himself and falling to the hands of ally and enemy.
Magnetic and tightly wound as Hook, Jack O'Connell (Skins, This Is England, Starred Up) summons a career-best performance. He is taciturn and watchful, human and, when he has to be, merciless.
Demange's direction of Hook's odyssey is assured. It's impossible to tell Blackburn and Liverpool stood in for Belfast. The pace is relentless. The tension inexorable. Every scene is precise. There is no flab. '71 is violent. Grim, too. It is also absolutely riveting. Recommended.


Your home is a huge piece of your every day life. It's where you eat, sleep and have fun – it's where you spend a lot of your daily life. As a result of these daily activities is the dust, dirt and other particles that accumulate and contaminate your home's air. These impurities can contribute to bad indoor air quality, which could have great effects on your family's health and comfort. However, there are various products that can help you maintain healthier, fresher air that can make indoor air quality the least of your problems.
Knowing that it's important for you to understand all of the options that we offer that can help improve your indoor air, we'll feature each indoor air quality solution on our blog in next few months. You'll find out what products are available, why it's important and how it will integrate into your current HVAC system. Monitor the Breathe Healthier Air blog to learn more.
If you're interested in adding a Lennox® indoor air quality product to your home, give the professionals at Breathe Healthier Air a call at 772-228-6980.


If you have a large office or classroom where you need to share the links, documents, or large amount of text frequently, Clipboard Share will come handy. It is a nifty little system tray tool that allows sharing of clipboard over the network.
The first thing that comes to mind is why not share the content over an IM client by establishing a group chat? This is a valid question, but has few disadvantages, such as, limited number of text can be send, text larger than 1MB or 100 words cannot be send, etc.
Clipboard Share is easy to set-up and sends the text over encrypted communication channel. It can only send/receive clipboard to/from trusted computers only. You can select the computers from the Authorized Sender tab in Settings. Since it can connect with multiple systems, it is possible to share the clipboard with more than 2 computers.
The username will be the computer's default but can be changed easily. You can define the maximum size of the received messages for security purpose. Other options are Port and an option to run the app on startup.
The log keeps history of the clipboard that has been shared between computers and can be accessed from the system tray right-click context menu.
Before using this app, please make sure that PNRP(Peer Name Resolution Protocol) is installed and allowed in Windows Firewall. It is required for discovering other computers, Windows Remote Assistance in Windows 7 also uses PNRP when connecting via Easy Connect.
It requires .NET Framework 3.5 and works on Windows XP, Windows Vista, and Windows 7. More more, check out other useful Clipboard apps Clipdiary, TenClips, Clips, Clipboarder, and Clipdiary.


Nutrition therapy is vital to all people of different ages. Some people make a mistake when they think that the Nutrition Therapy is meant for the women and the mothers in the society. It is possible that some people have health issues related to the nutrition an others issues related to Weight Management. However, are multiple Nutritionist New York who can take care of Nutrition Therapy any time that you need. It is an assurance that when you consider some factors you can manage to hire the ideal Nutritionist New York in the industry. You can be sure that you can get confused due to the multiple Nutrition Therapy institution especially if your first time in the industry. There are credible benefits of Nutrition Therapy from the experts that you can enjoy and they are as follows.
If you get the Nutrition Therapy you can always enjoy the benefit of being heath. Nutrition therapy ensure that you get to know the food that you can always eat to be to help your body remain strong t fight all the disease that may tend to affect the body. Therefore, it is a guarantee that the nutrition therapy can make sure you can never spend your money in the hospitals bills. The nutrition therapy allows people to leva health.
It is possible that you are likely to have the people complaining about their skins and their weight. For example, some are big in size, some are small and other has spots and painful spots on their faces. The Nutrition Therapy is important in Weight Management and the skin management. It needs you to be cautious when you need to employ the Nutritionist New York. If you seek the ideal Nutritionist New York to offer the best nutrition therapy you can take a brief duration to gain the ideal skin and body sizes.
Lastly, the nutrition therapy educate you in the bets meal s to feed your family The great benefits need to be communal not private. It is possible to have the youngsters using the skills they learned from their parents when they mature. Of you get the ideal Nutrition Therapy and train the kids you can be sure that you calk always have the healthy family. Still, the Nutrition Therapy can help you acquire the best skin appearance and your body cells ca always functioning accordingly.