Skip to content

Commit 09813a3

Browse files
authored
Plates: deprecate primary plate sets (#7977)
1 parent a9ca2bd commit 09813a3

5 files changed

Lines changed: 53 additions & 0 deletions

File tree

assay/api-src/org/labkey/api/assay/plate/PlateService.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.labkey.api.query.ValidationException;
3131
import org.labkey.api.security.User;
3232
import org.labkey.api.services.ServiceRegistry;
33+
import org.labkey.api.settings.OptionalFeatureService;
3334
import org.labkey.api.view.ActionURL;
3435

3536
import java.sql.SQLException;
@@ -38,6 +39,7 @@
3839
public interface PlateService
3940
{
4041
long NO_RUNID = -1;
42+
String DEPRECATE_PRIMARY_PLATE_SET_FLAG = "primaryPlateSets";
4143

4244
class NameConflictException extends Exception
4345
{
@@ -272,4 +274,9 @@ interface PlateDetailsResolver
272274
*/
273275
ActionURL getDetailsURL(Plate plate);
274276
}
277+
278+
static boolean isPrimaryPlateSetsEnabled()
279+
{
280+
return OptionalFeatureService.get().isFeatureEnabled(DEPRECATE_PRIMARY_PLATE_SET_FLAG);
281+
}
275282
}

assay/src/org/labkey/assay/AssayModule.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,14 @@ protected void init()
201201
false,
202202
false,
203203
OptionalFeatureService.FeatureType.Deprecated));
204+
205+
OptionalFeatureService.get().addFeatureFlag(new OptionalFeatureFlag(
206+
PlateService.DEPRECATE_PRIMARY_PLATE_SET_FLAG,
207+
"Allow for Primary Plate Sets to be created",
208+
"Enables the creation of Primary Plate Sets. This option will be removed in a future release of LabKey Server.",
209+
false,
210+
false,
211+
OptionalFeatureService.FeatureType.Deprecated));
204212
}
205213

206214
@Override

assay/src/org/labkey/assay/data/generator/PlateSetDataGenerator.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.labkey.api.assay.plate.AssayPlateMetadataService;
2424
import org.labkey.api.assay.plate.Plate;
2525
import org.labkey.api.assay.plate.PlateCustomField;
26+
import org.labkey.api.assay.plate.PlateService;
2627
import org.labkey.api.assay.plate.PlateSet;
2728
import org.labkey.api.assay.plate.PlateSetType;
2829
import org.labkey.api.assay.plate.PlateType;
@@ -77,6 +78,12 @@ public PlateSetDataGenerator(PipelineJob job, PlateSetDataGenerator.Config confi
7778

7879
public void generatePlateSets()
7980
{
81+
if (!PlateService.isPrimaryPlateSetsEnabled())
82+
{
83+
_log.error("PlateSetDataGenerator is not able to generate plate sets when primary plate sets are disabled.");
84+
return;
85+
}
86+
8087
Config config = getConfig();
8188
if (validateConfiguration(config))
8289
{

assay/src/org/labkey/assay/plate/PlateManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2886,6 +2886,8 @@ public PlateSetImpl createPlateSet(
28862886

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

28902892
try (DbScope.Transaction tx = ensureTransaction())
28912893
{

assay/src/org/labkey/assay/plate/PlateManagerTest.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.labkey.api.assay.plate.Plate;
2525
import org.labkey.api.assay.plate.PlateCustomField;
2626
import org.labkey.api.assay.plate.PlateLayoutHandler;
27+
import org.labkey.api.assay.plate.PlateService;
2728
import org.labkey.api.assay.plate.PlateSet;
2829
import org.labkey.api.assay.plate.PlateSetType;
2930
import org.labkey.api.assay.plate.PlateType;
@@ -55,6 +56,7 @@
5556
import org.labkey.api.query.QueryUpdateService;
5657
import org.labkey.api.query.ValidationException;
5758
import org.labkey.api.security.User;
59+
import org.labkey.api.settings.OptionalFeatureService;
5860
import org.labkey.api.util.JunitUtil;
5961
import org.labkey.api.util.Pair;
6062
import org.labkey.api.util.TestContext;
@@ -99,6 +101,7 @@ public final class PlateManagerTest
99101
private static Container container;
100102
private static ExpSampleType sampleType;
101103
private static User user;
104+
private static boolean primaryPlateSetFlag;
102105

103106
private enum PlateMetadataFields
104107
{
@@ -126,6 +129,10 @@ public static void setupTest() throws Exception
126129
container.setActiveModules(newActiveModules);
127130
}
128131

132+
// Configure optional feature flag
133+
primaryPlateSetFlag = OptionalFeatureService.get().isFeatureEnabled(PlateService.DEPRECATE_PRIMARY_PLATE_SET_FLAG);
134+
OptionalFeatureService.get().setFeatureEnabled(PlateService.DEPRECATE_PRIMARY_PLATE_SET_FLAG, true, user);
135+
129136
Domain domain = PlateManager.get().getPlateMetadataDomain(container, user);
130137
if (domain != null)
131138
domain.delete(user);
@@ -201,11 +208,33 @@ public static void setupTest() throws Exception
201208
@AfterClass
202209
public static void cleanup()
203210
{
211+
// Restore optional feature flag
212+
OptionalFeatureService.get().setFeatureEnabled(PlateService.DEPRECATE_PRIMARY_PLATE_SET_FLAG, primaryPlateSetFlag, user);
213+
204214
deleteTestContainer();
205215
container = null;
206216
user = null;
207217
}
208218

219+
@Test
220+
public void testDeprecatePrimaryPlateSetFlag()
221+
{
222+
try
223+
{
224+
OptionalFeatureService.get().setFeatureEnabled(PlateService.DEPRECATE_PRIMARY_PLATE_SET_FLAG, false, user);
225+
226+
PlateSetImpl plateSetImpl = new PlateSetImpl();
227+
plateSetImpl.setType(PlateSetType.primary);
228+
plateSetImpl.setName("testDeprecatePrimaryPlateSetFlag");
229+
230+
assertCreatePlateSetThrows("The primary plate set feature is not enabled.", plateSetImpl, null, null);
231+
}
232+
finally
233+
{
234+
OptionalFeatureService.get().setFeatureEnabled(PlateService.DEPRECATE_PRIMARY_PLATE_SET_FLAG, true, user);
235+
}
236+
}
237+
209238
@Test
210239
public void testCreatePlateTemplate() throws Exception
211240
{

0 commit comments

Comments
 (0)