Skip to content
Merged
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
50 changes: 50 additions & 0 deletions src/org/labkey/test/params/experiment/InventoryMetricUnit.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.labkey.test.params.experiment;

import org.apache.commons.lang3.StringUtils;

/**
* Enum of the various storage amount types.
*/
public enum InventoryMetricUnit
{
// If you add a value here you will also need to update SMSampleTypeDefinition.getInventoryMetricUnit.
G("g", "g (grams)"),
MG("mg", "mg (milligrams)"),
KG("kg", "kg (kilograms)"),
ML("mL", "mL (milliliters)"),
UL("uL", "uL (microliters)"),
L("L", "L (liters)"),
UNIT("unit", "unit"),
UNKNOWN("unknown", "unknown"); // Used by getInventoryMetricUnit. Return if an unknown value is in the UI.

private final String _value; // Used when creating a sample type with the API and setting this property.
private final String _label; // Used when setting the property through the UI.

InventoryMetricUnit(String value, String label)
{
_value = value;
_label = label;
}

public String getLabel()
{
return _label;
}

public String getValue()
{
return _value;
}

public static String getStandardUnit(String unitString)
{
if (StringUtils.isEmpty(unitString))
return unitString;
for (InventoryMetricUnit unit : values())
{
if (unit.getValue().toLowerCase().equals(unitString))
return unit.getValue();
}
return unitString;
}
}
7 changes: 0 additions & 7 deletions src/org/labkey/test/params/experiment/MetricUnit.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class SampleTypeDefinition extends DomainProps
private final Set<String> _dataParentAliases = new HashSet<>();

// Currently, these values are only used by the SampleManager module.
private MetricUnit _inventoryMetricUnit;
private InventoryMetricUnit _inventoryMetricUnit;
private String _labelColor;
private String _aliquotNameExpression;

Expand Down Expand Up @@ -96,12 +96,12 @@ public SampleTypeDefinition setLinkedDatasetCategory(String value)
return this;
}

protected MetricUnit getInventoryMetricUnit()
protected InventoryMetricUnit getInventoryMetricUnit()
{
return _inventoryMetricUnit;
}

public SampleTypeDefinition setInventoryMetricUnit(MetricUnit inventoryMetricUnit)
public SampleTypeDefinition setInventoryMetricUnit(InventoryMetricUnit inventoryMetricUnit)
{
_inventoryMetricUnit = inventoryMetricUnit;
return this;
Expand Down
36 changes: 2 additions & 34 deletions src/org/labkey/test/tests/SampleTypeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import org.labkey.test.params.FieldDefinition.ColumnType;
import org.labkey.test.params.FieldDefinition.LookupInfo;
import org.labkey.test.params.FieldInfo;
import org.labkey.test.params.experiment.MetricUnit;
import org.labkey.test.params.experiment.InventoryMetricUnit;
import org.labkey.test.params.experiment.SampleTypeDefinition;
import org.labkey.test.util.ApiPermissionsHelper;
import org.labkey.test.util.AuditLogHelper;
Expand Down Expand Up @@ -1868,7 +1868,7 @@ public void testAmountsAndUnitsWithDisplayUnit()

clickProject(PROJECT_NAME);
SampleTypeDefinition sampleTypeDefinition = new SampleTypeDefinition(sampleTypeName);
sampleTypeDefinition.setInventoryMetricUnit(TestMetricUnit.L);
sampleTypeDefinition.setInventoryMetricUnit(InventoryMetricUnit.L);
SampleTypeAPIHelper.createEmptySampleType(getProjectName(), sampleTypeDefinition);
refresh();
sampleHelper.goToSampleType(sampleTypeName);
Expand Down Expand Up @@ -2068,36 +2068,4 @@ public BrowserType bestBrowser()
{
return BrowserType.CHROME;
}

public enum TestMetricUnit implements MetricUnit
{
G("g", "g (grams)"),
MG("mg", "mg (milligrams)"),
KG("kg", "kg (kilograms)"),
ML("mL", "mL (milliliters)"),
UL("uL", "uL (microliters)"),
L("L", "L (liters)"),
UNIT("unit", "unit");

private final String _value;
private final String _label;

TestMetricUnit(String value, String label)
{
_value = value;
_label = label;
}

@Override
public String getLabel()
{
return _label;
}

@Override
public String getValue()
{
return _value;
}
}
}
Loading