Skip to content

Commit

Permalink
Lots of work on DSTU2 server
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesagnew committed Dec 21, 2014
1 parent 94bef8d commit 994e490
Show file tree
Hide file tree
Showing 206 changed files with 5,659 additions and 114,093 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,14 @@ private String scanResource(Class<? extends IBaseResource> theClass, ResourceDef
RuntimeResourceDefinition resourceDef = new RuntimeResourceDefinition(myContext, resourceName, theClass, resourceDefinition);
myClassToElementDefinitions.put(theClass, resourceDef);
if (primaryNameProvider) {
myNameToResourceDefinitions.put(resourceName, resourceDef);
try {
IResource res = (IResource) theClass.newInstance();
if (res.getStructureFhirVersionEnum() == myContext.getVersion().getVersion()) {
myNameToResourceDefinitions.put(resourceName, resourceDef);
}
} catch (Exception e) {
ourLog.error("Failed to instantiate type[" +theClass.getName() +"]", e);
}
}
scanCompositeElementForChildren(theClass, resourceDef);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
* #L%
*/

import java.util.Map;

import ca.uhn.fhir.model.api.annotation.ResourceDef;
import ca.uhn.fhir.model.base.resource.ResourceMetadataMap;
import ca.uhn.fhir.model.dstu.composite.ContainedDt;
Expand Down Expand Up @@ -134,4 +132,10 @@ public interface IResource extends ICompositeElement, org.hl7.fhir.instance.mode
*/
String getResourceName();

/**
* Returns the FHIR version represented by this structure
*/
public ca.uhn.fhir.context.FhirVersionEnum getStructureFhirVersionEnum();


}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public BaseResourceReferenceDt(IResource theResource) {
setReference(theResource.getId());
}

protected abstract IdDt getReference();
public abstract IdDt getReference();

/**
* Gets the actual loaded and parsed resource instance, <b>if it is already present</b>. This method will return the resource instance only if it has previously been loaded using
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
import java.util.Collections;
import java.util.List;

import org.apache.commons.lang3.StringUtils;

import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.model.api.BaseResource;
import ca.uhn.fhir.model.api.IElement;
import ca.uhn.fhir.model.api.IResource;
Expand Down Expand Up @@ -105,4 +104,9 @@ public String getResourceName() {
return Binary.class.getName();
}

@Override
public FhirVersionEnum getStructureFhirVersionEnum() {
return FhirVersionEnum.DSTU1;
}

}
12 changes: 7 additions & 5 deletions hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/ParserState.java
Original file line number Diff line number Diff line change
Expand Up @@ -1834,12 +1834,14 @@ public void endingElement() {

@Override
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException {
throw new Error("Element " + theLocalPart + " in primitive!"); // TODO:
// can
// this
// happen?
if (false) {// TODO: make this configurable
throw new Error("Element " + theLocalPart + " in primitive!"); // TODO:
}
ourLog.warn("Ignoring element {} in primitive tag", theLocalPart);
push(new SwallowChildrenWholeState(getPreResourceState()));
return;
}

@Override
protected IBase getCurrentElement() {
return myInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,21 @@ public interface IRestfulClientFactory {
*/
IGenericClient newGenericClient(String theServerBase);


/**
* Sets the socket timeout (in milliseconds)
*/
void setSocketTimeout(int theSocketTimeout);


/**
* Sets the connection timeout (in milliseconds)
*/
void setConnectTimeout(int theConnectTimeout);


/**
* Sets the connection request timeout (in milliseconds)
*/
void setConnectionRequestTimeout(int theConnectionRequestTimeout);

/**
Expand Down
5 changes: 5 additions & 0 deletions hapi-fhir-base/testmindeps/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>0.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dev</artifactId>
<version>0.9-SNAPSHOT</version>
</dependency>
</dependencies>


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package ca.uhn.fhir.testmindeps;

import static org.junit.Assert.*;

import org.junit.Test;

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.model.dstu.resource.Patient;

public class FhirContextTest {

@Test
public void testWrongVersionDoesntGetInContext1() {

FhirContext ctx = FhirContext.forDstu1();
RuntimeResourceDefinition def = ctx.getResourceDefinition("Patient");
assertEquals(Patient.class, def.getImplementingClass());
}

@Test
public void testWrongVersionDoesntGetInContext2() {

FhirContext ctx = FhirContext.forDstu1();
RuntimeResourceDefinition def = ctx.getResourceDefinition("Patient");
assertEquals(Patient.class, def.getImplementingClass());

ctx = FhirContext.forDstu1();
def = ctx.getResourceDefinition(ca.uhn.fhir.model.dev.resource.Patient.class);
assertEquals(ca.uhn.fhir.model.dev.resource.Patient.class, def.getImplementingClass());
def = ctx.getResourceDefinition("Patient");
assertEquals(Patient.class, def.getImplementingClass());

}

}
10 changes: 10 additions & 0 deletions hapi-fhir-jpaserver-base/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,15 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="target/generated-sources/tinder">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="target/generated-resources/tinder">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding//target/generated-resources/tinder=UTF-8
encoding//target/generated-sources/tinder=UTF-8
encoding/<project>=UTF-8
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
<wb-module deploy-name="hapi-fhir-jpaserver-base">
<wb-resource deploy-path="/" source-path="/src/main/java"/>
<wb-resource deploy-path="/" source-path="/src/main/resources"/>
<wb-resource deploy-path="/" source-path="/target/generated-sources/tinder"/>
<wb-resource deploy-path="/" source-path="/target/generated-resources/tinder"/>
</wb-module>
</project-modules>
59 changes: 59 additions & 0 deletions hapi-fhir-jpaserver-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>0.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dev</artifactId>
<version>0.9-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
Expand Down Expand Up @@ -318,6 +323,49 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-tinder-plugin</artifactId>
<version>0.9-SNAPSHOT</version>
<executions>
<execution>
<id>build_dstu1</id>
<goals>
<goal>generate-jparest-server</goal>
</goals>
<configuration>
<version>dstu</version>
<packageBase>ca.uhn.fhir.jpa.rp.dstu</packageBase>
<targetResourceSpringBeansFile>hapi-fhir-server-resourceproviders-dstu1.xml</targetResourceSpringBeansFile>
<baseResourceNames></baseResourceNames>
</configuration>
</execution>
<execution>
<id>build_dev</id>
<goals>
<goal>generate-jparest-server</goal>
</goals>
<configuration>
<version>dev</version>
<packageBase>ca.uhn.fhir.jpa.rp.dev</packageBase>
<targetResourceSpringBeansFile>hapi-fhir-server-resourceproviders-dev.xml</targetResourceSpringBeansFile>
<baseResourceNames></baseResourceNames>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>0.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dev</artifactId>
<version>0.9-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
Expand All @@ -326,6 +374,17 @@
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
<resource>
<directory>${basedir}/target/generated-sources/tinder</directory>
</resource>
<resource>
<directory>${basedir}/target/generated-resources/tinder</directory>
</resource>
</resources>
</build>

<profiles>
Expand Down
Loading

0 comments on commit 994e490

Please sign in to comment.