String dataSetLabel;
String mimeType;
String responseType;
JSONArray jsonArray;
IDataSet dataSet;
IDataStore dataStore;
JSONObject dataSetJSON;
String fileExtension;
String fileName;
boolean writeBackResponseInline;
logger.debug("IN");
try {
super.service(request,response);
Assert.assertNotNull(getConsoleEngineInstance(), "It's not possible to execute " + this.getActionName() + " service before having properly created an instance of EngineInstance class");
Assert.assertNotNull(getConsoleEngineInstance().getDataSetServiceProxy(), "It's not possible to execute " + this.getActionName() + " service before having properly created an instance of DatasetServiceProxy class");
dataSetLabel = getAttributeAsString( DATASET_LABEL );
logger.debug("Parameter [" + DATASET_LABEL + "] is equals to [" + dataSetLabel + "]");
Assert.assertTrue(!StringUtilities.isEmpty( dataSetLabel ), "Parameter [" + DATASET_LABEL + "] cannot be null or empty");
mimeType = getAttributeAsString( MIME_TYPE );
logger.debug("Parameter [" + MIME_TYPE + "] is equal to [" + mimeType + "]");
if(mimeType == null) {
logger.warn("Parameter [" + MIME_TYPE + "] has not been valorized");
mimeType = DEFAULT_MIME_TYPE;
logger.debug("Parameter [" + MIME_TYPE + "] has been set equal to [" + mimeType + "]");
}
responseType = getAttributeAsString( RESPONSE_TYPE );
logger.debug("Parameter [" + RESPONSE_TYPE + "] is equal to [" + responseType + "]");
if(!RESPONSE_TYPE_INLINE.equalsIgnoreCase(responseType) && !RESPONSE_TYPE_ATTACHMENT.equalsIgnoreCase(responseType)) {
logger.warn("Value [" + responseType + "] is not a valid for parameter [" + RESPONSE_TYPE + "]");
responseType = RESPONSE_TYPE_ATTACHMENT;
logger.debug("Parameter [" + RESPONSE_TYPE + "] has been set equal to [" + responseType + "]");
}
String test = getAttributeAsString(META);
logger.debug("Parameter [" + META + "] is equal to [" + test + "]");
jsonArray = this.getAttributeAsJSONArray(META);
logger.debug("Parameter [" + META + "] is equal to [" + jsonArray.toString(4) + "]");
dataSet = null;
try {
dataSet = getConsoleEngineInstance().getDataSetServiceProxy().getDataSetByLabel( dataSetLabel );
} catch(Throwable t) {
throw new SpagoBIServiceException("Impossible to find a dataset whose label is [" + dataSetLabel + "]", t);
}
Assert.assertNotNull(dataSet, "Impossible to find a dataset whose label is [" + dataSetLabel + "]");
Assert.assertNotNull(dataSet, "Impossible to find a dataset whose label is [" + dataSetLabel + "]");
Map params = getConsoleEngineInstance().getAnalyticalDrivers();
dataSet.setParamsMap(params);
dataSet.setUserProfileAttributes(UserProfileUtils.getProfileAttributes( (UserProfile) this.getEnv().get(EngineConstants.ENV_USER_PROFILE)));
dataSet.loadData();
dataStore = dataSet.getDataStore();
Assert.assertNotNull(dataStore, "The dataStore returned by loadData method of the class [" + dataSet.getClass().getName()+ "] cannot be null");
// dataStore decoration ....
Object resultNumber = dataStore.getMetaData().getProperty("resultNumber");
if(resultNumber == null) dataStore.getMetaData().setProperty("resultNumber", new Integer((int)dataStore.getRecordsCount()));