use of ambit2.db.substance.processor.DBBundleStudyWriter in project ambit-mirror by ideaconsult.
the class SubstanceWriterTest method delete.
public int delete(SubstanceEndpointsBundle bundle, IRawReader<IStructureRecord> reader, Connection connection) throws Exception {
/*
* DBSubstanceWriter writer; if (bundle != null) writer = new
* DBBundleStudyWriter(bundle, DBSubstanceWriter.datasetMeta(), new
* SubstanceRecord()); else writer = new
* DBSubstanceWriter(DBSubstanceWriter.datasetMeta(), new
* SubstanceRecord(), clearMeasurements, clearComposition);
* writer.setSplitRecord(splitRecord); writer.setConnection(connection);
* writer.open();
*/
UpdateExecutor<IQueryUpdate> writer = new UpdateExecutor<IQueryUpdate>();
writer.setConnection(connection);
DeleteMatrixValue q = new DeleteMatrixValue();
q.setGroup(bundle);
int records = 0;
while (reader.hasNext()) {
Object record = reader.next();
if (record == null)
continue;
Assert.assertTrue(record instanceof SubstanceRecord);
Assert.assertEquals("IUC4-efdb21bb-e79f-3286-a988-b6f6944d3734", ((SubstanceRecord) record).getSubstanceUUID());
for (ProtocolApplication pa : ((SubstanceRecord) record).getMeasurements()) {
Assert.assertTrue(pa instanceof ProtocolApplicationAnnotated);
// System.out.println(((ProtocolApplicationAnnotated) pa)getRecords_to_delete());
ProtocolApplicationAnnotated paa = (ProtocolApplicationAnnotated) pa;
List<ValueAnnotated> vaa = paa.getRecords_to_delete();
for (ValueAnnotated va : vaa) {
q.setObject(va);
writer.process(q);
}
}
// writer.setImportedRecord((SubstanceRecord) record);
// writer.process((IStructureRecord) record);
records++;
}
writer.close();
return records;
}
use of ambit2.db.substance.processor.DBBundleStudyWriter in project ambit-mirror by ideaconsult.
the class SubstanceWriterTest method write.
public int write(SubstanceEndpointsBundle bundle, IRawReader<IStructureRecord> reader, Connection connection, PropertyKey key, boolean splitRecord, boolean clearMeasurements, boolean clearComposition) throws Exception {
DBSubstanceWriter writer;
if (bundle != null)
writer = new DBBundleStudyWriter(bundle, DBSubstanceWriter.datasetMeta(), new SubstanceRecord());
else
writer = new DBSubstanceWriter(DBSubstanceWriter.datasetMeta(), new SubstanceRecord(), clearMeasurements, clearComposition);
writer.setSplitRecord(splitRecord);
writer.setConnection(connection);
writer.open();
int records = 0;
while (reader.hasNext()) {
Object record = reader.next();
if (record == null)
continue;
Assert.assertTrue(record instanceof IStructureRecord);
if (record instanceof SubstanceRecord)
writer.setImportedRecord((SubstanceRecord) record);
writer.process((IStructureRecord) record);
records++;
}
writer.close();
return records;
}
Aggregations