• 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: Design Question...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Design Question...


  • Subject: Re: Design Question...
  • From: LD <email@hidden>
  • Date: Fri, 1 Jul 2005 12:51:48 +1000

Hi again,

On 30/06/2005, at 4:40 PM, james o wrote:

when my WOComponent is being built it iterates over items from a Question table. Each questionItem will have a corresponding pulldown menu or check box list built from a Choices table. at this point i can think of two options on storing the values in a Results table:

1. when the WORepetition is creating the pull-downs i can bind the corresponding Results table item to the pull down selection. the downside to this is that sometimes when a question (200 per evaluation) is created a result is not always entered causing blank result row to be inserted. the downside with this method is that it will create more data (blank rows) and won't work w/checkboxes - i'll need a join table for this. the plus side it will require less cpu/code to get the corresponding Question. after importing the existing legacy data i'll have 3 million rows in the results table @ least 1/2 of them will be null...

Sorry - my suggestion is similar but removes blank results before saving the ec. Working with checkboxes wouldn't require much more effort to get the same effect.


The schema I suggested was as follows - but that assumed that the choices are possibly unique per question.
Question <-->> Choice <-->> Result <<--> User


If your schema is as follows (where the choices are generic):
Question <-->> Results <<--> Choices
Results <<--> User

Then the adjustments would be...

// Result.java - no change

// WOComponent.java
<...>
public Result aResult() {
    Result aResult;

aResult = (Result) results.objectForKey(aQuestion);
if (aResult == null) {
aResult = EOUtilities.createAndInsertInstance(localEC, "Result");
aResult.addObjectToBothSidesOfRelationshipWithKey(user, "user");
aResult.addObjectToBothSidesOfRelationshipWithKey(aQuestion, "question");
// Choice relationship deferred to user selection
results.setObjectForKey(aResult, aQuestion);
}
return aResult;
}


public WOComponent actionMethod() {
    Enumeration en;

en = results.objectEnumerator();
while (en.hasMoreElements()) {
Result r = (Result) en.nextElement();
Choice c = r.choice();
if (c == null) {
aResult.removeObjectFromBothSidesOfRelationshipWithKey (user, "user");
aResult.removeObjectFromBothSidesOfRelationshipWithKey (aResult.question(), "question");
localEC.deleteObject(r);
}
}
// save changes to parent EC if applicable
// and return appropriate component
}


//
// WOComponent.wod as before
//

with regards,
--

LD
_______________________________________________
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


References: 
 >Design Question... (From: james o <email@hidden>)

  • Prev by Date: Re: Design Question...
  • Next by Date: File download
  • Previous by thread: Re: Design Question...
  • Next by thread: Re: Design Question...
  • Index(es):
    • Date
    • Thread