logger.debug("Deserializing string [" + (String)o + "]");
try {
crosstabDefinitionJSON = new JSONObject( (String)o );
} catch(Throwable t) {
logger.debug("Object to be deserialized must be string encoding a JSON object");
throw new SerializationException("An error occurred while deserializing query: " + (String)o, t);
}
} else if(o instanceof JSONObject) {
crosstabDefinitionJSON = (JSONObject)o;
} else {
Assert.assertUnreachable("Object to be deserialized must be of type string or of type JSONObject, not of type [" + o.getClass().getName() + "]");
}
crosstabDefinition = new CrosstabDefinition();
try {
deserializeRows(crosstabDefinitionJSON, crosstabDefinition);
deserializeColumns(crosstabDefinitionJSON, crosstabDefinition);
deserializeMeasures(crosstabDefinitionJSON, crosstabDefinition);
// config (measures on rows/columns, totals/subototals on rows/columns) remains a JSONObject
JSONObject config = crosstabDefinitionJSON.optJSONObject(CrosstabSerializationConstants.CONFIG);
crosstabDefinition.setConfig(config);
JSONArray calculatedFields = crosstabDefinitionJSON.optJSONArray(CrosstabSerializationConstants.CALCULATED_FIELDS);
crosstabDefinition.setCalculatedFields(calculatedFields);
} catch (Exception e) {
throw new SerializationException("An error occurred while deserializing query: " + crosstabDefinitionJSON.toString(), e);
}
} finally {
logger.debug("OUT");
}