package com.krishagni.catissueplus.core.biospecimen.services.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;

import com.krishagni.catissueplus.core.administrative.domain.ScheduledJobRun;
import com.krishagni.catissueplus.core.administrative.services.ScheduledTask;
import com.krishagni.catissueplus.core.biospecimen.ConfigParams;
import com.krishagni.catissueplus.core.biospecimen.repository.DaoFactory;
import com.krishagni.catissueplus.core.common.PlusTransactional;
import com.krishagni.catissueplus.core.common.util.ConfigUtil;

@Configurable
public class StagedParticipantsCleanupTask implements ScheduledTask {

	private static final int DEF_CLEANUP_INT = 90;

	@Autowired
	private DaoFactory daoFactory;
	
	@Override
	@PlusTransactional
	public void doJob(ScheduledJobRun jobRun) throws Exception {
		int olderThanDays = ConfigUtil.getInstance().getIntSetting(
			ConfigParams.MODULE,
			ConfigParams.STAGED_PART_CLEANUP_INT,
			DEF_CLEANUP_INT);
		daoFactory.getStagedParticipantDao().cleanupOldParticipants(olderThanDays);
	}
}

@@ -973,20 +973,17 @@
 .MODULE,
-%0A%09%09%09
+ 
 ConfigPa
@@ -1011,20 +1011,17 @@
 NUP_INT,
-%0A%09%09%09
+ 
 DEF_CLEA
@@ -1030,16 +1030,44 @@
 P_INT);%0A
+%09%09if (olderThanDays %3E 0) %7B%0A%09
 %09%09daoFac
@@ -1136,13 +1136,17 @@
 nDays);%0A
+%09%09%7D%0A
 %09%7D%0A%7D%0A

Disable cleaning of staged participants when retain interval specified is 0 days.