

package org.slc.sli.ingestion.validation;

import com.mongodb.DB;

import org.slc.sli.ingestion.reporting.AbstractMessageReport;
import org.slc.sli.ingestion.reporting.ReportStats;
import org.slc.sli.ingestion.reporting.Source;

import java.util.Map;

/**
 * Checks if the indexes are present for all the dbs before processing this job.
 * This validator fails if index files are not defined, it is only to add an
 * error message in the log file if the index counts do not match.
 *
 * @author unavani
 *
 */
public class IndexValidator extends ComplexValidator<DB> {
    private static final String STAGE_NAME = "Index Validation";

    @Override
    public boolean isValid(DB db, AbstractMessageReport report, ReportStats reportStats, Source source, Map<String, Object> parameters) {
        boolean isValid = true;

        for (Validator<DB> validator : this.getValidators()) {
            isValid &= validator.isValid(db, report, reportStats, source, null);
        }

        return isValid;
    }

    @Override
    public String getStageName() {
        return STAGE_NAME;
    }

}
