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
7 changes: 7 additions & 0 deletions assay/api-src/org/labkey/api/assay/plate/PlateService.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,6 +30,7 @@
import org.labkey.api.query.ValidationException;
import org.labkey.api.security.User;
import org.labkey.api.services.ServiceRegistry;
import org.labkey.api.settings.OptionalFeatureService;
import org.labkey.api.view.ActionURL;

import java.sql.SQLException;
Expand All@@ -38,6 +39,7 @@
public interface PlateService
{
long NO_RUNID = -1;
String DEPRECATE_PRIMARY_PLATE_SET_FLAG = "primaryPlateSets";

class NameConflictException extends Exception
{
Expand DownExpand Up@@ -272,4 +274,9 @@ interface PlateDetailsResolver
*/
ActionURL getDetailsURL(Plate plate);
}

static boolean isPrimaryPlateSetsEnabled()
{
return OptionalFeatureService.get().isFeatureEnabled(DEPRECATE_PRIMARY_PLATE_SET_FLAG);
}
}
8 changes: 8 additions & 0 deletions assay/src/org/labkey/assay/AssayModule.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -201,6 +201,14 @@ protected void init()
false,
false,
OptionalFeatureService.FeatureType.Deprecated));

OptionalFeatureService.get().addFeatureFlag(new OptionalFeatureFlag(
PlateService.DEPRECATE_PRIMARY_PLATE_SET_FLAG,
"Allow for Primary Plate Sets to be created",
"Enables the creation of Primary Plate Sets. This option will be removed in a future release of LabKey Server.",
false,
false,
OptionalFeatureService.FeatureType.Deprecated));
}

@Override
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,6 +23,7 @@
import org.labkey.api.assay.plate.AssayPlateMetadataService;
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.plate.PlateSet;
import org.labkey.api.assay.plate.PlateSetType;
import org.labkey.api.assay.plate.PlateType;
Expand DownExpand Up@@ -77,6 +78,12 @@ public PlateSetDataGenerator(PipelineJob job, PlateSetDataGenerator.Config confi

public void generatePlateSets()
{
if (!PlateService.isPrimaryPlateSetsEnabled())
{
_log.error("PlateSetDataGenerator is not able to generate plate sets when primary plate sets are disabled.");
return;
Comment thread
labkey-nicka marked this conversation as resolved.
}

Config config = getConfig();
if (validateConfiguration(config))
{
Expand Down
2 changes: 2 additions & 0 deletions assay/src/org/labkey/assay/plate/PlateManager.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -2886,6 +2886,8 @@ public PlateSetImpl createPlateSet(

if (plateSet.getType() == null)
plateSet.setType(PlateSetType.assay);
if (!PlateService.isPrimaryPlateSetsEnabled() && plateSet.getType() == PlateSetType.primary)
throw new ValidationException("The primary plate set feature is not enabled.");

try (DbScope.Transaction tx = ensureTransaction())
{
Expand Down
29 changes: 29 additions & 0 deletions assay/src/org/labkey/assay/plate/PlateManagerTest.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,6 +24,7 @@
import org.labkey.api.assay.plate.Plate;
import org.labkey.api.assay.plate.PlateCustomField;
import org.labkey.api.assay.plate.PlateLayoutHandler;
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;
Expand DownExpand Up@@ -55,6 +56,7 @@
import org.labkey.api.query.QueryUpdateService;
import org.labkey.api.query.ValidationException;
import org.labkey.api.security.User;
import org.labkey.api.settings.OptionalFeatureService;
import org.labkey.api.util.JunitUtil;
import org.labkey.api.util.Pair;
import org.labkey.api.util.TestContext;
Expand DownExpand Up@@ -99,6 +101,7 @@ public final class PlateManagerTest
private static Container container;
private static ExpSampleType sampleType;
private static User user;
private static boolean primaryPlateSetFlag;

private enum PlateMetadataFields
{
Expand DownExpand Up@@ -126,6 +129,10 @@ public static void setupTest() throws Exception
container.setActiveModules(newActiveModules);
}

// Configure optional feature flag
primaryPlateSetFlag = OptionalFeatureService.get().isFeatureEnabled(PlateService.DEPRECATE_PRIMARY_PLATE_SET_FLAG);
OptionalFeatureService.get().setFeatureEnabled(PlateService.DEPRECATE_PRIMARY_PLATE_SET_FLAG, true, user);

Domain domain = PlateManager.get().getPlateMetadataDomain(container, user);
if (domain != null)
domain.delete(user);
Expand DownExpand Up@@ -201,11 +208,33 @@ public static void setupTest() throws Exception
@AfterClass
public static void cleanup()
{
// Restore optional feature flag
OptionalFeatureService.get().setFeatureEnabled(PlateService.DEPRECATE_PRIMARY_PLATE_SET_FLAG, primaryPlateSetFlag, user);

deleteTestContainer();
container = null;
user = null;
}

@Test
public void testDeprecatePrimaryPlateSetFlag()
{
try
{
OptionalFeatureService.get().setFeatureEnabled(PlateService.DEPRECATE_PRIMARY_PLATE_SET_FLAG, false, user);

PlateSetImpl plateSetImpl = new PlateSetImpl();
plateSetImpl.setType(PlateSetType.primary);
plateSetImpl.setName("testDeprecatePrimaryPlateSetFlag");

assertCreatePlateSetThrows("The primary plate set feature is not enabled.", plateSetImpl, null, null);
}
finally
{
OptionalFeatureService.get().setFeatureEnabled(PlateService.DEPRECATE_PRIMARY_PLATE_SET_FLAG, true, user);
}
}

@Test
public void testCreatePlateTemplate() throws Exception
{
Expand Down