Merge branch 'generic-tinder-from-model'
This commit is contained in:
commit
0c0729711f
|
@ -21,7 +21,9 @@ package ca.uhn.fhir.tinder;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||||
|
import ca.uhn.fhir.tinder.parser.BaseStructureParser;
|
||||||
import ca.uhn.fhir.tinder.parser.DatatypeGeneratorUsingSpreadsheet;
|
import ca.uhn.fhir.tinder.parser.DatatypeGeneratorUsingSpreadsheet;
|
||||||
|
import ca.uhn.fhir.tinder.parser.ResourceGeneratorUsingModel;
|
||||||
import ca.uhn.fhir.tinder.parser.ResourceGeneratorUsingSpreadsheet;
|
import ca.uhn.fhir.tinder.parser.ResourceGeneratorUsingSpreadsheet;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -45,6 +47,9 @@ public abstract class AbstractGenerator {
|
||||||
} else if ("dstu3".equals(context.getVersion())) {
|
} else if ("dstu3".equals(context.getVersion())) {
|
||||||
fhirContext = FhirContext.forDstu3();
|
fhirContext = FhirContext.forDstu3();
|
||||||
packageSuffix = ".dstu3";
|
packageSuffix = ".dstu3";
|
||||||
|
} else if ("r4".equals(context.getVersion())) {
|
||||||
|
fhirContext = FhirContext.forR4();
|
||||||
|
packageSuffix = ".r4";
|
||||||
} else {
|
} else {
|
||||||
throw new FailureException("Unknown version configured: " + context.getVersion());
|
throw new FailureException("Unknown version configured: " + context.getVersion());
|
||||||
}
|
}
|
||||||
|
@ -139,26 +144,45 @@ public abstract class AbstractGenerator {
|
||||||
/*
|
/*
|
||||||
* Load the requested resources
|
* Load the requested resources
|
||||||
*/
|
*/
|
||||||
ResourceGeneratorUsingSpreadsheet rp = new ResourceGeneratorUsingSpreadsheet(context.getVersion(), context.getBaseDir());
|
|
||||||
context.setResourceGenerator(rp);
|
|
||||||
logInfo("Loading Resources...");
|
logInfo("Loading Resources...");
|
||||||
try {
|
try {
|
||||||
|
switch (context.getResourceSource()) {
|
||||||
|
case SPREADSHEET: {
|
||||||
|
logInfo("... resource definitions from spreadsheets");
|
||||||
|
ResourceGeneratorUsingSpreadsheet rp = new ResourceGeneratorUsingSpreadsheet(context.getVersion(), context.getBaseDir());
|
||||||
|
context.setResourceGenerator(rp);
|
||||||
|
|
||||||
rp.setBaseResourceNames(includeResources);
|
rp.setBaseResourceNames(includeResources);
|
||||||
rp.parse();
|
rp.parse();
|
||||||
|
|
||||||
rp.markResourcesForImports();
|
rp.markResourcesForImports();
|
||||||
|
rp.bindValueSets(vsp);
|
||||||
|
|
||||||
|
rp.getLocalImports().putAll(datatypeLocalImports);
|
||||||
|
datatypeLocalImports.putAll(rp.getLocalImports());
|
||||||
|
|
||||||
|
rp.combineContentMaps(dtp);
|
||||||
|
dtp.combineContentMaps(rp);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MODEL: {
|
||||||
|
logInfo("... resource definitions from model structures");
|
||||||
|
ResourceGeneratorUsingModel rp = new ResourceGeneratorUsingModel(context.getVersion(), context.getBaseDir());
|
||||||
|
context.setResourceGenerator(rp);
|
||||||
|
|
||||||
|
rp.setBaseResourceNames(includeResources);
|
||||||
|
rp.parse();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new FailureException("Failed to load resources", e);
|
throw new FailureException("Failed to load resources", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
rp.bindValueSets(vsp);
|
|
||||||
rp.getLocalImports().putAll(datatypeLocalImports);
|
|
||||||
datatypeLocalImports.putAll(rp.getLocalImports());
|
|
||||||
rp.combineContentMaps(dtp);
|
|
||||||
dtp.combineContentMaps(rp);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FailureException extends Exception {
|
public static class FailureException extends Exception {
|
||||||
|
|
||||||
public FailureException(String message, Throwable cause) {
|
public FailureException(String message, Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
|
@ -173,7 +197,7 @@ public abstract class AbstractGenerator {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ExecutionException extends Exception {
|
public static class ExecutionException extends Exception {
|
||||||
|
|
||||||
public ExecutionException(String message, Throwable cause) {
|
public ExecutionException(String message, Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
|
|
|
@ -19,25 +19,34 @@ package ca.uhn.fhir.tinder;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.tinder.TinderStructuresMojo.ValueSetFileDefinition;
|
import java.util.List;
|
||||||
import ca.uhn.fhir.tinder.parser.DatatypeGeneratorUsingSpreadsheet;
|
|
||||||
import ca.uhn.fhir.tinder.parser.ResourceGeneratorUsingSpreadsheet;
|
import javax.security.auth.login.FailedLoginException;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.maven.plugins.annotations.Parameter;
|
import org.apache.maven.plugins.annotations.Parameter;
|
||||||
|
|
||||||
import java.util.List;
|
import ca.uhn.fhir.tinder.AbstractGenerator.FailureException;
|
||||||
|
import ca.uhn.fhir.tinder.TinderStructuresMojo.ValueSetFileDefinition;
|
||||||
|
import ca.uhn.fhir.tinder.parser.BaseStructureParser;
|
||||||
|
import ca.uhn.fhir.tinder.parser.DatatypeGeneratorUsingSpreadsheet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bill.Denton
|
* @author Bill.Denton
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class GeneratorContext {
|
public class GeneratorContext {
|
||||||
|
public enum ResourceSource {SPREADSHEET, MODEL};
|
||||||
|
public static final ResourceSource DEFAULT_RESOURCE_SOURCE = ResourceSource.SPREADSHEET;
|
||||||
|
|
||||||
private String version;
|
private String version;
|
||||||
private String packageSuffix;
|
private String packageSuffix;
|
||||||
private String baseDir;
|
private String baseDir;
|
||||||
private List<String> includeResources;
|
private List<String> includeResources;
|
||||||
private List<String> excludeResources;
|
private List<String> excludeResources;
|
||||||
|
private ResourceSource resourceSource = DEFAULT_RESOURCE_SOURCE;
|
||||||
private List<ValueSetFileDefinition> valueSetFiles;
|
private List<ValueSetFileDefinition> valueSetFiles;
|
||||||
private ResourceGeneratorUsingSpreadsheet resourceGenerator = null;
|
private BaseStructureParser resourceGenerator = null;
|
||||||
private ValueSetGenerator valueSetGenerator = null;
|
private ValueSetGenerator valueSetGenerator = null;
|
||||||
private DatatypeGeneratorUsingSpreadsheet datatypeGenerator = null;
|
private DatatypeGeneratorUsingSpreadsheet datatypeGenerator = null;
|
||||||
|
|
||||||
|
@ -72,6 +81,29 @@ public class GeneratorContext {
|
||||||
this.includeResources = includeResources;
|
this.includeResources = includeResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ResourceSource getResourceSource() {
|
||||||
|
return resourceSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResourceSource(ResourceSource resourceSource) {
|
||||||
|
this.resourceSource = resourceSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResourceSource(String resourceSource) throws FailureException {
|
||||||
|
resourceSource = StringUtils.stripToNull(resourceSource);
|
||||||
|
if (null == resourceSource) {
|
||||||
|
this.resourceSource = DEFAULT_RESOURCE_SOURCE;
|
||||||
|
} else
|
||||||
|
if (ResourceSource.SPREADSHEET.name().equalsIgnoreCase(resourceSource)) {
|
||||||
|
this.resourceSource = ResourceSource.SPREADSHEET;
|
||||||
|
} else
|
||||||
|
if (ResourceSource.MODEL.name().equalsIgnoreCase(resourceSource)) {
|
||||||
|
this.resourceSource = ResourceSource.MODEL;
|
||||||
|
} else {
|
||||||
|
throw new FailureException("Unknown resource-source option: " + resourceSource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getPackageSuffix() {
|
public String getPackageSuffix() {
|
||||||
return packageSuffix;
|
return packageSuffix;
|
||||||
}
|
}
|
||||||
|
@ -80,11 +112,11 @@ public class GeneratorContext {
|
||||||
this.packageSuffix = packageSuffix;
|
this.packageSuffix = packageSuffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceGeneratorUsingSpreadsheet getResourceGenerator() {
|
public BaseStructureParser getResourceGenerator() {
|
||||||
return resourceGenerator;
|
return resourceGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResourceGenerator(ResourceGeneratorUsingSpreadsheet resourceGenerator) {
|
public void setResourceGenerator(BaseStructureParser resourceGenerator) {
|
||||||
this.resourceGenerator = resourceGenerator;
|
this.resourceGenerator = resourceGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
package ca.uhn.fhir.tinder;
|
package ca.uhn.fhir.tinder;
|
||||||
|
|
||||||
import ca.uhn.fhir.tinder.AbstractGenerator.ExecutionException;
|
import java.io.File;
|
||||||
import ca.uhn.fhir.tinder.AbstractGenerator.FailureException;
|
import java.io.IOException;
|
||||||
import ca.uhn.fhir.tinder.TinderStructuresMojo.ValueSetFileDefinition;
|
import java.util.List;
|
||||||
import ca.uhn.fhir.tinder.parser.DatatypeGeneratorUsingSpreadsheet;
|
|
||||||
import ca.uhn.fhir.tinder.parser.ResourceGeneratorUsingSpreadsheet;
|
|
||||||
import ca.uhn.fhir.tinder.parser.TargetType;
|
|
||||||
import org.apache.maven.model.Resource;
|
import org.apache.maven.model.Resource;
|
||||||
import org.apache.maven.plugin.AbstractMojo;
|
import org.apache.maven.plugin.AbstractMojo;
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
|
@ -16,9 +14,12 @@ import org.apache.maven.plugins.annotations.Mojo;
|
||||||
import org.apache.maven.plugins.annotations.Parameter;
|
import org.apache.maven.plugins.annotations.Parameter;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
|
|
||||||
import java.io.File;
|
import ca.uhn.fhir.tinder.AbstractGenerator.ExecutionException;
|
||||||
import java.io.IOException;
|
import ca.uhn.fhir.tinder.AbstractGenerator.FailureException;
|
||||||
import java.util.List;
|
import ca.uhn.fhir.tinder.TinderStructuresMojo.ValueSetFileDefinition;
|
||||||
|
import ca.uhn.fhir.tinder.parser.BaseStructureParser;
|
||||||
|
import ca.uhn.fhir.tinder.parser.DatatypeGeneratorUsingSpreadsheet;
|
||||||
|
import ca.uhn.fhir.tinder.parser.TargetType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate files from FHIR resource/composite metadata using Velocity templates.
|
* Generate files from FHIR resource/composite metadata using Velocity templates.
|
||||||
|
@ -40,7 +41,7 @@ import java.util.List;
|
||||||
* <td valign="top">version</td>
|
* <td valign="top">version</td>
|
||||||
* <td valign="top">The FHIR version whose resource metadata
|
* <td valign="top">The FHIR version whose resource metadata
|
||||||
* is to be used to generate the files<br>
|
* is to be used to generate the files<br>
|
||||||
* Valid values: <code><b>dstu</b></code> | <code><b>dstu2</b></code> | <code><b>dstu3</b></code></td>
|
* Valid values: <code><b>dstu2</b></code> | <code><b>dstu3</b></code> | <code><b>r4</b></code></td>
|
||||||
* <td valign="top" align="center">Yes</td>
|
* <td valign="top" align="center">Yes</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
|
@ -53,7 +54,7 @@ import java.util.List;
|
||||||
* <td valign="top">generateResources</td>
|
* <td valign="top">generateResources</td>
|
||||||
* <td valign="top">Should files be generated from FHIR resource metadata?<br>
|
* <td valign="top">Should files be generated from FHIR resource metadata?<br>
|
||||||
* Valid values: <code><b>true</b></code> | <code><b>false</b></code></td>
|
* Valid values: <code><b>true</b></code> | <code><b>false</b></code></td>
|
||||||
* <td valign="top" align="center" rowspan="4">One of these four options must be specified</td>
|
* <td valign="top" align="center" rowspan="4">One of these four options must be specified as <code><b>true</b></code></td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
* <td valign="top">generateDataTypes</td>
|
* <td valign="top">generateDataTypes</td>
|
||||||
|
@ -71,6 +72,14 @@ import java.util.List;
|
||||||
* Valid values: <code><b>true</b></code> | <code><b>false</b></code></td>
|
* Valid values: <code><b>true</b></code> | <code><b>false</b></code></td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
|
* <td valign="top">resourceSource</td>
|
||||||
|
* <td valign="top">Which source of resource definitions should be processed? Valid values are:<br>
|
||||||
|
* <ul>
|
||||||
|
* <li><code><b>spreadsheet</b></code> to cause resources to be generated based on the FHIR spreadsheets</li>
|
||||||
|
* <li><code><b>model</b></code> to cause resources to be generated based on the model structure classes</li></ul></td>
|
||||||
|
* <td valign="top" align="center">No. Defaults to: <code><b>spreadsheet</b></code></td>
|
||||||
|
* </tr>
|
||||||
|
* <tr>
|
||||||
* <td colspan="3" />
|
* <td colspan="3" />
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
|
@ -246,6 +255,9 @@ public class TinderGenericMultiFileMojo extends AbstractMojo {
|
||||||
@Parameter(required = false)
|
@Parameter(required = false)
|
||||||
private List<String> excludeResources;
|
private List<String> excludeResources;
|
||||||
|
|
||||||
|
@Parameter(required = false)
|
||||||
|
private String resourceSource;
|
||||||
|
|
||||||
@Parameter(required = false)
|
@Parameter(required = false)
|
||||||
private List<ValueSetFileDefinition> valueSetFiles;
|
private List<ValueSetFileDefinition> valueSetFiles;
|
||||||
|
|
||||||
|
@ -256,14 +268,15 @@ public class TinderGenericMultiFileMojo extends AbstractMojo {
|
||||||
public void execute() throws MojoExecutionException, MojoFailureException {
|
public void execute() throws MojoExecutionException, MojoFailureException {
|
||||||
|
|
||||||
GeneratorContext context = new GeneratorContext();
|
GeneratorContext context = new GeneratorContext();
|
||||||
|
Generator generator = new Generator();
|
||||||
|
try {
|
||||||
context.setVersion(version);
|
context.setVersion(version);
|
||||||
context.setBaseDir(baseDir);
|
context.setBaseDir(baseDir);
|
||||||
context.setIncludeResources(includeResources);
|
context.setIncludeResources(includeResources);
|
||||||
context.setExcludeResources(excludeResources);
|
context.setExcludeResources(excludeResources);
|
||||||
|
context.setResourceSource(resourceSource);
|
||||||
context.setValueSetFiles(valueSetFiles);
|
context.setValueSetFiles(valueSetFiles);
|
||||||
|
|
||||||
Generator generator = new Generator();
|
|
||||||
try {
|
|
||||||
generator.prepare(context);
|
generator.prepare(context);
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
throw new MojoExecutionException(e.getMessage(), e.getCause());
|
throw new MojoExecutionException(e.getMessage(), e.getCause());
|
||||||
|
@ -308,7 +321,7 @@ public class TinderGenericMultiFileMojo extends AbstractMojo {
|
||||||
/*
|
/*
|
||||||
* Write resources if selected
|
* Write resources if selected
|
||||||
*/
|
*/
|
||||||
ResourceGeneratorUsingSpreadsheet rp = context.getResourceGenerator();
|
BaseStructureParser rp = context.getResourceGenerator();
|
||||||
if (generateResources && rp != null) {
|
if (generateResources && rp != null) {
|
||||||
ourLog.info("Writing Resources...");
|
ourLog.info("Writing Resources...");
|
||||||
rp.setFilenamePrefix(filenamePrefix);
|
rp.setFilenamePrefix(filenamePrefix);
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
package ca.uhn.fhir.tinder;
|
package ca.uhn.fhir.tinder;
|
||||||
|
|
||||||
import ca.uhn.fhir.tinder.AbstractGenerator.ExecutionException;
|
import java.io.File;
|
||||||
import ca.uhn.fhir.tinder.AbstractGenerator.FailureException;
|
import java.io.FileInputStream;
|
||||||
import ca.uhn.fhir.tinder.TinderStructuresMojo.ValueSetFileDefinition;
|
import java.io.FileOutputStream;
|
||||||
import ca.uhn.fhir.tinder.parser.BaseStructureSpreadsheetParser;
|
import java.io.IOException;
|
||||||
import ca.uhn.fhir.tinder.parser.DatatypeGeneratorUsingSpreadsheet;
|
import java.io.InputStream;
|
||||||
import ca.uhn.fhir.tinder.parser.ResourceGeneratorUsingSpreadsheet;
|
import java.io.InputStreamReader;
|
||||||
import ca.uhn.fhir.tinder.parser.TargetType;
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.lang.WordUtils;
|
import org.apache.commons.lang.WordUtils;
|
||||||
import org.apache.maven.model.Resource;
|
import org.apache.maven.model.Resource;
|
||||||
import org.apache.maven.plugin.AbstractMojo;
|
import org.apache.maven.plugin.AbstractMojo;
|
||||||
|
@ -21,8 +23,13 @@ import org.apache.velocity.VelocityContext;
|
||||||
import org.apache.velocity.app.VelocityEngine;
|
import org.apache.velocity.app.VelocityEngine;
|
||||||
import org.apache.velocity.tools.generic.EscapeTool;
|
import org.apache.velocity.tools.generic.EscapeTool;
|
||||||
|
|
||||||
import java.io.*;
|
import ca.uhn.fhir.tinder.AbstractGenerator.ExecutionException;
|
||||||
import java.util.List;
|
import ca.uhn.fhir.tinder.AbstractGenerator.FailureException;
|
||||||
|
import ca.uhn.fhir.tinder.TinderStructuresMojo.ValueSetFileDefinition;
|
||||||
|
import ca.uhn.fhir.tinder.parser.BaseStructureParser;
|
||||||
|
import ca.uhn.fhir.tinder.parser.BaseStructureSpreadsheetParser;
|
||||||
|
import ca.uhn.fhir.tinder.parser.DatatypeGeneratorUsingSpreadsheet;
|
||||||
|
import ca.uhn.fhir.tinder.parser.TargetType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a single file based on resource or composite type metadata.
|
* Generate a single file based on resource or composite type metadata.
|
||||||
|
@ -44,7 +51,7 @@ import java.util.List;
|
||||||
* <td valign="top">version</td>
|
* <td valign="top">version</td>
|
||||||
* <td valign="top">The FHIR version whose resource metadata
|
* <td valign="top">The FHIR version whose resource metadata
|
||||||
* is to be used to generate the files<br>
|
* is to be used to generate the files<br>
|
||||||
* Valid values: <code><b>dstu</b></code> | <code><b>dstu2</b></code> | <code><b>dstu3</b></code></td>
|
* Valid values: <code><b>dstu2</b></code> | <code><b>dstu3</b></code> | <code><b>r4</b></code></td>
|
||||||
* <td valign="top" align="center">Yes</td>
|
* <td valign="top" align="center">Yes</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
|
@ -57,7 +64,7 @@ import java.util.List;
|
||||||
* <td valign="top">generateResources</td>
|
* <td valign="top">generateResources</td>
|
||||||
* <td valign="top">Should files be generated from FHIR resource metadata?<br>
|
* <td valign="top">Should files be generated from FHIR resource metadata?<br>
|
||||||
* Valid values: <code><b>true</b></code> | <code><b>false</b></code></td>
|
* Valid values: <code><b>true</b></code> | <code><b>false</b></code></td>
|
||||||
* <td valign="top" align="center" rowspan="2">One of these two options must be specified</td>
|
* <td valign="top" align="center" rowspan="2">One of these two options must be specified as <code><b>true</b></code></td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
* <td valign="top">generateDataTypes</td>
|
* <td valign="top">generateDataTypes</td>
|
||||||
|
@ -65,6 +72,14 @@ import java.util.List;
|
||||||
* Valid values: <code><b>true</b></code> | <code><b>false</b></code></td>
|
* Valid values: <code><b>true</b></code> | <code><b>false</b></code></td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
|
* <td valign="top">resourceSource</td>
|
||||||
|
* <td valign="top">Which source of resource definitions should be processed? Valid values are:<br>
|
||||||
|
* <ul>
|
||||||
|
* <li><code><b>spreadsheet</b></code> to cause resources to be generated based on the FHIR spreadsheets</li>
|
||||||
|
* <li><code><b>model</b></code> to cause resources to be generated based on the model structure classes</li></ul></td>
|
||||||
|
* <td valign="top" align="center">No. Defaults to: <code><b>spreadsheet</b></code></td>
|
||||||
|
* </tr>
|
||||||
|
* <tr>
|
||||||
* <td colspan="3" />
|
* <td colspan="3" />
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
|
@ -233,6 +248,9 @@ public class TinderGenericSingleFileMojo extends AbstractMojo {
|
||||||
@Parameter(required = false)
|
@Parameter(required = false)
|
||||||
private List<String> excludeResources;
|
private List<String> excludeResources;
|
||||||
|
|
||||||
|
@Parameter(required = false)
|
||||||
|
private String resourceSource;
|
||||||
|
|
||||||
@Parameter(required = false)
|
@Parameter(required = false)
|
||||||
private List<ValueSetFileDefinition> valueSetFiles;
|
private List<ValueSetFileDefinition> valueSetFiles;
|
||||||
|
|
||||||
|
@ -243,14 +261,15 @@ public class TinderGenericSingleFileMojo extends AbstractMojo {
|
||||||
public void execute() throws MojoExecutionException, MojoFailureException {
|
public void execute() throws MojoExecutionException, MojoFailureException {
|
||||||
|
|
||||||
GeneratorContext context = new GeneratorContext();
|
GeneratorContext context = new GeneratorContext();
|
||||||
|
Generator generator = new Generator();
|
||||||
|
try {
|
||||||
context.setVersion(version);
|
context.setVersion(version);
|
||||||
context.setBaseDir(baseDir);
|
context.setBaseDir(baseDir);
|
||||||
context.setIncludeResources(includeResources);
|
context.setIncludeResources(includeResources);
|
||||||
context.setExcludeResources(excludeResources);
|
context.setExcludeResources(excludeResources);
|
||||||
|
context.setResourceSource(resourceSource);
|
||||||
context.setValueSetFiles(valueSetFiles);
|
context.setValueSetFiles(valueSetFiles);
|
||||||
|
|
||||||
Generator generator = new Generator();
|
|
||||||
try {
|
|
||||||
generator.prepare(context);
|
generator.prepare(context);
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
throw new MojoExecutionException(e.getMessage(), e.getCause());
|
throw new MojoExecutionException(e.getMessage(), e.getCause());
|
||||||
|
@ -351,7 +370,7 @@ public class TinderGenericSingleFileMojo extends AbstractMojo {
|
||||||
/*
|
/*
|
||||||
* Write resources if selected
|
* Write resources if selected
|
||||||
*/
|
*/
|
||||||
ResourceGeneratorUsingSpreadsheet rp = context.getResourceGenerator();
|
BaseStructureParser rp = context.getResourceGenerator();
|
||||||
if (generateResources && rp != null) {
|
if (generateResources && rp != null) {
|
||||||
ourLog.info("Writing Resources...");
|
ourLog.info("Writing Resources...");
|
||||||
ctx.put("resources", rp.getResources());
|
ctx.put("resources", rp.getResources());
|
||||||
|
|
|
@ -19,6 +19,23 @@ package ca.uhn.fhir.tinder.ant;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.WordUtils;
|
||||||
|
import org.apache.tools.ant.BuildException;
|
||||||
|
import org.apache.tools.ant.Task;
|
||||||
|
import org.apache.velocity.VelocityContext;
|
||||||
|
import org.apache.velocity.app.VelocityEngine;
|
||||||
|
import org.apache.velocity.tools.generic.EscapeTool;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.tinder.AbstractGenerator;
|
import ca.uhn.fhir.tinder.AbstractGenerator;
|
||||||
import ca.uhn.fhir.tinder.AbstractGenerator.ExecutionException;
|
import ca.uhn.fhir.tinder.AbstractGenerator.ExecutionException;
|
||||||
|
@ -27,21 +44,10 @@ import ca.uhn.fhir.tinder.GeneratorContext;
|
||||||
import ca.uhn.fhir.tinder.TinderStructuresMojo.ValueSetFileDefinition;
|
import ca.uhn.fhir.tinder.TinderStructuresMojo.ValueSetFileDefinition;
|
||||||
import ca.uhn.fhir.tinder.ValueSetGenerator;
|
import ca.uhn.fhir.tinder.ValueSetGenerator;
|
||||||
import ca.uhn.fhir.tinder.VelocityHelper;
|
import ca.uhn.fhir.tinder.VelocityHelper;
|
||||||
|
import ca.uhn.fhir.tinder.parser.BaseStructureParser;
|
||||||
import ca.uhn.fhir.tinder.parser.BaseStructureSpreadsheetParser;
|
import ca.uhn.fhir.tinder.parser.BaseStructureSpreadsheetParser;
|
||||||
import ca.uhn.fhir.tinder.parser.DatatypeGeneratorUsingSpreadsheet;
|
import ca.uhn.fhir.tinder.parser.DatatypeGeneratorUsingSpreadsheet;
|
||||||
import ca.uhn.fhir.tinder.parser.ResourceGeneratorUsingSpreadsheet;
|
|
||||||
import ca.uhn.fhir.tinder.parser.TargetType;
|
import ca.uhn.fhir.tinder.parser.TargetType;
|
||||||
import org.apache.commons.lang.WordUtils;
|
|
||||||
import org.apache.tools.ant.BuildException;
|
|
||||||
import org.apache.tools.ant.Task;
|
|
||||||
import org.apache.velocity.VelocityContext;
|
|
||||||
import org.apache.velocity.app.VelocityEngine;
|
|
||||||
import org.apache.velocity.tools.generic.EscapeTool;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.StringTokenizer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
/**
|
/**
|
||||||
|
@ -64,7 +70,7 @@ import java.util.StringTokenizer;
|
||||||
* <td valign="top">version</td>
|
* <td valign="top">version</td>
|
||||||
* <td valign="top">The FHIR version whose resource metadata
|
* <td valign="top">The FHIR version whose resource metadata
|
||||||
* is to be used to generate the files<br>
|
* is to be used to generate the files<br>
|
||||||
* Valid values: <code><b>dstu</b></code> | <code><b>dstu2</b></code> | <code><b>dstu3</b></code></td>
|
* Valid values: <code><b>dstu2</b></code> | <code><b>dstu3</b></code> | <code><b>r4</b></code></td>
|
||||||
* <td valign="top" align="center">Yes</td>
|
* <td valign="top" align="center">Yes</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
|
@ -77,7 +83,7 @@ import java.util.StringTokenizer;
|
||||||
* <td valign="top">generateResources</td>
|
* <td valign="top">generateResources</td>
|
||||||
* <td valign="top">Should files be generated from FHIR resource metadata?<br>
|
* <td valign="top">Should files be generated from FHIR resource metadata?<br>
|
||||||
* Valid values: <code><b>true</b></code> | <code><b>false</b></code></td>
|
* Valid values: <code><b>true</b></code> | <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">At least one of these four options must be specified as <code><b>true</b></code></td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
* <td valign="top">generateDataTypes</td>
|
* <td valign="top">generateDataTypes</td>
|
||||||
|
@ -97,6 +103,14 @@ import java.util.StringTokenizer;
|
||||||
* Valid values: <code><b>true</b></code> | <code><b>false</b></code></td>
|
* Valid values: <code><b>true</b></code> | <code><b>false</b></code></td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
|
* <td valign="top">resourceSource</td>
|
||||||
|
* <td valign="top">Which source of resource definitions should be processed? Valid values are:<br>
|
||||||
|
* <ul>
|
||||||
|
* <li><code><b>spreadsheet</b></code> to cause resources to be generated based on the FHIR spreadsheets</li>
|
||||||
|
* <li><code><b>model</b></code> to cause resources to be generated based on the model structure classes</li></ul></td>
|
||||||
|
* <td valign="top" align="center">No. Defaults to: <code><b>spreadsheet</b></code></td>
|
||||||
|
* </tr>
|
||||||
|
* <tr>
|
||||||
* <td colspan="3" />
|
* <td colspan="3" />
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
|
@ -281,6 +295,8 @@ public class TinderGeneratorTask extends Task {
|
||||||
|
|
||||||
private List<String> excludeResources;
|
private List<String> excludeResources;
|
||||||
|
|
||||||
|
private String resourceSource;
|
||||||
|
|
||||||
private List<ValueSetFileDefinition> valueSetFiles;
|
private List<ValueSetFileDefinition> valueSetFiles;
|
||||||
|
|
||||||
private boolean verbose;
|
private boolean verbose;
|
||||||
|
@ -303,14 +319,15 @@ public class TinderGeneratorTask extends Task {
|
||||||
|
|
||||||
|
|
||||||
GeneratorContext context = new GeneratorContext();
|
GeneratorContext context = new GeneratorContext();
|
||||||
|
Generator generator = new Generator();
|
||||||
|
try {
|
||||||
context.setVersion(version);
|
context.setVersion(version);
|
||||||
context.setBaseDir(projectHome);
|
context.setBaseDir(projectHome);
|
||||||
context.setIncludeResources(includeResources);
|
context.setIncludeResources(includeResources);
|
||||||
context.setExcludeResources(excludeResources);
|
context.setExcludeResources(excludeResources);
|
||||||
|
context.setResourceSource(resourceSource);
|
||||||
context.setValueSetFiles(valueSetFiles);
|
context.setValueSetFiles(valueSetFiles);
|
||||||
|
|
||||||
Generator generator = new Generator();
|
|
||||||
try {
|
|
||||||
generator.prepare(context);
|
generator.prepare(context);
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
throw new BuildException(e.getMessage(), e.getCause());
|
throw new BuildException(e.getMessage(), e.getCause());
|
||||||
|
@ -413,7 +430,7 @@ public class TinderGeneratorTask extends Task {
|
||||||
/*
|
/*
|
||||||
* Write resources if selected
|
* Write resources if selected
|
||||||
*/
|
*/
|
||||||
ResourceGeneratorUsingSpreadsheet rp = context.getResourceGenerator();
|
BaseStructureParser rp = context.getResourceGenerator();
|
||||||
if (generateResources && rp != null) {
|
if (generateResources && rp != null) {
|
||||||
log("Writing Resources...");
|
log("Writing Resources...");
|
||||||
ctx.put("resources", rp.getResources());
|
ctx.put("resources", rp.getResources());
|
||||||
|
@ -436,7 +453,7 @@ public class TinderGeneratorTask extends Task {
|
||||||
/*
|
/*
|
||||||
* Write resources if selected
|
* Write resources if selected
|
||||||
*/
|
*/
|
||||||
ResourceGeneratorUsingSpreadsheet rp = context.getResourceGenerator();
|
BaseStructureParser rp = context.getResourceGenerator();
|
||||||
if (generateResources && rp != null) {
|
if (generateResources && rp != null) {
|
||||||
log("Writing Resources...");
|
log("Writing Resources...");
|
||||||
rp.setFilenamePrefix(filenamePrefix);
|
rp.setFilenamePrefix(filenamePrefix);
|
||||||
|
@ -550,6 +567,14 @@ public class TinderGeneratorTask extends Task {
|
||||||
this.projectHome = projectHome;
|
this.projectHome = projectHome;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getResourceSource() {
|
||||||
|
return resourceSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResourceSource(String resourceSource) {
|
||||||
|
this.resourceSource = resourceSource;
|
||||||
|
}
|
||||||
|
|
||||||
public void setTargetFile(String targetFile) {
|
public void setTargetFile(String targetFile) {
|
||||||
this.targetFile = targetFile;
|
this.targetFile = targetFile;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue