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);
}
Aggregations