use of org.teiid.query.optimizer.SourceTriggerActionPlanner.SourceEventCommand in project teiid by teiid.
the class EventDistributorImpl method dataModification.
@Override
public ResultsFuture<?> dataModification(String vdbName, String vdbVersion, String schema, String tableName, Object[] oldValues, Object[] newValues, String[] columnNames) {
VDBMetaData vdb = getVdbRepository().getLiveVDB(vdbName, vdbVersion);
if (vdb == null) {
return null;
}
TransformationMetadata tm = vdb.getAttachment(TransformationMetadata.class);
if (tm == null) {
return null;
}
// lookup, call triggers
Table t = getTable(vdbName, vdbVersion, schema, tableName);
if (t == null) {
return null;
}
// notify of just the table modification
dataModification(vdbName, vdbVersion, schema, tableName);
if (oldValues == null && newValues == null) {
return null;
}
if (!t.getTriggers().isEmpty()) {
if (columnNames != null) {
if ((oldValues != null && oldValues.length != columnNames.length) || (newValues != null && newValues.length != columnNames.length)) {
throw new IllegalArgumentException(RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40162));
}
} else {
if ((oldValues != null && oldValues.length != t.getColumns().size()) || (newValues != null && newValues.length != t.getColumns().size())) {
throw new IllegalArgumentException(RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40163));
}
}
// create command
SourceEventCommand sec = new SourceEventCommand(t, oldValues, newValues, columnNames);
try {
return DQPCore.executeQuery(sec, vdb, "admin", "event-distributor", -1, getDQPCore(), new // $NON-NLS-1$ //$NON-NLS-2$
DQPCore.ResultsListener() {
@Override
public void onResults(List<String> columns, List<? extends List<?>> results) throws Exception {
// no result
}
});
} catch (Throwable throwable) {
throw new TeiidRuntimeException(throwable);
}
}
return null;
}
Aggregations