示例#1
0
  public void updateData(SampleHuman sampleHuman) throws LIMSRuntimeException {

    SampleHuman oldData = readSampleHuman(sampleHuman.getId());
    SampleHuman newData = sampleHuman;

    // add to audit trail
    try {
      AuditTrailDAO auditDAO = new AuditTrailDAOImpl();
      String sysUserId = sampleHuman.getSysUserId();
      String event = IActionConstants.AUDIT_TRAIL_UPDATE;
      String tableName = "SAMPLE_HUMAN";
      auditDAO.saveHistory(newData, oldData, sysUserId, event, tableName);
    } catch (Exception e) {
      // bugzilla 2154
      LogEvent.logError("SampleHumanDAOImpl", "updateData()", e.toString());
      throw new LIMSRuntimeException("Error in SampleHuman AuditTrail updateData()", e);
    }

    try {
      HibernateUtil.getSession().merge(sampleHuman);
      HibernateUtil.getSession().flush();
      HibernateUtil.getSession().clear();
      HibernateUtil.getSession().evict(sampleHuman);
      HibernateUtil.getSession().refresh(sampleHuman);
    } catch (Exception e) {
      // bugzilla 2154
      LogEvent.logError("SampleHumanDAOImpl", "updateData()", e.toString());
      throw new LIMSRuntimeException("Error in SampleHuman updateData()", e);
    }
  }
示例#2
0
  public boolean insertData(SampleHuman sampleHuman) throws LIMSRuntimeException {

    try {
      String id = (String) HibernateUtil.getSession().save(sampleHuman);
      sampleHuman.setId(id);

      // bugzilla 1824 inserts will be logged in history table
      AuditTrailDAO auditDAO = new AuditTrailDAOImpl();
      String sysUserId = sampleHuman.getSysUserId();
      String tableName = "SAMPLE_HUMAN";
      auditDAO.saveNewHistory(sampleHuman, sysUserId, tableName);

      HibernateUtil.getSession().flush();
      HibernateUtil.getSession().clear();

    } catch (Exception e) {
      // bugzilla 2154
      LogEvent.logError("SampleHumanDAOImpl", "insertData()", e.toString());
      throw new LIMSRuntimeException("Error in SampleHuman insertData()", e);
    }

    return true;
  }
示例#3
0
  public void deleteData(List sampleHumans) throws LIMSRuntimeException {
    // add to audit trail
    try {
      AuditTrailDAO auditDAO = new AuditTrailDAOImpl();
      for (int i = 0; i < sampleHumans.size(); i++) {
        SampleHuman data = (SampleHuman) sampleHumans.get(i);

        SampleHuman oldData = (SampleHuman) readSampleHuman(data.getId());
        SampleHuman newData = new SampleHuman();

        String sysUserId = data.getSysUserId();
        String event = IActionConstants.AUDIT_TRAIL_DELETE;
        String tableName = "SAMPLE_HUMAN";
        auditDAO.saveHistory(newData, oldData, sysUserId, event, tableName);
      }
    } catch (Exception e) {
      // bugzilla 2154
      LogEvent.logError("SampleHumanDAOImpl", "AuditTrail deleteData()", e.toString());
      throw new LIMSRuntimeException("Error in SampleHuman AuditTrail deleteData()", e);
    }

    try {
      for (int i = 0; i < sampleHumans.size(); i++) {
        SampleHuman data = (SampleHuman) sampleHumans.get(i);
        // bugzilla 2206
        data = (SampleHuman) readSampleHuman(data.getId());
        HibernateUtil.getSession().delete(data);
        HibernateUtil.getSession().flush();
        HibernateUtil.getSession().clear();
      }
    } catch (Exception e) {
      // bugzilla 2154
      LogEvent.logError("SampleHumanDAOImpl", "deleteData()", e.toString());
      throw new LIMSRuntimeException("Error in SampleHuman deleteData()", e);
    }
  }