hi all,
I am trying to figure the best way to map input files, such as XLS or CSV files to objects in the system. Let me expand on that a little. I have the following objects:
Company Contact
Each have variables variables such as:
Addresses Phone numbers Emails etc
The input file I can get varies, sometimes there will be column headings, sometimes not, the column arrangement and numbers will change at times. It could look as follows:
COMPANY - CONTACT - ADDRESS - PHONE
----------------------------------------------------------------------
company1 contact1 address1 phone1
company1 contact2 address2
company2 contact3 phone2
contact4 address3
The above shows that "company" will have the "addres1" and "phone1" attached to the company, the "contact1" is its own object but has "company1" as its parent object.
The same is true for "contact2", (except for the phone).
"contact4" has no parent object so "address3" belongs to the contact, rather than a Company.
My thinking so far would be to have the following objects:
Mappings - (this is where I am not sure how to implement it. It should say how columns should map to variables, the ownership / hierarchy - e.g. Company has Address)
IMappingLoader - (loads the mapping objects)
-- XmlMappingLoader
-- DbMappingLoader
IDataLoader - (loads the data into a dataset)
-- XLSLoader
-- CSVLoader
So the mappings would be loaded, the data loaded into a dataset and the correct objects returned.
The part I am not really sure the best way to approach is how to do the mappings part. How to be able to say which column should belong to which object.
Thanks for any and all advice.
Jon