Skip to content

Commit a0be093

Browse files
Issue 868: Add more nouns for count units (#7551)
1 parent f6e0efe commit a0be093

3 files changed

Lines changed: 29 additions & 6 deletions

File tree

api/src/org/labkey/api/ontology/KindOfQuantity.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import org.jetbrains.annotations.NotNull;
44

55
import java.util.ArrayList;
6+
import java.util.Arrays;
7+
import java.util.Comparator;
68
import java.util.List;
79

810

@@ -39,7 +41,10 @@ public List<Unit> getCommonUnits()
3941
@Override
4042
public List<Unit> getCommonUnits()
4143
{
42-
return List.of(Unit.blocks, Unit.bottles, Unit.boxes, Unit.cells, Unit.kits, Unit.packs, Unit.pieces, Unit.slides, Unit.tests, Unit.unit);
44+
return Arrays.stream(Unit.values())
45+
.filter(u -> u.getKindOfQuantity() == KindOfQuantity.Count && u != Unit.count)
46+
.sorted(Comparator.comparing(Unit::toString))
47+
.toList();
4348
}
4449
};
4550

api/src/org/labkey/api/ontology/Unit.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ public enum Unit implements SimpleConvert
4646
bottles(KindOfQuantity.Count, unit, 1.0, 2, "bottles",
4747
Quantity.class,
4848
"bottle", "bottles"),
49+
organisms(KindOfQuantity.Count, unit, 1.0, 2, "organisms",
50+
Quantity.class,
51+
"organism", "organisms"),
52+
vials(KindOfQuantity.Count, unit, 1.0, 2, "vials",
53+
Quantity.class,
54+
"vial", "vials"),
55+
tubes(KindOfQuantity.Count, unit, 1.0, 2, "tubes",
56+
Quantity.class,
57+
"tube", "tubes"),
58+
syringes(KindOfQuantity.Count, unit, 1.0, 2, "syringes",
59+
Quantity.class,
60+
"syringe", "syringes"),
4961

5062
mL(KindOfQuantity.Volume, null, 1e0, 6, "mL",
5163
Quantity.Volume_ml.class,
@@ -130,7 +142,7 @@ public enum Unit implements SimpleConvert
130142
this.quantityClass = quantityClass;
131143
this.singular = singular;
132144
this.plural = plural;
133-
this.otherNames = null==otherNames || otherNames.length==0 ? null : otherNames;
145+
this.otherNames = null == otherNames || otherNames.length == 0 ? null : otherNames;
134146
}
135147

136148
public boolean isBase()
@@ -173,7 +185,8 @@ public String toString()
173185
return print;
174186
}
175187

176-
static final HashMap<String,Unit> unitMap = new HashMap<>(Unit.values().length*10);
188+
static final HashMap<String, Unit> unitMap = new HashMap<>(Unit.values().length * 10);
189+
177190
static
178191
{
179192
for (Unit unit : Unit.values())
@@ -200,7 +213,7 @@ public static Unit fromName(@Nullable String unitName)
200213
}
201214

202215
// don't assume multiplicative relation between units (e.g. Kelvin and Celsius)
203-
static Function<Double,Double> convertFn(Unit from, Unit to)
216+
static Function<Double, Double> convertFn(Unit from, Unit to)
204217
{
205218
if (from == to)
206219
return Function.identity();
@@ -214,7 +227,7 @@ public static double convert(double value, @NotNull Unit from, @NotNull Unit to)
214227
Quantity.LOG.debug("Converting value {} from {} to {}", value, from.name(), to.name());
215228
if (from.base != to.base)
216229
throw new IllegalArgumentException("Can't convert " + from.name() + " to " + to.name());
217-
return from==to ? value : to.fromBaseUnitValue(from.toBaseUnitValue(value));
230+
return from == to ? value : to.fromBaseUnitValue(from.toBaseUnitValue(value));
218231
}
219232

220233
@Override

api/src/org/labkey/api/workflow/WorkflowService.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ enum ActionType
2323
AssayImport("assay types", "Imported assay data"),
2424
DeriveSamples("derivation sample type parameters", "Derived samples"),
2525
AliquotSamples("aliquot sample type parameters", "Aliquot samples"),
26-
PoolSamples("pooling sample type parameters", "Pooled samples");
26+
PoolSamples("pooling sample type parameters", "Pooled samples"),
27+
AddToStorage("input parameters", "Added samples to storage"),
28+
MoveInStorage("input parameters", "Moved samples to storage"),
29+
CheckOut("input parameters", "Checked out samples"),
30+
CheckIn("input parameters", "Checked in samples"),
31+
RemoveFromStorage("sample status value", "Removed samples from storage");
2732

2833
private final String _inputDescription;
2934
private final String _auditMessage;

0 commit comments

Comments
 (0)