Package org.labkey.remoteapi.storage
Class CreateCommand
java.lang.Object
org.labkey.remoteapi.Command<ResponseType,org.apache.hc.client5.http.classic.methods.HttpPost>
org.labkey.remoteapi.PostCommand<StorageCommandResponse>
org.labkey.remoteapi.storage.BaseStorageCommand
org.labkey.remoteapi.storage.CreateCommand
- All Implemented Interfaces:
HasRequiredVersion
Create a new LabKey Freezer Manager storage item that can be used in the creation of a storage hierarchy.
Storage hierarchies consist of a top level Freezer or Primary Storage, which can have any combination of
child non-terminal storage locations (i.e., those that do not directly contain samples but can contain other
units) and terminal storage locations (i.e., units in the storage location that directly contain samples and cannot contain
other units).
See the LabKey Documentation
for further details.
A storage location may also have a parent hierarchy, which defines the physical location of the storage location. See the LabKey Documentation for further details.
Storage items can be of the following types: Physical Location, Freezer, Primary Storage, Shelf, Rack, Canister,
Storage Unit Type, or Terminal Storage Location. One of these values must be set as the "type" for
the StorageRow
provided to the CreateCommand constructor.
The additional properties for the storage item being created can be provided as the "props" for the
StorageRow
. The specific set of props will differ for each storage item type:
- Physical Location: name, description, locationId (rowId of the parent Physical Location)
- Freezer: name, description, locationId (rowId of the parent Physical Location), manufacturer, freezerModel, temperature, temperatureUnits, serialNumber, sensorName, lossRate, status, temperatureControlled (boolean)
- Primary Storage: name, description, locationId (rowId of the parent Physical Location), temperatureControlled (boolean)
- Shelf/Rack/Canister: name, description, locationId (rowId of the parent freezer, primary storage, or Shelf/Rack/Canister)
- Storage Unit Type: name, description, unitType (one of the following: "Box", "Plate", "Bag", "Cane", "Tube Rack"), rows, cols (required if positionFormat is not "Num"), positionFormat (one of the following: "Num", "AlphaNum", "AlphaAlpha", "NumAlpha", "NumNum"), positionOrder (one of the following: "RowColumn", "ColumnRow")
- Terminal Storage Location: name, description, typeId (rowId of the Storage Unit Type), locationId (rowId of the parent freezer, primary storage or Shelf/Rack/Canister)
Examples:
// May need to add CONTEXT_PATH for dev instances
Connection cn = new Connection("http://localhost:8080", user, password);
// Create Physical Location for freezer
StorageRow row = new StorageRow();
row.setType("Physical Location");
row.setProps(Map.of("name", "Building #1", "description", "Test physical location"));
CreateCommand cmd = new CreateCommand(row);
StorageCommandResponse response = cmd.execute(cn, "PROJECT_NAME");
Integer buildingRowId = response.getRowId();
// Create a freezer in Building #1
row = new StorageRow();
row.setType("Freezer");
row.setProps(Map.of("name", "Freezer A", "description", "Test freezer from API", "serialNumber", "ABC123", "locationId", buildingRowId));
cmd = new CreateCommand(row);
response = cmd.execute(cn, "PROJECT_NAME");
Integer freezerRowId = response.getRowId();
// Add two shelves to the freezer (note you can add additional non-terminal storage items to create
// the freezer hierarchy that matches your physical freezer)
row = new StorageRow();
row.setType("Shelf");
row.setProps(Map.of("name", "Shelf #1", "description", "Test shelf in Freezer A", "locationId", freezerRowId));
cmd = new CreateCommand(row);
response = cmd.execute(cn, "PROJECT_NAME");
Integer shelf1RowId = response.getRowId();
row = new StorageRow();
row.setType("Shelf");
row.setProps(Map.of("name", "Shelf #2", "description", "Another test shelf in Freezer A", "locationId", freezerRowId));
cmd = new CreateCommand(row);
response = cmd.execute(cn, "PROJECT_NAME");
Integer shelf2RowId = response.getRowId();
// Note that we are going to use an existing storage unit type that is part of the default set.
// You can create custom storage unit types using the CreateCommand with type = "Storage Unit Type".
SelectRowsCommand selectCommand = new SelectRowsCommand("inventory", "BoxType");
selectCommand.setColumns(Arrays.asList("RowId"));
selectCommand.addFilter(new Filter("Name", "96 Well Plate"));
SelectRowsResponse selectResponse = selectCommand.execute(connection, containerPath);
Integer plateTypeRowId = Integer.parseInt(selectResponse.getRows().get(0).get("RowId").toString());
// Add two plates to the shelf
row = new StorageRow();
row.setType("Terminal Storage Location");
row.setProps(Map.of("name", "Plate #1", "description", "Test plate on Shelf #1", "typeId", plateTypeRowId, "locationId", shelf1RowId));
cmd = new CreateCommand(row);
response = cmd.execute(cn, "PROJECT_NAME");
Integer plate1RowId = response.getRowId();
row = new StorageRow();
row.setType("Terminal Storage Location");
row.setProps(Map.of("name", "Plate #2", "description", "Another test plate on Shelf #1", "typeId", plateTypeRowId, "locationId", shelf1RowId));
cmd = new CreateCommand(row);
response = cmd.execute(cn, "PROJECT_NAME");
Integer plate2RowId = response.getRowId();
// Move Plate #2 to Shelf #2
row = new StorageRow();
row.setType("Terminal Storage Location");
row.setProps(Map.of("description", "Plate moved to Shelf #2", "locationId", shelf2RowId));
row.setRowId(plate2RowId);
UpdateCommand updateCmd = new UpdateCommand(row);
updateCmd.execute(cn, "PROJECT_NAME");
// Delete the freezer, which will delete the full hierarchy of non-terminal and terminal storage locations
row = new StorageRow();
row.setType("Freezer");
row.setRowId(freezerRowId);
DeleteCommand deleteCmd = new DeleteCommand(row);
deleteCmd.execute(cn, "PROJECT_NAME");
-
Nested Class Summary
Nested classes/interfaces inherited from class org.labkey.remoteapi.Command
Command.CommonParameters, Command.Response
-
Field Summary
Fields inherited from class org.labkey.remoteapi.Command
CONTENT_TYPE_JSON
-
Constructor Summary
ConstructorsConstructorDescriptionCreateCommand
(StorageRow storageRow) Constructs a new CreateCommand for the givenStorageRow
. -
Method Summary
Methods inherited from class org.labkey.remoteapi.storage.BaseStorageCommand
createResponse, getJsonObject, getRequiredVersion
Methods inherited from class org.labkey.remoteapi.PostCommand
createRequest
Methods inherited from class org.labkey.remoteapi.Command
_execute, createParameterMap, execute, getActionName, getControllerName, getHttpRequest, getParameters, getParamValueAsString, getTimeout, setRequiredVersion, setTimeout
-
Constructor Details
-
CreateCommand
Constructs a new CreateCommand for the givenStorageRow
.- Parameters:
storageRow
- The details about the storage row to be created.
-