Search in sources :

Example 26 with SamplingDesignItem

use of org.openforis.collect.model.SamplingDesignItem 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

SamplingDesignItem (org.openforis.collect.model.SamplingDesignItem)26 ArrayList (java.util.ArrayList)9 SamplingDesignSummaries (org.openforis.collect.model.SamplingDesignSummaries)8 Coordinate (org.openforis.idm.model.Coordinate)7 CollectSurvey (org.openforis.collect.model.CollectSurvey)6 Test (org.junit.Test)5 CollectIntegrationTest (org.openforis.collect.CollectIntegrationTest)3 SamplingPointDataGenerator (org.openforis.collect.io.metadata.samplingpointdata.SamplingPointDataGenerator)3 SamplingPointGenerationSettings (org.openforis.collect.metamodel.samplingdesign.SamplingPointGenerationSettings)3 SamplingDesignImportProcess (org.openforis.collect.io.metadata.samplingdesign.SamplingDesignImportProcess)2 SamplingDesignImportStatus (org.openforis.collect.io.metadata.samplingdesign.SamplingDesignImportStatus)2 SamplingPointLevelGenerationSettings (org.openforis.collect.metamodel.samplingdesign.SamplingPointLevelGenerationSettings)2 OfcSamplingDesignRecord (org.openforis.collect.persistence.jooq.tables.records.OfcSamplingDesignRecord)2 CsvWriter (org.openforis.commons.io.csv.CsvWriter)2 CoordinateOperations (org.openforis.idm.geospatial.CoordinateOperations)2 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)2 ReferenceDataSchema (org.openforis.idm.metamodel.ReferenceDataSchema)2 SamplingPointDefinition (org.openforis.idm.metamodel.ReferenceDataSchema.SamplingPointDefinition)2 Document (de.micromata.opengis.kml.v_2_2_0.Document)1 Kml (de.micromata.opengis.kml.v_2_2_0.Kml)1