Skip to content

Commit d8896e4

Browse files
instanceof Integer
probably need a new helpers like isIntegerObject() // instanceof Integer or Long asIntegerOrNull() // null if not isIntegerObject() asLongOrNull() // null if not isIntegerObject()
1 parent 7ae91e0 commit d8896e4

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ else if (serverVal instanceof Date)
494494
Date d = dateFormat.parse(expectations[idx]);
495495
assertEquals("Incorrect value for: " + col + " on row " + i, d, serverVal);
496496
}
497-
else if ((serverVal instanceof Integer || serverVal instanceof Double))
497+
else if ((serverVal instanceof Integer || serverVal instanceof Long || serverVal instanceof Double))
498498
{
499499
double d = Double.parseDouble(expectations[idx]);
500500
assertEquals("Incorrect value for: " + col + " on row " + i, d, Double.parseDouble(serverVal.toString()), DELTA);

laboratory/api-src/org/labkey/api/laboratory/query/ContainerIncrementingTable.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
import java.util.Set;
4242
import java.util.concurrent.Callable;
4343

44+
import static org.labkey.api.exp.api.ExperimentService.asInteger;
45+
4446
/**
4547
* User: bimber
4648
* Date: 3/12/13
@@ -153,6 +155,8 @@ private Integer getInteger(Object value) throws ValidationException
153155
return null;
154156
else if (value instanceof Integer)
155157
return (Integer)value;
158+
else if (value instanceof Long)
159+
return asInteger(value);
156160
else if (value instanceof Double)
157161
return ((Double)value).intValue();
158162
try
@@ -326,9 +330,9 @@ public Object call() throws Exception
326330
Object selfAssignedId = it.getInputColumnValue(inputColMap.get(_incrementingCol));
327331
if (selfAssignedId != null)
328332
{
329-
if (selfAssignedId instanceof Integer)
333+
if (selfAssignedId instanceof Integer || selfAssignedId instanceof Long)
330334
{
331-
rowId = (Integer)selfAssignedId;
335+
rowId = asInteger(selfAssignedId);
332336

333337
if (idGen.hasRowWithId(c, rowId))
334338
_context.getErrors().addRowError(new ValidationException("A record is already present with ID: " + rowId));

0 commit comments

Comments
 (0)