package uk.ac.ebi.spot.goci.service;

import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import uk.ac.ebi.spot.goci.model.Association;
import uk.ac.ebi.spot.goci.model.ValidationError;

import java.util.ArrayList;
import java.util.Collection;

/**
 * Created by emma on 01/04/2016.
 *
 * @author emma
 *         <p>
 *         Full checking service will run all checks
 */
@Service
@Lazy
public class FullAssociationCheckingService implements AssociationCheckingService {

    @Override
    public Collection<ValidationError> runChecks(Association association,
                                                 ValidationChecksBuilder validationChecksBuilder) {

        // TODO ADD COMPLETE LIST OF CHECKS

        // Create collection to store all newly created associations
        Collection<ValidationError> associationValidationErrors = new ArrayList<>();

        Collection<ValidationError> pvalueErrors = validationChecksBuilder.runPvalueChecks(association);
        if(!pvalueErrors.isEmpty()){
            associationValidationErrors.addAll(pvalueErrors);
        }

        Collection<ValidationError> annotationErrors =
                validationChecksBuilder.runAnnotationChecks(association);
        if (!annotationErrors.isEmpty()) {
            associationValidationErrors.addAll(annotationErrors);
        }

        String effectType = determineIfAssociationIsOrType(association);

        // Run checks depending on effect type
        if (effectType.equalsIgnoreCase("or")) {
            Collection<ValidationError> orErrors =
                    validationChecksBuilder.runOrChecks(association);
            if (!orErrors.isEmpty()) {
                associationValidationErrors.addAll(orErrors);
            }
        }

        if (effectType.equalsIgnoreCase("beta")) {
            Collection<ValidationError> betaErrors =
                    validationChecksBuilder.runBetaChecks(association);
            if (!betaErrors.isEmpty()) {
                associationValidationErrors.addAll(betaErrors);
            }
        }

        if (effectType.equalsIgnoreCase("nr")) {
            Collection<ValidationError> noEffectErrors =
                    validationChecksBuilder.runNoEffectErrors(association);
            if (!noEffectErrors.isEmpty()) {
                associationValidationErrors.addAll(noEffectErrors);
            }
        }
        return associationValidationErrors;
    }
}
@@ -707,53 +707,8 @@
  %7B%0A%0A
-        // TODO ADD COMPLETE LIST OF CHECKS%0A%0A
     
@@ -854,24 +854,354 @@
 yList%3C%3E();%0A%0A
+        // Run loci attribute checks i.e. risk allele, snp amd author reported genes%0A        Collection%3CValidationError%3E lociAttributeErrors = validationChecksBuilder.runLociAttributeChecks(association);%0A        if (!lociAttributeErrors.isEmpty()) %7B%0A            associationValidationErrors.addAll(lociAttributeErrors);%0A        %7D%0A%0A
         Coll

Add call to method to validate loci attributes