Search in sources :

Example 1 with JobProxy

use of org.openforis.concurrency.proxy.JobProxy in project collect by openforis.

the class RecordController method startValidationResportJob.

@RequestMapping(value = "survey/{surveyId}/data/records/validationreport", method = POST)
@ResponseBody
public JobProxy startValidationResportJob(@PathVariable("surveyId") int surveyId) {
    User user = sessionManager.getLoggedUser();
    Locale locale = sessionManager.getSessionState().getLocale();
    CollectSurvey survey = surveyManager.getById(surveyId);
    EntityDefinition rootEntityDef = survey.getSchema().getFirstRootEntityDefinition();
    ValidationReportJob job = jobManager.createJob(ValidationReportJob.class);
    Input input = new Input();
    input.setLocale(locale);
    input.setReportType(ReportType.CSV);
    RecordFilter recordFilter = createRecordFilter(survey, user, userGroupManager, rootEntityDef.getId(), false);
    input.setRecordFilter(recordFilter);
    job.setInput(input);
    this.validationReportJob = job;
    jobManager.start(job);
    return new JobProxy(job);
}
Also used : Locale(java.util.Locale) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) Input(org.openforis.collect.manager.ValidationReportJob.Input) CSVDataImportInput(org.openforis.collect.io.data.CSVDataImportJob.CSVDataImportInput) User(org.openforis.collect.model.User) JobProxy(org.openforis.concurrency.proxy.JobProxy) ValidationReportJob(org.openforis.collect.manager.ValidationReportJob) CollectSurvey(org.openforis.collect.model.CollectSurvey) RecordFilter(org.openforis.collect.model.RecordFilter) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with JobProxy

use of org.openforis.concurrency.proxy.JobProxy in project collect by openforis.

the class SaikuController method generateRepository.

@RequestMapping(value = "datasources/{surveyName}/generate", method = POST)
@ResponseBody
public JobProxy generateRepository(@PathVariable String surveyName, @RequestParam String language) throws CollectRdbException, SQLException {
    CollectSurvey survey = surveyManager.get(surveyName);
    ReportingRepositoriesGeneratorJob job = jobManager.createJob(ReportingRepositoriesGeneratorJob.class);
    job.setInput(new Input(language));
    job.setSurvey(survey);
    jobManager.startSurveyJob(job);
    return new JobProxy(job);
}
Also used : Input(org.openforis.collect.reporting.ReportingRepositoriesGeneratorJob.Input) JobProxy(org.openforis.concurrency.proxy.JobProxy) ReportingRepositoriesGeneratorJob(org.openforis.collect.reporting.ReportingRepositoriesGeneratorJob) CollectSurvey(org.openforis.collect.model.CollectSurvey) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with JobProxy

use of org.openforis.concurrency.proxy.JobProxy 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);
}
Also used : SessionState(org.openforis.collect.web.session.SessionState) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) CollectRecord(org.openforis.collect.model.CollectRecord) User(org.openforis.collect.model.User) JobProxy(org.openforis.concurrency.proxy.JobProxy) CollectSurvey(org.openforis.collect.model.CollectSurvey) BulkRecordMoveJob(org.openforis.collect.io.data.BulkRecordMoveJob) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with JobProxy

use of org.openforis.concurrency.proxy.JobProxy in project collect by openforis.

the class SaikuService method generateRdb.

@Secured(USER)
public JobProxy generateRdb(final String surveyName, final String preferredLanguage) {
    CollectSurvey survey = surveyManager.get(surveyName);
    ReportingRepositoriesGeneratorJob job = jobManager.createJob(ReportingRepositoriesGeneratorJob.class);
    job.setInput(new Input(preferredLanguage));
    job.setSurvey(survey);
    jobManager.startSurveyJob(job);
    return new JobProxy(job);
}
Also used : Input(org.openforis.collect.reporting.ReportingRepositoriesGeneratorJob.Input) JobProxy(org.openforis.concurrency.proxy.JobProxy) ReportingRepositoriesGeneratorJob(org.openforis.collect.reporting.ReportingRepositoriesGeneratorJob) CollectSurvey(org.openforis.collect.model.CollectSurvey) Secured(org.springframework.security.access.annotation.Secured)

Aggregations

CollectSurvey (org.openforis.collect.model.CollectSurvey)4 JobProxy (org.openforis.concurrency.proxy.JobProxy)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 User (org.openforis.collect.model.User)2 ReportingRepositoriesGeneratorJob (org.openforis.collect.reporting.ReportingRepositoriesGeneratorJob)2 Input (org.openforis.collect.reporting.ReportingRepositoriesGeneratorJob.Input)2 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)2 Locale (java.util.Locale)1 BulkRecordMoveJob (org.openforis.collect.io.data.BulkRecordMoveJob)1 CSVDataImportInput (org.openforis.collect.io.data.CSVDataImportJob.CSVDataImportInput)1 ValidationReportJob (org.openforis.collect.manager.ValidationReportJob)1 Input (org.openforis.collect.manager.ValidationReportJob.Input)1 CollectRecord (org.openforis.collect.model.CollectRecord)1 RecordFilter (org.openforis.collect.model.RecordFilter)1 SessionState (org.openforis.collect.web.session.SessionState)1 Secured (org.springframework.security.access.annotation.Secured)1