Skip to content

Commit 10f7f5e

Browse files
committed
Bugfixes around mGAP lucene indexes
1 parent 01f1d6a commit 10f7f5e

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

mGAP/src/org/labkey/mgap/columnTransforms/JBrowseHumanSessionTransform.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import org.labkey.api.util.GUID;
1010
import org.labkey.api.util.PageFlowUtil;
1111

12-
import java.util.Arrays;
1312
import java.util.Date;
1413
import java.util.HashMap;
1514
import java.util.List;
@@ -30,7 +29,7 @@ protected String getDatabaseName()
3029
}
3130

3231
@Override
33-
protected String getTrackJson(Results rs)
32+
protected String getTrackJson(boolean hasLuceneIndex)
3433
{
3534
return "{\"category\":\"mGAP Variant Catalog\",\"visibleByDefault\": true,\"additionalFeatureMsg\":\"<h2>**These annotations are created by lifting the macaque variants to human coordinates, and must be viewed in that context.</h2>\"}";
3635
}
@@ -93,7 +92,7 @@ private String getOrCreateJsonFile()
9392
row.put("createdby", getContainerUser().getUser().getUserId());
9493
row.put("modified", new Date());
9594
row.put("modifiedby", getContainerUser().getUser().getUserId());
96-
row.put("trackJson", getTrackJson());
95+
row.put("trackJson", getTrackJson(false));
9796

9897
getStatusLogger().info("creating jsonfile for output: " + outputFileId);
9998
List<Map<String, Object>> rows = jsonFiles.getUpdateService().insertRows(getContainerUser().getUser(), getContainerUser().getContainer(), List.of(row), new BatchValidationException(), null, new HashMap<>());

mGAP/src/org/labkey/mgap/columnTransforms/JBrowseSessionTransform.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ private String getOrCreateJsonFile(Results rs, String fieldKey) throws SQLExcept
270270

271271
if (isDefaultTrack)
272272
{
273-
row.put("trackJson", getTrackJson(rs));
273+
boolean hasLuceneIndex = StringUtils.trimToNull(rs.getString(FieldKey.fromString("luceneIndex/dataid/DataFileUrl"))) != null;
274+
row.put("trackJson", getTrackJson(hasLuceneIndex));
274275
}
275276
else
276277
{
@@ -307,22 +308,14 @@ protected String getDatabaseName()
307308
return "mGAP Release: " + getInputValue("version");
308309
}
309310

310-
protected String getTrackJson(Results rs)
311+
protected String getTrackJson(boolean hasLuceneIndex)
311312
{
312313
String indexString = "";
313314

314-
try
315-
{
316-
String luceneIndex = StringUtils.trimToNull(rs.getString(FieldKey.fromString("luceneIndex/dataid/DataFileUrl")));
317-
if (luceneIndex != null)
318-
{
319-
ArrayList<String> infoFields = new TableSelector(QueryService.get().getUserSchema(getContainerUser().getUser(), getContainerUser().getContainer(), mGAPSchema.NAME).getTable(mGAPSchema.TABLE_VARIANT_ANNOTATIONS), PageFlowUtil.set("infoKey"), new SimpleFilter(FieldKey.fromString("isIndexed"), true), null).getArrayList(String.class);
320-
indexString = ", \"createFullTextIndex\": true,\"infoFieldsForFullTextSearch\":\"" + (infoFields.isEmpty() ? "null" : StringUtils.join(infoFields, ",")) + "\"";
321-
}
322-
}
323-
catch (SQLException e)
315+
if (hasLuceneIndex)
324316
{
325-
getStatusLogger().error("Error extracting luceneIndex", e);
317+
ArrayList<String> infoFields = new TableSelector(QueryService.get().getUserSchema(getContainerUser().getUser(), getContainerUser().getContainer(), mGAPSchema.NAME).getTable(mGAPSchema.TABLE_VARIANT_ANNOTATIONS), PageFlowUtil.set("infoKey"), new SimpleFilter(FieldKey.fromString("isIndexed"), true), null).getArrayList(String.class);
318+
indexString = ", \"createFullTextIndex\": true,\"infoFieldsForFullTextSearch\":\"" + (infoFields.isEmpty() ? "null" : StringUtils.join(infoFields, ",")) + "\"";
326319
}
327320

328321
return "{\"category\":\"mGAP Variant Catalog\",\"visibleByDefault\": true,\"ensemblId\":\"Macaca_mulatta\",\"additionalFeatureMsg\":\"<h2>**The annotations below are primarily derived from human data sources (not macaque), and must be viewed in that context.</h2>\"" + indexString + "}";

0 commit comments

Comments
 (0)