use of org.teiid.core.TeiidException in project teiid by teiid.
the class BaseQueryExecution method buildRow.
@SuppressWarnings("unchecked")
<T extends AbstractMetadataRecord> List<?> buildRow(T record, List<Column> columns, Class<?>[] expectedType, Map<String, Object> values) throws TranslatorException {
List<Object> results = new ArrayList<Object>();
for (int i = 0; i < columns.size(); i++) {
Column column = columns.get(i);
T columnParent = (T) column.getParent();
String colName = column.getName();
if (!columnParent.equals(record)) {
// $NON-NLS-1$
colName = getName(columnParent) + "/" + column.getName();
}
Object value;
try {
value = ODataTypeManager.convertToTeiidRuntimeType(expectedType[i], values.get(colName), ODataMetadataProcessor.getNativeType(column));
} catch (TeiidException e) {
throw new TranslatorException(e);
}
results.add(value);
}
return results;
}
use of org.teiid.core.TeiidException in project teiid by teiid.
the class ReflectionHelper method create.
public static final Object create(String className, Object[] ctorObjs, Class<?>[] argTypes, final ClassLoader classLoader) throws TeiidException {
Class<?> cls;
try {
cls = loadClass(className, classLoader);
} catch (Exception e) {
throw new TeiidException(CorePlugin.Event.TEIID10034, e);
}
Constructor<?> ctor = null;
try {
ctor = cls.getDeclaredConstructor(argTypes);
} catch (NoSuchMethodException e) {
}
if (ctor == null && argTypes != null && argTypes.length > 0) {
List<Class<?>> argumentsClasses = Arrays.asList(argTypes);
List<Class<?>> argumentsClassList = convertArgumentClassesToPrimitives(argumentsClasses);
for (Constructor<?> possible : cls.getDeclaredConstructors()) {
if (argsMatch(argumentsClasses, argumentsClassList, possible.getParameterTypes())) {
ctor = possible;
break;
}
}
}
if (ctor == null) {
throw new TeiidException(CorePlugin.Event.TEIID10035, className + CorePlugin.Event.TEIID10035 + Arrays.toString(argTypes));
}
try {
return ctor.newInstance(ctorObjs);
} catch (InvocationTargetException e) {
throw new TeiidException(CorePlugin.Event.TEIID10036, e.getTargetException());
} catch (Exception e) {
throw new TeiidException(CorePlugin.Event.TEIID10036, e);
}
}
use of org.teiid.core.TeiidException in project teiid by teiid.
the class JDBCExecutionFactory method getDialect.
public SQLDialect getDialect() {
if (dialect == null) {
String name = getHibernateDialectClassName();
if (name != null) {
try {
Object impl = ReflectionHelper.create(name, null, this.getClass().getClassLoader());
InvocationHandler handler = new MixinProxy(new Object[] { impl });
this.dialect = (SQLDialect) Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class<?>[] { SQLDialect.class }, handler);
} catch (TeiidException e) {
// $NON-NLS-1$
LogManager.logDetail(LogConstants.CTX_CONNECTOR, e, name, "could not be loaded");
}
}
if (dialect == null) {
dialect = new DefaultSQLDialect();
}
}
return dialect;
}
use of org.teiid.core.TeiidException in project teiid by teiid.
the class QueryProcessor method nextBatchDirect.
private TupleBatch nextBatchDirect() throws BlockedException, TeiidProcessingException, TeiidComponentException {
boolean done = false;
TupleBatch result = null;
try {
init();
long currentTime = System.currentTimeMillis();
Assertion.assertTrue(!processorClosed);
while (currentTime < context.getTimeSliceEnd() || context.isNonBlocking()) {
if (requestCanceled) {
throw new TeiidProcessingException(QueryPlugin.Event.TEIID30160, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30160, this.context.getRequestId()));
}
if (currentTime > context.getTimeoutEnd()) {
throw new TeiidProcessingException(QueryPlugin.Event.TEIID30161, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30161));
}
result = processPlan.nextBatch();
if (continuous) {
result.setRowOffset(rowOffset);
if (result.getTerminationFlag()) {
result.setTermination(TupleBatch.ITERATION_TERMINATED);
List<Object> terminationTuple = Arrays.asList(new Object[this.getOutputElements().size()]);
result.getTuples().add(terminationTuple);
this.context.getTupleSourceCache().close();
this.processPlan.close();
this.processPlan.reset();
this.context.incrementReuseCount();
this.open = false;
}
rowOffset = result.getEndRow() + 1;
}
if (result.getTermination() != TupleBatch.NOT_TERMINATED) {
if (result.getTerminationFlag()) {
done = true;
}
break;
}
if (result.getRowCount() > 0) {
break;
}
}
} catch (BlockedException e) {
throw e;
} catch (TeiidException e) {
closeProcessing();
if (e instanceof TeiidProcessingException) {
throw (TeiidProcessingException) e;
}
if (e instanceof TeiidComponentException) {
throw (TeiidComponentException) e;
}
throw new TeiidComponentException(QueryPlugin.Event.TEIID30162, e);
}
if (done) {
closeProcessing();
}
if (result == null) {
RequestWorkItem workItem = this.getContext().getWorkItem();
if (workItem != null) {
// if we have a workitem (non-test scenario) then before
// throwing exprired time slice we need to indicate there's more work
workItem.moreWork();
}
throw EXPIRED_TIME_SLICE;
}
return result;
}
use of org.teiid.core.TeiidException in project teiid by teiid.
the class TestUpdateValidator method helpTest.
private UpdateValidator helpTest(String sql, TransformationMetadata md, boolean failInsert, boolean failUpdate, boolean failDelete) {
try {
String vGroup = "gx";
Command command = createView(sql, md, vGroup);
UpdateValidator uv = new UpdateValidator(md, UpdateType.INHERENT, UpdateType.INHERENT, UpdateType.INHERENT);
GroupSymbol gs = new GroupSymbol(vGroup);
ResolverUtil.resolveGroup(gs, md);
uv.validate(command, ResolverUtil.resolveElementsInGroup(gs, md));
UpdateInfo info = uv.getUpdateInfo();
assertEquals(uv.getReport().getFailureMessage(), failInsert, info.getInsertValidationError() != null);
assertEquals(uv.getReport().getFailureMessage(), failUpdate, info.getUpdateValidationError() != null);
assertEquals(uv.getReport().getFailureMessage(), failDelete, info.getDeleteValidationError() != null);
return uv;
} catch (TeiidException e) {
throw new RuntimeException(e);
}
}
Aggregations