package uk.ac.ebi.quickgo.annotation.service.statistics;

import uk.ac.ebi.quickgo.annotation.common.AnnotationFields;
import uk.ac.ebi.quickgo.rest.search.AggregateFunction;

import java.util.Collections;
import java.util.List;

import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Arrays.asList;
import static uk.ac.ebi.quickgo.annotation.service.statistics.RequiredStatisticType.statsType;

/**
 * Represents the required statistics that must be shown about annotations. Comprises
 * a list of {@link RequiredStatistic} entities, each of which captures particular details
 * of the annotations over which they have been calculated.
 *
 * The {@link RequiredStatistics} include statistics over annotations and gene products. Within each
 * statistic, by default of 10 items will be displayed for each statistic type (e.g., evidences, taxons, etc.),
 * except for GO terms, which by default displayed 200 ids.
 *
 * Created 16/08/17
 * @author Edd
 */
public class RequiredStatistics {
    static final int DEFAULT_GO_TERM_LIMIT = 200;
    protected static final List<RequiredStatisticType> STATS_TYPES;
    static final String ANNOTATION = "annotation";
    static final String GENE_PRODUCT = "geneProduct";

    static {
        STATS_TYPES = asList(
                statsType(AnnotationFields.Facetable.GO_ID, DEFAULT_GO_TERM_LIMIT),
                statsType(AnnotationFields.Facetable.TAXON_ID),
                statsType(AnnotationFields.Facetable.REFERENCE),
                statsType(AnnotationFields.Facetable.EVIDENCE_CODE),
                statsType(AnnotationFields.Facetable.ASSIGNED_BY),
                statsType(AnnotationFields.Facetable.GO_ASPECT),
                statsType(AnnotationFields.Facetable.GENE_PRODUCT_ID)
        );
    }

    protected List<RequiredStatistic> requiredStats;
    protected List<RequiredStatisticType> configuredTypes;

    RequiredStatistics(StatisticsTypeConfigurer statsConfigurer) {
        checkArgument(statsConfigurer != null, "Stats configurer cannot be null");
        configuredTypes = statsConfigurer.getConfiguredStatsTypes(getStatsTypes());
        requiredStats = Collections.unmodifiableList(asList(annotationStats(), geneProductStats()));
    }

    public List<RequiredStatistic> getRequiredStatistics() {
        return requiredStats;
    }

    protected RequiredStatistic annotationStats() {
        return new RequiredStatistic(ANNOTATION, AnnotationFields.Facetable.ID,
                AggregateFunction.COUNT.getName(), configuredTypes);
    }

    protected RequiredStatistic geneProductStats() {
        return new RequiredStatistic(GENE_PRODUCT, AnnotationFields.Facetable.GENE_PRODUCT_ID,
                AggregateFunction.UNIQUE.getName(), configuredTypes);
    }

    protected List<RequiredStatisticType> getStatsTypes() {
        return STATS_TYPES;
    }
}

@@ -1038,107 +1038,97 @@
 nal 
-int DEFAULT_GO_TERM_LIMIT = 200;%0A    protected static final List%3CRequiredStatisticType%3E STATS_TYPES
+List%3CRequiredStatisticType%3E STATS_TYPES;%0A    static final int DEFAULT_GO_TERM_LIMIT = 200
 ;%0A  
@@ -1690,79 +1690,8 @@
 ECT)
-,%0A                statsType(AnnotationFields.Facetable.GENE_PRODUCT_ID)
 %0A   
@@ -1703,39 +1703,37 @@
 );%0A    %7D%0A%0A    pr
-otec
+iva
 te
-d
  List%3CRequiredSt
@@ -1758,31 +1758,29 @@
 tats;%0A    pr
-otec
+iva
 te
-d
  List%3CRequir
@@ -2252,39 +2252,37 @@
 s;%0A    %7D%0A%0A    pr
-otec
+iva
 te
-d
  RequiredStatist
@@ -2466,23 +2466,21 @@
 %0A%0A    pr
-otec
+iva
 te
-d
  Require

Change the access to members.