Search in sources :

Example 1 with IQueryUpdate

use of net.idea.modbcum.i.query.IQueryUpdate 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;
}
Also used : DeleteMatrixValue(ambit2.db.update.bundle.matrix.DeleteMatrixValue) ProtocolApplication(ambit2.base.data.study.ProtocolApplication) UpdateExecutor(net.idea.modbcum.p.UpdateExecutor) ValueAnnotated(ambit2.base.data.study.ValueAnnotated) SubstanceRecord(ambit2.base.data.SubstanceRecord) IQueryUpdate(net.idea.modbcum.i.query.IQueryUpdate) ProtocolApplicationAnnotated(ambit2.base.data.study.ProtocolApplicationAnnotated)

Example 2 with IQueryUpdate

use of net.idea.modbcum.i.query.IQueryUpdate in project ambit-mirror by ideaconsult.

the class Bundle_crud_test method deleteQuery.

@Override
protected IQueryUpdate<Object, SubstanceEndpointsBundle> deleteQuery() throws Exception {
    SubstanceEndpointsBundle adataset = new SubstanceEndpointsBundle();
    adataset.setID(1);
    DeleteBundle q = new DeleteBundle(adataset);
    return (IQueryUpdate<Object, SubstanceEndpointsBundle>) q;
}
Also used : SubstanceEndpointsBundle(ambit2.base.data.substance.SubstanceEndpointsBundle) DeleteBundle(ambit2.db.update.bundle.DeleteBundle) IQueryUpdate(net.idea.modbcum.i.query.IQueryUpdate)

Example 3 with IQueryUpdate

use of net.idea.modbcum.i.query.IQueryUpdate in project ambit-mirror by ideaconsult.

the class DatasetStructure_crud_test method testCreateNew.

@Test
public void testCreateNew() throws Exception {
    IQueryUpdate query = createQueryNew();
    setUpDatabaseFromResource(dbFile);
    IDatabaseConnection c = getConnection();
    executor.setConnection(c.getConnection());
    executor.open();
    Assert.assertTrue(executor.process(query) >= 1);
    createVerifyNew(query);
    c.close();
}
Also used : IQueryUpdate(net.idea.modbcum.i.query.IQueryUpdate) IDatabaseConnection(org.dbunit.database.IDatabaseConnection) Test(org.junit.Test)

Example 4 with IQueryUpdate

use of net.idea.modbcum.i.query.IQueryUpdate in project ambit-mirror by ideaconsult.

the class Dataset_crud_test method deleteQuery.

@Override
protected IQueryUpdate<Object, SourceDataset> deleteQuery() throws Exception {
    SourceDataset adataset = new SourceDataset();
    adataset.setId(1);
    DeleteDataset q = new DeleteDataset(adataset);
    q.setGroup(new Integer(5));
    return (IQueryUpdate<Object, SourceDataset>) q;
}
Also used : ISourceDataset(ambit2.base.data.ISourceDataset) SourceDataset(ambit2.base.data.SourceDataset) IQueryUpdate(net.idea.modbcum.i.query.IQueryUpdate) DeleteDataset(ambit2.db.update.dataset.DeleteDataset)

Example 5 with IQueryUpdate

use of net.idea.modbcum.i.query.IQueryUpdate in project ambit-mirror by ideaconsult.

the class CreateBundlePolicyTest method testUpdate.

@Test
public void testUpdate() throws Exception {
    setUpDatabase(dbFile);
    IQueryUpdate query = updateQuery();
    IDatabaseConnection c = getConnection();
    executor.setConnection(c.getConnection());
    executor.open();
    Assert.assertTrue(executor.process(query) >= 1);
    updateVerify(query, 2);
    c.close();
}
Also used : IQueryUpdate(net.idea.modbcum.i.query.IQueryUpdate) IDatabaseConnection(org.dbunit.database.IDatabaseConnection) DbUnitTest(net.idea.restnet.db.test.DbUnitTest) Test(org.junit.Test)

Aggregations

IQueryUpdate (net.idea.modbcum.i.query.IQueryUpdate)10 IDatabaseConnection (org.dbunit.database.IDatabaseConnection)7 Test (org.junit.Test)7 DbUnitTest (net.idea.restnet.db.test.DbUnitTest)4 ISourceDataset (ambit2.base.data.ISourceDataset)1 SourceDataset (ambit2.base.data.SourceDataset)1 SubstanceRecord (ambit2.base.data.SubstanceRecord)1 ProtocolApplication (ambit2.base.data.study.ProtocolApplication)1 ProtocolApplicationAnnotated (ambit2.base.data.study.ProtocolApplicationAnnotated)1 ValueAnnotated (ambit2.base.data.study.ValueAnnotated)1 SubstanceEndpointsBundle (ambit2.base.data.substance.SubstanceEndpointsBundle)1 DeleteBundle (ambit2.db.update.bundle.DeleteBundle)1 DeleteMatrixValue (ambit2.db.update.bundle.matrix.DeleteMatrixValue)1 DeleteDataset (ambit2.db.update.dataset.DeleteDataset)1 UpdateExecutor (net.idea.modbcum.p.UpdateExecutor)1