mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-03-25 01:18:37 +00:00
Fix broken test cases
This commit is contained in:
parent
96986f8829
commit
d241df9868
@ -28,6 +28,7 @@ import java.util.TreeSet;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.Include;
|
||||
import ca.uhn.fhir.model.api.PathSpecification;
|
||||
import ca.uhn.fhir.model.dstu.valueset.SearchParamTypeEnum;
|
||||
import ca.uhn.fhir.rest.annotation.IncludeParam;
|
||||
@ -37,11 +38,11 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
|
||||
public class IncludeParameter extends BaseQueryParameter {
|
||||
|
||||
private Class<? extends Collection<PathSpecification>> myInstantiableCollectionType;
|
||||
private Class<? extends Collection<Include>> myInstantiableCollectionType;
|
||||
private HashSet<String> myAllow;
|
||||
private Class<?> mySpecType;
|
||||
|
||||
public IncludeParameter(IncludeParam theAnnotation, Class<? extends Collection<PathSpecification>> theInstantiableCollectionType, Class<?> theSpecType) {
|
||||
public IncludeParameter(IncludeParam theAnnotation, Class<? extends Collection<Include>> theInstantiableCollectionType, Class<?> theSpecType) {
|
||||
myInstantiableCollectionType = theInstantiableCollectionType;
|
||||
if (theAnnotation.allow().length > 0) {
|
||||
myAllow = new HashSet<String>();
|
||||
@ -51,7 +52,7 @@ public class IncludeParameter extends BaseQueryParameter {
|
||||
}
|
||||
|
||||
mySpecType = theSpecType;
|
||||
if (mySpecType != PathSpecification.class && mySpecType != String.class) {
|
||||
if (mySpecType != Include.class && mySpecType != PathSpecification.class && mySpecType != String.class) {
|
||||
throw new ConfigurationException("Invalid @" + IncludeParam.class.getSimpleName() + " parameter type: " + mySpecType);
|
||||
}
|
||||
|
||||
@ -63,14 +64,16 @@ public class IncludeParameter extends BaseQueryParameter {
|
||||
ArrayList<QualifiedParamList> retVal = new ArrayList<QualifiedParamList>();
|
||||
|
||||
if (myInstantiableCollectionType == null) {
|
||||
if (mySpecType == PathSpecification.class) {
|
||||
if (mySpecType == Include.class) {
|
||||
retVal.add(QualifiedParamList.singleton(((Include) theObject).getValue()));
|
||||
}else if (mySpecType == PathSpecification.class) {
|
||||
retVal.add(QualifiedParamList.singleton(((PathSpecification) theObject).getValue()));
|
||||
} else {
|
||||
retVal.add(QualifiedParamList.singleton(((String) theObject)));
|
||||
}
|
||||
} else {
|
||||
Collection<PathSpecification> val = (Collection<PathSpecification>) theObject;
|
||||
for (PathSpecification pathSpec : val) {
|
||||
Collection<Include> val = (Collection<Include>) theObject;
|
||||
for (Include pathSpec : val) {
|
||||
retVal.add(QualifiedParamList.singleton(pathSpec.getValue()));
|
||||
}
|
||||
}
|
||||
@ -85,7 +88,7 @@ public class IncludeParameter extends BaseQueryParameter {
|
||||
|
||||
@Override
|
||||
public Object parse(List<QualifiedParamList> theString) throws InternalErrorException, InvalidRequestException {
|
||||
Collection<PathSpecification> retValCollection = null;
|
||||
Collection<Include> retValCollection = null;
|
||||
if (myInstantiableCollectionType != null) {
|
||||
try {
|
||||
retValCollection = myInstantiableCollectionType.newInstance();
|
||||
@ -111,11 +114,17 @@ public class IncludeParameter extends BaseQueryParameter {
|
||||
if (retValCollection == null) {
|
||||
if (mySpecType == String.class) {
|
||||
return value;
|
||||
} else {
|
||||
} else if (mySpecType == PathSpecification.class) {
|
||||
return new PathSpecification(value);
|
||||
} else {
|
||||
return new Include(value);
|
||||
}
|
||||
} else {
|
||||
retValCollection.add(new PathSpecification(value));
|
||||
if (mySpecType == PathSpecification.class) {
|
||||
retValCollection.add(new PathSpecification(value));
|
||||
} else {
|
||||
retValCollection.add(new Include(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,13 +44,13 @@ import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.model.api.IQueryParameterOr;
|
||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.Include;
|
||||
import ca.uhn.fhir.model.api.PathSpecification;
|
||||
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.primitive.InstantDt;
|
||||
import ca.uhn.fhir.model.primitive.IntegerDt;
|
||||
import ca.uhn.fhir.rest.annotation.TransactionParam;
|
||||
import ca.uhn.fhir.rest.annotation.Count;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.IncludeParam;
|
||||
@ -60,6 +60,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.TransactionParam;
|
||||
import ca.uhn.fhir.rest.annotation.VersionIdParam;
|
||||
import ca.uhn.fhir.rest.method.QualifiedParamList;
|
||||
import ca.uhn.fhir.util.ReflectionUtil;
|
||||
@ -197,17 +198,17 @@ public class ParameterUtil {
|
||||
extractDescription(parameter, annotations);
|
||||
param = parameter;
|
||||
} else if (nextAnnotation instanceof IncludeParam) {
|
||||
Class<? extends Collection<PathSpecification>> instantiableCollectionType;
|
||||
Class<? extends Collection<Include>> instantiableCollectionType;
|
||||
Class<?> specType;
|
||||
|
||||
if (parameterType == String.class) {
|
||||
instantiableCollectionType = null;
|
||||
specType = String.class;
|
||||
} else if (parameterType != PathSpecification.class || innerCollectionType == null || outerCollectionType != null) {
|
||||
throw new ConfigurationException("Method '" + theMethod.getName() + "' is annotated with @" + IncludeParam.class.getSimpleName() + " but has a type other than Collection<" + PathSpecification.class.getSimpleName() + ">");
|
||||
} else if ((parameterType != Include.class && parameterType != PathSpecification.class) || innerCollectionType == null || outerCollectionType != null) {
|
||||
throw new ConfigurationException("Method '" + theMethod.getName() + "' is annotated with @" + IncludeParam.class.getSimpleName() + " but has a type other than Collection<" + Include.class.getSimpleName() + ">");
|
||||
} else {
|
||||
instantiableCollectionType = (Class<? extends Collection<PathSpecification>>) CollectionBinder.getInstantiableCollectionType(innerCollectionType, "Method '" + theMethod.getName() + "'");
|
||||
specType = PathSpecification.class;
|
||||
instantiableCollectionType = (Class<? extends Collection<Include>>) CollectionBinder.getInstantiableCollectionType(innerCollectionType, "Method '" + theMethod.getName() + "'");
|
||||
specType = parameterType;
|
||||
}
|
||||
|
||||
param = new IncludeParameter((IncludeParam) nextAnnotation, instantiableCollectionType, specType);
|
||||
|
@ -16,7 +16,6 @@ import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Version;
|
||||
|
||||
import org.hibernate.annotations.Index;
|
||||
|
||||
@ -77,7 +76,6 @@ public class ResourceTable extends BaseHasResource implements Serializable {
|
||||
@OneToMany(mappedBy = "myResource", cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true)
|
||||
private Collection<ResourceTag> myTags;
|
||||
|
||||
@Version()
|
||||
@Column(name = "RES_VER")
|
||||
private long myVersion;
|
||||
|
||||
|
@ -56,7 +56,7 @@ public class ${className}ResourceProvider extends JpaResourceProvider<${classNam
|
||||
#end
|
||||
#end
|
||||
})
|
||||
Set<PathSpecification> theIncludes
|
||||
Set<Include> theIncludes
|
||||
) {
|
||||
SearchParameterMap paramMap = new SearchParameterMap();
|
||||
paramMap.add("_id", theId);
|
||||
|
@ -11,7 +11,7 @@ public class TestProfileGenerator {
|
||||
@Test
|
||||
public void testIncludes() {
|
||||
|
||||
assertEquals("Patient.link.other", Patient.INCLUDE_LINK_OTHER.getInclude());
|
||||
assertEquals("Patient.link.other", Patient.INCLUDE_LINK_OTHER.getValue());
|
||||
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ public class PatientResourceProvider implements IResourceProvider {
|
||||
publishedDate = InstantDt.withCurrentTime();
|
||||
} else {
|
||||
Patient currentPatitne = myIdToPatientVersions.get(theId).getLast();
|
||||
Map<ResourceMetadataKeyEnum, Object> resourceMetadata = currentPatitne.getResourceMetadata();
|
||||
Map<ResourceMetadataKeyEnum<?>, Object> resourceMetadata = currentPatitne.getResourceMetadata();
|
||||
publishedDate = (InstantDt) resourceMetadata.get(ResourceMetadataKeyEnum.PUBLISHED);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user