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

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

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

import javax.persistence.Column;
import javax.persistence.Embedded;
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 javax.persistence.Transient;

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

@Entity
@Table(name = "site_research_staffs")
@GenericGenerator(name = "id-generator", strategy = "native", parameters = {@Parameter(name = "sequence", value = "seq_site_research_staffs_id") })
public class SiteResearchStaff extends AbstractMutableDomainObject{

	private ResearchStaff researchStaff;
	private Organization organization;
    private List<StudyPersonnel> studyPersonnels;
    private List<SiteResearchStaffRole> siteResearchStaffRoles;
    private String emailAddress;
    private String phoneNumber;
    private String faxNumber; 
    private Address address;
    
    @OneToMany(mappedBy = "siteResearchStaff", fetch = FetchType.LAZY)
    @Cascade(value = { CascadeType.ALL, CascadeType.DELETE_ORPHAN })
	public List<SiteResearchStaffRole> getSiteResearchStaffRoles() {
		return siteResearchStaffRoles;
	}
	public void setSiteResearchStaffRoles(
			List<SiteResearchStaffRole> siteResearchStaffRoles) {
		this.siteResearchStaffRoles = siteResearchStaffRoles;
	}
	
	/**
	 * Utility method to add SiteResearchRole 
	 * @param siteResearchStaffRole
	 */
	public void addSiteResearchStaffRole(SiteResearchStaffRole siteResearchStaffRole){
		if(getSiteResearchStaffRoles() == null){
			siteResearchStaffRoles = new ArrayList<SiteResearchStaffRole>();
		}
		siteResearchStaffRole.setSiteResearchStaff(this);
		getSiteResearchStaffRoles().add(siteResearchStaffRole);
	}
    
    @OneToMany(mappedBy = "siteResearchStaff", fetch = FetchType.LAZY)
    @Cascade(value = { CascadeType.ALL, CascadeType.DELETE_ORPHAN })<commit_msg>fixing sync of research staff<commit_after>package gov.nih.nci.cabig.caaers.domain;

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

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

import javax.persistence.Column;
import javax.persistence.Embedded;
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 javax.persistence.Transient;

import org.apache.commons.lang.StringUtils;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

@Entity
@Table(name = "site_research_staffs")
@GenericGenerator(name = "id-generator", strategy = "native", parameters = {@Parameter(name = "sequence", value = "seq_site_research_staffs_id") })
public class SiteResearchStaff extends AbstractMutableDomainObject{

	private ResearchStaff researchStaff;
	private Organization organization;
    private List<StudyPersonnel> studyPersonnels;
    private List<SiteResearchStaffRole> siteResearchStaffRoles;
    private String emailAddress;
    private String phoneNumber;
    private String faxNumber; 
    private Address address;
    
    
    ///LOGIC
    public SiteResearchStaffRole findSiteResearchStaffRole(SiteResearchStaffRole other){
    	for(SiteResearchStaffRole role : siteResearchStaffRoles){
    		if(StringUtils.equals(role.getRoleCode(), other.getRoleCode())) return role;
    	}
    	return null;
	}
    
    @OneToMany(mappedBy = "siteResearchStaff", fetch = FetchType.LAZY)
    @Cascade(value = { CascadeType.ALL, CascadeType.DELETE_ORPHAN })
	public List<SiteResearchStaffRole> getSiteResearchStaffRoles() {
		return siteResearchStaffRoles;
	}
	public void setSiteResearchStaffRoles(
			List<SiteResearchStaffRole> siteResearchStaffRoles) {
		this.siteResearchStaffRoles = siteResearchStaffRoles;
	}
	
	/**
	 * Utility method to add SiteResearchRole 
	 * @param siteResearchStaffRole
	 */
	public void addSiteResearchStaffRole(SiteResearchStaffRole siteResearchStaffRole){
		if(getSiteResearchStaffRoles() == null){
			siteResearchStaffRoles = new ArrayList<SiteResearchStaffRole>();
		}
		siteResearchStaffRole.setSiteResearchStaff(this);
		getSiteResearchStaffRoles().add(siteResearchStaffRole);
	}
    
    @OneToMany(mappedBy = "siteResearchStaff", fetch = FetchType.LAZY)
    @Cascade(value = { CascadeType.ALL, CascadeType.DELETE_ORPHAN })
{'fraction_non_alphanumeric': 0.08955536912751678, 'fraction_numerical': 0.0, 'mean_word_length': 6.117910447761194, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '7396130', 'n_tokens_mistral': 1535, 'n_tokens_neox': 1374, 'n_words': 258}