Skip to content

Commit

Permalink
issue #3437 more unit test coverage for fhir-remote-index
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Arnold <[email protected]>
  • Loading branch information
punktilious committed Jun 4, 2022
1 parent f2687cc commit f44b4cb
Show file tree
Hide file tree
Showing 4 changed files with 461 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

package com.ibm.fhir.database.utils.common;

import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
Expand Down Expand Up @@ -88,6 +89,32 @@ public Long getLong() throws SQLException {
return result;
}

/**
* Get a BigDecimal column value and increment the column index
* @return
* @throws SQLException
*/
public BigDecimal getBigDecimal() throws SQLException {
BigDecimal result = rs.getBigDecimal(index++);
if (rs.wasNull()) {
result = null;
}
return result;
}

/**
* Get a Double column value and increment the column index
* @return
* @throws SQLException
*/
public Double getDouble() throws SQLException {
Double result = rs.getDouble(index++);
if (rs.wasNull()) {
result = null;
}
return result;
}

/**
* Get a Timestamp column value and increment the column index
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,10 @@ public void process(String requestShard, String resourceType, String logicalId,
dao.addString(logicalResourceId, parameterNameValue.getParameterNameId(), parameter.getValue(), parameter.getValue().toLowerCase(), parameter.getCompositeId());

if (parameter.isSystemParam()) {
systemDao.addString(logicalResourceId, parameterNameValue.getParameterNameId(), parameter.getValue(), parameter.getValue().toLowerCase(), parameter.getCompositeId());
systemDao.addString(logicalResourceId, parameterNameValue.getParameterNameId(), parameter.getValue(), parameter.getValue().toLowerCase());
}
} catch (SQLException x) {
logger.log(Level.SEVERE, "StringParameter", x);
throw new FHIRPersistenceException("Failed inserting string params for '" + resourceType + "'");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
import java.util.Calendar;

import com.ibm.fhir.database.utils.common.CalendarHelper;
Expand Down Expand Up @@ -131,32 +130,16 @@ public void close() {
}
}

/**
* Set the compositeId on the given PreparedStatement, handling a value if necessary
* @param ps
* @param index
* @param compositeId
* @throws SQLException
*/
private void setComposite(PreparedStatement ps, int index, Integer compositeId) throws SQLException {
if (compositeId != null) {
ps.setInt(index, compositeId);
} else {
ps.setNull(index, Types.INTEGER);
}
}

/**
* Add a string parameter value to the whole-system batch statement
*
* @param logicalResourceId
* @param parameterNameId
* @param strValue
* @param strValueLower
* @param compositeId
* @throws SQLException
*/
public void addString(long logicalResourceId, int parameterNameId, String strValue, String strValueLower, Integer compositeId) throws SQLException {
public void addString(long logicalResourceId, int parameterNameId, String strValue, String strValueLower) throws SQLException {
// System level string attributes
if (systemStrings == null) {
final String insertSystemString = "INSERT INTO str_values (parameter_name_id, str_value, str_value_lcase, logical_resource_id) VALUES (?,?,?,?)";
Expand All @@ -166,7 +149,6 @@ public void addString(long logicalResourceId, int parameterNameId, String strVal
systemStrings.setString(2, strValue);
systemStrings.setString(3, strValueLower);
systemStrings.setLong(4, logicalResourceId);
setComposite(systemStrings, 5, compositeId);
systemStrings.addBatch();
systemStringCount++;
}
Expand Down Expand Up @@ -242,7 +224,7 @@ public void addProfile(long logicalResourceId, long canonicalId, String version,
* @throws SQLException
*/
public void addSecurity(long logicalResourceId, long commonTokenValueId) throws SQLException {
if (systemTags == null) {
if (systemSecurity == null) {
final String INS = "INSERT INTO logical_resource_security(common_token_value_id, logical_resource_id) VALUES (?,?)";
systemSecurity = connection.prepareStatement(INS);
}
Expand Down
Loading

0 comments on commit f44b4cb

Please sign in to comment.