This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Creating Relationship to a Federated Item Type

Eric Domke - Monday, March 26, 2012 10:20 PM:

Has anyone had any luck creating a real relationship to a federated item type?  To clarify, I have a real (table-backed) item type A for which I want to create a real (table-backed) relationship (type B) to a federated (no table data) item type C.  The first obstacle I ran into is that Innovator creates a foreign key constraint in the database between the related_id of type B and and the id of type C even though the table of type C does not actually store any ids.  Even after manually removing this constraint, Innovator will still not return data for the related_id in AML (it only returns nulls) even though valid IDs are stored in the database.  Any ideas?



tstickel - Friday, March 30, 2012 11:26 AM:

Can you determine whether the server method that you have set-up as a onAfterGet method for your itemtype C is actually being called.  My guess is that it is not being called.  But if it is, does the onAfterGet method populate all the properties of itemtype C with non-null values?  I would be tempted to include a non-null ID property in what the onAfterGet method returns, even if it is just set as a ficticious ID value.

Alternatively, I would be tempted to have itemtype C be a hybrid, with minimal Innovator properties stored as an Innovator table and the rest of the properties federated.  You might even be able to have just one record in this table, where the onAfterGet actually goes to your external datasource to retrieve the "real data" and your application just ignores the "minimal Innovator properties".  In this scenerio every relationship (type B) record would have its source ID set to your type A records, but its related ID would always be set to point to the one type C record.  Of course this raises the question as to how does the onAfterGet method determine what external data "record"  it should be accessing.

I haven't actually done this, so these are just thoughts on the issue.



Eric Domke - Monday, April 2, 2012 11:20 AM:

Thanks for the ideas.

ItemType C actually is a fully federated type that has an onGet method (as opposed to using the onAfterGet).  I am fairly certain that this method (which does work properly if I just do an AML against ItemTypeC) is not being called.  When I do an AML against ItemType B, it explicitly returns a related_id property with is_null="1" even though there is a related_id value stored in the table for ItemType B.

I am hesitant to store actual data in the ItemType C.  The scenario for doing this is federation between a closed instance of Innovator which is tightly controlled by my team and a more open, playground instance of Innovator which is available to more individuals in the company to build solutions in.  In one situation, ItemType C is part data, and I really don't want to have to sync 100,000s of records between databases.