Skip to content
Merged
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
6 changes: 1 addition & 5 deletions flow/src/org/labkey/flow/controllers/attribute/summary.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@
Collection<FlowEntry> aliases = entry.getValue();

Map<Long, Number> counts = FlowManager.get().getUsageCount(primary._type, primary._rowId);
long totalCount = 0;
for (Number count : counts.values())
totalCount += count.longValue();

Number primaryUsages = counts.get(primary._rowId);
Number primaryUsages = counts.get((long)primary._rowId);
%>
<tr>
<td>
Expand Down
54 changes: 13 additions & 41 deletions flow/src/org/labkey/flow/persist/FlowManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -288,12 +287,12 @@ public Collection<FlowEntry> getAttributeEntries(@NotNull String containerId, @N
public static class FlowEntry implements Comparable<FlowEntry>
{
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;
Expand All @@ -304,7 +303,7 @@ public FlowEntry(@NotNull AttributeType type, @NotNull Integer rowId, @NotNull S

public boolean isAlias()
{
return !_rowId.equals(_aliasId);
return _rowId != _aliasId;
}

@Override
Expand All @@ -315,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;
Expand All @@ -325,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;
}

Expand Down Expand Up @@ -548,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.
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -741,20 +739,6 @@ public Collection<FlowEntry> getAliases(final FlowEntry entry)
return aliases;
}

public Collection<Integer> 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<FlowEntry, Collection<FlowEntry>> getAliases(Container c, final AttributeType type)
{
TableInfo table = attributeTable(type);
Expand Down Expand Up @@ -879,7 +863,6 @@ public Map<Long, Number> getUsageCount(AttributeType type, int rowId)
if (entry == null)
return Collections.emptyMap();

TableInfo attrTable = attributeTable(type);
TableInfo valueTable = valueTable(type);
String valueTableAttrIdColumn = valueTableAttrIdColumn(type);
String valueTableOriginalAttrIdColumn = valueTableOriginalAttrIdColumn(type);
Expand Down Expand Up @@ -913,7 +896,6 @@ public Collection<FlowDataObject> 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);
Expand Down Expand Up @@ -949,7 +931,6 @@ public Map<Integer, Collection<FlowDataObject>> 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);
Expand Down Expand Up @@ -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<Container> containers)
{
DbScope scope = getSchema().getScope();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -1478,7 +1450,7 @@ public int getFCSFileCount(User user, Container container)

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

// filter to those wells that were imported from a Keywords run
Expand All @@ -1489,8 +1461,8 @@ public int getFCSFileCount(User user, Container container)
Map<String, List<Aggregate.Result>> 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;
}
Expand All @@ -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<Aggregate> aggregates = Collections.singletonList(new Aggregate("RowId", Aggregate.BaseType.COUNT));
List<Aggregate> aggregates = Collections.singletonList(new Aggregate(FieldKey.fromParts("RowId"), Aggregate.BaseType.COUNT));
List<ColumnInfo> columns = Collections.singletonList(table.getColumn("RowId"));
Map<String, List<Aggregate.Result>> agg = new TableSelector(table, columns, filter, null).getAggregates(aggregates);
Aggregate.Result result = agg.get("RowId").get(0);
Expand Down Expand Up @@ -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<String, Object> map) throws SQLException
public String beforeImportObject(Map<String, Object> map)
{
String lsid = (String)map.get("lsid");
assert lsid != null;
Expand Down
2 changes: 1 addition & 1 deletion flow/src/org/labkey/flow/persist/PersistTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<AttributeCache.KeywordEntry> cacheAliases = cacheEntry.getAliases();
Expand Down