package gov.nih.nci.cabig.caaers.domain;

import gov.nih.nci.cabig.ctms.domain.DomainObject;

import java.sql.Timestamp;

/**
 * @author Rhett Sutphin
 */
public class Fixtures {
    public static <T extends DomainObject> T setId(int id, T target) {
        target.setId(id);
        return target;
    }

    public static Participant createParticipant(String first, String last) {
        Participant p = new Participant();
        p.setFirstName(first);
        p.setLastName(last);
        return p;
    }

    public static Study createStudy(String shortTitle) {
        Study s = new Study();
        s.setShortTitle(shortTitle);
        return s;
    }

    public static Site createSite(String name) {
        Site site = new Site();
        site.setName(name);
        return site;
    }

    /** Creates an assignment and the associated Study, Participant, StudySite, and Site objs */
    public static StudyParticipantAssignment createAssignment() {
        return assignParticipant(
            createParticipant("D", "C"),
            createStudy("DC"),
            createSite("N/A")
        );
    }

    public static StudyParticipantAssignment assignParticipant(Participant p, Study study, Site site) {
        StudySite ss = new StudySite();
        ss.setSite(site);
        study.addStudySite(ss);
        site.addStudySite(ss);

        StudyParticipantAssignment assignment = new StudyParticipantAssignment();
        ss.addAssignment(assignment);
        p.addAssignment(assignment);

        return assignment;
    }

    public static StudyAgent createStudyAgent(String agentName) {
        StudyAgent agent = new StudyAgent();
        agent.setAgent(new Agent());
        agent.getAgent().setName(agentName);
        return agent;
    }

    public static ExpeditedAdverseEventReport createSaveableExpeditedReport() {
        ExpeditedAdverseEventReport report = new ExpeditedAdverseEventReport();
        report.setCreatedAt(new Timestamp(103));
        report.getReporter().setFirstName("Frank");
        report.getReporter().setLastName("Just Frank");
        report.getPhysician().setFirstName("Frank");
        report.getPhysician().setLastName("Just Frank");
        return report;
    }
}

@@ -85,16 +85,80 @@
 nObject;
+%0Aimport gov.nih.nci.cabig.caaers.domain.report.ReportDefinition;
 %0A%0Aimport
@@ -2275,11 +2275,193 @@
 t;%0A    %7D
+%0A%0A    public static ReportDefinition createReportDefinition(String name) %7B%0A        ReportDefinition def = new ReportDefinition();%0A        def.setName(name);%0A        return def;%0A    %7D
 %0A%7D%0A

Add fixture for report definition