package uk.ac.ebi.pride.proteogenomics.pogo.model.export.file;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.ac.ebi.pride.proteogenomics.pogo.model.PoGoEntry;
import uk.ac.ebi.pride.proteogenomics.pogo.model.export.PoGoExporter;
import uk.ac.ebi.pride.proteogenomics.pogo.model.export.PoGoExporterException;

import java.util.List;

/**
 * Project: libpogo
 * Package: uk.ac.ebi.pride.proteogenomics.pogo.model.export
 * Timestamp: 2017-06-12 15:01
 * ---
 * © 2017 Manuel Bernal Llinares <mbdebian@gmail.com>
 * All rights reserved.
 *
 * Yes, this class is the director and the builder itself, in a library of this size, overhauling the layers of
 * abstraction makes no sense
 */

public class PoGoFileExporter implements PoGoExporter {
    public enum HEADERS {
        EXPERIMENT("Experiment"),
        PEPTIDE("Peptide"),
        PSM("PSMs"),
        QUANT("Quant");

        private String value = "";

        HEADERS(String value) {
            this.value = value;
        }

        public String getValue() {
            return value;
        }
    }

    private String fileName = "";
    private PoGoEntrySerializer poGoEntrySerializer = null;
    private PoGoHeaderSerializer poGoHeaderSerializer = null;

    public PoGoFileExporter(String fileName, PoGoEntrySerializer poGoEntrySerializer, PoGoHeaderSerializer poGoHeaderSerializer) {
        this.fileName = fileName;
        this.poGoEntrySerializer = poGoEntrySerializer;
        this.poGoHeaderSerializer = poGoHeaderSerializer;
    }

    public void export(List<PoGoEntry> poGoEntries) throws PoGoExporterException {
        // TODO
    }
}

@@ -324,16 +324,37 @@
 ption;%0A%0A
+import java.io.File;%0A
 import j
@@ -776,16 +776,107 @@
 orter %7B%0A
+    private static final Logger logger = LoggerFactory.getLogger(PoGoFileExporter.class);%0A%0A
     publ
@@ -1732,16 +1732,274 @@
 // TODO%0A
+        File output = new File(fileName);%0A        if (!output.canWrite()) %7B%0A            throw new PoGoExporterException(String.format(%22Can't export PoGo data to file '%25s'%22, fileName));%0A        %7D%0A        // TODO - write header%0A        // TODO - Write entries%0A
     %7D%0A%7D%0A

check output file for PoGo export