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

Refactor Plate cache #4694

Merged
merged 22 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
40e4783
check point
labkey-klum Aug 8, 2023
eb6aa19
support import of plate with pre-defined metadata
labkey-klum Aug 9, 2023
501d465
Merge branch 'develop' into fb_assay_results_metadata
labkey-klum Aug 9, 2023
8227358
plate metadata optional (in the app), add metrics for assays with pla…
labkey-klum Aug 10, 2023
661ac64
support for transform scripts
labkey-klum Aug 10, 2023
b7d2a92
Merge branch 'develop' into fb_assay_results_metadata
labkey-klum Aug 11, 2023
ce695e9
Merge branch 'develop' into fb_assay_results_metadata
labkey-klum Aug 14, 2023
a35a6fd
change the plate cache granularity to per-plate
labkey-klum Aug 14, 2023
3f487b3
merge from develop
labkey-klum Aug 15, 2023
2b4cee8
use the plate cache more often
labkey-klum Aug 16, 2023
9c6aa8e
Update vocab properties via query, add validation to the well table f…
labkey-klum Aug 17, 2023
d8b3269
cacheing fixes, unit tests for plate metadata
labkey-klum Aug 19, 2023
cdb010e
Merge branch 'develop' into fb_plate_cache
labkey-klum Aug 19, 2023
0994976
unit test fixes, ensure plate metadata domain for LKB folders
labkey-klum Aug 21, 2023
c0d5f67
new plate endpoint for metadata domain
labkey-klum Aug 21, 2023
f75c4d3
Add GetPlate endpoint
labkey-klum Aug 22, 2023
9d30a8e
plate cache logging
labkey-klum Aug 22, 2023
36a14bd
Merge branch 'develop' into fb_plate_cache
labkey-klum Aug 22, 2023
c174b28
plate cache logging
labkey-klum Aug 22, 2023
f1ec5e6
simplify plate cache
labkey-klum Aug 22, 2023
333151f
resolve well metadata columns by field key (and PropertyURI)
labkey-klum Aug 23, 2023
9c7e314
Merge branch 'develop' into fb_plate_cache
labkey-klum Aug 24, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public interface AssayPlateMetadataService
{
String PLATE_TEMPLATE_COLUMN_NAME = "PlateTemplate";
Map<AssayDataType, AssayPlateMetadataService> _handlers = new HashMap<>();
String EXPERIMENTAL_APP_PLATE_SUPPORT = "experimental-app-plate-support";

static void registerService(AssayDataType dataType, AssayPlateMetadataService handler)
{
Expand All @@ -38,7 +39,7 @@ static void registerService(AssayDataType dataType, AssayPlateMetadataService ha

static boolean isExperimentalAppPlateEnabled()
{
return ExperimentalFeatureService.get().isFeatureEnabled("experimental-app-plate-support");
return ExperimentalFeatureService.get().isFeatureEnabled(EXPERIMENTAL_APP_PLATE_SUPPORT);
}

@Nullable
Expand Down
16 changes: 16 additions & 0 deletions assay/api-src/org/labkey/api/assay/plate/Plate.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.labkey.api.assay.plate;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.exp.Identifiable;
import org.labkey.api.study.PropertySet;
Expand Down Expand Up @@ -43,6 +44,8 @@ public interface Plate extends PropertySet, Identifiable

Well getWell(int rowId);

List<Well> getWells();

WellGroup getWellGroup(WellGroup.Type type, String wellGroupName);

@Nullable WellGroup getWellGroup(int rowId);
Expand Down Expand Up @@ -71,4 +74,17 @@ public interface Plate extends PropertySet, Identifiable

@Override
@Nullable ActionURL detailsURL();

/**
* The list of metadata fields that are configured for this plate
*/
@NotNull List<PlateCustomField> getCustomFields();

Plate copy();

/**
* Returns the domain ID for the plate metadata domain.
*/
@Nullable
Integer getMetadataDomainId();
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.labkey.assay.plate.model;
package org.labkey.api.assay.plate;

import com.fasterxml.jackson.annotation.JsonInclude;
import org.labkey.api.exp.property.DomainProperty;
Expand Down
7 changes: 7 additions & 0 deletions assay/api-src/org/labkey/api/assay/plate/PlateService.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.labkey.api.data.statistics.StatsService;
import org.labkey.api.exp.Lsid;
import org.labkey.api.exp.api.ExpRun;
import org.labkey.api.exp.property.Domain;
import org.labkey.api.query.ValidationException;
import org.labkey.api.security.User;
import org.labkey.api.services.ServiceRegistry;
import org.labkey.api.view.ActionURL;
Expand Down Expand Up @@ -236,6 +238,11 @@ static PlateService get()
*/
TableInfo getPlateTableInfo();

/**
* Create the plate metadata domain for this container.
*/
@NotNull Domain ensurePlateMetadataDomain(Container container, User user) throws ValidationException;

/**
* A PlateDetailsResolver implementation provides a URL where a detailed, plate-type specific
* UI can be found.
Expand Down
11 changes: 6 additions & 5 deletions assay/api-src/org/labkey/api/assay/plate/PositionImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ public int getColumn()
return _column;
}

// needed for DB serialization
public int getCol()
{
return getColumn();
}

@Override
public int getRow()
{
Expand Down Expand Up @@ -143,11 +149,6 @@ public void setCol(int column)
setColumn(column);
}

public int getCol()
{
return getColumn();
}

public Integer getPlateId()
{
return _plateId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.labkey.assay.plate.model;
package org.labkey.api.assay.plate;

import org.labkey.api.exp.property.DomainProperty;

Expand Down
5 changes: 5 additions & 0 deletions assay/src/org/labkey/assay/AssayModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.labkey.api.security.User;
import org.labkey.api.security.permissions.ReadPermission;
import org.labkey.api.security.roles.RoleManager;
import org.labkey.api.settings.AdminConsole;
import org.labkey.api.util.ContextListener;
import org.labkey.api.util.JspTestCase;
import org.labkey.api.util.PageFlowUtil;
Expand Down Expand Up @@ -89,6 +90,7 @@

import static org.labkey.api.assay.DefaultDataTransformer.LEGACY_SESSION_COOKIE_NAME_REPLACEMENT;
import static org.labkey.api.assay.DefaultDataTransformer.LEGACY_SESSION_ID_REPLACEMENT;
import static org.labkey.api.assay.plate.AssayPlateMetadataService.EXPERIMENTAL_APP_PLATE_SUPPORT;

public class AssayModule extends SpringModule
{
Expand Down Expand Up @@ -246,6 +248,9 @@ public void moduleStartupComplete(ServletContext servletContext)
});

ExperimentService.get().addExperimentListener(new AssayExperimentListener());

AdminConsole.addExperimentalFeatureFlag(new AdminConsole.ExperimentalFeatureFlag(EXPERIMENTAL_APP_PLATE_SUPPORT,
"Plate samples in Biologics", "Plate samples in Biologics for import and analysis.", false, true));
}

@Override
Expand Down
55 changes: 33 additions & 22 deletions assay/src/org/labkey/assay/PlateController.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
import org.labkey.api.action.SimpleViewAction;
import org.labkey.api.action.SpringActionController;
import org.labkey.api.assay.plate.Plate;
import org.labkey.api.assay.plate.PlateCustomField;
import org.labkey.api.assay.plate.PlateService;
import org.labkey.api.assay.security.DesignAssayPermission;
import org.labkey.api.data.Container;
import org.labkey.api.data.ContainerManager;
import org.labkey.api.exp.property.Domain;
import org.labkey.api.gwt.client.model.GWTPropertyDescriptor;
import org.labkey.api.gwt.server.BaseRemoteService;
import org.labkey.api.security.RequiresAnyOf;
Expand All @@ -57,9 +59,7 @@
import org.labkey.assay.plate.PlateDataServiceImpl;
import org.labkey.assay.plate.PlateManager;
import org.labkey.assay.plate.PlateUrls;
import org.labkey.assay.plate.model.PlateCustomField;
import org.labkey.assay.plate.model.PlateType;
import org.labkey.assay.plate.model.WellCustomField;
import org.labkey.assay.view.AssayGWTView;
import org.springframework.validation.BindException;
import org.springframework.validation.Errors;
Expand Down Expand Up @@ -734,12 +734,12 @@ public Object execute(CustomFieldsForm form, BindException errors) throws Except
}

@RequiresPermission(ReadPermission.class)
public class GetFieldsAction extends MutatingApiAction<CustomFieldsForm>
public class GetFieldsAction extends ReadOnlyApiAction<CustomFieldsForm>
{
@Override
public Object execute(CustomFieldsForm form, BindException errors) throws Exception
{
return success(PlateManager.get().getFields(getContainer(), getUser(), form.getPlateId()));
return success(PlateManager.get().getFields(getContainer(), form.getPlateId()));
}
}

Expand All @@ -753,39 +753,50 @@ public Object execute(CustomFieldsForm form, BindException errors) throws Except
}
}

public static class SetFieldsForm extends CustomFieldsForm
/**
* Returns the Domain ID for the plate metadata configured for this container. If the domain has
* not been created then null will be returned.
*/
@RequiresPermission(ReadPermission.class)
public class GetPlateMetadataDomainAction extends ReadOnlyApiAction<Object>
{
private Integer _wellId;
private List<WellCustomField> _wellFields;

public Integer getWellId()
@Override
public Object execute(Object form, BindException errors) throws Exception
{
return _wellId;
Domain domain = PlateManager.get().getPlateMetadataDomain(getContainer(), getUser());
return success(domain != null ? domain.getTypeId() : null);
}
}

public void setWellId(Integer wellId)
{
_wellId = wellId;
}
public static class GetPlateForm
{
private Integer _rowId;

public List<WellCustomField> getWellFields()
public Integer getRowId()
{
return _wellFields;
return _rowId;
}

public void setWellFields(List<WellCustomField> wellFields)
public void setRowId(Integer rowId)
{
_wellFields = wellFields;
_rowId = rowId;
}
}

@RequiresPermission(UpdatePermission.class)
public class SetFieldsAction extends MutatingApiAction<SetFieldsForm>
@RequiresPermission(ReadPermission.class)
public static class GetPlateAction extends ReadOnlyApiAction<GetPlateForm>
{
@Override
public Object execute(SetFieldsForm form, BindException errors) throws Exception
public void validateForm(GetPlateForm form, Errors errors)
{
if (form.getRowId() == null)
errors.reject(ERROR_GENERIC, "Plate \"rowId\" is required.");
}

@Override
public Object execute(GetPlateForm form, BindException errors) throws Exception
{
return success(PlateManager.get().setFields(getContainer(), getUser(), form.getPlateId(), form.getWellId(), form.getWellFields()));
return PlateManager.get().getPlate(getContainer(), form.getRowId());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import org.labkey.api.security.User;
import org.labkey.assay.TSVProtocolSchema;
import org.labkey.assay.plate.model.Well;
import org.labkey.assay.plate.model.WellCustomField;
import org.labkey.api.assay.plate.WellCustomField;
import org.labkey.assay.query.AssayDbSchema;

import java.io.File;
Expand Down Expand Up @@ -283,7 +283,7 @@ public List<Map<String, Object>> mergePlateMetadata(
throw new ExperimentException("Unable to resolve the plate for the run");

// if there are metadata fields configured for this plate
if (!PlateManager.get().getFields(container, user, plate.getRowId()).isEmpty())
if (!PlateManager.get().getFields(container, plate.getRowId()).isEmpty())
{
// create the map of well locations to the well
Map<Position, Well> positionToWell = new HashMap<>();
Expand Down
Loading