Page 1 of 1

Admin UI displays duplicated items when extending Customer

Posted: Tue Nov 27, 2012 5:36 am
by aaron8tang
I'm running the demo site, and extends the Customer entity:

Code: Select all

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "CHP_CUSTOMER")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region="blStandardElements")
public class CHPCustomerImpl extends CustomerImpl implements CHPCustomer {

    private static final long serialVersionUID = 1L;

    @Column(name = "FULL_NAME")
    @AdminPresentation(friendlyName = "CustomerImpl_UserName", order=1, prominent=true)
    protected String fullname;
   
    @ManyToOne(targetEntity = OrgnizationImpl.class)
    @JoinColumn(name = "ORG_ID")
    @AdminPresentation(friendlyName = "", order=2, prominent=true)
    protected Orgnization orgnization;

    @Column(name = "CUSTOMER_CODE")
    @AdminPresentation(friendlyName = "", order=2, prominent=true)
    protected String customerCode;

    @Column(name = "INVOICE_TITLE")
    @AdminPresentation(friendlyName = "", order=2,prominent=true)
    protected String invoiceTitle;

    @Column(name = "IS_APPROVED")
    @AdminPresentation(friendlyName = "", prominent=true)
    protected Boolean approved = false;
   
    @ManyToOne(targetEntity = AdminUserImpl.class)
    @JoinColumn(name = "APPROVED_BY")
    @AdminPresentation(friendlyName = "", order=2, prominent=true)
    protected AdminUser approvedBy;
   
    @Column(name = "DATE_APPROVED")
    @AdminPresentation(friendlyName = "", prominent=true)
    protected Date dateApproved;

   
    @Override
   public String getFullname() {
      return this.fullname;
   }

   @Override
   public void setFullname(String fullname) {
      this.fullname = fullname;
   }

   @Override
   public Orgnization getOrgnization() {
      return this.orgnization;
   }

   @Override
   public void setOrgnization(Orgnization orgnization) {
      this.orgnization = orgnization;
   }

   @Override
   public String getInvoiceTitle() {
      return this.invoiceTitle;
   }

   @Override
   public void setInvoiceTitle(String invoiceTitle) {
      this.invoiceTitle = invoiceTitle;
   }

   @Override
   public Date getDateApproved() {
      return this.dateApproved;
   }

   @Override
   public void setDateApproved(Date dateApproved) {
      this.dateApproved = dateApproved;
   }

   @Override
   public AdminUser getApprovedBy() {
      return this.approvedBy;
   }

   @Override
   public void setApprovedBy(AdminUser adminUser) {
      this.approvedBy = adminUser;
   }
   
    @Override
    public boolean isApproved() {
        return approved;
    }

    @Override
    public void setApproved(boolean approved) {
        this.approved = approved;
    }

   @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        CHPCustomerImpl other = (CHPCustomerImpl) obj;

        if (id != null && other.id != null) {
            return id.equals(other.id);
        }

        if (fullname == null) {
            if (other.fullname != null) {
                return false;
            }
        } else if (!fullname.equals(other.fullname)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((fullname == null) ? 0 : fullname.hashCode());
        return result;
    }


The front site runs well, and a customer registered.
But on the Admin UI, duplicated items displayed.
duplicated_ui_item.png
duplicated_ui_item.png (9.18 KiB) Viewed 30799 times


What happens? And how to correct it?

Thanks.

Re: Admin UI displays duplicated items when extending Customer

Posted: Tue Nov 27, 2012 5:44 am
by aaron8tang
It seems caused by property in the extended CHPCustomer entity

Code: Select all

    @ManyToOne(targetEntity = AdminUserImpl.class)
    @JoinColumn(name = "APPROVED_BY")
    @AdminPresentation(friendlyName = "", order=2, prominent=true)
    protected AdminUser approvedBy;


because "Admin Name" and "Admin Login" only owned by AdminUserImpl.

What I wanna to do is that a registered customer should be approved by an admin user. So I add an approved_by property
in the extended entity. Is this the right way to do that?

I'm running the 2.1-SNAPSHOT code base.

Thanks.

Re: Admin UI displays duplicated items when extending Customer

Posted: Wed Dec 12, 2012 1:27 pm
by jefffischer
Is this still a problem in the 2.1.0-GA release?