CompetenceCourse course = getCompetenceCourse(request);
ExecutionSemester period = getExecutionPeriod(request);
CompetenceCourseInformationRequestBean bean = null;
IViewState viewState = RenderUtils.getViewState("editVersion");
CompetenceCourseInformation information = null;
if (viewState != null) {
bean = (CompetenceCourseInformationRequestBean) viewState.getMetaObject().getObject();
ExecutionSemester beanPeriod = bean.getExecutionPeriod();
if (beanPeriod == null) {
beanPeriod = ExecutionSemester.readActualExecutionSemester();
bean.setExecutionPeriod(beanPeriod);
}
information = bean.getCompetenceCourse().findCompetenceCourseInformationForExecutionPeriod(beanPeriod);
}
if (bean == null) {
bean =
new CompetenceCourseInformationRequestBean(
course.findCompetenceCourseInformationForExecutionPeriod((period != null) ? period : ExecutionSemester
.readActualExecutionSemester()));
} else {
if (information == null) {
bean.reset();
} else {
bean.update(information);
}
}
IViewState viewStateLoad = RenderUtils.getViewState("editVersionLoad");
CompetenceCourseLoadBean load;
if (viewStateLoad != null) {
load = (CompetenceCourseLoadBean) viewStateLoad.getMetaObject().getObject();
} else {
if (information != null && information.getCompetenceCourseLoadsSet().size() > 0) {
load = new CompetenceCourseLoadBean(information.getCompetenceCourseLoadsSet().iterator().next());
} else if (period != null
&& course.findCompetenceCourseInformationForExecutionPeriod(period).getCompetenceCourseLoadsSet().size() > 0) {
load =
new CompetenceCourseLoadBean(course.findCompetenceCourseInformationForExecutionPeriod(period)
.getCompetenceCourseLoadsSet().iterator().next());