class InitialDetailsFormPopulator implements CompetitionSetupFormPopulator {

	@Override
	public CompetitionSetupForm populateForm(CompetitionResource competitionResource) {
		final List<InnovationAreaResource> allInnovationAreas = categoryRestService.getInnovationAreas().getSuccess();
	    InitialDetailsForm competitionSetupForm = new InitialDetailsForm();

		competitionSetupForm.setCompetitionTypeId(competitionResource.getCompetitionType());
		competitionSetupForm.setExecutiveUserId(competitionResource.getExecutive());

		competitionSetupForm.setInnovationSectorCategoryId(competitionResource.getInnovationSector());
		Set<Long> innovationAreaCategoryIds = competitionResource.getInnovationAreas();
		competitionSetupForm.setInnovationAreaCategoryIds(setInnovationAreas(innovationAreaCategoryIds, allInnovationAreas));
		competitionSetupForm.setInnovationAreaNamesFormatted(getFormattedInnovationAreaNames(innovationAreaCategoryIds, allInnovationAreas));
		competitionSetupForm.setInnovationLeadUserId(competitionResource.getLeadTechnologist());

		if (competitionResource.getStartDate() != null) {
			competitionSetupForm.setOpeningDateDay(competitionResource.getStartDate().getDayOfMonth());
			competitionSetupForm.setOpeningDateMonth(competitionResource.getStartDate().getMonth().getValue());
			competitionSetupForm.setOpeningDateYear(competitionResource.getStartDate().getYear());
		}

		competitionSetupForm.setTitle(competitionResource.getName());
		competitionSetupForm.setStateAid(competitionResource.getStateAid());
		competitionSetupForm.setFundingType(competitionResource.getFundingType());

		return competitionSetupForm;
	}

}