Re: Deletion Confusion
Re: Deletion Confusion
- Subject: Re: Deletion Confusion
- From: James Cicenia <email@hidden>
- Date: Sat, 8 Jan 2005 17:32:59 -0600
I actually was looking for the one line suggestion implemented as
follows:
clearSchedule(){
phases(new NSArray());
}
This being in the Project EO class. It seems to work so far.
Seems to be working nicely my new "cancel/undo" feature/interface.
-James
On Jan 8, 2005, at 4:51 PM, Chuck Hill wrote:
On Jan 8, 2005, at 8:27 AM, James Cicenia wrote:
Otherwise this seemed to work:
for(int i=0;i<project.phases().count();i++){
ProjectPhase originalPhase =
(ProjectPhase)project.phases().objectAtIndex(i);
for(int j=0;j<originalPhase.tasks().count();j++){
ProjectPhaseTask originalTask = (ProjectPhaseTask)
originalPhase.tasks().objectAtIndex(j);
ec.deleteObject(originalTask);
}
ec.deleteObject(originalPhase);
}
Maybe I just need to loop through phases as my owns destination and
cascade rules are all set properly.
OK - I forgot about not modifying a collection. Hmm, so why did the
above code work? Shouldn't project.phases().count()
decrease in value by one each time through?
No. deleteObject just flags it for deletion. It does not directly
modify any relationships. You are responsible for doing that, or for
getting EOF to refresh so that they show correctly. Just saving can
get that done with the right delete rules.
Chuck
On Jan 7, 2005, at 8:30 PM, Chuck Hill wrote:
On Jan 7, 2005, at 1:55 PM, James Cicenia wrote:
Hello -
I am baffled, tired, or both.
Baffled usually follows tired pretty closely IME.
I have the following structure with the shown relationships:
Project -->> Phases -->>Tasks
I need to temporarily purge all Phases and Task.
Your use of the word 'temporarily' makes me uneasy. How do you
temporarily delete objects? Have you discovered object
reincarnation? :-P
Is there a simple one line that I am missing that will do this?
ec.deleteObject(project);
Which I suspect is not what you want to do.
Do I have to walk through both Phases and Tasks or is
Phases good enough because of the cascade rule?
Phases is good enough. If the Project ->> Phases relationship is
set to owns destination, then
project.setPhases(new NSMutableArray());
might do it in one line. I don't know if that will work, seems like
it should.
ALSO, when I was iterating over the relationship to delete
each object, the set total kept getting smaller so it would never
delete all the records. It would always leave two. I thought
enumerator
would solve that, but no go.
No. You can't modify a collection that you are enumerating. You
need to make a copy:
NSArray copyOfPhases = new NSArray(project.phases());
and enumerate that.
Any help would be great.. too tired to see what I am doing wrong
here.
Hope that helped.
Chuck
--
Practical WebObjects - a book for intermediate WebObjects developers
who want to increase their overall knowledge of WebObjects, or those
who are trying to solve specific application development problems.
http://www.global-village.net/products/practical_webobjects
--
Practical WebObjects - a book for intermediate WebObjects developers
who want to increase their overall knowledge of WebObjects, or those
who are trying to solve specific application development problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
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