Finalizing 1.2 release
This commit is contained in:
parent
31934ff582
commit
effe139325
|
@ -6,7 +6,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
<version>1.2</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -22,33 +22,33 @@
|
|||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-base</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-jpaserver-example</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
<version>1.2</version>
|
||||
<type>war</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dstu</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dstu2</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-validation-resources</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -143,7 +143,7 @@
|
|||
<artifactItem>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-jpaserver-example</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
<version>1.2</version>
|
||||
<type>war</type>
|
||||
<overWrite>true</overWrite>
|
||||
<outputDirectory>target/classes</outputDirectory>
|
||||
|
|
|
@ -28,10 +28,13 @@ public class App {
|
|||
private static List<BaseCommand> ourCommands;
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(App.class);
|
||||
|
||||
public static final String LINESEP = System.getProperty("line.separator");
|
||||
|
||||
static {
|
||||
ourCommands = new ArrayList<BaseCommand>();
|
||||
ourCommands.add(new RunServerCommand());
|
||||
ourCommands.add(new ExampleDataUploader());
|
||||
ourCommands.add(new ValidateCommand());
|
||||
|
||||
Collections.sort(ourCommands);
|
||||
}
|
||||
|
@ -79,16 +82,22 @@ public class App {
|
|||
System.out.println(" hapi-fhir-cli {command} [options]");
|
||||
System.out.println();
|
||||
System.out.println("Commands:");
|
||||
|
||||
int longestCommandLength = 0;
|
||||
for (BaseCommand next : ourCommands) {
|
||||
String left = " " + next.getCommandName() + " - ";
|
||||
String[] rightParts = WordUtils.wrap(next.getCommandDescription(), 80 - left.length()).split("\\n");
|
||||
for (int i = 1; i < rightParts.length; i++) {
|
||||
rightParts[i] = StringUtils.leftPad("", left.length()) + rightParts[i];
|
||||
longestCommandLength = Math.max(longestCommandLength, next.getCommandName().length());
|
||||
}
|
||||
System.out.println(left + StringUtils.join(rightParts, '\n'));
|
||||
|
||||
for (BaseCommand next : ourCommands) {
|
||||
String left = " " + StringUtils.rightPad(next.getCommandName(), longestCommandLength);
|
||||
String[] rightParts = WordUtils.wrap(next.getCommandDescription(), 80 - (left.length() + 3)).split("\\n");
|
||||
for (int i = 1; i < rightParts.length; i++) {
|
||||
rightParts[i] = StringUtils.leftPad("", left.length() + 3) + rightParts[i];
|
||||
}
|
||||
System.out.println(ansi().bold().fg(Color.GREEN) + left + ansi().boldOff().fg(Color.WHITE) + " - " + ansi().bold() + StringUtils.join(rightParts, LINESEP));
|
||||
}
|
||||
System.out.println();
|
||||
System.out.println("See what options are available:");
|
||||
System.out.println(ansi().boldOff().fg(Color.WHITE) + "See what options are available:");
|
||||
System.out.println(" hapi-fhir-cli help {command}");
|
||||
System.out.println();
|
||||
}
|
||||
|
@ -143,12 +152,14 @@ public class App {
|
|||
Options options = command.getOptions();
|
||||
DefaultParser parser = new DefaultParser();
|
||||
CommandLine parsedOptions;
|
||||
|
||||
logAppHeader();
|
||||
loggingConfigOn();
|
||||
|
||||
try {
|
||||
String[] args = Arrays.asList(theArgs).subList(1, theArgs.length).toArray(new String[theArgs.length - 1]);
|
||||
parsedOptions = parser.parse(options, args, true);
|
||||
|
||||
logAppHeader();
|
||||
loggingConfigOn();
|
||||
|
||||
// Actually execute the command
|
||||
command.run(parsedOptions);
|
||||
|
|
|
@ -9,6 +9,8 @@ import ca.uhn.fhir.rest.client.IGenericClient;
|
|||
|
||||
public abstract class BaseCommand implements Comparable<BaseCommand> {
|
||||
|
||||
private FhirContext myFhirCtx;
|
||||
|
||||
public BaseCommand() {
|
||||
super();
|
||||
}
|
||||
|
@ -32,4 +34,11 @@ public abstract class BaseCommand implements Comparable<BaseCommand> {
|
|||
|
||||
public abstract void run(CommandLine theCommandLine) throws ParseException, Exception;
|
||||
|
||||
public FhirContext getFhirCtx() {
|
||||
if (myFhirCtx == null) {
|
||||
myFhirCtx = FhirContext.forDstu2();
|
||||
}
|
||||
return myFhirCtx;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
package ca.uhn.fhir.cli;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.defaultString;
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
import static org.fusesource.jansi.Ansi.*;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.Option;
|
||||
import org.apache.commons.cli.OptionGroup;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.fusesource.jansi.Ansi;
|
||||
|
||||
import com.phloc.commons.io.file.FileUtils;
|
||||
|
||||
import ca.uhn.fhir.rest.method.MethodUtil;
|
||||
import ca.uhn.fhir.rest.server.EncodingEnum;
|
||||
import ca.uhn.fhir.validation.FhirInstanceValidator;
|
||||
import ca.uhn.fhir.validation.FhirValidator;
|
||||
import ca.uhn.fhir.validation.SingleValidationMessage;
|
||||
import ca.uhn.fhir.validation.ValidationResult;
|
||||
|
||||
public class ValidateCommand extends BaseCommand {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ValidateCommand.class);
|
||||
|
||||
@Override
|
||||
public String getCommandDescription() {
|
||||
return "Validate a resource using the FHIR validation tools";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "validate";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Options getOptions() {
|
||||
Options retVal = new Options();
|
||||
|
||||
OptionGroup source = new OptionGroup();
|
||||
source.addOption(new Option("f", "file", true, "The name of the file to validate"));
|
||||
source.addOption(new Option("d", "data", true, "The text to validate"));
|
||||
retVal.addOptionGroup(source);
|
||||
|
||||
retVal.addOption("x", "xsd", false, "Validate using Schemas");
|
||||
retVal.addOption("s", "sch", false, "Validate using Schematrons");
|
||||
retVal.addOption("p", "profile", false, "Validate using Profiles (StructureDefinition / ValueSet)");
|
||||
|
||||
retVal.addOption("e", "encoding", false, "File encoding (default is UTF-8)");
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(CommandLine theCommandLine) throws ParseException, Exception {
|
||||
String fileName = theCommandLine.getOptionValue("f");
|
||||
String contents = theCommandLine.getOptionValue("c");
|
||||
if (isNotBlank(fileName) && isNotBlank(contents)) {
|
||||
throw new ParseException("Can not supply both a file (-f) and data (-d)");
|
||||
}
|
||||
if (isBlank(fileName) && isBlank(contents)) {
|
||||
throw new ParseException("Must supply either a file (-f) or data (-d)");
|
||||
}
|
||||
|
||||
if (isNotBlank(fileName)) {
|
||||
String encoding = theCommandLine.getOptionValue("e", "UTF-8");
|
||||
ourLog.info("Reading file '{}' using encoding {}", fileName, encoding);
|
||||
|
||||
contents = IOUtils.toString(new InputStreamReader(new FileInputStream(fileName), encoding));
|
||||
ourLog.info("Fully read - Size is {}", FileUtils.getFileSizeDisplay(contents.length()));
|
||||
}
|
||||
|
||||
EncodingEnum enc = MethodUtil.detectEncodingNoDefault(defaultString(contents));
|
||||
if (enc == null) {
|
||||
throw new ParseException("Could not detect encoding (json/xml) of contents");
|
||||
}
|
||||
|
||||
FhirValidator val = getFhirCtx().newValidator();
|
||||
if (theCommandLine.hasOption("p")) {
|
||||
val.registerValidatorModule(new FhirInstanceValidator());
|
||||
}
|
||||
|
||||
val.setValidateAgainstStandardSchema(theCommandLine.hasOption("x"));
|
||||
val.setValidateAgainstStandardSchematron(theCommandLine.hasOption("s"));
|
||||
|
||||
ValidationResult results = val.validateWithResult(contents);
|
||||
|
||||
StringBuilder b = new StringBuilder("Validation results:" + ansi().boldOff());
|
||||
int count = 0;
|
||||
for (SingleValidationMessage next : results.getMessages()) {
|
||||
count++;
|
||||
b.append(App.LINESEP);
|
||||
b.append("Issue ").append(count).append(": ");
|
||||
b.append(next.getSeverity()).append(" - ").append(next.getLocationString());
|
||||
b.append(App.LINESEP);
|
||||
b.append(" ").append(next.getMessage());
|
||||
}
|
||||
|
||||
if (count > 0) {
|
||||
ourLog.info(b.toString());
|
||||
}
|
||||
|
||||
if (results.isSuccessful()) {
|
||||
ourLog.info("Validation successful!");
|
||||
} else {
|
||||
ourLog.warn("Validation FAILED");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
<!--<format>tar.bz2</format>-->
|
||||
<format>tar.bz2</format>
|
||||
</formats>
|
||||
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
<!--<format>tar.bz2</format>-->
|
||||
<format>tar.bz2</format>
|
||||
</formats>
|
||||
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
|
||||
|
||||
<id>hapi-fhir-standard-distribution</id>
|
||||
<id>standard-distribution</id>
|
||||
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
<!--<format>tar.bz2</format>-->
|
||||
<format>tar.bz2</format>
|
||||
</formats>
|
||||
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
|
|
|
@ -1,5 +1,25 @@
|
|||
package ca.uhn.fhir.jpa.dao;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR JPA Server
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2015 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 org.hl7.fhir.instance.model.ValueSet;
|
||||
import org.hl7.fhir.instance.model.ValueSet.ConceptSetComponent;
|
||||
import org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionComponent;
|
||||
|
|
1
pom.xml
1
pom.xml
|
@ -1287,6 +1287,7 @@
|
|||
<module>hapi-fhir-testpage-overlay</module>
|
||||
<module>hapi-fhir-jpaserver-uhnfhirtest</module>
|
||||
<module>hapi-fhir-android</module>
|
||||
<module>hapi-fhir-cli</module>
|
||||
<module>hapi-fhir-dist</module>
|
||||
<module>examples</module>
|
||||
<!--<module>hapi-fhir-osgi-core</module>-->
|
||||
|
|
Loading…
Reference in New Issue