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

Cleanup ADL14Converter code #648

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Cleanup ADL14Converter code #648

wants to merge 7 commits into from

Conversation

VeraPrinsen
Copy link
Collaborator

@VeraPrinsen VeraPrinsen commented Dec 17, 2024

Before I'm going to add anything new to the ADL14Converter code, I wanted to cleanup the code a little.

  • Empty if statements have been removed
  • Removed unused code
  • Added documentation to methods to describe what they do
  • Optimised imports
  • Ran the 'Reformat code' to make code more readable (Adds a space in: if(CObject object..... for example

@@ -153,15 +136,18 @@ private List<String> findUnnecessaryCodes(CObject cObject, Map<String, Archetype
return result;
}

/**
* Replace old id's in term definition with the new codes
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

One line 156-161, it seems that there is a bug, because the newTerm variable is never used, so I expect that needed to be used on line 161 instead just 'term'. But I don't want to change any functionality in this PR. Might look at this later.

Copy link

codecov bot commented Dec 17, 2024

Codecov Report

Attention: Patch coverage is 74.62687% with 34 lines in your changes missing coverage. Please review.

Project coverage is 72.01%. Comparing base (eb7b43d) to head (8571a29).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...a/com/nedap/archie/adl14/ADL14NodeIDConverter.java 73.43% 4 Missing and 13 partials ⚠️
...in/java/com/nedap/archie/adl14/ADL14Converter.java 65.21% 2 Missing and 6 partials ⚠️
.../nedap/archie/adl14/DefaultRmStructureRemover.java 65.00% 2 Missing and 5 partials ⚠️
.../archie/aom/utils/ArchetypeParsePostProcessor.java 86.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #648      +/-   ##
============================================
+ Coverage     71.96%   72.01%   +0.04%     
+ Complexity     7071     7069       -2     
============================================
  Files           671      671              
  Lines         23056    23037      -19     
  Branches       3745     3745              
============================================
- Hits          16592    16589       -3     
+ Misses         4717     4703      -14     
+ Partials       1747     1745       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@VeraPrinsen VeraPrinsen self-assigned this Dec 17, 2024
* Sets the default occurrences with ADL 1.4 rules, if not explicitly set in a given Archetype.
* Useful for conversion to ADL 2, where the default values are different, and it is good to start
* Sets the default occurrences with ADL 1.4 rules ({1..1}), if not explicitly set in a given Archetype.
* Useful for conversion to ADL 2, where the default values are different ({0..*}), and it is good to start
Copy link
Collaborator

@pieterbos pieterbos Dec 17, 2024

Choose a reason for hiding this comment

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

they are not {0..*} default - they are whatever is in the reference model for that property. Which can be one of at least 0..1, 1..1, 0..* or 1..*.

@@ -31,20 +31,9 @@ public void setDefaults(Archetype archetype) {
}

private void correctItemsMultiplicities(CObject cObject) {
for(CAttribute attribute:cObject.getAttributes()) {
// according to the specification, the following lines must be added.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Has this been removed from the specification? Otherwise it is a valid comment.

public ADL2ConversionResult() {

/* Empty construction for Jackson parsing */
Copy link
Collaborator

Choose a reason for hiding this comment

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

You have moved javadoc comments, which are actually converted to documentation on the build, to an internal comment. That does not seem like a good idea, as the javadoc will no longer list that this constructor should not be used.

*
* @param existingRepository the existing repository to use
*/
public void setExistingRepository(InMemoryFullArchetypeRepository existingRepository) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I do not think it is not a good idea to remove this. It may be unused in Archie at the moment, but is necessary if you are converting OPTs, for example. It is part of the public API of Archie.

Copy link
Collaborator

Choose a reason for hiding this comment

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

correctItemsCardinality(archetype.getDefinition());
List<String> unnecessaryCodes = findUnnecessaryCodes(archetype.getDefinition(),
archetype.getTerminology().getTermDefinitions().get(archetype.getOriginalLanguage().getCodeString()));
convert(archetype.getDefinition());
if(previousConversionApplier != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can actually start a conversion without having a previous conversion. It should thus be part of the API, or the readme needs an update on how to initialize this as an empty converter. Making the API call more difficult.

So why was this null-check removed?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The archetype languege server does not support storing previous conversion, so does never set a previous conversion applier, for example. Please do not remove.

Copy link
Collaborator

@pieterbos pieterbos left a comment

Choose a reason for hiding this comment

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

Good start for a cleanup. however, I think you removed a bit too much - this harms the public API in several places. At least:

  • if no previous conversion has been added, it does not make sense to upply a previous conversion applier. You could in that case initialize it to something that does not perform any operation, if you do not want a null check.
  • the existing repository is very useful to have, if you want to convert in steps instead of all in one go. It should not be removed. For example, if you have converted 10 archetypes before, and someone supplies a new ADL 1.4 repository, you can use it to convert only the new file - and keep the previously converted ADL 2 results as input.

See individual comments for some more minor things.

@pieterbos
Copy link
Collaborator

Please check against at least the archetype language server that you can make it work again with the API changes. Unused code in Archie does not mean unused code, if it is part of the public API.

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.

2 participants