Skip to content

Commit 924d5ae

Browse files
committed
Force lucene config creation in mGAP ETL
1 parent 24841a5 commit 924d5ae

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

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

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
import org.labkey.api.pipeline.PipelineValidationException;
1818
import org.labkey.api.query.BatchValidationException;
1919
import org.labkey.api.query.FieldKey;
20+
import org.labkey.api.query.InvalidKeyException;
2021
import org.labkey.api.query.QueryService;
22+
import org.labkey.api.query.QueryUpdateServiceException;
2123
import org.labkey.api.query.UserSchema;
2224
import org.labkey.api.util.GUID;
2325
import org.labkey.api.util.PageFlowUtil;
@@ -178,6 +180,39 @@ protected void addTracks(final String databaseId, String releaseId)
178180
});
179181
}
180182

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+
181216
protected void getOrCreateDatabaseMember(String databaseId, String jsonFileId) throws Exception
182217
{
183218
SimpleFilter filter = new SimpleFilter(FieldKey.fromString("database"), databaseId);
@@ -261,7 +296,10 @@ private String getOrCreateJsonFile(Results rs, String fieldKey) throws SQLExcept
261296
if (ts1.exists())
262297
{
263298
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;
265303
}
266304

267305
try

0 commit comments

Comments
 (0)