Search in sources :

Example 1 with SurveyLockingJobProxy

use of org.openforis.collect.remoting.service.concurrency.proxy.SurveyLockingJobProxy 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);
}
Also used : SessionState(org.openforis.collect.web.session.SessionState) CollectRecord(org.openforis.collect.model.CollectRecord) RecordStep(org.openforis.collect.event.RecordStep) Step(org.openforis.collect.model.CollectRecord.Step) SurveyLockingJobProxy(org.openforis.collect.remoting.service.concurrency.proxy.SurveyLockingJobProxy) BulkRecordMoveJob(org.openforis.collect.io.data.BulkRecordMoveJob) Secured(org.springframework.security.access.annotation.Secured)

Aggregations

RecordStep (org.openforis.collect.event.RecordStep)1 BulkRecordMoveJob (org.openforis.collect.io.data.BulkRecordMoveJob)1 CollectRecord (org.openforis.collect.model.CollectRecord)1 Step (org.openforis.collect.model.CollectRecord.Step)1 SurveyLockingJobProxy (org.openforis.collect.remoting.service.concurrency.proxy.SurveyLockingJobProxy)1 SessionState (org.openforis.collect.web.session.SessionState)1 Secured (org.springframework.security.access.annotation.Secured)1