package org.slc.sli.test.generators;

import java.util.List;

import org.apache.log4j.Logger;
import org.slc.sli.test.edfi.entities.CohortReferenceType;
import org.slc.sli.test.edfi.entities.StaffCohortAssociation;
import org.slc.sli.test.edfi.entities.StaffReferenceType;
import org.slc.sli.test.edfi.entities.StudentCohortAssociation;

public class StaffCohortAssociationGenerator {
	private static final Logger log = Logger.getLogger(StudentCohortAssociation.class);
	private boolean includeOptionalData = true;
	private boolean includeAllData = true;
	private String beginDate = "2011-03-04";
	private String endDate = "2012-03-04";

	public StaffCohortAssociation getStaffCohortAssociation (List<CohortReferenceType> CohortReference, List<StaffReferenceType> StaffReference) throws Exception {
		StaffCohortAssociation sca = new StaffCohortAssociation ();
		if (includeAllData) {
			sca.getCohortReference().addAll(CohortReference);
			sca.getStaffReference().addAll(StaffReference);
			sca.setBeginDate(beginDate);
		}
		else {
			log.info("Required Data is invalid !");
		}

		if (includeOptionalData) {
			sca.setEndDate(endDate);
			sca.setStudentRecordAccess(true);
		}
		else {
			log.info("Optional Data is invalid!");
		}
		return sca;


	}

}


package org.slc.sli.test.generators;

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

import org.apache.log4j.Logger;
import org.slc.sli.test.edfi.entities.CohortIdentityType;
import org.slc.sli.test.edfi.entities.CohortReferenceType;
import org.slc.sli.test.edfi.entities.StaffCohortAssociation;
import org.slc.sli.test.edfi.entities.StaffIdentityType;
import org.slc.sli.test.edfi.entities.StaffReferenceType;

public class StaffCohortAssociationGenerator {
	private static final Logger log = Logger.getLogger(StaffCohortAssociationGenerator.class);

	private static String beginDate = "2011-03-04";
	private static String endDate = "2012-03-04";

    /**
     * Generates a StaffCohortAssociation between a cohort and a staff  
     * with a school as a reference.
     *
     * @param cohortId
     * @param staffId
     * @param schoolId
     * 
     * @return <code>StaffCohortAssociation</code>
     */
    public static StaffCohortAssociation generateLowFi(String cohortId, String staffId, String schoolId) {

        StaffCohortAssociation staffCohortAssoc = new StaffCohortAssociation();
        
        // construct and add the staff reference
        StaffIdentityType sit = new StaffIdentityType();
        sit.setStaffUniqueStateId(staffId);
        StaffReferenceType srt = new StaffReferenceType();
        srt.setStaffIdentity(sit);
        staffCohortAssoc.getStaffReference().add(srt);

        // construct and add the Cohort Reference       
        CohortIdentityType ci = new CohortIdentityType();
        ci.setCohortIdentifier(cohortId);
        ci.getStateOrganizationIdOrEducationOrgIdentificationCode().add(schoolId);
        CohortReferenceType crt = new CohortReferenceType();
        crt.setCohortIdentity(ci);
        staffCohortAssoc.getCohortReference().add(crt);

        //set begin and end dates
        staffCohortAssoc.setBeginDate(beginDate);
        staffCohortAssoc.setEndDate(endDate);
        
        staffCohortAssoc.setStudentRecordAccess(Boolean.TRUE);
        
        return staffCohortAssoc;
    }

    /**
     * Generates a StaffCohortAssociation between a cohort and a list of staffs 
     * with a list of schools as a reference.
     *
     * @param cohortId
     * @param staffIds
     * @param schoolIds
     * 
     * @return <code>StaffCohortAssociation</code>
     */
    public static StaffCohortAssociation generateLowFi(String cohortId, List<String> staffIds, List<String> schoolIds) {

        StaffCohortAssociation staffCohortAssoc = new StaffCohortAssociation();
        
        // construct and add the staff references
        List<StaffReferenceType> srts = new ArrayList<StaffReferenceType>(staffIds.size());
        for (String staffId : staffIds) {
            StaffIdentityType sit = new StaffIdentityType();
            sit.setStaffUniqueStateId(staffId);
            StaffReferenceType srt = new StaffReferenceType();
            srt.setStaffIdentity(sit);
            srts.add(srt);
        }
        staffCohortAssoc.getStaffReference().addAll(srts);

        // construct and add the Cohort Reference
        CohortIdentityType ci = new CohortIdentityType();
        ci.setCohortIdentifier(cohortId);
        ci.getStateOrganizationIdOrEducationOrgIdentificationCode().addAll(schoolIds);
        CohortReferenceType crt = new CohortReferenceType();
        crt.setCohortIdentity(ci);
        staffCohortAssoc.getCohortReference().add(crt);
        
        //set begin and end dates
        staffCohortAssoc.setBeginDate(beginDate);
        staffCohortAssoc.setEndDate(endDate);
        
        staffCohortAssoc.setStudentRecordAccess(Boolean.TRUE);
        
        return staffCohortAssoc;
    }
}


Support cohort data