Re: Re DisplayGroups. Inserting and deleting objs
Re: Re DisplayGroups. Inserting and deleting objs
- Subject: Re: Re DisplayGroups. Inserting and deleting objs
- From: Jevon Hills <email@hidden>
- Date: Wed, 22 Jan 2003 11:56:20 -0700
Futher to my last note:
I have begun some testing and discover what I think the problem is but
don't know how to solve it.
I have printed out the value of the "linkTable" (smplt) object just
before I try and delete it. Here is the out put of a successfull
delete:
{values = {csmltid = 1186; smartcard = "<SmartCard 36a9c1
_EOIntegralKeyGlobalID[SMARTCARD (java.math.BigDecimal)100071]>";
consoleid = 8; smartcardid = 100071; }; this =
"<ConsoleSmartCardLinkTable 4729ca
_EOIntegralKeyGlobalID[CONSOLESMARTCARDLINKTABLE
(java.math.BigDecimal)1186]>"; }
And here is the out put of one which I had just added and tried to
delete, but failed:
{values = {csmltid = 1187; smartcard = "null"; consoleid = 5;
smartcardid = 100071; }; this = "<ConsoleSmartCardLinkTable 518e15 [Gid
Not Found]>"; }
is the problem that I don't have a smartcard object in the second on
and as a result I dont get a Gid, or is there another reason??
tia
On Wednesday, January 22, 2003, at 11:11 AM, Jevon Hills wrote:
> Thanx for your advice, but I'm still having some issues. I believe
> these are around Editingcontext.
>
> When I first open the page I can remove any of the associated consoles
> no problem, but If i add a new console. I am unable to remove it with
> out first killing and restarting my session.
>
> I get the unable to find guid for object. so it appears That i don't
> manage to insert new objects into the editing context.
>
>
> Here is the code I used to associate a console with a card
>
> ------------
> for (int icount = 0; icount < associateConsoles.count(); icount++)
> {
> System.out.println("Add console " + (icount+1));
>
> Console con = (Console)
> associateConsoles.objectAtIndex(icount);
> //System.out.println("Add Console " + con);
>
> if (!selectedSCConsoles.containsObject(con))
> {
> System.out.println("Need to add this one");
> selectedSCConsoles.addObject((Console) con);
>
> // build smplt and add to groups
> ConsoleSmartCardLinkTable csclt = new
> ConsoleSmartCardLinkTable();
>
> csclt.setSmartcardid(selectedCard.smartcardid());
> csclt.setConsoleid(con.consoleid());
> csclt.setSmartcard(selectedCard);
>
> //System.out.println("Insert into EC");
> con.addToConsolesmartcardlinktable(csclt);
> ec.insertObject(csclt);//class attribute of
> session().defaulteditingcontext()
> }
> }
> try
> {
> saveChanges();
> }
>
> ------------------
> This seems to work fine, but I'm not 100% certain of this.
>
> Here is my remove Association code
>
> ---------------------------
> while(selectedSCSelectedConsoles.count() > 0)
> {
> System.out.println("*******NEXT CONSOLE");
>
> currentConsole = (Console)
> selectedSCSelectedConsoles.objectAtIndex(0);
>
> System.out.println("*****Remove " +
> currentConsole.consoleid() + " " + currentConsole.consolename() + "
> from list*****");
>
> NSArray list =
> currentConsole.consolesmartcardlinktable();
> for(int i = 0; i < list.count(); i++)
> {
> ConsoleSmartCardLinkTable smplt =
> (ConsoleSmartCardLinkTable) list.objectAtIndex(i);
> System.out.println("smplt: " +
> smplt.consoleid() + "\t" + smplt.smartcardid());
> if(smplt.smartcardid()==null)
> {
> }
> else
> if(smplt.smartcardid().intValue()==selectedCard.smartcardid().intValue(
> ))
> {
>
> System.out.println("----DELETEING-----");
>
> selectedCard.removeFromConsolesmartcardlinktables(smplt);
> EOEditingContext delEC =
> smplt.editingContext();
> delEC.deleteObject(smplt);
>
> selectedSCConsoles.removeObject(currentConsole);
> }
>
> selectedSCSelectedConsoles.removeObject(currentConsole);
> }
> }
>
> try
> {
> saveChanges();
> }
> ------------------------------------------------
> With this I get the null guid. But only on the items I have added in
> the current session.
>
> And finally the saveChanges() Method
> ----------------------------------------------
> private void saveChanges()
> throws Exception
> {
> try
> {
> System.out.println("SAVING");
> ec.saveChanges();
> }
> catch (Exception exception)
> {
> // An error occurred during the save. You could present
> //an error page which explains the reason for the save
> //failure. The default is to raise an exception which
> //presents a diagnostic page.
> System.out.println("Unable to save while WHILESAVING");
>
> NSLog.err.appendln("Cannot save changes ");
> throw exception;
> }
>
> }
>
> ---------------------------------------------
> Thank you again for your help.
>
> On Wednesday, January 15, 2003, at 12:46 PM, Art Isbell wrote:
>
>> On Wednesday, January 15, 2003, at 07:03 AM, Jevon Hills wrote:
>>
>>> will be using card keys for security. A card key can only access a
>>> console if it is associated with it. This is a many to Many relation
>>> ship modeled in the database by a table of CardKeys, a table of
>>> Consoles and a linktable between the 2. the link table contains
>>> cardid
>>> and consoleid.
>>>
>>> so when I add a Console to a Card I just add a row to the link table
>>> and, obviously when I remove an association I delete a row.
>>
>> Methinks you are working too hard. If you let EOModeler build your
>> many-to-many relationship, it creates flattened to-many relationships
>> between each entity. If you use those relationships, you won't have
>> to reference the link entity at all. In fact, it should be marked as
>> Abstract since there's no need to ever create any link entity objects
>> in your app.
>>
>> Art
>> http://homepage.mac.com/aisbell/
>> _______________________________________________
>> webobjects-dev mailing list | email@hidden
>> Help/Unsubscribe/Archives:
>> http://www.lists.apple.com/mailman/listinfo/webobjects-dev
>> Do not post admin requests to the list. They will be ignored.
>>
>>
> Jevon K. Hills
> Intern - Zymeta Media Promotion Systems
>
Jevon K. Hills
Intern - Zymeta Media Promotion Systems
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.