fix/enhance tinder-tests for new functions

This commit is contained in:
Bill Denton 2016-12-06 11:26:24 -08:00
parent 698c21c6c1
commit 1452a29a09
8 changed files with 322 additions and 88 deletions

View File

@ -57,7 +57,7 @@ import ca.uhn.fhir.tinder.parser.TargetType;
* <td valign="top">generateResources</td>
* <td valign="top">Should files be generated from FHIR resource metadata?<br>
* Valid values:&nbsp;<code><b>true</b></code>&nbsp;|&nbsp;<code><b>false</b></code></td>
* <td valign="top" align="center" rowspan="4">At least one of these four options must be specified</td>
* <td valign="top" align="center" rowspan="4">One of these four options must be specified</td>
* </tr>
* <tr>
* <td valign="top">generateDataTypes</td>
@ -82,9 +82,9 @@ import ca.uhn.fhir.tinder.parser.TargetType;
* for FHIR resources or composite data types. There is one file
* generated for each selected entity. The following configuration
* properties control the naming of the generated source files:<br>
* &nbsp;&nbsp;&nbsp;&nbsp;&lt;targetSourceDirectory&gt;/&lt;packageName&gt;/&lt;filenamePrefix&gt;<i>element-name</i>&lt;filenameSuffix&gt;<br>
* &nbsp;&nbsp;&nbsp;&nbsp;&lt;targetSourceDirectory&gt;/&lt;targetPackage&gt;/&lt;filenamePrefix&gt;<i>element-name</i>&lt;filenameSuffix&gt;<br>
* where: <i>element-name</i> is the "title-case" name of the selected resource or composite data type.<br>
* Note that all dots in the packageName will be replaced by the path separator character when building the
* Note that all dots in the targetPackage will be replaced by the path separator character when building the
* actual source file location. Also note that <code>.java</code> will be added to the filenameSuffix if it is not already included.
* </td>
* </tr>
@ -94,7 +94,7 @@ import ca.uhn.fhir.tinder.parser.TargetType;
* <td valign="top" align="center">Yes when Java source files are to be generated</td>
* </tr>
* <tr>
* <td valign="top">packageName</td>
* <td valign="top">targetPackage</td>
* <td valign="top">The Java package that will contain the generated classes.
* This package is generated in the &lt;targetSourceDirectory&gt; if needed.</td>
* <td valign="top" align="center">Yes when <i>targetSourceDirectory</i> is specified</td>
@ -119,7 +119,7 @@ import ca.uhn.fhir.tinder.parser.TargetType;
* <td valign="top" colspan="3">Maven resource files can also be generated
* for FHIR resources or composite data types. The following configuration
* properties control the naming of the generated resource files:<br>
* &nbsp;&nbsp;&nbsp;&nbsp;&lt;targetResourceDirectory&gt;/&lt;folderName&gt;/&lt;filenamePrefix&gt;<i>element-name</i>&lt;filenameSuffix&gt;<br>
* &nbsp;&nbsp;&nbsp;&nbsp;&lt;targetResourceDirectory&gt;/&lt;targetFolder&gt;/&lt;filenamePrefix&gt;<i>element-name</i>&lt;filenameSuffix&gt;<br>
* where: <i>element-name</i> is the "title-case" name of the selected resource or composite data type.
* </td>
* </tr>
@ -129,7 +129,7 @@ import ca.uhn.fhir.tinder.parser.TargetType;
* <td valign="top" align="center">Yes when resource files are to be generated</td>
* </tr>
* <tr>
* <td valign="top">folderName</td>
* <td valign="top">targetFolder</td>
* <td valign="top">The folder within the targetResourceDirectory where the generated files will be placed.
* This folder is generated in the &lt;targetResourceDirectory&gt; if needed.</td>
* <td valign="top" align="center">No</td>
@ -217,7 +217,7 @@ public class TinderGenericMultiFileMojo extends AbstractMojo {
private File targetSourceDirectory;
@Parameter(required = false)
private String packageName;
private String targetPackage;
@Parameter(required = false)
private String filenamePrefix;
@ -229,7 +229,7 @@ public class TinderGenericMultiFileMojo extends AbstractMojo {
private File targetResourceDirectory;
@Parameter(required = false)
private String folderName;
private String targetFolder;
// one of these two is required
@Parameter(required = false)
@ -284,21 +284,24 @@ public class TinderGenericMultiFileMojo extends AbstractMojo {
throw new MojoFailureException("Both [targetSourceDirectory] and [targetResourceDirectory] are specified. Please choose just one.");
}
targetType = TargetType.SOURCE;
if (null == packageName) {
throw new MojoFailureException("The [packageName] property must be specified when generating Java source code.");
if (null == targetPackage) {
throw new MojoFailureException("The [targetPackage] property must be specified when generating Java source code.");
}
targetDirectory = new File(targetSourceDirectory, packageName.replace('.', File.separatorChar));
targetDirectory = new File(targetSourceDirectory, targetPackage.replace('.', File.separatorChar));
} else
if (targetResourceDirectory != null) {
if (targetSourceDirectory != null) {
throw new MojoFailureException("Both [targetSourceDirectory] and [targetResourceDirectory] are specified. Please choose just one.");
}
targetType = TargetType.RESOURCE;
if (folderName != null) {
targetDirectory = new File(targetResourceDirectory, folderName);
if (targetFolder != null) {
targetDirectory = new File(targetResourceDirectory, targetFolder);
} else {
targetDirectory = targetResourceDirectory;
}
if (null == targetPackage) {
targetPackage = "";
}
} else {
throw new MojoFailureException("Either [targetSourceDirectory] or [targetResourceDirectory] must be specified.");
}
@ -316,7 +319,7 @@ public class TinderGenericMultiFileMojo extends AbstractMojo {
rp.setTemplate(template);
rp.setTemplateFile(templateFile);
rp.setVelocityPath(velocityPath);
rp.writeAll(targetType, targetDirectory, null, packageName);
rp.writeAll(targetType, targetDirectory, null, targetPackage);
}
/*
@ -330,7 +333,7 @@ public class TinderGenericMultiFileMojo extends AbstractMojo {
dtp.setTemplate(template);
dtp.setTemplateFile(templateFile);
dtp.setVelocityPath(velocityPath);
dtp.writeAll(targetType, targetDirectory, null, packageName);
dtp.writeAll(targetType, targetDirectory, null, targetPackage);
}
/*
@ -344,7 +347,7 @@ public class TinderGenericMultiFileMojo extends AbstractMojo {
vsp.setTemplate(template);
vsp.setTemplateFile(templateFile);
vsp.setVelocityPath(velocityPath);
vsp.writeMarkedValueSets(targetType, targetDirectory, packageName);
vsp.writeMarkedValueSets(targetType, targetDirectory, targetPackage);
}
/*
@ -358,18 +361,22 @@ public class TinderGenericMultiFileMojo extends AbstractMojo {
pp.setTemplate(template);
pp.setTemplateFile(templateFile);
pp.setVelocityPath(velocityPath);
pp.writeAll(targetType, targetDirectory, null, packageName);
pp.writeAll(targetType, targetDirectory, null, targetPackage);
}
switch (targetType) {
case SOURCE: {
myProject.addCompileSourceRoot(targetDirectory.getAbsolutePath());
myProject.addCompileSourceRoot(targetSourceDirectory.getAbsolutePath());
break;
}
case RESOURCE: {
Resource resource = new Resource();
resource.setDirectory(targetDirectory.getAbsolutePath());
resource.addInclude("*");
resource.setDirectory(targetResourceDirectory.getAbsolutePath());
if (targetFolder != null) {
resource.addInclude(targetFolder+"/*");
} else {
resource.addInclude("*");
}
myProject.addResource(resource);
break;
}
@ -398,7 +405,7 @@ public class TinderGenericMultiFileMojo extends AbstractMojo {
TinderGenericMultiFileMojo mojo = new TinderGenericMultiFileMojo();
mojo.myProject = new MavenProject();
mojo.version = "dstu2";
mojo.packageName = "ca.uhn.test";
mojo.targetPackage = "ca.uhn.test";
mojo.template = "/vm/jpa_resource_provider.vm";
mojo.targetSourceDirectory = new File("target/generated/valuesets");
mojo.execute();

View File

@ -66,7 +66,7 @@ import ca.uhn.fhir.tinder.parser.TargetType;
* <td valign="top">generateResources</td>
* <td valign="top">Should files be generated from FHIR resource metadata?<br>
* Valid values:&nbsp;<code><b>true</b></code>&nbsp;|&nbsp;<code><b>false</b></code></td>
* <td valign="top" align="center" rowspan="2">At least one of these two options must be specified</td>
* <td valign="top" align="center" rowspan="2">One of these two options must be specified</td>
* </tr>
* <tr>
* <td valign="top">generateDataTypes</td>
@ -81,8 +81,8 @@ import ca.uhn.fhir.tinder.parser.TargetType;
* for FHIR resources or composite data types. There is one file
* generated for each selected entity. The following configuration
* properties control the naming of the generated source files:<br>
* &nbsp;&nbsp;&nbsp;&nbsp;&lt;targetSourceDirectory&gt;/&lt;packageName&gt;/&lt;targetFile&gt;<br>
* Note that all dots in the packageName will be replaced by the path separator character when building the
* &nbsp;&nbsp;&nbsp;&nbsp;&lt;targetSourceDirectory&gt;/&lt;targetPackage&gt;/&lt;targetFile&gt;<br>
* Note that all dots in the targetPackage will be replaced by the path separator character when building the
* actual source file location. Also note that <code>.java</code> will be added to the targetFile if it is not already included.
* </td>
* </tr>
@ -92,12 +92,18 @@ import ca.uhn.fhir.tinder.parser.TargetType;
* <td valign="top" align="center">Yes when a Java source file is to be generated</td>
* </tr>
* <tr>
* <td valign="top">packageName</td>
* <td valign="top">targetPackage</td>
* <td valign="top">The Java package that will contain the generated classes.
* This package is generated in the &lt;targetSourceDirectory&gt; if needed.</td>
* <td valign="top" align="center">Yes when <i>targetSourceDirectory</i> is specified</td>
* </tr>
* <tr>
* <td valign="top">packageBase</td>
* <td valign="top">The base Java package for related classes. This property
* can be used to reference class in other places in a folder structure.</td>
* <td valign="top" align="center">No</td>
* </tr>
* <tr>
* <td valign="top">targetFile</td>
* <td valign="top">The name of the file to be generated</td>
* <td valign="top" align="center">Yes</td>
@ -109,7 +115,7 @@ import ca.uhn.fhir.tinder.parser.TargetType;
* <td valign="top" colspan="3">Maven resource files can also be generated
* for FHIR resources or composite data types. The following configuration
* properties control the naming of the generated resource files:<br>
* &nbsp;&nbsp;&nbsp;&nbsp;&lt;targetResourceDirectory&gt;/&lt;folderName&gt;/&lt;targetFile&gt;<br>
* &nbsp;&nbsp;&nbsp;&nbsp;&lt;targetResourceDirectory&gt;/&lt;targetFolder&gt;/&lt;targetFile&gt;<br>
* </td>
* </tr>
* <tr>
@ -118,7 +124,7 @@ import ca.uhn.fhir.tinder.parser.TargetType;
* <td valign="top" align="center">Yes when a resource file is to be generated</td>
* </tr>
* <tr>
* <td valign="top">folderName</td>
* <td valign="top">targetFolder</td>
* <td valign="top">The folder within the targetResourceDirectory where the generated file will be placed.
* This folder is generated in the &lt;targetResourceDirectory&gt; if needed.</td>
* <td valign="top" align="center">No</td>
@ -200,13 +206,16 @@ public class TinderGenericSingleFileMojo extends AbstractMojo {
private File targetSourceDirectory;
@Parameter(required = false)
private String packageName;
private String targetPackage;
@Parameter(required = false)
private String packageBase;
@Parameter(required = false)
private File targetResourceDirectory;
@Parameter(required = false)
private String folderName;
private String targetFolder;
@Parameter(required = false)
private String targetFile;
@ -268,10 +277,10 @@ public class TinderGenericSingleFileMojo extends AbstractMojo {
throw new MojoFailureException("Both [targetSourceDirectory] and [targetResourceDirectory] are specified. Please choose just one.");
}
targetType = TargetType.SOURCE;
if (null == packageName) {
if (null == targetPackage) {
throw new MojoFailureException("The [targetPackage] property must be specified when generating Java source code.");
}
targetDirectory = new File(targetSourceDirectory, packageName.replace('.', File.separatorChar));
targetDirectory = new File(targetSourceDirectory, targetPackage.replace('.', File.separatorChar));
if (!targetFile.endsWith(".java")) {
targetFile += ".java";
}
@ -281,13 +290,16 @@ public class TinderGenericSingleFileMojo extends AbstractMojo {
throw new MojoFailureException("Both [targetSourceDirectory] and [targetResourceDirectory] are specified. Please choose just one.");
}
targetType = TargetType.RESOURCE;
if (folderName != null) {
folderName = folderName.replace('\\', '/');
folderName = folderName.replace('/', File.separatorChar);
targetDirectory = new File(targetResourceDirectory, folderName);
if (targetFolder != null) {
targetFolder = targetFolder.replace('\\', '/');
targetFolder = targetFolder.replace('/', File.separatorChar);
targetDirectory = new File(targetResourceDirectory, targetFolder);
} else {
targetDirectory = targetResourceDirectory;
}
if (null == targetPackage) {
targetPackage = "";
}
} else {
throw new MojoFailureException("Either [targetSourceDirectory] or [targetResourceDirectory] must be specified.");
}
@ -326,9 +338,19 @@ public class TinderGenericSingleFileMojo extends AbstractMojo {
* build new Velocity Context
*/
VelocityContext ctx = new VelocityContext();
int ix = packageName.lastIndexOf('.');
ctx.put("packageBase", packageName.subSequence(0, ix));
ctx.put("targetPackage", packageName);
if (packageBase != null) {
ctx.put("packageBase", packageBase);
} else
if (targetPackage != null) {
int ix = targetPackage.lastIndexOf('.');
if (ix > 0) {
ctx.put("packageBase", targetPackage.subSequence(0, ix));
} else {
ctx.put("packageBase", targetPackage);
}
}
ctx.put("targetPackage", targetPackage);
ctx.put("targetFolder", targetFolder);
ctx.put("version", version);
ctx.put("isRi", BaseStructureSpreadsheetParser.determineVersionEnum(version).isRi());
ctx.put("hash", "#");
@ -366,15 +388,15 @@ public class TinderGenericSingleFileMojo extends AbstractMojo {
switch (targetType) {
case SOURCE: {
myProject.addCompileSourceRoot(targetDirectory.getAbsolutePath());
myProject.addCompileSourceRoot(targetSourceDirectory.getAbsolutePath());
break;
}
case RESOURCE: {
Resource resource = new Resource();
resource.setDirectory(targetDirectory.getAbsolutePath());
resource.setDirectory(targetResourceDirectory.getAbsolutePath());
String resName = targetFile;
if (folderName != null) {
resName = folderName+File.separator+targetFile;
if (targetFolder != null) {
resName = targetFolder+File.separator+targetFile;
}
resource.addInclude(resName);
myProject.addResource(resource);
@ -409,7 +431,7 @@ public class TinderGenericSingleFileMojo extends AbstractMojo {
mojo.myProject = new MavenProject();
mojo.template = "/vm/jpa_spring_beans.vm";
mojo.version = "dstu2";
mojo.packageName = "ca.uhn.test";
mojo.targetPackage = "ca.uhn.test";
mojo.targetSourceDirectory = new File("target/generated/valuesets");
mojo.targetFile = "tmp_beans.xml";
mojo.execute();

View File

@ -113,12 +113,12 @@ import ca.uhn.fhir.tinder.parser.TargetType;
* be generated containing all of the selected entity. The following configuration
* properties control the naming of the generated source files:
* <p>The following properties will be used when generating multiple source files:<br>
* &nbsp;&nbsp;&nbsp;&nbsp;&lt;targetSourceDirectory&gt;/&lt;packageName&gt;/&lt;filenamePrefix&gt;<i>element-name</i>&lt;filenameSuffix&gt;<br>
* &nbsp;&nbsp;&nbsp;&nbsp;&lt;targetSourceDirectory&gt;/&lt;targetPackage&gt;/&lt;filenamePrefix&gt;<i>element-name</i>&lt;filenameSuffix&gt;<br>
* &nbsp;&nbsp;&nbsp;&nbsp;where: <i>element-name</i> is the "title-case" name of the selected resource or composite data type.
* <p>The following properties will be used when generating a single source file:<br>
* &nbsp;&nbsp;&nbsp;&nbsp;&lt;targetSourceDirectory&gt;/&lt;packageName&gt;/&lt;targetFile&gt;
* &nbsp;&nbsp;&nbsp;&nbsp;&lt;targetSourceDirectory&gt;/&lt;targetPackage&gt;/&lt;targetFile&gt;
* <p>
* Note that all dots in the packageName will be replaced by the path separator character when building the
* Note that all dots in the targetPackage will be replaced by the path separator character when building the
* actual source file location. Also note that <code>.java</code> will be added to the filenameSuffix or targetFile if it is not already included.
* </td>
* </tr>
@ -128,12 +128,18 @@ import ca.uhn.fhir.tinder.parser.TargetType;
* <td valign="top" align="center">Yes when Java source files are to be generated</td>
* </tr>
* <tr>
* <td valign="top">packageName</td>
* <td valign="top">targetPackage</td>
* <td valign="top">The Java package that will contain the generated classes.
* This package is generated in the &lt;targetSourceDirectory&gt; if needed.</td>
* <td valign="top" align="center">Yes when <i>targetSourceDirectory</i> is specified</td>
* </tr>
* <tr>
* <td valign="top">packageBase</td>
* <td valign="top">The base Java package for related classes. This property
* can be used to reference class in other places in a folder structure.</td>
* <td valign="top" align="center">No</td>
* </tr>
* <tr>
* <td valign="top">targetFile</td>
* <td valign="top">The name of the file to be generated</td>
* <td valign="top" align="center">Yes when generating a single file containing all selected elements</td>
@ -161,10 +167,10 @@ import ca.uhn.fhir.tinder.parser.TargetType;
* be generated containing all of the selected entity. The following configuration
* properties control the naming of the generated files:
* <p>The following properties will be used when generating multiple files (one for each selected element):<br>
* &nbsp;&nbsp;&nbsp;&nbsp;&lt;targetResourceDirectory&gt;/&lt;folderName&gt;/&lt;filenamePrefix&gt;<i>element-name</i>&lt;filenameSuffix&gt;<br>
* &nbsp;&nbsp;&nbsp;&nbsp;&lt;targetResourceDirectory&gt;/&lt;targetFolder&gt;/&lt;filenamePrefix&gt;<i>element-name</i>&lt;filenameSuffix&gt;<br>
* &nbsp;&nbsp;&nbsp;&nbsp;where: <i>element-name</i> is the "title-case" name of the selected resource or composite data type.
* <p>The following properties will be used when generating a single file containing all selected elements:<br>
* &nbsp;&nbsp;&nbsp;&nbsp;&lt;targetResourceDirectory&gt;/&lt;folderName&gt;/&lt;targetFile&gt;
* &nbsp;&nbsp;&nbsp;&nbsp;&lt;targetResourceDirectory&gt;/&lt;targetFolder&gt;/&lt;targetFile&gt;
* </td>
* </tr>
* <tr>
@ -173,7 +179,7 @@ import ca.uhn.fhir.tinder.parser.TargetType;
* <td valign="top" align="center">Yes when resource files are to be generated</td>
* </tr>
* <tr>
* <td valign="top">folderName</td>
* <td valign="top">targetFolder</td>
* <td valign="top">The folder within the targetResourceDirectory where the generated files will be placed.
* This folder is generated in the &lt;targetResourceDirectory&gt; if needed.</td>
* <td valign="top" align="center">No</td>
@ -250,7 +256,9 @@ public class TinderGeneratorTask extends Task {
private File targetSourceDirectory;
private String packageName;
private String targetPackage;
private String packageBase;
private String targetFile;
@ -260,7 +268,7 @@ public class TinderGeneratorTask extends Task {
private File targetResourceDirectory;
private String folderName;
private String targetFolder;
// one of these two is required
private String template;
@ -319,21 +327,24 @@ public class TinderGeneratorTask extends Task {
throw new BuildException("Both [targetSourceDirectory] and [targetResourceDirectory] are specified. Please choose just one.");
}
targetType = TargetType.SOURCE;
if (null == packageName) {
throw new BuildException("The [packageName] property must be specified when generating Java source code.");
if (null == targetPackage) {
throw new BuildException("The [targetPackage] property must be specified when generating Java source code.");
}
targetDirectory = new File(targetSourceDirectory, packageName.replace('.', File.separatorChar));
targetDirectory = new File(targetSourceDirectory, targetPackage.replace('.', File.separatorChar));
} else
if (targetResourceDirectory != null) {
if (targetSourceDirectory != null) {
throw new BuildException("Both [targetSourceDirectory] and [targetResourceDirectory] are specified. Please choose just one.");
}
targetType = TargetType.RESOURCE;
if (folderName != null) {
targetDirectory = new File(targetResourceDirectory, folderName);
if (targetFolder != null) {
targetDirectory = new File(targetResourceDirectory, targetFolder);
} else {
targetDirectory = targetResourceDirectory;
}
if (null == targetPackage) {
targetPackage = "";
}
} else {
throw new BuildException("Either [targetSourceDirectory] or [targetResourceDirectory] must be specified.");
}
@ -383,9 +394,19 @@ public class TinderGeneratorTask extends Task {
* build new Velocity Context
*/
VelocityContext ctx = new VelocityContext();
int ix = packageName.lastIndexOf('.');
ctx.put("packageBase", packageName.subSequence(0, ix));
ctx.put("targetPackage", packageName);
if (packageBase != null) {
ctx.put("packageBase", packageBase);
} else
if (targetPackage != null) {
int ix = targetPackage.lastIndexOf('.');
if (ix > 0) {
ctx.put("packageBase", targetPackage.subSequence(0, ix));
} else {
ctx.put("packageBase", targetPackage);
}
}
ctx.put("targetPackage", targetPackage);
ctx.put("targetFolder", targetFolder);
ctx.put("version", version);
ctx.put("isRi", BaseStructureSpreadsheetParser.determineVersionEnum(version).isRi());
ctx.put("hash", "#");
@ -436,7 +457,7 @@ public class TinderGeneratorTask extends Task {
rp.setTemplate(template);
rp.setTemplateFile(templateFile);
rp.setVelocityPath(velocityPath);
rp.writeAll(targetType, targetDirectory, null, packageName);
rp.writeAll(targetType, targetDirectory, null, targetPackage);
}
/*
@ -450,7 +471,7 @@ public class TinderGeneratorTask extends Task {
dtp.setTemplate(template);
dtp.setTemplateFile(templateFile);
dtp.setVelocityPath(velocityPath);
dtp.writeAll(targetType, targetDirectory, null, packageName);
dtp.writeAll(targetType, targetDirectory, null, targetPackage);
}
/*
@ -464,7 +485,7 @@ public class TinderGeneratorTask extends Task {
vsp.setTemplate(template);
vsp.setTemplateFile(templateFile);
vsp.setVelocityPath(velocityPath);
vsp.writeMarkedValueSets(targetType, targetDirectory, packageName);
vsp.writeMarkedValueSets(targetType, targetDirectory, targetPackage);
}
/*
@ -478,7 +499,7 @@ public class TinderGeneratorTask extends Task {
pp.setTemplate(template);
pp.setTemplateFile(templateFile);
pp.setVelocityPath(velocityPath);
pp.writeAll(targetType, targetDirectory, null, packageName);
pp.writeAll(targetType, targetDirectory, null, targetPackage);
}
}
@ -550,8 +571,12 @@ public class TinderGeneratorTask extends Task {
this.targetSourceDirectory = targetSourceDirectory;
}
public void setPackageName(String packageName) {
this.packageName = packageName;
public void setTargetPackage(String targetPackage) {
this.targetPackage = targetPackage;
}
public void setPackageBase(String packageBase) {
this.packageBase = packageBase;
}
public void setTargetFile(String targetFile) {
@ -570,8 +595,8 @@ public class TinderGeneratorTask extends Task {
this.targetResourceDirectory = targetResourceDirectory;
}
public void setFolderName(String folderName) {
this.folderName = folderName;
public void setTaargetFolder(String targetFolder) {
this.targetFolder = targetFolder;
}
public void setTemplate(String template) {

View File

@ -180,11 +180,11 @@ public abstract class BaseStructureParser {
}
protected String getFilenamePrefix() {
return myFilenamePrefix;
return myFilenamePrefix != null ? myFilenamePrefix : "";
}
protected String getFilenameSuffix() {
return myFilenameSuffix;
return myFilenameSuffix != null ? myFilenameSuffix : "";
}
public Map<String, String> getLocalImports() {
@ -536,6 +536,7 @@ public abstract class BaseStructureParser {
capitalize = "Dstu1";
}
ctx.put("versionCapitalized", capitalize);
ctx.put("this", theResource);
VelocityEngine v = new VelocityEngine();
InputStream templateIs = null;

View File

@ -24,6 +24,11 @@
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>2.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
@ -104,14 +109,34 @@
</goals>
<configuration>
<version>dstu</version>
<generateResources>true</generateResources>
<templateFile>${project.basedir}/src/test/resources/templates/resource_test.vm</templateFile>
<packageBase>ca.uhn.test.generic.multi</packageBase>
<targetDirectory>${project.build.directory}/generated-sources/tinder</targetDirectory>
<targetSourceDirectory>${project.build.directory}/generated-sources/tinder</targetSourceDirectory>
<targetPackage>ca.uhn.test.generic.multi</targetPackage>
<filenameSuffix>ResourceTest.java</filenameSuffix>
<baseResourceNames>
<baseResourceName>patient</baseResourceName>
<baseResourceName>organization</baseResourceName>
</baseResourceNames>
<includeResources>
<includeResource>patient</includeResource>
<includeResource>organization</includeResource>
</includeResources>
</configuration>
</execution>
<execution>
<id>generic_multi_json</id>
<goals>
<goal>generate-multi-files</goal>
</goals>
<configuration>
<version>dstu2</version>
<generateResources>true</generateResources>
<templateFile>${project.basedir}/src/test/resources/templates/resource_map.vm</templateFile>
<velocityPath>${project.basedir}/src/test/resources/macros</velocityPath>
<targetResourceDirectory>${project.build.directory}/generated-resources/tinder</targetResourceDirectory>
<targetFolder>maps</targetFolder>
<filenameSuffix>_Map.json</filenameSuffix>
<includeResources>
<includeResource>patient</includeResource>
<includeResource>organization</includeResource>
</includeResources>
</configuration>
</execution>
<execution>
@ -121,26 +146,56 @@
</goals>
<configuration>
<version>dstu</version>
<generateResources>true</generateResources>
<templateFile>${project.basedir}/src/test/resources/templates/resource_test_beans_java.vm</templateFile>
<packageBase>ca.uhn.test.generic.multi</packageBase>
<targetDirectory>${project.build.directory}/generated-sources/tinder</targetDirectory>
<targetSourceDirectory>${project.build.directory}/generated-sources/tinder</targetSourceDirectory>
<targetPackage>ca.uhn.test.generic.single</targetPackage>
<packageBase>ca.uhn.test.generic.multi</packageBase>
<targetFile>TestConfigDstu1.java</targetFile>
<baseResourceNames>
<baseResourceName>patient</baseResourceName>
<baseResourceName>organization</baseResourceName>
</baseResourceNames>
<includeResources>
<includeResource>patient</includeResource>
<includeResource>organization</includeResource>
</includeResources>
</configuration>
</execution>
<execution>
<id>generic_single_json</id>
<goals>
<goal>generate-single-file</goal>
</goals>
<configuration>
<version>dstu2</version>
<generateDatatypes>true</generateDatatypes>
<templateFile>${project.basedir}/src/test/resources/templates/composite_map.vm</templateFile>
<velocityPath>${project.basedir}/src/test/resources/macros</velocityPath>
<targetResourceDirectory>${project.build.directory}/generated-resources/tinder</targetResourceDirectory>
<targetFolder>maps</targetFolder>
<targetFile>Datatypes_Dstu2.json</targetFile>
<includeResources>
<includeResource>patient</includeResource>
<includeResource>organization</includeResource>
</includeResources>
</configuration>
</execution>
<!-- <execution> <id>client</id> <goals> <goal>generate-client</goal> </goals> <configuration> <clientClassName>ca.uhn.hitest.HiTest</clientClassName> <serverBaseHref>http://fhir.healthintersections.com.au/open</serverBaseHref>
<generateSearchForAllParams>true</generateSearchForAllParams> </configuration> </execution> -->
</executions>
<dependencies>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>2.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
<plugin>
@ -157,22 +212,24 @@
<taskdef name="hapi-tinder" classname="ca.uhn.fhir.tinder.ant.TinderGeneratorTask" classpathref="maven.plugin.classpath"/>
<hapi-tinder templateFile="${project.basedir}/src/test/resources/templates/resource_test.vm"
targetDir="${project.build.directory}/generated-sources/tinder"
packageBase="ca.uhn.test.ant.multi"
targetclassSuffix="ResourceTest.java"
generateResources="true"
targetSourceDirectory="${project.build.directory}/generated-sources/tinder"
targetPackage="ca.uhn.test.ant.multi"
filenameSuffix="ResourceTest.java"
projectHome="${project.basedir}/.."
version="dstu2"
baseResourceNames="patient,organization"
includeResources="patient,organization"
/>
<hapi-tinder templateFile="${project.basedir}/src/test/resources/templates/resource_test_beans_java.vm"
targetDir="${project.build.directory}/generated-sources/tinder"
generateResources="true"
targetSourceDirectory="${project.build.directory}/generated-sources/tinder"
targetFile="TestConfigDstu2.java"
targetPackage="ca.uhn.test.ant.single"
packageBase="ca.uhn.test.ant.multi"
projectHome="${project.basedir}/.."
version="dstu2"
baseResourceNames="patient,organization"
includeResources="patient,organization"
/>
</target>

View File

@ -0,0 +1,84 @@
##################################################################
## dumpBaseElement
##################################################################
#macro ( dumpBaseElement $lead, $elem )
${lead}BaseElement:
${lead} binding: $!{elem.binding}
${lead} bindingClass: $!{elem.bindingClass}
${lead} cardMax: $!{elem.cardMax}
${lead} cardMin: $!{elem.cardMin}
${lead} comments: $!{elem.comments}
${lead} declaringClassNameComplete: $!{elem.declaringClassNameComplete}
${lead} declaringClassNameCompleteForChildren: $!{elem.declaringClassNameCompleteForChildren}
${lead} definition: $!{elem.definition}
${lead} elementName: $!{elem.elementName}
${lead} elementParentName: $!{elem.elementParentName}
${lead} extensionUrl: $!{elem.extensionUrl}
${lead} name: $!{elem.name}
${lead} requirement: $!{elem.requirement}
${lead} shortName: $!{elem.shortName}
${lead} type: [#{foreach}(${t} in $!{elem.type})${t}#{if}($foreach.hasNext),#{end}#{end}]
${lead} v2Mapping: $!{elem.v2Mapping}
${lead} isExtensionLocal: $!{elem.extensionLocal}
${lead} isExtensionModifier: $!{elem.extensionModifier}
${lead} isHasExtensionUrl: $!{elem.hasExtensionUrl}
${lead} isHasMultipleTypes: $!{elem.hasMultipleTypes}
${lead} isModifier: $!{elem.modifier}
${lead} isResourceRef: $!{elem.resourceRef}
${lead} isSummary: $!{elem.summary}
#end
##################################################################
## dumpChild
##################################################################
#macro ( dumpChild $lead, $child )
${lead}Child:
${lead} annotationType: $!{child.annotationType}
#set ( $st = $!{child.singleType} )
${lead} boundDatatype: #{if}(${st}=="CodeDt"||${st}=="CodeableConceptDt")$!{child.boundDatatype}#{end} .
${lead} cardMaxForChildAnnotation: $!{child.cardMaxForChildAnnotation}
${lead} elementNameSimplified: $!{child.elementNameSimplified}
${lead} methodName: $!{child.methodName}
${lead} referenceType: $!{child.referenceType}
${lead} referenceTypeForConstructor: $!{child.referenceTypeForConstructor}
${lead} referenceTypesForMultiple: $!{child.referenceTypesForMultiple}
${lead} singleType: $!{child.singleType}
${lead} variableName: $!{child.variableName}
${lead} isBlock: $!{child.block}
${lead} isPrimitive: $!{child.primitive}
${lead} primitiveType: #{if}(${child.primitive})$!{child.primitiveType}#{end} .
${lead} isBoundCode: $!{child.boundCode}
${lead} isRepeatable: $!{child.repeatable}
${lead} isSingleChildInstantiable: $!{child.singleChildInstantiable}
#end ## of macro
##################################################################
## childVars
##################################################################
#macro ( childVars $lead, $childElements )
#foreach ( $child in $childElements )
${lead}Child: $!{child.elementName}
${lead} Class: $child.class.name
#dumpBaseElement ("${lead} ", $child )
#dumpChild ("${lead} ", $child )
#end ## end for-each on child
#end ## of macro
##################################################################
## childResourceBlocks
##################################################################
#macro ( childResourceBlocks $lead, $resourceBlockChildren )
#foreach ( $blockChild in $resourceBlockChildren )
${lead}Block: $!{blockChild.name}
${lead} Class: $blockChild.class.name
#dumpBaseElement ("${lead} ", $blockChild )
#dumpChild ("${lead} ", $blockChild )
${lead} ResourceBlock:
${lead} className: $!{blockChild.className}
${lead} Children:
#childVars( "${lead} ", $blockChild.children )
${lead} Blocks:
#childResourceBlocks( "${lead} ", $blockChild.resourceBlockChildren )
#end
#end

View File

@ -0,0 +1,21 @@
#parse ( "dump_templates.vm" )
#foreach ( $d in $datatypes )
Type: ${d.elementName}
Class: $d.class.name
#dumpBaseElement (" ", $d)
BaseRootType:
id: $!{d.id}
profile: $!{d.profile}
Composite:
--
Children:
#childVars( " ", $d.children )
Blocks
#childResourceBlocks(" ", $d.resourceBlockChildren)
================================================================================
================================================================================
#end

View File

@ -0,0 +1,17 @@
#parse ( "dump_templates.vm" )
Resource: ${elementName}
Class: ${this.class.name}
#dumpBaseElement (" ", ${this} )
BaseRootType:
id: $!{this.id}
profile: $!{this.profile}
Resource:
searchParameterNames: #{foreach}(${n} in ${this.searchParameterNames})${n}#{if}($foreach.hasNext), #{end}#{end}
Children:
#childVars( " ", $children )
Blocks:
#childResourceBlocks( " ", $resourceBlockChildren)