class AdditionalInfoFormPopulator implements CompetitionSetupFormPopulator {

	@Override
	public CompetitionSetupForm populateForm(CompetitionResource competitionResource) {
		AdditionalInfoForm competitionSetupForm = new AdditionalInfoForm();

		competitionSetupForm.setActivityCode(competitionResource.getActivityCode());
		competitionSetupForm.setCompetitionCode(competitionResource.getCode());
		competitionSetupForm.setPafNumber(competitionResource.getPafCode());
		competitionSetupForm.setBudgetCode(competitionResource.getBudgetCode());

		competitionResource.getFunders().forEach(funderResource ->  {
			FunderRowForm funder = new FunderRowForm(funderResource);
			competitionSetupForm.getFunders().add(funder);
		});

        if(competitionResource.getFunders().isEmpty()) {
			CompetitionFunderResource competitionFunderResource = initFirstFunder();
			competitionSetupForm.setFunders(asList(new FunderRowForm(competitionFunderResource)));
			competitionResource.setFunders(asList(competitionFunderResource));
            competitionSetupRestService.update(competitionResource);
        }

        return competitionSetupForm;
	}

}