Hi,
I implement a Designer Plug-In for BIRT and have the problem, that my parameter data types from my ParameterMetaData are not used in UI sometimes. Concretely I have this problem with the data type "Boolean", while "Date" works.
The implementation of method "getParameterType" returns 16 (java.sql.Types.BOOLEAN), as it is given by "getManifest().getDataSetType(null).getDataTypeMapping(nativeDataTypeName)".
The method "getParameterTypeName" returns "Boolean".
When populating an edited / created data set the native data types are also set at the parameter elements of the data set.
Is this a known bug? Unfortunately I didn't found anything useful about this problem.
Here are the snippets of my code.
1. Method for updating parameter settings at data set populating
private static void updateParameterDesign(IParameterMetaData metaData, DataSetDesign dataSetDesign) throws OdaException {
DataSetParameters paramDesign =
DesignSessionUtil.toDataSetParametersDesign(metaData,
DesignSessionUtil.toParameterModeDesign(IParameterMetaData.parameterModeIn));
// no exception in conversion; go ahead and assign to specified dataSetDesign
dataSetDesign.setParameters(paramDesign);
if (paramDesign == null) {
return; // no parameter definitions; done with update
}
paramDesign.setDerivedMetaData(true);
if (paramDesign.getParameterDefinitions().size() > 0) {
EList<ParameterDefinition> definitions = paramDesign.getParameterDefinitions();
for (int i = 0; i < definitions.size(); i++) {
int type = metaData.getParameterType(i + 1);
ParameterDefinition def = definitions.get(i);
DataElementAttributes attributes = def.getAttributes();
Object defaultValue = QueryUtil.getDefaultValue(type);
attributes.setNativeDataTypeCode(type);
if(defaultValue != null) {
if(defaultValue instanceof String) {
def.setDefaultScalarValue(defaultValue.toString());
}
def.addDefaultValue(defaultValue);
}
}
}
}
2a. ParameterMetaData-Implementation (getting data types)
public int getParameterType(int param) throws OdaException {
try {
int code = Driver.getNativeDataTypeCode(getParameterTypeName(param));
return code;
} catch (Exception e) {
throw new OdaException("Could not get data type for parameter " + param);
}
}
public String getParameterTypeName(int param) throws OdaException {
String type = getDefinition(param).getType();
return type == null ? "String" : type;
}
public IParam getDefinition(int index) {
return params.get(index - 1);
}
2b. Method for getting data type code (class Driver used in 2a)
public static int getNativeDataTypeCode(String nativeDataTypeName) throws OdaException {
DataTypeMapping typeMapping = getManifest().getDataSetType(null).getDataTypeMapping(nativeDataTypeName);
if (typeMapping != null) {
return typeMapping.getNativeTypeCode();
}
return UNDEFINED_DATA_TYPE_CODE;
}