Skip to content

Commit 7615619

Browse files
authored
Fix data region column name references (#2526)
Remove unnecessary logging parameters from CustomizeView Update CustomizeView to use FieldKey Fix data region column name references
1 parent abecd65 commit 7615619

21 files changed

+218
-289
lines changed

src/org/labkey/test/components/CustomizeView.java

Lines changed: 74 additions & 154 deletions
Large diffs are not rendered by default.

src/org/labkey/test/params/FieldKey.java

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,30 @@ public final class FieldKey implements CharSequence, WrapsFieldKey
1515
private static final String[] ILLEGAL = {"$", "/", "&", "}", "~", ",", "."};
1616
private static final String[] REPLACEMENT = {"$D", "$S", "$A", "$B", "$T", "$C", "$P"};
1717

18-
public static final FieldKey EMPTY = new FieldKey(""); // Useful as a sort of FieldKey builder starting point
19-
public static final FieldKey SOURCES_FK = new FieldKey("DataInputs");
20-
public static final FieldKey PARENTS_FK = new FieldKey("MaterialInputs");
18+
public static final FieldKey EMPTY = new FieldKey(null, ""); // Useful as a sort of FieldKey builder starting point
19+
public static final FieldKey SOURCES_FK = FieldKey.fromParts("DataInputs");
20+
public static final FieldKey PARENTS_FK = FieldKey.fromParts("MaterialInputs");
2121

2222
private static final String SEPARATOR = "/";
2323

2424
private final FieldKey _parent;
2525
private final String _name;
2626
private final String _fieldKey;
2727

28-
private FieldKey(String name)
29-
{
30-
_parent = null;
31-
_name = name;
32-
_fieldKey = encodePart(name);
33-
}
34-
3528
private FieldKey(FieldKey parent, String child)
3629
{
37-
_parent = parent;
38-
_name = parent.getName() + SEPARATOR + child;
39-
_fieldKey = parent + SEPARATOR + encodePart(child);
30+
if (parent != null && !parent.isEmpty())
31+
{
32+
_parent = parent;
33+
_name = parent.getName() + SEPARATOR + child;
34+
_fieldKey = parent + SEPARATOR + encodePart(child);
35+
}
36+
else
37+
{
38+
_parent = null;
39+
_name = child;
40+
_fieldKey = encodePart(child);
41+
}
4042
}
4143

4244
public static List<String> getIllegalChars()
@@ -46,14 +48,7 @@ public static List<String> getIllegalChars()
4648

4749
public static FieldKey fromParts(List<String> parts)
4850
{
49-
FieldKey fieldKey = EMPTY;
50-
51-
for (String part : parts)
52-
{
53-
fieldKey = fieldKey.child(part);
54-
}
55-
56-
return fieldKey;
51+
return EMPTY.child(parts);
5752
}
5853

5954
public static FieldKey fromParts(String... parts)
@@ -113,19 +108,23 @@ public FieldKey getParent()
113108
return _parent;
114109
}
115110

116-
public FieldKey child(String part)
111+
public FieldKey child(String... parts)
117112
{
118-
if (StringUtils.isBlank(part))
119-
throw new IllegalArgumentException("FieldKey can't have blank part(s): " + this);
113+
return child(Arrays.asList(parts));
114+
}
120115

121-
if (StringUtils.isBlank(getName()))
122-
{
123-
return new FieldKey(part);
124-
}
125-
else
116+
public FieldKey child(List<String> parts)
117+
{
118+
FieldKey child = this;
119+
120+
for (String part : parts)
126121
{
127-
return new FieldKey(this, part);
122+
if (StringUtils.isBlank(part))
123+
throw new IllegalArgumentException("FieldKey can't have blank part(s): " + parts);
124+
125+
child = new FieldKey(child, part);
128126
}
127+
return child;
129128
}
130129

131130
public Iterator<FieldKey> getIterator()

src/org/labkey/test/tests/ButtonCustomizationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public void testSteps()
188188
Locator.lkButton(METADATA_LINK_BUTTON).waitForElement(getDriver(), WAIT_FOR_JAVASCRIPT)
189189
.getAttribute("class").contains("labkey-disabled-button"));
190190

191-
buttonRegion.checkCheckbox(buttonRegion.getRowIndex("Portland", "Name"));
191+
buttonRegion.checkCheckbox(buttonRegion.getRowIndex("Name", "Portland"));
192192
// wait for the button to enable:
193193
waitForElement(Locator.lkButton(METADATA_LINK_BUTTON), 10000);
194194

src/org/labkey/test/tests/ContainerContextTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.labkey.test.categories.Data;
3636
import org.labkey.test.pages.reports.ScriptReportPage;
3737
import org.labkey.test.params.FieldDefinition;
38+
import org.labkey.test.params.FieldKey;
3839
import org.labkey.test.params.list.IntListDefinition;
3940
import org.labkey.test.util.DataRegionTable;
4041
import org.labkey.test.util.Ext4Helper;
@@ -177,7 +178,7 @@ public void testListLookupURL() throws Exception
177178

178179
log("** Adding in lookup list columns to grid");
179180
_customizeViewsHelper.openCustomizeViewPanel();
180-
_customizeViewsHelper.addColumn(new String[] { "ListLookup", "LookupAge" });
181+
_customizeViewsHelper.addColumn(FieldKey.fromParts("ListLookup", "LookupAge"));
181182
_customizeViewsHelper.saveCustomView();
182183

183184
log("** Checking URLs go to correct container...");

src/org/labkey/test/tests/CustomizeViewTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ private void saveAfterApplyingView(String name, String newColumnLabel, String ne
300300
@Test
301301
public void saveFilterTest()
302302
{
303-
String fieldKey = FieldKey.fromParts(LAST_NAME_COLUMN).toString();
303+
FieldKey fieldKey = FieldKey.fromParts(LAST_NAME_COLUMN);
304304
String op = "Starts With";
305305
String value = "J";
306306
String[] viewNames = {TRICKY_CHARACTERS + "view", "AAC", "aaa", "aad", "zzz"};
@@ -309,7 +309,7 @@ public void saveFilterTest()
309309
for(String name : viewNames)
310310
{
311311
_customizeViewsHelper.openCustomizeViewPanel();
312-
_customizeViewsHelper.addFilter(new String[]{fieldKey}, fieldKey, op, value);
312+
_customizeViewsHelper.addFilter(fieldKey, op, value);
313313
_customizeViewsHelper.saveCustomView(name);
314314
}
315315

@@ -350,7 +350,7 @@ private void setColumns(String... columnNames)
350350
private void addFilter(String columnName, String op, String value)
351351
{
352352
_customizeViewsHelper.openCustomizeViewPanel();
353-
_customizeViewsHelper.addFilter(FieldKey.fromParts(columnName).toString(), columnName, op, value);
353+
_customizeViewsHelper.addFilter(FieldKey.fromParts(columnName).toString(), op, value);
354354
_customizeViewsHelper.applyCustomView();
355355
}
356356

src/org/labkey/test/tests/DataReportsTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public void doQueryReportTests()
191191
clickAndWait(Locator.linkWithText("AE-1:(VTN) AE Log"));
192192
DataRegionTable dataSetTable = new DataRegionTable("Dataset", getDriver());
193193
dataSetTable.openCustomizeGrid();
194-
_customizeViewsHelper.addFilter("MouseId", "Mouse Id", "Equals One Of", String.join(";", PTIDS_FOR_CUSTOM_VIEW));
194+
_customizeViewsHelper.addFilter("MouseId", "Equals One Of", String.join(";", PTIDS_FOR_CUSTOM_VIEW));
195195
_customizeViewsHelper.saveCustomView(QUERY_REPORT_VIEW_NAME_2);
196196

197197
goToManageViews().clickAddReport("Query Report");
@@ -337,8 +337,8 @@ public void doRReportsTest()
337337
DataRegionTable dataSetTable = new DataRegionTable("Dataset", getDriver());
338338
dataSetTable.openCustomizeGrid();
339339
_customizeViewsHelper.removeColumn(R_REMCOL);
340-
_customizeViewsHelper.addFilter("DEMhisp", "3.Latino\\a or Hispanic?", "Does Not Equal", "Yes");
341-
_customizeViewsHelper.addSort(R_SORT, "2.What is your sex?", SortDirection.DESC);
340+
_customizeViewsHelper.addFilter("DEMhisp", "Does Not Equal", "Yes");
341+
_customizeViewsHelper.addSort(R_SORT, SortDirection.DESC);
342342
_customizeViewsHelper.saveCustomView("Custom Query View");
343343

344344
log("Check that customize view worked");

src/org/labkey/test/tests/FlagColumnTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.labkey.test.categories.Assays;
1313
import org.labkey.test.categories.Daily;
1414
import org.labkey.test.params.FieldDefinition;
15+
import org.labkey.test.params.FieldKey;
1516
import org.labkey.test.util.DataRegionTable;
1617
import org.labkey.test.util.RelativeUrl;
1718

@@ -116,9 +117,9 @@ private void doInit()
116117
clickAndWait(Locator.linkWithText("view results"));
117118
var customizeView = _customizeViewsHelper.openCustomizeViewPanel();
118119
customizeView.showHiddenItems();
119-
customizeView.addColumn(new String[] { "Run" });
120-
customizeView.addColumn(new String[] { "Run", RUN_FLAG});
121-
customizeView.addColumn(new String[] { "Run", "AnotherRunFlag" });
120+
customizeView.addColumn(FieldKey.fromParts("Run"));
121+
customizeView.addColumn(FieldKey.fromParts("Run", RUN_FLAG));
122+
customizeView.addColumn(FieldKey.fromParts("Run", "AnotherRunFlag"));
122123
customizeView.addSort("RowId", SortDirection.ASC);
123124
customizeView.saveCustomView();
124125

src/org/labkey/test/tests/InlineImagesAssayTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.labkey.test.components.CustomizeView;
3131
import org.labkey.test.pages.ReactAssayDesignerPage;
3232
import org.labkey.test.params.FieldDefinition;
33+
import org.labkey.test.params.FieldKey;
3334
import org.labkey.test.util.DataRegionExportHelper;
3435
import org.labkey.test.util.DataRegionTable;
3536
import org.labkey.test.util.ExcelHelper;
@@ -177,8 +178,8 @@ public final void testAssayInlineImages() throws Exception
177178
DataRegionTable list = new DataRegionTable("Data", getDriver());
178179
CustomizeView customizeView = list.openCustomizeGrid();
179180
customizeView.showHiddenItems();
180-
customizeView.addColumn(new String[]{"Run", "RowId"});
181-
customizeView.addColumn(new String[]{"Run", "Protocol", "RowId"});
181+
customizeView.addColumn(FieldKey.fromParts("Run", "RowId"));
182+
customizeView.addColumn(FieldKey.fromParts("Run", "Protocol", "RowId"));
182183
customizeView.applyCustomView();
183184
var protocolId = list.getDataAsText(0, "Run/Protocol/RowId");
184185
var runId = list.getDataAsText(0, "Run/RowId");

src/org/labkey/test/tests/SampleTypeLineageTest.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.labkey.test.categories.Daily;
1818
import org.labkey.test.components.ext4.Window;
1919
import org.labkey.test.params.FieldDefinition;
20+
import org.labkey.test.params.FieldKey;
2021
import org.labkey.test.params.experiment.DataClassDefinition;
2122
import org.labkey.test.params.experiment.SampleTypeDefinition;
2223
import org.labkey.test.util.DataRegionTable;
@@ -383,7 +384,7 @@ public void testUpdateLineageUsingFileImport()
383384

384385
log("Check that the imported data is as expected.");
385386
DataRegionTable dataRegionTable = new DataRegionTable("Material", this);
386-
int row = dataRegionTable.getRowIndex(testSample, "Name");
387+
int row = dataRegionTable.getRowIndex("Name", testSample);
387388
String data = dataRegionTable.getDataAsText(row, columnName);
388389
checker().verifyEquals("Something doesn't look right. Value for column not as expected.",
389390
testData, data);
@@ -406,7 +407,7 @@ public void testUpdateLineageUsingFileImport()
406407

407408
log("Check that the updated data is shown.");
408409
dataRegionTable = new DataRegionTable("Material", this);
409-
row = dataRegionTable.getRowIndex(testSample, "Name");
410+
row = dataRegionTable.getRowIndex("Name", testSample);
410411
data = dataRegionTable.getDataAsText(row, columnName);
411412
checker().verifyEquals("Value for column not updated as expected.",
412413
updatedTestData, data);
@@ -459,7 +460,7 @@ public void testLineageWithThreeGenerations()
459460
DataRegionTable table = sampleHelper.getSamplesDataRegionTable();
460461
table.openCustomizeGrid();
461462
_customizeViewsHelper.showHiddenItems();
462-
_customizeViewsHelper.addColumn(new String[]{"Inputs", "Materials", parentSampleType});
463+
_customizeViewsHelper.addColumn(FieldKey.fromParts("Inputs", "Materials", parentSampleType));
463464
_customizeViewsHelper.applyCustomView();
464465
waitAndClickAndWait(Locator.linkWithText("SampleSetBVT4"));
465466

@@ -652,7 +653,7 @@ public void testDeriveSampleByUI() throws CommandException, IOException
652653

653654
for(String parent : parents)
654655
{
655-
int index = drt.getRowIndex(parent, "Name");
656+
int index = drt.getRowIndex("Name", parent);
656657
drt.checkCheckbox(index);
657658
}
658659

@@ -1129,7 +1130,7 @@ public void testDeleteSamplesSomeWithDerivedSamples()
11291130
sampleHelper.createSampleType(new SampleTypeDefinition(SAMPLE_TYPE_NAME), sampleData);
11301131
DataRegionTable drtSamples = sampleHelper.getSamplesDataRegionTable();
11311132
log("Derive one sample from another");
1132-
drtSamples.checkCheckbox(drtSamples.getRowIndex(parentSampleNames.get(0), "Name"));
1133+
drtSamples.checkCheckbox(drtSamples.getRowIndex("Name", parentSampleNames.get(0)));
11331134
clickButton("Derive Samples");
11341135
waitAndClickAndWait(Locator.lkButton("Next"));
11351136
String childName = parentSampleNames.get(0) + ".1";
@@ -1145,8 +1146,8 @@ public void testDeleteSamplesSomeWithDerivedSamples()
11451146

11461147
log("Derive a sample with two parents");
11471148
clickAndWait(Locator.linkContainingText(SAMPLE_TYPE_NAME));
1148-
drtSamples.checkCheckbox(drtSamples.getRowIndex(parentSampleNames.get(1), "Name"));
1149-
drtSamples.checkCheckbox(drtSamples.getRowIndex(childName, "Name"));
1149+
drtSamples.checkCheckbox(drtSamples.getRowIndex("Name", parentSampleNames.get(1)));
1150+
drtSamples.checkCheckbox(drtSamples.getRowIndex("Name", childName));
11501151
clickButton("Derive Samples");
11511152
waitAndClickAndWait(Locator.lkButton("Next"));
11521153
String twoParentChildName = parentSampleNames.get(1) + "+" + childName + ".1";
@@ -1156,14 +1157,14 @@ public void testDeleteSamplesSomeWithDerivedSamples()
11561157
clickAndWait(Locator.linkContainingText(SAMPLE_TYPE_NAME));
11571158

11581159
log("Try to delete parent sample");
1159-
drtSamples.checkCheckbox(drtSamples.getRowIndex(parentSampleNames.get(0), "Name"));
1160+
drtSamples.checkCheckbox(drtSamples.getRowIndex("Name", parentSampleNames.get(0)));
11601161
drtSamples.clickHeaderButton("Delete");
11611162
Window.Window(getDriver()).withTitle("No samples can be deleted").waitFor()
11621163
.clickButton("Dismiss", true);
11631164

11641165
log("Try to delete multiple parent samples");
1165-
drtSamples.checkCheckbox(drtSamples.getRowIndex(parentSampleNames.get(1), "Name"));
1166-
drtSamples.checkCheckbox(drtSamples.getRowIndex(childName, "Name"));
1166+
drtSamples.checkCheckbox(drtSamples.getRowIndex("Name", parentSampleNames.get(1)));
1167+
drtSamples.checkCheckbox(drtSamples.getRowIndex("Name", childName));
11671168
drtSamples.clickHeaderButton("Delete");
11681169
Window.Window(getDriver()).withTitle("No samples can be deleted").waitFor()
11691170
.clickButton("Dismiss", true);
@@ -1172,21 +1173,21 @@ public void testDeleteSamplesSomeWithDerivedSamples()
11721173
assertEquals("No selection should remain", 0, drtSamples.getSelectedCount());
11731174

11741175
log("Try to delete parent and child");
1175-
drtSamples.checkCheckbox(drtSamples.getRowIndex(parentSampleNames.get(1), "Name"));
1176-
drtSamples.checkCheckbox(drtSamples.getRowIndex(twoParentChildName, "Name"));
1176+
drtSamples.checkCheckbox(drtSamples.getRowIndex("Name", parentSampleNames.get(1)));
1177+
drtSamples.checkCheckbox(drtSamples.getRowIndex("Name", twoParentChildName));
11771178
assertEquals("Parent and child should be checked", 2, drtSamples.getCheckedCount());
11781179
assertEquals("Parent and child should be checked", 2, drtSamples.getSelectedCount());
11791180

11801181
sampleHelper.deleteSamples(drtSamples, "Permanently delete 1 sample");
1181-
assertEquals("Deleted sample " + twoParentChildName + " still appears in grid", -1, drtSamples.getRowIndex(twoParentChildName, "Name"));
1182-
assertTrue("Parent sample " + parentSampleNames.get(1) + " does not appears in grid", drtSamples.getRowIndex(parentSampleNames.get(1), "Name") > -1);
1182+
assertEquals("Deleted sample " + twoParentChildName + " still appears in grid", -1, drtSamples.getRowIndex("Name", twoParentChildName));
1183+
assertTrue("Parent sample " + parentSampleNames.get(1) + " does not appears in grid", drtSamples.getRowIndex("Name", parentSampleNames.get(1)) > -1);
11831184
assertEquals("Only parent sample should be checked", 1, drtSamples.getCheckedCount());
11841185
assertEquals("Only parent sample should be checked", 1, drtSamples.getSelectedCount());
11851186

11861187
log("Now that the child is gone, try to delete the parent");
11871188
sampleHelper.deleteSamples(drtSamples, "Permanently delete 1 sample");
11881189

1189-
assertEquals("Deleted sample " + parentSampleNames.get(1) + " still appears in grid", -1, drtSamples.getRowIndex(parentSampleNames.get(1), "Name"));
1190+
assertEquals("Deleted sample " + parentSampleNames.get(1) + " still appears in grid", -1, drtSamples.getRowIndex("Name", parentSampleNames.get(1)));
11901191
assertEquals("No selection should remain", 0, drtSamples.getCheckedCount());
11911192

11921193
log("Now try to delete what's left, in several hitches");

0 commit comments

Comments
 (0)