Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion api/src/org/labkey/api/ontology/KindOfQuantity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;


Expand Down Expand Up @@ -39,7 +41,10 @@ public List<Unit> getCommonUnits()
@Override
public List<Unit> getCommonUnits()
{
return List.of(Unit.blocks, Unit.bottles, Unit.boxes, Unit.cells, Unit.kits, Unit.packs, Unit.pieces, Unit.slides, Unit.tests, Unit.unit);
return Arrays.stream(Unit.values())
.filter(u -> u.getKindOfQuantity() == KindOfQuantity.Count && u != Unit.count)
.sorted(Comparator.comparing(Unit::toString))
.toList();
}
};

Expand Down
21 changes: 17 additions & 4 deletions api/src/org/labkey/api/ontology/Unit.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ public enum Unit implements SimpleConvert
bottles(KindOfQuantity.Count, unit, 1.0, 2, "bottles",
Quantity.class,
"bottle", "bottles"),
organisms(KindOfQuantity.Count, unit, 1.0, 2, "organisms",
Quantity.class,
"organism", "organisms"),
vials(KindOfQuantity.Count, unit, 1.0, 2, "vials",
Quantity.class,
"vial", "vials"),
tubes(KindOfQuantity.Count, unit, 1.0, 2, "tubes",
Quantity.class,
"tube", "tubes"),
syringes(KindOfQuantity.Count, unit, 1.0, 2, "syringes",
Quantity.class,
"syringe", "syringes"),

mL(KindOfQuantity.Volume, null, 1e0, 6, "mL",
Quantity.Volume_ml.class,
Expand Down Expand Up @@ -130,7 +142,7 @@ public enum Unit implements SimpleConvert
this.quantityClass = quantityClass;
this.singular = singular;
this.plural = plural;
this.otherNames = null==otherNames || otherNames.length==0 ? null : otherNames;
this.otherNames = null == otherNames || otherNames.length == 0 ? null : otherNames;
}

public boolean isBase()
Expand Down Expand Up @@ -173,7 +185,8 @@ public String toString()
return print;
}

static final HashMap<String,Unit> unitMap = new HashMap<>(Unit.values().length*10);
static final HashMap<String, Unit> unitMap = new HashMap<>(Unit.values().length * 10);

static
{
for (Unit unit : Unit.values())
Expand All @@ -200,7 +213,7 @@ public static Unit fromName(@Nullable String unitName)
}

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

@Override
Expand Down
7 changes: 6 additions & 1 deletion api/src/org/labkey/api/workflow/WorkflowService.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ enum ActionType
AssayImport("assay types", "Imported assay data"),
DeriveSamples("derivation sample type parameters", "Derived samples"),
AliquotSamples("aliquot sample type parameters", "Aliquot samples"),
PoolSamples("pooling sample type parameters", "Pooled samples");
PoolSamples("pooling sample type parameters", "Pooled samples"),
AddToStorage("input parameters", "Added samples to storage"),
MoveInStorage("input parameters", "Moved samples to storage"),
CheckOut("input parameters", "Checked out samples"),
CheckIn("input parameters", "Checked in samples"),
RemoveFromStorage("sample status value", "Removed samples from storage");

private final String _inputDescription;
private final String _auditMessage;
Expand Down
Loading