forked from BimberLab/DiscvrLabKeyModules
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathResultsOORDisplayColumn.java
More file actions
68 lines (56 loc) · 1.63 KB
/
ResultsOORDisplayColumn.java
File metadata and controls
68 lines (56 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package org.labkey.api.studies.query;
import org.apache.commons.lang3.StringUtils;
import org.labkey.api.data.ColumnInfo;
import org.labkey.api.data.DataColumn;
import org.labkey.api.data.RenderContext;
import org.labkey.api.query.FieldKey;
import java.text.DecimalFormat;
import java.util.Set;
public class ResultsOORDisplayColumn extends DataColumn
{
public ResultsOORDisplayColumn(ColumnInfo col)
{
super(col);
}
@Override
public Class getDisplayValueClass()
{
return String.class;
}
@Override
public Object getDisplayValue(RenderContext ctx)
{
Object result = ctx.get(getBoundColumn().getFieldKey(), Double.class);
if (result == null)
{
return null;
}
if (getBoundColumn().getFormat() != null)
{
DecimalFormat fmt = new DecimalFormat(getBoundColumn().getFormat());
result = fmt.format(result);
}
String oor = ctx.get(getOOR(), String.class);
if (StringUtils.isEmpty(oor))
{
return result;
}
return oor + result;
}
private FieldKey getOOR()
{
ColumnInfo col = getBoundColumn();
if (col == null)
{
return null;
}
FieldKey oor = FieldKey.fromString(col.getFieldKey().getName() + "OORIndicator");
return getBoundColumn().getFieldKey().getParent() == null ? oor : FieldKey.fromParts(getBoundColumn().getFieldKey().getParent(), oor);
}
@Override
public void addQueryFieldKeys(Set<FieldKey> keys)
{
super.addQueryFieldKeys(keys);
keys.add(getOOR());
}
}