manually creating eo's
manually creating eo's
- Subject: manually creating eo's
- From: John Lennard <email@hidden>
- Date: Mon, 1 Nov 2004 13:10:08 +1300
Hello,
I am currently working on a project which requires me to update my
application with records from another datasource.
Due to the scant documentation for the soap/webservices I have decided
to write my own update mechanism.
I have written a small application that reads the alternate datasorce
and wraps the information in a simple xml dialect that is then posted
to the webobjects application where i can get a DOM document from the
request which i can then parse and build eo's.
This is where my problems begin. I want to either find an eo that
matches this raw data including pk's and update it, or if i dont find
a matching object create a new one with this data, including pk's.
The current code, it would seem is leaving the ObjectGraph in a some
what sorry state causing exceptions every now any then about missing
objects or objects disappearing.
I was wondering if any body knows a way that i can perform the above
tasks and keep my object graph intact as to not cause exceptions.
see below for the code i am using to create/look for objects
i think i am going slightly mad
John
---
public static EOEnterpriseObject
createAndInsertForGlobalID(EOEditingContext ec, EOGlobalID globalId) {
EOEnterpriseObject eoObject = ec.faultForGlobalID(globalId, ec);
if (eoObject.isFault()) {
EOFaultHandler fh = eoObject.faultHandler();
fh.completeInitializationOfObject( eoObject );
ec.insertObject( eoObject );
}
return eoObject;
}
public static EOEnterpriseObject
objectForEntityAndPrimaryKey(EOEditingContext ec, EOEntity entity,
NSDictionary pkDict) {
EOGlobalID globalId = entity.globalIDForRow( pkDict );
EOEnterpriseObject eoObject = ec.objectForGlobalID( globalId );
if ( null == eoObject ) {
try {
eoObject = EOUtilities.objectWithPrimaryKey(ec, entity.name() , pkDict);
} catch (EOObjectNotAvailableException eona) { }
}
return eoObject;
}
_______________________________________________
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