Search in sources :

Example 1 with SourceEventCommand

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;
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) Table(org.teiid.metadata.Table) DQPCore(org.teiid.dqp.internal.process.DQPCore) TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) TeiidComponentException(org.teiid.core.TeiidComponentException) TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) SourceEventCommand(org.teiid.query.optimizer.SourceTriggerActionPlanner.SourceEventCommand) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData)

Aggregations

VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)1 TeiidComponentException (org.teiid.core.TeiidComponentException)1 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)1 DQPCore (org.teiid.dqp.internal.process.DQPCore)1 Table (org.teiid.metadata.Table)1 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)1 SourceEventCommand (org.teiid.query.optimizer.SourceTriggerActionPlanner.SourceEventCommand)1