protected JDBCBaseExecution(Command command, Connection connection, ExecutionContext context, JDBCExecutionFactory jef) { this.connection = connection; this.context = context; this.executionFactory = jef; trimString = jef.isTrimStrings(); fetchSize = context.getBatchSize(); this.command = command; }
public void addStatementWarnings() throws SQLException { SQLWarning warning = this.statement.getWarnings(); if (warning != null) { context.addWarning(warning); if (LogManager.isMessageToBeRecorded(LogConstants.CTX_CONNECTOR, MessageLevel.DETAIL)) { while (warning != null) { LogManager.logDetail(LogConstants.CTX_CONNECTOR, context.getRequestId() + " Warning: ", warning); //$NON-NLS-1$ warning = warning.getNextWarning(); } } } this.statement.clearWarnings(); } }
public FakeExecutionContextImpl(ExecutionContext c) { super(c.getVdbName(), c.getVdbVersion(), c.getCommandPayload(), c .getConnectionId(), c.getConnectorIdentifier(), Long.valueOf(c .getRequestId()), c.getPartIdentifier(), c .getExecutionCountIdentifier()); }
public QueryExecutionImpl(QueryExpression command, SalesforceConnection connection, RuntimeMetadata metadata, ExecutionContext context, SalesForceExecutionFactory salesForceExecutionFactory) { this.connection = connection; this.metadata = metadata; this.context = context; this.query = command; this.executionFactory = salesForceExecutionFactory; connectionIdentifier = context.getConnectionId(); connectorIdentifier = context.getConnectorIdentifier(); requestIdentifier = context.getRequestId(); partIdentifier = context.getPartIdentifier(); }
/** * Returns the source comment for the given command * @param context * @param command * @return the comment */ public String getSourceComment(ExecutionContext context, Command command) { if (addSourceComment() && context != null) { return comment.get().format(new Object[] {context.getConnectionId(), context.getRequestId(), context.getPartIdentifier(), context.getExecutionCountIdentifier(), context.getSession().getUserName(), context.getVdbName(), context.getVdbVersion(), context.isTransactional() }); } return ""; //$NON-NLS-1$ }
public boolean equals(Object obj) { if(obj == this) { return true; } if(! (obj instanceof ExecutionContext)) { return false; } ExecutionContext other = (ExecutionContext) obj; return EquivalenceUtil.areEqual(this.getRequestId(), other.getRequestId()) && EquivalenceUtil.areEqual(this.getPartIdentifier(), other.getPartIdentifier()); }
@Override public int[] getUpdateCounts() throws DataNotAvailableException, TranslatorException { if (this.visitor.getMethod().equals("DELETE")) { //$NON-NLS-1$ //DELETE return (this.response != null)?new int[]{1}:new int[]{0}; } else if(this.visitor.getMethod().equals("PUT")) { //$NON-NLS-1$ // UPDATE; // conflicting implementation found where some sent 200 with content; other with 204 no-content return (this.response != null)?new int[]{1}:new int[]{0}; } else if (this.visitor.getMethod().equals("POST")) { //$NON-NLS-1$ //INSERT if (this.response != null && this.response.hasRow()) { if (this.executionContext.getCommandContext().isReturnAutoGeneratedKeys()) { addAutoGeneretedKeys(); } return new int[]{1}; } } return new int[] {0}; }
AggregationOptions options = this.executionFactory.getOptions(this.executionContext.getBatchSize()); if (this.executionContext.getCommandContext().isReturnAutoGeneratedKeys()) { addAutoGeneretedKeys(executionResults.get(0));
Class<?>[] keyColumnDataTypes = null; String[] keyColumnNames = null; if (command instanceof Insert && context.getCommandContext().isReturnAutoGeneratedKeys() && executionFactory.supportsGeneratedKeys(context, command)) { Insert insert = (Insert)command; NamedTable nt = insert.getTable(); try { ResultSet keys = statement.getGeneratedKeys(); GeneratedKeys generatedKeys = context.getCommandContext().returnGeneratedKeys(keyColumnNames, keyColumnDataTypes); context.addWarning(e); LogManager.logDetail(LogConstants.CTX_CONNECTOR, e, "Exception determining generated keys, no keys will be returned"); //$NON-NLS-1$
context.logCommand("Using retrieve: ", visitor.getRetrieveFieldList(), visitor.getTableName(), visitor.getIdInCriteria()); //$NON-NLS-1$ results = this.executionFactory.buildQueryResult(connection.retrieve(visitor.getRetrieveFieldList(), visitor.getTableName(), visitor.getIdInCriteria())); context.logCommand(finalQuery); && (context.getSourceHints() != null && context.getSourceHints().contains("bulk"))) { //$NON-NLS-1$ BulkValidator bulkValidator = new BulkValidator(); query.acceptVisitor(bulkValidator); results = connection.query(finalQuery, this.context.getBatchSize(), visitor.getQueryAll());
if (context != null) { Object payload = context.getCommandPayload(); if (payload instanceof String) { String payloadString = (String)payload; } else { String msg = JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID11003, "Execution Payload", payloadString); //$NON-NLS-1$ context.addWarning(new TranslatorException(msg)); LogManager.logWarning(LogConstants.CTX_CONNECTOR, msg); String hint = context.getSourceHint(); if (context.getGeneralHint() != null) { if (hint != null) { hint += (" " + context.getGeneralHint()); //$NON-NLS-1$ } else { hint = context.getGeneralHint(); } else { String msg = JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID11003, "Source Hint", hint); //$NON-NLS-1$ context.addWarning(new TranslatorException(msg)); LogManager.logWarning(LogConstants.CTX_CONNECTOR, msg);
@Override public void execute() throws TranslatorException { ec.addWarning(new Exception("Some warning")); //$NON-NLS-1$ } @Override
public String toString() { if (!source) { if (event == Event.NEW) { return "\tSTART USER COMMAND:\tstartTime=" + new Timestamp(timestamp) + "\trequestID=" + requestID + "\ttxID=" + transactionID + "\tsessionID=" + sessionID + "\tapplicationName=" + applicationName + "\tprincipal=" + principal + "\tvdbName=" + vdbName + "\tvdbVersion=" + vdbVersion + "\tsql=" + sql; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ } return "\t"+ event +" USER COMMAND:\tendTime=" + new Timestamp(timestamp) + "\trequestID=" + requestID + "\ttxID=" + transactionID + "\tsessionID=" + sessionID + "\tprincipal=" + principal + "\tvdbName=" + vdbName + "\tvdbVersion=" + vdbVersion + "\tfinalRowCount=" + rowCount+ ((plan!=null)?"\tplan=" + plan.toYaml():"") + ((cpuTime!=null)?"\tcpuTime(ns)=" + cpuTime:""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ } if (event == Event.NEW) { return "\tSTART DATA SRC COMMAND:\tstartTime=" + new Timestamp(timestamp) + "\trequestID=" + requestID + "\tsourceCommandID="+ sourceCommandID + "\texecutionID="+ executionContext.getExecutionCountIdentifier() + "\ttxID=" + transactionID + "\tmodelName="+ modelName + "\ttranslatorName=" + translatorName + "\tsessionID=" + sessionID + "\tprincipal=" + principal + "\tsql=" + sql; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ } return "\t"+ event +" SRC COMMAND:\tendTime=" + new Timestamp(timestamp) + "\trequestID=" + requestID + "\tsourceCommandID="+ sourceCommandID + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ "\texecutionID="+ executionContext.getExecutionCountIdentifier() + "\ttxID=" + transactionID + "\tmodelName="+ modelName + "\ttranslatorName=" + translatorName + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ "\tsessionID=" + sessionID + "\tprincipal=" + principal + ((sourceCommand != null)?"\tsourceCommand=" + StringUtil.toString(sourceCommand, " "):"") + ((rowCount != null)?"\tfinalRowCount=" + rowCount:"") + ((cpuTime!=null)?"\tcpuTime(ns)=" + cpuTime:""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ }
protected void setSizeContraints(Statement statement) { try { executionFactory.setFetchSize(command, context, statement, fetchSize); } catch (SQLException e) { if (LogManager.isMessageToBeRecorded(LogConstants.CTX_CONNECTOR, MessageLevel.DETAIL)) { LogManager.logDetail(LogConstants.CTX_CONNECTOR, context.getRequestId(), " could not set fetch size: ", fetchSize); //$NON-NLS-1$ } } }
public boolean equals(Object obj) { if(obj == this) { return true; } if(! (obj instanceof ExecutionContext)) { return false; } ExecutionContext other = (ExecutionContext) obj; return EquivalenceUtil.areEqual(this.getRequestId(), other.getRequestId()) && EquivalenceUtil.areEqual(this.getPartIdentifier(), other.getPartIdentifier()); }
@Override public int[] getUpdateCounts() throws DataNotAvailableException, TranslatorException { if (this.visitor.getOperationType() == OperationType.DELETE) { return new int[]{this.updateCount.get()}; } else if(this.visitor.getOperationType() == OperationType.UPDATE) { return new int[]{this.updateCount.get()}; } else if (this.visitor.getOperationType() == OperationType.INSERT) { if (this.createdEntity != null) { if (this.executionContext.getCommandContext().isReturnAutoGeneratedKeys()) { addAutoGeneretedKeys(this.visitor.getODataQuery().getRootDocument().getTable(), this.createdEntity); } } return new int[]{1}; } return new int[] {0}; }
throw te; this.executionContext.addWarning(te); LogManager.logWarning(LogConstants.CTX_CONNECTOR, e, msg);
public CommandEnitity(CommandLogMessage msg) { this.time = new Timestamp(msg.getTimestamp()); this.eventType = msg.getStatus().name(); this.sessionId = msg.getSessionID(); this.requestId = msg.getRequestID(); this.vdbName = msg.getVdbName(); this.vdbVersion = msg.getVdbVersion(); this.applicationName = msg.getApplicationName(); this.transactionId = msg.getTransactionID(); this.principal = msg.getPrincipal(); this.sourceCommandId = msg.getSourceCommandID(); this.sourceCommand = msg.isSource(); if (msg.getExecutionContext() != null) { this.executionId = msg.getExecutionContext().getExecutionCountIdentifier(); } this.modelName = msg.getModelName(); this.translatorName = msg.getTranslatorName(); this.sql = msg.getSql(); this.rowCount = msg.getRowCount(); if ((msg.getPlan() != null && msg.getStatus() == Event.PLAN)) { try { this.queryplan = new SerialBlob(msg.getPlan().toString().getBytes()); } catch (SerialException e) { //ignore } catch (SQLException e) { //ignore } } }
private void doSelect(String select) throws TranslatorException { this.results = this.connection.query(select, this.context.getBatchSize(), Boolean.FALSE); }
public boolean equals(Object obj) { if(obj == this) { return true; } if(! (obj instanceof ExecutionContext)) { return false; } ExecutionContext other = (ExecutionContext) obj; return EquivalenceUtil.areEqual(this.getRequestId(), other.getRequestId()) && EquivalenceUtil.areEqual(this.getPartIdentifier(), other.getPartIdentifier()); }