@Override
public void loadAdditionalComponentAttributes() throws FactoryException, JAXBException {
com.salesforce.ide.api.metadata.types.ReportType reportType = null;
DescribeSObjectResult primaryObject = null;
DescribeObjectRegistry describeObjectRegistry = null;
try {
reportType = (com.salesforce.ide.api.metadata.types.ReportType) component.getDefaultMetadataExtInstance();
describeObjectRegistry = getComponentFactory().getConnectionFactory().getDescribeObjectRegistry();
// BaseObject here is plural form save from user inpurt in Ui
primaryObject =
describeObjectRegistry.getCachedDescribeByPluralLabel(getProject(), reportType.getBaseObject());
} catch (InstantiationException e) {
logger.warn("Unable to instantiate default metadataExt instance for Report Type", e);
} catch (IllegalAccessException e) {
logger.warn("Unable to instantiate default metadataExt instance for Report Type", e);
} catch (Exception e) {
logger.warn("Unable to get describeObject for " + reportType.getBaseObject(), e);
}
if (Utils.isEmpty(primaryObject)) {
logger.error("Unable to load additional component attributes for Report Type '" + reportType.getLabel()
+ "' due to unable to locate primary object '" + reportType.getBaseObject()
+ "' from DescribeObjectRegistry");
return;
}
// load all fields & sections from primary object
ReportLayoutSection section = new ReportLayoutSection();
section.setMasterLabel(primaryObject.getLabelPlural()); // Master label is plural label of describeObject
// exclude fields that describeSObject returned as extra: default + sobject specific set.
List<String> excludeFieldList = new ArrayList<String>();
List<String> defaultExcludeFieldList =
describeObjectRegistry.getExcludedCrtFields().get(DEFAULT_EXCLUDED_FIELD_KEY);
excludeFieldList.addAll(defaultExcludeFieldList);
List<String> sObjectSpecificExcludedList =
describeObjectRegistry.getExcludedCrtFields().get(primaryObject.getName());
if (Utils.isNotEmpty(sObjectSpecificExcludedList)) {
excludeFieldList.addAll(sObjectSpecificExcludedList);
}
String tableName = primaryObject.getName(); // Table label is name of describeSObject