use of org.teiid.core.TeiidException in project teiid by teiid.
the class TestQueryRewriter method testRewriteConvertThrowsEvaluationError.
@Test
public void testRewriteConvertThrowsEvaluationError() {
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
// $NON-NLS-1$
Criteria origCrit = parseCriteria("convert('x', integer) = 0", metadata);
// rewrite
try {
QueryRewriter.rewriteCriteria(origCrit, null, metadata);
// $NON-NLS-1$
fail("Expected QueryValidatorException due to invalid string");
} catch (TeiidException e) {
// $NON-NLS-1$
assertEquals("TEIID30328 Unable to evaluate convert('x', integer): TEIID30384 Error while evaluating function convert", e.getMessage());
}
}
use of org.teiid.core.TeiidException in project teiid by teiid.
the class TestValidator method helpFailProcedure.
private void helpFailProcedure(String procedure, String userUpdateStr, Table.TriggerEvent procedureType) {
QueryMetadataInterface metadata = RealMetadataFactory.exampleUpdateProc(procedureType, procedure);
try {
validateProcedure(userUpdateStr, metadata);
fail("Expected failures for " + procedure);
} catch (QueryValidatorException e) {
} catch (TeiidException e) {
throw new RuntimeException(e);
}
}
use of org.teiid.core.TeiidException in project teiid by teiid.
the class TestDeepGroupCollectorVisitor method helpTestVisitor.
public void helpTestVisitor(String sql, String[] expectedGroups) {
LanguageObject obj = null;
try {
obj = QueryParser.getQueryParser().parseCommand(sql);
} catch (TeiidException e) {
throw new RuntimeException(e);
}
Collection actualGroups = GroupCollectorVisitor.getGroupsIgnoreInlineViews(obj, false);
// $NON-NLS-1$
assertEquals("Did not get expected number of groups", expectedGroups.length, actualGroups.size());
Iterator iter = actualGroups.iterator();
for (int i = 0; iter.hasNext(); i++) {
GroupSymbol group = (GroupSymbol) iter.next();
assertTrue(// $NON-NLS-1$ //$NON-NLS-2$
"Expected group did not match, expected=" + expectedGroups[i] + ", actual=" + group, group.getName().equalsIgnoreCase(expectedGroups[i]));
}
}
use of org.teiid.core.TeiidException in project teiid by teiid.
the class IndexMetadataRepository method loadAll.
// there are multiple threads trying to load this, since the initial index lading is not
// optimized for multi-thread loading this locking to sync will work
private synchronized void loadAll(Collection<Datatype> systemDatatypes, Map<String, ? extends VDBResource> resources) throws IOException {
if (this.loaded) {
return;
}
ArrayList<Index> tmp = new ArrayList<Index>();
for (VDBResource f : resources.values()) {
if (f.getName().endsWith(VDBResources.INDEX_EXT)) {
Index index = new Index(f);
index.setDoCache(true);
tmp.add(index);
}
}
for (Index index : tmp) {
try {
IEntryResult[] results = SimpleIndexUtil.queryIndex(new Index[] { index }, new char[0], true, true, false);
recordFactory.getMetadataRecord(results);
} catch (TeiidException e) {
throw new TeiidRuntimeException(RuntimeMetadataPlugin.Event.TEIID80000, e);
}
}
// force close, since we cached the index files
for (Index index : tmp) {
index.close();
}
Map<String, AbstractMetadataRecord> uuidToRecord = getByType(MetadataConstants.RECORD_TYPE.DATATYPE);
if (systemDatatypes != null) {
for (Datatype datatype : systemDatatypes) {
uuidToRecord.put(datatype.getUUID(), datatype);
}
}
this.loaded = true;
// associate the annotation/extension metadata
for (Map<String, AbstractMetadataRecord> map : allRecords.values()) {
for (AbstractMetadataRecord metadataRecord : map.values()) {
String uuid = metadataRecord.getUUID();
metadataRecord.setAnnotation(this.annotationCache.get(uuid));
metadataRecord.setProperties(this.extensionCache.get(uuid));
}
}
}
use of org.teiid.core.TeiidException in project teiid by teiid.
the class ODataSQLBuilder method updateStreamProperty.
public Update updateStreamProperty(EdmProperty edmProperty, final InputStream content) throws TeiidException {
Update update = new Update();
update.setGroup(this.context.getGroupSymbol());
Column column = this.context.getColumnByName(edmProperty.getName());
ElementSymbol symbol = new ElementSymbol(column.getName(), this.context.getGroupSymbol());
update.addChange(symbol, new Reference(0));
Class<?> lobType = DataTypeManager.getDataTypeClass(column.getRuntimeType());
int sqlType = JDBCSQLTypeInfo.getSQLType(column.getRuntimeType());
if (content == null) {
this.params.add(new SQLParameter(null, sqlType));
} else {
Object value = null;
InputStreamFactory isf = new InputStreamFactory() {
@Override
public InputStream getInputStream() throws IOException {
return content;
}
};
if (lobType.isAssignableFrom(SQLXML.class)) {
value = new SQLXMLImpl(isf);
} else if (lobType.isAssignableFrom(ClobType.class)) {
value = new ClobImpl(isf, -1);
} else if (lobType.isAssignableFrom(BlobType.class)) {
value = new BlobImpl(isf);
} else {
throw new TeiidException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16031, column.getName()));
}
this.params.add(new SQLParameter(value, sqlType));
}
update.setCriteria(this.context.getCriteria());
return update;
}
Aggregations