Re: Entity / Attributes / Import
Re: Entity / Attributes / Import
- Subject: Re: Entity / Attributes / Import
- From: Art Isbell <email@hidden>
- Date: Wed, 12 May 2004 12:45:20 -1000
On May 12, 2004, at 10:19 AM, James Cicenia wrote:
Is there a simple way I can query the keys of my model to see if it
exists?
Not sure what you mean by "the keys of my model". If you mean the
attribute names of an entity in your eomodel, you can ask the entity
for an attribute with a certain name. However, if the first row of
your import file contains the database column names which may differ
from the attribute names, you'd need to ask the entity for a list of
its attributes and ask each attribute for it external name.
Basically, you can programmatically find out all sorts of info about
your eomodel. See the EOModelGroup (or EOModel), EOEntity,
EOAttribute, EORelationship, and EOJoin documentation for details.
Or, should I just trap for a bad key in takeValueForKey by putting it
into a
try/catch block?
For the purpose of accepting or rejecting the import file, that would
probably be sufficient if the keys are the attribute names rather than
the column names.
I am trying to import files via an upload into our database and was
trying
to make it flexible enough where the first row of the file are the
keys in the
database.
You may run into problems with non-String value class attributes
because all import file values will be Strings. See
EOAttribute.validateValue() as a way to convert a String to the
attribute's value class prior to setting its value in the EO class
object. You might also want to investigate avoiding creating EO class
objects if you're just trying to import data. That can be considerably
slower than dealing with each row as a dictionary using EOAccess API.
Aloha,
Art
_______________________________________________
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.