mirror of
https://github.com/Wisser/Jailer.git
synced 2026-05-17 19:38:47 -05:00
fix(ui): select a predictable first table on startup
previously map.values.iterator.next was selecting a random table
This commit is contained in:
@@ -37,11 +37,13 @@ import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -304,6 +306,18 @@ public class DataModel {
|
||||
return tables.values();
|
||||
}
|
||||
|
||||
/**
|
||||
* When starting UI we need to pick a table to get selected at first, in a stable way.
|
||||
* Alphabetically first table sounds good and deterministic.
|
||||
*/
|
||||
public Optional<Table> firstTable() {
|
||||
if (MapUtils.isEmpty(tables)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
return tables.keySet().stream().sorted().findFirst().map(tables::get);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads in <code>table.csv</code> and <code>association.csv</code>
|
||||
* and builds the relational data model.
|
||||
|
||||
@@ -198,7 +198,7 @@ public class ExtractionModel {
|
||||
public ExtractionModel(DataModel dataModel, ExecutionContext executionContext) {
|
||||
this.dataModel = dataModel;
|
||||
this.version = null;
|
||||
subject = dataModel.getTables().iterator().hasNext()? dataModel.getTables().iterator().next() : null;
|
||||
subject = dataModel.firstTable().orElse(null);
|
||||
condition = "";
|
||||
dataModel.setRestrictionModel(new RestrictionModel(dataModel, executionContext));
|
||||
dataModel.deriveFilters();
|
||||
|
||||
Reference in New Issue
Block a user