public class DegreeCurricularPlansForDegree implements DataProvider {
@Override
public Object provide(Object source, Object currentValue) {
final StudentOptionalEnrolmentBean optionalEnrolmentBean = (StudentOptionalEnrolmentBean) source;
final List<DegreeCurricularPlan> result = new ArrayList<DegreeCurricularPlan>();
if (optionalEnrolmentBean.getDegree() != null && optionalEnrolmentBean.getDegreeType() != null) {
if (optionalEnrolmentBean.getDegree().getDegreeType().equals(optionalEnrolmentBean.getDegreeType())) {
result.addAll(optionalEnrolmentBean.getDegree().getDegreeCurricularPlansSet());
if (optionalEnrolmentBean.getDegreeCurricularPlan() != null
&& !optionalEnrolmentBean.getDegree().getDegreeCurricularPlansSet()
.contains(optionalEnrolmentBean.getDegreeCurricularPlan())) {
optionalEnrolmentBean.setDegreeCurricularPlan(null);
}
} else {
optionalEnrolmentBean.setDegree(null);
optionalEnrolmentBean.setDegreeCurricularPlan(null);
}
}
Collections.sort(result, DegreeCurricularPlan.COMPARATOR_BY_NAME);
return result;