private DeletionAuditTrail getDeletionAuditTrail(Object o, String userName) { DeletionAuditTrail dat = new DeletionAuditTrail(); if (o instanceof DeletionAuditSeriesInfo) { DeletionAuditSeriesInfo seriesInfo = (DeletionAuditSeriesInfo) o; dat.setDataType(NCIAConstants.GENERAL_SERIES_TYPE); dat.setDataId(seriesInfo.getSeriesInstanceUID()); dat.setTotalImages(seriesInfo.getTotalImageSize()); } if (o instanceof DeletionAuditStudyInfo) { DeletionAuditStudyInfo study = (DeletionAuditStudyInfo) o; dat.setDataType(NCIAConstants.STUDY_TYPE); dat.setDataId(study.getStudyInstanceUID()); dat.setTotalImages(null); } if (o instanceof DeletionAuditPatientInfo) { DeletionAuditPatientInfo patient = (DeletionAuditPatientInfo) o; dat.setDataType(NCIAConstants.PATIENT_TYPE); dat.setDataId(patient.getPatientId()); dat.setTotalImages(null); } dat.setTimeStamp(new Date()); if (userName == null) { dat.setUserName("System"); } else { dat.setUserName(userName); } return dat; }
public void recordPatient(DeletionAuditPatientInfo patient, String userName) throws DataAccessException { Session session = getExistingSession(); DeletionAuditTrail deletionAuditTrail = getDeletionAuditTrail(patient, userName); try { session.save(deletionAuditTrail); } catch (HibernateException e) { System.out.println("******** Unable to add patient deletion to audit trail *********"); System.out.println(" Series - " + patient.getPatientId() + " User - " + userName); e.printStackTrace(); } }