Skip to content

Commit bc5f60e

Browse files
committed
Merge remote-tracking branch 'origin/develop' into fb_aliasDupes
2 parents a9396ae + 5078dc0 commit bc5f60e

8 files changed

Lines changed: 57 additions & 65 deletions

File tree

api/src/org/labkey/api/jsp/JspBase.java

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ public HtmlString checked(boolean checked)
345345
}
346346

347347

348-
private static final HtmlString SELECTED = HtmlString.of(" selected");
348+
private static final HtmlString SELECTED = h(" selected");
349349

350350
/** Returns " selected" (if true) or "" (false) */
351351
public HtmlString selected(boolean selected)
@@ -359,22 +359,15 @@ public HtmlString selected(Object a, Object b)
359359
return selected(Objects.equals(a,b));
360360
}
361361

362-
/** Returns " selected" (if a.equals(b)) */
363-
public HtmlString selectedEq(Object a, Object b)
364-
{
365-
return selected(null==a ? null==b : a.equals(b));
366-
}
367-
368-
369-
private static final HtmlString DISABLED = HtmlString.of(" disabled");
362+
private static final HtmlString DISABLED = h(" disabled");
370363

371364
/** Returns " disabled" (if true) or "" (false) */
372365
public HtmlString disabled(boolean disabled)
373366
{
374367
return disabled ? DISABLED : EMPTY_STRING;
375368
}
376369

377-
private static final HtmlString READ_ONLY = HtmlString.of(" readonly");
370+
private static final HtmlString READ_ONLY = h(" readonly");
378371

379372
/** Returns " readonly" (if true) or "" (false) */
380373
public HtmlString readonly(boolean readOnly)
@@ -383,8 +376,8 @@ public HtmlString readonly(boolean readOnly)
383376
}
384377

385378

386-
private static final HtmlString ALTERNATE_ROW = HtmlString.of("labkey-alternate-row");
387-
private static final HtmlString ROW = HtmlString.of("labkey-row");
379+
private static final HtmlString ALTERNATE_ROW = h("labkey-alternate-row");
380+
private static final HtmlString ROW = h("labkey-row");
388381

389382
// Returns "labkey-alternate-row" (true) or "labkey-row" (false)
390383
public HtmlString getShadeRowClass(boolean shade)
@@ -580,25 +573,25 @@ public HtmlString helpLink(String helpTopic, String displayText)
580573
// Format date using the container-configured date format and HTML filter the result
581574
public HtmlString formatDate(Date date)
582575
{
583-
return HtmlString.of(null == date ? "" : DateUtil.formatDate(getContainer(), date));
576+
return h(null == date ? "" : DateUtil.formatDate(getContainer(), date));
584577
}
585578

586579
// Format LocalDate using the container-configured date format and HTML filter the result
587580
public HtmlString formatDate(LocalDate date)
588581
{
589-
return HtmlString.of(null == date ? "" : DateUtil.formatDate(getContainer(), date));
582+
return h(null == date ? "" : DateUtil.formatDate(getContainer(), date));
590583
}
591584

592585
// Format date & time using the container-configured date & time format and HTML filter the result
593586
public HtmlString formatDateTime(Date date)
594587
{
595-
return HtmlString.of(null == date ? "" : DateUtil.formatDateTime(getContainer(), date));
588+
return h(null == date ? "" : DateUtil.formatDateTime(getContainer(), date));
596589
}
597590

598591
// Format date & time using the specified date & time format and HTML filter the result
599592
public HtmlString formatDateTime(Date date, String pattern)
600593
{
601-
return HtmlString.of(null == date ? "" : DateUtil.formatDateTime(date, pattern));
594+
return h(null == date ? "" : DateUtil.formatDateTime(date, pattern));
602595
}
603596

604597
public String getMessage(ObjectError e)
@@ -616,7 +609,7 @@ public String getMessage(ObjectError e)
616609

617610
public Errors getErrors(String bean)
618611
{
619-
return (Errors)getViewContext().getRequest().getAttribute(BindingResult.MODEL_KEY_PREFIX + bean);
612+
return (Errors)getViewContext().getRequestOrThrow().getAttribute(BindingResult.MODEL_KEY_PREFIX + bean);
620613
}
621614

622615
protected List<ObjectError> _getErrorsForPath(String path)
@@ -696,7 +689,7 @@ public List<ObjectError> getErrorsForPath(String path)
696689
if (!_returnedErrors.containsKey(e))
697690
{
698691
missed.add(e);
699-
_returnedErrors.put(e,"missed");
692+
_returnedErrors.put(e, "missed");
700693
}
701694
}
702695
}
@@ -782,7 +775,7 @@ protected HtmlString formAction(Class<? extends Controller> actionClass, Method
782775
@Deprecated // makeId() is preferred
783776
protected int getRequestScopedUID()
784777
{
785-
return UniqueID.getRequestScopedUID(getViewContext().getRequest());
778+
return UniqueID.getRequestScopedUID(getViewContext().getRequestOrThrow());
786779
}
787780

788781
protected String makeId(String prefix)

api/src/org/labkey/filters/ContentSecurityPolicyFilter.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,6 @@ private void extractCspVersion(String s)
203203
}
204204
}
205205

206-
private static final String X_FRAME_OPTIONS_HEADER_NAME = "X-Frame-Options";
207-
208206
@Override
209207
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
210208
{

core/src/org/labkey/core/admin/AdminController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12321,8 +12321,8 @@ public void handleReports(ReportToJsonObjects jsonObjects, HttpServletRequest re
1232112321
@Override
1232212322
protected ObjectMapper createRequestObjectMapper()
1232312323
{
12324-
// Annoyingly, Chrome posts an array of JSON objects but Safari posts individual JSON objects. Set a flag
12325-
// that ensures both cases deserialize into List<JSONObject>.
12324+
// Annoyingly, Chrome and Firefox post an array of JSON objects but Safari posts individual JSON objects.
12325+
// Set a flag that ensures both cases deserialize into List<JSONObject>.
1232612326
return JsonUtil.DEFAULT_MAPPER.copy().enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
1232712327
}
1232812328
}

core/test/src/org/labkey/test/tests/AttachmentsTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616
package org.labkey.test.tests;
1717

18-
import org.apache.commons.collections4.Bag;
19-
import org.apache.commons.collections4.bag.HashBag;
18+
import org.apache.commons.collections4.MultiSet;
19+
import org.apache.commons.collections4.multiset.HashMultiSet;
2020
import org.junit.Assert;
2121
import org.junit.BeforeClass;
2222
import org.junit.Test;
@@ -116,7 +116,7 @@ public void testParentTypesInAuditLog() throws IOException, CommandException
116116
{
117117
SelectRowsResponse auditResponse = new SelectRowsCommand("auditLog", AuditLogHelper.AuditEvent.ATTACHMENT_AUDIT_EVENT.getName()).execute(createDefaultConnection(), getProjectName());
118118
Assert.assertEquals(10, auditResponse.getRowCount());
119-
Bag<String> parentTypes = new HashBag<>();
119+
MultiSet<String> parentTypes = new HashMultiSet<>();
120120
auditResponse.getRowset().forEach(row -> parentTypes.add((String)row.getValue("ParentType")));
121121
Assert.assertEquals(ISSUE_ATTACHMENTS, parentTypes.getCount("IssueComment"));
122122
Assert.assertEquals(WIKI_ATTACHMENTS, parentTypes.getCount("Wiki"));

query/src/org/labkey/query/persist/QueryManager.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
package org.labkey.query.persist;
1818

19-
import org.apache.commons.collections4.Bag;
20-
import org.apache.commons.collections4.bag.HashBag;
19+
import org.apache.commons.collections4.MultiSet;
20+
import org.apache.commons.collections4.multiset.HashMultiSet;
2121
import org.apache.commons.lang3.StringUtils;
2222
import org.apache.logging.log4j.LogManager;
2323
import org.apache.logging.log4j.Logger;
@@ -1058,23 +1058,23 @@ public static void registerUsageMetrics(String moduleName)
10581058
if (null != svc)
10591059
{
10601060
svc.registerUsageMetrics(moduleName, () -> {
1061-
Bag<String> bag = DbScope.getDbScopes().stream()
1062-
.filter(scope -> !scope.isLabKeyScope()).map(DbScope::getDatabaseProductName)
1063-
.collect(Collectors.toCollection(HashBag::new));
1061+
MultiSet<String> multiSet = DbScope.getDbScopes().stream()
1062+
.filter(scope -> !scope.isLabKeyScope()).map(DbScope::getDatabaseProductName)
1063+
.collect(Collectors.toCollection(HashMultiSet::new));
10641064

1065-
Map<String, Object> statsMap = bag.uniqueSet().stream()
1066-
.collect(Collectors.toMap(Function.identity(), bag::getCount));
1065+
Map<String, Object> statsMap = multiSet.uniqueSet().stream()
1066+
.collect(Collectors.toMap(Function.identity(), multiSet::getCount));
10671067

10681068
Map<String, Object> metrics = new HashMap<>();
10691069
metrics.put("externalDatasources", statsMap);
10701070
metrics.put(
1071-
"customViewCounts",
1072-
Map.of(
1073-
"DataClasses", getSchemaCustomViewCounts("exp.data"),
1074-
"SampleTypes", getSchemaCustomViewCounts("samples"),
1075-
"Assays", getSchemaCustomViewCounts("assay"),
1076-
"Inventory", getSchemaCustomViewCounts("inventory")
1077-
)
1071+
"customViewCounts",
1072+
Map.of(
1073+
"DataClasses", getSchemaCustomViewCounts("exp.data"),
1074+
"SampleTypes", getSchemaCustomViewCounts("samples"),
1075+
"Assays", getSchemaCustomViewCounts("assay"),
1076+
"Inventory", getSchemaCustomViewCounts("inventory")
1077+
)
10781078
);
10791079
metrics.put("customViewWithLineageColumn", getLineageCustomViewMetrics());
10801080
metrics.put("queryDefWithCalculatedFieldsCounts", getCalculatedFieldsCountsMetric());

specimen/src/org/labkey/specimen/SpecimenModule.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
package org.labkey.specimen;
1818

19-
import org.apache.commons.collections4.bag.HashBag;
19+
import org.apache.commons.collections4.MultiSet;
20+
import org.apache.commons.collections4.multiset.HashMultiSet;
2021
import org.apache.commons.lang3.mutable.MutableInt;
2122
import org.apache.logging.log4j.Logger;
2223
import org.jetbrains.annotations.NotNull;
@@ -74,12 +75,12 @@
7475
import org.labkey.specimen.importer.SpecimenSettingsImporter;
7576
import org.labkey.specimen.model.SpecimenRequestEventType;
7677
import org.labkey.specimen.pipeline.SpecimenPipeline;
77-
import org.labkey.specimen.requirements.SpecimenRequestRequirementProvider;
7878
import org.labkey.specimen.query.SpecimenPivotByDerivativeType;
7979
import org.labkey.specimen.query.SpecimenPivotByPrimaryType;
8080
import org.labkey.specimen.query.SpecimenPivotByRequestingLocation;
8181
import org.labkey.specimen.query.SpecimenQueryView;
8282
import org.labkey.specimen.query.SpecimenUpdateService;
83+
import org.labkey.specimen.requirements.SpecimenRequestRequirementProvider;
8384
import org.labkey.specimen.security.roles.SpecimenCoordinatorRole;
8485
import org.labkey.specimen.security.roles.SpecimenRequesterRole;
8586
import org.labkey.specimen.settings.RepositorySettings;
@@ -272,7 +273,7 @@ protected void startupAfterSpringConfig(ModuleContext moduleContext)
272273
{
273274
svc.registerUsageMetrics(NAME, () -> {
274275
// Collect and add specimen repository statistics: simple vs. advanced study count, event/vial/specimen count, count of studies with requests enabled, request count by status
275-
HashBag<String> specimenBag = new HashBag<>();
276+
MultiSet<String> specimenMultiSet = new HashMultiSet<>();
276277
MutableInt requestsEnabled = new MutableInt(0);
277278
MutableInt hasLocations = new MutableInt(0);
278279

@@ -283,35 +284,35 @@ protected void startupAfterSpringConfig(ModuleContext moduleContext)
283284

284285
if (settings.isSimple())
285286
{
286-
specimenBag.add("simple");
287+
specimenMultiSet.add("simple");
287288
TableInfo simpleSpecimens = schema.getTable(SpecimenTablesProvider.SIMPLE_SPECIMEN_TABLE_NAME);
288-
specimenBag.add("simpleSpecimens", (int) new TableSelector(simpleSpecimens).getRowCount());
289+
specimenMultiSet.add("simpleSpecimens", (int) new TableSelector(simpleSpecimens).getRowCount());
289290
}
290291
else
291292
{
292-
specimenBag.add("advanced");
293+
specimenMultiSet.add("advanced");
293294
TableInfo events = schema.getTable(SpecimenTablesProvider.SPECIMEN_EVENT_TABLE_NAME);
294295
TableInfo vials = schema.getTable(SpecimenTablesProvider.SPECIMEN_DETAIL_TABLE_NAME);
295296
TableInfo specimens = schema.getTable(SpecimenTablesProvider.SPECIMEN_SUMMARY_TABLE_NAME);
296-
specimenBag.add("events", (int) new TableSelector(events).getRowCount());
297-
specimenBag.add("vials", (int) new TableSelector(vials).getRowCount());
298-
specimenBag.add("specimens", (int) new TableSelector(specimens).getRowCount());
297+
specimenMultiSet.add("events", (int) new TableSelector(events).getRowCount());
298+
specimenMultiSet.add("vials", (int) new TableSelector(vials).getRowCount());
299+
specimenMultiSet.add("specimens", (int) new TableSelector(specimens).getRowCount());
299300
}
300301

301302
if (settings.isEnableRequests())
302303
requestsEnabled.increment();
303304

304305
TableInfo locations = schema.getTable(SpecimenQuerySchema.LOCATION_TABLE_NAME);
305306
long locationCount = new TableSelector(locations).getRowCount();
306-
specimenBag.add("locations", (int) locationCount);
307-
specimenBag.add("locationsInUse", (int) new TableSelector(locations, new SimpleFilter(FieldKey.fromParts("In Use"), true), null).getRowCount());
307+
specimenMultiSet.add("locations", (int) locationCount);
308+
specimenMultiSet.add("locationsInUse", (int) new TableSelector(locations, new SimpleFilter(FieldKey.fromParts("In Use"), true), null).getRowCount());
308309
if (locationCount > 0)
309310
hasLocations.increment();
310311

311-
LOG.debug(specimenBag.toString());
312+
LOG.debug(specimenMultiSet.toString());
312313
});
313314

314-
Map<String, Object> specimensMap = specimenBag.uniqueSet().stream().collect(Collectors.toMap(s -> s, specimenBag::getCount));
315+
Map<String, Object> specimensMap = specimenMultiSet.uniqueSet().stream().collect(Collectors.toMap(s -> s, specimenMultiSet::getCount));
315316
Map<String, Object> requestsMap = new SqlSelector(SpecimenSchema.get().getSchema(), new SQLFragment("SELECT Label, COUNT(*) FROM study.SampleRequest INNER JOIN study.SampleRequestStatus srs ON StatusId = srs.RowId GROUP BY Label")).getValueMap(String.class);
316317
requestsMap.put("enabled", requestsEnabled);
317318
specimensMap.put("requests", requestsMap);

study/test/src/org/labkey/test/tests/study/StudyDataspaceTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616
package org.labkey.test.tests.study;
1717

18-
import org.apache.commons.collections4.Bag;
19-
import org.apache.commons.collections4.bag.HashBag;
18+
import org.apache.commons.collections4.MultiSet;
19+
import org.apache.commons.collections4.multiset.HashMultiSet;
2020
import org.apache.commons.lang3.tuple.Pair;
2121
import org.junit.Assert;
2222
import org.junit.experimental.categories.Category;
@@ -346,14 +346,14 @@ private void verifyVisitTags()
346346
"1/3 - Heterologous boost regimen", "2/4 - Heterologous boost regimen",
347347
"2/4 - Heterologous boost regimen", "1/3 - Heterologous boost regimen");
348348

349-
Bag<List<String>> expectedRows = new HashBag<>(DataRegionTable.collateColumnsIntoRows(VISIT_TAG_MAP_TAGS, VISIT_TAG_MAP_VISITS, VISIT_TAG_MAP_COHORTS));
349+
MultiSet<List<String>> expectedRows = new HashMultiSet<>(DataRegionTable.collateColumnsIntoRows(VISIT_TAG_MAP_TAGS, VISIT_TAG_MAP_VISITS, VISIT_TAG_MAP_COHORTS));
350350

351351
// Check visit tags
352352
clickProject(getProjectName());
353353
goToModule("Query");
354354
viewQueryData("study", "VisitTagMap");
355355
DataRegionTable visitTagMaps = new DataRegionTable("query", this);
356-
Bag<List<String>> actualRows = new HashBag<>(visitTagMaps.getRows("VisitTag", "Visit", "Cohort"));
356+
MultiSet<List<String>> actualRows = new HashMultiSet<>(visitTagMaps.getRows("VisitTag", "Visit", "Cohort"));
357357

358358
assertEquals("Wrong Rows", expectedRows, actualRows);
359359

@@ -364,13 +364,13 @@ private void verifyVisitTags()
364364
final List<String> STUDY5_VISIT_TAG_MAP_TAGS = Arrays.asList("First Vaccination", "Second Vaccination", "Follow Up", "Follow Up");
365365
final List<String> STUDY5_VISIT_TAG_MAP_VISITS = Arrays.asList("Day -1001", "Day -1316", "Day -1351", "Day -1377");
366366
final List<String> STUDY5_VISIT_TAG_MAP_COHORTS = Arrays.asList(" ", " ", " ", " ");
367-
expectedRows = new HashBag<>(DataRegionTable.collateColumnsIntoRows(STUDY5_VISIT_TAG_MAP_TAGS, STUDY5_VISIT_TAG_MAP_VISITS, STUDY5_VISIT_TAG_MAP_COHORTS));
367+
expectedRows = new HashMultiSet<>(DataRegionTable.collateColumnsIntoRows(STUDY5_VISIT_TAG_MAP_TAGS, STUDY5_VISIT_TAG_MAP_VISITS, STUDY5_VISIT_TAG_MAP_COHORTS));
368368

369369
clickFolder(FOLDER_STUDY5);
370370
goToModule("Query");
371371
viewQueryData("study", "VisitTagMap");
372372
visitTagMaps = new DataRegionTable("query", this);
373-
actualRows = new HashBag<>(visitTagMaps.getRows("VisitTag", "Visit", "Cohort"));
373+
actualRows = new HashMultiSet<>(visitTagMaps.getRows("VisitTag", "Visit", "Cohort"));
374374

375375
assertEquals("Wrong Visit Tag Map Rows in study folder", expectedRows, actualRows);
376376

study/test/src/org/labkey/test/tests/study/StudyVisitTagTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616
package org.labkey.test.tests.study;
1717

18-
import org.apache.commons.collections4.Bag;
19-
import org.apache.commons.collections4.bag.HashBag;
18+
import org.apache.commons.collections4.MultiSet;
19+
import org.apache.commons.collections4.multiset.HashMultiSet;
2020
import org.junit.experimental.categories.Category;
2121
import org.labkey.api.util.FileUtil;
2222
import org.labkey.test.BaseWebDriverTest;
@@ -129,24 +129,24 @@ protected void doVerifySteps()
129129
{
130130
final List<String> VISIT_TAG_NAMES = Arrays.asList("day0", "finalvaccination", "finalvisit", "firstvaccination", "notsingleuse", "peakimmunogenicity");
131131
final List<String> VISIT_TAG_CAPTIONS = Arrays.asList("Day 0 (meaning varies)", "Final Vaccination", "Final visit", "First Vaccination", "Not Single Use Tag", "Predicted peak immunogenicity visit");
132-
Bag<List<String>> expectedRows = new HashBag<>(DataRegionTable.collateColumnsIntoRows(VISIT_TAG_NAMES, VISIT_TAG_CAPTIONS));
132+
MultiSet<List<String>> expectedRows = new HashMultiSet<>(DataRegionTable.collateColumnsIntoRows(VISIT_TAG_NAMES, VISIT_TAG_CAPTIONS));
133133

134134
goToProjectHome();
135135
goToModule("Query");
136136
viewQueryData("study", "VisitTag");
137137
DataRegionTable visitTags = new DataRegionTable("query", this);
138-
Bag<List<String>> actualRows = new HashBag<>(visitTags.getRows("Name", "Caption"));
138+
MultiSet<List<String>> actualRows = new HashMultiSet<>(visitTags.getRows("Name", "Caption"));
139139
assertEquals("Wrong Visit Tag Data", expectedRows, actualRows);
140140

141141
final List<String> VISIT_TAG_MAP_TAGS = Arrays.asList("Day 0 (meaning varies)", "First Vaccination", "Final Vaccination", "First Vaccination", "Final Vaccination", "Final visit");
142142
final List<String> VISIT_TAG_MAP_VISITS = Arrays.asList("Visit1", "Visit2", "Visit3", "Visit3", "Visit4", "Visit5");
143143
final List<String> VISIT_TAG_MAP_COHORTS = Arrays.asList(" ", "Positive", "Negative", "Negative", "Positive", " ");
144-
expectedRows = new HashBag<>(DataRegionTable.collateColumnsIntoRows(VISIT_TAG_MAP_TAGS, VISIT_TAG_MAP_VISITS, VISIT_TAG_MAP_COHORTS));
144+
expectedRows = new HashMultiSet<>(DataRegionTable.collateColumnsIntoRows(VISIT_TAG_MAP_TAGS, VISIT_TAG_MAP_VISITS, VISIT_TAG_MAP_COHORTS));
145145

146146
goToModule("Query");
147147
viewQueryData("study", "VisitTagMap");
148148
DataRegionTable visitTagMaps = new DataRegionTable("query", this);
149-
actualRows = new HashBag<>(visitTagMaps.getRows("VisitTag", "Visit", "Cohort"));
149+
actualRows = new HashMultiSet<>(visitTagMaps.getRows("VisitTag", "Visit", "Cohort"));
150150
assertEquals("Wrong Visit Tag Map Data", expectedRows, actualRows);
151151

152152
// verify insert/edit of tags

0 commit comments

Comments
 (0)