Work on multitenancy
This commit is contained in:
parent
97289b3a1f
commit
b2d2346228
|
@ -58,7 +58,8 @@ public enum VersionEnum {
|
|||
V4_0_0,
|
||||
V4_0_3,
|
||||
V4_1_0,
|
||||
V4_2_0;
|
||||
V4_2_0,
|
||||
V4_3_0;
|
||||
|
||||
public static VersionEnum latestVersion() {
|
||||
VersionEnum[] values = VersionEnum.values();
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
- item:
|
||||
type: "add"
|
||||
title: "The version of a few dependencies have been bumped to the latest versions
|
||||
(dependent HAPI modules listed in brackets):
|
||||
<ul>
|
||||
<li>Hibernate ORM (JPA): 5.4.6 -> 5.4.10</li>
|
||||
</ul>"
|
||||
- item:
|
||||
type: change
|
||||
title: "The JPA server now shared a single set of tags for all versions of a resource, bringing it in line with the
|
||||
functional description in the FHIR specification. This means that it is no longer possible to modify the tags for
|
||||
a specific version of a resource, and also causes significant performance improvements in some cases."
|
|
@ -236,18 +236,6 @@
|
|||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>javax.xml.bind</groupId>-->
|
||||
<!-- <artifactId>jaxb-api</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!--<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
</dependency>-->
|
||||
|
||||
<!-- Test Database -->
|
||||
<dependency>
|
||||
|
@ -255,11 +243,6 @@
|
|||
<artifactId>derby</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>org.apache.derby</groupId>
|
||||
<artifactId>derbyshared</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.apache.derby</groupId>
|
||||
<artifactId>derbytools</artifactId>
|
||||
|
@ -319,15 +302,7 @@
|
|||
</dependency>
|
||||
|
||||
|
||||
<!-- <dependency> <groupId>org.hsqldb</groupId> <artifactId>hsqldb</artifactId> <version>2.3.2</version> </dependency> -->
|
||||
|
||||
<!-- Spring -->
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>aopalliance</groupId>
|
||||
<artifactId>aopalliance</artifactId>
|
||||
</dependency>
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
|
@ -370,12 +345,6 @@
|
|||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-messaging</artifactId>
|
||||
</dependency>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-core</artifactId>
|
||||
</dependency>
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-tx</artifactId>
|
||||
|
@ -422,6 +391,16 @@
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-java8</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.jboss.spec.javax.transaction</groupId>
|
||||
<artifactId>jboss-transaction-api_1.2_spec</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-ehcache</artifactId>
|
||||
|
@ -451,10 +430,6 @@
|
|||
<artifactId>javax.activation</artifactId>
|
||||
<version>1.2.0</version>
|
||||
</dependency>
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>javax.transaction</groupId>-->
|
||||
<!--<artifactId>javax.transaction-api</artifactId>-->
|
||||
<!--</dependency>-->
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>javax.mail-api</artifactId>
|
||||
|
@ -471,14 +446,6 @@
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>com.sun.activation</groupId>-->
|
||||
<!--<artifactId>javax.activation</artifactId>-->
|
||||
<!--</dependency>-->
|
||||
<!--<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>javax.el</groupId>
|
||||
<artifactId>javax.el-api</artifactId>
|
||||
|
|
|
@ -1,10 +1,21 @@
|
|||
package ca.uhn.fhir.jpa.dao;
|
||||
|
||||
import ca.uhn.fhir.context.*;
|
||||
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||
import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
|
||||
import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.context.RuntimeChildResourceDefinition;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.context.RuntimeSearchParam;
|
||||
import ca.uhn.fhir.interceptor.api.HookParams;
|
||||
import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster;
|
||||
import ca.uhn.fhir.interceptor.api.Pointcut;
|
||||
import ca.uhn.fhir.jpa.dao.data.*;
|
||||
import ca.uhn.fhir.jpa.dao.data.IForcedIdDao;
|
||||
import ca.uhn.fhir.jpa.dao.data.IResourceHistoryTableDao;
|
||||
import ca.uhn.fhir.jpa.dao.data.IResourceProvenanceDao;
|
||||
import ca.uhn.fhir.jpa.dao.data.IResourceTableDao;
|
||||
import ca.uhn.fhir.jpa.dao.data.IResourceTagDao;
|
||||
import ca.uhn.fhir.jpa.dao.expunge.ExpungeService;
|
||||
import ca.uhn.fhir.jpa.dao.index.DaoSearchParamSynchronizer;
|
||||
import ca.uhn.fhir.jpa.dao.index.IdHelperService;
|
||||
|
@ -75,7 +86,11 @@ import org.springframework.transaction.support.TransactionSynchronizationAdapter
|
|||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.persistence.*;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.NoResultException;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.PersistenceContextType;
|
||||
import javax.persistence.TypedQuery;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Root;
|
||||
|
@ -84,7 +99,12 @@ import javax.xml.stream.events.XMLEvent;
|
|||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.*;
|
||||
import static org.apache.commons.lang3.StringUtils.defaultIfBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.defaultString;
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.left;
|
||||
import static org.apache.commons.lang3.StringUtils.trim;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
|
@ -149,6 +169,8 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> extends BaseStora
|
|||
@Autowired
|
||||
protected IInterceptorBroadcaster myInterceptorBroadcaster;
|
||||
@Autowired
|
||||
protected DaoRegistry myDaoRegistry;
|
||||
@Autowired
|
||||
ExpungeService myExpungeService;
|
||||
@Autowired
|
||||
private DaoConfig myConfig;
|
||||
|
@ -159,8 +181,6 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> extends BaseStora
|
|||
@Autowired
|
||||
private ISearchParamPresenceSvc mySearchParamPresenceSvc;
|
||||
@Autowired
|
||||
protected DaoRegistry myDaoRegistry;
|
||||
@Autowired
|
||||
private SearchParamWithInlineReferencesExtractor mySearchParamWithInlineReferencesExtractor;
|
||||
@Autowired
|
||||
private DaoSearchParamSynchronizer myDaoSearchParamSynchronizer;
|
||||
|
@ -620,6 +640,7 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> extends BaseStora
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
@ -681,6 +702,7 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> extends BaseStora
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,130 @@
|
|||
package ca.uhn.fhir.jpa.dao.r4;
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.BaseHapiFhirDao;
|
||||
import ca.uhn.fhir.jpa.dao.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceEncodingEnum;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceHistoryTable;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceTag;
|
||||
import ca.uhn.fhir.jpa.model.entity.TagTypeEnum;
|
||||
import ca.uhn.fhir.jpa.model.util.JpaConstants;
|
||||
import ca.uhn.fhir.jpa.provider.SystemProviderDstu2Test;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.param.ReferenceParam;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.param.TokenParam;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r4.model.*;
|
||||
import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent;
|
||||
import org.hl7.fhir.r4.model.Bundle.BundleEntryRequestComponent;
|
||||
import org.hl7.fhir.r4.model.Bundle.BundleEntryResponseComponent;
|
||||
import org.hl7.fhir.r4.model.Bundle.BundleType;
|
||||
import org.hl7.fhir.r4.model.Bundle.HTTPVerb;
|
||||
import org.hl7.fhir.r4.model.Observation.ObservationStatus;
|
||||
import org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.support.TransactionCallback;
|
||||
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDate;
|
||||
import java.time.Month;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.emptyString;
|
||||
import static org.hamcrest.Matchers.endsWith;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.matchesPattern;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class MultitenantR4Test extends BaseJpaR4SystemTest {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(MultitenantR4Test.class);
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void beforeDisableResultReuse() {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreateResourceNoTenant() {
|
||||
Patient p = new Patient();
|
||||
p.addIdentifier().setSystem("system").setValue("value");
|
||||
p.setBirthDate(new Date());
|
||||
Long patientId = myPatientDao.create(p).getId().getIdPartAsLong();
|
||||
|
||||
runInTransaction(()->{
|
||||
ResourceTable resourceTable = myResourceTableDao.findById(patientId).orElseThrow(() -> new IllegalArgumentException());
|
||||
assertNull(resourceTable.getTenantId());
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateResourceWithTenant() {
|
||||
Patient p = new Patient();
|
||||
p.setUserData(JpaConstants.USERDATA_TENANT_ID, 3);
|
||||
p.setUserData(JpaConstants.USERDATA_TENANT_DATE, LocalDate.of(2020, Month.JANUARY, 14));
|
||||
p.addIdentifier().setSystem("system").setValue("value");
|
||||
p.setBirthDate(new Date());
|
||||
Long patientId = myPatientDao.create(p).getId().getIdPartAsLong();
|
||||
|
||||
runInTransaction(()->{
|
||||
ResourceTable resourceTable = myResourceTableDao.findById(patientId).orElseThrow(() -> new IllegalArgumentException());
|
||||
assertNull(resourceTable.getTenantId());
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
}
|
|
@ -56,7 +56,13 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
|
|||
init360(); // 20180918 - 20181112
|
||||
init400(); // 20190401 - 20190814
|
||||
init410(); // 20190815 - 20191014
|
||||
init420(); // 20191015 - present
|
||||
init420(); // 20191015 - 20200213
|
||||
init430(); // 20200213 - present
|
||||
}
|
||||
|
||||
protected void init430() {
|
||||
Builder version = forVersion(VersionEnum.V4_3_0);
|
||||
|
||||
}
|
||||
|
||||
protected void init420() { // 20191015 - present
|
||||
|
|
|
@ -22,7 +22,6 @@ package ca.uhn.fhir.jpa.model.entity;
|
|||
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.jpa.model.cross.IBasePersistedResource;
|
||||
import ca.uhn.fhir.jpa.model.cross.ResourcePersistentId;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
|
@ -64,6 +63,9 @@ public abstract class BaseHasResource implements IBaseResourceEntity, IBasePersi
|
|||
@OptimisticLock(excluded = true)
|
||||
private Date myUpdated;
|
||||
|
||||
@Embedded
|
||||
private TenantId myTenantId;
|
||||
|
||||
/**
|
||||
* This is stored as an optimization to avoid neeind to query for this
|
||||
* after an update
|
||||
|
@ -71,6 +73,14 @@ public abstract class BaseHasResource implements IBaseResourceEntity, IBasePersi
|
|||
@Transient
|
||||
private transient String myTransientForcedId;
|
||||
|
||||
public TenantId getTenantId() {
|
||||
return myTenantId;
|
||||
}
|
||||
|
||||
public void setTenantId(TenantId theTenantId) {
|
||||
myTenantId = theTenantId;
|
||||
}
|
||||
|
||||
public String getTransientForcedId() {
|
||||
return myTransientForcedId;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,14 @@ import com.google.common.hash.Hashing;
|
|||
import org.hibernate.search.annotations.ContainedIn;
|
||||
import org.hibernate.search.annotations.Field;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import java.util.Date;
|
||||
|
||||
@MappedSuperclass
|
||||
|
@ -47,10 +54,9 @@ public abstract class BaseResourceIndexedSearchParam extends BaseResourceIndex {
|
|||
private static final byte[] DELIMITER_BYTES = "|".getBytes(Charsets.UTF_8);
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// TODO: make this nullable=false and a primitive (written may 2017)
|
||||
@Field()
|
||||
@Column(name = "SP_MISSING", nullable = true)
|
||||
private Boolean myMissing = Boolean.FALSE;
|
||||
@Column(name = "SP_MISSING", nullable = false)
|
||||
private boolean myMissing = false;
|
||||
|
||||
@Field
|
||||
@Column(name = "SP_NAME", length = MAX_SP_NAME, nullable = false)
|
||||
|
@ -64,14 +70,27 @@ public abstract class BaseResourceIndexedSearchParam extends BaseResourceIndex {
|
|||
@Column(name = "RES_ID", insertable = false, updatable = false, nullable = false)
|
||||
private Long myResourcePid;
|
||||
|
||||
// FIXME: replace with join
|
||||
@Field()
|
||||
@Column(name = "RES_TYPE", nullable = false, length = Constants.MAX_RESOURCE_NAME_LENGTH)
|
||||
private String myResourceType;
|
||||
|
||||
@Field()
|
||||
@Column(name = "SP_UPDATED", nullable = true) // TODO: make this false after HAPI 2.3
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date myUpdated;
|
||||
|
||||
@Embedded
|
||||
private TenantId myTenantId;
|
||||
|
||||
public TenantId getTenantId() {
|
||||
return myTenantId;
|
||||
}
|
||||
|
||||
public void setTenantId(TenantId theTenantId) {
|
||||
myTenantId = theTenantId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subclasses may override
|
||||
*/
|
||||
|
@ -123,7 +142,7 @@ public abstract class BaseResourceIndexedSearchParam extends BaseResourceIndex {
|
|||
}
|
||||
|
||||
public boolean isMissing() {
|
||||
return Boolean.TRUE.equals(myMissing);
|
||||
return myMissing;
|
||||
}
|
||||
|
||||
public BaseResourceIndexedSearchParam setMissing(boolean theMissing) {
|
||||
|
|
|
@ -27,12 +27,20 @@ import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
|||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.hibernate.annotations.OptimisticLock;
|
||||
import org.hibernate.search.annotations.*;
|
||||
import org.hibernate.search.annotations.Analyze;
|
||||
import org.hibernate.search.annotations.Analyzer;
|
||||
import org.hibernate.search.annotations.Field;
|
||||
import org.hibernate.search.annotations.Fields;
|
||||
import org.hibernate.search.annotations.Indexed;
|
||||
import org.hibernate.search.annotations.Store;
|
||||
|
||||
import javax.persistence.Index;
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.defaultString;
|
||||
|
@ -52,12 +60,6 @@ public class ResourceTable extends BaseHasResource implements Serializable, IBas
|
|||
private static final int MAX_PROFILE_LENGTH = 200;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// @Transient
|
||||
// private transient byte[] myResource;
|
||||
//
|
||||
// @Transient
|
||||
// private transient ResourceEncodingEnum myEncoding;
|
||||
|
||||
/**
|
||||
* Holds the narrative text only - Used for Fulltext searching but not directly stored in the DB
|
||||
*/
|
||||
|
@ -186,9 +188,9 @@ public class ResourceTable extends BaseHasResource implements Serializable, IBas
|
|||
* {@link #myHasLinks} is true, meaning that there are actually resource links present
|
||||
* right now. This avoids Hibernate Search triggering a select on the resource link
|
||||
* table.
|
||||
*
|
||||
* <p>
|
||||
* This field is used by FulltextSearchSvcImpl
|
||||
*
|
||||
* <p>
|
||||
* You can test that any changes don't cause extra queries by running
|
||||
* FhirResourceDaoR4QueryCountTest
|
||||
*/
|
||||
|
@ -421,7 +423,6 @@ public class ResourceTable extends BaseHasResource implements Serializable, IBas
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceTag> getTags() {
|
||||
if (myTags == null) {
|
||||
myTags = new HashSet<>();
|
||||
|
@ -590,16 +591,16 @@ public class ResourceTable extends BaseHasResource implements Serializable, IBas
|
|||
* This is a convenience to avoid loading the version a second time within a single transaction. It is
|
||||
* not persisted.
|
||||
*/
|
||||
public void setCurrentVersionEntity(ResourceHistoryTable theCurrentVersionEntity) {
|
||||
myCurrentVersionEntity = theCurrentVersionEntity;
|
||||
public ResourceHistoryTable getCurrentVersionEntity() {
|
||||
return myCurrentVersionEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a convenience to avoid loading the version a second time within a single transaction. It is
|
||||
* not persisted.
|
||||
*/
|
||||
public ResourceHistoryTable getCurrentVersionEntity() {
|
||||
return myCurrentVersionEntity;
|
||||
public void setCurrentVersionEntity(ResourceHistoryTable theCurrentVersionEntity) {
|
||||
myCurrentVersionEntity = theCurrentVersionEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,8 +28,8 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||
import javax.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "HFJ_RES_TAG", uniqueConstraints= {
|
||||
@UniqueConstraint(name="IDX_RESTAG_TAGID", columnNames= {"RES_ID","TAG_ID"})
|
||||
@Table(name = "HFJ_RES_TAG", uniqueConstraints = {
|
||||
@UniqueConstraint(name = "IDX_RESTAG_TAGID", columnNames = {"RES_ID", "TAG_ID"})
|
||||
})
|
||||
public class ResourceTag extends BaseTag {
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class ResourceTag extends BaseTag {
|
|||
private Long myId;
|
||||
|
||||
@ManyToOne(cascade = {})
|
||||
@JoinColumn(name = "RES_ID", referencedColumnName = "RES_ID", foreignKey=@ForeignKey(name="FK_RESTAG_RESOURCE"))
|
||||
@JoinColumn(name = "RES_ID", referencedColumnName = "RES_ID", foreignKey = @ForeignKey(name = "FK_RESTAG_RESOURCE"))
|
||||
private ResourceTable myResource;
|
||||
|
||||
@Column(name = "RES_TYPE", length = ResourceTable.RESTYPE_LEN, nullable = false)
|
||||
|
@ -50,14 +50,8 @@ public class ResourceTag extends BaseTag {
|
|||
|
||||
@Column(name = "RES_ID", insertable = false, updatable = false)
|
||||
private Long myResourceId;
|
||||
|
||||
public Long getResourceId() {
|
||||
return myResourceId;
|
||||
}
|
||||
|
||||
public void setResourceId(Long theResourceId) {
|
||||
myResourceId = theResourceId;
|
||||
}
|
||||
@Embedded
|
||||
private TenantId myTenantId;
|
||||
|
||||
public ResourceTag() {
|
||||
}
|
||||
|
@ -69,18 +63,30 @@ public class ResourceTag extends BaseTag {
|
|||
setResourceType(theResourceTable.getResourceType());
|
||||
}
|
||||
|
||||
public void setTenantId(TenantId theTenantId) {
|
||||
myTenantId = theTenantId;
|
||||
}
|
||||
|
||||
public Long getResourceId() {
|
||||
return myResourceId;
|
||||
}
|
||||
|
||||
public void setResourceId(Long theResourceId) {
|
||||
myResourceId = theResourceId;
|
||||
}
|
||||
|
||||
public ResourceTable getResource() {
|
||||
return myResource;
|
||||
}
|
||||
|
||||
public String getResourceType() {
|
||||
return myResourceType;
|
||||
}
|
||||
|
||||
public void setResource(ResourceTable theResource) {
|
||||
myResource = theResource;
|
||||
}
|
||||
|
||||
public String getResourceType() {
|
||||
return myResourceType;
|
||||
}
|
||||
|
||||
public void setResourceType(String theResourceType) {
|
||||
myResourceType = theResourceType;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package ca.uhn.fhir.jpa.model.entity;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embeddable;
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Embeddable
|
||||
public class TenantId implements Cloneable {
|
||||
|
||||
@Column(name = "TENANT_ID", nullable = true)
|
||||
private Integer myTenantId;
|
||||
@Column(name = "TENANT_DATE", nullable = true)
|
||||
private LocalDate myTenantDate;
|
||||
|
||||
public Integer getTenantId() {
|
||||
return myTenantId;
|
||||
}
|
||||
|
||||
public TenantId setTenantId(Integer theTenantId) {
|
||||
myTenantId = theTenantId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDate getTenantDate() {
|
||||
return myTenantDate;
|
||||
}
|
||||
|
||||
public TenantId setTenantDate(LocalDate theTenantDate) {
|
||||
myTenantDate = theTenantDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TenantId clone() {
|
||||
return new TenantId()
|
||||
.setTenantId(getTenantId())
|
||||
.setTenantDate(getTenantDate());
|
||||
}
|
||||
}
|
|
@ -24,39 +24,30 @@ import ca.uhn.fhir.rest.api.Constants;
|
|||
|
||||
public class JpaConstants {
|
||||
|
||||
/**
|
||||
* Non-instantiable
|
||||
*/
|
||||
private JpaConstants() {
|
||||
// nothing
|
||||
}
|
||||
public static final String USERDATA_TENANT_ID = JpaConstants.class.getName() + "_USERDATA_TENANT_ID";
|
||||
public static final String USERDATA_TENANT_DATE = JpaConstants.class.getName() + "_USERDATA_TENANT_DATE";
|
||||
|
||||
/**
|
||||
* Operation name for the $apply-codesystem-delta-add operation
|
||||
*/
|
||||
public static final String OPERATION_APPLY_CODESYSTEM_DELTA_ADD = "$apply-codesystem-delta-add";
|
||||
|
||||
/**
|
||||
* Operation name for the $apply-codesystem-delta-remove operation
|
||||
*/
|
||||
public static final String OPERATION_APPLY_CODESYSTEM_DELTA_REMOVE = "$apply-codesystem-delta-remove";
|
||||
|
||||
/**
|
||||
* Operation name for the $expunge operation
|
||||
*/
|
||||
public static final String OPERATION_EXPUNGE = "$expunge";
|
||||
|
||||
/**
|
||||
* Operation name for the $match operation
|
||||
*/
|
||||
public static final String OPERATION_MATCH = "$match";
|
||||
|
||||
/**
|
||||
* @deprecated Replace with {@link #OPERATION_EXPUNGE}
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String OPERATION_NAME_EXPUNGE = OPERATION_EXPUNGE;
|
||||
|
||||
/**
|
||||
* Parameter name for the $expunge operation
|
||||
*/
|
||||
|
@ -84,113 +75,91 @@ public class JpaConstants {
|
|||
* be removed if they are nt explicitly included in updates
|
||||
*/
|
||||
public static final String HEADER_META_SNAPSHOT_MODE = "X-Meta-Snapshot-Mode";
|
||||
|
||||
/**
|
||||
* Operation name for the $lookup operation
|
||||
*/
|
||||
public static final String OPERATION_LOOKUP = "$lookup";
|
||||
|
||||
/**
|
||||
* Operation name for the $expand operation
|
||||
*/
|
||||
public static final String OPERATION_EXPAND = "$expand";
|
||||
|
||||
/**
|
||||
* Operation name for the $validate-code operation
|
||||
*/
|
||||
public static final String OPERATION_VALIDATE_CODE = "$validate-code";
|
||||
|
||||
/**
|
||||
* Operation name for the $get-resource-counts operation
|
||||
*/
|
||||
public static final String OPERATION_GET_RESOURCE_COUNTS = "$get-resource-counts";
|
||||
|
||||
/**
|
||||
* Operation name for the $meta operation
|
||||
*/
|
||||
public static final String OPERATION_META = "$meta";
|
||||
|
||||
/**
|
||||
* Operation name for the $validate operation
|
||||
*/
|
||||
// NB don't delete this, it's used in Smile as well, even though hapi-fhir-server uses the version from Constants.java
|
||||
public static final String OPERATION_VALIDATE = Constants.EXTOP_VALIDATE;
|
||||
|
||||
/**
|
||||
* Operation name for the $suggest-keywords operation
|
||||
*/
|
||||
public static final String OPERATION_SUGGEST_KEYWORDS = "$suggest-keywords";
|
||||
|
||||
/**
|
||||
* Operation name for the $everything operation
|
||||
*/
|
||||
public static final String OPERATION_EVERYTHING = "$everything";
|
||||
|
||||
/**
|
||||
* Operation name for the $process-message operation
|
||||
*/
|
||||
public static final String OPERATION_PROCESS_MESSAGE = "$process-message";
|
||||
|
||||
/**
|
||||
* Operation name for the $meta-delete operation
|
||||
*/
|
||||
public static final String OPERATION_META_DELETE = "$meta-delete";
|
||||
|
||||
/**
|
||||
* Operation name for the $meta-add operation
|
||||
*/
|
||||
public static final String OPERATION_META_ADD = "$meta-add";
|
||||
|
||||
/**
|
||||
* Operation name for the $translate operation
|
||||
*/
|
||||
public static final String OPERATION_TRANSLATE = "$translate";
|
||||
|
||||
/**
|
||||
* Operation name for the $document operation
|
||||
*/
|
||||
public static final String OPERATION_DOCUMENT = "$document";
|
||||
|
||||
/**
|
||||
* Trigger a subscription manually for a given resource
|
||||
*/
|
||||
public static final String OPERATION_TRIGGER_SUBSCRIPTION = "$trigger-subscription";
|
||||
|
||||
/**
|
||||
* Operation name for the "$subsumes" operation
|
||||
*/
|
||||
public static final String OPERATION_SUBSUMES = "$subsumes";
|
||||
|
||||
/**
|
||||
* Operation name for the "$snapshot" operation
|
||||
*/
|
||||
public static final String OPERATION_SNAPSHOT = "$snapshot";
|
||||
|
||||
/**
|
||||
* Operation name for the "$binary-access" operation
|
||||
*/
|
||||
public static final String OPERATION_BINARY_ACCESS_READ = "$binary-access-read";
|
||||
|
||||
/**
|
||||
* Operation name for the "$binary-access" operation
|
||||
*/
|
||||
public static final String OPERATION_BINARY_ACCESS_WRITE = "$binary-access-write";
|
||||
|
||||
/**
|
||||
* Operation name for the "$upload-external-code-system" operation
|
||||
*/
|
||||
public static final String OPERATION_UPLOAD_EXTERNAL_CODE_SYSTEM = "$upload-external-code-system";
|
||||
|
||||
/**
|
||||
* Operation name for the "$export" operation
|
||||
*/
|
||||
public static final String OPERATION_EXPORT = "$export";
|
||||
|
||||
/**
|
||||
* Operation name for the "$export-poll-status" operation
|
||||
*/
|
||||
public static final String OPERATION_EXPORT_POLL_STATUS = "$export-poll-status";
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This extension should be of type <code>string</code> and should be
|
||||
|
@ -198,7 +167,6 @@ public class JpaConstants {
|
|||
* </p>
|
||||
*/
|
||||
public static final String EXT_SUBSCRIPTION_SUBJECT_TEMPLATE = "http://hapifhir.io/fhir/StructureDefinition/subscription-email-subject-template";
|
||||
|
||||
/**
|
||||
* This extension URL indicates whether a REST HOOK delivery should
|
||||
* include the version ID when delivering.
|
||||
|
@ -208,7 +176,6 @@ public class JpaConstants {
|
|||
* </p>
|
||||
*/
|
||||
public static final String EXT_SUBSCRIPTION_RESTHOOK_STRIP_VERSION_IDS = "http://hapifhir.io/fhir/StructureDefinition/subscription-resthook-strip-version-ids";
|
||||
|
||||
/**
|
||||
* This extension URL indicates whether a REST HOOK delivery should
|
||||
* reload the resource and deliver the latest version always. This
|
||||
|
@ -226,12 +193,10 @@ public class JpaConstants {
|
|||
* </p>
|
||||
*/
|
||||
public static final String EXT_SUBSCRIPTION_RESTHOOK_DELIVER_LATEST_VERSION = "http://hapifhir.io/fhir/StructureDefinition/subscription-resthook-deliver-latest-version";
|
||||
|
||||
/**
|
||||
* Indicate which strategy will be used to match this subscription
|
||||
*/
|
||||
public static final String EXT_SUBSCRIPTION_MATCHING_STRATEGY = "http://hapifhir.io/fhir/StructureDefinition/subscription-matching-strategy";
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This extension should be of type <code>string</code> and should be
|
||||
|
@ -239,45 +204,43 @@ public class JpaConstants {
|
|||
* </p>
|
||||
*/
|
||||
public static final String EXT_SUBSCRIPTION_EMAIL_FROM = "http://hapifhir.io/fhir/StructureDefinition/subscription-email-from";
|
||||
|
||||
/**
|
||||
* Extension ID for external binary references
|
||||
*/
|
||||
public static final String EXT_EXTERNALIZED_BINARY_ID = "http://hapifhir.io/fhir/StructureDefinition/externalized-binary-id";
|
||||
|
||||
/**
|
||||
* Placed in system-generated extensions
|
||||
*/
|
||||
public static final String EXTENSION_EXT_SYSTEMDEFINED = JpaConstants.class.getName() + "_EXTENSION_EXT_SYSTEMDEFINED";
|
||||
|
||||
/**
|
||||
* Message added to expansion valueset
|
||||
*/
|
||||
public static final String EXT_VALUESET_EXPANSION_MESSAGE = "http://hapifhir.io/fhir/StructureDefinition/valueset-expansion-message";
|
||||
|
||||
|
||||
/**
|
||||
* Parameter for the $export operation
|
||||
*/
|
||||
public static final String PARAM_EXPORT_POLL_STATUS_JOB_ID = "_jobId";
|
||||
|
||||
/**
|
||||
* Parameter for the $export operation
|
||||
*/
|
||||
public static final String PARAM_EXPORT_OUTPUT_FORMAT = "_outputFormat";
|
||||
|
||||
/**
|
||||
* Parameter for the $export operation
|
||||
*/
|
||||
public static final String PARAM_EXPORT_TYPE = "_type";
|
||||
|
||||
/**
|
||||
* Parameter for the $export operation
|
||||
*/
|
||||
public static final String PARAM_EXPORT_SINCE = "_since";
|
||||
|
||||
/**
|
||||
* Parameter for the $export operation
|
||||
*/
|
||||
public static final String PARAM_EXPORT_TYPE_FILTER = "_typeFilter";
|
||||
|
||||
/**
|
||||
* Non-instantiable
|
||||
*/
|
||||
private JpaConstants() {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
|
|
7
pom.xml
7
pom.xml
|
@ -645,7 +645,7 @@
|
|||
<jsr305_version>3.0.2</jsr305_version>
|
||||
<flyway_version>6.1.0</flyway_version>
|
||||
<!--<hibernate_version>5.2.10.Final</hibernate_version>-->
|
||||
<hibernate_version>5.4.6.Final</hibernate_version>
|
||||
<hibernate_version>5.4.10.Final</hibernate_version>
|
||||
<!-- Update lucene version when you update hibernate-search version -->
|
||||
<hibernate_search_version>5.11.3.Final</hibernate_search_version>
|
||||
<lucene_version>5.5.5</lucene_version>
|
||||
|
@ -1278,6 +1278,11 @@
|
|||
<artifactId>hibernate-core</artifactId>
|
||||
<version>${hibernate_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-java8</artifactId>
|
||||
<version>${hibernate_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-ehcache</artifactId>
|
||||
|
|
Loading…
Reference in New Issue