Type migration to boxed integer to avoid int defaulting to 0
This commit is contained in:
parent
34d5925393
commit
3b41b5b960
|
@ -176,15 +176,15 @@ public class PredicateBuilderDate extends BasePredicateBuilder implements IPredi
|
|||
lb = theBuilder.greaterThan(theFrom.get("myValueHigh"), upperBoundInstant);
|
||||
}
|
||||
} else if (operation == SearchFilterParser.CompareOperation.ge) {
|
||||
if (lowerBoundInstant == null) {
|
||||
throw new InvalidRequestException("lowerBound value not correctly specified for compare operation");
|
||||
}
|
||||
if (isOrdinalComparison) {
|
||||
lb = theBuilder.greaterThanOrEqualTo(theFrom.get("myValueLowDateOrdinal"), theRange.getLowerBoundAsDateInteger());
|
||||
} else {
|
||||
lb = theBuilder.greaterThanOrEqualTo(theFrom.get("myValueLow"), lowerBoundInstant);
|
||||
}
|
||||
} else if (operation == SearchFilterParser.CompareOperation.ne) {
|
||||
if (lowerBoundInstant == null) {
|
||||
throw new InvalidRequestException("lowerBound value not correctly specified for compare operation");
|
||||
}
|
||||
if (isOrdinalComparison) {
|
||||
lb = theBuilder.greaterThanOrEqualTo(theFrom.get("myValueLowDateOrdinal"), theRange.getLowerBoundAsDateInteger());
|
||||
} else {
|
||||
lb = theBuilder.greaterThanOrEqualTo(theFrom.get("myValueLow"), lowerBoundInstant);
|
||||
}
|
||||
} else if (operation == SearchFilterParser.CompareOperation.ne) {
|
||||
if ((lowerBoundInstant == null) ||
|
||||
(upperBoundInstant == null)) {
|
||||
throw new InvalidRequestException("lowerBound and/or upperBound value not correctly specified for compare operation");
|
||||
|
@ -224,6 +224,7 @@ public class PredicateBuilderDate extends BasePredicateBuilder implements IPredi
|
|||
gt = theBuilder.lessThanOrEqualTo(theFrom.get("myValueLow"), upperBoundInstant);
|
||||
lt = theBuilder.lessThanOrEqualTo(theFrom.get("myValueHigh"), upperBoundInstant);
|
||||
}
|
||||
|
||||
if (theRange.getUpperBound().getPrefix() == ParamPrefixEnum.ENDS_BEFORE || theRange.getUpperBound().getPrefix() == ParamPrefixEnum.EQUAL) {
|
||||
ub = lt;
|
||||
} else {
|
||||
|
|
|
@ -68,6 +68,7 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
|
|||
version.onTable("HFJ_RES_VER").dropColumn("20200218.2", "FORCED_ID_PID");
|
||||
version.onTable("HFJ_RES_VER").addForeignKey("20200218.3", "FK_RESOURCE_HISTORY_RESOURCE").toColumn("RES_ID").references("HFJ_RESOURCE", "RES_ID");
|
||||
version.onTable("HFJ_RES_VER").modifyColumn("20200220.1", "RES_ID").nonNullable().failureAllowed().withType(BaseTableColumnTypeTask.ColumnTypeEnum.LONG);
|
||||
//
|
||||
}
|
||||
|
||||
protected void init420() { // 20191015 - 20200217
|
||||
|
|
|
@ -29,12 +29,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.apache.commons.lang3.time.DateUtils;
|
||||
import org.hibernate.search.annotations.Field;
|
||||
import org.hl7.fhir.r4.model.DateTimeType;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
@Embeddable
|
||||
|
@ -57,10 +55,15 @@ public class ResourceIndexedSearchParamDate extends BaseResourceIndexedSearchPar
|
|||
@Field
|
||||
public Date myValueLow;
|
||||
|
||||
/**
|
||||
* Field which stores an integer representation of YYYYMDD as calculated by Calendar
|
||||
* e.g. 2019-01-20 -> 2019020
|
||||
* (note that the month is 0 since calendar month counting starts at 0.
|
||||
*/
|
||||
@Column(name="SP_VALUE_LOW_DATE_ORDINAL")
|
||||
public int myValueLowDateOrdinal;
|
||||
public Integer myValueLowDateOrdinal;
|
||||
@Column(name="SP_VALUE_HIGH_DATE_ORDINAL")
|
||||
public int myValueHighDateOrdinal;
|
||||
public Integer myValueHighDateOrdinal;
|
||||
|
||||
@Transient
|
||||
private transient String myOriginalValue;
|
||||
|
@ -99,13 +102,7 @@ public class ResourceIndexedSearchParamDate extends BaseResourceIndexedSearchPar
|
|||
this.myValueHighDateOrdinal = generateOrdinalDateInteger(theHigh);
|
||||
}
|
||||
private int generateOrdinalDateInteger(Date theDate) {
|
||||
Calendar calendar = DateUtils.toCalendar(theDate);
|
||||
String ordinalDateString = new StringBuilder()
|
||||
.append(calendar.get(Calendar.YEAR))
|
||||
.append(calendar.get(Calendar.MONTH))
|
||||
.append(calendar.get(Calendar.DAY_OF_MONTH))
|
||||
.toString();
|
||||
return Integer.parseInt(ordinalDateString);
|
||||
return ca.uhn.fhir.util.DateUtils.convertDatetoDayInteger(theDate);
|
||||
}
|
||||
|
||||
private void computeValueLowDateOrdinal(Date theLow) {
|
||||
|
|
Loading…
Reference in New Issue