Skip to content
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

Reintroduce detail level system #943

Merged

Conversation

matt-hh
Copy link
Collaborator

@matt-hh matt-hh commented Sep 29, 2022

No description provided.

jhmegorei and others added 30 commits October 4, 2022 16:37
This class reimplements the logic from the ElementPermissionProxy.
As the name suggests, it only calculates the detail levels (more efficiently I think).
It does explicitly NOT include functionality to serialize elements.
This should be done separately (see ApplicationEntity#entity_for_level).
- anonymize_below: X -> anonymizes the field with a default string if the current detail level of the object is lower than X
- anonymize_with: Y -> uses Y as a replacement when a value gets anonymized
…ntend and the anonymization code was broken anyway
As we discussed, we will only use the simpler logic of nested_detail_levels,
based on the maximum configured level over all accessible collections.
This removes a lot of special cases (that were not required anyway).

Further optimization will be possible when the shared and synced collections
feature gets merged, so we only have one of those left.
jhmegorei and others added 19 commits October 5, 2022 09:03
When no detail levels are configured, 10 is returned for every requested class.
When detail levels are configured, every request for an unconfigured class returns 0, configured classes return their respective configuration.

This allows us to use simple hashes in our specs, instead of relying on the result of the ElementDetailLevelCalculator.
The spec tries to parse a Xlsx file generated by Axlsx using Roo.
The currently used Roo gem has a parser implementation that does not properly understand
the valid xml structure Axlsx generates, so the spec fails.

The newer version Roo 2.9.0 appears to have addressed this bug but requires Ruby 2.7 to run.
Until we complete the Rails 6 Upgrade, this spec is pending
@matt-hh matt-hh marked this pull request as ready for review October 13, 2022 12:15
@matt-hh matt-hh changed the title Reintroduce detail level system for reports Reintroduce Detail Level system Oct 13, 2022
@matt-hh matt-hh changed the title Reintroduce Detail Level system Reintroduce detail level system Oct 14, 2022
@PiTrem PiTrem merged commit 020e17b into ComPlat:development-5 Oct 18, 2022
mehreenmansur pushed a commit that referenced this pull request Dec 12, 2022
* Create infrastructure to configure Entities for different Detail Levels

* Introduce ElementDetailLevelCalculator

This class reimplements the logic from the ElementPermissionProxy.
As the name suggests, it only calculates the detail levels (more efficiently I think).
It does explicitly NOT include functionality to serialize elements.
This should be done separately (see ApplicationEntity#entity_for_level).

* Fix some lint issues

* Fix internal datastructure in ElementDetailLevelCalculator

* Fix bugs in ElementDetailLevelCalculator

* Add expose! method with additional features

- anonymize_below: X -> anonymizes the field with a default string if the current detail level of the object is lower than X
- anonymize_with: Y -> uses Y as a replacement when a value gets anonymized

* Some fixes

* Fix usage of with_options

* Fix specs

* Add specs for calculator and application entity

* Use with_options to make SampleEntity a little more readable

* Remove analyses field from sample entity as it is not used in the frontend and the anonymization code was broken anyway

* Introduce detail levels into WellplateEntity

* Introduce detail levels to WellEntity

* Fix well entity

* Fix anonymization bugs in SampleEntity

* Use expose! in WellplateEntity and fix some anonymizations

* Use expose! in WellEntity and fix double expose of readouts

* Rework ResearchPlanEntity a little, but it does not use anonymization anyway

* Introduce detail levels into Screen

* Fix syntax bug in ResearchPlanEntity

* Fix ElementDetailLevelCalculatorSpec

* Remove detail_level method from ElementDetailLevelCalculator

As we discussed, we will only use the simpler logic of nested_detail_levels,
based on the maximum configured level over all accessible collections.
This removes a lot of special cases (that were not required anyway).

Further optimization will be possible when the shared and synced collections
feature gets merged, so we only have one of those left.

* Reintroduce anonymization to ElementAPI

* Reintroduce anonymization to SampleAPI

* Reintroduce anonymization to ScreenAPI

* Reintroduce anonymization to SearchAPI

* Reintroduce anonymization to WellplateAPI

* Reintroduce anonymization to ResearchPlanAPI

* Reintroduce anonymization into ReactionAPI

* WIP find a better workflow to test entities

* Fix logic bug in ApplicationEntity that made anonymization options within with_options not work properly

* Add final spec for sample entity

* Add specs for 2 special cases

* Add specs for well entity

* Add specs for wellplate entity

* Fix some linter issues

* Fix more rubocop issues

* Fix rubocop issues in classes

* Add specs for screen entity

* Update ResearchPlanEntity

* Add anonymization to SampleReportEntity

* Refactor LiteratureEntity

* Make literatures method in SampleReportEntity private

* Fix invocation of ElementDetailLevelCalculator in ReactionAPI

* Inntroduce anonymization to ReactionEntity

* Add default for detail_levels in ElementDetailLevelCalculator

* Fix specs that broke after introducing anonymization

* Use expose! in ReactionMaterialEntity

* Introduce anonymization and analyses into ReactionMaterialReportEntity

* Fix syntax issue in SampleReportEntity

* Fix filenames of several spec files

* Prevent deprecation warnings about unsafe SQL strings

* Fix reporter specs for csv and html

* Raise exception when inkscape is not installed

* Rework ReactionReportEntity to include anonymization and inheritance from ReactionEntity

* Introduce anonymization into ElementEntity

* Reintroduce detail levels into GenericElementAPI

* Make PurificationSolvents available for DetailLevel0

* Add specs for research plan entity

* WIP Add specs for reaction

* Make usage of ApplicationEntity#detail_levels less error-prone

When no detail levels are configured, 10 is returned for every requested class.
When detail levels are configured, every request for an unconfigured class returns 0, configured classes return their respective configuration.

This allows us to use simple hashes in our specs, instead of relying on the result of the ElementDetailLevelCalculator.

* Unify usage of expose! in ReactionMaterialEntity

* Set Reporter::Xlsx::ReactionList spec to pending

The spec tries to parse a Xlsx file generated by Axlsx using Roo.
The currently used Roo gem has a parser implementation that does not properly understand
the valid xml structure Axlsx generates, so the spec fails.

The newer version Roo 2.9.0 appears to have addressed this bug but requires Ruby 2.7 to run.
Until we complete the Rails 6 Upgrade, this spec is pending

* Add reaction entity spec

* Add spec for sample report spec

* Reintroduce Detail levels to some more codepaths

* Fix reaction material Entity to display analyses properly

* Remove fcontext and binding.pry

* Add ci image with inkscape dependency

* Fix ci image again

* Add a working ci image

* Fix spec

* Disable spec with missing dependency

Co-authored-by: Johannes Haubold <jh@megorei.com>
TasnimMehzabin pushed a commit that referenced this pull request Mar 24, 2023
* Create infrastructure to configure Entities for different Detail Levels

* Introduce ElementDetailLevelCalculator

This class reimplements the logic from the ElementPermissionProxy.
As the name suggests, it only calculates the detail levels (more efficiently I think).
It does explicitly NOT include functionality to serialize elements.
This should be done separately (see ApplicationEntity#entity_for_level).

* Fix some lint issues

* Fix internal datastructure in ElementDetailLevelCalculator

* Fix bugs in ElementDetailLevelCalculator

* Add expose! method with additional features

- anonymize_below: X -> anonymizes the field with a default string if the current detail level of the object is lower than X
- anonymize_with: Y -> uses Y as a replacement when a value gets anonymized

* Some fixes

* Fix usage of with_options

* Fix specs

* Add specs for calculator and application entity

* Use with_options to make SampleEntity a little more readable

* Remove analyses field from sample entity as it is not used in the frontend and the anonymization code was broken anyway

* Introduce detail levels into WellplateEntity

* Introduce detail levels to WellEntity

* Fix well entity

* Fix anonymization bugs in SampleEntity

* Use expose! in WellplateEntity and fix some anonymizations

* Use expose! in WellEntity and fix double expose of readouts

* Rework ResearchPlanEntity a little, but it does not use anonymization anyway

* Introduce detail levels into Screen

* Fix syntax bug in ResearchPlanEntity

* Fix ElementDetailLevelCalculatorSpec

* Remove detail_level method from ElementDetailLevelCalculator

As we discussed, we will only use the simpler logic of nested_detail_levels,
based on the maximum configured level over all accessible collections.
This removes a lot of special cases (that were not required anyway).

Further optimization will be possible when the shared and synced collections
feature gets merged, so we only have one of those left.

* Reintroduce anonymization to ElementAPI

* Reintroduce anonymization to SampleAPI

* Reintroduce anonymization to ScreenAPI

* Reintroduce anonymization to SearchAPI

* Reintroduce anonymization to WellplateAPI

* Reintroduce anonymization to ResearchPlanAPI

* Reintroduce anonymization into ReactionAPI

* WIP find a better workflow to test entities

* Fix logic bug in ApplicationEntity that made anonymization options within with_options not work properly

* Add final spec for sample entity

* Add specs for 2 special cases

* Add specs for well entity

* Add specs for wellplate entity

* Fix some linter issues

* Fix more rubocop issues

* Fix rubocop issues in classes

* Add specs for screen entity

* Update ResearchPlanEntity

* Add anonymization to SampleReportEntity

* Refactor LiteratureEntity

* Make literatures method in SampleReportEntity private

* Fix invocation of ElementDetailLevelCalculator in ReactionAPI

* Inntroduce anonymization to ReactionEntity

* Add default for detail_levels in ElementDetailLevelCalculator

* Fix specs that broke after introducing anonymization

* Use expose! in ReactionMaterialEntity

* Introduce anonymization and analyses into ReactionMaterialReportEntity

* Fix syntax issue in SampleReportEntity

* Fix filenames of several spec files

* Prevent deprecation warnings about unsafe SQL strings

* Fix reporter specs for csv and html

* Raise exception when inkscape is not installed

* Rework ReactionReportEntity to include anonymization and inheritance from ReactionEntity

* Introduce anonymization into ElementEntity

* Reintroduce detail levels into GenericElementAPI

* Make PurificationSolvents available for DetailLevel0

* Add specs for research plan entity

* WIP Add specs for reaction

* Make usage of ApplicationEntity#detail_levels less error-prone

When no detail levels are configured, 10 is returned for every requested class.
When detail levels are configured, every request for an unconfigured class returns 0, configured classes return their respective configuration.

This allows us to use simple hashes in our specs, instead of relying on the result of the ElementDetailLevelCalculator.

* Unify usage of expose! in ReactionMaterialEntity

* Set Reporter::Xlsx::ReactionList spec to pending

The spec tries to parse a Xlsx file generated by Axlsx using Roo.
The currently used Roo gem has a parser implementation that does not properly understand
the valid xml structure Axlsx generates, so the spec fails.

The newer version Roo 2.9.0 appears to have addressed this bug but requires Ruby 2.7 to run.
Until we complete the Rails 6 Upgrade, this spec is pending

* Add reaction entity spec

* Add spec for sample report spec

* Reintroduce Detail levels to some more codepaths

* Fix reaction material Entity to display analyses properly

* Remove fcontext and binding.pry

* Add ci image with inkscape dependency

* Fix ci image again

* Add a working ci image

* Fix spec

* Disable spec with missing dependency

Co-authored-by: Johannes Haubold <jh@megorei.com>
baolanlequang pushed a commit that referenced this pull request Mar 5, 2024
* Create infrastructure to configure Entities for different Detail Levels

* Introduce ElementDetailLevelCalculator

This class reimplements the logic from the ElementPermissionProxy.
As the name suggests, it only calculates the detail levels (more efficiently I think).
It does explicitly NOT include functionality to serialize elements.
This should be done separately (see ApplicationEntity#entity_for_level).

* Fix some lint issues

* Fix internal datastructure in ElementDetailLevelCalculator

* Fix bugs in ElementDetailLevelCalculator

* Add expose! method with additional features

- anonymize_below: X -> anonymizes the field with a default string if the current detail level of the object is lower than X
- anonymize_with: Y -> uses Y as a replacement when a value gets anonymized

* Some fixes

* Fix usage of with_options

* Fix specs

* Add specs for calculator and application entity

* Use with_options to make SampleEntity a little more readable

* Remove analyses field from sample entity as it is not used in the frontend and the anonymization code was broken anyway

* Introduce detail levels into WellplateEntity

* Introduce detail levels to WellEntity

* Fix well entity

* Fix anonymization bugs in SampleEntity

* Use expose! in WellplateEntity and fix some anonymizations

* Use expose! in WellEntity and fix double expose of readouts

* Rework ResearchPlanEntity a little, but it does not use anonymization anyway

* Introduce detail levels into Screen

* Fix syntax bug in ResearchPlanEntity

* Fix ElementDetailLevelCalculatorSpec

* Remove detail_level method from ElementDetailLevelCalculator

As we discussed, we will only use the simpler logic of nested_detail_levels,
based on the maximum configured level over all accessible collections.
This removes a lot of special cases (that were not required anyway).

Further optimization will be possible when the shared and synced collections
feature gets merged, so we only have one of those left.

* Reintroduce anonymization to ElementAPI

* Reintroduce anonymization to SampleAPI

* Reintroduce anonymization to ScreenAPI

* Reintroduce anonymization to SearchAPI

* Reintroduce anonymization to WellplateAPI

* Reintroduce anonymization to ResearchPlanAPI

* Reintroduce anonymization into ReactionAPI

* WIP find a better workflow to test entities

* Fix logic bug in ApplicationEntity that made anonymization options within with_options not work properly

* Add final spec for sample entity

* Add specs for 2 special cases

* Add specs for well entity

* Add specs for wellplate entity

* Fix some linter issues

* Fix more rubocop issues

* Fix rubocop issues in classes

* Add specs for screen entity

* Update ResearchPlanEntity

* Add anonymization to SampleReportEntity

* Refactor LiteratureEntity

* Make literatures method in SampleReportEntity private

* Fix invocation of ElementDetailLevelCalculator in ReactionAPI

* Inntroduce anonymization to ReactionEntity

* Add default for detail_levels in ElementDetailLevelCalculator

* Fix specs that broke after introducing anonymization

* Use expose! in ReactionMaterialEntity

* Introduce anonymization and analyses into ReactionMaterialReportEntity

* Fix syntax issue in SampleReportEntity

* Fix filenames of several spec files

* Prevent deprecation warnings about unsafe SQL strings

* Fix reporter specs for csv and html

* Raise exception when inkscape is not installed

* Rework ReactionReportEntity to include anonymization and inheritance from ReactionEntity

* Introduce anonymization into ElementEntity

* Reintroduce detail levels into GenericElementAPI

* Make PurificationSolvents available for DetailLevel0

* Add specs for research plan entity

* WIP Add specs for reaction

* Make usage of ApplicationEntity#detail_levels less error-prone

When no detail levels are configured, 10 is returned for every requested class.
When detail levels are configured, every request for an unconfigured class returns 0, configured classes return their respective configuration.

This allows us to use simple hashes in our specs, instead of relying on the result of the ElementDetailLevelCalculator.

* Unify usage of expose! in ReactionMaterialEntity

* Set Reporter::Xlsx::ReactionList spec to pending

The spec tries to parse a Xlsx file generated by Axlsx using Roo.
The currently used Roo gem has a parser implementation that does not properly understand
the valid xml structure Axlsx generates, so the spec fails.

The newer version Roo 2.9.0 appears to have addressed this bug but requires Ruby 2.7 to run.
Until we complete the Rails 6 Upgrade, this spec is pending

* Add reaction entity spec

* Add spec for sample report spec

* Reintroduce Detail levels to some more codepaths

* Fix reaction material Entity to display analyses properly

* Remove fcontext and binding.pry

* Add ci image with inkscape dependency

* Fix ci image again

* Add a working ci image

* Fix spec

* Disable spec with missing dependency

Co-authored-by: Johannes Haubold <jh@megorei.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants