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

Refactor P_BMM implementation #68

Merged
merged 35 commits into from
Jan 31, 2019
Merged

Refactor P_BMM implementation #68

merged 35 commits into from
Jan 31, 2019

Conversation

pieterbos
Copy link
Collaborator

@pieterbos pieterbos commented Nov 27, 2018

  • Full new P_BMM implementation, bound directly to jackson, with stricter validation on field names
  • removed quite a lot of hard to understand spaghetti-code.
  • removed all state from P_BMM implementation, apart from sourceSchemaId
  • cleaned up a lot of code, removed hard to debug lambda's with simple for-loops, split up classes into separate smaller ones, split up methods into separate smaller ones, rewrote hard to read algorithms into simpler ones, rewrote some directly ported Eiffel-code into something more javaesque.
  • Introduced BmmRepository instead of ReferenceModelAccess that is just a simple repository. Perhaps rename to BmmModelAccess since it does sort of the same, but cleaner/simpler.
    • no more dependence on files - supply your own IO!
  • introduced BmmValidationResult. Perhaps should be renamed to BmmSchema again, but that would introduce a hard link between BMM and P_BMM.
  • decoupled validation and conversion from the models, so we can create BMM v3 separately from the P_BMM implementation.
  • replaced all default usage in archie with the new model, although ReferenceModelAccess can still be used

TODO:

  • happy flow integration tests with quite a lot of BMM models

  • Discuss with @cnanjo . Hi :)

  • Implement generic ODIN serializer with Jackson

    • use to serializer BMM
    • replace custom mapper in ADL with generic ODIN object mapper (yay, can throw away code!)
  • Reintroduce a cyclic include check to solve possible infinite loop.

  • implement ancestor_defs instead of just ancestor - note that this did not work in the deprecated P_BMM implementation. Converted to BMM 2.0, so some information in the model is lost

  • change use of case insensitive treemaps into case insensitive order preserving maps.

  • update readme with documentation about BMM and ODIN

  • deprecate the old P_BMM implementation

  • error flow tests

  • probably some cleanup after review

Optional, or for a later change:

  • integrate object mapper with integrated automatic ODIN => JSON conversion and parsing?
  • probably some more javadoc?
  • unit tests of the separate validators/converters?

Note: the base branch for this PR is the construct_example_json branch. Was much easier to do this with the ExampleJsonInstanceGenerator in place, because it does quite a lot of testing of the BMM. That one should probably be merged first into master before this one.

@pieterbos pieterbos changed the title Bmm jackson Refactor P_BMM implementation Nov 27, 2018
@codecov-io
Copy link

codecov-io commented Dec 18, 2018

Codecov Report

Merging #68 into master will increase coverage by 0.94%.
The diff coverage is 74.45%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #68      +/-   ##
============================================
+ Coverage     69.11%   70.06%   +0.94%     
- Complexity     4635     5283     +648     
============================================
  Files           554      616      +62     
  Lines         16153    18103    +1950     
  Branches       2261     2585     +324     
============================================
+ Hits          11164    12683    +1519     
- Misses         3932     4255     +323     
- Partials       1057     1165     +108
Impacted Files Coverage Δ Complexity Δ
...ce/serializer/BmmEnumerationIntegerSerializer.java 71.42% <ø> (ø) 3 <0> (ø) ⬇️
...enehr/bmm/persistence/PersistedBmmGenericType.java 74.24% <ø> (ø) 18 <0> (ø) ⬇️
...rg/openehr/bmm/persistence/PersistedBmmSchema.java 72.83% <ø> (ø) 99 <0> (ø) ⬇️
...g/openehr/bmm/persistence/PersistedBmmPackage.java 88.05% <ø> (ø) 22 <0> (ø) ⬇️
...ce/deserializer/BmmSinglePropertyDeserializer.java 100% <ø> (ø) 3 <0> (ø) ⬇️
...persistence/deserializer/BmmClassDeserializer.java 100% <ø> (ø) 8 <0> (ø) ⬇️
.../deserializer/BmmGenericParameterDeserializer.java 100% <ø> (ø) 4 <0> (ø) ⬇️
...sistence/deserializer/BmmOpenTypeDeserializer.java 0% <ø> (ø) 0 <0> (ø) ⬇️
...mm/persistence/serializer/BmmSchemaSerializer.java 0% <ø> (ø) 0 <0> (ø) ⬇️
...ain/java/com/nedap/archie/aom/LanguageSection.java 100% <ø> (ø) 5 <0> (ø) ⬇️
... and 241 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2584df4...1ce7560. Read the comment docs.

@pieterbos pieterbos changed the base branch from construct_example_json to master January 21, 2019 14:53
Copy link
Collaborator

@steijgeler steijgeler left a comment

Choose a reason for hiding this comment

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

A lot more readable than the previous implementation, but difficult for me to say there are no issues anywhere. I couldn't find any anyway. Most things have tests, and the validation and conversion of the openehr rm 102 are all passing and have been checked manually.

Some documentation could be improved, especially the BmmSchemaConverter. Could you also go over the TODO's? Some can be removed it seems to me. Apart from that this looks good 👍

//
// if (!archetype.getTranslations().isEmpty()) {
// language.put("translations", archetype.getTranslations());
// }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this be removed?

public class UniqueSchemaIdValidation implements BmmValidation {
@Override
public void validate(BmmValidationResult validationResult, BmmRepository repository, MessageLogger logger, PBmmSchema schema) {
//TODO:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please either remove this validation, or describe what has to be done. I assume there is as reason why you haven't implemented this, but it is not clear to me

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll remove it - it's not possible to have non-unique schema ids in this stage, the repository will overwrite any you try to add.


createModelsByClosureAndVersion(result);

return result;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe there is still some spaghetti here. Validation and converter steps are a bit intertwined, some steps are hidden within other steps, and documentation could be better. It is a lot better compared to what we had previously though, so kudos for that! If we do run into validation errors now, it should undoubtedly be easier to spot what they are.

If you could add a little more documentation right here of what each step does, should already add a lot more clarity. For example about what the preprocessin, descendantsCalculator and createModelsByClosureAndVersion does, or what is actually returned

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes there is. Some of the validations can only be easily run after part of the conversion, that's why it's intertwined. Could be fixed, but lots of complicated code, so I left it. I'll see if I can write some comments :)

@JsonIgnore
public PBmmBaseType getTypeRef() {
if(typeDef == null && type != null) {
if(type.length() == 1) {//TODO!!!!: ?!?!?! Probably a parameter such as "T"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Confusing TODO ;) Does something have to be fixed here, or are you just unsure when this case would be met?

@pieterbos pieterbos merged commit 7e5d075 into master Jan 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants