Page 1 of 2

Extending Customer entity with two customs entities

Posted: Tue Oct 16, 2012 2:41 am
by denis
Hey,

I am facing a problem :

I have 2 entities that extend from a Broadleaf Customer :

Code: Select all

BusinessCustomer extends ConsumerCustomer extends CustomerImpl


I added in applicationContext-entity.xml the following line :

Code: Select all

<bean id="org.broadleafcommerce.profile.core.domain.Customer" class="fr.mycompany.core.domain.ConsumerCustomer" scope="prototype"/>


As expected when i click on "add" button from the admin i have the choice between ConsumerCustomer and BusinessCustomer. However, if i choose ConsumerCustomer it works, the object is fully created in the database in ConsumerCustomer table.
But if i choose a BusinessConsumer, only a ConsumerCustomer is created, nothing in BusinessCustomer table.

It's normal because we have overrided Broadleaf Consumer by ConsumerCustomer in the applicationContext-entity.xml

We want to know how to do what we want, is there a solution ?

Thanks in advance for your help

Re: Extending Customer entity with two customs entities

Posted: Mon Oct 22, 2012 4:30 pm
by phillipuniverse
This is fixed by the following Jira issue: http://jira.broadleafcommerce.org/browse/BLC-702

Also, if you are extending Customer in this way (2 extensions), you do not need to declare an entity override in the applicationContext-entity as you have done there.

Re: Extending Customer entity with two customs entities

Posted: Mon Oct 22, 2012 4:43 pm
by denis
Awesome !

Thx Philip and broadleaf team!

Best regards

Re: Extending Customer entity with two customs entities

Posted: Mon Oct 22, 2012 9:49 pm
by phillipuniverse
One other note. I believe you also notated that you saw some exceptions being thrown in the admin when selecting any Customer row. The following Jira ticket should resolve that as well: http://jira.broadleafcommerce.org/browse/BLC-703

Re: Extending Customer entity with two customs entities

Posted: Tue Oct 23, 2012 3:49 am
by denis
Now, everything works perfectly !

Thanks again for your help

Re: Extending Customer entity with two customs entities

Posted: Tue Nov 06, 2012 12:10 pm
by denis
There is an other problem in the admin display,


Finally i have :

- MFCustomer extends CustomerImpl
- BusinessCustomer extends MFCustomer
- ConsumerCustomer extends MFCustomer

So one object (MFCustomer) extends CustomerImpl and 2 other entities that extend MFCustomer.

It works but :

- I have added a new entity Group (@MappedSuperClass)
- A BusinessGroup (@entity) that extends Group
- A ConsumerGroup (@entity) that extends Group

In each Customer entity (BusinessCustomer and ConsumerCustomer) i have added a BusinessGroup (into BusinessCustomer) and a ConsumerGroup (into ConsumerCustomer), annoted with

@AdminPresentation(friendlyName = "Customer_Group", visibility = VisibilityEnum.GRID_HIDDEN)
@AdminPresentationToOneLookup
http://imgur.com/xZZnV

The problem is that when i go to the admin and try to create a BusinessCustomer or a ConsumerCustomer i have the both Group (BusinessGroup and ConsumerGroup) ==> http://imgur.com/XSLqH,YrEXz

Have i forgotten something or it's a broadleaf issue ?

Thanks in advance for your help !

Re: Extending Customer entity with two customs entities

Posted: Tue Nov 06, 2012 4:18 pm
by phillipuniverse
Hm interesting problem. Curious if you have a 'normal' property (like a String or an Integer or something) defined in BusinessCustomer and not in ConsumerCustomer if it still shows up on both forms. Can you check to ensure that this works ok?

Unsure if this is a bug in the framework. My initial thought that it probably is, but this will take some debugging.

Re: Extending Customer entity with two customs entities

Posted: Tue Nov 06, 2012 4:50 pm
by denis
Hi Phillip,

I have tested to add a property "test" (it's a long) in ConsumerCustomer and no the property is only displayed on ConsumerCustomer form, not in BusinessCustomer.

But in the three cases (MFCustomer, ConsumerCustomer and BusinessCustomer forms) i have both groups (BusinessGroup and ConsumerGroup).

Maybe a bug with the annotation @AdminPresentationToOneLookup in my case.

Thanks

Re: Extending Customer entity with two customs entities

Posted: Tue Nov 06, 2012 5:31 pm
by phillipuniverse
Yeah that's what I'm thinking. This will definitely take some debugging, I'll let you know when I have any updates on this.

What version of BLC are you on?

Re: Extending Customer entity with two customs entities

Posted: Wed Nov 07, 2012 2:32 am
by denis
I currently use BLC 2.1.0-SNAPSHOT

Thanks!