-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correctly handle custom types in programatic access to JPA
- Loading branch information
1 parent
090f079
commit eba136d
Showing
9 changed files
with
159 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/CustomObservationDstu3.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package ca.uhn.fhir.jpa.dao.dstu3; | ||
|
||
import org.hl7.fhir.dstu3.model.Observation; | ||
import org.hl7.fhir.dstu3.model.StringType; | ||
|
||
import ca.uhn.fhir.model.api.annotation.Child; | ||
import ca.uhn.fhir.model.api.annotation.Extension; | ||
import ca.uhn.fhir.model.api.annotation.ResourceDef; | ||
|
||
@ResourceDef(name = "Observation", profile = CustomObservationDstu3.PROFILE) | ||
public class CustomObservationDstu3 extends Observation { | ||
|
||
public static final String PROFILE = "http://custom_ObservationDstu3"; | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Extension(definedLocally = false, isModifier = false, url = "http://eyeColour") | ||
@Child(name = "eyeColour") | ||
private StringType myEyeColour; | ||
|
||
public StringType getEyeColour() { | ||
return myEyeColour; | ||
} | ||
|
||
public void setEyeColour(StringType theEyeColour) { | ||
myEyeColour = theEyeColour; | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
...rver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoCustomTypeDstu3Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package ca.uhn.fhir.jpa.dao.dstu3; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.hl7.fhir.dstu3.model.StringType; | ||
import org.hl7.fhir.instance.model.api.IIdType; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import ca.uhn.fhir.jpa.dao.SearchParameterMap; | ||
import ca.uhn.fhir.rest.server.IBundleProvider; | ||
|
||
@SuppressWarnings({ }) | ||
public class FhirResourceDaoCustomTypeDstu3Test extends BaseJpaDstu3Test { | ||
|
||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoCustomTypeDstu3Test.class); | ||
|
||
@Before | ||
public void before() { | ||
myFhirCtx.setDefaultTypeForProfile(CustomObservationDstu3.PROFILE, CustomObservationDstu3.class); | ||
} | ||
|
||
@Test | ||
public void testSaveAndRestore() { | ||
CustomObservationDstu3 obs = new CustomObservationDstu3(); | ||
obs.setEyeColour(new StringType("blue")); | ||
|
||
IIdType id = myObservationDao.create(obs).getId().toUnqualifiedVersionless(); | ||
|
||
CustomObservationDstu3 read = (CustomObservationDstu3) myObservationDao.read(id); | ||
assertEquals("blue", read.getEyeColour().getValue()); | ||
|
||
IBundleProvider found = myObservationDao.search(new SearchParameterMap()); | ||
assertEquals(1, found.size()); | ||
CustomObservationDstu3 search = (CustomObservationDstu3) found.getResources(0, 1).get(0); | ||
assertEquals("blue", search.getEyeColour().getValue()); | ||
|
||
} | ||
|
||
@After | ||
public void after() { | ||
myFhirCtx.setDefaultTypeForProfile(CustomObservationDstu3.PROFILE, null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
hapi-fhir-jpaserver-base/src/test/resources/bug454_utf8.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"resourceType": "CodeSystem", | ||
"url": "http://nestvision.com/fhir/myexample-yh", | ||
"name": "NestVision Restful Interactions", | ||
"status": "active", | ||
"publisher": "鏉ㄦ旦", | ||
"description": "this is a codesystem example.", | ||
"caseSensitive": true, | ||
"concept": [ | ||
{ | ||
"code": "mygod", | ||
"display": "wodetian", | ||
"definition": "this is a translate." | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
call SYSCS_UTIL.SYSCS_COMPRESS_TABLE('SA', 'HFJ_SEARCH_RESULT', 1); | ||
CALL SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE( 'SA', 'HFJ_SEARCH_RESULT', 0, 0, 1 ); | ||
|
||
|
||
dd if=/dev/urandom of=/opt/glassfish/tmp.tmp bs=1M count=500 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters