@Test void testGetReferenceTracks() { when(userPermissionEvaluator.hasPermission(any(), eq(EntityTypePermission.READ_DATA))) .thenReturn(true); EntityType entity = mock(EntityType.class); Entity attrsEntity = mock(Entity.class); GenomeBrowserAttributes genomeBrowserAttributes = new GenomeBrowserAttributes(attrsEntity); GenomeBrowserTrack reference = GenomeBrowserTrack.create( "ref_id", "label", "ref_label", entity, GenomeBrowserSettings.TrackType.VARIANT, null, GenomeBrowserSettings.MolgenisReferenceMode.ALL, genomeBrowserAttributes, null, null, null, null, null); EntityType molgenisEntity = mock(EntityType.class); GenomeBrowserTrack track = GenomeBrowserTrack.create( "id", "label", "entityLabel", molgenisEntity, GenomeBrowserSettings.TrackType.VARIANT, Collections.singletonList(reference), GenomeBrowserSettings.MolgenisReferenceMode.CONFIGURED, genomeBrowserAttributes, "alert(\"test\")", "attr 1:attr1,reference attribute:REF,position on genome:POS", null, null, null); GenomeBrowserService genomeBrowserService = new GenomeBrowserService(dataService, userPermissionEvaluator); Map<String, GenomeBrowserTrack> result = genomeBrowserService.getReferenceTracks(track); assertEquals(1, result.size()); assertEquals(reference, result.get("ref_id")); }
Map<String, GenomeBrowserTrack> getReferenceTracks(GenomeBrowserTrack settings) { Map<String, GenomeBrowserTrack> result = new HashMap<>(); if (hasPermission() && settings.getMolgenisReferenceMode() != GenomeBrowserSettings.MolgenisReferenceMode.NONE) { if (settings.getMolgenisReferenceMode() == GenomeBrowserSettings.MolgenisReferenceMode.CONFIGURED) { settings .getMolgenisReferenceTracks() .forEach(referenceTrack -> result.put(referenceTrack.getId(), referenceTrack)); } else { List<GenomeBrowserAttributes> defaultGenomeBrowserAttributes = getDefaultGenomeBrowserAttributes().collect(Collectors.toList()); for (EntityType entityType : dataService.getMeta().getEntityTypes().collect(Collectors.toList())) { if (!entityType.isAbstract() && !entityType.equals(settings.getEntity())) { getGenomeBrowserTracks(entityType, defaultGenomeBrowserAttributes) .values() .forEach( referenceSettings -> result.put(referenceSettings.getId(), referenceSettings)); } } } } return result; }
GenomeBrowserService { Map<String, GenomeBrowserTrack> getReferenceTracks(GenomeBrowserTrack settings) { Map<String, GenomeBrowserTrack> result = new HashMap<>(); if (hasPermission() && settings.getMolgenisReferenceMode() != GenomeBrowserSettings.MolgenisReferenceMode.NONE) { if (settings.getMolgenisReferenceMode() == GenomeBrowserSettings.MolgenisReferenceMode.CONFIGURED) { settings .getMolgenisReferenceTracks() .forEach(referenceTrack -> result.put(referenceTrack.getId(), referenceTrack)); } else { List<GenomeBrowserAttributes> defaultGenomeBrowserAttributes = getDefaultGenomeBrowserAttributes().collect(Collectors.toList()); for (EntityType entityType : dataService.getMeta().getEntityTypes().collect(Collectors.toList())) { if (!entityType.isAbstract() && !entityType.equals(settings.getEntity())) { getGenomeBrowserTracks(entityType, defaultGenomeBrowserAttributes) .values() .forEach( referenceSettings -> result.put(referenceSettings.getId(), referenceSettings)); } } } } return result; } }
GenomeBrowserService { Map<String, GenomeBrowserTrack> getReferenceTracks(GenomeBrowserTrack settings) { Map<String, GenomeBrowserTrack> result = new HashMap<>(); if (hasPermission() && settings.getMolgenisReferenceMode() != GenomeBrowserSettings.MolgenisReferenceMode.NONE) { if (settings.getMolgenisReferenceMode() == GenomeBrowserSettings.MolgenisReferenceMode.CONFIGURED) { settings .getMolgenisReferenceTracks() .forEach(referenceTrack -> result.put(referenceTrack.getId(), referenceTrack)); } else { List<GenomeBrowserAttributes> defaultGenomeBrowserAttributes = getDefaultGenomeBrowserAttributes().collect(Collectors.toList()); for (EntityType entityType : dataService.getMeta().getEntityTypes().collect(Collectors.toList())) { if (!entityType.isAbstract() && !entityType.equals(settings.getEntity())) { getGenomeBrowserTracks(entityType, defaultGenomeBrowserAttributes) .values() .forEach( referenceSettings -> result.put(referenceSettings.getId(), referenceSettings)); } } } } return result; } GenomeBrowserService(
      DataService dataService, UserPermissionEvaluator userPermissionEvaluator); }
GenomeBrowserService { Map<String, GenomeBrowserTrack> getReferenceTracks(GenomeBrowserTrack settings) { Map<String, GenomeBrowserTrack> result = new HashMap<>(); if (hasPermission() && settings.getMolgenisReferenceMode() != GenomeBrowserSettings.MolgenisReferenceMode.NONE) { if (settings.getMolgenisReferenceMode() == GenomeBrowserSettings.MolgenisReferenceMode.CONFIGURED) { settings .getMolgenisReferenceTracks() .forEach(referenceTrack -> result.put(referenceTrack.getId(), referenceTrack)); } else { List<GenomeBrowserAttributes> defaultGenomeBrowserAttributes = getDefaultGenomeBrowserAttributes().collect(Collectors.toList()); for (EntityType entityType : dataService.getMeta().getEntityTypes().collect(Collectors.toList())) { if (!entityType.isAbstract() && !entityType.equals(settings.getEntity())) { getGenomeBrowserTracks(entityType, defaultGenomeBrowserAttributes) .values() .forEach( referenceSettings -> result.put(referenceSettings.getId(), referenceSettings)); } } } } return result; } GenomeBrowserService(
      DataService dataService, UserPermissionEvaluator userPermissionEvaluator); @Transactional(readOnly = true) @GetMapping(value = "/tracks", produces = APPLICATION_JSON_VALUE) @ResponseBody List<String> getGenomeBrowserTracksAsString(@RequestParam String entityTypeId); Map<String, GenomeBrowserTrack> getGenomeBrowserTracks(EntityType entityType); @Transactional(readOnly = true) List<String> getTracksString(Map<String, GenomeBrowserTrack> entityTracks); }
GenomeBrowserService { Map<String, GenomeBrowserTrack> getReferenceTracks(GenomeBrowserTrack settings) { Map<String, GenomeBrowserTrack> result = new HashMap<>(); if (hasPermission() && settings.getMolgenisReferenceMode() != GenomeBrowserSettings.MolgenisReferenceMode.NONE) { if (settings.getMolgenisReferenceMode() == GenomeBrowserSettings.MolgenisReferenceMode.CONFIGURED) { settings .getMolgenisReferenceTracks() .forEach(referenceTrack -> result.put(referenceTrack.getId(), referenceTrack)); } else { List<GenomeBrowserAttributes> defaultGenomeBrowserAttributes = getDefaultGenomeBrowserAttributes().collect(Collectors.toList()); for (EntityType entityType : dataService.getMeta().getEntityTypes().collect(Collectors.toList())) { if (!entityType.isAbstract() && !entityType.equals(settings.getEntity())) { getGenomeBrowserTracks(entityType, defaultGenomeBrowserAttributes) .values() .forEach( referenceSettings -> result.put(referenceSettings.getId(), referenceSettings)); } } } } return result; } GenomeBrowserService(
      DataService dataService, UserPermissionEvaluator userPermissionEvaluator); @Transactional(readOnly = true) @GetMapping(value = "/tracks", produces = APPLICATION_JSON_VALUE) @ResponseBody List<String> getGenomeBrowserTracksAsString(@RequestParam String entityTypeId); Map<String, GenomeBrowserTrack> getGenomeBrowserTracks(EntityType entityType); @Transactional(readOnly = true) List<String> getTracksString(Map<String, GenomeBrowserTrack> entityTracks); static final String URI; }