-
Notifications
You must be signed in to change notification settings - Fork 24
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
base: master
Are you sure you want to change the base?
Changes from all commits
d600f02
3513d35
3776862
628c078
78b22c5
c83a563
8571a29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,10 @@ | |
import com.nedap.archie.rminfo.MetaModels; | ||
|
||
/** | ||
* 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 | ||
* with the correct values already present. | ||
* | ||
* <p> | ||
* Cardinality and existence are also specified to have a default value. However, this is not used | ||
* in practice (source, several openEHR community members). Adding that to the conversion would | ||
* lead to problems. So these are left out. | ||
|
@@ -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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
// however, in practice this is not followed, and adding it would | ||
// lead to more problems | ||
/* | ||
if(attribute.getCardinality() == null) { | ||
attribute.setCardinality(new Cardinality(0, 1)); | ||
} | ||
if(attribute.getExistence() == null) { | ||
attribute.setExistence(new MultiplicityInterval(1, 1)); | ||
}*/ | ||
for(CObject child:attribute.getChildren()) { | ||
if(child.getOccurrences() == null && | ||
metaModels.isMultiple(cObject.getRmTypeName(), attribute.getRmAttributeName())) { | ||
for (CAttribute attribute : cObject.getAttributes()) { | ||
for (CObject child : attribute.getChildren()) { | ||
if (child.getOccurrences() == null && metaModels.isMultiple(cObject.getRmTypeName(), attribute.getRmAttributeName())) { | ||
child.setOccurrences(new MultiplicityInterval(1, 1)); | ||
} | ||
correctItemsMultiplicities(child); | ||
|
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
|
||
/** | ||
* ADL 2 conversion result. Always has the archetypeId field set. | ||
* Either has archetype and conversionLog non-null in case of a succesful conversion, or | ||
* Either has archetype and conversionLog non-null in case of a successful conversion, or | ||
* exception non-null in case of an unexpected Exception | ||
*/ | ||
public class ADL2ConversionResult { | ||
|
@@ -18,24 +18,13 @@ public class ADL2ConversionResult { | |
private MessageLogger log; | ||
private Exception exception; | ||
|
||
/** | ||
* empty constructor for JSON parsing. Do not use | ||
*/ | ||
public ADL2ConversionResult() { | ||
|
||
/* Empty construction for Jackson parsing */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
} | ||
|
||
public ADL2ConversionResult(Archetype archetype) { | ||
this.archetypeId = archetype.getArchetypeId().getFullId(); | ||
this(archetype.getArchetypeId().getFullId(), null); | ||
this.archetype = archetype; | ||
log = new MessageLogger(); | ||
} | ||
|
||
public ADL2ConversionResult(Archetype archetype, ADL2ConversionLog conversionLog) { | ||
this.archetypeId = archetype.getArchetypeId().getFullId(); | ||
this.archetype = archetype; | ||
this.conversionLog = conversionLog; | ||
log = new MessageLogger(); | ||
} | ||
|
||
public ADL2ConversionResult(String archetypeId, Exception exception) { | ||
|
@@ -44,14 +33,11 @@ public ADL2ConversionResult(String archetypeId, Exception exception) { | |
log = new MessageLogger(); | ||
} | ||
|
||
/** GETTERS **/ | ||
public String getArchetypeId() { | ||
return archetypeId; | ||
} | ||
|
||
public void setArchetypeId(String archetypeId) { | ||
this.archetypeId = archetypeId; | ||
} | ||
|
||
public Archetype getArchetype() { | ||
return archetype; | ||
} | ||
|
@@ -60,14 +46,6 @@ public ADL2ConversionLog getConversionLog() { | |
return conversionLog; | ||
} | ||
|
||
public void setConversionLog(ADL2ConversionLog conversionLog) { | ||
this.conversionLog = conversionLog; | ||
} | ||
|
||
public void setArchetype(Archetype archetype) { | ||
this.archetype = archetype; | ||
} | ||
|
||
public MessageLogger getLog() { | ||
return log; | ||
} | ||
|
@@ -76,9 +54,12 @@ public Exception getException() { | |
return exception; | ||
} | ||
|
||
public void setException(Exception exception) { | ||
this.exception = exception; | ||
/** SETTERS **/ | ||
public void setArchetype(Archetype archetype) { | ||
this.archetype = archetype; | ||
} | ||
|
||
|
||
public void setConversionLog(ADL2ConversionLog conversionLog) { | ||
this.conversionLog = conversionLog; | ||
} | ||
} |
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.
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..*.