class QueryRegistryTransformer {

    public QueryRegistry fromEbXML(EbXMLAdhocQueryRequest ebXML) {
        if (ebXML == null) {
            return null;
        }
        
        String id = ebXML.getId();
        QueryType queryType = id == null ? QueryType.SQL : QueryType.valueOfId(id);
        if (queryType == null) {
            return null;
        }
        
        Query query = createQuery(queryType);        
        query.accept(new FromEbXMLVisitor(ebXML));
        
        QueryRegistry queryRegistry = new QueryRegistry(query);
        queryRegistry.setReturnType(QueryReturnType.valueOfCode(ebXML.getReturnType()));

        return queryRegistry;
    }

}