} else {
Assert.assertUnreachable("attributes of PARAMETERS JSONObject can be only JSONArray or String");
}
}
} catch (JSONException e) {
throw new SpagoBIServiceException("parameter JSONObject is malformed", e);
}
}
// END converts JSON object with document's parameters into an hashmap
// START get the relevant biobject parameter
biObjectParameter = null;
List parameters = obj.getBiObjectParameters();
for(int i = 0; i < parameters.size(); i++) {
BIObjectParameter p = (BIObjectParameter) parameters.get(i);
if( biparameterId.equalsIgnoreCase( p.getParameterUrlName() ) ) {
biObjectParameter = p;
break;
}
}
Assert.assertNotNull(biObjectParameter, "Impossible to find parameter [" + biparameterId + "]" );
// END get the relevant biobject parameter
lovProvDet = executionInstance.getLovDetail(biObjectParameter);
// START get the lov result
String lovResult = null;
try {
// get the result of the lov
IEngUserProfile profile = getUserProfile();
// get from cache, if available
LovResultCacheManager executionCacheManager = new LovResultCacheManager();
lovResult = executionCacheManager.getLovResult(profile, biObjectParameter, executionInstance, true);
// get all the rows of the result
LovResultHandler lovResultHandler = new LovResultHandler(lovResult);
rows = lovResultHandler.getRows();
} catch (Exception e) {
throw new SpagoBIServiceException(SERVICE_NAME, "Impossible to get parameter's values", e);
}
Assert.assertNotNull(lovResult, "Impossible to get parameter's values" );
// END get the lov result
// START filtering the list by filtering toolbar
try {
if(filtersJSON != null) {
String valuefilter = (String) filtersJSON.get(SpagoBIConstants.VALUE_FILTER);
String columnfilter = (String) filtersJSON.get(SpagoBIConstants.COLUMN_FILTER);
String typeFilter = (String) filtersJSON.get(SpagoBIConstants.TYPE_FILTER);
String typeValueFilter = (String) filtersJSON.get(SpagoBIConstants.TYPE_VALUE_FILTER);
rows = DelegatedBasicListService.filterList(rows, valuefilter, typeValueFilter, columnfilter, typeFilter);
}
} catch (JSONException e) {
throw new SpagoBIServiceException(SERVICE_NAME, "Impossible to read filter's configuration", e);
}
// END filtering the list by filtering toolbar
// START filtering for correlation (only for DependenciesPostProcessingLov, i.e. scripts, java classes and fixed lists)
biParameterExecDependencies = executionInstance
.getDependencies(biObjectParameter);
if (lovProvDet instanceof DependenciesPostProcessingLov
&& selectedParameterValues != null
&& biParameterExecDependencies != null
&& biParameterExecDependencies.size() > 0) {
rows = ((DependenciesPostProcessingLov) lovProvDet)
.processDependencies(rows, selectedParameterValues,
biParameterExecDependencies);
}
// END filtering for correlation
// START building JSON object to be returned
JSONObject valuesJSON;
try {
JSONArray valuesDataJSON = new JSONArray();
valueColumn = lovProvDet.getValueColumnName();
displayColumn = lovProvDet.getDescriptionColumnName();
descriptionColumn = displayColumn;
int lb = (start != null)? start.intValue(): 0;
int ub = (limit != null)? lb + limit.intValue(): rows.size() - lb;
ub = (ub > rows.size())? rows.size(): ub;
for (int q = lb; q < ub; q++) {
SourceBean row = (SourceBean) rows.get(q);
JSONObject valueJSON = new JSONObject();
if(MODE_COMPLETE.equalsIgnoreCase( mode )) {
List columns = row.getContainedAttributes();
for(int i = 0; i < columns.size(); i++) {
SourceBeanAttribute attribute = (SourceBeanAttribute)columns.get(i);
valueJSON.put(attribute.getKey().toUpperCase(), attribute.getValue());
}
} else {
String value = (String) row.getAttribute(valueColumn);
String description = (String) row.getAttribute(descriptionColumn);
valueJSON.put("value", value);
valueJSON.put("label", description);
valueJSON.put("description", description);
}
valuesDataJSON.put(valueJSON);
}
String[] visiblecolumns;
if(MODE_COMPLETE.equalsIgnoreCase( mode )) {
visiblecolumns = (String[])lovProvDet.getVisibleColumnNames().toArray(new String[0]);
for(int j = 0; j< visiblecolumns.length; j++) {
visiblecolumns[j] = visiblecolumns[j].toUpperCase();
}
} else {
valueColumn = "value";
displayColumn = "label";
descriptionColumn = "description";
visiblecolumns = new String[]{"value", "label", "description"};
}
valuesJSON = (JSONObject)JSONStoreFeedTransformer.getInstance().transform(valuesDataJSON,
valueColumn.toUpperCase(), displayColumn.toUpperCase(), descriptionColumn.toUpperCase(), visiblecolumns, new Integer(rows.size()));
} catch (Exception e) {
throw new SpagoBIServiceException("Impossible to serialize response", e);
}
// END building JSON object to be returned
try {
writeBackToClient( new JSONSuccess( valuesJSON ) );
} catch (IOException e) {
throw new SpagoBIServiceException("Impossible to write back the responce to the client", e);
}
} finally {
logger.debug("OUT");
}