コード例 #1
0
 public SectionContentsBean(SectionDataIfc section) {
   try {
     this.itemContents = new ArrayList();
     setSectionId(section.getSectionId().toString());
     setTitle(section.getTitle());
     setDescription(section.getDescription());
     Integer sequence = section.getSequence();
     if (sequence != null) {
       setNumber(sequence.toString());
     } else {
       setNumber("1");
     }
     setNumber(section.getSequence().toString());
     // do teh rest later
     Set itemSet = section.getItemSet();
     if (itemSet != null) {
       setQuestions(itemSet.size());
       Iterator i = itemSet.iterator();
       while (i.hasNext()) {
         ItemDataIfc item = (ItemDataIfc) i.next();
         ItemContentsBean itemBean = new ItemContentsBean(item);
         this.itemContents.add(itemBean);
       }
     }
     // set questionNumbers now
     setQuestionNumbers();
     setMetaData(section);
     this.attachmentList = section.getSectionAttachmentList();
     if (this.attachmentList != null && this.attachmentList.size() > 0) this.hasAttachment = true;
   } catch (Exception e) {
     e.printStackTrace();
     throw new RuntimeException(e);
   }
 }
コード例 #2
0
  public void deleteItem(Long itemId, String agent) {
    ItemData item = null;
    try {
      item = (ItemData) getHibernateTemplate().load(ItemData.class, itemId);
    } catch (DataAccessException e) {
      log.warn("unable to retrieve item " + itemId + " due to:" + e);
      return;
    }
    // get list of attachment in item
    AssessmentService service = new AssessmentService();
    List itemAttachmentList = service.getItemResourceIdList(item);
    service.deleteResources(itemAttachmentList);

    int retryCount = PersistenceService.getInstance().getPersistenceHelper().getRetryCount();
    while (retryCount > 0) {
      try {
        SectionDataIfc section = item.getSection();
        // section might be null if you are deleting an item created inside a pool, that's not
        // linked to any assessment.
        if (section != null) {
          Set set = section.getItemSet();
          set.remove(item);
        }
        getHibernateTemplate().delete(item);
        retryCount = 0;
      } catch (Exception e) {
        log.warn("problem deleting item: " + e.getMessage());
        retryCount =
            PersistenceService.getInstance().getPersistenceHelper().retryDeadlock(e, retryCount);
      }
    }
  }