use of org.teiid.translator.salesforce.execution.visitors.JoinQueryVisitor in project teiid by teiid.
the class QueryExecutionImpl method getObjectData.
private List<Object[]> getObjectData(SObject sObject) throws TranslatorException {
Iterator<XmlObject> topFields = sObject.getChildren();
ArrayList<XmlObject> children = new ArrayList<XmlObject>();
while (topFields.hasNext()) {
children.add(topFields.next());
}
logAndMapFields(sObject.getType(), children);
List<Object[]> result = new ArrayList<Object[]>();
if (visitor instanceof JoinQueryVisitor) {
for (int i = 0; i < children.size(); i++) {
XmlObject element = children.get(i);
extactJoinResults(element, result);
}
}
return extractDataFromFields(sObject, children, result);
}
use of org.teiid.translator.salesforce.execution.visitors.JoinQueryVisitor in project teiid by teiid.
the class QueryExecutionImpl method execute.
@Override
public void execute() throws TranslatorException {
try {
// redundant with command log
// $NON-NLS-1$
LogManager.logDetail(LogConstants.CTX_CONNECTOR, getLogPreamble(), "Incoming Query:", query);
List<TableReference> from = ((Select) query).getFrom();
boolean join = false;
if (from.get(0) instanceof Join) {
join = true;
visitor = new JoinQueryVisitor(metadata);
} else {
visitor = new SelectVisitor(metadata);
}
visitor.visitNode(query);
if (visitor.canRetrieve()) {
// $NON-NLS-1$
context.logCommand("Using retrieve: ", visitor.getRetrieveFieldList(), visitor.getTableName(), visitor.getIdInCriteria());
results = this.executionFactory.buildQueryResult(connection.retrieve(visitor.getRetrieveFieldList(), visitor.getTableName(), visitor.getIdInCriteria()));
} else {
String finalQuery = visitor.getQuery().trim();
// redundant
// $NON-NLS-1$
LogManager.logDetail(LogConstants.CTX_CONNECTOR, getLogPreamble(), "Executing Query:", finalQuery);
context.logCommand(finalQuery);
if (!join && !visitor.getQueryAll() && (context.getSourceHints() != null && context.getSourceHints().contains("bulk"))) {
// $NON-NLS-1$
BulkValidator bulkValidator = new BulkValidator();
query.acceptVisitor(bulkValidator);
if (bulkValidator.isBulkEligible()) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
LogManager.logDetail(LogConstants.CTX_CONNECTOR, getLogPreamble(), "Using bulk logic", bulkValidator.usePkChunking() ? "with" : "without", "pk chunking");
this.activeJob = connection.createBulkJob(visitor.getTableName(), OperationEnum.query, bulkValidator.usePkChunking());
batchInfo = connection.addBatch(finalQuery, this.activeJob);
return;
}
// $NON-NLS-1$
LogManager.logDetail(LogConstants.CTX_CONNECTOR, getLogPreamble(), "Ingoring bulk hint as the query is not bulk eligible");
}
results = connection.query(finalQuery, this.context.getBatchSize(), visitor.getQueryAll());
}
} catch (ResourceException e) {
throw new TranslatorException(e);
}
}
Aggregations