Search in sources :

Example 1 with BackupProcess

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;
}
Also used : SessionState(org.openforis.collect.web.session.SessionState) BackupProcess(org.openforis.collect.remoting.service.backup.BackupProcess) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 2 with BackupProcess

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;
}
Also used : HashMap(java.util.HashMap) BackupProcess(org.openforis.collect.remoting.service.backup.BackupProcess)

Example 3 with BackupProcess

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;
}
Also used : HashMap(java.util.HashMap) BackupProcess(org.openforis.collect.remoting.service.backup.BackupProcess)

Aggregations

BackupProcess (org.openforis.collect.remoting.service.backup.BackupProcess)3 HashMap (java.util.HashMap)2 CollectSurvey (org.openforis.collect.model.CollectSurvey)1 SessionState (org.openforis.collect.web.session.SessionState)1