Search in sources :

Example 1 with PentahoMetadataException

use of org.pentaho.pms.core.exception.PentahoMetadataException in project data-access by pentaho.

the class MetadataService method doXmlQueryToCdaJson.

/**
 * Executes a XML query and returns a CDA compatible JSON serialization of the result set
 *
 * @param rowLimit
 * @return
 */
public String doXmlQueryToCdaJson(String xml, int rowLimit) {
    IPentahoResultSet resultSet = executeQuery(xml, rowLimit);
    if (resultSet == null) {
        return null;
    }
    String json = null;
    try {
        MetadataServiceUtil util = getMetadataServiceUtil();
        Domain domain = util.getDomainObject(xml);
        util.setDomain(domain);
        String locale = LocaleHelper.getClosestLocale(LocaleHelper.getLocale().toString(), domain.getLocaleCodes());
        json = util.createCdaJson(resultSet, locale);
    } catch (JSONException e) {
        // $NON-NLS-1$
        error(Messages.getErrorString("MetadataService.ERROR_0007_JSON_ERROR"), e);
    } catch (PentahoMetadataException e) {
        // $NON-NLS-1$
        error(Messages.getErrorString("MetadataService.ERROR_0007_BAD_QUERY_DOMAIN"), e);
    }
    return json;
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) JSONException(org.json.JSONException) Domain(org.pentaho.metadata.model.Domain) PentahoMetadataException(org.pentaho.pms.core.exception.PentahoMetadataException)

Aggregations

JSONException (org.json.JSONException)1 IPentahoResultSet (org.pentaho.commons.connection.IPentahoResultSet)1 Domain (org.pentaho.metadata.model.Domain)1 PentahoMetadataException (org.pentaho.pms.core.exception.PentahoMetadataException)1