Search in sources :

Example 6 with SamplingDesignSummaries

use of org.openforis.collect.model.SamplingDesignSummaries in project collect by openforis.

the class SamplingDesignExportTask method execute.

@Override
protected void execute() throws Throwable {
    if (getTotalItems() > 0) {
        Integer surveyId = survey.getId();
        CsvWriter writer = new CsvWriter(outputStream, OpenForisIOUtils.UTF_8, ',', '"');
        SamplingDesignSummaries summaries = samplingDesignManager.loadBySurvey(surveyId);
        ArrayList<String> colNames = getHeaders();
        writer.writeHeaders(colNames);
        List<SamplingDesignItem> items = summaries.getRecords();
        for (SamplingDesignItem item : items) {
            writeSummary(writer, item);
            incrementProcessedItems();
        }
        writer.flush();
    }
}
Also used : CsvWriter(org.openforis.commons.io.csv.CsvWriter) SamplingDesignSummaries(org.openforis.collect.model.SamplingDesignSummaries) SamplingDesignItem(org.openforis.collect.model.SamplingDesignItem)

Example 7 with SamplingDesignSummaries

use of org.openforis.collect.model.SamplingDesignSummaries in project collect by openforis.

the class SamplingDesignService method loadBySurvey.

protected SamplingDesignSummariesProxy loadBySurvey(boolean work, int surveyId, int offset, int maxRecords) {
    SamplingDesignSummaries summaries;
    CollectSurvey survey;
    if (work) {
        survey = surveyManager.loadSurvey(surveyId);
    } else {
        survey = surveyManager.getById(surveyId);
    }
    summaries = samplingDesignManager.loadBySurvey(surveyId, offset, maxRecords);
    return new SamplingDesignSummariesProxy(survey, summaries);
}
Also used : SamplingDesignSummaries(org.openforis.collect.model.SamplingDesignSummaries) CollectSurvey(org.openforis.collect.model.CollectSurvey) SamplingDesignSummariesProxy(org.openforis.collect.model.proxy.SamplingDesignSummariesProxy)

Example 8 with SamplingDesignSummaries

use of org.openforis.collect.model.SamplingDesignSummaries in project collect by openforis.

the class SamplingPointDataKmlGenerator method loadSamplingDesignItems.

private List<SamplingDesignItem> loadSamplingDesignItems() {
    SamplingDesignSummaries samplingDesignSummaries = samplingDesignManager.loadBySurvey(survey.getId());
    List<SamplingDesignItem> samplingDesignItems = samplingDesignSummaries.getRecords();
    List<SamplingDesignItem> result = new ArrayList<SamplingDesignItem>();
    for (SamplingDesignItem item : samplingDesignItems) {
        result.add(item);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) SamplingDesignSummaries(org.openforis.collect.model.SamplingDesignSummaries) SamplingDesignItem(org.openforis.collect.model.SamplingDesignItem)

Example 9 with SamplingDesignSummaries

use of org.openforis.collect.model.SamplingDesignSummaries in project collect by openforis.

the class SamplingDesignExportProcess method exportToCSV.

public void exportToCSV(OutputStream out, CollectSurvey survey) {
    CsvWriter writer = null;
    try {
        writer = new CsvWriter(out);
        SamplingDesignSummaries summaries = samplingDesignManager.loadBySurvey(survey.getId());
        ArrayList<String> colNames = new ArrayList<String>();
        colNames.addAll(Arrays.asList(SamplingDesignFileColumn.LEVEL_COLUMN_NAMES));
        colNames.add(SamplingDesignFileColumn.X.getColumnName());
        colNames.add(SamplingDesignFileColumn.Y.getColumnName());
        colNames.add(SamplingDesignFileColumn.SRS_ID.getColumnName());
        // info columns
        List<ReferenceDataDefinition.Attribute> infoAttributes = getInfoAttributes(survey);
        for (ReferenceDataDefinition.Attribute attribute : infoAttributes) {
            colNames.add(attribute.getName());
        }
        writer.writeHeaders(colNames);
        List<SamplingDesignItem> items = summaries.getRecords();
        for (SamplingDesignItem item : items) {
            writeSummary(writer, survey, item);
        }
    } catch (Exception e) {
        log.error(e);
    } finally {
        IOUtils.closeQuietly(writer);
    }
}
Also used : CsvWriter(org.openforis.commons.io.csv.CsvWriter) ArrayList(java.util.ArrayList) SamplingDesignSummaries(org.openforis.collect.model.SamplingDesignSummaries) ReferenceDataDefinition(org.openforis.idm.metamodel.ReferenceDataSchema.ReferenceDataDefinition) SamplingDesignItem(org.openforis.collect.model.SamplingDesignItem)

Aggregations

SamplingDesignSummaries (org.openforis.collect.model.SamplingDesignSummaries)9 SamplingDesignItem (org.openforis.collect.model.SamplingDesignItem)8 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 CollectIntegrationTest (org.openforis.collect.CollectIntegrationTest)3 CollectSurvey (org.openforis.collect.model.CollectSurvey)3 SamplingDesignImportProcess (org.openforis.collect.io.metadata.samplingdesign.SamplingDesignImportProcess)2 SamplingDesignImportStatus (org.openforis.collect.io.metadata.samplingdesign.SamplingDesignImportStatus)2 CsvWriter (org.openforis.commons.io.csv.CsvWriter)2 LngLatAlt (org.geojson.LngLatAlt)1 CollectSurveyContext (org.openforis.collect.model.CollectSurveyContext)1 SamplingDesignSummariesProxy (org.openforis.collect.model.proxy.SamplingDesignSummariesProxy)1 CoordinateOperations (org.openforis.idm.geospatial.CoordinateOperations)1 ReferenceDataDefinition (org.openforis.idm.metamodel.ReferenceDataSchema.ReferenceDataDefinition)1 Coordinate (org.openforis.idm.model.Coordinate)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1