use of org.openforis.collect.datacleansing.DataReportItem in project collect by openforis.
the class DataReportController method loadItems.
@RequestMapping(value = "{reportId}/items.json", method = GET)
@ResponseBody
public PaginatedResponse loadItems(@PathVariable int reportId, @RequestParam int offset, @RequestParam int limit) {
CollectSurvey survey = sessionManager.getActiveSurvey();
DataReport report = itemManager.loadById(survey, reportId);
int total = itemManager.countItems(report);
List<DataReportItem> items = itemManager.loadItems(report, offset, limit);
List<DataReportItemForm> rows = new ArrayList<DataReportItemForm>(items.size());
for (DataReportItem item : items) {
rows.add(new DataReportItemForm(item));
}
return new PaginatedResponse(total, rows);
}
use of org.openforis.collect.datacleansing.DataReportItem 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);
}
use of org.openforis.collect.datacleansing.DataReportItem in project collect by openforis.
the class DataReportManager method loadItems.
public List<DataReportItem> loadItems(DataReport report, Integer offset, Integer limit) {
CollectSurvey survey = report.getSurvey();
Map<Integer, CollectRecord> recordCache = new HashMap<Integer, CollectRecord>();
List<DataReportItem> items = dataReportItemDao.loadByReport(report, offset, limit);
for (DataReportItem item : items) {
int recordId = item.getRecordId();
CollectRecord record = recordCache.get(recordId);
if (record == null) {
record = recordManager.load(survey, recordId, report.getRecordStep(), false);
recordCache.put(recordId, record);
}
item.setRecord(record);
}
return items;
}
Aggregations