allow templates access to resource-block referenced by a block-copy
This commit is contained in:
parent
28ed425d6b
commit
67aee59f0f
|
@ -2,5 +2,17 @@ package ca.uhn.fhir.tinder.model;
|
|||
|
||||
public class ResourceBlockCopy extends Child {
|
||||
|
||||
private ResourceBlock referencedBlock = null;
|
||||
|
||||
@Override
|
||||
public boolean isBlockRef() {
|
||||
return referencedBlock != null;
|
||||
}
|
||||
|
||||
public ResourceBlock getReferencedBlock () {
|
||||
return this.referencedBlock;
|
||||
}
|
||||
public void setReferencedBlock (ResourceBlock referencedBlock) {
|
||||
this.referencedBlock = referencedBlock;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,6 +127,7 @@ public abstract class BaseStructureSpreadsheetParser extends BaseStructureParser
|
|||
// HashMap<String,String>();
|
||||
|
||||
Map<String, List<String>> pathToResourceTypes = new HashMap<String, List<String>>();
|
||||
List<Child> blockCopies = new ArrayList<Child>();
|
||||
for (int i = 2; i < rows.getLength(); i++) {
|
||||
Element nextRow = (Element) rows.item(i);
|
||||
String name = cellValue(nextRow, 0);
|
||||
|
@ -152,6 +153,7 @@ public abstract class BaseStructureSpreadsheetParser extends BaseStructureParser
|
|||
} else if (type.startsWith("@")) {
|
||||
// type = type.substring(type.lastIndexOf('.')+1);
|
||||
elem = new ResourceBlockCopy();
|
||||
blockCopies.add(elem);
|
||||
} else if (type.equals("*")) {
|
||||
elem = new AnyChild();
|
||||
} else {
|
||||
|
@ -198,6 +200,26 @@ public abstract class BaseStructureSpreadsheetParser extends BaseStructureParser
|
|||
// }
|
||||
// }
|
||||
|
||||
// resolve BlockCopy elements so they can access
|
||||
// the children of the referenced ResourceBlock
|
||||
// from Velocity templates.
|
||||
for (Child blockCopy : blockCopies) {
|
||||
BaseElement element = blockCopy;
|
||||
refLoop:
|
||||
while (element.getElementParentName() != null) {
|
||||
BaseElement parent = elements.get(element.getElementParentName());
|
||||
List<BaseElement> children = parent.getChildren();
|
||||
for (BaseElement child : children) {
|
||||
if (!child.equals(blockCopy) && child instanceof ResourceBlock
|
||||
&& child.getElementName().equals(blockCopy.getElementName())) {
|
||||
((ResourceBlockCopy)blockCopy).setReferencedBlock((ResourceBlock)child);
|
||||
break refLoop;
|
||||
}
|
||||
}
|
||||
element = parent;
|
||||
}
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
|
|
|
@ -136,6 +136,8 @@
|
|||
<includeResources>
|
||||
<includeResource>patient</includeResource>
|
||||
<includeResource>organization</includeResource>
|
||||
<includeResource>bundle</includeResource>
|
||||
<includeResource>composition</includeResource>
|
||||
</includeResources>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
|
@ -45,6 +45,7 @@ ${lead} referenceTypesForMultiple: $!{child.referenceTypesForMultiple}
|
|||
${lead} singleType: $!{child.singleType}
|
||||
${lead} variableName: $!{child.variableName}
|
||||
${lead} isBlock: $!{child.block}
|
||||
${lead} isBlockRef: $!{child.blockRef}
|
||||
${lead} isPrimitive: $!{child.primitive}
|
||||
${lead} primitiveType: #{if}(${child.primitive})$!{child.primitiveType}#{end} .
|
||||
${lead} isBoundCode: $!{child.boundCode}
|
||||
|
|
Loading…
Reference in New Issue