-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adapter refactoring Level 04 #164
Conversation
…Only`, `DependenciesCreateOnly`, `DependenciesUpdateOnly`
…rence (does not return a new List)
There is not a single use case where they are used with non-IBHoMObjects anyway. This clarifies that they are meant to be implemented as part as the full CRUD
…ss name. #163 No need to store its value as a hard-coded value somewhere, like "Robot_id". The initialisation had to be done inside a new BHoMAdapter constructor, because the identifier `this` is not available in the auto-property initialisers.
… 2) Added ActionConfig global property and logic to reset it at the start of each AdapterAction (except Move).
…now in BHoM_UI (except for the Move, which must have it here)
- UpdateTags is not a CRUD method because there is no CRUD action involved; it's only used to update (if existing) a collection of tags to be stored in a private field of the specific adapter. Moved in new folder "SupportMethods". - MapSpecialProperties might end up in "SupportMethods" too - Refactored the Push to allow for AdapterSettings to be overridden with more ActionConfig, especially for the PushType - Added a PushType for `DeleteAllThenCreate` that should clean the exported model and then create stuff in it. - Added method in FullCRUD that does the previous. Uses the DiffingEngine "HashComparing", but only to avoid Deleting and then Creating the same stuff. - MapSpecialProperties must be abstracted more. Renamed as `PortProperties`. Added generic method that does the same thing, but for any object and given a propertyName. - When the new PortProperties is called by the adapter, specific adapter implementation can say what properties should be ported. This work has to be finished.
// Performs a Pull and then a Push. Useful to move data between two different software without passing it through the UI. | ||
public virtual bool Move(BHoMAdapter to, IRequest request, Dictionary<string, object> pullConfig = null, Dictionary<string, object> pushConfig = null) | ||
[Description("Performs a Pull and then a Push. Useful to move data between two different software without passing it through the UI.")] | ||
public virtual bool Move(IBHoMAdapter to, IRequest request, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel that this is actually a copy
rather than a move
at this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a big refactoring! I felt it made the HTTPAdapter simpler when amending the code do comply with this.
Some observations I made with @alelom while reviewing this.
The come with a green tick because I believe the best time to do these is in the next wave.
- When performing an action, like a
Push
or aPull
, I feel that the information to include are sparser than they can be. I.e.PullType
can be a property of theActionConfig
. This takes us to specifty theActionConfig
intoPullConfig
,PushConfig
,ExecuteConfig
,MoveConfig
, andRemoveConfig
. They all inherit fromActionConfig
. All of this allows to keep the information more compressed and I feel that's more intuitive. - In the light of 1., the
ActionConfig
can be removed from theCreate
, as it is never used. - I never know if to override the
Pull
or theRead
or any other one, when I need to perform a task. I prefer to be channeled to override only one or the other, otherwise the implementer is completely lost in there. My suggestion is to use the pattern Grasshopper uses for the component. To disable the override of aPull
or aPush
, and add two functionsBeforeAction
andAfterAction
, the same way Grasshopper implementsBeforeSolveInstance
andAfterSolveIntance
. This way if you need to wrap your objects aroundBHoMObject
s or anything else, you can override these two.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the tests I have run on my toolkits as part of the refactoring process, this is good to me. I have not reviewed the code but can see from comments that others have.
This is really a good suggestion! It would simplify things. However, we must also consider that overriding the "core" action might be needed in some cases, as brought up by @adecler. |
/azp run BHoM_Adapter.CheckInstaller |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to approve this. Tested on a number of different Adapter_Toolkits.
And in addition approval based on the very valuable restructuring of the Adapter itself, and the successful passing reviews on the many dependant PRs.
Alignment instructions
https://github.com/BHoM/BHoM_Adapter/wiki/BHoM_Adapter-refactoring-Level-04-alignment-instructions
NOTE: DEPENDS ON
BHoM/BHoM_Engine#1371
NOTE: BRANCHES DEPENDANT ON THIS (needed for testing)
BHoM/BHoM_UI#167
If you use Grasshopper: Aligning with changes in BHoMAdapter Refactoring Level 04 Grasshopper_UI#440
If you use Excel: https://github.com/BHoM/Excel_Toolkit/pull/172
If you use Dynamo: Aligning with changes in BHoMAdapter Refactoring Level 04 Dynamo_UI#188
If your Toolkit needs Socket_Toolkit: Aligning with changes in BHoMAdapter Refactoring Level 04 Socket_Toolkit#57
If your Toolkit needs Mongo_Toolkit: Aligning with changes in BHoMAdapter Refactoring Level 04 Mongo_Toolkit#82
If you want your test scripts to get their Adapter components to be automatically upgraded to their new version: Adding support for method upgrade Versioning_Toolkit#8
Issues addressed by this PR
Changes on Config and Settings: Closes #45 Closes #108
Changes on Delete action: Closes #138 Closes #156
Retrocompatibility: Closes #158
MapSpecialProperties: Closes #168
Project and folders rearrangements/tidy up: Closes #170, Closes #169, Closes #171
Test files
Test files for specific Toolkits to be found in their related alignment PR.
At the moment, you can only find GSA: BHoM/GSA_Toolkit#130
Changelog
config Dictionary<string,object>
input for all Adapter Actions with a new classActionConfig
. It contains configs common to all Toolkits. It can be inherited in specific Toolkits to create other adapter-specific Configs.CopyBHoMObjectProperties
that copies only IBHoMObject basic properties over;ICopyTypeSpecificProperties
that's meant to copy type specific properties. Specific implementation of that must be done in specific Toolkits.PushType
(and PullType) enum. Allow to select the type of Push being done (FullCRUD, DeleteThenCreate, CreateOnly, etc).DeleteThenCreate