on 2018 Jun 12 2:19 PM
Hi,
I'm trying to compare the model of a promotion which is sent from datahub with the current model from the hybris database in order to see if something was modified.
For this I've tried to implement a ValidateInterceptor and I am trying to get the current model from the database and compare it with the model that reaches the ValidateInterceptor
I've tried a couple of things which have not worked so far. 1) Trying to get the current promotion using modelService - the modelService is returning the same promotion with the promotion from the interceptor 2) Trying to use interceptorContext isModified flags - it sees some attributes as modified even though they weren't 3) Tried to use ModelValueHistory - Some of the attributes are clasified as dirtyAttributes.
Request clarification before answering.
Hi,
what kind of comparison you are trying to do ? Any specific attribute change ? If yes check for your attribute in dirty attributes list.
InterceptorContext.isModified will return true if there are some changes.
If you need to get OldValue for specific attribute in model, you can get it through modelContext
For e.g.
ItemModelContextImpl modelContext = (ItemModelContextImpl) yourModel.getItemModelContext();
Object oldValue;
if (modelContext.isLoaded("yourAttribute"))
{
oldValue = modelContext.getOriginalValue("yourAttribute");
}
else {
oldValue = modelContext.getAttributeProvider().getAttribute("yourAttribute");
}
Hope this helps !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.