Skip to content

Commit f113ab2

Browse files
committed
Bugfix to session title in JBrowse viewer
1 parent 3b70af8 commit f113ab2

File tree

3 files changed

+40
-164
lines changed

3 files changed

+40
-164
lines changed

jbrowse/src/client/JBrowse/Browser/plugins/ExtendedVariantPlugin/ExtendedVariantWidget/ExtendedVariantWidget.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,9 @@ export default jbrowse => {
348348
feature={feat}
349349
{...props}
350350
/>
351+
{annTable}
351352
{displays}
352353
{infoDisplays}
353-
{annTable}
354354
{makeChart(samples, feat, classes, trackId)}
355355
</Paper>
356356
)

jbrowse/src/org/labkey/jbrowse/JBrowseController.java

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
import java.util.Map;
9191
import java.util.Set;
9292
import java.util.regex.Matcher;
93+
import java.util.regex.Pattern;
9394

9495
public class JBrowseController extends SpringActionController
9596
{
@@ -335,15 +336,29 @@ public void setDatabaseIds(String[] databaseIds)
335336
}
336337
}
337338

339+
// Based on: https://www.code4copy.com/java/validate-uuid-string-java/
340+
private final static Pattern UUID_REGEX_PATTERN = Pattern.compile("^[{]?[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?$");
341+
342+
private static boolean isValidUUID(String str)
343+
{
344+
if (str == null)
345+
{
346+
return false;
347+
}
348+
349+
return UUID_REGEX_PATTERN.matcher(str).matches();
350+
}
351+
338352
@RequiresPermission(ReadPermission.class)
339-
public class BrowserAction extends SimpleViewAction<BrowserForm>
353+
public class JBrowseAction extends SimpleViewAction<BrowserForm>
340354
{
341355
private String _title;
342356

343357
@Override
344358
public ModelAndView getView(BrowserForm form, BindException errors) throws Exception
345359
{
346-
JBrowseSession db = new TableSelector(JBrowseSchema.getInstance().getTable(JBrowseSchema.TABLE_DATABASES), new SimpleFilter(FieldKey.fromString("objectid"), form.getDatabase()), null).getObject(JBrowseSession.class);
360+
String guid = form.getEffectiveSessionId();
361+
JBrowseSession db = isValidUUID(guid) ? new TableSelector(JBrowseSchema.getInstance().getTable(JBrowseSchema.TABLE_DATABASES), new SimpleFilter(FieldKey.fromString("objectid"), form.getEffectiveSessionId()), null).getObject(JBrowseSession.class) : null;
347362
_title = db == null ? "JBrowse" : db.getName();
348363
form.setPageTitle(_title);
349364

@@ -361,9 +376,16 @@ public void addNavTrail(NavTree root)
361376
}
362377
}
363378

379+
@RequiresPermission(ReadPermission.class)
380+
public class BrowserAction extends JBrowseAction
381+
{
382+
383+
}
384+
364385
public static class BrowserForm
365386
{
366387
private String _database;
388+
private String _session;
367389
private String _pageTitle;
368390

369391
public String getDatabase()
@@ -376,6 +398,21 @@ public void setDatabase(String database)
376398
_database = database;
377399
}
378400

401+
public String getSession()
402+
{
403+
return _session;
404+
}
405+
406+
public String getEffectiveSessionId()
407+
{
408+
return _session == null ? _database : _session;
409+
}
410+
411+
public void setSession(String session)
412+
{
413+
_session = session;
414+
}
415+
379416
public String getPageTitle()
380417
{
381418
return _pageTitle;

jbrowse/src/org/labkey/jbrowse/view/browser.jsp

Lines changed: 0 additions & 161 deletions
This file was deleted.

0 commit comments

Comments
 (0)