*/
public class ReadStudentsAndGroupsByShiftID {
@Atomic
public static InfoSiteStudentsAndGroups run(String groupPropertiesId, String shiftId) throws FenixServiceException {
InfoSiteStudentsAndGroups infoSiteStudentsAndGroups = new InfoSiteStudentsAndGroups();
Grouping groupProperties = FenixFramework.getDomainObject(groupPropertiesId);
infoSiteStudentsAndGroups.setInfoGrouping(InfoGrouping.newInfoFromDomain(groupProperties));
Shift shift = FenixFramework.getDomainObject(shiftId);
if (groupProperties == null) {
throw new ExistingServiceException();
}
infoSiteStudentsAndGroups.setInfoShift(InfoShift.newInfoFromDomain(shift));
List infoSiteStudentsAndGroupsList = new ArrayList();
List studentGroups = getStudentGroupsByShiftAndGroupProperties(groupProperties, shift);
Iterator iterStudentGroups = studentGroups.iterator();
while (iterStudentGroups.hasNext()) {
Collection studentGroupAttendList;
StudentGroup studentGroup = (StudentGroup) iterStudentGroups.next();
studentGroupAttendList = studentGroup.getAttendsSet();
Iterator iterStudentGroupAttendList = studentGroupAttendList.iterator();
InfoSiteStudentInformation infoSiteStudentInformation = null;
InfoSiteStudentAndGroup infoSiteStudentAndGroup = null;
Attends attend = null;
while (iterStudentGroupAttendList.hasNext()) {
infoSiteStudentInformation = new InfoSiteStudentInformation();
infoSiteStudentAndGroup = new InfoSiteStudentAndGroup();
attend = (Attends) iterStudentGroupAttendList.next();
infoSiteStudentAndGroup.setInfoStudentGroup(InfoStudentGroup.newInfoFromDomain(studentGroup));
infoSiteStudentInformation.setNumber(attend.getRegistration().getNumber());
infoSiteStudentInformation.setName(attend.getRegistration().getPerson().getName());
infoSiteStudentInformation.setUsername(attend.getRegistration().getPerson().getUsername());
infoSiteStudentInformation.setEmail(attend.getRegistration().getPerson().getEmail());
infoSiteStudentInformation.setPersonID(attend.getRegistration().getPerson().getExternalId());
infoSiteStudentAndGroup.setInfoSiteStudentInformation(infoSiteStudentInformation);
infoSiteStudentsAndGroupsList.add(infoSiteStudentAndGroup);
}
}
Collections.sort(infoSiteStudentsAndGroupsList, new BeanComparator("infoSiteStudentInformation.number"));
infoSiteStudentsAndGroups.setInfoSiteStudentsAndGroupsList(infoSiteStudentsAndGroupsList);
return infoSiteStudentsAndGroups;
}