Remove warning
This commit is contained in:
parent
f9960b22d5
commit
7ed14d538a
|
@ -54,6 +54,7 @@ ca.uhn.fhir.jpa.dao.BaseHapiFhirSystemDao.transactionInvalidUrl=Unable to perfor
|
|||
|
||||
ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.duplicateCreateForcedId=Can not create entity with ID[{0}], a resource with this ID already exists
|
||||
ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.failedToCreateWithInvalidId=Can not process entity with ID[{0}], this is not a valid FHIR ID
|
||||
ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.incorrectResourceType=Incorrect resource type detected for endpoint, found {0} but expected {1}
|
||||
ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.failedToCreateWithClientAssignedNumericId=Can not create resource with ID[{0}], no resource with this ID exists and clients may only assign IDs which contain at least one non-numeric character
|
||||
ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.failedToCreateWithClientAssignedId=Can not create resource with ID[{0}], ID must not be supplied on a create (POST) operation
|
||||
ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.invalidParameterChain=Invalid parameter chain: {0}
|
||||
|
|
|
@ -754,6 +754,11 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
|
|||
* The resource that is about to be stored
|
||||
*/
|
||||
protected void preProcessResourceForStorage(T theResource) {
|
||||
String type = getContext().getResourceDefinition(theResource).getName();
|
||||
if (!getResourceName().equals(type)) {
|
||||
throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "incorrectResourceType", type, getResourceName()));
|
||||
}
|
||||
|
||||
if (theResource.getIdElement().hasIdPart()) {
|
||||
if (!theResource.getIdElement().isIdPartValid()) {
|
||||
throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "failedToCreateWithInvalidId", theResource.getIdElement().getIdPart()));
|
||||
|
|
|
@ -49,7 +49,6 @@ public class TestDstu21Config extends BaseJavaConfigDstu21 {
|
|||
retVal.setPackagesToScan("ca.uhn.fhir.jpa.entity");
|
||||
retVal.setPersistenceProvider(new HibernatePersistenceProvider());
|
||||
retVal.setJpaProperties(jpaProperties());
|
||||
retVal.afterPropertiesSet();
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@ public class TestDstu2Config extends BaseJavaConfigDstu2 {
|
|||
retVal.setPackagesToScan("ca.uhn.fhir.jpa.entity");
|
||||
retVal.setPersistenceProvider(new HibernatePersistenceProvider());
|
||||
retVal.setJpaProperties(jpaProperties());
|
||||
retVal.afterPropertiesSet();
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.hl7.fhir.dstu21.model.Media;
|
|||
import org.hl7.fhir.dstu21.model.Medication;
|
||||
import org.hl7.fhir.dstu21.model.MedicationOrder;
|
||||
import org.hl7.fhir.dstu21.model.Meta;
|
||||
import org.hl7.fhir.dstu21.model.NamingSystem;
|
||||
import org.hl7.fhir.dstu21.model.Observation;
|
||||
import org.hl7.fhir.dstu21.model.Organization;
|
||||
import org.hl7.fhir.dstu21.model.Patient;
|
||||
|
@ -142,6 +143,9 @@ public abstract class BaseJpaDstu21Test extends BaseJpaTest {
|
|||
@Qualifier("myPatientDaoDstu21")
|
||||
protected IFhirResourceDaoPatient<Patient> myPatientDao;
|
||||
@Autowired
|
||||
@Qualifier("myNamingSystemDaoDstu21")
|
||||
protected IFhirResourceDao<NamingSystem> myNamingSystemDao;
|
||||
@Autowired
|
||||
@Qualifier("myMediaDaoDstu21")
|
||||
protected IFhirResourceDao<Media> myMediaDao;
|
||||
@Autowired
|
||||
|
|
|
@ -49,6 +49,7 @@ import org.hl7.fhir.dstu21.model.Encounter;
|
|||
import org.hl7.fhir.dstu21.model.Enumerations.AdministrativeGender;
|
||||
import org.hl7.fhir.dstu21.model.IdType;
|
||||
import org.hl7.fhir.dstu21.model.Meta;
|
||||
import org.hl7.fhir.dstu21.model.NamingSystem;
|
||||
import org.hl7.fhir.dstu21.model.Observation;
|
||||
import org.hl7.fhir.dstu21.model.OperationOutcome;
|
||||
import org.hl7.fhir.dstu21.model.OperationOutcome.IssueSeverity;
|
||||
|
@ -71,6 +72,8 @@ import org.mockito.ArgumentCaptor;
|
|||
import ca.uhn.fhir.jpa.dao.BaseHapiFhirDao;
|
||||
import ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao;
|
||||
import ca.uhn.fhir.jpa.dao.FhirResourceDaoDstu21;
|
||||
import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
|
||||
import ca.uhn.fhir.jpa.dao.IFhirResourceDaoPatient;
|
||||
import ca.uhn.fhir.jpa.dao.SearchParameterMap;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamString;
|
||||
import ca.uhn.fhir.jpa.entity.TagTypeEnum;
|
||||
|
@ -326,6 +329,51 @@ public class FhirResourceDaoDstu21Test extends BaseJpaDstu21Test {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateLongString() {
|
||||
//@formatter:off
|
||||
String input = "<NamingSystem>\n" +
|
||||
" <name value=\"NDF-RT (National Drug File – Reference Terminology)\"/>\n" +
|
||||
" <status value=\"draft\"/>\n" +
|
||||
" <kind value=\"codesystem\"/>\n" +
|
||||
" <publisher value=\"HL7, Inc\"/>\n" +
|
||||
" <date value=\"2015-08-21\"/>\n" +
|
||||
" <uniqueId>\n" +
|
||||
" <type value=\"uri\"/>\n" +
|
||||
" <value value=\"http://hl7.org/fhir/ndfrt\"/>\n" +
|
||||
" <preferred value=\"true\"/>\n" +
|
||||
" </uniqueId>\n" +
|
||||
" <uniqueId>\n" +
|
||||
" <type value=\"oid\"/>\n" +
|
||||
" <value value=\"2.16.840.1.113883.6.209\"/>\n" +
|
||||
" <preferred value=\"false\"/>\n" +
|
||||
" </uniqueId>\n" +
|
||||
" </NamingSystem>";
|
||||
//@formatter:on
|
||||
|
||||
NamingSystem res = myFhirCtx.newXmlParser().parseResource(NamingSystem.class, input);
|
||||
IIdType id = myNamingSystemDao.create(res).getId().toUnqualifiedVersionless();
|
||||
|
||||
assertThat(toUnqualifiedVersionlessIdValues(myNamingSystemDao.search(NamingSystem.SP_NAME, new StringParam("NDF"))), contains(id.getValue()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateWrongType() {
|
||||
|
||||
// Lose typing so we can put the wrong type in
|
||||
@SuppressWarnings("rawtypes")
|
||||
IFhirResourceDao dao = myNamingSystemDao;
|
||||
|
||||
Patient resource = new Patient();
|
||||
resource.addName().addFamily("My Name");
|
||||
try {
|
||||
dao.create(resource);
|
||||
fail();
|
||||
} catch (InvalidRequestException e) {
|
||||
assertEquals("Incorrect resource type detected for endpoint, found Patient but expected NamingSystem", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateTextIdFails() {
|
||||
Patient p = new Patient();
|
||||
|
@ -829,8 +877,7 @@ public class FhirResourceDaoDstu21Test extends BaseJpaDstu21Test {
|
|||
|
||||
assertGone(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testDeleteWithMatchUrlChainedIdentifier() {
|
||||
String methodName = "testDeleteWithMatchUrlChainedIdentifer";
|
||||
|
@ -850,13 +897,12 @@ public class FhirResourceDaoDstu21Test extends BaseJpaDstu21Test {
|
|||
myPatientDao.deleteByUrl("Patient?organization.identifier=http://example.com|" + methodName);
|
||||
assertGone(id);
|
||||
assertNotGone(orgId);
|
||||
|
||||
|
||||
myOrganizationDao.deleteByUrl("Organization?identifier=http://example.com|" + methodName);
|
||||
assertGone(id);
|
||||
assertGone(orgId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDeleteWithMatchUrlChainedTag() {
|
||||
|
@ -864,9 +910,9 @@ public class FhirResourceDaoDstu21Test extends BaseJpaDstu21Test {
|
|||
|
||||
Organization org = new Organization();
|
||||
org.getMeta().addTag().setSystem("http://foo").setCode("term");
|
||||
|
||||
|
||||
org.setName(methodName);
|
||||
|
||||
|
||||
IIdType orgId = myOrganizationDao.create(org).getId().toUnqualifiedVersionless();
|
||||
|
||||
Patient p = new Patient();
|
||||
|
@ -878,7 +924,7 @@ public class FhirResourceDaoDstu21Test extends BaseJpaDstu21Test {
|
|||
|
||||
myPatientDao.deleteByUrl("Patient?organization._tag=http://foo|term");
|
||||
assertGone(id);
|
||||
|
||||
|
||||
myOrganizationDao.deleteByUrl("Organization?_tag=http://foo|term");
|
||||
try {
|
||||
myOrganizationDao.read(orgId);
|
||||
|
@ -903,7 +949,6 @@ public class FhirResourceDaoDstu21Test extends BaseJpaDstu21Test {
|
|||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDeleteWithMatchUrlQualifierMissing() {
|
||||
String methodName = "testDeleteWithMatchUrlChainedProfile";
|
||||
|
@ -924,9 +969,9 @@ public class FhirResourceDaoDstu21Test extends BaseJpaDstu21Test {
|
|||
/*
|
||||
* Org 2 has a name
|
||||
*/
|
||||
|
||||
|
||||
Organization org2 = new Organization();
|
||||
org2.setName(methodName);
|
||||
org2.setName(methodName);
|
||||
org2.addIdentifier().setValue(methodName);
|
||||
IIdType org2Id = myOrganizationDao.create(org2).getId().toUnqualifiedVersionless();
|
||||
|
||||
|
@ -939,13 +984,13 @@ public class FhirResourceDaoDstu21Test extends BaseJpaDstu21Test {
|
|||
ourLog.info("Org ID 1 : {}", org1Id);
|
||||
ourLog.info("Pat ID 2 : {}", patId2);
|
||||
ourLog.info("Org ID 2 : {}", org2Id);
|
||||
|
||||
|
||||
myPatientDao.deleteByUrl("Patient?organization.name:missing=true");
|
||||
assertGone(patId1);
|
||||
assertNotGone(patId2);
|
||||
assertNotGone(org1Id);
|
||||
assertNotGone(org2Id);
|
||||
|
||||
|
||||
myOrganizationDao.deleteByUrl("Organization?name:missing=true");
|
||||
assertGone(patId1);
|
||||
assertNotGone(patId2);
|
||||
|
@ -957,7 +1002,7 @@ public class FhirResourceDaoDstu21Test extends BaseJpaDstu21Test {
|
|||
assertGone(patId2);
|
||||
assertGone(org1Id);
|
||||
assertNotGone(org2Id);
|
||||
|
||||
|
||||
myOrganizationDao.deleteByUrl("Organization?name:missing=false");
|
||||
assertGone(patId1);
|
||||
assertGone(patId2);
|
||||
|
@ -971,12 +1016,13 @@ public class FhirResourceDaoDstu21Test extends BaseJpaDstu21Test {
|
|||
private void assertNotGone(IIdType theId) {
|
||||
if ("Patient".equals(theId.getResourceType())) {
|
||||
myPatientDao.read(theId);
|
||||
} else if ("Organization".equals(theId.getResourceType())){
|
||||
} else if ("Organization".equals(theId.getResourceType())) {
|
||||
myOrganizationDao.read(theId);
|
||||
} else {
|
||||
fail("No type");
|
||||
}
|
||||
}
|
||||
|
||||
private void assertGone(IIdType theId) {
|
||||
try {
|
||||
assertNotGone(theId);
|
||||
|
@ -986,19 +1032,17 @@ public class FhirResourceDaoDstu21Test extends BaseJpaDstu21Test {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testDeleteWithMatchUrlChainedProfile() {
|
||||
String methodName = "testDeleteWithMatchUrlChainedProfile";
|
||||
|
||||
List<IdType> profileList = new ArrayList<IdType>();
|
||||
|
||||
|
||||
Organization org = new Organization();
|
||||
|
||||
org.getMeta().getProfile().add(new IdType("http://foo"));
|
||||
|
||||
org.getMeta().getProfile().add(new IdType("http://foo"));
|
||||
org.setName(methodName);
|
||||
|
||||
|
||||
IIdType orgId = myOrganizationDao.create(org).getId().toUnqualifiedVersionless();
|
||||
|
||||
Patient p = new Patient();
|
||||
|
@ -1010,7 +1054,7 @@ public class FhirResourceDaoDstu21Test extends BaseJpaDstu21Test {
|
|||
|
||||
myPatientDao.deleteByUrl("Patient?organization._profile=http://foo");
|
||||
assertGone(id);
|
||||
|
||||
|
||||
myOrganizationDao.deleteByUrl("Organization?_profile=http://foo");
|
||||
try {
|
||||
myOrganizationDao.read(orgId);
|
||||
|
@ -1995,7 +2039,7 @@ public class FhirResourceDaoDstu21Test extends BaseJpaDstu21Test {
|
|||
patient.getMeta().addTag(null, "Dog", "Puppies");
|
||||
|
||||
patient.getMeta().addSecurity().setSystem("seclabel:sys:1").setCode("seclabel:code:1").setDisplay("seclabel:dis:1");
|
||||
|
||||
|
||||
patient.getMeta().addProfile(("http://profile/1"));
|
||||
|
||||
id1 = myPatientDao.create(patient).getId();
|
||||
|
@ -2741,7 +2785,7 @@ public class FhirResourceDaoDstu21Test extends BaseJpaDstu21Test {
|
|||
assertEquals("http://profile/1", profiles.get(0).getValue());
|
||||
assertEquals("http://profile/2", profiles.get(1).getValue());
|
||||
|
||||
List<Patient> search = toList(myPatientDao.search(Patient.SP_IDENTIFIER, new TokenParam(patient.getIdentifier().get(0).getSystem(),patient.getIdentifier().get(0).getValue())));
|
||||
List<Patient> search = toList(myPatientDao.search(Patient.SP_IDENTIFIER, new TokenParam(patient.getIdentifier().get(0).getSystem(), patient.getIdentifier().get(0).getValue())));
|
||||
assertEquals(1, search.size());
|
||||
retrieved = search.get(0);
|
||||
|
||||
|
|
|
@ -63,7 +63,6 @@ public class FhirServerConfig extends BaseJavaConfigDstu2 {
|
|||
retVal.setPackagesToScan("ca.uhn.fhir.jpa.entity");
|
||||
retVal.setPersistenceProvider(new HibernatePersistenceProvider());
|
||||
retVal.setJpaProperties(jpaProperties());
|
||||
retVal.afterPropertiesSet();
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,6 @@ public class TestDstu1Config extends BaseJavaConfigDstu1 {
|
|||
retVal.setPackagesToScan("ca.uhn.fhir.jpa.entity");
|
||||
retVal.setPersistenceProvider(new HibernatePersistenceProvider());
|
||||
retVal.setJpaProperties(jpaProperties());
|
||||
retVal.afterPropertiesSet();
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,6 @@ public class TestDstu21Config extends BaseJavaConfigDstu21 {
|
|||
retVal.setPackagesToScan("ca.uhn.fhir.jpa.entity");
|
||||
retVal.setPersistenceProvider(new HibernatePersistenceProvider());
|
||||
retVal.setJpaProperties(jpaProperties());
|
||||
retVal.afterPropertiesSet();
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,6 @@ public class TestDstu2Config extends BaseJavaConfigDstu2 {
|
|||
retVal.setPackagesToScan("ca.uhn.fhir.jpa.entity");
|
||||
retVal.setPersistenceProvider(new HibernatePersistenceProvider());
|
||||
retVal.setJpaProperties(jpaProperties());
|
||||
retVal.afterPropertiesSet();
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
|
|
@ -139,6 +139,12 @@
|
|||
implementations and wasn't compatible
|
||||
with coming changes to that API.
|
||||
</action>
|
||||
<action type="fix">
|
||||
Remove afterPropertiesSet() call in Java config for JPA
|
||||
server's EntityManagerFactory. This doesn't need to be called
|
||||
manually, the the manual call led to a warning about
|
||||
the EntityManager being created twice.
|
||||
</action>
|
||||
</release>
|
||||
<release version="1.3" date="2015-11-14">
|
||||
<action type="add">
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<faqs xmlns="http://maven.apache.org/FML/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/FML/1.0.1 http://maven.apache.org/xsd/fml-1.0.1.xsd"
|
||||
title="Frequently Asked Questions" toplink="false">
|
||||
<part id="JPA Server">
|
||||
<title>JPA Server</title>
|
||||
<faq id="access_underlying_derby_database">
|
||||
<question>
|
||||
I would like to connect to the Derby database using a JDBC database browser (e.g. Squirrel, Toad, DBVisualizer)
|
||||
so that I can access the underlying tables. How do I do that?
|
||||
</question>
|
||||
<answer>
|
||||
<p>
|
||||
By default Derby doesn't actually open any TCP ports for you to connect externally to it.
|
||||
Being an embedded database, it works a bit differently than other databases in that the
|
||||
client actually is the database and there's no outside communication with it possible.
|
||||
</p>
|
||||
<p>
|
||||
There are a few options available to work around this fact:
|
||||
<ul>
|
||||
<li>
|
||||
The easiest thing is to just load your data using the FHIR API. E.g. you can
|
||||
use HTTP/REST creates, transactions, etc to load data into your database directly.
|
||||
</li>
|
||||
<li>
|
||||
If you want to access the underlying database, the next easiest thing is to configure
|
||||
the database to use a filesystem directory, e.g.
|
||||
"<code>jdbc:derby:directory:target/jpaserver_derby_files;create=true</code>". You can
|
||||
then shut the server down and use that same URL to connect a derby client (e.g.
|
||||
Squirrel or DBVisualizer) to the same path. You may need to use a fully qualified
|
||||
path instead of a relative one though.
|
||||
</li>
|
||||
<li>
|
||||
Another option is to use a different database (e.g. MySQL, Postgres, Oracle, etc.).
|
||||
HAPI's JPA server is based on JPA/Hibernate so it will support any database platform
|
||||
that hibernate supports.
|
||||
</li>
|
||||
<li>
|
||||
A final option is to start up Derby in network mode. Doing this is a bit more
|
||||
involved since you need to start the derby server separately, and then use a special
|
||||
URL to connect to it. You can find an example of how to start network Derby
|
||||
<a href="https://github.com/jamesagnew/hapi-fhir/blob/master/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/DerbyNetworkServer.java">here</a>
|
||||
and
|
||||
an example of setting up a datasource
|
||||
<a href="https://github.com/jamesagnew/hapi-fhir/blob/master/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu21Config.java">here</a>.
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
</answer>
|
||||
</faq>
|
||||
</part>
|
||||
</faqs>
|
Loading…
Reference in New Issue