Annotation documentation updates

This commit is contained in:
jamesagnew 2014-08-07 08:27:52 -04:00
parent 0b7cfec06b
commit deef33317d
22 changed files with 103 additions and 225 deletions

View File

@ -277,7 +277,6 @@
<escapeHTML>false</escapeHTML>
</configuration>
</plugin>
<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
@ -328,7 +327,6 @@
</reportSet>
</reportSets>
</plugin>
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>

View File

@ -20,7 +20,7 @@ package ca.uhn.fhir.context;
* #L%
*/
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.*;
import java.io.IOException;
import java.io.InputStream;
@ -55,7 +55,6 @@ import ca.uhn.fhir.model.api.IResourceBlock;
import ca.uhn.fhir.model.api.IValueSetEnumBinder;
import ca.uhn.fhir.model.api.annotation.Block;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.CodeTableDef;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.api.annotation.Extension;
@ -257,16 +256,6 @@ class ModelScanner {
}
}
CodeTableDef codeTableDefinition = theClass.getAnnotation(CodeTableDef.class);
if (codeTableDefinition != null) {
if (ICodeEnum.class.isAssignableFrom(theClass)) {
@SuppressWarnings("unchecked")
Class<? extends ICodeEnum> resClass = (Class<? extends ICodeEnum>) theClass;
scanCodeTable(resClass, codeTableDefinition);
} else {
throw new ConfigurationException("Type contains a @" + CodeTableDef.class.getSimpleName() + " annotation but does not implement " + ICodeEnum.class.getCanonicalName() + ": " + theClass.getCanonicalName());
}
}
Block blockDefinition = theClass.getAnnotation(Block.class);
if (blockDefinition != null) {
@ -279,7 +268,7 @@ class ModelScanner {
}
}
if (blockDefinition == null && codeTableDefinition == null && datatypeDefinition == null && resourceDefinition == null) {
if (blockDefinition == null && datatypeDefinition == null && resourceDefinition == null) {
throw new ConfigurationException("Resource type does not contain any valid HAPI-FHIR annotations: " + theClass.getCanonicalName());
}
}
@ -287,8 +276,7 @@ class ModelScanner {
private void scanBlock(Class<? extends IResourceBlock> theClass, Block theBlockDefinition) {
ourLog.debug("Scanning resource block class: {}", theClass.getName());
String resourceName = theBlockDefinition.name(); // TODO: remove name
resourceName = theClass.getCanonicalName();
String resourceName = theClass.getCanonicalName();
if (isBlank(resourceName)) {
throw new ConfigurationException("Block type @" + Block.class.getSimpleName() + " annotation contains no name: " + theClass.getCanonicalName());
}
@ -299,9 +287,6 @@ class ModelScanner {
scanCompositeElementForChildren(theClass, resourceDef);
}
private String scanCodeTable(Class<? extends ICodeEnum> theCodeType, CodeTableDef theCodeTableDefinition) {
return null; // TODO: implement
}
private void scanCompositeDatatype(Class<? extends ICompositeDatatype> theClass, DatatypeDef theDatatypeDefinition) {
ourLog.debug("Scanning resource class: {}", theClass.getName());

View File

@ -25,6 +25,14 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Class annotation used to indicate a class which is a "block"/"component" type. A block
* is a nested group of fields within a resource definition and can contain other blocks as
* well as data types.
* <p>
* An example of a block would be Patient.contact
* </p>
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(value= {ElementType.TYPE})
public @interface Block {

View File

@ -27,6 +27,10 @@ import java.lang.annotation.Target;
import ca.uhn.fhir.model.api.IElement;
/**
* Field annotation for fields within resource and datatype definitions, indicating
* a child of that type.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(value= {ElementType.FIELD})
public @interface Child {
@ -42,14 +46,37 @@ public @interface Child {
*/
int MAX_UNLIMITED = -1;
/**
* The name of this field, as it will appear in serialized versions of the message
*/
String name();
/**
* The order in which this field comes within its parent. The first field should have a
* value of 0, the second a value of 1, etc.
*/
int order() default ORDER_UNKNOWN;
/**
* The minimum number of repetitions allowed for this child
*/
int min() default 0;
/**
* The maximum number of repetitions allowed for this child. Should be
* set to {@link #MAX_UNLIMITED} if there is no limit to the number of
* repetitions.
*/
int max() default 1;
/**
* Lists the allowable types for this field, if the field supports multiple
* types (otherwise does not need to be populated).
* <p>
* For example, if this field supports either DateTimeDt or BooleanDt types,
* those two classes should be supplied here.
* </p>
*/
Class<? extends IElement>[] type() default {};
// Not implemented

View File

@ -1,36 +0,0 @@
package ca.uhn.fhir.model.api.annotation;
/*
* #%L
* HAPI FHIR - Core Library
* %%
* Copyright (C) 2014 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.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import ca.uhn.fhir.model.api.IElement;
@Retention(RetentionPolicy.RUNTIME)
@Target(value= {ElementType.FIELD})
public @interface Choice {
Class<? extends IElement>[] types() default {};
}

View File

@ -1,40 +0,0 @@
package ca.uhn.fhir.model.api.annotation;
/*
* #%L
* HAPI FHIR - Core Library
* %%
* Copyright (C) 2014 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.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(value= {ElementType.TYPE})
public @interface CodeTableDef {
int tableId();
String name();
int[] restrictedToSnomedIsA() default {};
}

View File

@ -1,37 +0,0 @@
package ca.uhn.fhir.model.api.annotation;
/*
* #%L
* HAPI FHIR - Core Library
* %%
* Copyright (C) 2014 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.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(value= {ElementType.FIELD})
public @interface Constraint {
String[] coRequirements() default {};
String[] lessThan() default {};
String[] greaterThan() default {};
}

View File

@ -28,6 +28,9 @@ import java.lang.annotation.Target;
import ca.uhn.fhir.model.primitive.BoundCodeDt;
import ca.uhn.fhir.model.primitive.CodeDt;
/**
* Class annotation to note a class which defines a datatype
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(value= {ElementType.TYPE})
public @interface DatatypeDef {

View File

@ -25,6 +25,10 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation which may be placed on a resource/datatype definition, or a field, or
* a search parameter definition in order to provide documentation for that item.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(value= {ElementType.FIELD, ElementType.TYPE, ElementType.PARAMETER, ElementType.METHOD})
public @interface Description {

View File

@ -1,35 +0,0 @@
package ca.uhn.fhir.model.api.annotation;
/*
* #%L
* HAPI FHIR - Core Library
* %%
* Copyright (C) 2014 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.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(value= {ElementType.FIELD})
public @interface EnumeratedCodeValue {
String value();
String system() default "";
}

View File

@ -25,36 +25,41 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Field modifier to be placed on a child field (a field also annotated with the {@link Child} annotation) which
* indicates that this field is an extension.
*/
@Target(value = { ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
public @interface Extension {
/**
* This parameter affects how the extension is treated when the element
* definition containing this resource is exported to a profile.
* This parameter affects how the extension is treated when the element definition containing this resource is
* exported to a profile.
*
* <p>
* If set to <b><code>true</code></b>, the resource is taken to be a local
* resource and its definition is exported along with the reference. Use
* this option for extension defintions that you have added locally (i.e.
* within your own organization)
* If set to <b><code>true</code></b>, the resource is taken to be a local resource and its definition is exported
* along with the reference. Use this option for extension defintions that you have added locally (i.e. within your
* own organization)
* </p>
*
* <p>
* If set to <b><code>false</code></b>, the resource is taken to be a remote
* resource and its definition is <b>not</b> exported to the profile. Use
* this option for extensions that are defined by other organizations (i.e.
* If set to <b><code>false</code></b>, the resource is taken to be a remote resource and its definition is
* <b>not</b> exported to the profile. Use this option for extensions that are defined by other organizations (i.e.
* by regional authorities or jurisdictional governments)
* </p>
*/
boolean definedLocally();
/**
* Returns <code>true</code> if this extension is a
* <a href="http://www.hl7.org/implement/standards/fhir/extensibility.html#modifierExtension">modifier extension</a>
* Returns <code>true</code> if this extension is a <a
* href="http://www.hl7.org/implement/standards/fhir/extensibility.html#modifierExtension">modifier extension</a>
*/
boolean isModifier();
/**
* The URL associated with this extension
*/
String url();
}

View File

@ -1,34 +0,0 @@
package ca.uhn.fhir.model.api.annotation;
/*
* #%L
* HAPI FHIR - Core Library
* %%
* Copyright (C) 2014 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.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(value= {ElementType.FIELD})
public @interface IsIdentifier {
// nothing
}

View File

@ -25,6 +25,9 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Class annotation which indicates a resource definition class
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(value= {ElementType.TYPE})
public @interface ResourceDef {
@ -34,8 +37,14 @@ public @interface ResourceDef {
*/
String name();
/**
* Not currently used
*/
String id() default "";
/**
* The URL indicating the profile for this resource definition, if known
*/
String profile() default "";
}

View File

@ -29,12 +29,24 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
public @interface SearchParamDefinition {
/**
* The name for this parameter
*/
String name();
/**
* The path for this parameter
*/
String path();
/**
* A description of this parameter
*/
String description() default "";
/**
* The type for this parameter, e.g. "string", or "token"
*/
String type() default "string";
/**

View File

@ -27,7 +27,10 @@ import java.lang.annotation.Target;
/**
* Marker annotation for a primitive setter method that can be used to
* indicate a "simple setter" method on a resource or composite type
* indicate a "simple setter" method on a resource or composite type.
*
* This annotation is used by HAPI's code generator and can be ignored by
* client code
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(value= {ElementType.CONSTRUCTOR})

View File

@ -1,4 +1,4 @@
package ca.uhn.fhir.model.api.annotation;
package ca.uhn.fhir.rest.annotation;
/*
* #%L
@ -26,9 +26,6 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import ca.uhn.fhir.model.api.TagList;
import ca.uhn.fhir.rest.annotation.AddTags;
import ca.uhn.fhir.rest.annotation.DeleteTags;
import ca.uhn.fhir.rest.annotation.GetTags;
/**
* Parameter annotation for the {@link TagList} parameter in a {@link GetTags},

View File

@ -33,12 +33,12 @@ import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.TagList;
import ca.uhn.fhir.model.api.annotation.TagListParam;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationSystemEnum;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.TagListParam;
import ca.uhn.fhir.rest.client.BaseHttpClientInvocation;
import ca.uhn.fhir.rest.method.SearchMethodBinding.RequestType;
import ca.uhn.fhir.rest.server.Constants;

View File

@ -34,7 +34,6 @@ import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
import ca.uhn.fhir.model.api.Tag;
import ca.uhn.fhir.model.api.TagList;
import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.api.annotation.TagListParam;
import ca.uhn.fhir.model.dstu.resource.OperationOutcome;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.model.primitive.InstantDt;
@ -48,6 +47,7 @@ import ca.uhn.fhir.rest.annotation.ResourceParam;
import ca.uhn.fhir.rest.annotation.ServerBase;
import ca.uhn.fhir.rest.annotation.Since;
import ca.uhn.fhir.rest.annotation.Sort;
import ca.uhn.fhir.rest.annotation.TagListParam;
import ca.uhn.fhir.rest.annotation.TransactionParam;
import ca.uhn.fhir.rest.annotation.VersionIdParam;
import ca.uhn.fhir.rest.api.MethodOutcome;

View File

@ -66,6 +66,15 @@ public class XmlParserTest {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(XmlParserTest.class);
private static FhirContext ourCtx;
@Test
public void testParseLanguage() {
String input = "<Patient xmlns=\"http://hl7.org/fhir\"><language value=\"zh-CN\"/><text><status value=\"generated\"/><div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\"> 海生 <b>王 </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Identifier</td><td>URNo</td></tr><tr><td>Address</td><td><span>99 Houston Road </span><br/><span>BENTLEIGH </span><span>Victoria </span></td></tr><tr><td>Date of birth</td><td><span>01 January 1997</span></td></tr></tbody></table></div></text><identifier><use value=\"usual\"/><label value=\"URNo\"/><value value=\"89532\"/></identifier><name><text value=\"王海生\"/><family value=\"\"/><given value=\"海生\"/></name><telecom><system value=\"phone\"/><value value=\"9899 9878\"/><use value=\"home\"/></telecom><telecom><system value=\"email\"/><value value=\"zimmerman@datacorp.com.au\"/><use value=\"home\"/></telecom><gender><coding><system value=\"http://hl7.org/fhir/v3/AdministrativeGender\"/><code value=\"M\"/><display value=\"Male\"/></coding><text value=\"Male\"/></gender><birthDate value=\"1997-01-01\"/><address><use value=\"home\"/><text value=\"99 Houston Road, BENTLEIGH, 3204\"/><line value=\"99 Houston Road\"/><city value=\"BENTLEIGH\"/><state value=\"Victoria\"/><zip value=\"3204\"/><period><start value=\"2006-06-16\"/></period></address><active value=\"true\"/></Patient>";
Patient pt = ourCtx.newXmlParser().parseResource(Patient.class, input);
assertEquals("zh-CN", pt.getLanguage().getValue());
}
@Test
public void testEncodeBoundCode() {

View File

@ -25,7 +25,6 @@ import org.mockito.internal.stubbing.defaultanswers.ReturnsDeepStubs;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.Tag;
import ca.uhn.fhir.model.api.TagList;
import ca.uhn.fhir.model.api.annotation.TagListParam;
import ca.uhn.fhir.model.dstu.resource.Conformance;
import ca.uhn.fhir.model.dstu.resource.Patient;
import ca.uhn.fhir.model.primitive.IdDt;
@ -33,6 +32,7 @@ import ca.uhn.fhir.rest.annotation.AddTags;
import ca.uhn.fhir.rest.annotation.DeleteTags;
import ca.uhn.fhir.rest.annotation.GetTags;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.TagListParam;
import ca.uhn.fhir.rest.annotation.VersionIdParam;
import ca.uhn.fhir.rest.client.api.IBasicClient;
import ca.uhn.fhir.rest.server.Constants;

View File

@ -25,7 +25,6 @@ import org.junit.Test;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.Tag;
import ca.uhn.fhir.model.api.TagList;
import ca.uhn.fhir.model.api.annotation.TagListParam;
import ca.uhn.fhir.model.dstu.resource.Observation;
import ca.uhn.fhir.model.dstu.resource.Patient;
import ca.uhn.fhir.model.primitive.IdDt;
@ -33,6 +32,7 @@ import ca.uhn.fhir.rest.annotation.AddTags;
import ca.uhn.fhir.rest.annotation.DeleteTags;
import ca.uhn.fhir.rest.annotation.GetTags;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.TagListParam;
import ca.uhn.fhir.rest.annotation.VersionIdParam;
import ca.uhn.fhir.testutil.RandomServerPortProvider;

View File

@ -6,7 +6,7 @@
<dependent-module archiveName="hapi-fhir-base-0.6-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/hapi-fhir-base/hapi-fhir-base">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module deploy-path="/" handle="module:/overlay/prj/hapi-fhir-testpage-overlay?includes=**/**&amp;excludes=META-INF/MANIFEST.MF">
<dependent-module deploy-path="/" handle="module:/overlay/prj/hapi-fhir-tester-overlay?includes=**/**&amp;excludes=META-INF/MANIFEST.MF">
<dependency-type>consumes</dependency-type>
</dependent-module>
<dependent-module deploy-path="/" handle="module:/overlay/slf/?includes=**/**&amp;excludes=META-INF/MANIFEST.MF">