<commit_before>package uk.ac.ebi.spot.goci.curation.service;

import org.springframework.stereotype.Service;
import uk.ac.ebi.spot.goci.curation.model.StudyAssociationTableView;
import uk.ac.ebi.spot.goci.model.Association;
import uk.ac.ebi.spot.goci.model.EfoTrait;
import uk.ac.ebi.spot.goci.model.Study;

import java.util.*;

/**
 * Created by emma on 09/10/2015.
 *
 * @author emma
 *         <p>
 *         Service that takes a Study object and creates a view object that can be returned and rendered by HTML.
 */
@Service
public class StudyAssociationTableViewService {

    public StudyAssociationTableViewService() {
    }

    public List<StudyAssociationTableView> createViews(List<Study> studies) {

        List<StudyAssociationTableView> views = new ArrayList<>();

        for (Study study : studies) {

            StudyAssociationTableView view = new StudyAssociationTableView();

            view.setStudyId(study.getId());
            view.setAuthor(study.getAuthor());
            view.setPublicationDate(study.getPublicationDate());
            view.setPublication(study.getPublication());
            view.setTitle(study.getTitle());
            view.setPubmedId(study.getPubmedId());
            view.setStudyDiseaseTrait(study.getDiseaseTrait().getTrait());
            view.setCurator(study.getHousekeeping().getCurator().getLastName());
            view.setCurationStatus(study.getHousekeeping().getCurationStatus().getStatus());
            view.setNotes(study.getHousekeeping().getNotes());

            // Study EFO traits
            Collection<String> traitNames = new ArrayList<>();
            for (EfoTrait efoTrait : study.getEfoTraits()) {
                traitNames.add(efoTrait.getTrait());
            }
            view.setStudyEfoTrait(String.join(",", traitNames));

            // Association details<commit_msg>Added catch for null disease trait<commit_after>package uk.ac.ebi.spot.goci.curation.service;

import org.springframework.stereotype.Service;
import uk.ac.ebi.spot.goci.curation.model.StudyAssociationTableView;
import uk.ac.ebi.spot.goci.model.Association;
import uk.ac.ebi.spot.goci.model.EfoTrait;
import uk.ac.ebi.spot.goci.model.Study;

import java.util.*;

/**
 * Created by emma on 09/10/2015.
 *
 * @author emma
 *         <p>
 *         Service that takes a Study object and creates a view object that can be returned and rendered by HTML.
 */
@Service
public class StudyAssociationTableViewService {

    public StudyAssociationTableViewService() {
    }

    public List<StudyAssociationTableView> createViews(List<Study> studies) {

        List<StudyAssociationTableView> views = new ArrayList<>();

        for (Study study : studies) {

            StudyAssociationTableView view = new StudyAssociationTableView();

            view.setStudyId(study.getId());
            view.setAuthor(study.getAuthor());
            view.setPublicationDate(study.getPublicationDate());
            view.setPublication(study.getPublication());
            view.setTitle(study.getTitle());
            view.setPubmedId(study.getPubmedId());
            view.setCurator(study.getHousekeeping().getCurator().getLastName());
            view.setCurationStatus(study.getHousekeeping().getCurationStatus().getStatus());
            view.setNotes(study.getHousekeeping().getNotes());

            // Study disease trait, which could potentially be null
            if (study.getDiseaseTrait() != null) {
                view.setStudyDiseaseTrait(study.getDiseaseTrait().getTrait());
            }

            // Study EFO traits
            Collection<String> traitNames = new ArrayList<>();
            for (EfoTrait efoTrait : study.getEfoTraits()) {
                traitNames.add(efoTrait.getTrait());
            }
            view.setStudyEfoTrait(String.join(",", traitNames));

            // Association details
{'fraction_non_alphanumeric': 0.11636927851047324, 'fraction_numerical': 0.004137574347039048, 'mean_word_length': 2.8718718718718717, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6083545', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1072, 'n_words': 193}