public void setAssessment(AssessmentIfc assessment) { try { this.assessment = assessment; if (assessment instanceof AssessmentFacade) { this.assessmentId = assessment.getAssessmentId().toString(); } else if (assessment instanceof PublishedAssessmentFacade) { this.assessmentId = ((PublishedAssessmentFacade) assessment).getPublishedAssessmentId().toString(); } this.title = assessment.getTitle(); // work out the question side & total point this.sections = new ArrayList<SectionContentsBean>(); List<? extends SectionDataIfc> sectionArray = assessment.getSectionArraySorted(); for (int i = 0; i < sectionArray.size(); i++) { SectionDataIfc section = sectionArray.get(i); SectionContentsBean sectionBean = new SectionContentsBean(section); this.sections.add(sectionBean); } setPartNumbers(); setQuestionSizeAndTotalScore(); setSectionList(sectionArray); } catch (Exception ex) { ex.printStackTrace(); } }
public ItemFacade saveItem(ItemFacade item) throws DataFacadeException { try { ItemDataIfc itemdata = (ItemDataIfc) item.getData(); itemdata.setLastModifiedDate(new Date()); itemdata.setLastModifiedBy(AgentFacade.getAgentString()); int retryCount = PersistenceService.getInstance().getPersistenceHelper().getRetryCount(); while (retryCount > 0) { try { getHibernateTemplate().saveOrUpdate(itemdata); item.setItemId(itemdata.getItemId()); retryCount = 0; } catch (Exception e) { log.warn("problem save or update itemdata: " + e.getMessage()); retryCount = PersistenceService.getInstance().getPersistenceHelper().retryDeadlock(e, retryCount); } } if ((item.getData() != null) && (item.getData().getSection() != null)) { AssessmentIfc assessment = item.getData().getSection().getAssessment(); assessment.setLastModifiedBy(AgentFacade.getAgentString()); assessment.setLastModifiedDate(new Date()); retryCount = PersistenceService.getInstance().getPersistenceHelper().getRetryCount(); while (retryCount > 0) { try { getHibernateTemplate().update(assessment); retryCount = 0; } catch (Exception e) { log.warn("problem updating asssessment: " + e.getMessage()); retryCount = PersistenceService.getInstance() .getPersistenceHelper() .retryDeadlock(e, retryCount); } } } return item; } catch (Exception e) { e.printStackTrace(); return null; } }