Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/edu/ku/brc/specify/conversion/BasicSQLUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -1792,12 +1792,20 @@ public static void setData(final PreparedStatement pStmt, final int type, final

case java.sql.Types.REAL:
case java.sql.Types.DOUBLE:
case java.sql.Types.NUMERIC:
case java.sql.Types.DECIMAL:
if (isStr)
{
pStmt.setString(colInx, (String)data);
} else
{
pStmt.setDouble(colInx, (Double)data);
if (data instanceof Number)
{
pStmt.setDouble(colInx, ((Number)data).doubleValue());
} else
{
pStmt.setDouble(colInx, Double.parseDouble(data.toString()));
}
}
break;

Expand Down
54 changes: 50 additions & 4 deletions src/edu/ku/brc/specify/conversion/GenericDBConversion.java
Original file line number Diff line number Diff line change
Expand Up @@ -6369,6 +6369,20 @@ public boolean convertDeterminationRecords()
{
pStmt.setInt(fldInx, getCollectionMemberId());

} else if (newFieldName.matches("Integer[1-5]") ||
newFieldName.matches("Number[1-5]") ||
newFieldName.matches("Text[3-8]") ||
newFieldName.matches("YesNo[3-5]"))
{
FieldMetaData fldMetaData = newFieldMetaData.get(i);
if (fldMetaData != null)
{
pStmt.setNull(fldInx, fldMetaData.getSqlType());
} else
{
pStmt.setObject(fldInx, null);
}

} else
{
Integer index = null;
Expand Down Expand Up @@ -10248,6 +10262,38 @@ protected GeologicTimePeriodTreeDefItem addGtpDefItem(Integer rankCode,
return item;
}

private BigDecimal toBigDecimal(final Object value)
{
if (value == null)
{
return null;
}
if (value instanceof BigDecimal)
{
return (BigDecimal)value;
}
if (value instanceof Number)
{
try
{
return new BigDecimal(value.toString());
} catch (NumberFormatException ex)
{
log.error("Unable to convert numeric value [" + value + "] to BigDecimal", ex);
return null;
}
}

try
{
return new BigDecimal(value.toString());
} catch (NumberFormatException ex)
{
log.error("Unable to convert value [" + value + "] to BigDecimal", ex);
return null;
}
}

/**
* @param tblWriter
* @param treeDef
Expand Down Expand Up @@ -10315,10 +10361,10 @@ public void convertGTP(final TableWriter tblWriter, final GeologicTimePeriodTree
Date creTDate = rs.getDate(7);
Timestamp modT = (modTDate != null) ? new Timestamp(modTDate.getTime()) : null;
Timestamp creT = (creTDate != null) ? new Timestamp(creTDate.getTime()) : null;
BigDecimal upper = new BigDecimal((Double)rs.getObject(8));
BigDecimal uError = new BigDecimal((Double)rs.getObject(9));
BigDecimal lower = new BigDecimal((Double)rs.getObject(10));
BigDecimal lError = new BigDecimal((Double)rs.getObject(11));
BigDecimal upper = toBigDecimal(rs.getObject(8));
BigDecimal uError = toBigDecimal(rs.getObject(9));
BigDecimal lower = toBigDecimal(rs.getObject(10));
BigDecimal lError = toBigDecimal(rs.getObject(11));

if (isEmpty(name))
{
Expand Down
Loading