<commit_before>package edu.duke.cabig.c3pr.infrastructure;

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

import com.semanticbits.coppa.infrastructure.service.RemoteResolver;
import com.semanticbits.coppasimulator.domain.ResearchStaffDTO;
import com.semanticbits.coppasimulator.service.ResearchStaffService;

import edu.duke.cabig.c3pr.domain.RemoteResearchStaff;

/**
 * The Class RemoteResearchStaffResolver.
 */
public class RemoteResearchStaffResolver implements RemoteResolver{

	ResearchStaffService researchStaffService;
	
	/* (non-Javadoc)
	 * @see com.semanticbits.coppa.infrastructure.service.RemoteResolver#find(java.lang.Object)
	 */
	public List<Object> find(Object arg0) {
		RemoteResearchStaff remoteResearchStaff = (RemoteResearchStaff) arg0;
		
		ResearchStaffDTO researchStaffDTO = researchStaffService.getClinicalResearchStaffPerson("<EMAIL>");
		List<ResearchStaffDTO> researchStaffDTOList  = new ArrayList<ResearchStaffDTO>();
		researchStaffDTOList.add(researchStaffDTO);
		
		List<Object> researchStaffList = convertToResearchStaff(researchStaffDTOList);
		
		return researchStaffList;
	}

	/* (non-Javadoc)
	 * @see com.semanticbits.coppa.infrastructure.service.RemoteResolver#getRemoteEntityByUniqueId(java.lang.String)
	 */
	public Object getRemoteEntityByUniqueId(String arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	
	private List<Object> convertToResearchStaff(List<ResearchStaffDTO> researchStaffDTOList){
		List<Object> researchStaffList = new ArrayList<Object>();
		RemoteResearchStaff remoteResearchStaff;
		for(ResearchStaffDTO researchStaffDTO: researchStaffDTOList){
			remoteResearchStaff = new RemoteResearchStaff();
			remoteResearchStaff.setFirstName(researchStaffDTO.getFirstName());
			remoteResearchStaff.setLastName(researchStaffDTO.getLastName());
			remoteResearchStaff.setNciIdentifier(researchStaffDTO.getNciIdentifier());
			remoteResearchStaff.setUniqueIdentifier(researchStaffDTO.getEmailAddress());
			researchStaffList.add(remoteResearchStaff);
		}
		
		return researchStaffList;
	}
	
	public ResearchStaffService getResearchStaffService() {
		return researchStaffService;
	}

	public void setResearchStaffService(ResearchStaffService researchStaffService) {
		this.researchStaffService = researchStaffService;<commit_msg>COPPA related development<commit_after>package edu.duke.cabig.c3pr.infrastructure;

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

import com.semanticbits.coppa.infrastructure.service.RemoteResolver;
import com.semanticbits.coppasimulator.domain.ResearchStaffDTO;
import com.semanticbits.coppasimulator.service.ResearchStaffService;

import edu.duke.cabig.c3pr.domain.HealthcareSite;
import edu.duke.cabig.c3pr.domain.RemoteResearchStaff;

/**
 * The Class RemoteResearchStaffResolver.
 */
public class RemoteResearchStaffResolver implements RemoteResolver{

	ResearchStaffService researchStaffService;
	
	/* (non-Javadoc)
	 * @see com.semanticbits.coppa.infrastructure.service.RemoteResolver#find(java.lang.Object)
	 */
	public List<Object> find(Object arg0) {
		RemoteResearchStaff remoteResearchStaff = (RemoteResearchStaff) arg0;
		
		List<ResearchStaffDTO> researchStaffDTOList  = new ArrayList<ResearchStaffDTO>();
		researchStaffDTOList.add(researchStaffService.getClinicalResearchStaffPerson("<EMAIL>"));
		researchStaffDTOList.add(researchStaffService.getClinicalResearchStaffPerson("<EMAIL>"));
		
		//pass the healthcareSite tht was set in the exmaple object that was sent in....otherwise null
		return convertToResearchStaff(researchStaffDTOList, remoteResearchStaff.getHealthcareSite());
	}

	/* (non-Javadoc)
	 * @see com.semanticbits.coppa.infrastructure.service.RemoteResolver#getRemoteEntityByUniqueId(java.lang.String)
	 */
	public Object getRemoteEntityByUniqueId(String arg0) {
		Object object = researchStaffService.getClinicalResearchStaffPerson(arg0);
		List<ResearchStaffDTO> researchStaffDTOList = new ArrayList<ResearchStaffDTO>();
		researchStaffDTOList.add((ResearchStaffDTO)object);
		return convertToResearchStaff(researchStaffDTOList, null).get(0);
	}

	
	private List<Object> convertToResearchStaff(List<ResearchStaffDTO> researchStaffDTOList, HealthcareSite healthcareSite){
		List<Object> researchStaffList = new ArrayList<Object>();
		RemoteResearchStaff remoteResearchStaff;
		for(ResearchStaffDTO researchStaffDTO: researchStaffDTOList){
			remoteResearchStaff = new RemoteResearchStaff();
			remoteResearchStaff.setFirstName(researchStaffDTO.getFirstName());
			remoteResearchStaff.setLastName(researchStaffDTO.getLastName());
			remoteResearchStaff.setNciIdentifier(researchStaffDTO.getNciIdentifier());
			//set the healthcare site that was passed in
			remoteResearchStaff.setHealthcareSite(healthcareSite);
			
			remoteResearchStaff.setUniqueIdentifier(researchStaffDTO.getEmailAddress());
			researchStaffList.add(remoteResearchStaff);
		}
		
		return researchStaffList;
	}
	
	public ResearchStaffService getResearchStaffService() {
		return researchStaffService;
	}

	public void setResearchStaffService(ResearchStaffService researchStaffService) {
		this.researchStaffService = researchStaffService;
{'fraction_non_alphanumeric': 0.08699029126213592, 'fraction_numerical': 0.002524271844660194, 'mean_word_length': 7.294685990338165, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '3639143', 'n_tokens_mistral': 1714, 'n_tokens_neox': 1429, 'n_words': 220}