use of org.openforis.collect.remoting.service.backup.BackupProcess in project collect by openforis.
the class BackupService method getBackup.
private BackupProcess getBackup(String rootEntityName) throws Exception {
SessionState sessionState = sessionManager.getSessionState();
CollectSurvey survey = sessionState.getActiveSurvey();
Integer surveyId = survey.getId();
Map<String, BackupProcess> backupsPerSurvey = backups.get(surveyId);
if (backupsPerSurvey == null) {
backupsPerSurvey = new HashMap<String, BackupProcess>();
backups.put(surveyId, backupsPerSurvey);
}
BackupProcess backup = backupsPerSurvey.get(rootEntityName);
if (backup == null) {
int[] stepNumbers = { 1, 2, 3 };
backup = new BackupProcess(surveyManager, recordManager, dataMarshaller, backupDirectory, survey, rootEntityName, stepNumbers);
backupsPerSurvey.put(rootEntityName, backup);
}
return backup;
}
use of org.openforis.collect.remoting.service.backup.BackupProcess in project collect by openforis.
the class BackupService method backup.
public synchronized Map<String, Object> backup(String rootEntityName, List<Integer> ids, Integer stepNumber) {
Map<String, Object> result = new HashMap<String, Object>();
try {
BackupProcess backup = getBackup(rootEntityName);
if (backup.isRunning()) {
result.put("error", "Another backup is already active for this survey. Please try later in a few minutes.");
} else {
ExecutorServiceUtil.executeInCachedPool(backup);
result.put("start", "The backup is started");
}
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
use of org.openforis.collect.remoting.service.backup.BackupProcess in project collect by openforis.
the class BackupService method getStatus.
public Map<String, Object> getStatus(String rootEntityName) throws Exception {
Map<String, Object> result = new HashMap<String, Object>();
BackupProcess backup = getBackup(rootEntityName);
result.put("active", backup.isRunning());
// result.put("count", backup.getCount());
return result;
}
Aggregations