use of org.openforis.collect.io.data.BulkRecordMoveJob in project collect by openforis.
the class RecordController method moveRecords.
@RequestMapping(value = "survey/{surveyId}/data/move/records", method = POST, produces = APPLICATION_JSON_VALUE)
@ResponseBody
public JobProxy moveRecords(@PathVariable("surveyId") int surveyId, @RequestParam String fromStep, @RequestParam boolean promote) {
BulkRecordMoveJob job = jobManager.createJob(BulkRecordMoveJob.class);
SessionState sessionState = sessionManager.getSessionState();
User loggedUser = sessionState.getUser();
CollectSurvey survey = surveyManager.getById(surveyId);
EntityDefinition rootEntityDef = survey.getSchema().getFirstRootEntityDefinition();
job.setSurvey(survey);
job.setRootEntity(rootEntityDef.getName());
job.setPromote(promote);
job.setFromStep(Step.valueOf(fromStep));
job.setUser(loggedUser);
job.setRecordMovedCallback(new BulkRecordMoveJob.Callback() {
@Override
public void recordMoved(CollectRecord record) {
if (promote) {
publishRecordPromotedEvents(record, loggedUser.getUsername());
} else {
publishRecordDeletedEvent(record, RecordStep.valueOf(fromStep), loggedUser.getUsername());
}
}
});
jobManager.startSurveyJob(job);
return new JobProxy(job);
}
use of org.openforis.collect.io.data.BulkRecordMoveJob in project collect by openforis.
the class DataService method moveRecords.
@Secured(CLEANSING)
public SurveyLockingJobProxy moveRecords(String rootEntity, int fromStepNumber, final boolean promote) {
BulkRecordMoveJob job = collectJobManager.createJob(BulkRecordMoveJob.class);
SessionState sessionState = getSessionState();
final String userName = sessionState.getUser().getUsername();
job.setSurvey(sessionState.getActiveSurvey());
job.setRootEntity(rootEntity);
job.setPromote(promote);
final Step fromStep = Step.valueOf(fromStepNumber);
job.setFromStep(fromStep);
job.setUser(sessionState.getUser());
job.setRecordMovedCallback(new BulkRecordMoveJob.Callback() {
@Override
public void recordMoved(CollectRecord record) {
if (promote) {
publishRecordPromotedEvents(record, userName);
} else {
publishRecordDeletedEvent(record, fromStep.toRecordStep(), userName);
}
}
});
collectJobManager.startSurveyJob(job);
return new SurveyLockingJobProxy(job);
}
Aggregations