/** * convenience method to set transfer status and active flag to stop migration */ public static void stopMigration() { transferStatus = Status.STOPPED; setActive(false); }
/** * Constructor to initialize variables */ public Hl7InArchivesMigrateThread() { this.userContext = Context.getUserContext(); setProgressStatusMap(new HashMap<>()); progressStatusMap.put(HL7Constants.NUMBER_TRANSFERRED_KEY, 0); progressStatusMap.put(HL7Constants.NUMBER_OF_FAILED_TRANSFERS_KEY, 0); }
setTransferStatus(Status.RUNNING); while (isActive() && transferStatus == Status.RUNNING) { try { if (isActive()) { Context.getHL7Service().migrateHl7InArchivesToFileSystem(progressStatusMap); setTransferStatus(Status.COMPLETED); setTransferStatus(Status.ERROR); log.warn("Some error occurred while migrating hl7 archives", e); setActive(false);
while (Hl7InArchivesMigrateThread.isActive() && Hl7InArchivesMigrateThread.getTransferStatus() == Status.RUNNING && hl7InArchives != null && !hl7InArchives.isEmpty()) { while (Hl7InArchivesMigrateThread.isActive() && Hl7InArchivesMigrateThread.getTransferStatus() == Status.RUNNING && iterator.hasNext()) { HL7InArchive archive = iterator.next();
/** * @see org.openmrs.hl7.HL7Service#getHL7InArchiveByUuid(java.lang.String) */ @Override @Transactional(readOnly = true) public HL7InArchive getHL7InArchiveByUuid(String uuid) throws APIException { if (Hl7InArchivesMigrateThread.isActive()) { throw new APIException("Hl7Service.cannot.fetch.archives", (Object[]) null); } return dao.getHL7InArchiveByUuid(uuid); }
/** * @see org.openmrs.hl7.db.HL7DAO#getHL7InArchivesToMigrate() */ @Override @SuppressWarnings("unchecked") public List<HL7InArchive> getHL7InArchivesToMigrate() { Integer daysToKeep = Hl7InArchivesMigrateThread.getDaysKept(); Criteria crit = getHL7SearchCriteria(HL7InArchive.class, HL7Constants.HL7_STATUS_PROCESSED, null); crit.setMaxResults(HL7Constants.MIGRATION_MAX_BATCH_SIZE); if (daysToKeep != null) { Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, -1 * daysToKeep); crit.add(Restrictions.lt("dateCreated", cal.getTime())); } return crit.list(); }