BroadleafCommerce/BroadleafCommerce — pull request #3 by phillipuniverse (2012-06-18 07:07:32+00:00)
Title: Catalog refactor

Big refactoring on the catalog based on http://jira.broadleafcommerce.org/browse/BLC-531. Please review and let me know if you have any questions. I've also included Javadocs which are hopefully readable and make sense. Big changes are:

#### Removal of ProductSku
#### @OneToOne between Product and Sku
> This is mapped via a foreign key on Product, DEFAULT_SKU_ID. There is also a reverse relationship for this maintained in Sku, but Product is the owning entity. I actually thought that since the @OneToOne on Sku has a 'mappedBy' this would actually automagically get mapped back to Product but I wasn't so lucky. So I'm planning on maintaining that relationship in the admin. It's also set to CascadeType.ALL simply so that you can do this:
```java
Sku sku = new SkuImpl();
sku.setName("test");
Product product = new ProductImpl();
product.setDefaultSku(sku);
catalogService.save(product);
```
Instead of having to do:
```java
Sku sku = new SkuImpl();
sku.setName("test");
catalogService.save(sku);
Product product = new ProductImpl();
product.setDefaultSku(sku);
catalogService.save(product);
```

#### @OneToMany between Product and Sku
> Maintained via BLC_PRODUCT_SKU_XREF. The thing of note here is that the default Sku shouldn't show up in this list since it's already being mapped by the foreign key. This @OneToMany should really only be used in the context of creating additional Skus based on ProductOptions. Sku is the maintainer of this relationship, but the foreign keys are actually in the XREF table.

#### Duplicated Product -> Sku properties removed
#### Deprecated BLC_PRODUCT_MEDIA
> No longer needed since this will just come from the defaultSku. I deprecated rather than remove because it was just as simple to deprecate

This will require a few modifications to current implementations which is in the process of being documented (along with migration scripts). At a high-level:
1. Migrate Weight and Dimension fields to BLC_SKU
2. Ensure that MyCompanyProductImpl extends from just plain old ProductImpl
3. Migrate foreign key SKU_ID from BLC_PRODUCT_SKU up to BLC_PRODUCT as DEFAULT_SKU_ID
4. Migrate everything in BLC_PRODUCT_MEDIA to those Product's default Sku IDs to go in BLC_SKU_MEDIA