Search in sources :

Example 1 with OfcDataReportItemRecord

use of org.openforis.collect.persistence.jooq.tables.records.OfcDataReportItemRecord in project collect by openforis.

the class DataReportItemDao method insert.

public void insert(DataReport report, List<DataReportItem> items) {
    JooqDSLContext dsl = dsl(report);
    int nextId = dsl.nextId();
    int maxId = nextId;
    Insert<OfcDataReportItemRecord> insert = dsl.createInsertStatement();
    BatchBindStep batch = dsl.batch(insert);
    for (DataReportItem item : items) {
        Integer id = item.getId();
        if (id == null) {
            id = nextId++;
            item.setId(id);
        }
        Object[] values = dsl.extractValues(item);
        batch.bind(values);
        maxId = Math.max(maxId, id);
    }
    batch.execute();
    dsl.restartSequence(maxId + 1);
}
Also used : DataReportItem(org.openforis.collect.datacleansing.DataReportItem) OfcDataReportItemRecord(org.openforis.collect.persistence.jooq.tables.records.OfcDataReportItemRecord) BatchBindStep(org.jooq.BatchBindStep)

Aggregations

BatchBindStep (org.jooq.BatchBindStep)1 DataReportItem (org.openforis.collect.datacleansing.DataReportItem)1 OfcDataReportItemRecord (org.openforis.collect.persistence.jooq.tables.records.OfcDataReportItemRecord)1