Skip to content

Commit 16ef3a4

Browse files
Fix flow test failure - int vs long (#948)
* Fix flow test failure - int vs long * Switch back to long
1 parent 93c0943 commit 16ef3a4

3 files changed

Lines changed: 15 additions & 47 deletions

File tree

flow/src/org/labkey/flow/controllers/attribute/summary.jsp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@
4545
Collection<FlowEntry> aliases = entry.getValue();
4646
4747
Map<Long, Number> counts = FlowManager.get().getUsageCount(primary._type, primary._rowId);
48-
long totalCount = 0;
49-
for (Number count : counts.values())
50-
totalCount += count.longValue();
51-
52-
Number primaryUsages = counts.get(primary._rowId);
48+
Number primaryUsages = counts.get((long)primary._rowId);
5349
%>
5450
<tr>
5551
<td>

flow/src/org/labkey/flow/persist/FlowManager.java

Lines changed: 13 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import org.labkey.api.exp.PropertyDescriptor;
4949
import org.labkey.api.exp.api.ExpData;
5050
import org.labkey.api.exp.api.ExpSampleType;
51-
import org.labkey.api.exp.api.ExperimentService;
5251
import org.labkey.api.exp.query.SamplesSchema;
5352
import org.labkey.api.module.ModuleLoader;
5453
import org.labkey.api.query.BatchValidationException;
@@ -288,12 +287,12 @@ public Collection<FlowEntry> getAttributeEntries(@NotNull String containerId, @N
288287
public static class FlowEntry implements Comparable<FlowEntry>
289288
{
290289
public final AttributeType _type;
291-
public final Integer _rowId;
290+
public final int _rowId;
292291
public final String _containerId;
293292
public final String _name;
294-
public final Integer _aliasId;
293+
public final int _aliasId;
295294

296-
public FlowEntry(@NotNull AttributeType type, @NotNull Integer rowId, @NotNull String containerId, @NotNull String name, @NotNull Integer aliasId)
295+
public FlowEntry(@NotNull AttributeType type, @NotNull int rowId, @NotNull String containerId, @NotNull String name, @NotNull Integer aliasId)
297296
{
298297
_type = type;
299298
_rowId = rowId;
@@ -304,7 +303,7 @@ public FlowEntry(@NotNull AttributeType type, @NotNull Integer rowId, @NotNull S
304303

305304
public boolean isAlias()
306305
{
307-
return !_rowId.equals(_aliasId);
306+
return _rowId != _aliasId;
308307
}
309308

310309
@Override
@@ -315,7 +314,7 @@ public boolean equals(Object o)
315314

316315
FlowEntry flowEntry = (FlowEntry) o;
317316

318-
if (!_rowId.equals(flowEntry._rowId)) return false;
317+
if (_rowId != flowEntry._rowId) return false;
319318
if (_type != flowEntry._type) return false;
320319

321320
return true;
@@ -325,7 +324,7 @@ public boolean equals(Object o)
325324
public int hashCode()
326325
{
327326
int result = _type.hashCode();
328-
result = 31 * result + _rowId.hashCode();
327+
result = 31 * result + Integer.hashCode(_rowId);
329328
return result;
330329
}
331330

@@ -548,7 +547,7 @@ private void ensureAlias(@NotNull FlowEntry entry, @NotNull String aliasName, bo
548547
return;
549548

550549
// If this existing entry is already an alias of entry, do nothing
551-
if (existing._aliasId.equals(entry._rowId))
550+
if (existing._aliasId == entry._rowId)
552551
return;
553552

554553
// If this existing entry doesn't have any aliases, we can make this existing entry an alias of the entry.
@@ -628,7 +627,6 @@ private void updateAttribute(@NotNull Container container, @NotNull FlowEntry en
628627
// Update any attribute usages of the current rowId to the new rowId, keeping the original id the same
629628
private int updateAttributeValuesPreferredId(@NotNull String containerId, @NotNull AttributeType type, int currentRowId, int newRowId)
630629
{
631-
TableInfo attrTable = attributeTable(type);
632630
TableInfo valueTable = valueTable(type);
633631
String valueTableAttrIdColumn = valueTableAttrIdColumn(type);
634632

@@ -741,20 +739,6 @@ public Collection<FlowEntry> getAliases(final FlowEntry entry)
741739
return aliases;
742740
}
743741

744-
public Collection<Integer> getAliasIds(final FlowEntry entry)
745-
{
746-
//_log.info("getAliasIds");
747-
// Get the attributes that have an id equal to the entry and exclude the entry itself.
748-
TableInfo table = attributeTable(entry._type);
749-
SimpleFilter filter = new SimpleFilter();
750-
filter.addCondition(table.getColumn("Container"), entry._containerId);
751-
filter.addCondition(table.getColumn("Id"), entry._rowId);
752-
filter.addCondition(table.getColumn("RowId"), entry._rowId, CompareType.NEQ);
753-
TableSelector selector = new TableSelector(table, Collections.singleton("RowId"), filter, null);
754-
755-
return selector.getArrayList(Integer.class);
756-
}
757-
758742
public Map<FlowEntry, Collection<FlowEntry>> getAliases(Container c, final AttributeType type)
759743
{
760744
TableInfo table = attributeTable(type);
@@ -879,7 +863,6 @@ public Map<Long, Number> getUsageCount(AttributeType type, int rowId)
879863
if (entry == null)
880864
return Collections.emptyMap();
881865

882-
TableInfo attrTable = attributeTable(type);
883866
TableInfo valueTable = valueTable(type);
884867
String valueTableAttrIdColumn = valueTableAttrIdColumn(type);
885868
String valueTableOriginalAttrIdColumn = valueTableOriginalAttrIdColumn(type);
@@ -913,7 +896,6 @@ public Collection<FlowDataObject> getUsages(FlowEntry entry)
913896
if (entry == null)
914897
return Collections.emptyList();
915898

916-
TableInfo attrTable = attributeTable(entry._type);
917899
TableInfo valueTable = valueTable(entry._type);
918900
String valueTableAttrIdColumn = valueTableAttrIdColumn(entry._type);
919901
String valueTableOriginalAttrIdColumn = valueTableOriginalAttrIdColumn(entry._type);
@@ -949,7 +931,6 @@ public Map<Integer, Collection<FlowDataObject>> getAllUsages(AttributeType type,
949931
if (entry == null)
950932
return Collections.emptyMap();
951933

952-
TableInfo attrTable = attributeTable(type);
953934
TableInfo valueTable = valueTable(type);
954935
String valueTableAttrIdColumn = valueTableAttrIdColumn(type);
955936
String valueTableOriginalAttrIdColumn = valueTableOriginalAttrIdColumn(type);
@@ -1094,15 +1075,6 @@ private void deleteAttributes(SQLFragment sqlObjectIds)
10941075
}
10951076
}
10961077

1097-
public void deleteAttributes(ExpData data)
1098-
{
1099-
AttrObject obj = getAttrObject(data);
1100-
if (obj == null)
1101-
return;
1102-
deleteAttributes(new Integer[] {obj.getRowId()});
1103-
}
1104-
1105-
11061078
private void deleteObjectIds(Integer[] oids, Set<Container> containers)
11071079
{
11081080
DbScope scope = getSchema().getScope();
@@ -1212,7 +1184,7 @@ public void setKeyword(Container c, User user, ExpData data, String keyword, Str
12121184
String sampleLabel = data.getName();
12131185
ensureKeywordName(c, sampleLabel, keyword, true);
12141186

1215-
AttributeCache.Entry a = AttributeCache.KEYWORDS.byAttribute(c, keyword);
1187+
AttributeCache.Entry<?, ?> a = AttributeCache.KEYWORDS.byAttribute(c, keyword);
12161188
assert a != null : "Expected to find keyword entry for '" + keyword + "'";
12171189
int preferredId = a.getAliasedId() == null ? a.getRowId() : a.getAliasedId();
12181190
int originalId = a.getRowId();
@@ -1478,7 +1450,7 @@ public int getFCSFileCount(User user, Container container)
14781450

14791451
// count(fcsfile)
14801452
TableInfo table = schema.getTable(FlowTableType.FCSFiles, null);
1481-
List<Aggregate> aggregates = Collections.singletonList(new Aggregate("RowId", Aggregate.BaseType.COUNT));
1453+
List<Aggregate> aggregates = Collections.singletonList(new Aggregate(FieldKey.fromParts("RowId"), Aggregate.BaseType.COUNT));
14821454
List<ColumnInfo> columns = Collections.singletonList(table.getColumn("RowId"));
14831455

14841456
// filter to those wells that were imported from a Keywords run
@@ -1489,8 +1461,8 @@ public int getFCSFileCount(User user, Container container)
14891461
Map<String, List<Aggregate.Result>> agg = new TableSelector(table, columns, filter, null).getAggregates(aggregates);
14901462
//TODO: multiple aggregates
14911463
Aggregate.Result result = agg.get(aggregates.get(0).getColumnName()).get(0);
1492-
if (result != null && result.getValue() instanceof Number)
1493-
return ((Number)result.getValue()).intValue();
1464+
if (result != null && result.getValue() instanceof Number n)
1465+
return n.intValue();
14941466

14951467
return 0;
14961468
}
@@ -1503,7 +1475,7 @@ public int getFCSFileOnlyRunsCount(User user, Container container)
15031475
filter.addCondition(FieldKey.fromParts("FCSFileCount"), 0, CompareType.NEQ);
15041476
filter.addCondition(FieldKey.fromParts("ProtocolStep"), "Keywords", CompareType.EQUAL);
15051477
TableInfo table = schema.getTable(FlowTableType.Runs, null);
1506-
List<Aggregate> aggregates = Collections.singletonList(new Aggregate("RowId", Aggregate.BaseType.COUNT));
1478+
List<Aggregate> aggregates = Collections.singletonList(new Aggregate(FieldKey.fromParts("RowId"), Aggregate.BaseType.COUNT));
15071479
List<ColumnInfo> columns = Collections.singletonList(table.getColumn("RowId"));
15081480
Map<String, List<Aggregate.Result>> agg = new TableSelector(table, columns, filter, null).getAggregates(aggregates);
15091481
Aggregate.Result result = agg.get("RowId").get(0);
@@ -1629,7 +1601,7 @@ public void setFileDateForAllFCSFiles(@NotNull Container c, @NotNull User user)
16291601
final OntologyManager.ImportHelper helper = new OntologyManager.ImportHelper()
16301602
{
16311603
@Override
1632-
public String beforeImportObject(Map<String, Object> map) throws SQLException
1604+
public String beforeImportObject(Map<String, Object> map)
16331605
{
16341606
String lsid = (String)map.get("lsid");
16351607
assert lsid != null;

flow/src/org/labkey/flow/persist/PersistTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public void keywordAliases() throws Exception
140140
AttributeCache.KeywordEntry cacheEntry = AttributeCache.KEYWORDS.byName(c, "keyword1");
141141
assertEquals("keyword1", cacheEntry.getAttribute());
142142
assertEquals(c, cacheEntry.getContainer());
143-
assertEquals(entry._rowId.intValue(), cacheEntry.getRowId());
143+
assertEquals(entry._rowId, cacheEntry.getRowId());
144144

145145
// verify cached keyword alias
146146
Collection<AttributeCache.KeywordEntry> cacheAliases = cacheEntry.getAliases();

0 commit comments

Comments
 (0)