use of gov.ca.cwds.rest.api.domain.Participant in project API by ca-cwds.
the class ParticipantValidator method hasValidParticipants.
/**
* @param scr - ScreeningToReferral object
* @return Boolean - has valid participants
* @throws ServiceException - throw and errors
*/
public static Boolean hasValidParticipants(ScreeningToReferral scr) throws ServiceException {
int reporterCount = 0;
int victimCount = 0;
Set<Participant> participants = scr.getParticipants();
if (participants != null) {
for (Participant participant : participants) {
if (isReporterType(participant)) {
reporterCount++;
}
if (hasVictimRole(participant)) {
victimCount++;
}
}
}
// only one reporter is allowed on a referral
if (reporterCount != ALLOWED_NUMBER_OF_REPORTERS) {
return INVALID_PARTICIPANTS;
}
// one victim is required for a referral
if (victimCount < MINIMUM_NUMBER_OF_VICTIMS) {
return INVALID_PARTICIPANTS;
}
return VALID_PARTICIPANTS;
}
use of gov.ca.cwds.rest.api.domain.Participant in project API by ca-cwds.
the class ClientTest method testCreateWithDefaultCreatesWithValues.
@Test
public void testCreateWithDefaultCreatesWithValues() {
Participant participant = new Participant(1, "sourceTable", "clientId", "firstName", "lastName", "gender", "ssn", "dob", 3, 4, new HashSet(), new HashSet());
String genderCode = "male";
String dateStarted = "now";
Client client = Client.createWithDefaults(participant, dateStarted, genderCode);
assertEquals("Expected BirthDate field to be initialized with values", participant.getDateOfBirth(), client.getBirthDate());
assertEquals("Expected First Name field to be initialized with values", participant.getFirstName(), client.getCommonFirstName());
assertEquals("Expected LastName field to be initialized with values", participant.getLastName(), client.getCommonLastName());
assertEquals("Expected SSN field to be initialized with values", participant.getSsn(), client.getSocialSecurityNumber());
assertEquals("Expected genderCode field to be initialized with values", genderCode, client.getGenderCode());
assertEquals("Expected dateStarted field to be initialized with values", dateStarted, client.getCreationDate());
}
use of gov.ca.cwds.rest.api.domain.Participant in project API by ca-cwds.
the class ReporterTest method streetNameShouldThrowExceptionWhenOnlyContaingOneWord.
@Test(expected = ArrayIndexOutOfBoundsException.class)
public void streetNameShouldThrowExceptionWhenOnlyContaingOneWord() {
String streetAddress = "main";
gov.ca.cwds.rest.api.domain.Address address = new gov.ca.cwds.rest.api.domain.Address("legacy_source_table", "legacy_id", streetAddress, "city", "state", 12345, "type");
Participant participant = new Participant(5L, "legacy_source_table", "legacy_client_id", "firstName", "lastName", "gender", "ssn", "date_of_birth", 7L, 8L, new HashSet(), new HashSet());
Reporter reporter = Reporter.createWithDefaults("referralId", true, address, participant, "countyCode", new Short("0"));
}
use of gov.ca.cwds.rest.api.domain.Participant in project API by ca-cwds.
the class ClientTest method testCreateWithDefaultCreatesWithDefaultValues.
@Test
public void testCreateWithDefaultCreatesWithDefaultValues() {
Participant participant = new Participant(1, "sourceTable", "clientId", "firstName", "lastName", "gender", "ssn", "dob", 3, 4, new HashSet(), new HashSet());
String genderCode = "male";
String dateStarted = "now";
Client client = Client.createWithDefaults(participant, dateStarted, genderCode);
assertEquals("Expected existingClientId field to be initialized with default values", "", client.getExistingClientId());
assertEquals("Expected adjudicatedDelinquentIndicator field to be initialized with default values", false, client.getAdjudicatedDelinquentIndicator());
assertEquals("Expected adoptionStatusCode field to be initialized with default values", "N", client.getAdoptionStatusCode());
assertEquals("Expected alienRegistrationNumber field to be initialized with default values", "", client.getAlienRegistrationNumber());
assertEquals("Expected birth city field to be initialized with default values", "", client.getBirthCity());
assertEquals("Expected birthCountryCodeType field to be initialized with default values", new Short("0"), client.getBirthCountryCodeType());
assertEquals("Expected birthFacilityName field to be initialized with default values", "", client.getBirthFacilityName());
assertEquals("Expected birthStateCodeType field to be initialized with default values", new Short("0"), client.getBirthStateCodeType());
assertEquals("Expected birthplaceVerifiedIndicator field to be initialized with default values", false, client.getBirthplaceVerifiedIndicator());
assertEquals("Expected childClientIndicatorVar field to be initialized with default values", false, client.getChildClientIndicatorVar());
assertEquals("Expected clientIndexNumber field to be initialized with default values", "", client.getClientIndexNumber());
assertEquals("Expected commentDescription field to be initialized with default values", "", client.getCommentDescription());
assertEquals("Expected commonMiddleName field to be initialized with default values", "", client.getCommonMiddleName());
assertEquals("Expected confidentialityActionDate field to be initialized with default values", "", client.getConfidentialityActionDate());
assertEquals("Expected confidentialityInEffectIndicator field to be initialized with default values", false, client.getConfidentialityInEffectIndicator());
assertEquals("Expected currCaChildrenServIndicator field to be initialized with default values", false, client.getCurrCaChildrenServIndicator());
assertEquals("Expected currentlyOtherDescription field to be initialized with default values", "", client.getCurrentlyOtherDescription());
assertEquals("Expected currentlyRegionalCenterIndicato field to be initialized with default values", false, client.getCurrentlyRegionalCenterIndicator());
assertEquals("Expected deathDate field to be initialized with default values", "", client.getDeathDate());
assertEquals("Expected deathDateVerifiedIndicato field to be initialized with default values", false, client.getDeathDateVerifiedIndicator());
assertEquals("Expected deathPlace field to be initialized with default values", "", client.getDeathPlace());
assertEquals("Expected deathReasonText field to be initialized with default values", "", client.getDeathReasonText());
assertEquals("Expected driverLicenseNumber field to be initialized with default values", "", client.getDriverLicenseNumber());
assertEquals("Expected driverLicenseStateCodeType field to be initialized with default values", new Short("0"), client.getDriverLicenseStateCodeType());
assertEquals("Expected emailAddress field to be initialized with default values", "", client.getEmailAddress());
assertEquals("Expected estimatedDobCode field to be initialized with default values", "N", client.getEstimatedDobCode());
assertEquals("Expected ethUnableToDetReasonCode field to be initialized with default values", "K", client.getEthUnableToDetReasonCode());
assertEquals("Expected fatherParentalRightTermDate field to be initialized with default values", "", client.getFatherParentalRightTermDate());
assertEquals("Expected healthSummaryText field to be initialized with default values", "", client.getHealthSummaryText());
assertEquals("Expected hispUnableToDetReasonCode field to be initialized with default values", "", client.getHispUnableToDetReasonCode());
assertEquals("Expected hispanicOriginCode field to be initialized with default values", "X", client.getHispanicOriginCode());
assertEquals("Expected immigrationCountryCodeTyp field to be initialized with default values", new Short("0"), client.getImmigrationCountryCodeType());
assertEquals("Expected immigrationStatusType field to be initialized with default values", new Short("0"), client.getImmigrationStatusType());
assertEquals("Expected incapacitatedParentCode field to be initialized with default values", "U", client.getIncapacitatedParentCode());
assertEquals("Expected individualHealthCarePlanIndicator field to be initialized with default values", false, client.getIndividualHealthCarePlanIndicator());
assertEquals("Expected limitationOnScpHealthIndicator field to be initialized with default values", false, client.getLimitationOnScpHealthIndicator());
assertEquals("Expected literateCode field to be initialized with default values", "U", client.getLiterateCode());
assertEquals("Expected maritalCohabitatnHstryIndicatorVar field to be initialized with default values", false, client.getMaritalCohabitatnHstryIndicatorVar());
assertEquals("Expected maritalStatusType field to be initialized with default values", new Short("0"), client.getMaritalStatusType());
assertEquals("Expected militaryStatusCod field to be initialized with default values", "N", client.getMilitaryStatusCode());
assertEquals("Expected motherParentalRightTermDate field to be initialized with default values", "", client.getMotherParentalRightTermDate());
assertEquals("Expected namePrefixDescription field to be initialized with default values", "", client.getNamePrefixDescription());
assertEquals("Expected nameType field to be initialized with default values", new Short("1313"), client.getNameType());
assertEquals("Expected outstandingWarrantIndicator field to be initialized with default values", false, client.getOutstandingWarrantIndicator());
assertEquals("Expected prevCaChildrenServIndicator field to be initialized with default values", false, client.getPrevCaChildrenServIndicator());
assertEquals("Expected prevOtherDescription field to be initialized with default values", "", client.getPrevOtherDescription());
assertEquals("Expected prevRegionalCenterIndicato field to be initialized with default values", false, client.getPrevRegionalCenterIndicator());
assertEquals("Expected primaryEthnicityType field to be initialized with default values", new Short("0"), client.getPrimaryEthnicityType());
assertEquals("Expected primaryLanguageType field to be initialized with default values", new Short("0"), client.getPrimaryLanguageType());
assertEquals("Expected religionType field to be initialized with default values", new Short("0"), client.getReligionType());
assertEquals("Expected secondaryLanguageType field to be initialized with default values", new Short("1253"), client.getSecondaryLanguageType());
assertEquals("Expected sensitiveHlthInfoOnFileIndicator field to be initialized with default values", false, client.getSensitiveHlthInfoOnFileIndicator());
assertEquals("Expected sensitivityIndicator field to be initialized with default values", "N", client.getSensitivityIndicator());
assertEquals("Expected soc158PlacementCode field to be initialized with default values", "N", client.getSoc158PlacementCode());
assertEquals("Expected soc158SealedClientIndicator field to be initialized with default values", false, client.getSoc158SealedClientIndicator());
assertEquals("Expected socialSecurityNumChangedCode field to be initialized with default values", "N", client.getSocialSecurityNumChangedCode());
assertEquals("Expected suffixTitleDescription field to be initialized with default values", "", client.getSuffixTitleDescription());
assertEquals("Expected tribalAncestryClientIndicatorVar field to be initialized with default values", false, client.getTribalAncestryClientIndicatorVar());
assertEquals("Expected tribalMembrshpVerifctnIndicatorVar field to be initialized with default values", false, client.getTribalMembrshpVerifctnIndicatorVar());
assertEquals("Expected unemployedParentCode field to be initialized with default values", "U", client.getUnemployedParentCode());
assertEquals("Expected zippyCreatedIndicator field to be initialized with default values", false, client.getZippyCreatedIndicator());
assertEquals("Expected address field to be initialized with default values", null, client.getAddress());
}
use of gov.ca.cwds.rest.api.domain.Participant in project API by ca-cwds.
the class ParticipantService method create.
/**
* {@inheritDoc}
*
* @see gov.ca.cwds.rest.services.CrudsService#create(gov.ca.cwds.rest.api.Request)
*/
@Override
public Response create(Request request) {
assert request instanceof Participant;
Participant participant = (Participant) request;
gov.ca.cwds.data.persistence.ns.Participant managed = new gov.ca.cwds.data.persistence.ns.Participant(participant, null, null);
Person person = personService.find(managed.getPersonId());
managed = participantDao.create(managed);
return new Participant(managed, person);
}
Aggregations