Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plates: Add Samples to Existing Plate Set #6202

Merged
merged 24 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a6eaea3
CreatePlateSetAction: support create/add
labkey-nicka Dec 31, 2024
1bc5365
Reformat: Initial support for sourcing from sampleIds, plate metadata
labkey-nicka Dec 31, 2024
c45a7ae
Reformat: support plate metadata, array individualized plate layouts
labkey-nicka Dec 31, 2024
ae8c842
ArrayOperation: process additional plates
labkey-nicka Dec 31, 2024
5aebf43
Cache well data in execution context
labkey-nicka Dec 31, 2024
b7516fb
Improve error logging
labkey-nicka Jan 2, 2025
67f4702
Adjust indexing
labkey-nicka Jan 2, 2025
2ea7ed0
ArrayOperation: strictly layout against "plates" when provided
labkey-nicka Jan 3, 2025
e68ab5a
Primary plate sets: coalesce duplicate wells error messaging
labkey-nicka Jan 3, 2025
fdd4a33
Reformat: support "fillExistingWells"
labkey-nicka Jan 5, 2025
0b5c781
Change plate processing
labkey-nicka Jan 7, 2025
8c3befb
ArrayOperation: check plate run counts
labkey-nicka Jan 8, 2025
749daae
Match target plate specifications
labkey-nicka Jan 8, 2025
f7cf4c6
Support fillPlatesOnly
labkey-nicka Jan 9, 2025
639ed82
Merge branch 'develop' into fb_add_to_plate
labkey-nicka Jan 9, 2025
ff68a96
Support re-plate plate set
labkey-nicka Jan 10, 2025
cbe6d6a
return this
labkey-nicka Jan 10, 2025
ba34286
Remove now redundant error prefixing
labkey-nicka Jan 13, 2025
789046c
Merge branch 'develop' into fb_add_to_plate
labkey-nicka Jan 13, 2025
7e4004b
validatePrimaryPlateSetUniqueSamples: skip left joining samples
labkey-nicka Jan 13, 2025
8614b16
Merge branch 'develop' into fb_add_to_plate
labkey-nicka Jan 14, 2025
81b6319
Merge branch 'develop' into fb_add_to_plate
labkey-nicka Jan 15, 2025
839fdd1
Match container scope
labkey-nicka Jan 16, 2025
9707766
Merge branch 'develop' into fb_add_to_plate
labkey-nicka Jan 16, 2025
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
163 changes: 14 additions & 149 deletions assay/src/org/labkey/assay/PlateController.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
package org.labkey.assay;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.json.JSONArray;
import org.json.JSONObject;
Expand All @@ -37,7 +35,6 @@
import org.labkey.api.assay.plate.PlateCustomField;
import org.labkey.api.assay.plate.PlateService;
import org.labkey.api.assay.plate.PlateSet;
import org.labkey.api.assay.plate.PlateSetType;
import org.labkey.api.assay.plate.PlateType;
import org.labkey.api.assay.security.DesignAssayPermission;
import org.labkey.api.collections.RowMapFactory;
Expand Down Expand Up @@ -65,6 +62,7 @@
import org.labkey.api.util.JsonUtil;
import org.labkey.api.util.PageFlowUtil;
import org.labkey.api.util.URLHelper;
import org.labkey.api.util.logging.LogHelper;
import org.labkey.api.view.ActionURL;
import org.labkey.api.view.DataViewSnapshotSelectionForm;
import org.labkey.api.view.HtmlView;
Expand All @@ -76,9 +74,9 @@
import org.labkey.assay.plate.PlateImpl;
import org.labkey.assay.plate.PlateManager;
import org.labkey.assay.plate.PlateSetExport;
import org.labkey.assay.plate.PlateSetImpl;
import org.labkey.assay.plate.PlateUrls;
import org.labkey.assay.plate.TsvPlateLayoutHandler;
import org.labkey.assay.plate.model.CreatePlateSetOptions;
import org.labkey.assay.plate.model.ReformatOptions;
import org.labkey.assay.view.AssayGWTView;
import org.springframework.validation.BindException;
Expand All @@ -101,7 +99,7 @@
public class PlateController extends SpringActionController
{
private static final SpringActionController.DefaultActionResolver _actionResolver = new DefaultActionResolver(PlateController.class);
private static final Logger _log = LogManager.getLogger(PlateController.class);
private static final Logger LOG = LogHelper.getLogger(PlateController.class, "Controller for plate related actions");

public PlateController()
{
Expand Down Expand Up @@ -956,160 +954,23 @@ public Object execute(GetPlateForm form, BindException errors) throws Exception
}
}

public static class CreatePlateSetForm
{
private String _description;
private String _name;
private List<PlateManager.PlateData> _plates = new ArrayList<>();
private Integer _parentPlateSetId;
private String _selectionKey;
private Boolean _template;
private PlateSetType _type;

public String getDescription()
{
return _description;
}

public void setDescription(String description)
{
_description = description;
}

public String getName()
{
return _name;
}

public void setName(String name)
{
_name = name;
}

public List<PlateManager.PlateData> getPlates()
{
return _plates;
}

public void setPlates(List<PlateManager.PlateData> plates)
{
_plates = plates;
}

public Integer getParentPlateSetId()
{
return _parentPlateSetId;
}

public void setParentPlateSetId(Integer parentPlateSetId)
{
_parentPlateSetId = parentPlateSetId;
}

public PlateSetType getType()
{
return _type;
}

public void setType(PlateSetType type)
{
_type = type;
}

public String getSelectionKey()
{
return _selectionKey;
}

public void setSelectionKey(String selectionKey)
{
_selectionKey = selectionKey;
}

public boolean isReplateCase()
{
return _parentPlateSetId != null && _selectionKey == null && _plates.isEmpty();
}

public boolean isRearrayCase()
{
return _selectionKey != null && !_plates.isEmpty();
}

public boolean isEmptyCase()
{
return _plates.isEmpty() && _selectionKey == null;
}

public boolean isDefaultCase()
{
return !_plates.isEmpty() && _selectionKey == null;
}

public Boolean getTemplate()
{
return _template;
}

public void setTemplate(Boolean template)
{
_template = template;
}
}

@RequiresPermission(InsertPermission.class)
public static class CreatePlateSetAction extends MutatingApiAction<CreatePlateSetForm>
public static class CreatePlateSetAction extends MutatingApiAction<CreatePlateSetOptions>
{
@Override
public void validateForm(CreatePlateSetForm form, Errors errors)
{
if (!form.isReplateCase() && !form.isRearrayCase() && !form.isEmptyCase() && !form.isDefaultCase())
errors.reject(ERROR_GENERIC, "Invalid parameters.");
}

@Override
public Object execute(CreatePlateSetForm form, BindException errors) throws Exception
public Object execute(CreatePlateSetOptions options, BindException errors) throws Exception
{
try
{
PlateSetImpl plateSet = new PlateSetImpl();
plateSet.setDescription(form.getDescription());
plateSet.setName(form.getName());
plateSet.setType(form.getType());
if (form.getTemplate() != null)
plateSet.setTemplate(form.getTemplate());

if (form.isReplateCase())
{
plateSet = (PlateSetImpl) PlateManager.get().replatePlateSet(getContainer(), getUser(), plateSet, form.getParentPlateSetId());
}
else
{
List<PlateManager.PlateData> plates = form.getPlates();
if (form.isRearrayCase())
{
String selectionKey = StringUtils.trimToNull(form.getSelectionKey());
if (selectionKey == null)
{
errors.reject(ERROR_REQUIRED, "Specifying a \"selectionKey\" is required for this configuration.");
return null;
}

plates = PlateManager.get().reArrayFromSelection(getContainer(), getUser(), plates, selectionKey);
}
else
{
plates = PlateManager.get().preparePlateData(getContainer(), getUser(), plates);
}

plateSet = PlateManager.get().createPlateSet(getContainer(), getUser(), plateSet, plates, form.getParentPlateSetId());
}

PlateSet plateSet = PlateManager.get().createOrAddToPlateSet(getContainer(), getUser(), options);
return success(plateSet);
}
catch (Exception e)
{
errors.reject(ERROR_GENERIC, e.getMessage() != null ? e.getMessage() : "Failed to create plate set. An error has occurred.");
String message = "Failed to create plate set.";
if (e.getMessage() != null)
message += " " + e.getMessage();
errors.reject(ERROR_GENERIC, message);
}

return null;
Expand Down Expand Up @@ -1775,6 +1636,10 @@ public Object execute(ReformatOptions options, BindException errors) throws Exce
}
catch (Exception e)
{
if (e instanceof ValidationException ve)
LOG.debug("Request failed due to a validation exception", ve);
else
LOG.error("Request failed due to an exception", e);
String message = "Failed to reformat plates.";
if (e.getMessage() != null)
message += " " + e.getMessage();
Expand Down
Loading