• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Sophisticated relationship help
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sophisticated relationship help


  • Subject: Re: Sophisticated relationship help
  • From: Art Isbell <email@hidden>
  • Date: Sat, 25 Feb 2006 22:10:42 -1000

On Feb 25, 2006, at 9:10 PM, Jim Wong wrote:

I have 3 entities: COMPANY, OPPORTUNITY, OPPORTUNITY_COMPANY. 

COMPANY
- companyID (attribute)


OPPORTUNITY
- oppID (attribute)
- customer (relationship between OPPORTUNITY(oppID) and OPPORTUNITY_COMPANY (oppID))

OPPORTUNITY_CUSTOMER
- oppID (attribute)
- customerID (attribute)
- company (relationship between OPPORTUNITY_CUSTOMER (customerID) and COMPANY (companyID))
- opportunity (relationship between OPPORTUNITY_CUSTOMER (oppID) and OPPORTUNITY (oppID))

The requirements of a form are:
- In a form which displays all companies in COMPANY, user can select by WOCheckBOX the company(s) which will be customer of an opportunity. 
- Upon submission, the selected companies needs to be added to the OPPORTUNITY_CUSTOMER as customers of a related OPPORTUNITY. 

how can i get the above done? how's the coding requirement be like? 

EOModeler can build a valid many-to-many relationship between Company and Opportunity.  This is preferable to building these relationships manually because it's easy to make a mistake.  Click the Tools > Table Mode EOModeler menu.  Select the model name (the top node along the left edge of the EOModeler window).  In the right section of the window, select the Company and Opportunity entities.  Click the Property > Join in Many to Many menu item.  This will create Company.opportunities and Opportunity.companies to-many relationships that are flattened across the Opportunity_Company join entity.  Inspect the Opportunity_Company entity to make sure that it has the correct table name.  You may rename the Opportunity_Company entity to Opportunity_Customer and the Opportunity.companies relationship to Opportunity.customers if you prefer.

Then when the form is submitted, iterate through the selected companies adding each company to the Opportunity.customers relationship:

opportunity.addObjectToBothSidesOfRelationshipWithKey(selectedCompany, "customers");

Then send a saveChanges() message to the editing context.  Your eomodel will guide EOF to automatically manage the Opportunity_Customer entity which you don't need to refer to in your code or even to generate a custom Java class for; just leave it an EOGenericRecord.

Aloha,
Art

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Sophisticated relationship help
      • From: Jim Wong <email@hidden>
References: 
 >WOCheckBox Howto? (From: Jim Wong <email@hidden>)
 >Re: WOCheckBox Howto? (From: Mark Morris <email@hidden>)
 >Sophisticated relationship help (From: Jim Wong <email@hidden>)

  • Prev by Date: Sophisticated relationship help
  • Next by Date: Re: Sophisticated relationship help
  • Previous by thread: Sophisticated relationship help
  • Next by thread: Re: Sophisticated relationship help
  • Index(es):
    • Date
    • Thread