@@ -0,0 +1,2968 @@
+package dk.statsbiblioteket.medieplatform.newspaper.manualQA;%0A%0Aimport dk.statsbiblioteket.medieplatform.autonomous.Batch;%0Aimport dk.statsbiblioteket.medieplatform.autonomous.ResultCollector;%0Aimport dk.statsbiblioteket.medieplatform.autonomous.iterator.common.AttributeParsingEvent;%0Aimport dk.statsbiblioteket.medieplatform.autonomous.iterator.common.NodeBeginsParsingEvent;%0Aimport dk.statsbiblioteket.medieplatform.autonomous.iterator.common.NodeEndParsingEvent;%0Aimport dk.statsbiblioteket.medieplatform.autonomous.iterator.eventhandlers.DefaultTreeEventHandler;%0Aimport dk.statsbiblioteket.medieplatform.newspaper.manualQA.flagging.FlaggingCollector;%0A%0Aimport javax.xml.bind.JAXBException;%0Aimport java.io.ByteArrayInputStream;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0A%0A%0Apublic class DarknessHistogramChecker extends DefaultTreeEventHandler %7B%0A    private final ResultCollector resultCollector;%0A    private final FlaggingCollector flaggingCollector;%0A    private Batch batch;%0A%0A%0A    public DarknessHistogramChecker(ResultCollector resultCollector, FlaggingCollector flaggingCollector, Batch batch) %7B%0A        this.resultCollector = resultCollector;%0A        this.flaggingCollector = flaggingCollector;%0A        this.batch = batch;%0A    %7D%0A%0A%0A    @Override%0A    public void handleAttribute(AttributeParsingEvent event) %7B%0A        try %7B%0A            if (event.getName().endsWith(%22.histogram.xml%22)) %7B%0A                long%5B%5D histogram = new Histogram(event.getData()).values();%0A                // TODO%0A%0A                boolean tooDark = histogramIsTooDark(histogram);%0A%0A                if (tooDark) %7B%0A                    // TODO set flag in list of histograms/pics%0A                %7D%0A%0A            %7D%0A        %7D catch (Exception e) %7B%0A            resultCollector.addFailure(event.getName(), %22exception%22, getComponent(), e.getMessage());%0A        %7D%0A    %7D%0A%0A%0A    private boolean histogramIsTooDark(long%5B%5D histogram) %7B%0A        // TODO%0A        return false;%0A    %7D%0A%0A%0A    private String getComponent() %7B%0A        return getClass().getName();%0A    %7D%0A%0A%0A    @Override%0A    public void handleNodeBegin(NodeBeginsParsingEvent event) %7B%0A        try %7B%0A            if (event.getName().matches(%22/%22 + batch.getBatchID() + %22-%22 + %22%5B0-9%5D%7B2%7D$%22)) %7B%0A                // We have now entered a film, so clear the numbers for this film in readying for a new one%0A                // TODO%0A%0A            %7D%0A        %7D catch (Exception e) %7B%0A            resultCollector.addFailure(event.getName(), %22exception%22, getComponent(), e.getMessage());%0A        %7D%0A    %7D%0A%0A%0A    @Override%0A    public void handleNodeEnd(NodeEndParsingEvent event) %7B%0A        try %7B%0A            if (event.getName().matches(%22/%22 + batch.getBatchID() + %22-%22 + %22%5B0-9%5D%7B2%7D$%22)) %7B%0A                // We have now left a film, so flag if there were too many dark pages%0A                // TODO%0A%0A%0A%0A%0A            %7D%0A        %7D catch (Exception e) %7B%0A            resultCollector.addFailure(event.getName(), %22exception%22, getComponent(), e.getMessage());%0A        %7D%0A    %7D%0A%7D%0A

Work in progress