|
18 | 18 | import org.apache.commons.lang3.StringUtils; |
19 | 19 | import org.apache.logging.log4j.Logger; |
20 | 20 | import org.apache.logging.log4j.LogManager; |
| 21 | +import org.jetbrains.annotations.NotNull; |
21 | 22 | import org.jetbrains.annotations.Nullable; |
22 | 23 | import org.labkey.api.assay.AssayProvider; |
23 | 24 | import org.labkey.api.assay.AssayService; |
@@ -336,26 +337,33 @@ public void updateWorkbookTags(User u, Container c, Collection<String> tags, boo |
336 | 337 | } |
337 | 338 | } |
338 | 339 |
|
| 340 | + public void populateDefaultData(User u, Container c) |
| 341 | + { |
| 342 | + populateDefaultData(u, c, Arrays.asList(LaboratorySchema.TABLE_SAMPLE_TYPE, LaboratorySchema.TABLE_SPECIES)); |
| 343 | + } |
| 344 | + |
339 | 345 | //pass null to populate all supported tables |
340 | | - public void populateDefaultData(User u, Container c, @Nullable List<String> tableNames) |
| 346 | + public void populateDefaultData(User u, Container c, @NotNull List<String> tableNames) |
341 | 347 | { |
342 | 348 | if (c.isWorkbook()) |
343 | 349 | { |
344 | 350 | return; |
345 | 351 | } |
346 | 352 |
|
347 | | - if (tableNames == null) |
348 | | - { |
349 | | - tableNames = new ArrayList<>(); |
350 | | - tableNames.add(LaboratorySchema.TABLE_SAMPLE_TYPE); |
351 | | - } |
352 | | - |
353 | 353 | for (String name : tableNames) |
354 | 354 | { |
355 | | - if (LaboratorySchema.TABLE_SAMPLE_TYPE.equalsIgnoreCase(name)) |
| 355 | + if (LaboratorySchema.TABLE_SAMPLE_TYPE.equalsIgnoreCase(name) ) |
356 | 356 | { |
357 | 357 | populateDefaultDataForTable(u, c, "laboratory", LaboratorySchema.TABLE_SAMPLE_TYPE, PageFlowUtil.set("type"), "type"); |
358 | 358 | } |
| 359 | + else if (LaboratorySchema.TABLE_SPECIES.equalsIgnoreCase(name) ) |
| 360 | + { |
| 361 | + populateDefaultDataForTable(u, c, "laboratory", LaboratorySchema.TABLE_SPECIES, PageFlowUtil.set("common_name", "scientific_name", "mhc_prefix"), "common_name"); |
| 362 | + } |
| 363 | + else |
| 364 | + { |
| 365 | + throw new IllegalArgumentException("Unknown table: " + name); |
| 366 | + } |
359 | 367 | } |
360 | 368 | } |
361 | 369 |
|
|
0 commit comments