|
17 | 17 | import org.labkey.api.pipeline.PipelineValidationException; |
18 | 18 | import org.labkey.api.query.BatchValidationException; |
19 | 19 | import org.labkey.api.query.FieldKey; |
| 20 | +import org.labkey.api.query.InvalidKeyException; |
20 | 21 | import org.labkey.api.query.QueryService; |
| 22 | +import org.labkey.api.query.QueryUpdateServiceException; |
21 | 23 | import org.labkey.api.query.UserSchema; |
22 | 24 | import org.labkey.api.util.GUID; |
23 | 25 | import org.labkey.api.util.PageFlowUtil; |
@@ -178,6 +180,39 @@ protected void addTracks(final String databaseId, String releaseId) |
178 | 180 | }); |
179 | 181 | } |
180 | 182 |
|
| 183 | + private void ensureLuceneData(String objectId) |
| 184 | + { |
| 185 | + //determine if there is already a JSONfile for this outputfile |
| 186 | + TableSelector ts1 = new TableSelector(getJsonFiles(), PageFlowUtil.set("isprimarytrack", "container"), new SimpleFilter(FieldKey.fromString("objectid"), objectId), null); |
| 187 | + if (!ts1.exists()) |
| 188 | + { |
| 189 | + getStatusLogger().error("expected jsonfile to exist: " + objectId); |
| 190 | + return; |
| 191 | + } |
| 192 | + |
| 193 | + try (Results rs = ts1.getResults()) |
| 194 | + { |
| 195 | + boolean isDefaultTrack = rs.getBoolean(FieldKey.fromString("isprimarytrack")); |
| 196 | + if (!isDefaultTrack) |
| 197 | + { |
| 198 | + return; |
| 199 | + } |
| 200 | + |
| 201 | + String containerId = rs.getString(FieldKey.fromString("container")); |
| 202 | + |
| 203 | + Map<String, Object> row = new CaseInsensitiveHashMap<>(); |
| 204 | + row.put("objectid", objectId); |
| 205 | + row.put("container", containerId); |
| 206 | + row.put("trackJson", getTrackJson(true)); |
| 207 | + |
| 208 | + getJsonFiles().getUpdateService().updateRows(getContainerUser().getUser(), getContainerUser().getContainer(), Arrays.asList(row), Arrays.asList(new CaseInsensitiveHashMap<>(Map.of("objectid", objectId))), new BatchValidationException(), null, null); |
| 209 | + } |
| 210 | + catch (SQLException | QueryUpdateServiceException | BatchValidationException | InvalidKeyException e) |
| 211 | + { |
| 212 | + getStatusLogger().error("Unable to update lucene config", e); |
| 213 | + } |
| 214 | + } |
| 215 | + |
181 | 216 | protected void getOrCreateDatabaseMember(String databaseId, String jsonFileId) throws Exception |
182 | 217 | { |
183 | 218 | SimpleFilter filter = new SimpleFilter(FieldKey.fromString("database"), databaseId); |
@@ -261,7 +296,10 @@ private String getOrCreateJsonFile(Results rs, String fieldKey) throws SQLExcept |
261 | 296 | if (ts1.exists()) |
262 | 297 | { |
263 | 298 | getStatusLogger().info("jsonfile already exists for output: " + outputFileId); |
264 | | - return ts1.getArrayList(String.class).get(0); |
| 299 | + String objectId = ts1.getArrayList(String.class).get(0); |
| 300 | + ensureLuceneData(objectId); |
| 301 | + |
| 302 | + return objectId; |
265 | 303 | } |
266 | 304 |
|
267 | 305 | try |
|
0 commit comments