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 {
|
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>();
|
// HashMap<String,String>();
|
||||||
|
|
||||||
Map<String, List<String>> pathToResourceTypes = new HashMap<String, List<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++) {
|
for (int i = 2; i < rows.getLength(); i++) {
|
||||||
Element nextRow = (Element) rows.item(i);
|
Element nextRow = (Element) rows.item(i);
|
||||||
String name = cellValue(nextRow, 0);
|
String name = cellValue(nextRow, 0);
|
||||||
|
@ -152,6 +153,7 @@ public abstract class BaseStructureSpreadsheetParser extends BaseStructureParser
|
||||||
} else if (type.startsWith("@")) {
|
} else if (type.startsWith("@")) {
|
||||||
// type = type.substring(type.lastIndexOf('.')+1);
|
// type = type.substring(type.lastIndexOf('.')+1);
|
||||||
elem = new ResourceBlockCopy();
|
elem = new ResourceBlockCopy();
|
||||||
|
blockCopies.add(elem);
|
||||||
} else if (type.equals("*")) {
|
} else if (type.equals("*")) {
|
||||||
elem = new AnyChild();
|
elem = new AnyChild();
|
||||||
} else {
|
} 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++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,6 +136,8 @@
|
||||||
<includeResources>
|
<includeResources>
|
||||||
<includeResource>patient</includeResource>
|
<includeResource>patient</includeResource>
|
||||||
<includeResource>organization</includeResource>
|
<includeResource>organization</includeResource>
|
||||||
|
<includeResource>bundle</includeResource>
|
||||||
|
<includeResource>composition</includeResource>
|
||||||
</includeResources>
|
</includeResources>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
|
|
@ -45,6 +45,7 @@ ${lead} referenceTypesForMultiple: $!{child.referenceTypesForMultiple}
|
||||||
${lead} singleType: $!{child.singleType}
|
${lead} singleType: $!{child.singleType}
|
||||||
${lead} variableName: $!{child.variableName}
|
${lead} variableName: $!{child.variableName}
|
||||||
${lead} isBlock: $!{child.block}
|
${lead} isBlock: $!{child.block}
|
||||||
|
${lead} isBlockRef: $!{child.blockRef}
|
||||||
${lead} isPrimitive: $!{child.primitive}
|
${lead} isPrimitive: $!{child.primitive}
|
||||||
${lead} primitiveType: #{if}(${child.primitive})$!{child.primitiveType}#{end} .
|
${lead} primitiveType: #{if}(${child.primitive})$!{child.primitiveType}#{end} .
|
||||||
${lead} isBoundCode: $!{child.boundCode}
|
${lead} isBoundCode: $!{child.boundCode}
|
||||||
|
|
Loading…
Reference in New Issue