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

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * A specification of format and content for the statistics download.
 * @author Tony Wardell
 * Date: 26/09/2017
 * Time: 10:52
 * Created with IntelliJ IDEA.
 */
public class StatisticsWorkBookLayout {
    public static final Map<String, StatisticsToWorkbook.SheetLayout> SHEET_LAYOUT_MAP = new HashMap<>();
    static final String ANNOTATION = "annotation";
    static final String GENE_PRODUCT = "geneProduct";

    public static final String[] SECTION_TYPES = new String[]{ANNOTATION, GENE_PRODUCT};

    //Annotation stats
    private static final AnnotationSectionLayout SL_ANNOTATION_REFERENCES =
            new AnnotationSectionLayout("References (by annotation)");
    private static final AnnotationSectionLayout SL_ANNOTATION_TAXON =
            new AnnotationSectionLayout("Taxon IDs (by annotation)");
    private static final AnnotationSectionLayout SL_ANNOTATION_ASSIGNED =
            new AnnotationSectionLayout("Sources (by annotation)");
    private static final AnnotationSectionLayout SL_ANNOTATION_GOID =
            new AnnotationSectionLayout("GO IDs (by annotation)");
    private static final AnnotationSectionLayout SL_ANNOTATION_ASPECT =
            new AnnotationSectionLayout("Aspects (by annotation)");
    private static final AnnotationSectionLayout SL_ANNOTATION_EVIDENCE_CODE =
            new AnnotationSectionLayout("Evidence Codes (by annotation)");

    //Gene product stats
    private static final GeneProductSectionLayout SL_GENE_PRODUCT_GOID =
            new GeneProductSectionLayout("GO IDs (by protein)");
    private static final GeneProductSectionLayout SL_GENE_PRODUCT_ASPECT =
            new GeneProductSectionLayout("Aspects (by protein)");
    private static final GeneProductSectionLayout SL_GENE_PRODUCT_EVIDENCE_CODE =
            new GeneProductSectionLayout("Evidence Codes (by protein)");
    private static final GeneProductSectionLayout SL_GENE_PRODUCT_REFERENCES =
            new GeneProductSectionLayout("References (by protein)");
    private static final GeneProductSectionLayout SL_GENE_PRODUCT_TAXON =
            new GeneProductSectionLayout("Taxon IDs (by protein)");
    private static final GeneProductSectionLayout SL_GENE_PRODUCT_ASSIGNED =
            new GeneProductSectionLayout("Sources (by protein)");

    static {
        SHEET_LAYOUT_MAP.put("goId",
                new StatisticsToWorkbook.SheetLayout("goid",
                        Arrays.asList(SL_ANNOTATION_GOID,
                                SL_GENE_PRODUCT_GOID)));
        SHEET_LAYOUT_MAP.put("aspect",
                new StatisticsToWorkbook.SheetLayout("aspect",
                        Arrays.asList(SL_ANNOTATION_ASPECT,
                                SL_GENE_PRODUCT_ASPECT)));
        SHEET_LAYOUT_MAP.put("evidenceCode",
                new StatisticsToWorkbook.SheetLayout("evidence",
                        Arrays.asList(SL_ANNOTATION_EVIDENCE_CODE,
                                SL_GENE_PRODUCT_EVIDENCE_CODE)));
        SHEET_LAYOUT_MAP.put("reference",
                new StatisticsToWorkbook.SheetLayout("reference",
                        Arrays.asList(SL_ANNOTATION_REFERENCES,
                                SL_GENE_PRODUCT_REFERENCES)));
        SHEET_LAYOUT_MAP.put("taxonId",
                new StatisticsToWorkbook.SheetLayout("taxon",
                        Arrays.asList(SL_ANNOTATION_TAXON,
                                SL_GENE_PRODUCT_TAXON)));
        SHEET_LAYOUT_MAP.put("assignedBy",
                new StatisticsToWorkbook.SheetLayout("assigned",
                        Arrays.asList(SL_ANNOTATION_ASSIGNED,
                                SL_GENE_PRODUCT_ASSIGNED)));
    }

    static class AnnotationSectionLayout extends StatisticsToWorkbook.SectionLayout {
        private static final int BY_ANNOTATION_STARTING_COLUMN = 0;

        AnnotationSectionLayout(String header) {
            super(ANNOTATION, header, BY_ANNOTATION_STARTING_COLUMN);
        }
    }

    static class GeneProductSectionLayout extends StatisticsToWorkbook.SectionLayout {
        private static final int BY_PROTEIN_STARTING_COLUMN = 10;

        GeneProductSectionLayout(String header) {
            super(GENE_PRODUCT, header, BY_PROTEIN_STARTING_COLUMN);
        }
    }
}

@@ -368,36 +368,42 @@
 String, 
-StatisticsToWorkbook
+WorkbookFromStatisticsImpl
 .SheetLa
@@ -2488,36 +2488,42 @@
     new 
-StatisticsToWorkbook
+WorkbookFromStatisticsImpl
 .SheetLa
@@ -2709,36 +2709,42 @@
     new 
-StatisticsToWorkbook
+WorkbookFromStatisticsImpl
 .SheetLa
@@ -2942,36 +2942,42 @@
     new 
-StatisticsToWorkbook
+WorkbookFromStatisticsImpl
 .SheetLa
@@ -3188,36 +3188,42 @@
     new 
-StatisticsToWorkbook
+WorkbookFromStatisticsImpl
 .SheetLa
@@ -3427,36 +3427,42 @@
     new 
-StatisticsToWorkbook
+WorkbookFromStatisticsImpl
 .SheetLa
@@ -3655,36 +3655,42 @@
     new 
-StatisticsToWorkbook
+WorkbookFromStatisticsImpl
 .SheetLa
@@ -3885,36 +3885,42 @@
 extends 
-StatisticsToWorkbook
+WorkbookFromStatisticsImpl
 .Section
@@ -4187,28 +4187,34 @@
 nds 
-StatisticsToWorkbook
+WorkbookFromStatisticsImpl
 .Sec

Rename StatisticsToWorkbook -> WorkbookFromStatisticsImpl