Skip to content

Conversation

@cbeach47
Copy link
Contributor

Description of Change

Modifies the transformation API to allow an entityIdPath that are a CSV of entity/attribute IDs.

Related Issues

Related to #790

WIP.

@cbeach47
Copy link
Contributor Author

cbeach47 commented Jan 27, 2026

MDR should be able to map an attribute from each scenario:

  • Base LIF > literal attribute

  • Base LIF > associated attribute from Base LIF

  • Base LIF > associated by reference entity from Base LIF > required attribute in Base LIF from referenced entity

  • Base LIF > associated by embedded entity from Base LIF > attribute (opt/req) in Base LIF from embedded entity

  • Source Schema has the same scenarios as Base LIF.

  • Org LIF > literal attribute

  • Org LIF > associated attribute from Org LIF

  • Org LIF > associated by reference entity from Org LIF > required attribute in Org LIF from referenced entity

  • Org LIF > associated by embedded entity from Org LIF > attribute (opt/req) in Org LIF from embedded entity

  • Org LIF > associated attribute from Base LIF

  • Org LIF > associated by reference entity from Base LIF > required attribute in Base LIF from referenced entity (entity must be embedded first)

  • Org LIF > associated by embedded entity from Base LIF > attribute (opt/req) in Base LIF from embedded entity

  • Org LIF > associated attribute from Source Schema

  • Org LIF > associated by reference entity from Source Schema > required attribute in Source Schema from referenced entity (entity must be embedded first)

  • Org LIF > associated by embedded entity from Source Schema > attribute (opt/req) in Source Schema from embedded entity

  • Org LIF > associated attribute from Partner LIF

  • Org LIF > associated by reference entity from Partner LIF > required attribute in Partner LIF from referenced entity (entity must be embedded first)

  • Org LIF > associated by embedded entity from Partner LIF > attribute (opt/req) in Partner LIF from embedded entity

  • Partner LIF has the same scenarios as Org LIF, however, the create/edit schema flows may be different / locked down for Partner LIFs. Using the scenarios for mapping are all valid however.

@cbeach47 cbeach47 force-pushed the bugfix/issue-790/adjust-entity-id-path branch from 4f7c81d to d127ca2 Compare January 28, 2026 13:09
id_path=id_path,
fail_if_origin_data_model_is_not_the_anchor=(
i == 0
), # Only fail if the first node does not originate on the anchor data model

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this check is needed fail_if_origin_data_model_is_not_the_anchor. Is there a reason this is here that I'm forgetting about?
If the data model is BaseLIF or SourceSchema, then the entity/attribute's data_model_id should equal the anchor_data_model_id.
If the data model is OrgLIF or PartnerLIF, then even the root entity data_model_id may not equal the anchor_data_model_id.
I believe these cases are covered by your is_self_contained_anchor_model check.

Copy link
Contributor Author

@cbeach47 cbeach47 Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the data model is OrgLIF or PartnerLIF, then even the root entity data_model_id may not equal the anchor_data_model_id.

ah ok, I'll relax that constraint.

originates_in_anchor = anchor_data_model_id == node_data_model_id
if not originates_in_anchor:
signature = f"{node_type} {raw_node_id}({cleaned_node_id}) for data model {node_data_model_id} in the entityIdPath {id_path}"
if fail_if_origin_data_model_is_not_the_anchor:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per my other comment, I don't think we should have this check.

)

# Will only be checked for Org LIF and Partner LIF anchor data models
await check_existing_inclusion(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo, if the data model type is OrgLIF or PartnerLIF, you should check for the existing inclusion regardless of whether the entity/attribute's data_model_id == anchor_data_model_id.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and if the data_model_id == anchor_data_model_id then the inclusion's ExtDataModelId will then be null?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on looking at the frontend code, I think the Inclusion's ExtDataModelId is supposed to always equal the anchor_data_model_id.

return result.scalar_one_or_none() is not None


async def check_entity_association_strict(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you using this instead of check_existing_association? There are cases where ExtendedByDataModelId could be null:

  • If data model type is BaseLIF or SourceSchema, then I think the ExtendedByDataModelId will always be null.
  • If the data model type is OrgLIF or PartnerLIF then the ExtendedByDataModelId may or may not be null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't like that it was an 'or' condition in check_existing_association. I felt we should be able to determine what value the ExtendedByDataModelId should be prior to invoking the method.

Copy link

@mgwozdz-unicon mgwozdz-unicon Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been having a hard time trying to determine how we could reverse engineer the ExtendedByDataModelId of the association. I think what I said in my other comment is true that for the OrgLIF and PartnerLIF, these are the cases where ExtendedByDataModelId of the association will not be null:

  1. The entity/attribute itself is an Extension and has ExtendedByDataModelId non-null.
  2. Someone used "+ Existing" to create an association in their OrgLIF or PartnerLIF that does not exist in BaseLIF.

That 2nd case is difficult to discern. The only thing I can think of to prove this is:

  1. If the Association has Extension=true, then ExtendedByDataModelId=anchor_data_model_id.

But we're trying to fetch the Association based off of this info, so we don't know yet whether or not it's an extension. I guess if you wanted, you could fetch the Association with the 'or' condition and then check if Extension=true and if it does then check that ExtendedByDataModelId=anchor_data_model_id.

in [DataModelType.BaseLIF, DataModelType.SourceSchema],
)

extended_by_data_model_id = None if originates_in_anchor else anchor_data_model.Id

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the data model is BaseLIF or SourceSchema, then the association's extended_by_data_model_id should equal null always.
If the data model is OrgLIF or PartnerLIF, then the association's extended_by_data_model_id should be non-null if:

  1. The entity/attribute itself is an Extension and has ExtendedByDataModelId non-null.
  2. Someone used "+ Existing" to create an association in their OrgLIF or PartnerLIF that does not exist in BaseLIF.

I don't think we need to try to calculate which of these situations we're in though. I think it's okay to just always check for the association with extended_by_data_model_id = null or anchor_data_model_id, which is what I'm trying to suggest in my other comment when I say that I think you should use the check_entity_association method instead of the check_entity_association_strict method. Same for checking the entity-attribute association.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

3 participants