From e5a11f58560059ca33aea630c674ce4ac12fd7e5 Mon Sep 17 00:00:00 2001 From: TonyWardell Date: Mon, 18 Jun 2018 11:06:44 +0100 Subject: [PATCH] Remove static presets. --- .../client/model/presets/CompositePreset.java | 5 -- .../presets/impl/CompositePresetImpl.java | 61 ------------------- .../client/controller/PresetsRetrievalIT.java | 21 +------ 3 files changed, 3 insertions(+), 84 deletions(-) diff --git a/quickgo-client/src/main/java/uk/ac/ebi/quickgo/client/model/presets/CompositePreset.java b/quickgo-client/src/main/java/uk/ac/ebi/quickgo/client/model/presets/CompositePreset.java index 79c63f7ba8..43debf0712 100644 --- a/quickgo-client/src/main/java/uk/ac/ebi/quickgo/client/model/presets/CompositePreset.java +++ b/quickgo-client/src/main/java/uk/ac/ebi/quickgo/client/model/presets/CompositePreset.java @@ -1,7 +1,6 @@ package uk.ac.ebi.quickgo.client.model.presets; import com.fasterxml.jackson.annotation.JsonFilter; - import java.util.List; /** @@ -28,10 +27,6 @@ public interface CompositePreset { List getQualifiers(); - List getAspects(); - - List getGeneProductTypes(); - List getExtRelations(); List getExtDatabases(); diff --git a/quickgo-client/src/main/java/uk/ac/ebi/quickgo/client/model/presets/impl/CompositePresetImpl.java b/quickgo-client/src/main/java/uk/ac/ebi/quickgo/client/model/presets/impl/CompositePresetImpl.java index fe33040e33..b4c49d3960 100644 --- a/quickgo-client/src/main/java/uk/ac/ebi/quickgo/client/model/presets/impl/CompositePresetImpl.java +++ b/quickgo-client/src/main/java/uk/ac/ebi/quickgo/client/model/presets/impl/CompositePresetImpl.java @@ -62,8 +62,6 @@ public CompositePresetImpl() { for (PresetType presetType : PresetType.values()) { presetsMap.put(presetType, new LinkedHashSet<>()); } - - initialiseStaticPresets(); } public void addPreset(PresetType presetType, PresetItem presetItem) { @@ -104,14 +102,6 @@ public void addPreset(PresetType presetType, PresetItem presetItem) { return sortedPresetItems(QUALIFIERS); } - @Override public List getAspects() { - return sortedPresetItems(ASPECTS); - } - - @Override public List getGeneProductTypes() { - return sortedPresetItems(GENE_PRODUCT_TYPES); - } - @Override public List getExtRelations() { return sortedPresetItems(EXT_RELATIONS); @@ -122,11 +112,6 @@ public List getExtDatabases() { return sortedPresetItems(EXT_DATABASES); } - private void initialiseStaticPresets() { - presetsMap.put(ASPECTS, StaticAspects.createAspects()); - presetsMap.put(GENE_PRODUCT_TYPES, StaticGeneProductTypes.createGeneProductTypes()); - } - /** * Sorts the presets according to the ordering rules defined in the class description. This method * makes use of the default grouping function defined by {@link CompositePresetImpl#defaultGrouping()}. @@ -230,50 +215,4 @@ private static void ifPresetItemMatchesThenApply( .findFirst() .ifPresent(itemConsumer); } - - private static class StaticAspects { - - static Set createAspects() { - Set presetAspects = new HashSet<>(); - Arrays.stream(Aspect.values()) - .forEach(aspect -> insertAspect(presetAspects, aspect)); - return presetAspects; - } - - private static void insertAspect(Set presets, Aspect aspect) { - presets.add(PresetItem - .createWithName(aspect.getFullName()) - .withProperty(PresetItem.Property.ID.getKey(), aspect.getScientificName()).build()); - } - } - - private static class StaticGeneProductTypes { - - private enum GeneProductType { - PROTEINS("Proteins", "protein"), - RNA("RNA", "miRNA"), - COMPLEXES("Complexes", "complex"); - - private final String name; - private final String shortName; - - GeneProductType(String name, String shortName) { - this.name = name; - this.shortName = shortName; - } - } - - static Set createGeneProductTypes() { - Set presetAspects = new HashSet<>(); - Arrays.stream(GeneProductType.values()) - .forEach(aspect -> insertGeneProductType(presetAspects, aspect)); - return presetAspects; - } - - private static void insertGeneProductType(Set presets, GeneProductType geneProductType) { - presets.add(PresetItem - .createWithName(geneProductType.name) - .withProperty(PresetItem.Property.ID.getKey(), geneProductType.shortName).build()); - } - } } diff --git a/quickgo-client/src/test/java/uk/ac/ebi/quickgo/client/controller/PresetsRetrievalIT.java b/quickgo-client/src/test/java/uk/ac/ebi/quickgo/client/controller/PresetsRetrievalIT.java index f490f2b2ae..8215603356 100644 --- a/quickgo-client/src/test/java/uk/ac/ebi/quickgo/client/controller/PresetsRetrievalIT.java +++ b/quickgo-client/src/test/java/uk/ac/ebi/quickgo/client/controller/PresetsRetrievalIT.java @@ -1,5 +1,8 @@ package uk.ac.ebi.quickgo.client.controller; +import uk.ac.ebi.quickgo.client.QuickGOREST; +import uk.ac.ebi.quickgo.client.model.presets.impl.CompositePresetImpl; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -10,8 +13,6 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; -import uk.ac.ebi.quickgo.client.QuickGOREST; -import uk.ac.ebi.quickgo.client.model.presets.impl.CompositePresetImpl; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.hasSize; @@ -106,22 +107,6 @@ public void canRetrieveQualifierPresets() throws Exception { .andExpect(jsonPath("$.qualifiers").exists()); } - @Test - public void canRetrieveAspectPresets() throws Exception { - mockMvc.perform(get(RESOURCE_URL)) - .andDo(print()) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.aspects.*", hasSize(3))); - } - - @Test - public void canRetrieveGeneProductTypesPresets() throws Exception { - mockMvc.perform(get(RESOURCE_URL)) - .andDo(print()) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.geneProductTypes.*", hasSize(3))); - } - @Test public void canRetrieveAnnotationExtensionRelationsPresets() throws Exception { mockMvc.perform(get(RESOURCE_URL))