<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<vdb name="twitter" version="1">

    <description>Shows how to call Web Services</description>
    
    <property name="UseConnectorMetadata" value="cached" />

    <model name="twitter">
        <source name="twitter" translator-name="rest" connection-jndi-name="java:/twitterDS"/>
    </model>
    <model name="twitterview" type="VIRTUAL">
         <metadata type="DDL"><![CDATA[
             CREATE VIRTUAL PROCEDURE getTweets(query varchar) RETURNS (created_on varchar(25), from_user varchar(25), to_user varchar(25), 
                 profile_image_url varchar(25), source varchar(25), text varchar(140)) AS 
                select tweet.* from 
                    (call twitter.invokeHTTP(action => 'GET', endpoint =>querystring('',query as "q"))) w, 
                    XMLTABLE('results' passing JSONTOXML('myxml', w.result) columns 
                    created_on string PATH 'created_at', 
                    from_user string PATH 'from_user',
                    to_user string PATH 'to_user',  
                    profile_image_url string PATH 'profile_image_url',  
                    source string PATH 'source',    
                    text string PATH 'text') tweet;
                CREATE VIEW Tweet AS select * FROM twitterview.getTweets;
        ]]> </metadata>
    </model>

    <translator name="rest" type="ws">
        <property name="DefaultBinding" value="HTTP"/>
        <property name="DefaultServiceMode" value="MESSAGE"/>
    </translator>
</vdb>