77 lines
3.2 KiB
Java
77 lines
3.2 KiB
Java
package ovh.herisson.Clyde.Services;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import ovh.herisson.Clyde.Repositories.CurriculumRepository;
|
|
import ovh.herisson.Clyde.Repositories.ExternalCurriculumRepository;
|
|
import ovh.herisson.Clyde.Repositories.UserCurriculumRepository;
|
|
import ovh.herisson.Clyde.Tables.*;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
|
|
@Service
|
|
public class UserCurriculumService {
|
|
|
|
private final UserCurriculumRepository userCurriculumRepository;
|
|
private final CurriculumRepository curriculumRepo;
|
|
|
|
private final ExternalCurriculumRepository externalCurriculumRepo;
|
|
public UserCurriculumService(UserCurriculumRepository userCurriculumRepository, CurriculumRepository curriculumRepo, ExternalCurriculumRepository externalCurriculumRepo) {
|
|
this.userCurriculumRepository = userCurriculumRepository;
|
|
this.curriculumRepo = curriculumRepo;
|
|
this.externalCurriculumRepo = externalCurriculumRepo;
|
|
}
|
|
|
|
public Curriculum findByUser(User student){
|
|
return userCurriculumRepository.findByUser(student);
|
|
}
|
|
|
|
public HashMap<String,Object> findAllCurriculumByStudent(User student) {
|
|
ArrayList<UserCurriculum> list = userCurriculumRepository.findByUserOrderByCurriculum(student);
|
|
|
|
ArrayList<HashMap<String, Object>> curriculumlist = new ArrayList<HashMap<String, Object>>();
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
HashMap<String, Object> element = new HashMap<>();
|
|
Curriculum c = list.get(i).getCurriculum();
|
|
|
|
|
|
element.put("curriculumId", c.getCurriculumId());
|
|
element.put("year", c.getYear());
|
|
element.put("option", c.getOption());
|
|
element.put("dateyear", list.get(i).getYear());
|
|
curriculumlist.add(element);
|
|
}
|
|
|
|
HashMap<String, Object> toReturn = new HashMap<String, Object>();
|
|
toReturn.put("curriculumList", curriculumlist);
|
|
return toReturn;
|
|
}
|
|
|
|
|
|
public HashMap<String,Object> findAllExternalCurriculumByInscriptionRequestId(Long id) {
|
|
ArrayList<ExternalCurriculum> list = externalCurriculumRepo.getExternalCurriculumByInscriptionRequestId(id);
|
|
|
|
ArrayList<HashMap<String, Object>> externalCurriculumList = new ArrayList<HashMap<String, Object>>();
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
HashMap<String, Object> element = new HashMap<>();
|
|
element.put("id", list.get(0).getId());
|
|
element.put("inscriptionRequestId", list.get(0).getInscriptionRequestId());
|
|
element.put("school", list.get(0).getSchool());
|
|
element.put("formation", list.get(0).getFormation());
|
|
element.put("completion", list.get(0).getCompletion());
|
|
element.put("startYear", list.get(0).getStartYear());
|
|
element.put("endYear", list.get(0).getEndYear());
|
|
element.put("justifDocUrl", list.get(0).getJustifdocUrl());
|
|
element.put("state", list.get(0).getState());
|
|
externalCurriculumList.add(element);
|
|
}
|
|
|
|
HashMap<String, Object> toReturn = new HashMap<String, Object>();
|
|
toReturn.put("externalCurriculumList", externalCurriculumList);
|
|
return toReturn;
|
|
}
|
|
|
|
}
|