//unimplemented
}
@Override
public Entity add(PersistencePackage persistencePackage, DynamicEntityDao dynamicEntityDao, RecordHelper helper) throws ServiceException {
Entity entity = persistencePackage.getEntity();
try {
//Fill out the Sku instance from the form
PersistencePerspective persistencePerspective = persistencePackage.getPersistencePerspective();
Sku adminInstance = (Sku) Class.forName(entity.getType()[0]).newInstance();
Map<String, FieldMetadata> adminProperties = helper.getSimpleMergedProperties(Sku.class.getName(), persistencePerspective);
adminInstance = (Sku) helper.createPopulatedInstance(adminInstance, entity, adminProperties, false);
//Verify that there isn't already a Sku for this particular product option value combo
Entity errorEntity = validateUniqueProductOptionValueCombination(adminInstance.getProduct(),
getProductOptionProperties(entity),
null);
if (errorEntity != null) {
entity.setPropertyValidationErrors(errorEntity.getPropertyValidationErrors());
return entity;
}
//persist the newly-created Sku
adminInstance = dynamicEntityDao.persist(adminInstance);
//associate the product option values
associateProductOptionValuesToSku(entity, adminInstance, dynamicEntityDao);
//After associating the product option values, save off the Sku
adminInstance = dynamicEntityDao.merge(adminInstance);
//Fill out the DTO and add in the product option value properties to it
Entity result = helper.getRecord(adminProperties, adminInstance, null, null);
for (Property property : getProductOptionProperties(entity)) {
result.addProperty(property);
}
return result;
} catch (Exception e) {
throw new ServiceException("Unable to perform fetch for entity: " + Sku.class.getName(), e);
}