Fix failing tests

This commit is contained in:
James Agnew 2017-06-30 21:32:01 -04:00
parent 6e181b140d
commit dd7b1b28c2
7 changed files with 44 additions and 34 deletions

View File

@ -119,10 +119,11 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
TagDefinition def = getTagOrNull(TagTypeEnum.TAG, theScheme, theTerm, theLabel);
if (def != null) {
BaseTag newEntity = entity.addTag(def);
if (newEntity.getTagId() == null) {
myEntityManager.persist(newEntity);
myEntityManager.merge(entity);
}
}
ourLog.info("Processed addTag {}/{} on {} in {}ms", new Object[] { theScheme, theTerm, theId, w.getMillisAndRestart() });
}
@ -450,10 +451,12 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
TagDefinition def = getTagOrNull(nextDef.getTagType(), nextDef.getSystem(), nextDef.getCode(), nextDef.getDisplay());
if (def != null) {
BaseTag newEntity = entity.addTag(def);
if (newEntity.getTagId() == null) {
myEntityManager.persist(newEntity);
}
}
}
}
validateMetaCount(entity.getTags().size());

View File

@ -23,16 +23,7 @@ package ca.uhn.fhir.jpa.entity;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.*;
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.model.primitive.IdDt;

View File

@ -39,6 +39,10 @@ public class BaseTag implements Serializable {
@Column(name = "TAG_ID", insertable = false, updatable = false)
private Long myTagId;
public Long getTagId() {
return myTagId;
}
public TagDefinition getTag() {
return myTag;
}
@ -47,5 +51,4 @@ public class BaseTag implements Serializable {
myTag = theTag;
}
}

View File

@ -93,8 +93,13 @@ public class ResourceHistoryTable extends BaseHasResource implements Serializabl
}
@Override
public BaseTag addTag(TagDefinition theDef) {
ResourceHistoryTag historyTag = new ResourceHistoryTag(this, theDef);
public ResourceHistoryTag addTag(TagDefinition theTag) {
for (ResourceHistoryTag next : getTags()) {
if (next.getTag().equals(theTag)) {
return next;
}
}
ResourceHistoryTag historyTag = new ResourceHistoryTag(this, theTag);
getTags().add(historyTag);
return historyTag;
}

View File

@ -250,10 +250,13 @@ public class ResourceTable extends BaseHasResource implements Serializable {
@Override
public ResourceTag addTag(TagDefinition theTag) {
ResourceTag tag = new ResourceTag(this, theTag);
if (!getTags().contains(tag)) {
getTags().add(tag);
for (ResourceTag next : getTags()) {
if (next.getTag().equals(theTag)) {
return next;
}
}
ResourceTag tag = new ResourceTag(this, theTag);
getTags().add(tag);
return tag;
}

View File

@ -78,6 +78,8 @@ public class TagDefinition implements Serializable {
@Enumerated(EnumType.ORDINAL)
private TagTypeEnum myTagType;
private Integer myHashCode;
public TagDefinition() {
}
@ -110,6 +112,7 @@ public class TagDefinition implements Serializable {
public void setCode(String theCode) {
myCode = theCode;
myHashCode = null;
}
public void setDisplay(String theDisplay) {
@ -118,10 +121,12 @@ public class TagDefinition implements Serializable {
public void setSystem(String theSystem) {
mySystem = theSystem;
myHashCode = null;
}
public void setTagType(TagTypeEnum theTagType) {
myTagType = theTagType;
myHashCode = null;
}
public Tag toTag() {
@ -155,15 +160,14 @@ public class TagDefinition implements Serializable {
@Override
public int hashCode() {
if (myHashCode == null) {
HashCodeBuilder b = new HashCodeBuilder();
if (myId != null) {
b.append(myId);
} else {
b.append(myTagType);
b.append(mySystem);
b.append(myCode);
myHashCode = b.toHashCode();
}
return b.toHashCode();
return myHashCode;
}
@Override

View File

@ -100,7 +100,8 @@
</action>
<action type="fix">
Fix a regression in HAPI FHIR 2.5 JPA server where executing a search in a
transaction or batch operation caused an exception.
transaction or batch operation caused an exception. Thanks to Ravi Kuchi for
reporting!
</action>
<action type="fix">
Correct an issue when processing transactions in JPA server where updates and