package dk.statsbiblioteket.newspaper.processmonitor.backend;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import dk.statsbiblioteket.newspaper.mfpakintegration.database.MfPakDAO;

@Component
public class MfPakBatchEnricher implements BatchEnricher {

    private MfPakDAO mfpak;

    public MfPakDAO getMfpak() {
        return mfpak;
    }

    public void setMfpak(MfPakDAO mfpak) {
        this.mfpak = mfpak;
    }
    
    /**
     * Enriches the batch objects with 'avisid' and date intervals from the mfpak database. 
     * The returned reference to list of batches is the same as the one taken as input. 
     */
    @Override
    public List<Batch> enrich(List<Batch> batches) {
        return batches;
    }
    
}

@@ -56,16 +56,46 @@
 ckend;%0A%0A
+import java.sql.SQLException;%0A
 import j
@@ -145,16 +145,73 @@
 ource;%0A%0A
+import org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A
 import o
@@ -301,24 +301,118 @@
 Component;%0A%0A
+import dk.statsbiblioteket.newspaper.mfpakintegration.database.InconsistentDatabaseException;%0A
 import dk.st
@@ -572,16 +572,77 @@
  mfpak;%0A
+    private Logger log = LoggerFactory.getLogger(getClass());
 %0A    pub
@@ -1039,24 +1039,382 @@
  batches) %7B%0A
+        %0A        for(Batch b : batches) %7B%0A            String batchID = b.getBatchID();%0A            try %7B%0A                b.setAvisID(mfpak.getNewspaperID(batchID));    %0A            %7D catch (InconsistentDatabaseException %7C SQLException e) %7B%0A                log.debug(%22Failed to enrich batch %7B%7D%22, batchID, e);%0A            %7D%0A                %0A        %7D%0A        %0A
         retu

add enrichment of web-batch object with avisID