<commit_before>package gov.nih.nci.cabig.caaers.domain;

import gov.nih.nci.cabig.ctms.domain.AbstractMutableDomainObject;
import gov.nih.nci.cabig.ctms.domain.DomainObjectTools;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Where;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author <NAME>
 */
@Entity
@Table(name = "participant_assignments")
@GenericGenerator(name = "id-generator", strategy = "native", parameters = { @Parameter(name = "sequence", value = "seq_participant_assignments_id") })
@Where(clause = "load_status > 0")
public class StudyParticipantAssignment extends AbstractMutableDomainObject {
    private Participant participant;

    private StudySite studySite;

    private Date dateOfEnrollment;

    private List<ExpeditedAdverseEventReport> aeReports;

    private List<RoutineAdverseEventReport> aeRoutineReports;
    
    private List<AdverseEventReportingPeriod> reportingPeriods;
    
    private List<LabViewerLab> labViewerLabs;

    private Integer loadStatus = LoadStatus.COMPLETE.getCode();

    private String studySubjectIdentifier;
    
    private Date startDateOfFirstCourse;

    public StudyParticipantAssignment(Participant participant, StudySite studySite) {
        this.participant = participant;
        this.studySite = studySite;
        this.dateOfEnrollment = new Date();
    }

    public StudyParticipantAssignment() {
    }

    // //// LOGIC

    public void addReport(ExpeditedAdverseEventReport report) {
        report.setAssignment(this);
        getAeReports().add(report);
    }

    public void addRoutineReport(RoutineAdverseEventReport routineReport) {
        routineReport.setAssignment(this);
        getAeRoutineReports().add(routineReport);
    }
    
    public void addReportingPeriod(AdverseEventReportingPeriod reportingPeriod) {
    	//reportingPeriod.setAssignment(this);
    	getReportingPeriods().add(reportingPeriod);
    }

    // //// BEAN PROPERTIES

    public void setStudySite(StudySite studySite) {
        this.studySite = studySite;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "study_site_id")
    @Cascade( { CascadeType.LOCK })
    public StudySite getStudySite() {
        return studySite;
    }

    public void setParticipant(Participant participant) {
        this.participant = participant;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "participant_id")
    @Cascade( { CascadeType.LOCK })
    public Participant getParticipant() {
        return participant;
    }

    public void setDateOfEnrollment(Date dateOfEnrollment) {
        this.dateOfEnrollment = dateOfEnrollment;
    }

    @Column(name = "date_of_enrollment")
    public Date getDateOfEnrollment() {
        return dateOfEnrollment;
    }

    @OneToMany(mappedBy = "assignment")
    public List<ExpeditedAdverseEventReport> getAeReports() {
        if (aeReports == null) aeReports = new ArrayList<ExpeditedAdverseEventReport>();
        return aeReports;
    }

    public void setAeReports(List<ExpeditedAdverseEventReport> aeReports) {
        this.aeReports = aeReports;
    }

    @OneToMany(mappedBy = "assignment")
    public List<RoutineAdverseEventReport> getAeRoutineReports() {
        if (aeRoutineReports == null) aeRoutineReports = new ArrayList<RoutineAdverseEventReport>();
        return aeRoutineReports;
    }

    public void setAeRoutineReports(List<RoutineAdverseEventReport> aeRoutineReports) {
        this.aeRoutineReports = aeRoutineReports;
    }
    
    @OneToMany(mappedBy = "assignment")
    public List<AdverseEventReportingPeriod> getReportingPeriods() {
    	if(reportingPeriods == null) reportingPeriods = new ArrayList<AdverseEventReportingPeriod>();
    	return reportingPeriods;
    }
    
    public void setReportingPeriods(List<AdverseEventReportingPeriod> reportingPeriods) {
    	this.reportingPeriods = reportingPeriods;
    }

    @OneToMany(mappedBy = "assignment")
	public List<LabViewerLab> getLabViewerLabs() {
    	if(labViewerLabs == null) labViewerLabs = new ArrayList<LabViewerLab>();
    	return labViewerLabs;
	}

	public void setLabViewerLabs(List<LabViewerLab> labViewerLabs) {
		this.labViewerLabs = labViewerLabs;
	}
	
    public Integer getLoadStatus() {
        return loadStatus;
    }

    public void setLoadStatus(Integer loadStatus) {
        this.loadStatus = loadStatus;
    }
    @Column(name="first_course_date")
    public Date getStartDateOfFirstCourse() {
		return startDateOfFirstCourse;
	}
    public void setStartDateOfFirstCourse(Date startDateOfFirstCourse) {
		this.startDateOfFirstCourse = startDateOfFirstCourse;<commit_msg>added @OrderBy clause to labviewerlabs<commit_after>package gov.nih.nci.cabig.caaers.domain;

import gov.nih.nci.cabig.ctms.domain.AbstractMutableDomainObject;
import gov.nih.nci.cabig.ctms.domain.DomainObjectTools;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.OrderBy;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Where;

/**
 * @author <NAME>
 */
@Entity
@Table(name = "participant_assignments")
@GenericGenerator(name = "id-generator", strategy = "native", parameters = { @Parameter(name = "sequence", value = "seq_participant_assignments_id") })
@Where(clause = "load_status > 0")
public class StudyParticipantAssignment extends AbstractMutableDomainObject {
    private Participant participant;

    private StudySite studySite;

    private Date dateOfEnrollment;

    private List<ExpeditedAdverseEventReport> aeReports;

    private List<RoutineAdverseEventReport> aeRoutineReports;
    
    private List<AdverseEventReportingPeriod> reportingPeriods;
    
    private List<LabViewerLab> labViewerLabs;

    private Integer loadStatus = LoadStatus.COMPLETE.getCode();

    private String studySubjectIdentifier;
    
    private Date startDateOfFirstCourse;

    public StudyParticipantAssignment(Participant participant, StudySite studySite) {
        this.participant = participant;
        this.studySite = studySite;
        this.dateOfEnrollment = new Date();
    }

    public StudyParticipantAssignment() {
    }

    // //// LOGIC

    public void addReport(ExpeditedAdverseEventReport report) {
        report.setAssignment(this);
        getAeReports().add(report);
    }

    public void addRoutineReport(RoutineAdverseEventReport routineReport) {
        routineReport.setAssignment(this);
        getAeRoutineReports().add(routineReport);
    }
    
    public void addReportingPeriod(AdverseEventReportingPeriod reportingPeriod) {
    	//reportingPeriod.setAssignment(this);
    	getReportingPeriods().add(reportingPeriod);
    }

    // //// BEAN PROPERTIES

    public void setStudySite(StudySite studySite) {
        this.studySite = studySite;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "study_site_id")
    @Cascade( { CascadeType.LOCK })
    public StudySite getStudySite() {
        return studySite;
    }

    public void setParticipant(Participant participant) {
        this.participant = participant;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "participant_id")
    @Cascade( { CascadeType.LOCK })
    public Participant getParticipant() {
        return participant;
    }

    public void setDateOfEnrollment(Date dateOfEnrollment) {
        this.dateOfEnrollment = dateOfEnrollment;
    }

    @Column(name = "date_of_enrollment")
    public Date getDateOfEnrollment() {
        return dateOfEnrollment;
    }

    @OneToMany(mappedBy = "assignment")
    public List<ExpeditedAdverseEventReport> getAeReports() {
        if (aeReports == null) aeReports = new ArrayList<ExpeditedAdverseEventReport>();
        return aeReports;
    }

    public void setAeReports(List<ExpeditedAdverseEventReport> aeReports) {
        this.aeReports = aeReports;
    }

    @OneToMany(mappedBy = "assignment")
    public List<RoutineAdverseEventReport> getAeRoutineReports() {
        if (aeRoutineReports == null) aeRoutineReports = new ArrayList<RoutineAdverseEventReport>();
        return aeRoutineReports;
    }

    public void setAeRoutineReports(List<RoutineAdverseEventReport> aeRoutineReports) {
        this.aeRoutineReports = aeRoutineReports;
    }
    
    @OneToMany(mappedBy = "assignment")
    public List<AdverseEventReportingPeriod> getReportingPeriods() {
    	if(reportingPeriods == null) reportingPeriods = new ArrayList<AdverseEventReportingPeriod>();
    	return reportingPeriods;
    }
    
    public void setReportingPeriods(List<AdverseEventReportingPeriod> reportingPeriods) {
    	this.reportingPeriods = reportingPeriods;
    }

    @OneToMany(mappedBy = "assignment")
    @OrderBy(clause="lab_date desc")
	public List<LabViewerLab> getLabViewerLabs() {
    	if(labViewerLabs == null) labViewerLabs = new ArrayList<LabViewerLab>();
    	return labViewerLabs;
	}

	public void setLabViewerLabs(List<LabViewerLab> labViewerLabs) {
		this.labViewerLabs = labViewerLabs;
	}
	
    public Integer getLoadStatus() {
        return loadStatus;
    }

    public void setLoadStatus(Integer loadStatus) {
        this.loadStatus = loadStatus;
    }
    @Column(name="first_course_date")
    public Date getStartDateOfFirstCourse() {
		return startDateOfFirstCourse;
	}
    public void setStartDateOfFirstCourse(Date startDateOfFirstCourse) {
		this.startDateOfFirstCourse = startDateOfFirstCourse;
{'fraction_non_alphanumeric': 0.08979871018174712, 'fraction_numerical': 0.00019542700801250732, 'mean_word_length': 4.127755511022044, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 39, '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': '2281922', 'n_tokens_mistral': 3210, 'n_tokens_neox': 3079, 'n_words': 543}