• 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: D2W: Pattern for complex object creation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: D2W: Pattern for complex object creation


  • Subject: Re: D2W: Pattern for complex object creation
  • From: Paul Hoadley <email@hidden>
  • Date: Fri, 30 Mar 2012 08:52:43 +1030

Hi David,

On 30/03/2012, at 4:11 AM, David Holt wrote:

On 2012-03-29, at 8:51 AM, Ramsey Gurley wrote:


On Mar 29, 2012, at 2:31 AM, Paul Hoadley wrote:

Anyway, the subject above is probably a misnomer: I'm not trying to create particularly complex objects, but I am trying to do something outside CRUD, which is pretty much all I've ever done with D2W before.  In the model, a Billable object has an optional to-one relationship to Invoice.  When I create a Billable, it initially has no related Invoice.  Later I will create an Invoice for a client, and collect together some set of Billables, and the relationship is created at that time.  And that's the bit I need a pattern for: Invoice creation.  Billable also has a mandatory relationship to Practice (i.e., a client), and a startTime timestamp.  When I go to create an Invoice, I'd give the Invoice a date and select a Practice, and then I want to add, say, all of the Billables that (a) belong to no other Invoice, (b) point to the same Practice, and (c) have a startTime that falls before the new Invoice.date.

Well, you can just set the practice, the invoice date, and then save changes. In Invoice.willInsert() fetch the billables and add them to the relationship just before the save takes place. :-)  Or is that too automatic?

I would probably do it in my Invoice init() method.

Get the practice from thread storage (assuming you select it somehow and can save it in thread storage at that point)
Set the date to current time
Fetch billables that match your criteria
Set the relationship to billables.

Yeah, OK, and then the billables relationship would be editable before I save the Invoice.  Now, humour me—give me an example of how I can "select it somehow and save it in thread storage".  :-)

Profit? :-)

Here's hoping.


-- 
Paul Hoadley
http://logicsquad.net/



 _______________________________________________
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: D2W: Pattern for complex object creation
      • From: David Holt <email@hidden>
References: 
 >D2W: Pattern for complex object creation (From: Paul Hoadley <email@hidden>)
 >Re: D2W: Pattern for complex object creation (From: Ramsey Gurley <email@hidden>)
 >Re: D2W: Pattern for complex object creation (From: David Holt <email@hidden>)

  • Prev by Date: Re: D2W: Pattern for complex object creation
  • Next by Date: Re: D2W: Pattern for complex object creation
  • Previous by thread: Re: D2W: Pattern for complex object creation
  • Next by thread: Re: D2W: Pattern for complex object creation
  • Index(es):
    • Date
    • Thread