Merge branch 'master' into windows-fixes-2

This commit is contained in:
Ken Stevens 2019-01-31 09:52:09 -05:00
commit 5ca352aeb8
17 changed files with 2636 additions and 2401 deletions

View File

@ -14,7 +14,7 @@
<groupId>ca.uhn.hapi.example</groupId>
<artifactId>hapi-fhir-example-simple-server</artifactId>
<version>0.7</version>
<version>0.8</version>
<packaging>war</packaging>
<name>HAPI FHIR Example - Simple Server</name>
@ -35,12 +35,12 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>1.2-SNAPSHOT</version>
<version>1.6</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>1.2-SNAPSHOT</version>
<version>1.6</version>
</dependency>
<!--

View File

@ -1,128 +1,128 @@
target/
/bin
# Created by https://www.gitignore.io
### Java ###
*.class
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
### Vim ###
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
*.iml
## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:
# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries
# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml
# Gradle:
# .idea/gradle.xml
# .idea/libraries
# Mongo Explorer plugin:
# .idea/mongoSettings.xml
## File-based project format:
*.ipr
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
### Eclipse ###
*.pydevproject
.metadata
.gradle
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
# Eclipse Core
.project
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# JDT-specific (Eclipse Java Development Tools)
.classpath
# PDT-specific
.buildpath
# sbteclipse plugin
.target
# TeXlipse plugin
.texlipse
target/
/bin
# Created by https://www.gitignore.io
### Java ###
*.class
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
### Vim ###
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
*.iml
## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:
# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries
# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml
# Gradle:
# .idea/gradle.xml
# .idea/libraries
# Mongo Explorer plugin:
# .idea/mongoSettings.xml
## File-based project format:
*.ipr
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
### Eclipse ###
*.pydevproject
.metadata
.gradle
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
# Eclipse Core
.project
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# JDT-specific (Eclipse Java Development Tools)
.classpath
# PDT-specific
.buildpath
# sbteclipse plugin
.target
# TeXlipse plugin
.texlipse

View File

@ -1,187 +1,215 @@
package ca.uhn.fhir.tinder;
/*
* #%L
* HAPI FHIR Tinder Plug-In
* %%
* Copyright (C) 2014 - 2016 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.tinder.parser.DatatypeGeneratorUsingSpreadsheet;
import ca.uhn.fhir.tinder.parser.ResourceGeneratorUsingSpreadsheet;
import java.io.IOException;
import java.util.*;
public abstract class AbstractGenerator {
protected abstract void logDebug (String message);
protected abstract void logInfo (String message);
public void prepare (GeneratorContext context) throws ExecutionException, FailureException {
/*
* Deal with the FHIR spec version
*/
FhirContext fhirContext;
String packageSuffix = "";
if ("dstu2".equals(context.getVersion())) {
fhirContext = FhirContext.forDstu2();
} else if ("dstu3".equals(context.getVersion())) {
fhirContext = FhirContext.forDstu3();
packageSuffix = ".dstu3";
} else {
throw new FailureException("Unknown version configured: " + context.getVersion());
}
context.setPackageSuffix(packageSuffix);
/*
* Deal with which resources to process
*/
List<String> includeResources = context.getIncludeResources();
List<String> excludeResources = context.getExcludeResources();
if (includeResources == null || includeResources.isEmpty()) {
includeResources = new ArrayList<String>();
logInfo("No resource names supplied, going to use all resources from version: "+fhirContext.getVersion().getVersion());
Properties p = new Properties();
try {
p.load(fhirContext.getVersion().getFhirVersionPropertiesFile());
} catch (IOException e) {
throw new FailureException("Failed to load version property file", e);
}
logDebug("Property file contains: "+p);
TreeSet<String> keys = new TreeSet<String>();
for(Object next : p.keySet()) {
keys.add((String) next);
}
for (String next : keys) {
if (next.startsWith("resource.")) {
includeResources.add(next.substring("resource.".length()).toLowerCase());
}
}
if (fhirContext.getVersion().getVersion() == FhirVersionEnum.DSTU3) {
includeResources.remove("conformance");
}
}
for (int i = 0; i < includeResources.size(); i++) {
includeResources.set(i, includeResources.get(i).toLowerCase());
}
if (excludeResources != null) {
for (int i = 0; i < excludeResources.size(); i++) {
excludeResources.set(i, excludeResources.get(i).toLowerCase());
}
includeResources.removeAll(excludeResources);
}
context.setIncludeResources(includeResources);
logInfo("Including the following elements: "+includeResources);
/*
* Fill in ValueSet and DataTypes used by the resources
*/
ValueSetGenerator vsp = null;
DatatypeGeneratorUsingSpreadsheet dtp = null;
Map<String, String> datatypeLocalImports = new HashMap<String, String>();
vsp = new ValueSetGenerator(context.getVersion());
vsp.setResourceValueSetFiles(context.getValueSetFiles());
context.setValueSetGenerator(vsp);
try {
vsp.parse();
} catch (Exception e) {
throw new FailureException("Failed to load valuesets", e);
}
/*
* A few enums are not found by default because none of the generated classes
* refer to them, but we still want them.
*/
vsp.getClassForValueSetIdAndMarkAsNeeded("NarrativeStatus");
logInfo("Loading Datatypes...");
dtp = new DatatypeGeneratorUsingSpreadsheet(context.getVersion(), context.getBaseDir());
context.setDatatypeGenerator(dtp);
try {
dtp.parse();
dtp.markResourcesForImports();
} catch (Exception e) {
throw new FailureException("Failed to load datatypes", e);
}
dtp.bindValueSets(vsp);
datatypeLocalImports = dtp.getLocalImports();
/*
* Load the requested resources
*/
ResourceGeneratorUsingSpreadsheet rp = new ResourceGeneratorUsingSpreadsheet(context.getVersion(), context.getBaseDir());
context.setResourceGenerator(rp);
logInfo("Loading Resources...");
try {
rp.setBaseResourceNames(includeResources);
rp.parse();
rp.markResourcesForImports();
} catch (Exception 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 FailureException(String message, Throwable cause) {
super(message, cause);
}
public FailureException(Throwable cause) {
super(cause);
}
public FailureException(String message) {
super(message);
}
}
public class ExecutionException extends Exception {
public ExecutionException(String message, Throwable cause) {
super(message, cause);
}
public ExecutionException(String message) {
super(message);
}
}
}
package ca.uhn.fhir.tinder;
/*
* #%L
* HAPI FHIR Tinder Plug-In
* %%
* Copyright (C) 2014 - 2016 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.tinder.GeneratorContext.ResourceSource;
import ca.uhn.fhir.tinder.parser.BaseStructureParser;
import ca.uhn.fhir.tinder.parser.DatatypeGeneratorUsingSpreadsheet;
import ca.uhn.fhir.tinder.parser.ResourceGeneratorUsingModel;
import ca.uhn.fhir.tinder.parser.ResourceGeneratorUsingSpreadsheet;
import java.io.IOException;
import java.util.*;
public abstract class AbstractGenerator {
protected abstract void logDebug (String message);
protected abstract void logInfo (String message);
public void prepare (GeneratorContext context) throws ExecutionException, FailureException {
/*
* Deal with the FHIR spec version
*/
FhirContext fhirContext;
String packageSuffix = "";
if ("dstu2".equals(context.getVersion())) {
fhirContext = FhirContext.forDstu2();
} else if ("dstu3".equals(context.getVersion())) {
fhirContext = FhirContext.forDstu3();
packageSuffix = ".dstu3";
} else if ("r4".equals(context.getVersion())) {
fhirContext = FhirContext.forR4();
packageSuffix = ".r4";
} else {
throw new FailureException("Unknown version configured: " + context.getVersion());
}
context.setPackageSuffix(packageSuffix);
/*
* Deal with which resources to process
*/
List<String> includeResources = context.getIncludeResources();
List<String> excludeResources = context.getExcludeResources();
if (includeResources == null || includeResources.isEmpty()) {
includeResources = new ArrayList<String>();
logInfo("No resource names supplied, going to use all resources from version: "+fhirContext.getVersion().getVersion());
Properties p = new Properties();
try {
p.load(fhirContext.getVersion().getFhirVersionPropertiesFile());
} catch (IOException e) {
throw new FailureException("Failed to load version property file", e);
}
logDebug("Property file contains: "+p);
TreeSet<String> keys = new TreeSet<String>();
for(Object next : p.keySet()) {
keys.add((String) next);
}
for (String next : keys) {
if (next.startsWith("resource.")) {
includeResources.add(next.substring("resource.".length()).toLowerCase());
}
}
if (fhirContext.getVersion().getVersion() == FhirVersionEnum.DSTU3) {
includeResources.remove("conformance");
}
}
for (int i = 0; i < includeResources.size(); i++) {
includeResources.set(i, includeResources.get(i).toLowerCase());
}
if (excludeResources != null) {
for (int i = 0; i < excludeResources.size(); i++) {
excludeResources.set(i, excludeResources.get(i).toLowerCase());
}
includeResources.removeAll(excludeResources);
}
context.setIncludeResources(includeResources);
logInfo("Including the following elements: "+includeResources);
/*
* Fill in ValueSet and DataTypes used by the resources
*/
ValueSetGenerator vsp = null;
DatatypeGeneratorUsingSpreadsheet dtp = null;
Map<String, String> datatypeLocalImports = new HashMap<String, String>();
if (ResourceSource.SPREADSHEET.equals(context.getResourceSource())) {
vsp = new ValueSetGenerator(context.getVersion());
vsp.setResourceValueSetFiles(context.getValueSetFiles());
context.setValueSetGenerator(vsp);
try {
vsp.parse();
} catch (Exception e) {
throw new FailureException("Failed to load valuesets", e);
}
/*
* A few enums are not found by default because none of the generated classes
* refer to them, but we still want them.
*/
vsp.getClassForValueSetIdAndMarkAsNeeded("NarrativeStatus");
logInfo("Loading Datatypes...");
dtp = new DatatypeGeneratorUsingSpreadsheet(context.getVersion(), context.getBaseDir());
context.setDatatypeGenerator(dtp);
try {
dtp.parse();
dtp.markResourcesForImports();
} catch (Exception e) {
throw new FailureException("Failed to load datatypes", e);
}
dtp.bindValueSets(vsp);
datatypeLocalImports = dtp.getLocalImports();
}
/*
* Load the requested resources
*/
logInfo("Loading Resources...");
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.parse();
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();
rp.markResourcesForImports();
break;
}
}
} catch (Exception e) {
throw new FailureException("Failed to load resources", e);
}
}
public static class FailureException extends Exception {
public FailureException(String message, Throwable cause) {
super(message, cause);
}
public FailureException(Throwable cause) {
super(cause);
}
public FailureException(String message) {
super(message);
}
}
public static class ExecutionException extends Exception {
public ExecutionException(String message, Throwable cause) {
super(message, cause);
}
public ExecutionException(String message) {
super(message);
}
}
}

View File

@ -1,137 +1,169 @@
package ca.uhn.fhir.tinder;
/*
* #%L
* HAPI FHIR Tinder Plug-In
* %%
* Copyright (C) 2014 - 2016 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import ca.uhn.fhir.tinder.TinderStructuresMojo.ValueSetFileDefinition;
import ca.uhn.fhir.tinder.parser.DatatypeGeneratorUsingSpreadsheet;
import ca.uhn.fhir.tinder.parser.ResourceGeneratorUsingSpreadsheet;
import org.apache.maven.plugins.annotations.Parameter;
import java.util.List;
/**
* @author Bill.Denton
*
*/
public class GeneratorContext {
private String version;
private String packageSuffix;
private String baseDir;
private List<String> includeResources;
private List<String> excludeResources;
private List<ValueSetFileDefinition> valueSetFiles;
private ResourceGeneratorUsingSpreadsheet resourceGenerator = null;
private ValueSetGenerator valueSetGenerator = null;
private DatatypeGeneratorUsingSpreadsheet datatypeGenerator = null;
public String getBaseDir() {
return baseDir;
}
public void setBaseDir(String baseDir) {
this.baseDir = baseDir;
}
public DatatypeGeneratorUsingSpreadsheet getDatatypeGenerator() {
return datatypeGenerator;
}
public void setDatatypeGenerator(DatatypeGeneratorUsingSpreadsheet datatypeGenerator) {
this.datatypeGenerator = datatypeGenerator;
}
public List<String> getExcludeResources() {
return excludeResources;
}
public void setExcludeResources(List<String> excludeResources) {
this.excludeResources = excludeResources;
}
public List<String> getIncludeResources() {
return includeResources;
}
public void setIncludeResources(List<String> includeResources) {
this.includeResources = includeResources;
}
public String getPackageSuffix() {
return packageSuffix;
}
public void setPackageSuffix(String packageSuffix) {
this.packageSuffix = packageSuffix;
}
public ResourceGeneratorUsingSpreadsheet getResourceGenerator() {
return resourceGenerator;
}
public void setResourceGenerator(ResourceGeneratorUsingSpreadsheet resourceGenerator) {
this.resourceGenerator = resourceGenerator;
}
public List<ValueSetFileDefinition> getValueSetFiles() {
return valueSetFiles;
}
public void setValueSetFiles(List<ValueSetFileDefinition> valueSetFiles) {
this.valueSetFiles = valueSetFiles;
}
public ValueSetGenerator getValueSetGenerator() {
return valueSetGenerator;
}
public void setValueSetGenerator(ValueSetGenerator valueSetGenerator) {
this.valueSetGenerator = valueSetGenerator;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public static class ProfileFileDefinition {
@Parameter(required = true)
String profileFile;
@Parameter(required = true)
String profileSourceUrl;
public String getProfileFile() {
return profileFile;
}
public void setProfileFile(String profileFile) {
this.profileFile = profileFile;
}
public String getProfileSourceUrl() {
return profileSourceUrl;
}
public void setProfileSourceUrl(String profileSourceUrl) {
this.profileSourceUrl = profileSourceUrl;
}
}
}
package ca.uhn.fhir.tinder;
/*
* #%L
* HAPI FHIR Tinder Plug-In
* %%
* Copyright (C) 2014 - 2016 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.util.List;
import javax.security.auth.login.FailedLoginException;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugins.annotations.Parameter;
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
*
*/
public class GeneratorContext {
public enum ResourceSource {SPREADSHEET, MODEL};
public static final ResourceSource DEFAULT_RESOURCE_SOURCE = ResourceSource.SPREADSHEET;
private String version;
private String packageSuffix;
private String baseDir;
private List<String> includeResources;
private List<String> excludeResources;
private ResourceSource resourceSource = DEFAULT_RESOURCE_SOURCE;
private List<ValueSetFileDefinition> valueSetFiles;
private BaseStructureParser resourceGenerator = null;
private ValueSetGenerator valueSetGenerator = null;
private DatatypeGeneratorUsingSpreadsheet datatypeGenerator = null;
public String getBaseDir() {
return baseDir;
}
public void setBaseDir(String baseDir) {
this.baseDir = baseDir;
}
public DatatypeGeneratorUsingSpreadsheet getDatatypeGenerator() {
return datatypeGenerator;
}
public void setDatatypeGenerator(DatatypeGeneratorUsingSpreadsheet datatypeGenerator) {
this.datatypeGenerator = datatypeGenerator;
}
public List<String> getExcludeResources() {
return excludeResources;
}
public void setExcludeResources(List<String> excludeResources) {
this.excludeResources = excludeResources;
}
public List<String> getIncludeResources() {
return includeResources;
}
public void setIncludeResources(List<String> 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() {
return packageSuffix;
}
public void setPackageSuffix(String packageSuffix) {
this.packageSuffix = packageSuffix;
}
public BaseStructureParser getResourceGenerator() {
return resourceGenerator;
}
public void setResourceGenerator(BaseStructureParser resourceGenerator) {
this.resourceGenerator = resourceGenerator;
}
public List<ValueSetFileDefinition> getValueSetFiles() {
return valueSetFiles;
}
public void setValueSetFiles(List<ValueSetFileDefinition> valueSetFiles) {
this.valueSetFiles = valueSetFiles;
}
public ValueSetGenerator getValueSetGenerator() {
return valueSetGenerator;
}
public void setValueSetGenerator(ValueSetGenerator valueSetGenerator) {
this.valueSetGenerator = valueSetGenerator;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public static class ProfileFileDefinition {
@Parameter(required = true)
String profileFile;
@Parameter(required = true)
String profileSourceUrl;
public String getProfileFile() {
return profileFile;
}
public void setProfileFile(String profileFile) {
this.profileFile = profileFile;
}
public String getProfileSourceUrl() {
return profileSourceUrl;
}
public void setProfileSourceUrl(String profileSourceUrl) {
this.profileSourceUrl = profileSourceUrl;
}
}
}

View File

@ -1,411 +1,434 @@
package ca.uhn.fhir.tinder;
import ca.uhn.fhir.tinder.AbstractGenerator.ExecutionException;
import ca.uhn.fhir.tinder.AbstractGenerator.FailureException;
import ca.uhn.fhir.tinder.TinderStructuresMojo.ValueSetFileDefinition;
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.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import java.io.File;
import java.io.IOException;
import java.util.List;
/**
* Generate files from FHIR resource/composite metadata using Velocity templates.
* <p>
* Generates either source or resource files for each selected resource or
* composite data type. One file is generated for each selected entity. The
* files are generated using a Velocity template that can be taken from
* inside the hapi-timder-plugin project or can be located in other projects
* <p>
* The following Maven plug-in configuration properties are used with this plug-in
* <p>
* <table border="1" cellpadding="2" cellspacing="0">
* <tr>
* <td valign="top"><b>Attribute</b></td>
* <td valign="top"><b>Description</b></td>
* <td align="center" valign="top"><b>Required</b></td>
* </tr>
* <tr>
* <td valign="top">version</td>
* <td valign="top">The FHIR version whose resource metadata
* is to be used to generate the files<br>
* Valid values:&nbsp;<code><b>dstu</b></code>&nbsp;|&nbsp;<code><b>dstu2</b></code>&nbsp;|&nbsp;<code><b>dstu3</b></code></td>
* <td valign="top" align="center">Yes</td>
* </tr>
* <tr>
* <td valign="top">baseDir</td>
* <td valign="top">The Maven project's base directory. This is used to
* possibly locate other assets within the project used in file generation.</td>
* <td valign="top" align="center">No. Defaults to: <code>${project.build.directory}/..</code></td>
* </tr>
* <tr>
* <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">One of these four options must be specified</td>
* </tr>
* <tr>
* <td valign="top">generateDataTypes</td>
* <td valign="top">Should files be generated from FHIR composite data type metadata?<br>
* Valid values:&nbsp;<code><b>true</b></code>&nbsp;|&nbsp;<code><b>false</b></code></td>
* </tr>
* <tr>
* <td valign="top">generateValueSets</td>
* <td valign="top">Should files be generated from FHIR value set metadata?<br>
* Valid values:&nbsp;<code><b>true</b></code>&nbsp;|&nbsp;<code><b>false</b></code></td>
* </tr>
* <tr>
* <td valign="top">generateProfiles</td>
* <td valign="top">Should files be generated from FHIR profile metadata?<br>
* Valid values:&nbsp;<code><b>true</b></code>&nbsp;|&nbsp;<code><b>false</b></code></td>
* </tr>
* <tr>
* <td colspan="3" />
* </tr>
* <tr>
* <td valign="top" colspan="3">Java source files can be generated
* 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;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 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>
* <tr>
* <td valign="top">targetSourceDirectory</td>
* <td valign="top">The Maven source directory to contain the generated files.</td>
* <td valign="top" align="center">Yes when Java source files are to be generated</td>
* </tr>
* <tr>
* <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">filenamePrefix</td>
* <td valign="top">The prefix string that is to be added onto the
* beginning of the resource or composite data type name to become
* the Java class name or resource file name.</td>
* <td valign="top" align="center">No</td>
* </tr>
* <tr>
* <td valign="top">filenameSuffix</td>
* <td valign="top">Suffix that will be added onto the end of the resource
* or composite data type name to become the Java class name or resource file name.</td>
* <td valign="top" align="center">No.</code></td>
* </tr>
* <tr>
* <td colspan="3" />
* </tr>
* <tr>
* <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;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>
* <tr>
* <td valign="top">targetResourceDirectory</td>
* <td valign="top">The Maven resource directory to contain the generated files.</td>
* <td valign="top" align="center">Yes when resource files are to be generated</td>
* </tr>
* <tr>
* <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>
* </tr>
* <tr>
* <td colspan="3" />
* </tr>
* <tr>
* <td valign="top">template</td>
* <td valign="top">The path of one of the <i>Velocity</i> templates
* contained within the <code>hapi-tinder-plugin</code> Maven plug-in
* classpath that will be used to generate the files.</td>
* <td valign="top" align="center" rowspan="2">One of these two options must be configured</td>
* </tr>
* <tr>
* <td valign="top">templateFile</td>
* <td valign="top">The full path to the <i>Velocity</i> template that is
* to be used to generate the files.</td>
* </tr>
* <tr>
* <td valign="top">velocityPath</td>
* <td valign="top">When using the <code>templateFile</code> option, this property
* can be used to specify where Velocity macros and other resources are located.</td>
* <td valign="top" align="center">No. Defaults to same directory as the template file.</td>
* </tr>
* <tr>
* <td valign="top">velocityProperties</td>
* <td valign="top">Specifies the full path to a java properties file
* containing Velocity configuration properties</td>
* <td valign="top" align="center">No.</td>
* </tr>
* <tr>
* <td valign="top">includeResources</td>
* <td valign="top">A list of the names of the resources or composite data types that should
* be used in the file generation</td>
* <td valign="top" align="center">No. Defaults to all defined resources except for DSTU2,
* the <code>Binary</code> resource is excluded and
* for DSTU3, the <code>Conformance</code> resource is excluded.</td>
* </tr>
* <tr>
* <td valign="top">excludeResources</td>
* <td valign="top">A list of the names of the resources or composite data types that should
* excluded from the file generation</td>
* <td valign="top" align="center">No.</td>
* </tr>
* <tr>
* <td valign="top">valueSetFiles</td>
* <td valign="top">A list of files containing value-set resource definitions
* to be used.</td>
* <td valign="top" align="center">No. Defaults to all defined value-sets that
* are referenced from the selected resources.</td>
* </tr>
* <tr>
* <td valign="top">profileFiles</td>
* <td valign="top">A list of files containing profile definitions
* to be used.</td>
* <td valign="top" align="center">No. Defaults to the default profile
* for each selected resource</td>
* </tr>
* </table>
*
*
*
* @author Bill.Denton
*
*/
@Mojo(name = "generate-multi-files", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
public class TinderGenericMultiFileMojo extends AbstractMojo {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TinderGenericMultiFileMojo.class);
@Parameter(required = true)
private String version;
@Parameter(required = true, defaultValue = "${project.build.directory}/..")
private String baseDir;
@Parameter(required = false, defaultValue="false")
private boolean generateResources;
@Parameter(required = false, defaultValue = "false")
private boolean generateDatatypes;
@Parameter(required = false, defaultValue = "false")
private boolean generateValueSets;
@Parameter(required = false)
private File targetSourceDirectory;
@Parameter(required = false)
private String targetPackage;
@Parameter(required = false)
private String filenamePrefix;
@Parameter(required = false)
private String filenameSuffix;
@Parameter(required = false)
private File targetResourceDirectory;
@Parameter(required = false)
private String targetFolder;
// one of these two is required
@Parameter(required = false)
private String template;
@Parameter(required = false)
private File templateFile;
@Parameter(required = false)
private String velocityPath;
@Parameter(required = false)
private String velocityProperties;
@Parameter(required = false)
private List<String> includeResources;
@Parameter(required = false)
private List<String> excludeResources;
@Parameter(required = false)
private List<ValueSetFileDefinition> valueSetFiles;
@Component
private MavenProject myProject;
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
GeneratorContext context = new GeneratorContext();
context.setVersion(version);
context.setBaseDir(baseDir);
context.setIncludeResources(includeResources);
context.setExcludeResources(excludeResources);
context.setValueSetFiles(valueSetFiles);
Generator generator = new Generator();
try {
generator.prepare(context);
} catch (ExecutionException e) {
throw new MojoExecutionException(e.getMessage(), e.getCause());
} catch (FailureException e) {
throw new MojoFailureException(e.getMessage(), e.getCause());
}
/*
* Deal with the generation target
*/
TargetType targetType = null;
File targetDirectory = null;
if (targetSourceDirectory != null) {
if (targetResourceDirectory != null) {
throw new MojoFailureException("Both [targetSourceDirectory] and [targetResourceDirectory] are specified. Please choose just one.");
}
targetType = TargetType.SOURCE;
if (null == targetPackage) {
throw new MojoFailureException("The [targetPackage] property must be specified when generating Java source code.");
}
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 (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.");
}
targetDirectory.mkdirs();
ourLog.info(" * Output ["+targetType.toString()+"] Directory: " + targetDirectory.getAbsolutePath());
/*
* Write resources if selected
*/
ResourceGeneratorUsingSpreadsheet rp = context.getResourceGenerator();
if (generateResources && rp != null) {
ourLog.info("Writing Resources...");
rp.setFilenamePrefix(filenamePrefix);
rp.setFilenameSuffix(filenameSuffix);
rp.setTemplate(template);
rp.setTemplateFile(templateFile);
rp.setVelocityPath(velocityPath);
rp.setVelocityProperties(velocityProperties);
rp.writeAll(targetType, targetDirectory, null, targetPackage);
}
/*
* Write composite datatypes
*/
DatatypeGeneratorUsingSpreadsheet dtp = context.getDatatypeGenerator();
if (generateDatatypes && dtp != null) {
ourLog.info("Writing Composite Datatypes...");
dtp.setFilenamePrefix(filenamePrefix);
dtp.setFilenameSuffix(filenameSuffix);
dtp.setTemplate(template);
dtp.setTemplateFile(templateFile);
dtp.setVelocityPath(velocityPath);
dtp.setVelocityProperties(velocityProperties);
dtp.writeAll(targetType, targetDirectory, null, targetPackage);
}
/*
* Write valuesets
*/
ValueSetGenerator vsp = context.getValueSetGenerator();
if (generateValueSets && vsp != null) {
ourLog.info("Writing ValueSet Enums...");
vsp.setFilenamePrefix(filenamePrefix);
vsp.setFilenameSuffix(filenameSuffix);
vsp.setTemplate(template);
vsp.setTemplateFile(templateFile);
vsp.setVelocityPath(velocityPath);
vsp.setVelocityProperties(velocityProperties);
vsp.writeMarkedValueSets(targetType, targetDirectory, targetPackage);
}
switch (targetType) {
case SOURCE: {
myProject.addCompileSourceRoot(targetSourceDirectory.getAbsolutePath());
break;
}
case RESOURCE: {
Resource resource = new Resource();
resource.setDirectory(targetResourceDirectory.getAbsolutePath());
if (targetFolder != null) {
resource.addInclude(targetFolder+"/*");
} else {
resource.addInclude("*");
}
myProject.addResource(resource);
break;
}
default:
}
}
public static void main(String[] args) throws IOException, MojoFailureException, MojoExecutionException {
// PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
// HttpClientBuilder builder = HttpClientBuilder.create();
// builder.setConnectionManager(connectionManager);
// CloseableHttpClient client = builder.build();
//
// HttpGet get = new HttpGet("http://fhir.healthintersections.com.au/open/metadata");
// CloseableHttpResponse response = client.execute(get);
//
// String metadataString = EntityUtils.toString(response.getEntity());
//
// ourLog.info("Metadata String: {}", metadataString);
// String metadataString = IOUtils.toString(new FileInputStream("src/test/resources/healthintersections-metadata.xml"));
// Conformance conformance = new FhirContext(Conformance.class).newXmlParser().parseResource(Conformance.class, metadataString);
TinderGenericMultiFileMojo mojo = new TinderGenericMultiFileMojo();
mojo.myProject = new MavenProject();
mojo.version = "dstu2";
mojo.targetPackage = "ca.uhn.test";
mojo.template = "/vm/jpa_resource_provider.vm";
mojo.targetSourceDirectory = new File("target/generated/valuesets");
mojo.execute();
}
class Generator extends AbstractGenerator {
@Override
protected void logDebug(String message) {
ourLog.debug(message);
}
@Override
protected void logInfo(String message) {
ourLog.info(message);
}
}
}
package ca.uhn.fhir.tinder;
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.apache.maven.model.Resource;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import ca.uhn.fhir.tinder.AbstractGenerator.ExecutionException;
import ca.uhn.fhir.tinder.AbstractGenerator.FailureException;
import ca.uhn.fhir.tinder.GeneratorContext.ResourceSource;
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.
* <p>
* Generates either source or resource files for each selected resource or
* composite data type. One file is generated for each selected entity. The
* files are generated using a Velocity template that can be taken from
* inside the hapi-timder-plugin project or can be located in other projects
* <p>
* The following Maven plug-in configuration properties are used with this plug-in
* <p>
* <table border="1" cellpadding="2" cellspacing="0">
* <tr>
* <td valign="top"><b>Attribute</b></td>
* <td valign="top"><b>Description</b></td>
* <td align="center" valign="top"><b>Required</b></td>
* </tr>
* <tr>
* <td valign="top">version</td>
* <td valign="top">The FHIR version whose resource metadata
* is to be used to generate the files<br>
* Valid values:&nbsp;<code><b>dstu2</b></code>&nbsp;|&nbsp;<code><b>dstu3</b></code>&nbsp;|&nbsp;<code><b>r4</b></code></td>
* <td valign="top" align="center">Yes</td>
* </tr>
* <tr>
* <td valign="top">baseDir</td>
* <td valign="top">The Maven project's base directory. This is used to
* possibly locate other assets within the project used in file generation.</td>
* <td valign="top" align="center">No. Defaults to: <code>${project.build.directory}/..</code></td>
* </tr>
* <tr>
* <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">One of these four options must be specified as <code><b>true</b></code></td>
* </tr>
* <tr>
* <td valign="top">generateDataTypes</td>
* <td valign="top">Should files be generated from FHIR composite data type metadata?<br>
* Valid values:&nbsp;<code><b>true</b></code>&nbsp;|&nbsp;<code><b>false</b></code></td>
* </tr>
* <tr>
* <td valign="top">generateValueSets</td>
* <td valign="top">Should files be generated from FHIR value set metadata?<br>
* Valid values:&nbsp;<code><b>true</b></code>&nbsp;|&nbsp;<code><b>false</b></code></td>
* </tr>
* <tr>
* <td valign="top">generateProfiles</td>
* <td valign="top">Should files be generated from FHIR profile metadata?<br>
* Valid values:&nbsp;<code><b>true</b></code>&nbsp;|&nbsp;<code><b>false</b></code></td>
* </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>&nbsp;&nbsp;to cause resources to be generated based on the FHIR spreadsheets</li>
* <li><code><b>model</b></code>&nbsp;&nbsp;to cause resources to be generated based on the model structure classes. Note that
* <code>generateResources</code> is the only one of the above options that can be used when <code>model</code> is specified.</li></ul></td>
* <td valign="top" align="center">No. Defaults to: <code><b>spreadsheet</b></code></td>
* </tr>
* <tr>
* <td colspan="3" />
* </tr>
* <tr>
* <td valign="top" colspan="3">Java source files can be generated
* 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;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 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>
* <tr>
* <td valign="top">targetSourceDirectory</td>
* <td valign="top">The Maven source directory to contain the generated files.</td>
* <td valign="top" align="center">Yes when Java source files are to be generated</td>
* </tr>
* <tr>
* <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">filenamePrefix</td>
* <td valign="top">The prefix string that is to be added onto the
* beginning of the resource or composite data type name to become
* the Java class name or resource file name.</td>
* <td valign="top" align="center">No</td>
* </tr>
* <tr>
* <td valign="top">filenameSuffix</td>
* <td valign="top">Suffix that will be added onto the end of the resource
* or composite data type name to become the Java class name or resource file name.</td>
* <td valign="top" align="center">No.</code></td>
* </tr>
* <tr>
* <td colspan="3" />
* </tr>
* <tr>
* <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;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>
* <tr>
* <td valign="top">targetResourceDirectory</td>
* <td valign="top">The Maven resource directory to contain the generated files.</td>
* <td valign="top" align="center">Yes when resource files are to be generated</td>
* </tr>
* <tr>
* <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>
* </tr>
* <tr>
* <td colspan="3" />
* </tr>
* <tr>
* <td valign="top">template</td>
* <td valign="top">The path of one of the <i>Velocity</i> templates
* contained within the <code>hapi-tinder-plugin</code> Maven plug-in
* classpath that will be used to generate the files.</td>
* <td valign="top" align="center" rowspan="2">One of these two options must be configured</td>
* </tr>
* <tr>
* <td valign="top">templateFile</td>
* <td valign="top">The full path to the <i>Velocity</i> template that is
* to be used to generate the files.</td>
* </tr>
* <tr>
* <td valign="top">velocityPath</td>
* <td valign="top">When using the <code>templateFile</code> option, this property
* can be used to specify where Velocity macros and other resources are located.</td>
* <td valign="top" align="center">No. Defaults to same directory as the template file.</td>
* </tr>
* <tr>
* <td valign="top">velocityProperties</td>
* <td valign="top">Specifies the full path to a java properties file
* containing Velocity configuration properties</td>
* <td valign="top" align="center">No.</td>
* </tr>
* <tr>
* <td valign="top">includeResources</td>
* <td valign="top">A list of the names of the resources or composite data types that should
* be used in the file generation</td>
* <td valign="top" align="center">No. Defaults to all defined resources except for DSTU2,
* the <code>Binary</code> resource is excluded and
* for DSTU3, the <code>Conformance</code> resource is excluded.</td>
* </tr>
* <tr>
* <td valign="top">excludeResources</td>
* <td valign="top">A list of the names of the resources or composite data types that should
* excluded from the file generation</td>
* <td valign="top" align="center">No.</td>
* </tr>
* <tr>
* <td valign="top">valueSetFiles</td>
* <td valign="top">A list of files containing value-set resource definitions
* to be used.</td>
* <td valign="top" align="center">No. Defaults to all defined value-sets that
* are referenced from the selected resources.</td>
* </tr>
* <tr>
* <td valign="top">profileFiles</td>
* <td valign="top">A list of files containing profile definitions
* to be used.</td>
* <td valign="top" align="center">No. Defaults to the default profile
* for each selected resource</td>
* </tr>
* </table>
*
*
*
* @author Bill.Denton
*
*/
@Mojo(name = "generate-multi-files", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
public class TinderGenericMultiFileMojo extends AbstractMojo {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TinderGenericMultiFileMojo.class);
@Parameter(required = true)
private String version;
@Parameter(required = true, defaultValue = "${project.build.directory}/..")
private String baseDir;
@Parameter(required = false, defaultValue="false")
private boolean generateResources;
@Parameter(required = false, defaultValue = "false")
private boolean generateDatatypes;
@Parameter(required = false, defaultValue = "false")
private boolean generateValueSets;
@Parameter(required = false)
private File targetSourceDirectory;
@Parameter(required = false)
private String targetPackage;
@Parameter(required = false)
private String filenamePrefix;
@Parameter(required = false)
private String filenameSuffix;
@Parameter(required = false)
private File targetResourceDirectory;
@Parameter(required = false)
private String targetFolder;
// one of these two is required
@Parameter(required = false)
private String template;
@Parameter(required = false)
private File templateFile;
@Parameter(required = false)
private String velocityPath;
@Parameter(required = false)
private String velocityProperties;
@Parameter(required = false)
private List<String> includeResources;
@Parameter(required = false)
private List<String> excludeResources;
@Parameter(required = false)
private String resourceSource;
@Parameter(required = false)
private List<ValueSetFileDefinition> valueSetFiles;
@Component
private MavenProject myProject;
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
GeneratorContext context = new GeneratorContext();
Generator generator = new Generator();
try {
context.setVersion(version);
context.setBaseDir(baseDir);
context.setIncludeResources(includeResources);
context.setExcludeResources(excludeResources);
context.setResourceSource(resourceSource);
context.setValueSetFiles(valueSetFiles);
if (ResourceSource.MODEL.equals(context.getResourceSource())) {
if (generateDatatypes) {
throw new MojoFailureException("Cannot use \"generateDatatypes\" when resourceSource=model");
}
if (generateValueSets) {
throw new MojoFailureException("Cannot use \"generateValueSets\" when resourceSource=model");
}
}
generator.prepare(context);
} catch (ExecutionException e) {
throw new MojoExecutionException(e.getMessage(), e.getCause());
} catch (FailureException e) {
throw new MojoFailureException(e.getMessage(), e.getCause());
}
/*
* Deal with the generation target
*/
TargetType targetType = null;
File targetDirectory = null;
if (targetSourceDirectory != null) {
if (targetResourceDirectory != null) {
throw new MojoFailureException("Both [targetSourceDirectory] and [targetResourceDirectory] are specified. Please choose just one.");
}
targetType = TargetType.SOURCE;
if (null == targetPackage) {
throw new MojoFailureException("The [targetPackage] property must be specified when generating Java source code.");
}
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 (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.");
}
targetDirectory.mkdirs();
ourLog.info(" * Output ["+targetType.toString()+"] Directory: " + targetDirectory.getAbsolutePath());
/*
* Write resources if selected
*/
BaseStructureParser rp = context.getResourceGenerator();
if (generateResources && rp != null) {
ourLog.info("Writing Resources...");
rp.setFilenamePrefix(filenamePrefix);
rp.setFilenameSuffix(filenameSuffix);
rp.setTemplate(template);
rp.setTemplateFile(templateFile);
rp.setVelocityPath(velocityPath);
rp.setVelocityProperties(velocityProperties);
rp.writeAll(targetType, targetDirectory, null, targetPackage);
}
/*
* Write composite datatypes
*/
DatatypeGeneratorUsingSpreadsheet dtp = context.getDatatypeGenerator();
if (generateDatatypes && dtp != null) {
ourLog.info("Writing Composite Datatypes...");
dtp.setFilenamePrefix(filenamePrefix);
dtp.setFilenameSuffix(filenameSuffix);
dtp.setTemplate(template);
dtp.setTemplateFile(templateFile);
dtp.setVelocityPath(velocityPath);
dtp.setVelocityProperties(velocityProperties);
dtp.writeAll(targetType, targetDirectory, null, targetPackage);
}
/*
* Write valuesets
*/
ValueSetGenerator vsp = context.getValueSetGenerator();
if (generateValueSets && vsp != null) {
ourLog.info("Writing ValueSet Enums...");
vsp.setFilenamePrefix(filenamePrefix);
vsp.setFilenameSuffix(filenameSuffix);
vsp.setTemplate(template);
vsp.setTemplateFile(templateFile);
vsp.setVelocityPath(velocityPath);
vsp.setVelocityProperties(velocityProperties);
vsp.writeMarkedValueSets(targetType, targetDirectory, targetPackage);
}
switch (targetType) {
case SOURCE: {
myProject.addCompileSourceRoot(targetSourceDirectory.getAbsolutePath());
break;
}
case RESOURCE: {
Resource resource = new Resource();
resource.setDirectory(targetResourceDirectory.getAbsolutePath());
if (targetFolder != null) {
resource.addInclude(targetFolder+"/*");
} else {
resource.addInclude("*");
}
myProject.addResource(resource);
break;
}
default:
}
}
public static void main(String[] args) throws IOException, MojoFailureException, MojoExecutionException {
// PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
// HttpClientBuilder builder = HttpClientBuilder.create();
// builder.setConnectionManager(connectionManager);
// CloseableHttpClient client = builder.build();
//
// HttpGet get = new HttpGet("http://fhir.healthintersections.com.au/open/metadata");
// CloseableHttpResponse response = client.execute(get);
//
// String metadataString = EntityUtils.toString(response.getEntity());
//
// ourLog.info("Metadata String: {}", metadataString);
// String metadataString = IOUtils.toString(new FileInputStream("src/test/resources/healthintersections-metadata.xml"));
// Conformance conformance = new FhirContext(Conformance.class).newXmlParser().parseResource(Conformance.class, metadataString);
TinderGenericMultiFileMojo mojo = new TinderGenericMultiFileMojo();
mojo.myProject = new MavenProject();
mojo.version = "dstu2";
mojo.targetPackage = "ca.uhn.test";
mojo.template = "/vm/jpa_resource_provider.vm";
mojo.targetSourceDirectory = new File("target/generated/valuesets");
mojo.execute();
}
class Generator extends AbstractGenerator {
@Override
protected void logDebug(String message) {
ourLog.debug(message);
}
@Override
protected void logInfo(String message) {
ourLog.info(message);
}
}
}

View File

@ -1,432 +1,458 @@
package ca.uhn.fhir.tinder;
import ca.uhn.fhir.tinder.AbstractGenerator.ExecutionException;
import ca.uhn.fhir.tinder.AbstractGenerator.FailureException;
import ca.uhn.fhir.tinder.TinderStructuresMojo.ValueSetFileDefinition;
import ca.uhn.fhir.tinder.parser.BaseStructureSpreadsheetParser;
import ca.uhn.fhir.tinder.parser.DatatypeGeneratorUsingSpreadsheet;
import ca.uhn.fhir.tinder.parser.ResourceGeneratorUsingSpreadsheet;
import ca.uhn.fhir.tinder.parser.TargetType;
import org.apache.commons.lang.WordUtils;
import org.apache.maven.model.Resource;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.tools.generic.EscapeTool;
import java.io.*;
import java.util.List;
/**
* Generate a single file based on resource or composite type metadata.
* <p>
* Generates either a source or resource file containing all selected resources or
* composite data types. The file is
* generated using a Velocity template that can be taken from
* inside the hapi-timder-plugin project or can be located in other projects
* <p>
* The following Maven plug-in configuration properties are used with this plug-in
* <p>
* <table border="1" cellpadding="2" cellspacing="0">
* <tr>
* <td valign="top"><b>Attribute</b></td>
* <td valign="top"><b>Description</b></td>
* <td align="center" valign="top"><b>Required</b></td>
* </tr>
* <tr>
* <td valign="top">version</td>
* <td valign="top">The FHIR version whose resource metadata
* is to be used to generate the files<br>
* Valid values:&nbsp;<code><b>dstu</b></code>&nbsp;|&nbsp;<code><b>dstu2</b></code>&nbsp;|&nbsp;<code><b>dstu3</b></code></td>
* <td valign="top" align="center">Yes</td>
* </tr>
* <tr>
* <td valign="top">baseDir</td>
* <td valign="top">The Maven project's base directory. This is used to
* possibly locate other assets within the project used in file generation.</td>
* <td valign="top" align="center">No. Defaults to: <code>${project.build.directory}/..</code></td>
* </tr>
* <tr>
* <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">One of these two options must be specified</td>
* </tr>
* <tr>
* <td valign="top">generateDataTypes</td>
* <td valign="top">Should files be generated from FHIR composite data type metadata?<br>
* Valid values:&nbsp;<code><b>true</b></code>&nbsp;|&nbsp;<code><b>false</b></code></td>
* </tr>
* <tr>
* <td colspan="3" />
* </tr>
* <tr>
* <td valign="top" colspan="3">Java source files can be generated
* 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;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>
* <tr>
* <td valign="top">targetSourceDirectory</td>
* <td valign="top">The Maven source directory to contain the generated file.</td>
* <td valign="top" align="center">Yes when a Java source file is to be generated</td>
* </tr>
* <tr>
* <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>
* </tr>
* <tr>
* <td colspan="3" />
* </tr>
* <tr>
* <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;targetFolder&gt;/&lt;targetFile&gt;<br>
* </td>
* </tr>
* <tr>
* <td valign="top">targetResourceDirectory</td>
* <td valign="top">The Maven resource directory to contain the generated file.</td>
* <td valign="top" align="center">Yes when a resource file is to be generated</td>
* </tr>
* <tr>
* <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>
* </tr>
* <tr>
* <td colspan="3" />
* </tr>
* <tr>
* <td valign="top">template</td>
* <td valign="top">The path of one of the <i>Velocity</i> templates
* contained within the <code>hapi-tinder-plugin</code> Maven plug-in
* classpath that will be used to generate the files.</td>
* <td valign="top" align="center" rowspan="2">One of these two options must be configured</td>
* </tr>
* <tr>
* <td valign="top">templateFile</td>
* <td valign="top">The full path to the <i>Velocity</i> template that is
* to be used to generate the files.</td>
* </tr>
* <tr>
* <td valign="top">velocityPath</td>
* <td valign="top">When using the <code>templateFile</code> option, this property
* can be used to specify where Velocity macros and other resources are located.</td>
* <td valign="top" align="center">No. Defaults to same directory as the template file.</td>
* </tr>
* <tr>
* <td valign="top">velocityProperties</td>
* <td valign="top">Specifies the full path to a java properties file
* containing Velocity configuration properties</td>
* <td valign="top" align="center">No.</td>
* </tr>
* <tr>
* <td valign="top">includeResources</td>
* <td valign="top">A list of the names of the resources or composite data types that should
* be used in the file generation</td>
* <td valign="top" align="center">No. Defaults to all defined resources except for DSTU2,
* the <code>Binary</code> resource is excluded and
* for DSTU3, the <code>Conformance</code> resource is excluded.</td>
* </tr>
* <tr>
* <td valign="top">excludeResources</td>
* <td valign="top">A list of the names of the resources or composite data types that should
* excluded from the file generation</td>
* <td valign="top" align="center">No.</td>
* </tr>
* <tr>
* <td valign="top">valueSetFiles</td>
* <td valign="top">A list of files containing value-set resource definitions
* to be used.</td>
* <td valign="top" align="center">No. Defaults to all defined value-sets that
* are referenced from the selected resources.</td>
* </tr>
* <tr>
* <td valign="top">profileFiles</td>
* <td valign="top">A list of files containing profile definitions
* to be used.</td>
* <td valign="top" align="center">No. Defaults to the default profile
* for each selected resource</td>
* </tr>
* </table>
*
*
*
* @author Bill.Denton
*
*/
@Mojo(name = "generate-single-file", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
public class TinderGenericSingleFileMojo extends AbstractMojo {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TinderGenericSingleFileMojo.class);
@Parameter(required = true)
private String version;
@Parameter(required = true, defaultValue = "${project.build.directory}/..")
private String baseDir;
@Parameter(required = false, defaultValue="false")
private boolean generateResources;
@Parameter(required = false, defaultValue = "false")
private boolean generateDatatypes;
@Parameter(required = false)
private File targetSourceDirectory;
@Parameter(required = false)
private String targetPackage;
@Parameter(required = false)
private String packageBase;
@Parameter(required = false)
private File targetResourceDirectory;
@Parameter(required = false)
private String targetFolder;
@Parameter(required = false)
private String targetFile;
// one of these two is required
@Parameter(required = false)
private String template;
@Parameter(required = false)
private File templateFile;
@Parameter(required = false)
private String velocityPath;
@Parameter(required = false)
private String velocityProperties;
@Parameter(required = false)
private List<String> includeResources;
@Parameter(required = false)
private List<String> excludeResources;
@Parameter(required = false)
private List<ValueSetFileDefinition> valueSetFiles;
@Component
private MavenProject myProject;
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
GeneratorContext context = new GeneratorContext();
context.setVersion(version);
context.setBaseDir(baseDir);
context.setIncludeResources(includeResources);
context.setExcludeResources(excludeResources);
context.setValueSetFiles(valueSetFiles);
Generator generator = new Generator();
try {
generator.prepare(context);
} catch (ExecutionException e) {
throw new MojoExecutionException(e.getMessage(), e.getCause());
} catch (FailureException e) {
throw new MojoFailureException(e.getMessage(), e.getCause());
}
try {
/*
* Deal with the generation target
*/
TargetType targetType = null;
File targetDirectory = null;
if (null == targetFile) {
throw new MojoFailureException("The [targetFile] parameter is required.");
}
if (targetSourceDirectory != null) {
if (targetResourceDirectory != null) {
throw new MojoFailureException("Both [targetSourceDirectory] and [targetResourceDirectory] are specified. Please choose just one.");
}
targetType = TargetType.SOURCE;
if (null == targetPackage) {
throw new MojoFailureException("The [targetPackage] property must be specified when generating Java source code.");
}
targetDirectory = new File(targetSourceDirectory, targetPackage.replace('.', File.separatorChar));
if (!targetFile.endsWith(".java")) {
targetFile += ".java";
}
} else
if (targetResourceDirectory != null) {
if (targetSourceDirectory != null) {
throw new MojoFailureException("Both [targetSourceDirectory] and [targetResourceDirectory] are specified. Please choose just one.");
}
targetType = TargetType.RESOURCE;
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.");
}
ourLog.info(" * Output ["+targetType.toString()+"] file ["+targetFile+"] in directory: " + targetDirectory.getAbsolutePath());
targetDirectory.mkdirs();
File target = new File(targetDirectory, targetFile);
OutputStreamWriter targetWriter = new OutputStreamWriter(new FileOutputStream(target, false), "UTF-8");
/*
* Next, deal with the template and initialize velocity
*/
VelocityEngine v = VelocityHelper.configureVelocityEngine(templateFile, velocityPath, velocityProperties);
InputStream templateIs = null;
if (templateFile != null) {
templateIs = new FileInputStream(templateFile);
} else {
templateIs = this.getClass().getResourceAsStream(template);
}
InputStreamReader templateReader = new InputStreamReader(templateIs);
/*
* build new Velocity Context
*/
VelocityContext ctx = new VelocityContext();
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", "#");
ctx.put("esc", new EscapeTool());
if (BaseStructureSpreadsheetParser.determineVersionEnum(version).isRi()) {
ctx.put("resourcePackage", "org.hl7.fhir." + version + ".model");
} else {
ctx.put("resourcePackage", "ca.uhn.fhir.model." + version + ".resource");
}
String capitalize = WordUtils.capitalize(version);
if ("Dstu".equals(capitalize)) {
capitalize="Dstu1";
}
ctx.put("versionCapitalized", capitalize);
/*
* Write resources if selected
*/
ResourceGeneratorUsingSpreadsheet rp = context.getResourceGenerator();
if (generateResources && rp != null) {
ourLog.info("Writing Resources...");
ctx.put("resources", rp.getResources());
v.evaluate(ctx, targetWriter, "", templateReader);
targetWriter.close();
} else {
DatatypeGeneratorUsingSpreadsheet dtp = context.getDatatypeGenerator();
if (generateDatatypes && dtp != null) {
ourLog.info("Writing DataTypes...");
ctx.put("datatypes", dtp.getResources());
v.evaluate(ctx, targetWriter, "", templateReader);
targetWriter.close();
}
}
switch (targetType) {
case SOURCE: {
myProject.addCompileSourceRoot(targetSourceDirectory.getAbsolutePath());
break;
}
case RESOURCE: {
Resource resource = new Resource();
resource.setDirectory(targetResourceDirectory.getAbsolutePath());
String resName = targetFile;
if (targetFolder != null) {
resName = targetFolder+File.separator+targetFile;
}
resource.addInclude(resName);
myProject.addResource(resource);
break;
}
default:
}
} catch (Exception e) {
throw new MojoFailureException("Failed to generate file", e);
}
}
public static void main(String[] args) throws IOException, MojoFailureException, MojoExecutionException {
// PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
// HttpClientBuilder builder = HttpClientBuilder.create();
// builder.setConnectionManager(connectionManager);
// CloseableHttpClient client = builder.build();
//
// HttpGet get = new HttpGet("http://fhir.healthintersections.com.au/open/metadata");
// CloseableHttpResponse response = client.execute(get);
//
// String metadataString = EntityUtils.toString(response.getEntity());
//
// ourLog.info("Metadata String: {}", metadataString);
// String metadataString = IOUtils.toString(new FileInputStream("src/test/resources/healthintersections-metadata.xml"));
// Conformance conformance = new FhirContext(Conformance.class).newXmlParser().parseResource(Conformance.class, metadataString);
TinderGenericSingleFileMojo mojo = new TinderGenericSingleFileMojo();
mojo.myProject = new MavenProject();
mojo.template = "/vm/jpa_spring_beans.vm";
mojo.version = "dstu2";
mojo.targetPackage = "ca.uhn.test";
mojo.targetSourceDirectory = new File("target/generated/valuesets");
mojo.targetFile = "tmp_beans.xml";
mojo.execute();
}
class Generator extends AbstractGenerator {
@Override
protected void logDebug(String message) {
ourLog.debug(message);
}
@Override
protected void logInfo(String message) {
ourLog.info(message);
}
}
}
package ca.uhn.fhir.tinder;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.List;
import org.apache.commons.lang.WordUtils;
import org.apache.maven.model.Resource;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.tools.generic.EscapeTool;
import ca.uhn.fhir.tinder.AbstractGenerator.ExecutionException;
import ca.uhn.fhir.tinder.AbstractGenerator.FailureException;
import ca.uhn.fhir.tinder.GeneratorContext.ResourceSource;
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.
* <p>
* Generates either a source or resource file containing all selected resources or
* composite data types. The file is
* generated using a Velocity template that can be taken from
* inside the hapi-timder-plugin project or can be located in other projects
* <p>
* The following Maven plug-in configuration properties are used with this plug-in
* <p>
* <table border="1" cellpadding="2" cellspacing="0">
* <tr>
* <td valign="top"><b>Attribute</b></td>
* <td valign="top"><b>Description</b></td>
* <td align="center" valign="top"><b>Required</b></td>
* </tr>
* <tr>
* <td valign="top">version</td>
* <td valign="top">The FHIR version whose resource metadata
* is to be used to generate the files<br>
* Valid values:&nbsp;<code><b>dstu2</b></code>&nbsp;|&nbsp;<code><b>dstu3</b></code>&nbsp;|&nbsp;<code><b>r4</b></code></td>
* <td valign="top" align="center">Yes</td>
* </tr>
* <tr>
* <td valign="top">baseDir</td>
* <td valign="top">The Maven project's base directory. This is used to
* possibly locate other assets within the project used in file generation.</td>
* <td valign="top" align="center">No. Defaults to: <code>${project.build.directory}/..</code></td>
* </tr>
* <tr>
* <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">One of these two options must be specified as <code><b>true</b></code></td>
* </tr>
* <tr>
* <td valign="top">generateDataTypes</td>
* <td valign="top">Should files be generated from FHIR composite data type metadata?<br>
* Valid values:&nbsp;<code><b>true</b></code>&nbsp;|&nbsp;<code><b>false</b></code></td>
* </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>&nbsp;&nbsp;to cause resources to be generated based on the FHIR spreadsheets</li>
* <li><code><b>model</b></code>&nbsp;&nbsp;to cause resources to be generated based on the model structure classes. Note that
* <code>generateResources</code> is the only one of the above options that can be used when <code>model</code> is specified.</li></ul></td>
* <td valign="top" align="center">No. Defaults to: <code><b>spreadsheet</b></code></td>
* </tr>
* <tr>
* <td colspan="3" />
* </tr>
* <tr>
* <td valign="top" colspan="3">Java source files can be generated
* 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;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>
* <tr>
* <td valign="top">targetSourceDirectory</td>
* <td valign="top">The Maven source directory to contain the generated file.</td>
* <td valign="top" align="center">Yes when a Java source file is to be generated</td>
* </tr>
* <tr>
* <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>
* </tr>
* <tr>
* <td colspan="3" />
* </tr>
* <tr>
* <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;targetFolder&gt;/&lt;targetFile&gt;<br>
* </td>
* </tr>
* <tr>
* <td valign="top">targetResourceDirectory</td>
* <td valign="top">The Maven resource directory to contain the generated file.</td>
* <td valign="top" align="center">Yes when a resource file is to be generated</td>
* </tr>
* <tr>
* <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>
* </tr>
* <tr>
* <td colspan="3" />
* </tr>
* <tr>
* <td valign="top">template</td>
* <td valign="top">The path of one of the <i>Velocity</i> templates
* contained within the <code>hapi-tinder-plugin</code> Maven plug-in
* classpath that will be used to generate the files.</td>
* <td valign="top" align="center" rowspan="2">One of these two options must be configured</td>
* </tr>
* <tr>
* <td valign="top">templateFile</td>
* <td valign="top">The full path to the <i>Velocity</i> template that is
* to be used to generate the files.</td>
* </tr>
* <tr>
* <td valign="top">velocityPath</td>
* <td valign="top">When using the <code>templateFile</code> option, this property
* can be used to specify where Velocity macros and other resources are located.</td>
* <td valign="top" align="center">No. Defaults to same directory as the template file.</td>
* </tr>
* <tr>
* <td valign="top">velocityProperties</td>
* <td valign="top">Specifies the full path to a java properties file
* containing Velocity configuration properties</td>
* <td valign="top" align="center">No.</td>
* </tr>
* <tr>
* <td valign="top">includeResources</td>
* <td valign="top">A list of the names of the resources or composite data types that should
* be used in the file generation</td>
* <td valign="top" align="center">No. Defaults to all defined resources except for DSTU2,
* the <code>Binary</code> resource is excluded and
* for DSTU3, the <code>Conformance</code> resource is excluded.</td>
* </tr>
* <tr>
* <td valign="top">excludeResources</td>
* <td valign="top">A list of the names of the resources or composite data types that should
* excluded from the file generation</td>
* <td valign="top" align="center">No.</td>
* </tr>
* <tr>
* <td valign="top">valueSetFiles</td>
* <td valign="top">A list of files containing value-set resource definitions
* to be used.</td>
* <td valign="top" align="center">No. Defaults to all defined value-sets that
* are referenced from the selected resources.</td>
* </tr>
* <tr>
* <td valign="top">profileFiles</td>
* <td valign="top">A list of files containing profile definitions
* to be used.</td>
* <td valign="top" align="center">No. Defaults to the default profile
* for each selected resource</td>
* </tr>
* </table>
*
*
*
* @author Bill.Denton
*
*/
@Mojo(name = "generate-single-file", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
public class TinderGenericSingleFileMojo extends AbstractMojo {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TinderGenericSingleFileMojo.class);
@Parameter(required = true)
private String version;
@Parameter(required = true, defaultValue = "${project.build.directory}/..")
private String baseDir;
@Parameter(required = false, defaultValue="false")
private boolean generateResources;
@Parameter(required = false, defaultValue = "false")
private boolean generateDatatypes;
@Parameter(required = false)
private File targetSourceDirectory;
@Parameter(required = false)
private String targetPackage;
@Parameter(required = false)
private String packageBase;
@Parameter(required = false)
private File targetResourceDirectory;
@Parameter(required = false)
private String targetFolder;
@Parameter(required = false)
private String targetFile;
// one of these two is required
@Parameter(required = false)
private String template;
@Parameter(required = false)
private File templateFile;
@Parameter(required = false)
private String velocityPath;
@Parameter(required = false)
private String velocityProperties;
@Parameter(required = false)
private List<String> includeResources;
@Parameter(required = false)
private List<String> excludeResources;
@Parameter(required = false)
private String resourceSource;
@Parameter(required = false)
private List<ValueSetFileDefinition> valueSetFiles;
@Component
private MavenProject myProject;
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
GeneratorContext context = new GeneratorContext();
Generator generator = new Generator();
try {
context.setVersion(version);
context.setBaseDir(baseDir);
context.setIncludeResources(includeResources);
context.setExcludeResources(excludeResources);
context.setResourceSource(resourceSource);
context.setValueSetFiles(valueSetFiles);
if (ResourceSource.MODEL.equals(context.getResourceSource())) {
if (generateDatatypes) {
throw new MojoFailureException("Cannot use \"generateDatatypes\" when resourceSource=model");
}
}
generator.prepare(context);
} catch (ExecutionException e) {
throw new MojoExecutionException(e.getMessage(), e.getCause());
} catch (FailureException e) {
throw new MojoFailureException(e.getMessage(), e.getCause());
}
try {
/*
* Deal with the generation target
*/
TargetType targetType = null;
File targetDirectory = null;
if (null == targetFile) {
throw new MojoFailureException("The [targetFile] parameter is required.");
}
if (targetSourceDirectory != null) {
if (targetResourceDirectory != null) {
throw new MojoFailureException("Both [targetSourceDirectory] and [targetResourceDirectory] are specified. Please choose just one.");
}
targetType = TargetType.SOURCE;
if (null == targetPackage) {
throw new MojoFailureException("The [targetPackage] property must be specified when generating Java source code.");
}
targetDirectory = new File(targetSourceDirectory, targetPackage.replace('.', File.separatorChar));
if (!targetFile.endsWith(".java")) {
targetFile += ".java";
}
} else
if (targetResourceDirectory != null) {
if (targetSourceDirectory != null) {
throw new MojoFailureException("Both [targetSourceDirectory] and [targetResourceDirectory] are specified. Please choose just one.");
}
targetType = TargetType.RESOURCE;
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.");
}
ourLog.info(" * Output ["+targetType.toString()+"] file ["+targetFile+"] in directory: " + targetDirectory.getAbsolutePath());
targetDirectory.mkdirs();
File target = new File(targetDirectory, targetFile);
OutputStreamWriter targetWriter = new OutputStreamWriter(new FileOutputStream(target, false), "UTF-8");
/*
* Next, deal with the template and initialize velocity
*/
VelocityEngine v = VelocityHelper.configureVelocityEngine(templateFile, velocityPath, velocityProperties);
InputStream templateIs = null;
if (templateFile != null) {
templateIs = new FileInputStream(templateFile);
} else {
templateIs = this.getClass().getResourceAsStream(template);
}
InputStreamReader templateReader = new InputStreamReader(templateIs);
/*
* build new Velocity Context
*/
VelocityContext ctx = new VelocityContext();
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", "#");
ctx.put("esc", new EscapeTool());
if (BaseStructureSpreadsheetParser.determineVersionEnum(version).isRi()) {
ctx.put("resourcePackage", "org.hl7.fhir." + version + ".model");
} else {
ctx.put("resourcePackage", "ca.uhn.fhir.model." + version + ".resource");
}
String capitalize = WordUtils.capitalize(version);
if ("Dstu".equals(capitalize)) {
capitalize="Dstu1";
}
ctx.put("versionCapitalized", capitalize);
/*
* Write resources if selected
*/
BaseStructureParser rp = context.getResourceGenerator();
if (generateResources && rp != null) {
ourLog.info("Writing Resources...");
ctx.put("resources", rp.getResources());
v.evaluate(ctx, targetWriter, "", templateReader);
targetWriter.close();
} else {
DatatypeGeneratorUsingSpreadsheet dtp = context.getDatatypeGenerator();
if (generateDatatypes && dtp != null) {
ourLog.info("Writing DataTypes...");
ctx.put("datatypes", dtp.getResources());
v.evaluate(ctx, targetWriter, "", templateReader);
targetWriter.close();
}
}
switch (targetType) {
case SOURCE: {
myProject.addCompileSourceRoot(targetSourceDirectory.getAbsolutePath());
break;
}
case RESOURCE: {
Resource resource = new Resource();
resource.setDirectory(targetResourceDirectory.getAbsolutePath());
String resName = targetFile;
if (targetFolder != null) {
resName = targetFolder+File.separator+targetFile;
}
resource.addInclude(resName);
myProject.addResource(resource);
break;
}
default:
}
} catch (Exception e) {
throw new MojoFailureException("Failed to generate file", e);
}
}
public static void main(String[] args) throws IOException, MojoFailureException, MojoExecutionException {
// PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
// HttpClientBuilder builder = HttpClientBuilder.create();
// builder.setConnectionManager(connectionManager);
// CloseableHttpClient client = builder.build();
//
// HttpGet get = new HttpGet("http://fhir.healthintersections.com.au/open/metadata");
// CloseableHttpResponse response = client.execute(get);
//
// String metadataString = EntityUtils.toString(response.getEntity());
//
// ourLog.info("Metadata String: {}", metadataString);
// String metadataString = IOUtils.toString(new FileInputStream("src/test/resources/healthintersections-metadata.xml"));
// Conformance conformance = new FhirContext(Conformance.class).newXmlParser().parseResource(Conformance.class, metadataString);
TinderGenericSingleFileMojo mojo = new TinderGenericSingleFileMojo();
mojo.myProject = new MavenProject();
mojo.template = "/vm/jpa_spring_beans.vm";
mojo.version = "dstu2";
mojo.targetPackage = "ca.uhn.test";
mojo.targetSourceDirectory = new File("target/generated/valuesets");
mojo.targetFile = "tmp_beans.xml";
mojo.execute();
}
class Generator extends AbstractGenerator {
@Override
protected void logDebug(String message) {
ourLog.debug(message);
}
@Override
protected void logInfo(String message) {
ourLog.info(message);
}
}
}

View File

@ -1,420 +1,489 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>3.7.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>hapi-tinder-test</artifactId>
<packaging>jar</packaging>
<name>HAPI Tinder Plugin - Test Project</name>
<dependencies>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Because Tinder is a part of the HAPI FHIR build process (it generates a bunch of the actual HAPI structure code), but also uses HAPI FHIR in order to run (e.g. to load ValueSet resources), we keep
the dependencies for the structures a version behind the main library. This is weird, but it works. -->
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2.1</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu3</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu3</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- <plugin> <groupId>ca.uhn.hapi.fhir</groupId> <artifactId>hapi-tinder-plugin</artifactId> <version>1.0-SNAPSHOT</version> <executions> <execution> <id>structs</id> <goals> <goal>generate-structures</goal>
</goals> <configuration> <package>ca.uhn.tindertest</package> <baseResourceNames> <baseResourceName>patient</baseResourceName> <baseResourceName>valueset</baseResourceName> <baseResourceName>organization</baseResourceName>
<baseResourceName>device</baseResourceName> <baseResourceName>location</baseResourceName> <baseResourceName>practitioner</baseResourceName> </baseResourceNames> </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> </plugin> -->
<plugin>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-tinder-plugin</artifactId>
<version>${project.version}</version>
<dependencies>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2.1</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu3</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu3</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<executions>
<!--
<execution>
<id>custom-structs</id>
<goals>
<goal>generate-structures</goal>
</goals>
<configuration>
<package>ca.uhn.test.customstructs</package>
<profileHttpBase>http://foo</profileHttpBase>
<version>dstu</version>
<resourceProfileFiles>
<resourceProfileFile>
<profileFile>${project.basedir}/src/test/resources/profile/patient.xml</profileFile>
<profileSourceUrl>http://foo1</profileSourceUrl>
</resourceProfileFile>
<resourceProfileFile>
<profileFile>${project.basedir}/src/test/resources/profile/organization.xml</profileFile>
<profileSourceUrl>http://foo1</profileSourceUrl>
</resourceProfileFile>
</resourceProfileFiles>
<resourceValueSetFiles>
<resourceValueSetFile>
<valueSetFile>${project.basedir}/src/test/resources/valueset/valueset-cgta-patientidpool.xml</valueSetFile>
</resourceValueSetFile>
<resourceValueSetFile>
<valueSetFile>${project.basedir}/src/test/resources/valueset/valueset-cgta-provideridpool.xml</valueSetFile>
</resourceValueSetFile>
</resourceValueSetFiles>
</configuration>
</execution>
-->
<execution>
<id>generalstructs</id>
<goals>
<goal>generate-structures</goal>
</goals>
<configuration>
<package>ca.uhn.test.realstructs</package>
<version>dstu2</version>
<baseResourceNames>
<baseResourceName>patient</baseResourceName>
<baseResourceName>valueset</baseResourceName>
<baseResourceName>organization</baseResourceName>
<baseResourceName>device</baseResourceName>
<baseResourceName>location</baseResourceName>
<baseResourceName>practitioner</baseResourceName>
<baseResourceName>list</baseResourceName>
<baseResourceName>auditevent</baseResourceName>
</baseResourceNames>
<buildDatatypes>true</buildDatatypes>
</configuration>
</execution>
<execution>
<id>generic_multi</id>
<goals>
<goal>generate-multi-files</goal>
</goals>
<configuration>
<version>dstu2</version>
<generateResources>true</generateResources>
<templateFile>${project.basedir}/src/test/resources/templates/resource_test.vm</templateFile>
<targetSourceDirectory>${project.build.directory}/generated-sources/tinder</targetSourceDirectory>
<targetPackage>ca.uhn.test.generic.multi</targetPackage>
<filenameSuffix>ResourceTest.java</filenameSuffix>
<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>
<includeResource>bundle</includeResource>
<includeResource>composition</includeResource>
</includeResources>
</configuration>
</execution>
<execution>
<id>generic_single</id>
<goals>
<goal>generate-single-file</goal>
</goals>
<configuration>
<version>dstu2</version>
<generateResources>true</generateResources>
<templateFile>${project.basedir}/src/test/resources/templates/resource_test_beans_java.vm</templateFile>
<targetSourceDirectory>${project.build.directory}/generated-sources/tinder</targetSourceDirectory>
<targetPackage>ca.uhn.test.generic.single</targetPackage>
<packageBase>ca.uhn.test.generic.multi</packageBase>
<targetFile>TestConfigDstu2.java</targetFile>
<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>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>testTinderTask</id>
<phase>generate-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<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" generateResources="true" targetSourceDirectory="${project.build.directory}/generated-sources/tinder"
targetPackage="ca.uhn.test.ant.multi" filenameSuffix="ResourceTest.java" projectHome="${project.basedir}/.." version="dstu2" includeResources="patient,organization" />
<hapi-tinder templateFile="${project.basedir}/src/test/resources/templates/resource_test_beans_java.vm" 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" includeResources="patient,organization" />
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2.1</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu3</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu3</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-tinder-plugin</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/generated-sources/tinder</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-tinder-plugin</artifactId>
<versionRange>[0.4-SNAPSHOT,)</versionRange>
<goals>
<goal>generate-structures</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-tinder-plugin</artifactId>
<versionRange>[0.4-SNAPSHOT,)</versionRange>
<goals>
<goal>generate-multi-files</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-tinder-plugin</artifactId>
<versionRange>[0.4-SNAPSHOT,)</versionRange>
<goals>
<goal>generate-single-file</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
<resource>
<directory>${basedir}/target/generated-resources/tinder</directory>
</resource>
</resources>
</build>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>3.7.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>hapi-tinder-test</artifactId>
<packaging>jar</packaging>
<name>HAPI Tinder Plugin - Test Project</name>
<dependencies>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Because Tinder is a part of the HAPI FHIR build process (it generates a bunch of the actual HAPI structure code), but also uses HAPI FHIR in order to run (e.g. to load ValueSet resources), we keep
the dependencies for the structures a version behind the main library. This is weird, but it works. -->
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2.1</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu3</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu3</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- <plugin> <groupId>ca.uhn.hapi.fhir</groupId> <artifactId>hapi-tinder-plugin</artifactId> <version>1.0-SNAPSHOT</version> <executions> <execution> <id>structs</id> <goals> <goal>generate-structures</goal>
</goals> <configuration> <package>ca.uhn.tindertest</package> <baseResourceNames> <baseResourceName>patient</baseResourceName> <baseResourceName>valueset</baseResourceName> <baseResourceName>organization</baseResourceName>
<baseResourceName>device</baseResourceName> <baseResourceName>location</baseResourceName> <baseResourceName>practitioner</baseResourceName> </baseResourceNames> </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> </plugin> -->
<plugin>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-tinder-plugin</artifactId>
<version>${project.version}</version>
<dependencies>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2.1</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu3</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-r4</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu3</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-r4</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<executions>
<!--
<execution>
<id>custom-structs</id>
<goals>
<goal>generate-structures</goal>
</goals>
<configuration>
<package>ca.uhn.test.customstructs</package>
<profileHttpBase>http://foo</profileHttpBase>
<version>dstu</version>
<resourceProfileFiles>
<resourceProfileFile>
<profileFile>${project.basedir}/src/test/resources/profile/patient.xml</profileFile>
<profileSourceUrl>http://foo1</profileSourceUrl>
</resourceProfileFile>
<resourceProfileFile>
<profileFile>${project.basedir}/src/test/resources/profile/organization.xml</profileFile>
<profileSourceUrl>http://foo1</profileSourceUrl>
</resourceProfileFile>
</resourceProfileFiles>
<resourceValueSetFiles>
<resourceValueSetFile>
<valueSetFile>${project.basedir}/src/test/resources/valueset/valueset-cgta-patientidpool.xml</valueSetFile>
</resourceValueSetFile>
<resourceValueSetFile>
<valueSetFile>${project.basedir}/src/test/resources/valueset/valueset-cgta-provideridpool.xml</valueSetFile>
</resourceValueSetFile>
</resourceValueSetFiles>
</configuration>
</execution>
-->
<execution>
<id>generalstructs</id>
<goals>
<goal>generate-structures</goal>
</goals>
<configuration>
<package>ca.uhn.test.realstructs</package>
<version>dstu2</version>
<baseResourceNames>
<baseResourceName>patient</baseResourceName>
<baseResourceName>valueset</baseResourceName>
<baseResourceName>organization</baseResourceName>
<baseResourceName>device</baseResourceName>
<baseResourceName>location</baseResourceName>
<baseResourceName>practitioner</baseResourceName>
<baseResourceName>list</baseResourceName>
<baseResourceName>auditevent</baseResourceName>
</baseResourceNames>
<buildDatatypes>true</buildDatatypes>
</configuration>
</execution>
<execution>
<id>generic_multi_dstu2</id>
<goals>
<goal>generate-multi-files</goal>
</goals>
<configuration>
<version>dstu2</version>
<generateResources>true</generateResources>
<templateFile>${project.basedir}/src/test/resources/templates/resource_test.vm</templateFile>
<targetSourceDirectory>${project.build.directory}/generated-sources/tinder</targetSourceDirectory>
<targetPackage>ca.uhn.test.generic.multi</targetPackage>
<filenameSuffix>ResourceTest.java</filenameSuffix>
<includeResources>
<includeResource>patient</includeResource>
<includeResource>organization</includeResource>
</includeResources>
</configuration>
</execution>
<execution>
<id>generic_multi_dstu3</id>
<goals>
<goal>generate-multi-files</goal>
</goals>
<configuration>
<version>dstu3</version>
<generateResources>true</generateResources>
<resourceSource>model</resourceSource>
<templateFile>${project.basedir}/src/test/resources/templates/resource_test.vm</templateFile>
<targetSourceDirectory>${project.build.directory}/generated-sources/tinder</targetSourceDirectory>
<targetPackage>ca.uhn.test.generic.multi.dstu3</targetPackage>
<filenameSuffix>ResourceTest.java</filenameSuffix>
<includeResources>
<includeResource>patient</includeResource>
<includeResource>organization</includeResource>
</includeResources>
</configuration>
</execution>
<execution>
<id>generic_multi_r4</id>
<goals>
<goal>generate-multi-files</goal>
</goals>
<configuration>
<version>r4</version>
<generateResources>true</generateResources>
<resourceSource>model</resourceSource>
<templateFile>${project.basedir}/src/test/resources/templates/resource_test.vm</templateFile>
<targetSourceDirectory>${project.build.directory}/generated-sources/tinder</targetSourceDirectory>
<targetPackage>ca.uhn.test.generic.multi.r4</targetPackage>
<filenameSuffix>ResourceTest.java</filenameSuffix>
<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>
<resourceSource>spreadsheet</resourceSource>
<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>
<includeResource>bundle</includeResource>
<includeResource>composition</includeResource>
</includeResources>
</configuration>
</execution>
<execution>
<id>generic_single_dstu2</id>
<goals>
<goal>generate-single-file</goal>
</goals>
<configuration>
<version>dstu2</version>
<generateResources>true</generateResources>
<templateFile>${project.basedir}/src/test/resources/templates/resource_test_beans_java.vm</templateFile>
<targetSourceDirectory>${project.build.directory}/generated-sources/tinder</targetSourceDirectory>
<targetPackage>ca.uhn.test.generic.single</targetPackage>
<packageBase>ca.uhn.test.generic.multi</packageBase>
<targetFile>TestConfigDstu2.java</targetFile>
<includeResources>
<includeResource>patient</includeResource>
<includeResource>organization</includeResource>
</includeResources>
</configuration>
</execution>
<execution>
<id>generic_single_r4</id>
<goals>
<goal>generate-single-file</goal>
</goals>
<configuration>
<version>r4</version>
<generateResources>true</generateResources>
<resourceSource>model</resourceSource>
<templateFile>${project.basedir}/src/test/resources/templates/resource_test_beans_java.vm</templateFile>
<targetSourceDirectory>${project.build.directory}/generated-sources/tinder</targetSourceDirectory>
<targetPackage>ca.uhn.test.generic.single.r4</targetPackage>
<packageBase>ca.uhn.test.generic.multi.r4</packageBase>
<targetFile>TestConfigR4.java</targetFile>
<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>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>testTinderTask</id>
<phase>generate-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<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" generateResources="true" targetSourceDirectory="${project.build.directory}/generated-sources/tinder"
targetPackage="ca.uhn.test.ant.multi" filenameSuffix="ResourceTest.java" projectHome="${project.basedir}/.." version="dstu2" includeResources="patient,organization" />
<hapi-tinder templateFile="${project.basedir}/src/test/resources/templates/resource_test_beans_java.vm" 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" includeResources="patient,organization" />
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2.1</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu3</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu3</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-tinder-plugin</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/generated-sources/tinder</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-tinder-plugin</artifactId>
<versionRange>[0.4-SNAPSHOT,)</versionRange>
<goals>
<goal>generate-structures</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-tinder-plugin</artifactId>
<versionRange>[0.4-SNAPSHOT,)</versionRange>
<goals>
<goal>generate-multi-files</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-tinder-plugin</artifactId>
<versionRange>[0.4-SNAPSHOT,)</versionRange>
<goals>
<goal>generate-single-file</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
<resource>
<directory>${basedir}/target/generated-resources/tinder</directory>
</resource>
</resources>
</build>
</project>

10
pom.xml
View File

@ -493,6 +493,16 @@
<id>ruoat</id>
<name>Ari Ruotsalainen</name>
</developer>
<developer>
<id>stevelle</id>
<name>Steve Lewis</name>
<organization>Cambia Health Solutions</organization>
</developer>
<developer>
<id>restevez-chs</id>
<name>Ricardo Estevez</name>
<organization>Cambia Health Solutions</organization>
</developer>
</developers>
<licenses>

View File

@ -344,6 +344,14 @@
using data parameters has been fixed. Thanks to GitHub user
@PickOneFish for reporting!
</action>
<action type="fix" issue="1135">
An issue with outdated syntax in the Vagrant file that prevent it from being used
was corrected. Thanks to Steve Lewis for the pull requst!
</action>
<action type="fix" issue="1130">
The HAPI FHIR tutorial server project had outdated versions of HAPI FHIR
in its pom file. Thanks to Ricardo Estevez for the pull request!
</action>
</release>
<release version="3.6.0" date="2018-11-12" description="Food">
<action type="add">

View File

@ -19,7 +19,12 @@
# default jdk attributes
default['java']['jdk_version'] = '6'
default['java']['arch'] = kernel['machine'] =~ /x86_64/ ? "x86_64" : "i586"
default['java']['arch'] = if node['kernel']['machine'].match?(/x86_64/)
"x86_64"
else
"i586"
end
#default['java']['arch'] = kernel['machine'] =~ /x86_64/ ?
default['java']['openjdk_packages'] = []
default['java']['openjdk_version'] = nil
default['java']['accept_license_agreement'] = false

View File

@ -114,7 +114,7 @@ class Chef
end
def platform_requires_license_acceptance?
%w(smartos).include?(node.platform)
%w(smartos).include?(node['platform_family'])
end
end
end

View File

@ -1,30 +1,29 @@
# provider mappings
# client
Chef::Platform.set :platform => :debian, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Debian
Chef::Platform.set :platform => :fedora, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Fedora
Chef::Platform.set :platform => :freebsd, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::FreeBSD
Chef::Platform.set :platform => :omnios, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Omnios
Chef::Platform.set :platform => :rhel, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Rhel
Chef::Platform.set :platform => :amazon, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Rhel
Chef::Platform.set :platform => :redhat, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Rhel
Chef::Platform.set :platform => :centos, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Rhel
Chef::Platform.set :platform => :oracle, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Rhel
Chef::Platform.set :platform => :scientific, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Rhel
Chef::Platform.set :platform => :smartos, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Smartos
Chef::Platform.set :platform => :suse, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Suse
Chef::Platform.set :platform => :ubuntu, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Ubuntu
Chef::Provider::MysqlClient::Debian.provides :mysql_client, platform: "debian"
Chef::Provider::MysqlClient::Fedora.provides :mysql_client, platform: "fedora"
Chef::Provider::MysqlClient::FreeBSD.provides :mysql_client, platform: "freebsd"
Chef::Provider::MysqlClient::Omnios.provides :mysql_client, platform: "omnios"
Chef::Provider::MysqlClient::Rhel.provides :mysql_client, platform: "amazon"
Chef::Provider::MysqlClient::Rhel.provides :mysql_client, platform: "redhat"
Chef::Provider::MysqlClient::Rhel.provides :mysql_client, platform: "centos"
Chef::Provider::MysqlClient::Rhel.provides :mysql_client, platform: "oracle"
Chef::Provider::MysqlClient::Rhel.provides :mysql_client, platform: "scientific"
Chef::Provider::MysqlClient::Smartos.provides :mysql_client, platform: "smartos"
Chef::Provider::MysqlClient::Suse.provides :mysql_client, platform: "suse"
Chef::Provider::MysqlClient::Ubuntu.provides :mysql_client, platform: "ubuntu"
# service
Chef::Platform.set :platform => :debian, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Debian
Chef::Platform.set :platform => :fedora, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Fedora
Chef::Platform.set :platform => :freebsd, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::FreeBSD
Chef::Platform.set :platform => :omnios, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Omnios
Chef::Platform.set :platform => :amazon, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Rhel
Chef::Platform.set :platform => :redhat, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Rhel
Chef::Platform.set :platform => :centos, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Rhel
Chef::Platform.set :platform => :oracle, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Rhel
Chef::Platform.set :platform => :scientific, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Rhel
Chef::Platform.set :platform => :smartos, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Smartos
Chef::Platform.set :platform => :suse, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Suse
Chef::Platform.set :platform => :ubuntu, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Ubuntu
Chef::Provider::MysqlService::Debian.provides :mysql_service, platform: "debian"
Chef::Provider::MysqlService::Fedora.provides :mysql_service, platform: "fedora"
Chef::Provider::MysqlService::FreeBSD.provides :mysql_service, platform: "freebsd"
Chef::Provider::MysqlService::Omnios.provides :mysql_service, platform: "omnios"
Chef::Provider::MysqlService::Rhel.provides :mysql_service, platform: "amazon"
Chef::Provider::MysqlService::Rhel.provides :mysql_service, platform: "redhat"
Chef::Provider::MysqlService::Rhel.provides :mysql_service, platform: "centos"
Chef::Provider::MysqlService::Rhel.provides :mysql_service, platform: "oracle"
Chef::Provider::MysqlService::Rhel.provides :mysql_service, platform: "scientific"
Chef::Provider::MysqlService::Smartos.provides :mysql_service, platform: "smartos"
Chef::Provider::MysqlService::Suse.provides :mysql_service, platform: "suse"
Chef::Provider::MysqlService::Ubuntu.provides :mysql_service, platform: "ubuntu"

View File

@ -40,7 +40,7 @@ Most often this will be used to generate a secure password for an attribute. In
```ruby
::Chef::Recipe.send(:include, Opscode::OpenSSL::Password)
node.set_unless[:my_password] = secure_password
node.default_unless[:my_password] = secure_password
```
To use the `openssl::upgrade` recipe, set the attributes as mentioned above. For example, we have a "stats_collector" service that uses openssl. It has a recipe that looks like this:

View File

@ -2,7 +2,7 @@
"name": "openssl",
"version": "2.0.0",
"description": "Provides a library with a method for generating secure random passwords.",
"long_description": "openssl Cookbook\n================\n\nThis cookbook provides a library method to generate secure random passwords in recipes using the Ruby OpenSSL library.\n\nIt also provides an attribute-driven recipe for upgrading OpenSSL packages.\n\nRequirements\n------------\n\nThe `secure_password` works on any platform with OpenSSL Ruby bindings installed, which are a requirement for Chef anyway.\n\nThe upgrade recipe works on the following tested platforms:\n\n* Ubuntu 12.04, 14.04\n* Debian 7.4\n* CentOS 6.5\n\nIt may work on other platforms or versions of the above platforms with or without modification.\n\n[Chef Sugar](https://github.com/sethvargo/chef-sugar) was introduced as a dependency to provide helpers that make the default attribute settings (see Attributes) easier to reason about.\n\nAttributes\n----------\n\n* `node['openssl']['packages']` - An array of packages of openssl. The default attributes attempt to be smart about which packages are the default, but this may need to be changed by users of the `openssl::upgrade` recipe.\n* `node['openssl']['restart_services']` - An array of service resources that use the `node['openssl']['packages']`. This is empty by default as Chef has no reliably reasonable way to detect which applications or services are compiled against these packages. *Note* These each need to be \"`service`\" resources specified somewhere in the recipes in the node's run list.\n\nRecipes\n-------\n\n### upgrade\n\nThe upgrade recipe iterates over the list of packages in the `node['openssl']['packages']` attribute and manages them with the `:upgrade` action. Each package will send `:restart` notification to service resources named by the `node['openssl']['restart_services']` attribute.\n\nUsage\n-----\n\nMost often this will be used to generate a secure password for an attribute. In a recipe:\n\n```ruby\n::Chef::Recipe.send(:include, Opscode::OpenSSL::Password)\nnode.set_unless[:my_password] = secure_password\n```\n\nTo use the `openssl::upgrade` recipe, set the attributes as mentioned above. For example, we have a \"stats_collector\" service that uses openssl. It has a recipe that looks like this:\n\nLWRP\n==== \n\nThis cookbook includes an LWRP for generating Self Signed Certificates\n\n## openssl_x509\ngenerate a pem formatted x509 cert + key \n\n### Attributes\n`common_name` A String representing the `CN` ssl field\n`org` A String representing the `O` ssl field\n`org_unit` A String representing the `OU` ssl field\n`country` A String representing the `C` ssl field\n`expire` A Fixnum reprenting the number of days from _now_ to expire the cert\n`key_file` Optional A string to the key file to use. If no key is present it will generate and store one. \n`key_pass` A String that is the key's passphrase\n`key_length` A Fixnum reprenting your desired Bit Length _Default: 2048_\n`owner` The owner of the files _Default: \"root\"_\n`group` The group of the files _Default: \"root\"_\n`mode` The mode to store the files in _Default: \"0400\"_\n\n### Example usage\n\n openssl_x509 \"/tmp/mycert.pem\" do\n common_name \"www.f00bar.com\"\n org \"Foo Bar\"\n org_unit \"Lab\"\n country \"US\"\n end\n\n \nLicense and Author\n==================\n\nAuthor:: Jesse Nelson (<spheromak@gmail.com>)\nAuthor:: Joshua Timberman (<joshua@opscode.com>)\n=======\n\n\n```ruby\nnode.default['openssl']['restart_services'] = ['stats_collector']\n\n# other recipe code here...\nservice 'stats_collector' do\n action [:enable, :start]\nend\n\ninclude_recipe 'openssl::upgrade'\n```\n\nThis will ensure that openssl is upgraded to the latest version so the `stats_collector` service won't be exploited (hopefully!).\n\n```text\nCopyright:: 2009-2011, Opscode, Inc\nCopyright:: 2014, Chef Software, Inc <legal@getchef.com>\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n",
"long_description": "openssl Cookbook\n================\n\nThis cookbook provides a library method to generate secure random passwords in recipes using the Ruby OpenSSL library.\n\nIt also provides an attribute-driven recipe for upgrading OpenSSL packages.\n\nRequirements\n------------\n\nThe `secure_password` works on any platform with OpenSSL Ruby bindings installed, which are a requirement for Chef anyway.\n\nThe upgrade recipe works on the following tested platforms:\n\n* Ubuntu 12.04, 14.04\n* Debian 7.4\n* CentOS 6.5\n\nIt may work on other platforms or versions of the above platforms with or without modification.\n\n[Chef Sugar](https://github.com/sethvargo/chef-sugar) was introduced as a dependency to provide helpers that make the default attribute settings (see Attributes) easier to reason about.\n\nAttributes\n----------\n\n* `node['openssl']['packages']` - An array of packages of openssl. The default attributes attempt to be smart about which packages are the default, but this may need to be changed by users of the `openssl::upgrade` recipe.\n* `node['openssl']['restart_services']` - An array of service resources that use the `node['openssl']['packages']`. This is empty by default as Chef has no reliably reasonable way to detect which applications or services are compiled against these packages. *Note* These each need to be \"`service`\" resources specified somewhere in the recipes in the node's run list.\n\nRecipes\n-------\n\n### upgrade\n\nThe upgrade recipe iterates over the list of packages in the `node['openssl']['packages']` attribute and manages them with the `:upgrade` action. Each package will send `:restart` notification to service resources named by the `node['openssl']['restart_services']` attribute.\n\nUsage\n-----\n\nMost often this will be used to generate a secure password for an attribute. In a recipe:\n\n```ruby\n::Chef::Recipe.send(:include, Opscode::OpenSSL::Password)\nnode.default_unless[:my_password] = secure_password\n```\n\nTo use the `openssl::upgrade` recipe, set the attributes as mentioned above. For example, we have a \"stats_collector\" service that uses openssl. It has a recipe that looks like this:\n\nLWRP\n==== \n\nThis cookbook includes an LWRP for generating Self Signed Certificates\n\n## openssl_x509\ngenerate a pem formatted x509 cert + key \n\n### Attributes\n`common_name` A String representing the `CN` ssl field\n`org` A String representing the `O` ssl field\n`org_unit` A String representing the `OU` ssl field\n`country` A String representing the `C` ssl field\n`expire` A Fixnum reprenting the number of days from _now_ to expire the cert\n`key_file` Optional A string to the key file to use. If no key is present it will generate and store one. \n`key_pass` A String that is the key's passphrase\n`key_length` A Fixnum reprenting your desired Bit Length _Default: 2048_\n`owner` The owner of the files _Default: \"root\"_\n`group` The group of the files _Default: \"root\"_\n`mode` The mode to store the files in _Default: \"0400\"_\n\n### Example usage\n\n openssl_x509 \"/tmp/mycert.pem\" do\n common_name \"www.f00bar.com\"\n org \"Foo Bar\"\n org_unit \"Lab\"\n country \"US\"\n end\n\n \nLicense and Author\n==================\n\nAuthor:: Jesse Nelson (<spheromak@gmail.com>)\nAuthor:: Joshua Timberman (<joshua@opscode.com>)\n=======\n\n\n```ruby\nnode.default['openssl']['restart_services'] = ['stats_collector']\n\n# other recipe code here...\nservice 'stats_collector' do\n action [:enable, :start]\nend\n\ninclude_recipe 'openssl::upgrade'\n```\n\nThis will ensure that openssl is upgraded to the latest version so the `stats_collector` service won't be exploited (hopefully!).\n\n```text\nCopyright:: 2009-2011, Opscode, Inc\nCopyright:: 2014, Chef Software, Inc <legal@getchef.com>\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n",
"maintainer": "Opscode, Inc.",
"maintainer_email": "cookbooks@opscode.com",
"license": "Apache 2.0",
@ -28,4 +28,4 @@
"recipes": {
"openssl": "Empty, this cookbook provides a library, see README.md"
}
}
}

View File

@ -65,8 +65,8 @@ unless node['tomcat']['deploy_manager_apps']
end
end
node.set_unless['tomcat']['keystore_password'] = secure_password
node.set_unless['tomcat']['truststore_password'] = secure_password
node.default_unless['tomcat']['keystore_password'] = secure_password
node.default_unless['tomcat']['truststore_password'] = secure_password
if node['tomcat']['run_base_instance']
tomcat_instance "base" do

View File

@ -73,7 +73,7 @@ attribute :multilib_policy, :kind_of => String, :equal_to => %w(all best), :defa
attribute :obsoletes, :kind_of => [TrueClass, FalseClass], :default => nil
attribute :overwrite_groups, :kind_of => [TrueClass, FalseClass], :default => nil
attribute :password, :kind_of => String, :regex => /.*/, :default => nil
attribute :path, :kind_of => String, :regex => /.*/, :default => nil, :name_attribute => true
attribute :path, :kind_of => String, :regex => /.*/, :name_attribute => true
attribute :persistdir, :kind_of => String, :regex => /.*/, :default => nil
attribute :pluginconfpath, :kind_of => String, :regex => /.*/, :default => nil
attribute :pluginpath, :kind_of => String, :regex => /.*/, :default => nil