|
15 | 15 | */ |
16 | 16 | package org.labkey.oconnorexperiments.query; |
17 | 17 |
|
| 18 | +import org.apache.commons.beanutils.ConvertUtils; |
18 | 19 | import org.jetbrains.annotations.NotNull; |
19 | 20 | import org.jetbrains.annotations.Nullable; |
20 | | -import org.json.JSONArray; |
21 | 21 | import org.labkey.api.collections.CaseInsensitiveHashMap; |
22 | 22 | import org.labkey.api.collections.RowMapFactory; |
23 | 23 | import org.labkey.api.data.ColumnInfo; |
|
29 | 29 | import org.labkey.api.data.Filter; |
30 | 30 | import org.labkey.api.data.JdbcType; |
31 | 31 | import org.labkey.api.data.LookupColumn; |
| 32 | +import org.labkey.api.data.MultiChoice; |
32 | 33 | import org.labkey.api.data.MultiValuedForeignKey; |
33 | 34 | import org.labkey.api.data.SchemaTableInfo; |
34 | 35 | import org.labkey.api.data.SimpleFilter; |
@@ -317,16 +318,10 @@ private void insertParentExperiments(User user, List<Map<String, Object>> rows, |
317 | 318 | List<Map<String, Object>> parentExperimentRows = new ArrayList<>(); |
318 | 319 | String c = (String)row.get("container"); |
319 | 320 | Object v = row.get("ParentExperiments"); |
320 | | - String[] parentExperiments = null; |
321 | | - if (v instanceof String[]) |
322 | | - parentExperiments = (String[])v; |
323 | | - else if (v instanceof JSONArray ja) |
324 | | - { |
325 | | - ArrayList<String> s = new ArrayList<>(); |
326 | | - for (Object o : ja.toList()) |
327 | | - s.add(o.toString()); |
328 | | - parentExperiments = s.toArray(new String[0]); |
329 | | - } |
| 321 | + |
| 322 | + // use a bit of shared code for this conversion |
| 323 | + MultiChoice.Array arr = (MultiChoice.Array)ConvertUtils.convert(v, MultiChoice.Array.class); |
| 324 | + String[] parentExperiments = null == arr || arr.isEmpty() ? null : arr.getStringArray(); |
330 | 325 |
|
331 | 326 | Container innerContainer = ContainerManager.getForId(c); |
332 | 327 | if (innerContainer == null) |
|
0 commit comments