From f1efca9f4a1ea6c24340adc3529b456df5f0a057 Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Thu, 30 Oct 2025 10:51:35 -0700 Subject: [PATCH 1/2] Fix flow test failure - int vs long --- .../flow/controllers/attribute/summary.jsp | 6 +-- .../org/labkey/flow/persist/FlowManager.java | 44 ++++--------------- 2 files changed, 9 insertions(+), 41 deletions(-) diff --git a/flow/src/org/labkey/flow/controllers/attribute/summary.jsp b/flow/src/org/labkey/flow/controllers/attribute/summary.jsp index d9d70d82b..86bdd1f30 100644 --- a/flow/src/org/labkey/flow/controllers/attribute/summary.jsp +++ b/flow/src/org/labkey/flow/controllers/attribute/summary.jsp @@ -44,11 +44,7 @@ FlowEntry primary = entry.getKey(); Collection aliases = entry.getValue(); - Map counts = FlowManager.get().getUsageCount(primary._type, primary._rowId); - long totalCount = 0; - for (Number count : counts.values()) - totalCount += count.longValue(); - + Map counts = FlowManager.get().getUsageCount(primary._type, primary._rowId); Number primaryUsages = counts.get(primary._rowId); %> diff --git a/flow/src/org/labkey/flow/persist/FlowManager.java b/flow/src/org/labkey/flow/persist/FlowManager.java index 84e075986..51135dd67 100644 --- a/flow/src/org/labkey/flow/persist/FlowManager.java +++ b/flow/src/org/labkey/flow/persist/FlowManager.java @@ -48,7 +48,6 @@ import org.labkey.api.exp.PropertyDescriptor; import org.labkey.api.exp.api.ExpData; import org.labkey.api.exp.api.ExpSampleType; -import org.labkey.api.exp.api.ExperimentService; import org.labkey.api.exp.query.SamplesSchema; import org.labkey.api.module.ModuleLoader; import org.labkey.api.query.BatchValidationException; @@ -628,7 +627,6 @@ private void updateAttribute(@NotNull Container container, @NotNull FlowEntry en // Update any attribute usages of the current rowId to the new rowId, keeping the original id the same private int updateAttributeValuesPreferredId(@NotNull String containerId, @NotNull AttributeType type, int currentRowId, int newRowId) { - TableInfo attrTable = attributeTable(type); TableInfo valueTable = valueTable(type); String valueTableAttrIdColumn = valueTableAttrIdColumn(type); @@ -741,20 +739,6 @@ public Collection getAliases(final FlowEntry entry) return aliases; } - public Collection getAliasIds(final FlowEntry entry) - { - //_log.info("getAliasIds"); - // Get the attributes that have an id equal to the entry and exclude the entry itself. - TableInfo table = attributeTable(entry._type); - SimpleFilter filter = new SimpleFilter(); - filter.addCondition(table.getColumn("Container"), entry._containerId); - filter.addCondition(table.getColumn("Id"), entry._rowId); - filter.addCondition(table.getColumn("RowId"), entry._rowId, CompareType.NEQ); - TableSelector selector = new TableSelector(table, Collections.singleton("RowId"), filter, null); - - return selector.getArrayList(Integer.class); - } - public Map> getAliases(Container c, final AttributeType type) { TableInfo table = attributeTable(type); @@ -873,13 +857,12 @@ private int deleteUnused(@NotNull Container c, AttributeType type) /** * Get a usage count for an attribute and its aliases. */ - public Map getUsageCount(AttributeType type, int rowId) + public Map getUsageCount(AttributeType type, int rowId) { FlowEntry entry = getAttributeEntry(type, rowId); if (entry == null) return Collections.emptyMap(); - TableInfo attrTable = attributeTable(type); TableInfo valueTable = valueTable(type); String valueTableAttrIdColumn = valueTableAttrIdColumn(type); String valueTableOriginalAttrIdColumn = valueTableOriginalAttrIdColumn(type); @@ -894,7 +877,7 @@ public Map getUsageCount(AttributeType type, int rowId) .append("GROUP BY val.").append(valueTableOriginalAttrIdColumn).append("\n"); SqlSelector selector = new SqlSelector(getSchema(), sql); - return selector.getValueMap(Long.class); + return selector.getValueMap(Integer.class); } /** @@ -913,7 +896,6 @@ public Collection getUsages(FlowEntry entry) if (entry == null) return Collections.emptyList(); - TableInfo attrTable = attributeTable(entry._type); TableInfo valueTable = valueTable(entry._type); String valueTableAttrIdColumn = valueTableAttrIdColumn(entry._type); String valueTableOriginalAttrIdColumn = valueTableOriginalAttrIdColumn(entry._type); @@ -949,7 +931,6 @@ public Map> getAllUsages(AttributeType type, if (entry == null) return Collections.emptyMap(); - TableInfo attrTable = attributeTable(type); TableInfo valueTable = valueTable(type); String valueTableAttrIdColumn = valueTableAttrIdColumn(type); String valueTableOriginalAttrIdColumn = valueTableOriginalAttrIdColumn(type); @@ -1094,15 +1075,6 @@ private void deleteAttributes(SQLFragment sqlObjectIds) } } - public void deleteAttributes(ExpData data) - { - AttrObject obj = getAttrObject(data); - if (obj == null) - return; - deleteAttributes(new Integer[] {obj.getRowId()}); - } - - private void deleteObjectIds(Integer[] oids, Set containers) { DbScope scope = getSchema().getScope(); @@ -1212,7 +1184,7 @@ public void setKeyword(Container c, User user, ExpData data, String keyword, Str String sampleLabel = data.getName(); ensureKeywordName(c, sampleLabel, keyword, true); - AttributeCache.Entry a = AttributeCache.KEYWORDS.byAttribute(c, keyword); + AttributeCache.Entry a = AttributeCache.KEYWORDS.byAttribute(c, keyword); assert a != null : "Expected to find keyword entry for '" + keyword + "'"; int preferredId = a.getAliasedId() == null ? a.getRowId() : a.getAliasedId(); int originalId = a.getRowId(); @@ -1478,7 +1450,7 @@ public int getFCSFileCount(User user, Container container) // count(fcsfile) TableInfo table = schema.getTable(FlowTableType.FCSFiles, null); - List aggregates = Collections.singletonList(new Aggregate("RowId", Aggregate.BaseType.COUNT)); + List aggregates = Collections.singletonList(new Aggregate(FieldKey.fromParts("RowId"), Aggregate.BaseType.COUNT)); List columns = Collections.singletonList(table.getColumn("RowId")); // filter to those wells that were imported from a Keywords run @@ -1489,8 +1461,8 @@ public int getFCSFileCount(User user, Container container) Map> agg = new TableSelector(table, columns, filter, null).getAggregates(aggregates); //TODO: multiple aggregates Aggregate.Result result = agg.get(aggregates.get(0).getColumnName()).get(0); - if (result != null && result.getValue() instanceof Number) - return ((Number)result.getValue()).intValue(); + if (result != null && result.getValue() instanceof Number n) + return n.intValue(); return 0; } @@ -1503,7 +1475,7 @@ public int getFCSFileOnlyRunsCount(User user, Container container) filter.addCondition(FieldKey.fromParts("FCSFileCount"), 0, CompareType.NEQ); filter.addCondition(FieldKey.fromParts("ProtocolStep"), "Keywords", CompareType.EQUAL); TableInfo table = schema.getTable(FlowTableType.Runs, null); - List aggregates = Collections.singletonList(new Aggregate("RowId", Aggregate.BaseType.COUNT)); + List aggregates = Collections.singletonList(new Aggregate(FieldKey.fromParts("RowId"), Aggregate.BaseType.COUNT)); List columns = Collections.singletonList(table.getColumn("RowId")); Map> agg = new TableSelector(table, columns, filter, null).getAggregates(aggregates); Aggregate.Result result = agg.get("RowId").get(0); @@ -1629,7 +1601,7 @@ public void setFileDateForAllFCSFiles(@NotNull Container c, @NotNull User user) final OntologyManager.ImportHelper helper = new OntologyManager.ImportHelper() { @Override - public String beforeImportObject(Map map) throws SQLException + public String beforeImportObject(Map map) { String lsid = (String)map.get("lsid"); assert lsid != null; From 0091ced27b201950768bf4602e182523746591e6 Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Thu, 30 Oct 2025 15:39:57 -0700 Subject: [PATCH 2/2] Switch back to long --- .../flow/controllers/attribute/summary.jsp | 4 ++-- .../org/labkey/flow/persist/FlowManager.java | 18 +++++++++--------- .../org/labkey/flow/persist/PersistTests.java | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/flow/src/org/labkey/flow/controllers/attribute/summary.jsp b/flow/src/org/labkey/flow/controllers/attribute/summary.jsp index 86bdd1f30..533d2b9a2 100644 --- a/flow/src/org/labkey/flow/controllers/attribute/summary.jsp +++ b/flow/src/org/labkey/flow/controllers/attribute/summary.jsp @@ -44,8 +44,8 @@ FlowEntry primary = entry.getKey(); Collection aliases = entry.getValue(); - Map counts = FlowManager.get().getUsageCount(primary._type, primary._rowId); - Number primaryUsages = counts.get(primary._rowId); + Map counts = FlowManager.get().getUsageCount(primary._type, primary._rowId); + Number primaryUsages = counts.get((long)primary._rowId); %> diff --git a/flow/src/org/labkey/flow/persist/FlowManager.java b/flow/src/org/labkey/flow/persist/FlowManager.java index 51135dd67..da086456b 100644 --- a/flow/src/org/labkey/flow/persist/FlowManager.java +++ b/flow/src/org/labkey/flow/persist/FlowManager.java @@ -287,12 +287,12 @@ public Collection getAttributeEntries(@NotNull String containerId, @N public static class FlowEntry implements Comparable { public final AttributeType _type; - public final Integer _rowId; + public final int _rowId; public final String _containerId; public final String _name; - public final Integer _aliasId; + public final int _aliasId; - public FlowEntry(@NotNull AttributeType type, @NotNull Integer rowId, @NotNull String containerId, @NotNull String name, @NotNull Integer aliasId) + public FlowEntry(@NotNull AttributeType type, @NotNull int rowId, @NotNull String containerId, @NotNull String name, @NotNull Integer aliasId) { _type = type; _rowId = rowId; @@ -303,7 +303,7 @@ public FlowEntry(@NotNull AttributeType type, @NotNull Integer rowId, @NotNull S public boolean isAlias() { - return !_rowId.equals(_aliasId); + return _rowId != _aliasId; } @Override @@ -314,7 +314,7 @@ public boolean equals(Object o) FlowEntry flowEntry = (FlowEntry) o; - if (!_rowId.equals(flowEntry._rowId)) return false; + if (_rowId != flowEntry._rowId) return false; if (_type != flowEntry._type) return false; return true; @@ -324,7 +324,7 @@ public boolean equals(Object o) public int hashCode() { int result = _type.hashCode(); - result = 31 * result + _rowId.hashCode(); + result = 31 * result + Integer.hashCode(_rowId); return result; } @@ -547,7 +547,7 @@ private void ensureAlias(@NotNull FlowEntry entry, @NotNull String aliasName, bo return; // If this existing entry is already an alias of entry, do nothing - if (existing._aliasId.equals(entry._rowId)) + if (existing._aliasId == entry._rowId) return; // If this existing entry doesn't have any aliases, we can make this existing entry an alias of the entry. @@ -857,7 +857,7 @@ private int deleteUnused(@NotNull Container c, AttributeType type) /** * Get a usage count for an attribute and its aliases. */ - public Map getUsageCount(AttributeType type, int rowId) + public Map getUsageCount(AttributeType type, int rowId) { FlowEntry entry = getAttributeEntry(type, rowId); if (entry == null) @@ -877,7 +877,7 @@ public Map getUsageCount(AttributeType type, int rowId) .append("GROUP BY val.").append(valueTableOriginalAttrIdColumn).append("\n"); SqlSelector selector = new SqlSelector(getSchema(), sql); - return selector.getValueMap(Integer.class); + return selector.getValueMap(Long.class); } /** diff --git a/flow/src/org/labkey/flow/persist/PersistTests.java b/flow/src/org/labkey/flow/persist/PersistTests.java index 02a0e7867..620af5f60 100644 --- a/flow/src/org/labkey/flow/persist/PersistTests.java +++ b/flow/src/org/labkey/flow/persist/PersistTests.java @@ -140,7 +140,7 @@ public void keywordAliases() throws Exception AttributeCache.KeywordEntry cacheEntry = AttributeCache.KEYWORDS.byName(c, "keyword1"); assertEquals("keyword1", cacheEntry.getAttribute()); assertEquals(c, cacheEntry.getContainer()); - assertEquals(entry._rowId.intValue(), cacheEntry.getRowId()); + assertEquals(entry._rowId, cacheEntry.getRowId()); // verify cached keyword alias Collection cacheAliases = cacheEntry.getAliases();