Search in sources :

Example 1 with GenomeBrowserSettings

use of org.molgenis.genomebrowser.meta.GenomeBrowserSettings in project molgenis by molgenis.

the class GenomeBrowserService method getGenomeBrowserTracks.

public Map<String, GenomeBrowserTrack> getGenomeBrowserTracks(EntityType entityType, List<GenomeBrowserAttributes> defaultGenomeBrowserAttributes) {
    Map<String, GenomeBrowserTrack> settings = new HashMap<>();
    dataService.findAll(GENOMEBROWSERSETTINGS, new QueryImpl<GenomeBrowserSettings>().eq(GenomeBrowserSettingsMetadata.ENTITY, entityType.getIdValue()), GenomeBrowserSettings.class).forEach(referenceSettings -> settings.put(referenceSettings.getIdentifier(), GenomeBrowserTrack.create(referenceSettings)));
    if (settings.isEmpty()) {
        // if not check if attrs match any default config
        Collections.sort(defaultGenomeBrowserAttributes);
        for (GenomeBrowserAttributes genomeBrowserAttributes : defaultGenomeBrowserAttributes) {
            List<String> attributeNames = Lists.newArrayList(entityType.getAttributeNames());
            if (areAllAttributeAvailable(genomeBrowserAttributes, attributeNames)) {
                GenomeBrowserTrack genomeBrowserTrack = getDefaultGenomeBrowserSettingsEntity(entityType, genomeBrowserAttributes);
                settings.put(genomeBrowserTrack.getId(), genomeBrowserTrack);
                break;
            }
        }
    }
    return settings;
}
Also used : GenomeBrowserAttributes(org.molgenis.genomebrowser.meta.GenomeBrowserAttributes) HashMap(java.util.HashMap) GenomeBrowserSettings(org.molgenis.genomebrowser.meta.GenomeBrowserSettings) GenomeBrowserTrack(org.molgenis.genomebrowser.GenomeBrowserTrack)

Aggregations

HashMap (java.util.HashMap)1 GenomeBrowserTrack (org.molgenis.genomebrowser.GenomeBrowserTrack)1 GenomeBrowserAttributes (org.molgenis.genomebrowser.meta.GenomeBrowserAttributes)1 GenomeBrowserSettings (org.molgenis.genomebrowser.meta.GenomeBrowserSettings)1