use of net.idea.modbcum.p.UpdateExecutor 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 net.idea.modbcum.p.UpdateExecutor in project ambit-mirror by ideaconsult.
the class AmbitDBQueryResource method execUpdate.
protected void execUpdate(Object object, IQueryUpdate query) throws ResourceException {
Connection conn = null;
UpdateExecutor x = null;
try {
DBConnection dbc = new DBConnection(getApplication().getContext(), getConfigFile());
conn = dbc.getConnection(30, true, 8);
x = new UpdateExecutor();
x.setConnection(conn);
x.process(query);
} catch (Exception e) {
throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, e.getMessage(), e);
} finally {
try {
if (conn != null)
conn.close();
} catch (Exception xx) {
}
try {
if (x != null)
x.close();
} catch (Exception xx) {
}
}
}
use of net.idea.modbcum.p.UpdateExecutor in project ambit-mirror by ideaconsult.
the class RegistrationConfirmResource method getRepresentation.
@Override
protected Representation getRepresentation(Variant variant) throws ResourceException {
if (MediaType.APPLICATION_JSON.equals(variant.getMediaType())) {
Connection conn = null;
UpdateExecutor exec = null;
Object code = getRequest().getResourceRef().getQueryAsForm().getFirstValue(confirmationCode);
if (code != null)
try {
String usersdbname = getContext().getParameters().getFirstValue(AMBITConfig.users_dbname.name());
if (usersdbname == null)
usersdbname = getDefaultUsersDB();
UserURIReporter reporter = new UserURIReporter(getRequest(), "");
DBConnection dbc = new DBConnection(getApplication().getContext(), getConfigFile());
conn = dbc.getConnection();
UserRegistration reg = new UserRegistration(code.toString());
reg.setTitle("Confirm reset");
ConfirmRegistration q = new ConfirmRegistration(reg);
q.setDatabaseName(usersdbname);
exec = new UpdateExecutor();
exec.setConnection(conn);
exec.process(q);
} catch (Exception x) {
try {
if (conn != null) {
conn.close();
conn = null;
}
} catch (Exception xx) {
}
throw new ResourceException(Status.SERVER_ERROR_INTERNAL, x);
} finally {
try {
exec.close();
} catch (Exception x) {
}
try {
if (conn != null)
conn.close();
} catch (Exception x) {
}
}
}
return super.getRepresentation(variant);
}
use of net.idea.modbcum.p.UpdateExecutor in project ambit-mirror by ideaconsult.
the class RoleDBResource method execUpdate.
protected void execUpdate(IQueryUpdate query) throws ResourceException {
Connection conn = null;
UpdateExecutor x = null;
try {
DBConnection dbc = new DBConnection(getApplication().getContext(), getConfigFile());
conn = dbc.getConnection();
x = new UpdateExecutor();
x.setConnection(conn);
x.process(query);
} catch (Exception e) {
throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, e.getMessage(), e);
} finally {
try {
if (conn != null)
conn.close();
} catch (Exception xx) {
}
try {
if (x != null)
x.close();
} catch (Exception xx) {
}
}
}
Aggregations