Skip to content

Instantly share code, notes, and snippets.

@phillipuniverse
Created March 21, 2013 21:09
Show Gist options
  • Save phillipuniverse/5216769 to your computer and use it in GitHub Desktop.
Save phillipuniverse/5216769 to your computer and use it in GitHub Desktop.
@Override
public DynamicResultSet inspect(PersistencePackage persistencePackage, DynamicEntityDao dynamicEntityDao, InspectHelper inspectHelper) throws ServiceException {
try {
PersistencePerspective persistencePerspective = persistencePackage.getPersistencePerspective();
Map<MergedPropertyType, Map<String, FieldMetadata>> allMergedProperties = new HashMap<MergedPropertyType, Map<String, FieldMetadata>>();
//Grab the default properties for the Sku
Map<String, FieldMetadata> properties = inspectHelper.getSimpleMergedProperties(PaymentResponseItem.class.getName(), persistencePerspective);
//Create the metadata for the collection
MapMetadata md = new MapMetadata();
md.setFriendlyName("Additional Fields");
md.setFieldName("additionalFields");
md.setMutable(false);
md.setKeyPropertyFriendlyName("Name");
md.setTargetClass(PaymentResponseItemImpl.class.getName());
md.setValuePropertyFriendlyName("Value");
md.setAvailableToTypes(new String[]{PaymentResponseItemImpl.class.getName()});
md.setDataSourceName("additionalFields");
md.setFieldName("additionalFields");
md.setOwningClass(PaymentResponseItemImpl.class.getName());
properties.put("additionalFields", md);
properties.remove("transactionSuccess");
allMergedProperties.put(MergedPropertyType.PRIMARY, properties);
Class<?>[] entityClasses = dynamicEntityDao.getAllPolymorphicEntitiesFromCeiling(PaymentResponseItem.class);
ClassMetadata mergedMetadata = inspectHelper.getMergedClassMetadata(entityClasses, allMergedProperties);
DynamicResultSet results = new DynamicResultSet(mergedMetadata, null, null);
return results;
} catch (Exception e) {
ServiceException ex = new ServiceException("Unable to retrieve inspection results for " +
persistencePackage.getCeilingEntityFullyQualifiedClassname(), e);
throw ex;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment