Get JPA working with single table
This commit is contained in:
parent
ee0a16990b
commit
75205c5d75
|
@ -175,59 +175,6 @@
|
||||||
<skip>true</skip>
|
<skip>true</skip>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>de.juplo</groupId>
|
|
||||||
<artifactId>hibernate4-maven-plugin</artifactId>
|
|
||||||
<version>1.0.1</version>
|
|
||||||
<configuration>
|
|
||||||
<force>true</force>
|
|
||||||
<target>SCRIPT</target>
|
|
||||||
<skip>false</skip>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>o10g</id>
|
|
||||||
<goals>
|
|
||||||
<goal>export</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<hibernateDialect>org.hibernate.dialect.Oracle10gDialect</hibernateDialect>
|
|
||||||
<outputFile>${project.build.directory}/schema_oracle_10g.sql</outputFile>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<id>derby</id>
|
|
||||||
<goals>
|
|
||||||
<goal>export</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<hibernateDialect>org.hibernate.dialect.DerbyTenSevenDialect</hibernateDialect>
|
|
||||||
<outputFile>${project.build.directory}/schema_derby.sql</outputFile>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<id>hsql</id>
|
|
||||||
<goals>
|
|
||||||
<goal>export</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<hibernateDialect>org.hibernate.dialect.HSQLDialect</hibernateDialect>
|
|
||||||
<outputFile>${project.build.directory}/schema_hsql.sql</outputFile>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<id>mysql5</id>
|
|
||||||
<goals>
|
|
||||||
<goal>export</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<hibernateDialect>org.hibernate.dialect.MySQL5Dialect</hibernateDialect>
|
|
||||||
<outputFile>${project.build.directory}/schema_mysql_5.sql</outputFile>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package ca.uhn.fhir.jpa.dao;
|
package ca.uhn.fhir.jpa.dao;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
import static org.apache.commons.lang3.StringUtils.*;
|
||||||
|
|
||||||
import java.text.Normalizer;
|
import java.text.Normalizer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -41,7 +41,7 @@ import ca.uhn.fhir.context.RuntimeChildResourceDefinition;
|
||||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
import ca.uhn.fhir.context.RuntimeSearchParam;
|
import ca.uhn.fhir.context.RuntimeSearchParam;
|
||||||
import ca.uhn.fhir.jpa.entity.BaseHasResource;
|
import ca.uhn.fhir.jpa.entity.BaseHasResource;
|
||||||
import ca.uhn.fhir.jpa.entity.BaseResourceTable;
|
import ca.uhn.fhir.jpa.entity.ResourceTable;
|
||||||
import ca.uhn.fhir.jpa.entity.BaseTag;
|
import ca.uhn.fhir.jpa.entity.BaseTag;
|
||||||
import ca.uhn.fhir.jpa.entity.ResourceHistoryTable;
|
import ca.uhn.fhir.jpa.entity.ResourceHistoryTable;
|
||||||
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamDate;
|
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamDate;
|
||||||
|
@ -75,12 +75,11 @@ import ca.uhn.fhir.rest.param.QualifiedDateParam;
|
||||||
import ca.uhn.fhir.rest.param.ReferenceParam;
|
import ca.uhn.fhir.rest.param.ReferenceParam;
|
||||||
import ca.uhn.fhir.rest.param.StringParam;
|
import ca.uhn.fhir.rest.param.StringParam;
|
||||||
import ca.uhn.fhir.rest.server.EncodingEnum;
|
import ca.uhn.fhir.rest.server.EncodingEnum;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||||
import ca.uhn.fhir.util.FhirTerser;
|
import ca.uhn.fhir.util.FhirTerser;
|
||||||
|
|
||||||
public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>> implements IFhirResourceDao<T> {
|
public class FhirResourceDao<T extends IResource> implements IFhirResourceDao<T> {
|
||||||
|
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDao.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDao.class);
|
||||||
private FhirContext myCtx;
|
private FhirContext myCtx;
|
||||||
|
@ -96,16 +95,15 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
|
||||||
private Class<T> myResourceType;
|
private Class<T> myResourceType;
|
||||||
private Map<Class<? extends IResource>, IFhirResourceDao<?>> myResourceTypeToDao;
|
private Map<Class<? extends IResource>, IFhirResourceDao<?>> myResourceTypeToDao;
|
||||||
|
|
||||||
private Class<X> myTableType;
|
|
||||||
|
|
||||||
@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
|
@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
|
||||||
@Override
|
@Override
|
||||||
public MethodOutcome create(T theResource) {
|
public MethodOutcome create(T theResource) {
|
||||||
|
|
||||||
final X entity = toEntity(theResource);
|
final ResourceTable entity = toEntity(theResource);
|
||||||
|
|
||||||
entity.setPublished(new Date());
|
entity.setPublished(new Date());
|
||||||
entity.setUpdated(entity.getPublished());
|
entity.setUpdated(entity.getPublished());
|
||||||
|
entity.setResourceType(toResourceName(theResource));
|
||||||
|
|
||||||
final List<ResourceIndexedSearchParamString> stringParams = extractSearchParamStrings(entity, theResource);
|
final List<ResourceIndexedSearchParamString> stringParams = extractSearchParamStrings(entity, theResource);
|
||||||
final List<ResourceIndexedSearchParamToken> tokenParams = extractSearchParamTokens(entity, theResource);
|
final List<ResourceIndexedSearchParamToken> tokenParams = extractSearchParamTokens(entity, theResource);
|
||||||
|
@ -118,9 +116,9 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
|
||||||
TransactionTemplate template = new TransactionTemplate(myPlatformTransactionManager);
|
TransactionTemplate template = new TransactionTemplate(myPlatformTransactionManager);
|
||||||
template.setPropagationBehavior(TransactionTemplate.PROPAGATION_REQUIRES_NEW);
|
template.setPropagationBehavior(TransactionTemplate.PROPAGATION_REQUIRES_NEW);
|
||||||
template.setReadOnly(false);
|
template.setReadOnly(false);
|
||||||
template.execute(new TransactionCallback<X>() {
|
template.execute(new TransactionCallback<ResourceTable>() {
|
||||||
@Override
|
@Override
|
||||||
public X doInTransaction(TransactionStatus theStatus) {
|
public ResourceTable doInTransaction(TransactionStatus theStatus) {
|
||||||
myEntityManager.persist(entity);
|
myEntityManager.persist(entity);
|
||||||
for (ResourceIndexedSearchParamString next : stringParams) {
|
for (ResourceIndexedSearchParamString next : stringParams) {
|
||||||
myEntityManager.persist(next);
|
myEntityManager.persist(next);
|
||||||
|
@ -145,14 +143,15 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
|
||||||
return outcome;
|
return outcome;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String toResourceName(T theResource) {
|
||||||
|
return myCtx.getResourceDefinition(theResource).getName();
|
||||||
|
}
|
||||||
|
|
||||||
public Class<T> getResourceType() {
|
public Class<T> getResourceType() {
|
||||||
return myResourceType;
|
return myResourceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<X> getTableType() {
|
|
||||||
return myTableType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(propagation = Propagation.REQUIRED)
|
@Transactional(propagation = Propagation.REQUIRED)
|
||||||
@Override
|
@Override
|
||||||
|
@ -186,7 +185,6 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void postConstruct() throws Exception {
|
public void postConstruct() throws Exception {
|
||||||
myResourceType = myTableType.newInstance().getResourceType();
|
|
||||||
myCtx = new FhirContext(myResourceType);
|
myCtx = new FhirContext(myResourceType);
|
||||||
myResourceName = myCtx.getResourceDefinition(myResourceType).getName();
|
myResourceName = myCtx.getResourceDefinition(myResourceType).getName();
|
||||||
}
|
}
|
||||||
|
@ -194,7 +192,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
|
||||||
@Transactional(propagation = Propagation.REQUIRED)
|
@Transactional(propagation = Propagation.REQUIRED)
|
||||||
@Override
|
@Override
|
||||||
public T read(IdDt theId) {
|
public T read(IdDt theId) {
|
||||||
X entity = readEntity(theId);
|
ResourceTable entity = readEntity(theId);
|
||||||
|
|
||||||
T retVal = toResource(entity);
|
T retVal = toResource(entity);
|
||||||
return retVal;
|
return retVal;
|
||||||
|
@ -226,15 +224,16 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
|
||||||
// Execute the query and make sure we return distinct results
|
// Execute the query and make sure we return distinct results
|
||||||
{
|
{
|
||||||
CriteriaBuilder builder = myEntityManager.getCriteriaBuilder();
|
CriteriaBuilder builder = myEntityManager.getCriteriaBuilder();
|
||||||
CriteriaQuery<X> cq = builder.createQuery(myTableType);
|
CriteriaQuery<ResourceTable> cq = builder.createQuery(ResourceTable.class);
|
||||||
Root<X> from = cq.from(myTableType);
|
Root<ResourceTable> from = cq.from(ResourceTable.class);
|
||||||
|
cq.where(builder.equal(from.get("myResourceType"), myCtx.getResourceDefinition(myResourceType).getName()));
|
||||||
if (!theParams.isEmpty()) {
|
if (!theParams.isEmpty()) {
|
||||||
cq.where(from.get("myId").in(pids));
|
cq.where(from.get("myId").in(pids));
|
||||||
}
|
}
|
||||||
TypedQuery<X> q = myEntityManager.createQuery(cq);
|
TypedQuery<ResourceTable> q = myEntityManager.createQuery(cq);
|
||||||
|
|
||||||
List<T> retVal = new ArrayList<>();
|
List<T> retVal = new ArrayList<>();
|
||||||
for (X next : q.getResultList()) {
|
for (ResourceTable next : q.getResultList()) {
|
||||||
T resource = toResource(next);
|
T resource = toResource(next);
|
||||||
retVal.add(resource);
|
retVal.add(resource);
|
||||||
}
|
}
|
||||||
|
@ -321,9 +320,10 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
|
||||||
return pids;
|
return pids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Required
|
@Required
|
||||||
public void setTableType(Class<X> theTableType) {
|
public void setResourceType(Class<? extends IResource> theTableType) {
|
||||||
myTableType = theTableType;
|
myResourceType = (Class<T>) theTableType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(propagation = Propagation.SUPPORTS)
|
@Transactional(propagation = Propagation.SUPPORTS)
|
||||||
|
@ -331,11 +331,11 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
|
||||||
public MethodOutcome update(final T theResource, final IdDt theId) {
|
public MethodOutcome update(final T theResource, final IdDt theId) {
|
||||||
|
|
||||||
TransactionTemplate template = new TransactionTemplate(myPlatformTransactionManager);
|
TransactionTemplate template = new TransactionTemplate(myPlatformTransactionManager);
|
||||||
X savedEntity = template.execute(new TransactionCallback<X>() {
|
ResourceTable savedEntity = template.execute(new TransactionCallback<ResourceTable>() {
|
||||||
@Override
|
@Override
|
||||||
public X doInTransaction(TransactionStatus theStatus) {
|
public ResourceTable doInTransaction(TransactionStatus theStatus) {
|
||||||
|
|
||||||
final X entity = readEntity(theId);
|
final ResourceTable entity = readEntity(theId);
|
||||||
entity.setUpdated(entity.getPublished());
|
entity.setUpdated(entity.getPublished());
|
||||||
|
|
||||||
final ResourceHistoryTable historyEntry = entity.toHistory(myCtx);
|
final ResourceHistoryTable historyEntry = entity.toHistory(myCtx);
|
||||||
|
@ -733,7 +733,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
|
||||||
return new HashSet<Long>(q.getResultList());
|
return new HashSet<Long>(q.getResultList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ResourceLink> extractResourceLinks(X theEntity, T theResource) {
|
private List<ResourceLink> extractResourceLinks(ResourceTable theEntity, T theResource) {
|
||||||
ArrayList<ResourceLink> retVal = new ArrayList<ResourceLink>();
|
ArrayList<ResourceLink> retVal = new ArrayList<ResourceLink>();
|
||||||
|
|
||||||
RuntimeResourceDefinition def = myCtx.getResourceDefinition(theResource);
|
RuntimeResourceDefinition def = myCtx.getResourceDefinition(theResource);
|
||||||
|
@ -770,7 +770,10 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<Class<? extends IResource>, IFhirResourceDao<?>> resourceTypeToDao = getResourceTypeToDao();
|
Map<Class<? extends IResource>, IFhirResourceDao<?>> resourceTypeToDao = getResourceTypeToDao();
|
||||||
Class<? extends BaseResourceTable<?>> tableType = resourceTypeToDao.get(type).getTableType();
|
IFhirResourceDao<?> dao = resourceTypeToDao.get(type);
|
||||||
|
if (dao == null) {
|
||||||
|
throw new InvalidRequestException("This server is not able to handle resources of type: " + nextValue.getResourceType());
|
||||||
|
}
|
||||||
Long valueOf;
|
Long valueOf;
|
||||||
try {
|
try {
|
||||||
valueOf = Long.valueOf(id);
|
valueOf = Long.valueOf(id);
|
||||||
|
@ -778,7 +781,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
|
||||||
String resName = myCtx.getResourceDefinition(type).getName();
|
String resName = myCtx.getResourceDefinition(type).getName();
|
||||||
throw new InvalidRequestException("Resource ID " + resName + "/" + id + " is invalid (must be numeric), specified in path: " + nextPath);
|
throw new InvalidRequestException("Resource ID " + resName + "/" + id + " is invalid (must be numeric), specified in path: " + nextPath);
|
||||||
}
|
}
|
||||||
BaseResourceTable<?> target = myEntityManager.find(tableType, valueOf);
|
ResourceTable target = myEntityManager.find(ResourceTable.class, valueOf);
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
String resName = myCtx.getResourceDefinition(type).getName();
|
String resName = myCtx.getResourceDefinition(type).getName();
|
||||||
throw new InvalidRequestException("Resource " + resName + "/" + id + " not found, specified in path: " + nextPath);
|
throw new InvalidRequestException("Resource " + resName + "/" + id + " not found, specified in path: " + nextPath);
|
||||||
|
@ -802,7 +805,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ResourceIndexedSearchParamDate> extractSearchParamDates(X theEntity, T theResource) {
|
private List<ResourceIndexedSearchParamDate> extractSearchParamDates(ResourceTable theEntity, T theResource) {
|
||||||
ArrayList<ResourceIndexedSearchParamDate> retVal = new ArrayList<ResourceIndexedSearchParamDate>();
|
ArrayList<ResourceIndexedSearchParamDate> retVal = new ArrayList<ResourceIndexedSearchParamDate>();
|
||||||
|
|
||||||
RuntimeResourceDefinition def = myCtx.getResourceDefinition(theResource);
|
RuntimeResourceDefinition def = myCtx.getResourceDefinition(theResource);
|
||||||
|
@ -840,7 +843,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nextEntity != null) {
|
if (nextEntity != null) {
|
||||||
nextEntity.setResource(theEntity, def.getName());
|
nextEntity.setResource(theEntity);
|
||||||
retVal.add(nextEntity);
|
retVal.add(nextEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -851,7 +854,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<ResourceIndexedSearchParamNumber> extractSearchParamNumber(X theEntity, T theResource) {
|
private ArrayList<ResourceIndexedSearchParamNumber> extractSearchParamNumber(ResourceTable theEntity, T theResource) {
|
||||||
ArrayList<ResourceIndexedSearchParamNumber> retVal = new ArrayList<ResourceIndexedSearchParamNumber>();
|
ArrayList<ResourceIndexedSearchParamNumber> retVal = new ArrayList<ResourceIndexedSearchParamNumber>();
|
||||||
|
|
||||||
RuntimeResourceDefinition def = myCtx.getResourceDefinition(theResource);
|
RuntimeResourceDefinition def = myCtx.getResourceDefinition(theResource);
|
||||||
|
@ -877,7 +880,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
|
||||||
if (nextObject instanceof QuantityDt) {
|
if (nextObject instanceof QuantityDt) {
|
||||||
QuantityDt nextValue = (QuantityDt) nextObject;
|
QuantityDt nextValue = (QuantityDt) nextObject;
|
||||||
ResourceIndexedSearchParamNumber nextEntity = new ResourceIndexedSearchParamNumber(resourceName, nextValue.getValue().getValue(), nextValue.getSystem().getValueAsString(), nextValue.getUnits().getValue());
|
ResourceIndexedSearchParamNumber nextEntity = new ResourceIndexedSearchParamNumber(resourceName, nextValue.getValue().getValue(), nextValue.getSystem().getValueAsString(), nextValue.getUnits().getValue());
|
||||||
nextEntity.setResource(theEntity, def.getName());
|
nextEntity.setResource(theEntity);
|
||||||
retVal.add(nextEntity);
|
retVal.add(nextEntity);
|
||||||
} else {
|
} else {
|
||||||
if (!multiType) {
|
if (!multiType) {
|
||||||
|
@ -894,7 +897,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ResourceIndexedSearchParamString> extractSearchParamStrings(X theEntity, T theResource) {
|
private List<ResourceIndexedSearchParamString> extractSearchParamStrings(ResourceTable theEntity, T theResource) {
|
||||||
ArrayList<ResourceIndexedSearchParamString> retVal = new ArrayList<ResourceIndexedSearchParamString>();
|
ArrayList<ResourceIndexedSearchParamString> retVal = new ArrayList<ResourceIndexedSearchParamString>();
|
||||||
|
|
||||||
RuntimeResourceDefinition def = myCtx.getResourceDefinition(theResource);
|
RuntimeResourceDefinition def = myCtx.getResourceDefinition(theResource);
|
||||||
|
@ -924,7 +927,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
|
||||||
if (nextObject instanceof IPrimitiveDatatype<?>) {
|
if (nextObject instanceof IPrimitiveDatatype<?>) {
|
||||||
IPrimitiveDatatype<?> nextValue = (IPrimitiveDatatype<?>) nextObject;
|
IPrimitiveDatatype<?> nextValue = (IPrimitiveDatatype<?>) nextObject;
|
||||||
ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(resourceName, normalizeString(nextValue.getValueAsString()), nextValue.getValueAsString());
|
ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(resourceName, normalizeString(nextValue.getValueAsString()), nextValue.getValueAsString());
|
||||||
nextEntity.setResource(theEntity, def.getName());
|
nextEntity.setResource(theEntity);
|
||||||
retVal.add(nextEntity);
|
retVal.add(nextEntity);
|
||||||
} else {
|
} else {
|
||||||
if (nextObject instanceof HumanNameDt) {
|
if (nextObject instanceof HumanNameDt) {
|
||||||
|
@ -937,7 +940,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(resourceName, normalizeString(nextName.getValueAsString()), nextName.getValueAsString());
|
ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(resourceName, normalizeString(nextName.getValueAsString()), nextName.getValueAsString());
|
||||||
nextEntity.setResource(theEntity, def.getName());
|
nextEntity.setResource(theEntity);
|
||||||
retVal.add(nextEntity);
|
retVal.add(nextEntity);
|
||||||
}
|
}
|
||||||
} else if (nextObject instanceof AddressDt) {
|
} else if (nextObject instanceof AddressDt) {
|
||||||
|
@ -953,14 +956,14 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(resourceName, normalizeString(nextName.getValueAsString()), nextName.getValueAsString());
|
ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(resourceName, normalizeString(nextName.getValueAsString()), nextName.getValueAsString());
|
||||||
nextEntity.setResource(theEntity, def.getName());
|
nextEntity.setResource(theEntity);
|
||||||
retVal.add(nextEntity);
|
retVal.add(nextEntity);
|
||||||
}
|
}
|
||||||
} else if (nextObject instanceof ContactDt) {
|
} else if (nextObject instanceof ContactDt) {
|
||||||
ContactDt nextContact = (ContactDt) nextObject;
|
ContactDt nextContact = (ContactDt) nextObject;
|
||||||
if (nextContact.getValue().isEmpty() == false) {
|
if (nextContact.getValue().isEmpty() == false) {
|
||||||
ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(resourceName, normalizeString(nextContact.getValue().getValueAsString()), nextContact.getValue().getValueAsString());
|
ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(resourceName, normalizeString(nextContact.getValue().getValueAsString()), nextContact.getValue().getValueAsString());
|
||||||
nextEntity.setResource(theEntity, def.getName());
|
nextEntity.setResource(theEntity);
|
||||||
retVal.add(nextEntity);
|
retVal.add(nextEntity);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -977,7 +980,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ResourceIndexedSearchParamToken> extractSearchParamTokens(X theEntity, T theResource) {
|
private List<ResourceIndexedSearchParamToken> extractSearchParamTokens(ResourceTable theEntity, T theResource) {
|
||||||
ArrayList<ResourceIndexedSearchParamToken> retVal = new ArrayList<ResourceIndexedSearchParamToken>();
|
ArrayList<ResourceIndexedSearchParamToken> retVal = new ArrayList<ResourceIndexedSearchParamToken>();
|
||||||
|
|
||||||
RuntimeResourceDefinition def = myCtx.getResourceDefinition(theResource);
|
RuntimeResourceDefinition def = myCtx.getResourceDefinition(theResource);
|
||||||
|
@ -1019,7 +1022,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
nextEntity = new ResourceIndexedSearchParamToken(nextSpDef.getName(), nextCoding.getSystem().getValueAsString(), nextCoding.getCode().getValue());
|
nextEntity = new ResourceIndexedSearchParamToken(nextSpDef.getName(), nextCoding.getSystem().getValueAsString(), nextCoding.getCode().getValue());
|
||||||
nextEntity.setResource(theEntity, def.getName());
|
nextEntity.setResource(theEntity);
|
||||||
retVal.add(nextEntity);
|
retVal.add(nextEntity);
|
||||||
}
|
}
|
||||||
nextEntity = null;
|
nextEntity = null;
|
||||||
|
@ -1031,7 +1034,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nextEntity != null) {
|
if (nextEntity != null) {
|
||||||
nextEntity.setResource(theEntity, def.getName());
|
nextEntity.setResource(theEntity);
|
||||||
retVal.add(nextEntity);
|
retVal.add(nextEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1067,43 +1070,38 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
|
||||||
return new String(out).toUpperCase();
|
return new String(out).toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateResourceIntoEntity(T theResource, X retVal) {
|
private void populateResourceIntoEntity(T theResource, ResourceTable theEntity) {
|
||||||
retVal.setResource(myCtx.newJsonParser().encodeResourceToString(theResource));
|
theEntity.setResource(myCtx.newJsonParser().encodeResourceToString(theResource));
|
||||||
retVal.setEncoding(EncodingEnum.JSON);
|
theEntity.setEncoding(EncodingEnum.JSON);
|
||||||
|
|
||||||
TagList tagList = (TagList) theResource.getResourceMetadata().get(ResourceMetadataKeyEnum.TAG_LIST);
|
TagList tagList = (TagList) theResource.getResourceMetadata().get(ResourceMetadataKeyEnum.TAG_LIST);
|
||||||
if (tagList != null) {
|
if (tagList != null) {
|
||||||
for (Tag next : tagList) {
|
for (Tag next : tagList) {
|
||||||
retVal.addTag(next.getTerm(), next.getLabel(), next.getScheme());
|
theEntity.addTag(next.getTerm(), next.getLabel(), next.getScheme());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private X readEntity(IdDt theId) {
|
private ResourceTable readEntity(IdDt theId) {
|
||||||
X entity = (X) myEntityManager.find(myTableType, theId.asLong());
|
ResourceTable entity = myEntityManager.find(ResourceTable.class, theId.asLong());
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
throw new ResourceNotFoundException(theId);
|
throw new ResourceNotFoundException(theId);
|
||||||
}
|
}
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
private X toEntity(T theResource) {
|
private ResourceTable toEntity(T theResource) {
|
||||||
X retVal;
|
ResourceTable retVal = new ResourceTable();
|
||||||
try {
|
|
||||||
retVal = myTableType.newInstance();
|
|
||||||
} catch (InstantiationException | IllegalAccessException e) {
|
|
||||||
throw new InternalErrorException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
populateResourceIntoEntity(theResource, retVal);
|
populateResourceIntoEntity(theResource, retVal);
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MethodOutcome toMethodOutcome(final X entity) {
|
private MethodOutcome toMethodOutcome(final ResourceTable entity) {
|
||||||
MethodOutcome outcome = new MethodOutcome();
|
MethodOutcome outcome = new MethodOutcome();
|
||||||
outcome.setId(entity.getId());
|
outcome.setId(new IdDt(entity.getId()));
|
||||||
outcome.setVersionId(entity.getVersion());
|
outcome.setVersionId(entity.getVersion());
|
||||||
return outcome;
|
return outcome;
|
||||||
}
|
}
|
||||||
|
@ -1139,7 +1137,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
|
||||||
String resourceText = theEntity.getResource();
|
String resourceText = theEntity.getResource();
|
||||||
IParser parser = theEntity.getEncoding().newParser(myCtx);
|
IParser parser = theEntity.getEncoding().newParser(myCtx);
|
||||||
T retVal = parser.parseResource(myResourceType, resourceText);
|
T retVal = parser.parseResource(myResourceType, resourceText);
|
||||||
retVal.setId(theEntity.getId());
|
retVal.setId(theEntity.getIdDt());
|
||||||
retVal.getResourceMetadata().put(ResourceMetadataKeyEnum.VERSION_ID, theEntity.getVersion());
|
retVal.getResourceMetadata().put(ResourceMetadataKeyEnum.VERSION_ID, theEntity.getVersion());
|
||||||
retVal.getResourceMetadata().put(ResourceMetadataKeyEnum.PUBLISHED, theEntity.getPublished());
|
retVal.getResourceMetadata().put(ResourceMetadataKeyEnum.PUBLISHED, theEntity.getPublished());
|
||||||
retVal.getResourceMetadata().put(ResourceMetadataKeyEnum.UPDATED, theEntity.getUpdated());
|
retVal.getResourceMetadata().put(ResourceMetadataKeyEnum.UPDATED, theEntity.getUpdated());
|
||||||
|
|
|
@ -4,7 +4,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import ca.uhn.fhir.jpa.entity.BaseResourceTable;
|
import ca.uhn.fhir.jpa.entity.ResourceTable;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.model.primitive.IdDt;
|
import ca.uhn.fhir.model.primitive.IdDt;
|
||||||
|
@ -35,8 +35,6 @@ public interface IFhirResourceDao<T extends IResource> {
|
||||||
|
|
||||||
Class<T> getResourceType();
|
Class<T> getResourceType();
|
||||||
|
|
||||||
Class<? extends BaseResourceTable<T>> getTableType();
|
|
||||||
|
|
||||||
Set<Long> searchForIds(String theParameterName, IQueryParameterType theValue);
|
Set<Long> searchForIds(String theParameterName, IQueryParameterType theValue);
|
||||||
|
|
||||||
Set<Long> searchForIds(Map<String, IQueryParameterType> theParams);
|
Set<Long> searchForIds(Map<String, IQueryParameterType> theParams);
|
||||||
|
|
|
@ -41,7 +41,7 @@ public abstract class BaseHasResource {
|
||||||
|
|
||||||
public abstract Collection<? extends BaseTag> getTags();
|
public abstract Collection<? extends BaseTag> getTags();
|
||||||
|
|
||||||
public abstract IdDt getId();
|
public abstract IdDt getIdDt();
|
||||||
|
|
||||||
public InstantDt getPublished() {
|
public InstantDt getPublished() {
|
||||||
return new InstantDt(myPublished);
|
return new InstantDt(myPublished);
|
||||||
|
|
|
@ -6,6 +6,8 @@ import javax.persistence.Column;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.MappedSuperclass;
|
import javax.persistence.MappedSuperclass;
|
||||||
|
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
|
@ -15,15 +17,22 @@ public abstract class BaseResourceIndexedSearchParam implements Serializable {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
@Column(name = "RES_ID")
|
@Column(name = "SP_ID")
|
||||||
private Long myId;
|
private Long myId;
|
||||||
|
|
||||||
@Column(name="SP_NAME", length=100)
|
@Column(name = "SP_NAME", length = 100, nullable=false)
|
||||||
private String myName;
|
private String myName;
|
||||||
|
|
||||||
@Column(name = "RES_TYPE",length=100,nullable=false)
|
@ManyToOne(optional = false)
|
||||||
|
@JoinColumn(name = "RES_ID", referencedColumnName="RES_ID")
|
||||||
|
private ResourceTable myResource;
|
||||||
|
|
||||||
|
@Column(name = "RES_TYPE", nullable=false)
|
||||||
private String myResourceType;
|
private String myResourceType;
|
||||||
|
|
||||||
|
@Column(name = "RES_ID", insertable = false, updatable = false)
|
||||||
|
private Long myResourcePid;
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return myName;
|
return myName;
|
||||||
}
|
}
|
||||||
|
@ -32,23 +41,13 @@ public abstract class BaseResourceIndexedSearchParam implements Serializable {
|
||||||
myName = theName;
|
myName = theName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract BaseResourceTable<?> getResource();
|
public ResourceTable getResource() {
|
||||||
|
return myResource;
|
||||||
protected abstract void setResource(BaseResourceTable<?> theResource);
|
|
||||||
|
|
||||||
public void setResource(BaseResourceTable<?> theResource, String theResourceType) {
|
|
||||||
setResource(theResource);
|
|
||||||
setResourceType(theResourceType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getResourceType() {
|
public void setResource(ResourceTable theResource) {
|
||||||
return myResourceType;
|
myResource = theResource;
|
||||||
|
myResourceType = theResource.getResourceType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResourceType(String theResourceType) {
|
|
||||||
myResourceType = theResourceType;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class ResourceHistoryTable extends BaseHasResource implements Serializabl
|
||||||
private Collection<ResourceHistoryTag> myTags;
|
private Collection<ResourceHistoryTag> myTags;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IdDt getId() {
|
public IdDt getIdDt() {
|
||||||
return new IdDt(myPk.getId());
|
return new IdDt(myPk.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class ResourceHistoryTablePk implements Serializable {
|
||||||
@Column(name="PID")
|
@Column(name="PID")
|
||||||
private Long myId;
|
private Long myId;
|
||||||
|
|
||||||
@Column(name="RES_TYPE", length=100, nullable=false)
|
@Column(name="RES_TYPE", length=30, nullable=false)
|
||||||
private String myResourceType;
|
private String myResourceType;
|
||||||
|
|
||||||
@Column(name="VERSION")
|
@Column(name="VERSION")
|
||||||
|
|
|
@ -26,22 +26,13 @@ public class ResourceIndexedSearchParamDate extends BaseResourceIndexedSearchPar
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
public Date myValueLow;
|
public Date myValueLow;
|
||||||
|
|
||||||
@ManyToOne(optional = false)
|
|
||||||
@JoinColumn(name = "RESOURCE_PID", nullable = false, foreignKey=@ForeignKey(name="FK_ISD_RESOURCE"))
|
|
||||||
private BaseResourceTable<?> myResource;
|
|
||||||
|
|
||||||
@Column(name = "RESOURCE_PID", insertable = false, updatable = false)
|
|
||||||
private Long myResourcePid;
|
|
||||||
|
|
||||||
public ResourceIndexedSearchParamDate(String theName, Date theLow, Date theHigh) {
|
public ResourceIndexedSearchParamDate(String theName, Date theLow, Date theHigh) {
|
||||||
setName(theName);
|
setName(theName);
|
||||||
setValueLow(theLow);
|
setValueLow(theLow);
|
||||||
setValueHigh(theHigh);
|
setValueHigh(theHigh);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseResourceTable<?> getResource() {
|
|
||||||
return myResource;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getValueHigh() {
|
public Date getValueHigh() {
|
||||||
return myValueHigh;
|
return myValueHigh;
|
||||||
|
@ -59,8 +50,6 @@ public class ResourceIndexedSearchParamDate extends BaseResourceIndexedSearchPar
|
||||||
myValueLow = theValueLow;
|
myValueLow = theValueLow;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setResource(BaseResourceTable<?> theResource) {
|
|
||||||
myResource = theResource;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,7 @@ import java.math.BigDecimal;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.ForeignKey;
|
|
||||||
import javax.persistence.Index;
|
import javax.persistence.Index;
|
||||||
import javax.persistence.JoinColumn;
|
|
||||||
import javax.persistence.ManyToOne;
|
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
|
@ -25,13 +22,6 @@ public class ResourceIndexedSearchParamNumber extends BaseResourceIndexedSearchP
|
||||||
@Column(name = "SP_VALUE", nullable = true)
|
@Column(name = "SP_VALUE", nullable = true)
|
||||||
public BigDecimal myValue;
|
public BigDecimal myValue;
|
||||||
|
|
||||||
@ManyToOne(optional = false)
|
|
||||||
@JoinColumn(name = "RESOURCE_PID", nullable = false, foreignKey=@ForeignKey(name="FK_ISN_RESOURCE"))
|
|
||||||
private BaseResourceTable<?> myResource;
|
|
||||||
|
|
||||||
@Column(name = "RESOURCE_PID", insertable = false, updatable = false)
|
|
||||||
private Long myResourcePid;
|
|
||||||
|
|
||||||
public ResourceIndexedSearchParamNumber(String theParamName, BigDecimal theValue, String theSystem, String theUnits) {
|
public ResourceIndexedSearchParamNumber(String theParamName, BigDecimal theValue, String theSystem, String theUnits) {
|
||||||
setName(theParamName);
|
setName(theParamName);
|
||||||
setSystem(theSystem);
|
setSystem(theSystem);
|
||||||
|
@ -39,10 +29,6 @@ public class ResourceIndexedSearchParamNumber extends BaseResourceIndexedSearchP
|
||||||
setUnits(theUnits);
|
setUnits(theUnits);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseResourceTable<?> getResource() {
|
|
||||||
return myResource;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSystem() {
|
public String getSystem() {
|
||||||
return mySystem;
|
return mySystem;
|
||||||
}
|
}
|
||||||
|
@ -55,9 +41,6 @@ public class ResourceIndexedSearchParamNumber extends BaseResourceIndexedSearchP
|
||||||
return myValue;
|
return myValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setResource(BaseResourceTable<?> theResource) {
|
|
||||||
myResource = theResource;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSystem(String theSystem) {
|
public void setSystem(String theSystem) {
|
||||||
mySystem = theSystem;
|
mySystem = theSystem;
|
||||||
|
|
|
@ -2,11 +2,7 @@ package ca.uhn.fhir.jpa.entity;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
|
||||||
import javax.persistence.ForeignKey;
|
|
||||||
import javax.persistence.Index;
|
import javax.persistence.Index;
|
||||||
import javax.persistence.JoinColumn;
|
|
||||||
import javax.persistence.ManyToOne;
|
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
|
@ -15,13 +11,6 @@ public class ResourceIndexedSearchParamString extends BaseResourceIndexedSearchP
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@ManyToOne(optional = false, cascade = {}, fetch = FetchType.LAZY)
|
|
||||||
@JoinColumn(name = "RESOURCE_PID", nullable = false, foreignKey=@ForeignKey(name="FK_ISS_RESOURCE"))
|
|
||||||
private BaseResourceTable<?> myResource;
|
|
||||||
|
|
||||||
@Column(name = "RESOURCE_PID", insertable=false, updatable=false)
|
|
||||||
private Long myResourcePid;
|
|
||||||
|
|
||||||
@Column(name = "SP_VALUE_NORMALIZED", length = 100, nullable = true)
|
@Column(name = "SP_VALUE_NORMALIZED", length = 100, nullable = true)
|
||||||
public String myValueNormalized;
|
public String myValueNormalized;
|
||||||
|
|
||||||
|
@ -37,15 +26,6 @@ public class ResourceIndexedSearchParamString extends BaseResourceIndexedSearchP
|
||||||
setValueExact(theValueExact);
|
setValueExact(theValueExact);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseResourceTable<?> getResource() {
|
|
||||||
return myResource;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected void setResource(BaseResourceTable<?> theResource) {
|
|
||||||
myResource = theResource;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValueNormalized() {
|
public String getValueNormalized() {
|
||||||
return myValueNormalized;
|
return myValueNormalized;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,7 @@ package ca.uhn.fhir.jpa.entity;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.ForeignKey;
|
|
||||||
import javax.persistence.Index;
|
import javax.persistence.Index;
|
||||||
import javax.persistence.JoinColumn;
|
|
||||||
import javax.persistence.ManyToOne;
|
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
|
@ -14,13 +11,6 @@ public class ResourceIndexedSearchParamToken extends BaseResourceIndexedSearchPa
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@ManyToOne(optional = false)
|
|
||||||
@JoinColumn(name = "RESOURCE_PID", nullable = false, foreignKey=@ForeignKey(name="FK_IST_RESOURCE"))
|
|
||||||
private BaseResourceTable<?> myResource;
|
|
||||||
|
|
||||||
@Column(name = "RESOURCE_PID", insertable=false, updatable=false)
|
|
||||||
private Long myResourcePid;
|
|
||||||
|
|
||||||
@Column(name = "SP_VALUE", nullable = true, length = 100)
|
@Column(name = "SP_VALUE", nullable = true, length = 100)
|
||||||
public String myValue;
|
public String myValue;
|
||||||
|
|
||||||
|
@ -44,18 +34,10 @@ public class ResourceIndexedSearchParamToken extends BaseResourceIndexedSearchPa
|
||||||
setValue(theValue);
|
setValue(theValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseResourceTable<?> getResource() {
|
|
||||||
return myResource;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return myValue;
|
return myValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setResource(BaseResourceTable<?> theResource) {
|
|
||||||
myResource = theResource;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(String theValue) {
|
public void setValue(String theValue) {
|
||||||
myValue = theValue;
|
myValue = theValue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import java.io.Serializable;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.ForeignKey;
|
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
@ -28,17 +27,17 @@ public class ResourceLink implements Serializable {
|
||||||
private String mySourcePath;
|
private String mySourcePath;
|
||||||
|
|
||||||
@ManyToOne(optional = false)
|
@ManyToOne(optional = false)
|
||||||
@JoinColumn(name = "SRC_RESOURCE_PID", nullable = false, foreignKey = @ForeignKey(name = "FK_RES_LINK_SRC_RES"))
|
@JoinColumn(name = "SRC_RESOURCE_ID", referencedColumnName="RES_ID")
|
||||||
private BaseResourceTable<?> mySourceResource;
|
private ResourceTable mySourceResource;
|
||||||
|
|
||||||
@Column(name = "SRC_RESOURCE_PID", insertable = false, updatable = false)
|
@Column(name = "SRC_RESOURCE_ID", insertable = false, updatable = false)
|
||||||
private Long mySourceResourcePid;
|
private Long mySourceResourcePid;
|
||||||
|
|
||||||
@ManyToOne(optional = false)
|
@ManyToOne(optional = false)
|
||||||
@JoinColumn(name = "TARGET_RESOURCE_PID", nullable = false, foreignKey = @ForeignKey(name = "FK_RES_LINK_TARGET_RES"))
|
@JoinColumn(name = "TARGET_RESOURCE_ID", referencedColumnName="RES_ID")
|
||||||
private BaseResourceTable<?> myTargetResource;
|
private ResourceTable myTargetResource;
|
||||||
|
|
||||||
@Column(name = "TARGET_RESOURCE_PID", insertable = false, updatable = false)
|
@Column(name = "TARGET_RESOURCE_ID", insertable = false, updatable = false)
|
||||||
private Long myTargetResourcePid;
|
private Long myTargetResourcePid;
|
||||||
|
|
||||||
public ResourceLink() {
|
public ResourceLink() {
|
||||||
|
@ -50,14 +49,14 @@ public class ResourceLink implements Serializable {
|
||||||
StringBuilder b = new StringBuilder();
|
StringBuilder b = new StringBuilder();
|
||||||
b.append("ResourceLink[");
|
b.append("ResourceLink[");
|
||||||
b.append("path=").append(mySourcePath);
|
b.append("path=").append(mySourcePath);
|
||||||
b.append(", src=").append(mySourceResource.getIdAsLong());
|
b.append(", src=").append(mySourceResource.getId());
|
||||||
b.append(", target=").append(myTargetResource.getIdAsLong());
|
b.append(", target=").append(myTargetResource.getId());
|
||||||
|
|
||||||
b.append("]");
|
b.append("]");
|
||||||
return b.toString();
|
return b.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceLink(String theSourcePath, BaseResourceTable<?> theSourceResource, BaseResourceTable<?> theTargetResource) {
|
public ResourceLink(String theSourcePath, ResourceTable theSourceResource, ResourceTable theTargetResource) {
|
||||||
super();
|
super();
|
||||||
mySourcePath = theSourcePath;
|
mySourcePath = theSourcePath;
|
||||||
mySourceResource = theSourceResource;
|
mySourceResource = theSourceResource;
|
||||||
|
@ -68,7 +67,7 @@ public class ResourceLink implements Serializable {
|
||||||
return mySourcePath;
|
return mySourcePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseResourceTable<?> getSourceResource() {
|
public ResourceTable getSourceResource() {
|
||||||
return mySourceResource;
|
return mySourceResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +75,7 @@ public class ResourceLink implements Serializable {
|
||||||
return mySourceResourcePid;
|
return mySourceResourcePid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseResourceTable<?> getTargetResource() {
|
public ResourceTable getTargetResource() {
|
||||||
return myTargetResource;
|
return myTargetResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +87,7 @@ public class ResourceLink implements Serializable {
|
||||||
mySourcePath = theSourcePath;
|
mySourcePath = theSourcePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSourceResource(BaseResourceTable<?> theSourceResource) {
|
public void setSourceResource(ResourceTable theSourceResource) {
|
||||||
mySourceResource = theSourceResource;
|
mySourceResource = theSourceResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +95,7 @@ public class ResourceLink implements Serializable {
|
||||||
mySourceResourcePid = theSourceResourcePid;
|
mySourceResourcePid = theSourceResourcePid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTargetResource(BaseResourceTable<?> theTargetResource) {
|
public void setTargetResource(ResourceTable theTargetResource) {
|
||||||
Validate.notNull(theTargetResource);
|
Validate.notNull(theTargetResource);
|
||||||
myTargetResource = theTargetResource;
|
myTargetResource = theTargetResource;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package ca.uhn.fhir.jpa.entity;
|
package ca.uhn.fhir.jpa.entity;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.DiscriminatorColumn;
|
|
||||||
import javax.persistence.DiscriminatorType;
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
|
@ -19,14 +18,13 @@ import javax.persistence.Table;
|
||||||
import javax.persistence.Version;
|
import javax.persistence.Version;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
|
||||||
import ca.uhn.fhir.model.primitive.IdDt;
|
import ca.uhn.fhir.model.primitive.IdDt;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "BASE_RES", uniqueConstraints = {})
|
@Table(name = "RESOURCE", uniqueConstraints = {})
|
||||||
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
|
@Inheritance(strategy = InheritanceType.JOINED)
|
||||||
@DiscriminatorColumn(name = "SVCVER_TYPE", length = 20, discriminatorType = DiscriminatorType.STRING)
|
public class ResourceTable extends BaseHasResource implements Serializable {
|
||||||
public abstract class BaseResourceTable<T extends IResource> extends BaseHasResource {
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Column(name = "SP_HAS_LINKS")
|
@Column(name = "SP_HAS_LINKS")
|
||||||
private boolean myHasLinks;
|
private boolean myHasLinks;
|
||||||
|
@ -66,6 +64,9 @@ public abstract class BaseResourceTable<T extends IResource> extends BaseHasReso
|
||||||
@OneToMany(mappedBy = "mySourceResource", cascade = {}, fetch = FetchType.LAZY, orphanRemoval = false)
|
@OneToMany(mappedBy = "mySourceResource", cascade = {}, fetch = FetchType.LAZY, orphanRemoval = false)
|
||||||
private Collection<ResourceLink> myResourceLinks;
|
private Collection<ResourceLink> myResourceLinks;
|
||||||
|
|
||||||
|
@Column(name = "RES_TYPE", length = 30)
|
||||||
|
private String myResourceType;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "myResource", cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true)
|
@OneToMany(mappedBy = "myResource", cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true)
|
||||||
private Collection<ResourceTag> myTags;
|
private Collection<ResourceTag> myTags;
|
||||||
|
|
||||||
|
@ -82,11 +83,11 @@ public abstract class BaseResourceTable<T extends IResource> extends BaseHasReso
|
||||||
getTags().add(new ResourceTag(this, theTerm, theLabel, theScheme));
|
getTags().add(new ResourceTag(this, theTerm, theLabel, theScheme));
|
||||||
}
|
}
|
||||||
|
|
||||||
public IdDt getId() {
|
public IdDt getIdDt() {
|
||||||
return new IdDt(myId);
|
return new IdDt(myId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getIdAsLong() {
|
public Long getId() {
|
||||||
return myId;
|
return myId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +126,9 @@ public abstract class BaseResourceTable<T extends IResource> extends BaseHasReso
|
||||||
return myResourceLinks;
|
return myResourceLinks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Class<T> getResourceType();
|
public String getResourceType() {
|
||||||
|
return myResourceType;
|
||||||
|
}
|
||||||
|
|
||||||
public Collection<ResourceTag> getTags() {
|
public Collection<ResourceTag> getTags() {
|
||||||
if (myTags == null) {
|
if (myTags == null) {
|
||||||
|
@ -162,8 +165,8 @@ public abstract class BaseResourceTable<T extends IResource> extends BaseHasReso
|
||||||
myHasLinks = theHasLinks;
|
myHasLinks = theHasLinks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(IdDt theId) {
|
public void setId(Long theId) {
|
||||||
myId = theId.asLong();
|
myId = theId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParamsDate(Collection<ResourceIndexedSearchParamDate> theParamsDate) {
|
public void setParamsDate(Collection<ResourceIndexedSearchParamDate> theParamsDate) {
|
||||||
|
@ -194,6 +197,10 @@ public abstract class BaseResourceTable<T extends IResource> extends BaseHasReso
|
||||||
myParamsTokenPopulated = theParamsTokenPopulated;
|
myParamsTokenPopulated = theParamsTokenPopulated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setResourceType(String theResourceType) {
|
||||||
|
myResourceType = theResourceType;
|
||||||
|
}
|
||||||
|
|
||||||
public void setVersion(IdDt theVersion) {
|
public void setVersion(IdDt theVersion) {
|
||||||
myVersion = theVersion.asLong();
|
myVersion = theVersion.asLong();
|
||||||
}
|
}
|
||||||
|
@ -203,7 +210,7 @@ public abstract class BaseResourceTable<T extends IResource> extends BaseHasReso
|
||||||
|
|
||||||
ResourceHistoryTablePk pk = new ResourceHistoryTablePk();
|
ResourceHistoryTablePk pk = new ResourceHistoryTablePk();
|
||||||
pk.setId(myId);
|
pk.setId(myId);
|
||||||
pk.setResourceType(theCtx.getResourceDefinition(getResourceType()).getName());
|
pk.setResourceType(myResourceType);
|
||||||
pk.setVersion(myVersion);
|
pk.setVersion(myVersion);
|
||||||
retVal.setPk(pk);
|
retVal.setPk(pk);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package ca.uhn.fhir.jpa.entity;
|
package ca.uhn.fhir.jpa.entity;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.ForeignKey;
|
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
@ -20,24 +19,24 @@ public class ResourceTag extends BaseTag {
|
||||||
private Long myId;
|
private Long myId;
|
||||||
|
|
||||||
@ManyToOne(cascade= {})
|
@ManyToOne(cascade= {})
|
||||||
@JoinColumn(name = "RESOURCE_PID", nullable=false, foreignKey=@ForeignKey(name="FK_RESTAG_RESOURCE"))
|
@JoinColumn(name = "RES_ID", referencedColumnName="RES_ID")
|
||||||
private BaseResourceTable<?> myResource;
|
private ResourceTable myResource;
|
||||||
|
|
||||||
public ResourceTag() {
|
public ResourceTag() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceTag(BaseResourceTable<?> theResource, String theTerm, String theLabel, String theScheme) {
|
public ResourceTag(ResourceTable theResource, String theTerm, String theLabel, String theScheme) {
|
||||||
myResource = theResource;
|
myResource = theResource;
|
||||||
setTerm(theTerm);
|
setTerm(theTerm);
|
||||||
setLabel(theLabel);
|
setLabel(theLabel);
|
||||||
setScheme(theScheme);
|
setScheme(theScheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseResourceTable<?> getResource() {
|
public ResourceTable getResource() {
|
||||||
return myResource;
|
return myResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResource(BaseResourceTable<?> theResource) {
|
public void setResource(ResourceTable theResource) {
|
||||||
myResource = theResource;
|
myResource = theResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,12 @@ public class CustomNamingStrategy extends ImprovedNamingStrategy {
|
||||||
propertyName));
|
propertyName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String foreignKeyColumnName(String thePropertyName, String thePropertyEntityName, String thePropertyTableName, String theReferencedColumnName) {
|
||||||
|
String foreignKeyColumnName = super.foreignKeyColumnName(thePropertyName, thePropertyEntityName, thePropertyTableName, theReferencedColumnName);
|
||||||
|
return foreignKeyColumnName;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String logicalCollectionTableName(final String tableName,
|
public String logicalCollectionTableName(final String tableName,
|
||||||
final String ownerEntityTable, final String associatedEntityTable,
|
final String ownerEntityTable, final String associatedEntityTable,
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
package ca.uhn.fhir.jpa.testentity;
|
|
||||||
|
|
||||||
import javax.persistence.DiscriminatorValue;
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.jpa.entity.BaseResourceTable;
|
|
||||||
import ca.uhn.fhir.model.dstu.resource.Device;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@DiscriminatorValue("DEVICE")
|
|
||||||
public class DeviceResourceTable extends BaseResourceTable<Device> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Device> getResourceType() {
|
|
||||||
return Device.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
package ca.uhn.fhir.jpa.testentity;
|
|
||||||
|
|
||||||
import javax.persistence.DiscriminatorValue;
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.jpa.entity.BaseResourceTable;
|
|
||||||
import ca.uhn.fhir.model.dstu.resource.DiagnosticReport;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@DiscriminatorValue("DIAGNOSTICREPORT")
|
|
||||||
public class DiagnosticReportResourceTable extends BaseResourceTable<DiagnosticReport> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<DiagnosticReport> getResourceType() {
|
|
||||||
return DiagnosticReport.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
package ca.uhn.fhir.jpa.testentity;
|
|
||||||
|
|
||||||
import javax.persistence.DiscriminatorValue;
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.jpa.entity.BaseResourceTable;
|
|
||||||
import ca.uhn.fhir.model.dstu.resource.Location;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@DiscriminatorValue("LOCATION")
|
|
||||||
public class LocationResourceTable extends BaseResourceTable<Location> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Location> getResourceType() {
|
|
||||||
return Location.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
package ca.uhn.fhir.jpa.testentity;
|
|
||||||
|
|
||||||
import javax.persistence.DiscriminatorValue;
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.jpa.entity.BaseResourceTable;
|
|
||||||
import ca.uhn.fhir.model.dstu.resource.Observation;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@DiscriminatorValue("OBSERVATION")
|
|
||||||
public class ObservationResourceTable extends BaseResourceTable<Observation> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Observation> getResourceType() {
|
|
||||||
return Observation.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
package ca.uhn.fhir.jpa.testentity;
|
|
||||||
|
|
||||||
import javax.persistence.DiscriminatorValue;
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.jpa.entity.BaseResourceTable;
|
|
||||||
import ca.uhn.fhir.model.dstu.resource.Organization;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@DiscriminatorValue("ORGANIZATION")
|
|
||||||
public class OrganizationResourceTable extends BaseResourceTable<Organization> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Organization> getResourceType() {
|
|
||||||
return Organization.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
package ca.uhn.fhir.jpa.testentity;
|
|
||||||
|
|
||||||
import javax.persistence.DiscriminatorValue;
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.jpa.entity.BaseResourceTable;
|
|
||||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@DiscriminatorValue("PATIENT")
|
|
||||||
public class PatientResourceTable extends BaseResourceTable<Patient> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Patient> getResourceType() {
|
|
||||||
return Patient.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
package ca.uhn.fhir.jpa.testentity;
|
|
||||||
|
|
||||||
import javax.persistence.DiscriminatorValue;
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.jpa.entity.BaseResourceTable;
|
|
||||||
import ca.uhn.fhir.model.dstu.resource.Questionnaire;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@DiscriminatorValue("QUESTIONNAIRE")
|
|
||||||
public class QuestionnaireResourceTable extends BaseResourceTable<Questionnaire> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<Questionnaire> getResourceType() {
|
|
||||||
return Questionnaire.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -8,15 +8,7 @@
|
||||||
<provider>org.hibernate.ejb.HibernatePersistence</provider>
|
<provider>org.hibernate.ejb.HibernatePersistence</provider>
|
||||||
<!-- <class>ca.uhn.fhir.jpa.entity.PatientResourceTable</class> -->
|
<!-- <class>ca.uhn.fhir.jpa.entity.PatientResourceTable</class> -->
|
||||||
|
|
||||||
<class>ca.uhn.fhir.jpa.testentity.DeviceResourceTable</class>
|
<class>ca.uhn.fhir.jpa.entity.ResourceTable</class>
|
||||||
<class>ca.uhn.fhir.jpa.testentity.DiagnosticReportResourceTable</class>
|
|
||||||
<class>ca.uhn.fhir.jpa.testentity.LocationResourceTable</class>
|
|
||||||
<class>ca.uhn.fhir.jpa.testentity.ObservationResourceTable</class>
|
|
||||||
<class>ca.uhn.fhir.jpa.testentity.OrganizationResourceTable</class>
|
|
||||||
<class>ca.uhn.fhir.jpa.testentity.PatientResourceTable</class>
|
|
||||||
<class>ca.uhn.fhir.jpa.testentity.QuestionnaireResourceTable</class>
|
|
||||||
<class>ca.uhn.fhir.jpa.testentity.QuestionnaireResourceTable</class>
|
|
||||||
|
|
||||||
<class>ca.uhn.fhir.jpa.entity.ResourceHistoryTable</class>
|
<class>ca.uhn.fhir.jpa.entity.ResourceHistoryTable</class>
|
||||||
<class>ca.uhn.fhir.jpa.entity.ResourceHistoryTag</class>
|
<class>ca.uhn.fhir.jpa.entity.ResourceHistoryTag</class>
|
||||||
<class>ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamDate</class>
|
<class>ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamDate</class>
|
||||||
|
|
|
@ -13,23 +13,26 @@
|
||||||
<context:annotation-config />
|
<context:annotation-config />
|
||||||
<context:mbean-server />
|
<context:mbean-server />
|
||||||
|
|
||||||
<bean id="myPatientDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
|
||||||
<property name="tableType" value="ca.uhn.fhir.jpa.testentity.PatientResourceTable"/>
|
|
||||||
</bean>
|
|
||||||
<bean id="myObservationDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
|
||||||
<property name="tableType" value="ca.uhn.fhir.jpa.testentity.ObservationResourceTable"/>
|
|
||||||
</bean>
|
|
||||||
<bean id="myDiagnosticReportDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
<bean id="myDiagnosticReportDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
||||||
<property name="tableType" value="ca.uhn.fhir.jpa.testentity.DiagnosticReportResourceTable"/>
|
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.DiagnosticReport"/>
|
||||||
</bean>
|
</bean>
|
||||||
<bean id="myDeviceDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
<bean id="myDeviceDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
||||||
<property name="tableType" value="ca.uhn.fhir.jpa.testentity.DeviceResourceTable"/>
|
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Device"/>
|
||||||
</bean>
|
</bean>
|
||||||
<bean id="myLocationDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
<bean id="myPatientDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
||||||
<property name="tableType" value="ca.uhn.fhir.jpa.testentity.LocationResourceTable"/>
|
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Patient"/>
|
||||||
|
</bean>
|
||||||
|
<bean id="myObservationDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
||||||
|
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Observation"/>
|
||||||
</bean>
|
</bean>
|
||||||
<bean id="myOrganizationDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
<bean id="myOrganizationDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
||||||
<property name="tableType" value="ca.uhn.fhir.jpa.testentity.OrganizationResourceTable"/>
|
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Organization"/>
|
||||||
|
</bean>
|
||||||
|
<bean id="myLocationDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
||||||
|
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Location"/>
|
||||||
|
</bean>
|
||||||
|
<bean id="myQuestionnaireDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
||||||
|
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Questionnaire"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="myPersistenceDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" lazy-init="true">
|
<bean id="myPersistenceDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" lazy-init="true">
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry excluding="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/>
|
<classpathentry excluding="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/>
|
||||||
<classpathentry kind="src" path="target/generated-sources/tinder"/>
|
<classpathentry kind="src" path="target/generated-sources/tinder"/>
|
||||||
<classpathentry including="**/*.java" kind="src" path="src/main/java"/>
|
|
||||||
<classpathentry excluding="**/*.java" kind="src" path="src/main/resources"/>
|
|
||||||
<classpathentry kind="src" path="src/test/java"/>
|
<classpathentry kind="src" path="src/test/java"/>
|
||||||
<classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.1/activation-1.1.jar" sourcepath="M2_REPO/javax/activation/activation/1.1/activation-1.1-sources.jar"/>
|
<classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.1/activation-1.1.jar" sourcepath="M2_REPO/javax/activation/activation/1.1/activation-1.1-sources.jar"/>
|
||||||
<classpathentry kind="var" path="M2_REPO/javax/json/javax.json-api/1.0/javax.json-api-1.0.jar" sourcepath="M2_REPO/javax/json/javax.json-api/1.0/javax.json-api-1.0-sources.jar"/>
|
<classpathentry kind="var" path="M2_REPO/javax/json/javax.json-api/1.0/javax.json-api-1.0.jar" sourcepath="M2_REPO/javax/json/javax.json-api/1.0/javax.json-api-1.0-sources.jar"/>
|
||||||
|
|
|
@ -20,6 +20,11 @@
|
||||||
<artifactId>hapi-fhir-jpaserver-base</artifactId>
|
<artifactId>hapi-fhir-jpaserver-base</artifactId>
|
||||||
<version>0.4-SNAPSHOT</version>
|
<version>0.4-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.thymeleaf</groupId>
|
||||||
|
<artifactId>thymeleaf</artifactId>
|
||||||
|
<version>2.1.2.RELEASE</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
|
@ -107,6 +112,63 @@
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>de.juplo</groupId>
|
||||||
|
<artifactId>hibernate4-maven-plugin</artifactId>
|
||||||
|
<version>1.0.2</version>
|
||||||
|
<configuration>
|
||||||
|
<force>true</force>
|
||||||
|
<target>SCRIPT</target>
|
||||||
|
<skip>false</skip>
|
||||||
|
<scanTestClasses>true</scanTestClasses>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>o10g</id>
|
||||||
|
<goals>
|
||||||
|
<goal>export</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>test</phase>
|
||||||
|
<configuration>
|
||||||
|
<hibernateDialect>org.hibernate.dialect.Oracle10gDialect</hibernateDialect>
|
||||||
|
<outputFile>${project.build.directory}/schema_oracle_10g.sql</outputFile>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>derby</id>
|
||||||
|
<goals>
|
||||||
|
<goal>export</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>test</phase>
|
||||||
|
<configuration>
|
||||||
|
<hibernateDialect>org.hibernate.dialect.DerbyTenSevenDialect</hibernateDialect>
|
||||||
|
<outputFile>${project.build.directory}/schema_derby.sql</outputFile>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>hsql</id>
|
||||||
|
<goals>
|
||||||
|
<goal>export</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>test</phase>
|
||||||
|
<configuration>
|
||||||
|
<hibernateDialect>org.hibernate.dialect.HSQLDialect</hibernateDialect>
|
||||||
|
<outputFile>${project.build.directory}/schema_hsql.sql</outputFile>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>mysql5</id>
|
||||||
|
<goals>
|
||||||
|
<goal>export</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>test</phase>
|
||||||
|
<configuration>
|
||||||
|
<hibernateDialect>org.hibernate.dialect.MySQL5Dialect</hibernateDialect>
|
||||||
|
<outputFile>${project.build.directory}/schema_mysql_5.sql</outputFile>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-deploy-plugin</artifactId>
|
<artifactId>maven-deploy-plugin</artifactId>
|
||||||
|
|
|
@ -14,19 +14,19 @@
|
||||||
<context:mbean-server />
|
<context:mbean-server />
|
||||||
|
|
||||||
<bean id="myPatientDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
<bean id="myPatientDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
||||||
<property name="tableType" value="ca.uhn.test.jpasrv.PatientResourceTable"/>
|
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Patient"/>
|
||||||
</bean>
|
</bean>
|
||||||
<bean id="myObservationDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
<bean id="myObservationDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
||||||
<property name="tableType" value="ca.uhn.test.jpasrv.ObservationResourceTable"/>
|
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Observation"/>
|
||||||
</bean>
|
</bean>
|
||||||
<bean id="myOrganizationDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
<bean id="myOrganizationDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
||||||
<property name="tableType" value="ca.uhn.test.jpasrv.OrganizationResourceTable"/>
|
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Organization"/>
|
||||||
</bean>
|
</bean>
|
||||||
<bean id="myLocationDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
<bean id="myLocationDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
||||||
<property name="tableType" value="ca.uhn.test.jpasrv.LocationResourceTable"/>
|
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Location"/>
|
||||||
</bean>
|
</bean>
|
||||||
<bean id="myQuestionnaireDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
<bean id="myQuestionnaireDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
||||||
<property name="tableType" value="ca.uhn.test.jpasrv.QuestionnaireResourceTable"/>
|
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Questionnaire"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="myPersistenceDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" lazy-init="true">
|
<bean id="myPersistenceDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" lazy-init="true">
|
||||||
|
|
|
@ -7,10 +7,6 @@
|
||||||
<persistence-unit name="FHIR_UT" transaction-type="RESOURCE_LOCAL">
|
<persistence-unit name="FHIR_UT" transaction-type="RESOURCE_LOCAL">
|
||||||
<provider>org.hibernate.ejb.HibernatePersistence</provider>
|
<provider>org.hibernate.ejb.HibernatePersistence</provider>
|
||||||
<class>ca.uhn.test.jpasrv.PatientResourceTable</class>
|
<class>ca.uhn.test.jpasrv.PatientResourceTable</class>
|
||||||
<class>ca.uhn.test.jpasrv.LocationResourceTable</class>
|
|
||||||
<class>ca.uhn.test.jpasrv.ObservationResourceTable</class>
|
|
||||||
<class>ca.uhn.test.jpasrv.OrganizationResourceTable</class>
|
|
||||||
<class>ca.uhn.test.jpasrv.QuestionnaireResourceTable</class>
|
|
||||||
<class>ca.uhn.fhir.jpa.entity.ResourceHistoryTable</class>
|
<class>ca.uhn.fhir.jpa.entity.ResourceHistoryTable</class>
|
||||||
<class>ca.uhn.fhir.jpa.entity.ResourceHistoryTag</class>
|
<class>ca.uhn.fhir.jpa.entity.ResourceHistoryTag</class>
|
||||||
<class>ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamDate</class>
|
<class>ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamDate</class>
|
||||||
|
@ -18,6 +14,7 @@
|
||||||
<class>ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamString</class>
|
<class>ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamString</class>
|
||||||
<class>ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamToken</class>
|
<class>ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamToken</class>
|
||||||
<class>ca.uhn.fhir.jpa.entity.ResourceLink</class>
|
<class>ca.uhn.fhir.jpa.entity.ResourceLink</class>
|
||||||
|
<class>ca.uhn.fhir.jpa.entity.ResourceTable</class>
|
||||||
<class>ca.uhn.fhir.jpa.entity.ResourceTag</class>
|
<class>ca.uhn.fhir.jpa.entity.ResourceTag</class>
|
||||||
|
|
||||||
<exclude-unlisted-classes>true</exclude-unlisted-classes>
|
<exclude-unlisted-classes>true</exclude-unlisted-classes>
|
||||||
|
|
|
@ -69,9 +69,9 @@ public class TinderJpaRestServerMojo extends AbstractMojo {
|
||||||
gen.setTemplate("/vm/jpa_resource_provider.vm");
|
gen.setTemplate("/vm/jpa_resource_provider.vm");
|
||||||
gen.writeAll(directoryBase, packageBase);
|
gen.writeAll(directoryBase, packageBase);
|
||||||
|
|
||||||
gen.setFilenameSuffix("ResourceTable");
|
// gen.setFilenameSuffix("ResourceTable");
|
||||||
gen.setTemplate("/vm/jpa_resource_table.vm");
|
// gen.setTemplate("/vm/jpa_resource_table.vm");
|
||||||
gen.writeAll(directoryBase, packageBase);
|
// gen.writeAll(directoryBase, packageBase);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new MojoFailureException("Failed to generate server",e);
|
throw new MojoFailureException("Failed to generate server",e);
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
|
|
||||||
package ${packageBase};
|
|
||||||
|
|
||||||
import javax.persistence.DiscriminatorValue;
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.jpa.entity.BaseResourceTable;
|
|
||||||
import ca.uhn.fhir.model.dstu.resource.*;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@DiscriminatorValue("${className}")
|
|
||||||
public class ${className}ResourceTable extends BaseResourceTable<${className}> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<${className}> getResourceType() {
|
|
||||||
return ${className}.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -33,6 +33,17 @@
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
If you are using HAPI narrative generation, you will need to include Thymeleaf
|
||||||
|
as well. Otherwise the following can be omitted.
|
||||||
|
-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.thymeleaf</groupId>
|
||||||
|
<artifactId>thymeleaf</artifactId>
|
||||||
|
<version>2.1.2.RELEASE</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
Loading…
Reference in New Issue