@Atomic
public static Integer run(String studentGroupCode, String groupPropertiesCode, String shiftCodeString, String username)
throws FenixServiceException {
check(RolePredicates.STUDENT_PREDICATE);
Grouping groupProperties = FenixFramework.getDomainObject(groupPropertiesCode);
if (groupProperties == null) {
throw new ExistingServiceException();
}
StudentGroup studentGroup = FenixFramework.getDomainObject(studentGroupCode);
if (studentGroup == null) {
throw new InvalidSituationServiceException();
}
if (studentGroup.getShift() != null && shiftCodeString == null) {
throw new InvalidArgumentsServiceException();
}
if (studentGroup.getShift() == null) {
if (shiftCodeString != null) {
throw new InvalidArgumentsServiceException();
}
} else {
if (!studentGroup.getShift().getExternalId().equals(shiftCodeString)) {
throw new InvalidArgumentsServiceException();
}
}
if (studentGroup.getShift() != null && groupProperties.getShiftType() != null) {
return Integer.valueOf(1);
}
if (studentGroup.getShift() != null && groupProperties.getShiftType() == null) {
return Integer.valueOf(2);
}
if (studentGroup.getShift() == null && groupProperties.getShiftType() != null) {
return Integer.valueOf(3);
}
if (studentGroup.getShift() == null && groupProperties.getShiftType() == null) {
return Integer.valueOf(4);
}
return Integer.valueOf(5);