Exemplo n.º 1
0
  /**
   * Transforms the request into its ebXML representation.
   *
   * @param request the request. Can be <code>null</code>.
   * @return the ebXML representation. <code>null</code> if the input was <code>null</code>.
   */
  public EbXMLAdhocQueryRequest toEbXML(QueryRegistry request) {
    if (request == null) {
      return null;
    }

    Query query = request.getQuery();
    EbXMLAdhocQueryRequest ebXML = createAdhocQueryRequest(query);
    query.accept(new ToEbXMLVisitor(ebXML));

    ebXML.setReturnType(request.getReturnType().getCode());

    return ebXML;
  }
Exemplo n.º 2
0
  /**
   * Transforms the ebXML representation into a request.
   *
   * @param ebXML the ebXML representation. Can be <code>null</code>.
   * @return the request. <code>null</code> if the input was <code>null</code>.
   */
  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;
  }