final List<InfoExecutionDegree> infoExecutionDegreeList =
ReadPublicExecutionDegreeByDCPID.run(degreeCurricularPlanId);
if (!infoExecutionDegreeList.isEmpty()) {
List<LabelValueBean> executionPeriodsLabelValueList = new ArrayList<LabelValueBean>();
InfoExecutionDegree infoExecutionDegree1 = infoExecutionDegreeList.iterator().next();
executionPeriodsLabelValueList.add(new LabelValueBean(infoExecutionDegree1.getInfoExecutionYear().getYear(), ""
+ infoExecutionDegree1.getInfoExecutionYear().getExternalId()));
for (int i = 1; i < infoExecutionDegreeList.size(); i++) {
final InfoExecutionDegree infoExecutionDegree = infoExecutionDegreeList.get(i);
if (infoExecutionDegree.getInfoExecutionYear().getYear() != infoExecutionDegree1.getInfoExecutionYear()
.getYear()) {
executionPeriodsLabelValueList.add(new LabelValueBean(infoExecutionDegree.getInfoExecutionYear()
.getYear(), "" + infoExecutionDegree.getInfoExecutionYear().getExternalId()));
infoExecutionDegree1 = infoExecutionDegreeList.get(i);
}
}
if (executionPeriodsLabelValueList.size() > 1) {
request.setAttribute(PresentationConstants.LABELLIST_EXECUTIONPERIOD, executionPeriodsLabelValueList);
} else {
request.removeAttribute(PresentationConstants.LABELLIST_EXECUTIONPERIOD);
}
}
} catch (FenixServiceException e) {
throw new FenixActionException(e);
}
List<LabelValueBean> anosCurriculares = new ArrayList<LabelValueBean>();
anosCurriculares.add(new LabelValueBean("---------", ""));
anosCurriculares.add(new LabelValueBean("1", "1"));
anosCurriculares.add(new LabelValueBean("2", "2"));
anosCurriculares.add(new LabelValueBean("3", "3"));
anosCurriculares.add(new LabelValueBean("4", "4"));
anosCurriculares.add(new LabelValueBean("5", "5"));
request.setAttribute("curricularYearList", anosCurriculares);
// If executionPeriod was previously selected,form has that value as
// default
InfoExecutionPeriod selectedExecutionPeriod =
(InfoExecutionPeriod) request.getAttribute(PresentationConstants.EXECUTION_PERIOD);
if (selectedExecutionPeriod != null) {
indexForm.set("indice", selectedExecutionPeriod.getInfoExecutionYear().getExternalId());
indexForm.set("curYear", Integer.valueOf(anosCurriculares.indexOf(anosCurriculares.iterator().next())));
request.setAttribute(PresentationConstants.EXECUTION_PERIOD, selectedExecutionPeriod);
request.setAttribute(PresentationConstants.EXECUTION_PERIOD_OID, selectedExecutionPeriod.getExternalId().toString());
}
InfoExecutionDegree infoExecutionDegree =
ReadPublicExecutionDegreeByDCPID.run(degreeCurricularPlanId, (String) indexForm.get("indice"));
if (infoExecutionDegree == null) {
try {
List<InfoExecutionDegree> infoExecutionDegrees = ReadPublicExecutionDegreeByDCPID.run(degreeCurricularPlanId);
if (infoExecutionDegrees.size() >= 1) {
infoExecutionDegree = infoExecutionDegrees.get(infoExecutionDegrees.size() - 1);
indexForm.set("indice", infoExecutionDegree.getInfoExecutionYear().getExternalId());
}
} catch (FenixServiceException e1) {
return mapping.findForward("Sucess");
}
}