Skip to content

Commit cf62f4c

Browse files
authored
Move single-module classes out of api into their owning modules (#1028)
## Rationale Shrink the api module by moving classes that only one module uses into that module, so they no longer compile on the api build path every module waits on. ## Related Pull Requests - LabKey/platform#8248 ## Changes - Move an api class used only by snprc_ehr into the module <!-- list of standard tasks (remove this comment to enable) ## Tasks - [ ] Claude Code Review - [ ] Manual Testing - [ ] Test Automation - [ ] Verify Fix -->
1 parent 167c91c commit cf62f4c

2 files changed

Lines changed: 66 additions & 1 deletion

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright (c) 2015-2026 LabKey Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.labkey.snprc_ehr.data;
17+
18+
import org.jetbrains.annotations.NotNull;
19+
import org.labkey.api.data.ColumnInfo;
20+
import org.labkey.api.data.DataColumn;
21+
import org.labkey.api.data.DisplayColumn;
22+
import org.labkey.api.data.DisplayColumnFactory;
23+
import org.labkey.api.data.RenderContext;
24+
import org.labkey.api.util.HtmlString;
25+
26+
/**
27+
* Renders the value in HTML preserving whitespace, including spaces and newlines.
28+
*
29+
* User: jeckels
30+
* Date: 10/9/2015
31+
*/
32+
public class WhitespacePreservingDisplayColumnFactory implements DisplayColumnFactory
33+
{
34+
@Override
35+
public DisplayColumn createRenderer(ColumnInfo col)
36+
{
37+
return new WhitespacePreservingDisplayColumn(col);
38+
}
39+
40+
public static class WhitespacePreservingDisplayColumn extends DataColumn
41+
{
42+
public WhitespacePreservingDisplayColumn(ColumnInfo col)
43+
{
44+
super(col);
45+
}
46+
47+
@NotNull
48+
@Override
49+
public HtmlString getFormattedHtml(RenderContext ctx)
50+
{
51+
Object value = ctx.get(getDisplayColumn().getFieldKey());
52+
if (value == null)
53+
{
54+
// If we couldn't find it by FieldKey, check by alias as well
55+
value = getDisplayColumn().getValue(ctx);
56+
}
57+
58+
if (value == null)
59+
{
60+
return HtmlString.NBSP;
61+
}
62+
return HtmlString.of(value.toString(), true);
63+
}
64+
}
65+
}

‎snprc_ehr/src/org/labkey/snprc_ehr/table/SNPRC_EHRCustomizer.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.labkey.api.data.MutableColumnInfo;
2727
import org.labkey.api.data.SQLFragment;
2828
import org.labkey.api.data.TableInfo;
29-
import org.labkey.api.data.WhitespacePreservingDisplayColumnFactory;
3029
import org.labkey.api.data.WrappedColumn;
3130

3231
import org.labkey.api.ehr.EHRService;
@@ -43,6 +42,7 @@
4342
import org.labkey.api.study.DatasetTable;
4443
import org.labkey.api.util.logging.LogHelper;
4544
import org.labkey.snprc_ehr.SNPRC_EHRSchema;
45+
import org.labkey.snprc_ehr.data.WhitespacePreservingDisplayColumnFactory;
4646
import org.labkey.snprc_ehr.helpers.CustomizerQueryProvider;
4747
import org.labkey.snprc_ehr.model.CalculatedColumn;
4848
import static org.labkey.snprc_ehr.constants.QueryConstants.*;

0 commit comments

Comments
 (0)