05-19-2020, 03:11 PM
Hi Listy,
Did you do any progress on the "self to self"?
I did some testing because I wanted to start using the DropElementWdg to manage this relations in a similar way as the VFX plugin does with the "shot planner" tool (with collections there is custom code taking care of the path problem, see CollectionAddCmd() in src/tactic/ui/panel/collection_wdg.py).
we need an asset_in_asset sType with two fields: parent_asset_code and child_asset_code (I'm using this names because they are the default names used in the collections code)
as stated by Remko we need a schema connection without the path (only the first one will be used) this is because in src/pyasm/search/search.py add_related_connection() line 3771 does:
the second call will fail if an entry without path does not exists.
in this case only two connections are needed:
Now when you do something like:
add_related_connection() line 3772 will add a new asset_in_asset with the code of src_sobject in parent_asset_code and line 3773 will add the code of dst_sobject to child_asset_code.
I found 3 problems with this:
1 - when you delete the parent asset it won't cascade to delete the related asset_in_asset entries because I found no way to tell tactic I want to use a specific path when deleting sObjects with include_dependencies=True so the delete operation will only use the second connection in the schema example and look only for entry where the deleted object is a child (child_asset_code)
2 - If you want to be able to use a "return" path like in
it would be impossible because you would need a different "default" (without path) schema connection:
3 - There are few modifications needed to DropElementAction a DropElementWdg to make it work, I will make a PR to illustrate them.
If we want to make the self to self relationship to work properly there is more work to be done in search.py.
Remko, do you fell e better support for self to self is needed? Do want me to open an issue for this?
Did you do any progress on the "self to self"?
I did some testing because I wanted to start using the DropElementWdg to manage this relations in a similar way as the VFX plugin does with the "shot planner" tool (with collections there is custom code taking care of the path problem, see CollectionAddCmd() in src/tactic/ui/panel/collection_wdg.py).
we need an asset_in_asset sType with two fields: parent_asset_code and child_asset_code (I'm using this names because they are the default names used in the collections code)
as stated by Remko we need a schema connection without the path (only the first one will be used) this is because in src/pyasm/search/search.py add_related_connection() line 3771 does:
Code:
line 3772: self.add_related_sobject(src_sobject, src_path=src_path)
line 3773: self.add_related_sobject(dst_sobject)
the second call will fail if an entry without path does not exists.
in this case only two connections are needed:
Code:
<connect from="prj/asset_in_asset" to="prj/asset" from_node="prj/asset_in_asset" to_node="prj/asset" relationship="code" from_col="parent_asset_code" to_col="code" path="parent" type="many_to_many"/>
<connect from="prj/asset_in_asset" to="prj/asset" from_node="prj/asset_in_asset" to_node="prj/asset" relationship="code" from_col="child_asset_code" to_col="code" type="many_to_many"/>
Now when you do something like:
Code:
instance_type = 'prj/asset_in_asset'
src_sobject = 'prj/asset?project=prj&code=ASSET00010'
dst_sobject = 'prj/asset?project=prj&code=ASSET00005'
instance = SearchType.create(instance_type)
instance.add_related_connection(src_sobject, dst_sobject, src_path="parent")
instance.commit()
add_related_connection() line 3772 will add a new asset_in_asset with the code of src_sobject in parent_asset_code and line 3773 will add the code of dst_sobject to child_asset_code.
I found 3 problems with this:
1 - when you delete the parent asset it won't cascade to delete the related asset_in_asset entries because I found no way to tell tactic I want to use a specific path when deleting sObjects with include_dependencies=True so the delete operation will only use the second connection in the schema example and look only for entry where the deleted object is a child (child_asset_code)
2 - If you want to be able to use a "return" path like in
Code:
<connect from="mfe/asset_in_asset" to="mfe/asset" from_node="mfe/asset_in_asset" to_node="mfe/asset" relationship="code" from_col="child_asset_code" to_col="code" path="child" type="many_to_many"/>
it would be impossible because you would need a different "default" (without path) schema connection:
Code:
<connect from="mfe/asset_in_asset" to="mfe/asset" from_node="mfe/asset_in_asset" to_node="mfe/asset" relationship="code" from_col="parent_asset_code" to_col="code" type="many_to_many"/>
3 - There are few modifications needed to DropElementAction a DropElementWdg to make it work, I will make a PR to illustrate them.
If we want to make the self to self relationship to work properly there is more work to be done in search.py.
Remko, do you fell e better support for self to self is needed? Do want me to open an issue for this?