Get content search working correctly

This commit is contained in:
jamesagnew 2015-10-13 09:18:34 -04:00
parent b97f7d4664
commit 6d93cbcaae
21 changed files with 204 additions and 79 deletions

View File

@ -800,8 +800,14 @@ public class JsonParser extends BaseParser implements IParser {
if (theResource instanceof IBaseBinary) {
IBaseBinary bin = (IBaseBinary) theResource;
theEventWriter.write("contentType", bin.getContentType());
theEventWriter.write("content", bin.getContentAsBase64());
String contentType = bin.getContentType();
if (isNotBlank(contentType)) {
theEventWriter.write("contentType", contentType);
}
String contentAsBase64 = bin.getContentAsBase64();
if (isNotBlank(contentAsBase64)) {
theEventWriter.write("content", contentAsBase64);
}
} else {
encodeCompositeElementToStreamWriter(theResDef, theResource, theResource, theEventWriter, resDef, theContainedResource, new CompositeChildElement(resDef));
}

View File

@ -52,8 +52,10 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URLEncodedUtils;
import org.hl7.fhir.instance.model.api.IBaseDatatype;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.instance.model.api.IPrimitiveType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionStatus;
@ -695,7 +697,11 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
}
}
for (ResourceTag next : new ArrayList<ResourceTag>(theEntity.getTags())) {
ArrayList<ResourceTag> existingTags = new ArrayList<ResourceTag>();
if (theEntity.isHasTags()) {
existingTags.addAll(theEntity.getTags());
}
for (ResourceTag next : existingTags) {
TagDefinition nextDef = next.getTag();
if (!allDefs.contains(nextDef)) {
if (shouldDroppedTagBeRemovedOnUpdate(theEntity, next)) {
@ -1224,23 +1230,38 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
theEntity.setVersion(theEntity.getVersion() + 1);
}
boolean paramsStringPopulated = theEntity.isParamsStringPopulated();
boolean paramsTokenPopulated = theEntity.isParamsTokenPopulated();
boolean paramsNumberPopulated = theEntity.isParamsNumberPopulated();
boolean paramsQuantityPopulated = theEntity.isParamsQuantityPopulated();
boolean paramsDatePopulated = theEntity.isParamsDatePopulated();
boolean paramsCoordsPopulated = theEntity.isParamsCoordsPopulated();
boolean paramsUriPopulated = theEntity.isParamsUriPopulated();
boolean hasLinks = theEntity.isHasLinks();
Collection<ResourceIndexedSearchParamString> paramsString = new ArrayList<ResourceIndexedSearchParamString>(theEntity.getParamsString()); // TODO: use the isPopulated method to decide whether to call this
Collection<ResourceIndexedSearchParamToken> paramsToken = new ArrayList<ResourceIndexedSearchParamToken>(theEntity.getParamsToken());
Collection<ResourceIndexedSearchParamNumber> paramsNumber = new ArrayList<ResourceIndexedSearchParamNumber>(theEntity.getParamsNumber());
Collection<ResourceIndexedSearchParamQuantity> paramsQuantity = new ArrayList<ResourceIndexedSearchParamQuantity>(theEntity.getParamsQuantity());
Collection<ResourceIndexedSearchParamDate> paramsDate = new ArrayList<ResourceIndexedSearchParamDate>(theEntity.getParamsDate());
Collection<ResourceIndexedSearchParamUri> paramsUri = new ArrayList<ResourceIndexedSearchParamUri>(theEntity.getParamsUri());
Collection<ResourceIndexedSearchParamCoords> paramsCoords = new ArrayList<ResourceIndexedSearchParamCoords>(theEntity.getParamsCoords());
Collection<ResourceLink> resourceLinks = new ArrayList<ResourceLink>(theEntity.getResourceLinks());
Collection<ResourceIndexedSearchParamString> paramsString = new ArrayList<ResourceIndexedSearchParamString>();
if (theEntity.isParamsStringPopulated()) {
paramsString.addAll(theEntity.getParamsString());
}
Collection<ResourceIndexedSearchParamToken> paramsToken = new ArrayList<ResourceIndexedSearchParamToken>();
if (theEntity.isParamsTokenPopulated()) {
paramsToken.addAll(theEntity.getParamsToken());
}
Collection<ResourceIndexedSearchParamNumber> paramsNumber = new ArrayList<ResourceIndexedSearchParamNumber>();
if (theEntity.isParamsNumberPopulated()) {
paramsNumber.addAll(theEntity.getParamsNumber());
}
Collection<ResourceIndexedSearchParamQuantity> paramsQuantity = new ArrayList<ResourceIndexedSearchParamQuantity>();
if (theEntity.isParamsQuantityPopulated()) {
paramsQuantity.addAll(theEntity.getParamsQuantity());
}
Collection<ResourceIndexedSearchParamDate> paramsDate = new ArrayList<ResourceIndexedSearchParamDate>();
if (theEntity.isParamsDatePopulated()) {
paramsDate.addAll(theEntity.getParamsDate());
}
Collection<ResourceIndexedSearchParamUri> paramsUri = new ArrayList<ResourceIndexedSearchParamUri>();
if (theEntity.isParamsUriPopulated()) {
paramsUri.addAll(theEntity.getParamsUri());
}
Collection<ResourceIndexedSearchParamCoords> paramsCoords = new ArrayList<ResourceIndexedSearchParamCoords>();
if (theEntity.isParamsCoordsPopulated()) {
paramsCoords.addAll(theEntity.getParamsCoords());
}
Collection<ResourceLink> resourceLinks = new ArrayList<ResourceLink>();
if (theEntity.isHasLinks()) {
resourceLinks.addAll(theEntity.getResourceLinks());
}
Set<ResourceIndexedSearchParamString> stringParams = null;
Set<ResourceIndexedSearchParamToken> tokenParams = null;
@ -1264,6 +1285,7 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
theEntity.setDeleted(theDeletedTimestampOrNull);
theEntity.setUpdated(theDeletedTimestampOrNull);
theEntity.setNarrativeTextParsedIntoWords(null);
theEntity.setContentTextParsedIntoWords(null);
} else {
@ -1313,6 +1335,7 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
theEntity.setHasLinks(links.isEmpty() == false);
theEntity.setIndexStatus(INDEX_STATUS_INDEXED);
theEntity.setNarrativeTextParsedIntoWords(parseNarrativeTextIntoWords(theResource));
theEntity.setContentTextParsedIntoWords(parseContentTextIntoWords(theResource));
} else {
@ -1342,83 +1365,69 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
if (thePerformIndexing) {
if (paramsStringPopulated) {
for (ResourceIndexedSearchParamString next : paramsString) {
myEntityManager.remove(next);
}
}
for (ResourceIndexedSearchParamString next : stringParams) {
myEntityManager.persist(next);
}
if (paramsTokenPopulated) {
for (ResourceIndexedSearchParamToken next : paramsToken) {
myEntityManager.remove(next);
}
}
for (ResourceIndexedSearchParamToken next : tokenParams) {
myEntityManager.persist(next);
}
if (paramsNumberPopulated) {
for (ResourceIndexedSearchParamNumber next : paramsNumber) {
myEntityManager.remove(next);
}
}
for (ResourceIndexedSearchParamNumber next : numberParams) {
myEntityManager.persist(next);
}
if (paramsQuantityPopulated) {
for (ResourceIndexedSearchParamQuantity next : paramsQuantity) {
myEntityManager.remove(next);
}
}
for (ResourceIndexedSearchParamQuantity next : quantityParams) {
myEntityManager.persist(next);
}
// Store date SP's
if (paramsDatePopulated) {
for (ResourceIndexedSearchParamDate next : paramsDate) {
myEntityManager.remove(next);
}
}
for (ResourceIndexedSearchParamDate next : dateParams) {
myEntityManager.persist(next);
}
// Store URI SP's
if (paramsUriPopulated) {
for (ResourceIndexedSearchParamUri next : paramsUri) {
myEntityManager.remove(next);
}
}
for (ResourceIndexedSearchParamUri next : uriParams) {
myEntityManager.persist(next);
}
// Store Coords SP's
if (paramsCoordsPopulated) {
for (ResourceIndexedSearchParamCoords next : paramsCoords) {
myEntityManager.remove(next);
}
}
for (ResourceIndexedSearchParamCoords next : coordsParams) {
myEntityManager.persist(next);
}
if (hasLinks) {
for (ResourceLink next : resourceLinks) {
myEntityManager.remove(next);
}
}
for (ResourceLink next : links) {
myEntityManager.persist(next);
}
} // if thePerformIndexing
theEntity = myEntityManager.merge(theEntity);
myEntityManager.flush();
if (theResource != null) {
@ -1502,4 +1511,20 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
return b.toString();
}
private String parseContentTextIntoWords(IResource theResource) {
StringBuilder b = new StringBuilder();
@SuppressWarnings("rawtypes")
List<IPrimitiveType> childElements = getContext().newTerser().getAllPopulatedChildElementsOfType(theResource, IPrimitiveType.class);
for (@SuppressWarnings("rawtypes") IPrimitiveType nextType : childElements) {
String nextValue = nextType.getValueAsString();
if (isNotBlank(nextValue)) {
if (b.length() > 0 && b.charAt(b.length() - 1) != ' ') {
b.append(' ');
}
b.append(nextValue);
}
}
return b.toString();
}
}

View File

@ -44,7 +44,7 @@ public class FhirSearchDao extends BaseHapiFhirDao<IBaseResource> implements ISe
BooleanJunction<?> bool = qb.bool();
List<List<? extends IQueryParameterType>> contentAndTerms = theParams.remove(Constants.PARAM_CONTENT);
addTextSearch(qb, bool, contentAndTerms, "myParamsString.myValueComplete");
addTextSearch(qb, bool, contentAndTerms, "myContentText");
List<List<? extends IQueryParameterType>> textAndTerms = theParams.remove(Constants.PARAM_TEXT);
addTextSearch(qb, bool, textAndTerms, "myNarrativeText");

View File

@ -30,6 +30,7 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import org.hibernate.search.annotations.ContainedIn;
import org.hibernate.search.annotations.Field;
@MappedSuperclass
@ -50,6 +51,7 @@ public abstract class BaseResourceIndexedSearchParam implements Serializable {
@ManyToOne(optional = false)
@JoinColumn(name = "RES_ID", referencedColumnName="RES_ID")
@ContainedIn
private ResourceTable myResource;
@Field

View File

@ -23,6 +23,7 @@ package ca.uhn.fhir.jpa.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
@ -31,6 +32,7 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Embeddable
@Entity
@Table(name = "HFJ_HISTORY_TAG")
public class ResourceHistoryTag extends BaseTag implements Serializable {

View File

@ -21,6 +21,7 @@ package ca.uhn.fhir.jpa.entity;
*/
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.Table;
@ -29,9 +30,9 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
//@formatter:off
@Embeddable
@Entity
@Table(name = "HFJ_SPIDX_COORDS" /* , indexes = { @Index(name = "IDX_SP_TOKEN", columnList = "SP_SYSTEM,SP_VALUE") } */)
@org.hibernate.annotations.Table(appliesTo = "HFJ_SPIDX_COORDS", indexes = {

View File

@ -23,6 +23,7 @@ package ca.uhn.fhir.jpa.entity;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Temporal;
@ -33,9 +34,9 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
//@formatter:off
@Embeddable
@Entity
@Table(name = "HFJ_SPIDX_DATE" /*, indexes= {@Index(name="IDX_SP_DATE", columnList= "SP_VALUE_LOW,SP_VALUE_HIGH")}*/)
@org.hibernate.annotations.Table(appliesTo = "HFJ_SPIDX_DATE", indexes= {

View File

@ -23,6 +23,7 @@ package ca.uhn.fhir.jpa.entity;
import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.Table;
@ -38,6 +39,7 @@ import org.hibernate.search.annotations.NumericField;
import ca.uhn.fhir.jpa.util.BigDecimalNumericFieldBridge;
//@formatter:off
@Embeddable
@Entity
@Table(name = "HFJ_SPIDX_NUMBER" /*, indexes= {@Index(name="IDX_SP_NUMBER", columnList="SP_VALUE")}*/ )
@org.hibernate.annotations.Table(appliesTo = "HFJ_SPIDX_NUMBER", indexes= {

View File

@ -23,6 +23,7 @@ package ca.uhn.fhir.jpa.entity;
import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.Table;
@ -38,6 +39,7 @@ import org.hibernate.search.annotations.NumericField;
import ca.uhn.fhir.jpa.util.BigDecimalNumericFieldBridge;
//@formatter:off
@Embeddable
@Entity
@Table(name = "HFJ_SPIDX_QUANTITY" /*, indexes= {@Index(name="IDX_SP_NUMBER", columnList="SP_VALUE")}*/ )
@org.hibernate.annotations.Table(appliesTo = "HFJ_SPIDX_QUANTITY", indexes= {

View File

@ -21,7 +21,10 @@ package ca.uhn.fhir.jpa.entity;
*/
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.apache.commons.lang3.StringUtils;
@ -29,9 +32,10 @@ import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.search.annotations.ContainedIn;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
@Embeddable
@Entity
@Table(name = "HFJ_SPIDX_STRING"/* , indexes= {@Index(name="IDX_SP_STRING", columnList="SP_VALUE_NORMALIZED")} */)
@org.hibernate.annotations.Table(appliesTo = "HFJ_SPIDX_STRING", indexes = {
@ -49,9 +53,11 @@ public class ResourceIndexedSearchParamString extends BaseResourceIndexedSearchP
@Column(name = "SP_VALUE_NORMALIZED", length = MAX_LENGTH, nullable = true)
private String myValueNormalized;
@Column(name="SP_VALUE_EXACT", insertable=false, updatable=false)
@Field
private String myValueComplete;
@ManyToOne(optional = false)
@JoinColumn(name = "RES_ID", referencedColumnName="RES_ID", insertable=false, updatable=false)
@ContainedIn
private ResourceTable myResourceTable;
public ResourceIndexedSearchParamString() {
}
@ -103,7 +109,6 @@ public class ResourceIndexedSearchParamString extends BaseResourceIndexedSearchP
throw new IllegalArgumentException("Value is too long: " + theValueExact.length());
}
myValueExact = theValueExact;
myValueComplete = theValueExact;
}
public void setValueNormalized(String theValueNormalized) {

View File

@ -21,6 +21,7 @@ package ca.uhn.fhir.jpa.entity;
*/
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.Table;
@ -32,6 +33,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
@Embeddable
@Entity
@Table(name = "HFJ_SPIDX_TOKEN" /* , indexes = { @Index(name = "IDX_SP_TOKEN", columnList = "SP_SYSTEM,SP_VALUE") } */)
@org.hibernate.annotations.Table(appliesTo = "HFJ_SPIDX_TOKEN", indexes = { @org.hibernate.annotations.Index(name = "IDX_SP_TOKEN", columnNames = { "RES_TYPE", "SP_NAME", "SP_SYSTEM", "SP_VALUE" }),

View File

@ -21,6 +21,7 @@ package ca.uhn.fhir.jpa.entity;
*/
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.Table;
@ -33,6 +34,7 @@ import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
//@formatter:off
@Embeddable
@Entity
@Table(name = "HFJ_SPIDX_URI" /* , indexes = { @Index(name = "IDX_SP_TOKEN", columnList = "SP_SYSTEM,SP_VALUE") } */)
@org.hibernate.annotations.Table(appliesTo = "HFJ_SPIDX_URI", indexes = {

View File

@ -49,7 +49,7 @@ import ca.uhn.fhir.rest.server.Constants;
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
//@formatter:off
@Indexed(interceptor=IndexNonDeletedInterceptor.class)
@Indexed(/*interceptor=IndexNonDeletedInterceptor.class*/)
@Entity
@Table(name = "HFJ_RESOURCE", uniqueConstraints = {}, indexes= {
@Index(name = "IDX_RES_DATE", columnList="RES_UPDATED"),
@ -86,55 +86,56 @@ public class ResourceTable extends BaseHasResource implements Serializable {
/**
* Holds the narrative text only - Used for Fulltext searching but not directly stored in the DB
*/
@Column(name = "SP_NARRATIVE_TEXT", length = Integer.MAX_VALUE - 1)
@Column(name = "SP_NARRATIVE_TEXT", length = Integer.MAX_VALUE - 1, nullable=true)
@Lob
@Field()
private String myNarrativeText;
/**
* Holds the narrative text only - Used for Fulltext searching but not directly stored in the DB
*/
@Column(name = "SP_CONTENT_TEXT", length = Integer.MAX_VALUE - 1, nullable=true)
@Lob
@Field()
private String myContentText;
@OneToMany(mappedBy = "myResource", cascade = {}, fetch = FetchType.LAZY, orphanRemoval = false)
@IndexedEmbedded
private Collection<ResourceIndexedSearchParamCoords> myParamsCoords;
@Column(name = "SP_COORDS_PRESENT")
private boolean myParamsCoordsPopulated;
@OneToMany(mappedBy = "myResource", cascade = {}, fetch = FetchType.LAZY, orphanRemoval = false)
@IndexedEmbedded
private Collection<ResourceIndexedSearchParamDate> myParamsDate;
@Column(name = "SP_DATE_PRESENT")
private boolean myParamsDatePopulated;
@OneToMany(mappedBy = "myResource", cascade = {}, fetch = FetchType.LAZY, orphanRemoval = false)
@IndexedEmbedded
private Collection<ResourceIndexedSearchParamNumber> myParamsNumber;
@Column(name = "SP_NUMBER_PRESENT")
private boolean myParamsNumberPopulated;
@OneToMany(mappedBy = "myResource", cascade = {}, fetch = FetchType.LAZY, orphanRemoval = false)
@IndexedEmbedded
private Collection<ResourceIndexedSearchParamQuantity> myParamsQuantity;
@Column(name = "SP_QUANTITY_PRESENT")
private boolean myParamsQuantityPopulated;
@OneToMany(mappedBy = "myResource", cascade = {}, fetch = FetchType.LAZY, orphanRemoval = false)
@IndexedEmbedded
private Collection<ResourceIndexedSearchParamString> myParamsString;
@Column(name = "SP_STRING_PRESENT")
private boolean myParamsStringPopulated;
@OneToMany(mappedBy = "myResource", cascade = {}, fetch = FetchType.LAZY, orphanRemoval = false)
@IndexedEmbedded
private Collection<ResourceIndexedSearchParamToken> myParamsToken;
@Column(name = "SP_TOKEN_PRESENT")
private boolean myParamsTokenPopulated;
@OneToMany(mappedBy = "myResource", cascade = {}, fetch = FetchType.LAZY, orphanRemoval = false)
@IndexedEmbedded
private Collection<ResourceIndexedSearchParamUri> myParamsUri;
@Column(name = "SP_URI_PRESENT")
@ -324,6 +325,10 @@ public class ResourceTable extends BaseHasResource implements Serializable {
myNarrativeText = theNarrativeText;
}
public void setContentTextParsedIntoWords(String theContentText) {
myContentText = theContentText;
}
public void setParamsCoords(Collection<ResourceIndexedSearchParamCoords> theParamsCoords) {
if (!isParamsTokenPopulated() && theParamsCoords.isEmpty()) {
return;
@ -447,9 +452,11 @@ public class ResourceTable extends BaseHasResource implements Serializable {
retVal.setDeleted(getDeleted());
retVal.setForcedId(getForcedId());
if (isHasTags()) {
for (ResourceTag next : getTags()) {
retVal.addTag(next);
}
}
return retVal;
}

View File

@ -33,6 +33,6 @@ public class IndexNonDeletedInterceptor implements EntityIndexingInterceptor<Res
@Override
public IndexingOverride onCollectionUpdate(ResourceTable entity) {
return onUpdate(entity);
return IndexingOverride.APPLY_DEFAULT;
}
}

View File

@ -1,6 +1,8 @@
package ca.uhn.fhir.jpa.dao;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.empty;
import static org.junit.Assert.assertThat;
import java.util.List;
@ -32,6 +34,53 @@ public class FhirResourceDaoDstu2SearchFtTest extends BaseJpaDstu2Test {
ftem.flushToIndexes();
}
@Test
public void testSearchAndReindex() {
Patient patient;
SearchParameterMap map;
patient = new Patient();
patient.getText().setDiv("<div>DIVAAA</div>");
patient.addName().addGiven("NAMEAAA");
IIdType pId1 = myPatientDao.create(patient).getId().toUnqualifiedVersionless();
map = new SearchParameterMap();
map.add(Constants.PARAM_CONTENT, new StringParam("NAMEAAA"));
assertThat(toUnqualifiedVersionlessIds(myPatientDao.search(map)), contains(pId1));
map = new SearchParameterMap();
map.add(Constants.PARAM_TEXT, new StringParam("DIVAAA"));
assertThat(toUnqualifiedVersionlessIds(myPatientDao.search(map)), contains(pId1));
/*
* Reindex
*/
patient = new Patient();
patient.setId(pId1);
patient.getText().setDiv("<div>DIVBBB</div>");
patient.addName().addGiven("NAMEBBB");
myPatientDao.update(patient);
map = new SearchParameterMap();
map.add(Constants.PARAM_CONTENT, new StringParam("NAMEAAA"));
assertThat(toUnqualifiedVersionlessIds(myPatientDao.search(map)), empty());
map = new SearchParameterMap();
map.add(Patient.SP_NAME, new StringParam("NAMEBBB"));
assertThat(toUnqualifiedVersionlessIds(myPatientDao.search(map)), contains(pId1));
map = new SearchParameterMap();
map.add(Constants.PARAM_CONTENT, new StringParam("NAMEBBB"));
assertThat(toUnqualifiedVersionlessIds(myPatientDao.search(map)), contains(pId1));
map = new SearchParameterMap();
map.add(Constants.PARAM_TEXT, new StringParam("DIVBBB"));
assertThat(toUnqualifiedVersionlessIds(myPatientDao.search(map)), contains(pId1));
}
@Test
public void testSearchWithChainedParams() {
String methodName = "testSearchWithChainedParams";

View File

@ -37,7 +37,7 @@
<property name="hibernate.cache.use_structured_entries" value="false" />
<property name="hibernate.search.default.directory_provider" value="filesystem"/>
<property name="hibernate.search.default.indexBase" value="./target/lucene_indexes"/>
<entry key="hibernate.search.lucene_version" value="LUCENE_CURRENT" />
<property name="hibernate.search.lucene_version" value="LUCENE_CURRENT" />
<!--
<property name="hibernate.ejb.naming_strategy" value="ca.uhn.fhir.jpa.util.CustomNamingStrategy" />
-->

View File

@ -55,7 +55,7 @@
<entry key="hibernate.cache.use_second_level_cache" value="false" />
<entry key="hibernate.cache.use_structured_entries" value="false" />
<entry key="hibernate.search.default.directory_provider" value="filesystem" />
<entry key="hibernate.search.default.indexBase" value="#{systemProperties['fhir.lucene.location.dstu2']};" />
<entry key="hibernate.search.default.indexBase" value="#{systemProperties['fhir.lucene.location.dstu2']}" />
<entry key="hibernate.search.lucene_version" value="LUCENE_CURRENT" />
</map>
</property>

View File

@ -17,6 +17,7 @@
classpath:hapi-fhir-server-resourceproviders-dstu1.xml
classpath:hapi-fhir-server-resourceproviders-dstu2.xml
classpath:fhir-spring-subscription-config-dstu2.xml
classpath:fhir-spring-search-config-dstu2.xml
</param-value>
</context-param>

View File

@ -66,6 +66,13 @@ public class JsonParserDstu2Test {
assertThat(encoded, containsString("\"div\":\"" + expected.replace("\"", "\\\"") + "\""));
}
@Test
public void testEncodeEmptyBinary() {
String output = ourCtx.newJsonParser().encodeResourceToString(new Binary());
assertEquals("{\"resourceType\":\"Binary\"}", output);
}
@Test
public void testNamespacePreservationParse() throws Exception {
String input = "{\"resourceType\":\"Patient\",\"text\":{\"div\":\"<xhtml:div xmlns:xhtml=\\\"http://www.w3.org/1999/xhtml\\\"><xhtml:img src=\\\"foo\\\"/>@fhirabend</xhtml:div>\"}}";

View File

@ -124,6 +124,13 @@ public class XmlParserDstu2Test {
}
@Test
public void testEncodeEmptyBinary() {
String output = ourCtx.newXmlParser().encodeResourceToString(new Binary());
assertEquals("<Binary xmlns=\"http://hl7.org/fhir\"/>", output);
}
@Test
public void testContainedResourceInExtensionUndeclared() {
Patient p = new Patient();

View File

@ -170,6 +170,10 @@
number of unneeded dependencies. Thanks to Thomas Andersen
for the pull request!
</action>
<action type="fix">
Fix a crash when encoding a Binary resource in JSON encoding
if the resource has no content-type
</action>
</release>
<release version="1.2" date="2015-09-18">
<action type="add">