Monday, November 30, 2015

PropertyDescriptor That set values on other properties (ATG Oracle Commerce)

As you already know PropertyDescriptors are great tool to make repository properties return or set a value based on your code logic instead of getting/setting this directly into the DB.

There are some good posts about PropertyDescriptors out there, like these:


And also Oracle Documentation is fine:



Recently I had a requirement that required change some properties based on the value of other property.
Then the first thing that came into my mind was: "a PropertyDescriptor could do this"

Since Property Descriptor methods have the RepositoryItemImpl and the value as parameter for both methods setPropertyValue and getPropertyValue
So is as easy as simply get the property you want to set, and it is great that it works for other items if those are related, an example of this are childSkus.

Below is an example of how to set skuProperties based on product Properties, meaning that the this PropertyDescriptor will Set some properties on childSkus based product's value and some configuration.


The code above can be used when Setting a value on a BCC project, and it will affect all the assets that were involved into the change, this is due we are working with CurrentVersionItem.
And also if a property happens to be null this can be catch by

skuValue instanceof RepositoryItemImpl.NullObject

Post a Comment