Search in sources :

Example 1 with DeletedAssociation

use of uk.ac.ebi.spot.goci.model.DeletedAssociation in project goci by EBISPOT.

the class AssociationDeletionService method deleteAssociation.

public void deleteAssociation(Association association, SecureUser user) {
    getLog().info("Deleting association ".concat(String.valueOf(association.getId())));
    // For each association get the loci
    Collection<Locus> loci = new ArrayList<Locus>();
    loci.addAll(association.getLoci());
    // SNPs are not deleted as they may be used in other associations.
    for (Locus locus : loci) {
        Collection<RiskAllele> locusRiskAlleles = locus.getStrongestRiskAlleles();
        locus.setStrongestRiskAlleles(new ArrayList<>());
        for (RiskAllele riskAllele : locusRiskAlleles) {
            lociAttributesService.deleteRiskAllele(riskAllele);
        }
        lociAttributesService.deleteLocus(locus);
    }
    // Add deletion event
    trackingOperationService.delete(association, user);
    DeletedAssociation deletedAssociation = createDeletedAssociation(association);
    // Delete associations
    associationRepository.delete(association);
    // Save deleted association
    getLog().info("Saving details of deleted association: ".concat(String.valueOf(deletedAssociation.getId())));
    deletedAssociationRepository.save(deletedAssociation);
}
Also used : RiskAllele(uk.ac.ebi.spot.goci.model.RiskAllele) ArrayList(java.util.ArrayList) Locus(uk.ac.ebi.spot.goci.model.Locus) DeletedAssociation(uk.ac.ebi.spot.goci.model.DeletedAssociation)

Aggregations

ArrayList (java.util.ArrayList)1 DeletedAssociation (uk.ac.ebi.spot.goci.model.DeletedAssociation)1 Locus (uk.ac.ebi.spot.goci.model.Locus)1 RiskAllele (uk.ac.ebi.spot.goci.model.RiskAllele)1