Skip to content

Commit

Permalink
Set empty opt14 nodeids to null, to fix conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
pieterbos committed Jan 4, 2021
1 parent 0f31c03 commit 14f4f66
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.nedap.archie.opt14;

import com.google.common.base.Strings;
import com.nedap.archie.aom.ArchetypeHRID;
import com.nedap.archie.aom.ArchetypeSlot;
import com.nedap.archie.aom.CArchetypeRoot;
Expand Down Expand Up @@ -28,16 +29,20 @@ public void convert(Template template, OPERATIONALTEMPLATE opt14) {

private CComplexObject convert(CCOMPLEXOBJECT cComplexObject14) {
CComplexObject cComplexObject = new CComplexObject();
cComplexObject.setNodeId(cComplexObject14.getNodeId());
cComplexObject.setRmTypeName(cComplexObject14.getRmTypeName());
cComplexObject.setOccurrences(BaseTypesConverter.convertMultiplicity(cComplexObject14.getOccurrences()));
setObjectBasics(cComplexObject14, cComplexObject);

for (CATTRIBUTE attribute14 : cComplexObject14.getAttributes()) {
cComplexObject.addAttribute(convert(attribute14));
}
return cComplexObject;
}

private void setObjectBasics(COBJECT cComplexObject14, CObject cComplexObject) {
cComplexObject.setNodeId(Strings.isNullOrEmpty(cComplexObject14.getNodeId()) ? null : cComplexObject14.getNodeId());
cComplexObject.setRmTypeName(cComplexObject14.getRmTypeName());
cComplexObject.setOccurrences(BaseTypesConverter.convertMultiplicity(cComplexObject14.getOccurrences()));
}

private CAttribute convert(CATTRIBUTE attribute14) {
CAttribute attribute = new CAttribute();
attribute.setRmAttributeName(attribute14.getRmAttributeName());
Expand Down Expand Up @@ -78,10 +83,8 @@ private CObject convert(COBJECT cobject14) {

private CObject convertSlot(ARCHETYPESLOT cobject14) {
ArchetypeSlot archetypeSlot = new ArchetypeSlot();
archetypeSlot.setNodeId(cobject14.getNodeId());
archetypeSlot.setRmTypeName(cobject14.getRmTypeName());
setObjectBasics(cobject14, archetypeSlot);

archetypeSlot.setOccurrences(BaseTypesConverter.convertMultiplicity(cobject14.getOccurrences()));
//TODO: assertions for include/exclude, should be straightforward
return archetypeSlot;
}
Expand All @@ -98,9 +101,7 @@ private CObject convertRoot(CARCHETYPEROOT cRoot14) {

CArchetypeRoot root = new CArchetypeRoot();
root.setArchetypeRef(overlay.getArchetypeId().getFullId());
root.setNodeId(cRoot14.getNodeId());
root.setOccurrences(BaseTypesConverter.convertMultiplicity(cRoot14.getOccurrences()));
root.setRmTypeName(cRoot14.getRmTypeName());
setObjectBasics(cRoot14, root);
return root;
}

Expand Down

0 comments on commit 14f4f66

Please sign in to comment.