本文整理汇总了Java中org.teiid.translator.TranslatorException类的典型用法代码示例。如果您正苦于以下问题:Java TranslatorException类的具体用法?Java TranslatorException怎么用?Java TranslatorException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TranslatorException类属于org.teiid.translator包,在下文中一共展示了TranslatorException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadMetadata
import org.teiid.translator.TranslatorException; //导入依赖的package包/类
@Override
public void loadMetadata(MetadataFactory factory, ExecutionFactory executionFactory, Object connectionFactory) throws TranslatorException {
if (executionFactory != null && executionFactory.supportsDirectQueryProcedure()) {
Procedure p = factory.addProcedure(executionFactory.getDirectQueryProcedureName());
p.setAnnotation("Invokes translator with a native query that returns results in an array of values"); //$NON-NLS-1$
ProcedureParameter param = factory.addProcedureParameter("request", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$
param.setAnnotation("The native query to execute"); //$NON-NLS-1$
param.setNullType(NullType.No_Nulls);
param = factory.addProcedureParameter("variable", TypeFacility.RUNTIME_NAMES.OBJECT, Type.In, p); //$NON-NLS-1$
param.setAnnotation("Any number of varaibles; usage will vary by translator"); //$NON-NLS-1$
param.setNullType(NullType.Nullable);
param.setVarArg(true);
factory.addProcedureResultSetColumn("tuple", DataTypeManager.getDataTypeName(DataTypeManager.getArrayType(TypeFacility.RUNTIME_TYPES.OBJECT)), p); //$NON-NLS-1$
}
}
示例2: getForeignKeyNIS
import org.teiid.translator.TranslatorException; //导入依赖的package包/类
private String getForeignKeyNIS(NamedTable table, ForeignKey fk) throws TranslatorException {
String fkeyColNIS = null;
if (fk != null) {
if (fk.getReferenceKey() != null) {
Column fkeyCol = fk.getReferenceKey().getColumns().get(0);
fkeyColNIS = fkeyCol.getSourceName();
} else if (fk.getReferenceColumns() != null) {
fkeyColNIS = fk.getReferenceColumns().get(0);
}
}
return fkeyColNIS;
}
示例3: exceptionOccurred
import org.teiid.translator.TranslatorException; //导入依赖的package包/类
AtomicResultsMessage exceptionOccurred(TranslatorException exception) throws TeiidComponentException, TeiidProcessingException {
if(workItem.requestMsg.supportsPartialResults()) {
AtomicResultsMessage emptyResults = new AtomicResultsMessage(new List[0]);
emptyResults.setWarnings(Arrays.asList((Exception)exception));
emptyResults.setFinalRow(this.rowsProcessed);
return emptyResults;
}
fullyCloseSource();
if (exception.getCause() instanceof TeiidComponentException) {
throw (TeiidComponentException)exception.getCause();
}
if (exception.getCause() instanceof TeiidProcessingException) {
throw (TeiidProcessingException)exception.getCause();
}
throw new TeiidProcessingException(QueryPlugin.Event.TEIID30504, exception, this.getConnectorName() + ": " + exception.getMessage()); //$NON-NLS-1$
}
示例4: execute
import org.teiid.translator.TranslatorException; //导入依赖的package包/类
@Override
public void execute() throws TranslatorException {
if (command instanceof BatchedUpdates) {
BatchedUpdates updates = (BatchedUpdates)this.command;
this.results = new int[updates.getUpdateCommands().size()];
int index = 0;
for (Command cmd:updates.getUpdateCommands()) {
this.results[index++] = executeUpdate(cmd);
}
}
else if (this.command instanceof Insert) {
this.results = new int[1];
Object entity = handleInsert((Insert)this.command);
this.enityManager.merge(entity);
this.results[0] = 1;
}
else {
// update or delete
this.results = new int[1];
this.results[0] = executeUpdate(this.command);
}
}
示例5: next
import org.teiid.translator.TranslatorException; //导入依赖的package包/类
@Override
public List<Object> next() throws TranslatorException,
DataNotAvailableException {
// create and return one row at a time for your resultset.
if (resultsIt.hasNext()) {
List<Object> r = new ArrayList<Object>(projects.size());
Object o = resultsIt.next();
sc.setAttribute(OBJECT_NAME, o, ScriptContext.ENGINE_SCOPE);
for (CompiledScript cs : this.projects) {
if (cs == null) {
r.add(o);
continue;
}
try {
r.add(cs.eval(sc));
} catch (ScriptException e) {
throw new TranslatorException(e);
}
}
return r;
}
return null;
}
示例6: execute
import org.teiid.translator.TranslatorException; //导入依赖的package包/类
@Override
public void execute() throws TranslatorException {
String path = (String)command.getArguments().get(0).getArgumentValue().getValue();
try {
files = FileConnection.Util.getFiles(path, fc, exceptionIfFileNotFound);
} catch (ResourceException e) {
throw new TranslatorException(e);
}
LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Getting", files != null ? files.length : 0, "file(s)"); //$NON-NLS-1$ //$NON-NLS-2$
String name = command.getProcedureName();
if (name.equalsIgnoreCase(GETTEXTFILES)) {
isText = true;
} else if (!name.equalsIgnoreCase(GETFILES)) {
throw new TeiidRuntimeException("Unknown procedure name " + name); //$NON-NLS-1$
}
}
示例7: testSelectOrderBy
import org.teiid.translator.TranslatorException; //导入依赖的package包/类
@Test
public void testSelectOrderBy() throws TranslatorException {
String sql = "SELECT * FROM Customer ORDER BY PK";
String expected = "SELECT \"Customer\".ROW_ID, \"Customer\".\"city\", \"Customer\".\"name\", \"Customer\".\"amount\", \"Customer\".\"product\" FROM \"Customer\" ORDER BY \"Customer\".ROW_ID";
helpTest(sql, expected);
sql = "SELECT * FROM Customer ORDER BY PK ASC";
expected = "SELECT \"Customer\".ROW_ID, \"Customer\".\"city\", \"Customer\".\"name\", \"Customer\".\"amount\", \"Customer\".\"product\" FROM \"Customer\" ORDER BY \"Customer\".ROW_ID";
helpTest(sql, expected);
sql = "SELECT * FROM Customer ORDER BY PK DESC";
expected = "SELECT \"Customer\".ROW_ID, \"Customer\".\"city\", \"Customer\".\"name\", \"Customer\".\"amount\", \"Customer\".\"product\" FROM \"Customer\" ORDER BY \"Customer\".ROW_ID DESC";
helpTest(sql, expected);
sql = "SELECT * FROM Customer ORDER BY name, city DESC";
expected = "SELECT \"Customer\".ROW_ID, \"Customer\".\"city\", \"Customer\".\"name\", \"Customer\".\"amount\", \"Customer\".\"product\" FROM \"Customer\" ORDER BY \"Customer\".\"name\", \"Customer\".\"city\" DESC";
helpTest(sql, expected);
}
示例8: init
import org.teiid.translator.TranslatorException; //导入依赖的package包/类
@BeforeClass
public static void init() throws VirtualDatabaseException, ConnectorManagerException, TranslatorException, FileNotFoundException, IOException, ResourceException, SQLException {
server = new EmbeddedServer();
FileExecutionFactory executionFactory = new FileExecutionFactory();
server.addTranslator("file", executionFactory);
FileManagedConnectionFactory fileManagedconnectionFactory = new FileManagedConnectionFactory();
fileManagedconnectionFactory.setParentDirectory(UnitTestUtil.getTestDataPath()+File.separator+"file");
ConnectionFactory connectionFactory = fileManagedconnectionFactory.createConnectionFactory();
ConnectionFactoryProvider<ConnectionFactory> connectionFactoryProvider = new EmbeddedServer.SimpleConnectionFactoryProvider<ConnectionFactory>(connectionFactory);
server.addConnectionFactoryProvider("java:/marketdata-file", connectionFactoryProvider);
EmbeddedConfiguration config = new EmbeddedConfiguration();
server.start(config);
DriverManager.registerDriver(server.getDriver());
server.deployVDB(new FileInputStream(UnitTestUtil.getTestDataFile("vdb"+File.separator+"marketdata-vdb.xml")));
factory = Persistence.createEntityManagerFactory("org.teiid.eclipselink.test");
}
示例9: visit
import org.teiid.translator.TranslatorException; //导入依赖的package包/类
@Override
public void visit(Update update) {
// don't visit the changes or they will be in the query.
visitNode(update.getTable());
visitNode(update.getWhere());
try {
loadColumnMetadata(update.getTable());
} catch (TranslatorException ce) {
exceptions.add(ce);
}
}
示例10: WSDLMetadataProcessor
import org.teiid.translator.TranslatorException; //导入依赖的package包/类
public WSDLMetadataProcessor(String wsdl) throws TranslatorException {
try {
WSDLFactory wsdlFactory = WSDLFactory.newInstance();
WSDLReader reader = wsdlFactory.newWSDLReader();
this.definition = reader.readWSDL(wsdl);
} catch (WSDLException e) {
throw new TranslatorException(e);
}
}
示例11: pkExistsInParent
import org.teiid.translator.TranslatorException; //导入依赖的package包/类
public boolean pkExistsInParent(MongoDocument document) throws TranslatorException {
while(document.isMerged()) {
if (document.getMergeKey().getAssociation() == Association.ONE) {
document = document.getMergeDocument();
}
else {
return false;
}
}
return true;
}
示例12: getMetadata
import org.teiid.translator.TranslatorException; //导入依赖的package包/类
@Override
public void getMetadata(MetadataFactory metadataFactory, Object conn) throws TranslatorException {
super.getMetadata(metadataFactory, conn);
metadataloaded++;
Table t = metadataFactory.addTable("Matadata");
metadataFactory.addColumn("execCount", "integer", t);
}
示例13: createExecution
import org.teiid.translator.TranslatorException; //导入依赖的package包/类
@Override
public Execution createExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connection)
throws TranslatorException {
if (command.toString().equals("SELECT g_0.execCount FROM Matadata AS g_0")) { //$NON-NLS-1$
return new ResultSetExecution() {
boolean served = false;
@Override
public void execute() throws TranslatorException {
}
@Override
public void close() {
}
@Override
public void cancel() throws TranslatorException {
}
@Override
public List<?> next() throws TranslatorException, DataNotAvailableException {
if (!served) {
served = true;
return Arrays.asList(metadataloaded);
}
return null;
}
};
}
return new LoopbackExecution(command, this);
}
示例14: convertFromExcelType
import org.teiid.translator.TranslatorException; //导入依赖的package包/类
static Object convertFromExcelType(final Boolean value, final Class<?> expectedType) throws TranslatorException {
if (value == null) {
return null;
}
if (expectedType.isAssignableFrom(Boolean.class)) {
return value;
}
throw new TranslatorException(ExcelPlugin.Event.TEIID23001, ExcelPlugin.Util.gs(ExcelPlugin.Event.TEIID23001, expectedType.getName()));
}
示例15: addColumn
import org.teiid.translator.TranslatorException; //导入依赖的package包/类
private Column addColumn(String name, Class<?> type, Table table, MetadataFactory mf) throws TranslatorException {
if (type == null) {
throw new TranslatorException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31086, name, table.getFullName()));
}
Column column = mf.addColumn(name, DataTypeManager.getDataTypeName(type), table);
column.setUpdatable(table.supportsUpdate());
return column;
}