/** Restore all the VOs related to this core responsibility structure */
  public void restore() throws ArchEException {
    Session openSession = ArchECoreDataProvider.getSessionFactory().getCurrentSession();
    if (openSession != null && openSession.isConnected() && openSession.isOpen()) {
      try {
        // Restore a raw responsibility structure
        rawRSVO =
            (ArchEResponsibilityStructureVO)
                (openSession
                    .createQuery("from ArchEResponsibilityStructureVO as v where v.id = ?")
                    .setInteger(0, version.getId())
                    .uniqueResult());

        // Lazy initialization of collections
        Hibernate.initialize(rawRSVO.getResponsibilities());

        for (Iterator<ArchEResponsibilityVO> itResps = rawRSVO.getResponsibilities().iterator();
            itResps.hasNext(); )
          this.restoreParametersForResponsibility(itResps.next(), openSession);

        // Restore the translation relations from requirements to responsibilities
        Query qrels =
            ArchECoreDataProvider.getSessionFactory()
                .getCurrentSession()
                .createQuery(
                    "from ArchETranslationRelationVO as rel where rel.parentType = ? and rel.version = ?");
        qrels.setString(0, "Scenario");
        qrels.setInteger(1, version.getId());
        trVOs = qrels.list();

        // Restore the refinement relations (between responsibilities)
        Query qrefs =
            ArchECoreDataProvider.getSessionFactory()
                .getCurrentSession()
                .createQuery("from ArchERefinementRelationVO as rel where rel.version = ?");
        qrefs.setInteger(0, version.getId());
        refVOs = qrefs.list();

      } catch (HibernateException ex) {
        throw new ArchEException(ex.getMessage(), ex.getCause());
      }
    }
  }
  /**
   * Save AS all the VOs related to this core responsibility structure
   *
   * @param newVersion The version for the new VOs
   * @throws ArchEException
   */
  public void saveAs(ArchEVersionVO newVersion) throws ArchEException {
    Session openSession = ArchECoreDataProvider.getSessionFactory().getCurrentSession();
    if (openSession != null && openSession.isConnected() && openSession.isOpen()) {
      try {

        // Save the newly-created raw responsibility structure
        rawRSVO.setId(newVersion.getId());

        ArchEResponsibilityVO itemResp = null;
        for (Iterator<ArchEResponsibilityVO> it = rawRSVO.getResponsibilities().iterator();
            it.hasNext(); ) {
          itemResp = it.next();
          itemResp.setVersion(newVersion);
          openSession.save(itemResp);
          this.saveParametersForResponsibilityAs(newVersion, itemResp, openSession);
        }

        // Create a copy of the existing translation relations
        ArchETranslationRelationVO itemTr = null;
        for (Iterator<ArchETranslationRelationVO> it = trVOs.iterator(); it.hasNext(); ) {
          itemTr = it.next();
          itemTr.setVersion(newVersion);
          openSession.save(itemTr);
        }

        // Create a copy of the existing refinement relations
        ArchERefinementRelationVO itemRef = null;
        for (Iterator<ArchERefinementRelationVO> it = refVOs.iterator(); it.hasNext(); ) {
          itemRef = it.next();
          itemRef.setVersion(newVersion);
          openSession.save(itemRef);
        }

      } catch (HibernateException ex) {
        throw new ArchEException(ex.getMessage(), ex.getCause());
      }
    }
  }