Search in sources :

Example 16 with Participant

use of gov.ca.cwds.rest.api.domain.Participant in project API by ca-cwds.

the class ScreeningToReferralService method create.

@UnitOfWork(value = "cms")
@Override
public Response create(Request request) {
    ScreeningToReferral screeningToReferral = (ScreeningToReferral) request;
    Set<ErrorMessage> messages = new HashSet<ErrorMessage>();
    verifyReferralHasValidParticipants(screeningToReferral, messages);
    String dateStarted = extractStartDate(screeningToReferral, messages);
    String timeStarted = extractStartTime(screeningToReferral, messages);
    String referralId = createCmsReferral(screeningToReferral, messages, dateStarted, timeStarted);
    createReferralAddress(screeningToReferral, messages);
    Set<Participant> resultParticipants = new HashSet<>();
    HashMap<Long, String> victimClient = new HashMap<>();
    HashMap<Long, String> perpatratorClient = new HashMap<>();
    processParticipants(screeningToReferral, messages, dateStarted, referralId, resultParticipants, victimClient, perpatratorClient);
    Set<CrossReport> resultCrossReports = createCrossReports(screeningToReferral, messages, referralId);
    Set<Allegation> resultAllegations = createAllegations(screeningToReferral, messages, referralId, victimClient, perpatratorClient);
    PostedScreeningToReferral pstr = PostedScreeningToReferral.createWithDefaults(referralId, screeningToReferral, resultParticipants, resultCrossReports, resultAllegations);
    pstr.setMessages(messages);
    return pstr;
}
Also used : HashMap(java.util.HashMap) Participant(gov.ca.cwds.rest.api.domain.Participant) CrossReport(gov.ca.cwds.rest.api.domain.CrossReport) PostedScreeningToReferral(gov.ca.cwds.rest.api.domain.PostedScreeningToReferral) ScreeningToReferral(gov.ca.cwds.rest.api.domain.ScreeningToReferral) Allegation(gov.ca.cwds.rest.api.domain.Allegation) PostedAllegation(gov.ca.cwds.rest.api.domain.cms.PostedAllegation) ErrorMessage(gov.ca.cwds.rest.api.domain.error.ErrorMessage) PostedScreeningToReferral(gov.ca.cwds.rest.api.domain.PostedScreeningToReferral) HashSet(java.util.HashSet) UnitOfWork(io.dropwizard.hibernate.UnitOfWork)

Example 17 with Participant

use of gov.ca.cwds.rest.api.domain.Participant in project API by ca-cwds.

the class ScreeningServiceTest method updateReturnsCorrectScreeningResponseOnSuccess.

@Test
public void updateReturnsCorrectScreeningResponseOnSuccess() throws Exception {
    roles.add("victim");
    gov.ca.cwds.rest.api.domain.Address domainAddress = new gov.ca.cwds.rest.api.domain.Address("", "", "742 Evergreen Terrace", "Springfield", "WA", 98700, "home");
    addresses.add(domainAddress);
    ScreeningRequest screeningRequest = new ScreeningRequest("ref", "2016-10-31", "Sac", "2016-10-31", "loc", "comm", "name", "now", "sure", "2016-10-31", "narrative", domainAddress);
    Participant bart = new Participant(1, "", "", "Bart", "Simpson", "male", "123456789", "2016-10-31", 1234, 1234, roles, addresses);
    Participant maggie = new Participant(2, "", "", "Maggie", "Simpson", "female", "123456789", "2016-10-31", 1234, 1234, roles, addresses);
    // Participant bart = new Participant(1, 123, "Bart", "Simpson", "M", "2016-10-31",
    // "123456789");
    // Participant maggie = new Participant(2, 1, "Maggie", "Simpson", "M", "2016-10-31",
    // "123456789");
    ImmutableSet.Builder<gov.ca.cwds.data.persistence.ns.Participant> peopleListBuilder = ImmutableSet.builder();
    ImmutableSet<gov.ca.cwds.data.persistence.ns.Participant> people = peopleListBuilder.add(new gov.ca.cwds.data.persistence.ns.Participant(bart, null, null)).add(new gov.ca.cwds.data.persistence.ns.Participant(maggie, null, null)).build();
    gov.ca.cwds.data.persistence.ns.Screening screening = new gov.ca.cwds.data.persistence.ns.Screening(1L, screeningRequest, new Address(domainAddress, null, null), people, null, null);
    when(screeningDao.find(new Long(123))).thenReturn(screening);
    when(screeningDao.update(any())).thenReturn(screening);
    ScreeningResponse expected = new ScreeningResponse(screening, people);
    ScreeningResponse updated = screeningService.update(1L, screeningRequest);
    assertThat(updated, is(expected));
}
Also used : Address(gov.ca.cwds.data.persistence.ns.Address) ScreeningRequest(gov.ca.cwds.rest.api.domain.ScreeningRequest) PostedScreening(gov.ca.cwds.rest.api.domain.PostedScreening) Screening(gov.ca.cwds.data.persistence.ns.Screening) Participant(gov.ca.cwds.rest.api.domain.Participant) ImmutableSet(com.google.common.collect.ImmutableSet) Screening(gov.ca.cwds.data.persistence.ns.Screening) ScreeningResponse(gov.ca.cwds.rest.api.domain.ScreeningResponse) Test(org.junit.Test)

Example 18 with Participant

use of gov.ca.cwds.rest.api.domain.Participant in project API by ca-cwds.

the class ParticipantValidator method anonymousReporter.

/**
   * @param str - ScreeningToReferral object
   * @return Boolean - is an anonymous reporter
   * @throws ServiceException - throw any exception
   */
// is there an anonymous reporter participant on this screening to referral?
public static Boolean anonymousReporter(ScreeningToReferral str) throws ServiceException {
    Set<Participant> participants;
    participants = str.getParticipants();
    if (participants != null) {
        for (Participant incomingParticipant : participants) {
            Set<String> roles = new HashSet<>(incomingParticipant.getRoles());
            if (roles != null && roles.contains(ANONYMOUS_REPORTER_ROLE)) {
                return true;
            }
        }
    }
    return false;
}
Also used : Participant(gov.ca.cwds.rest.api.domain.Participant) HashSet(java.util.HashSet)

Aggregations

Participant (gov.ca.cwds.rest.api.domain.Participant)18 Test (org.junit.Test)13 HashSet (java.util.HashSet)12 Address (gov.ca.cwds.rest.api.domain.Address)3 ImmutableSet (com.google.common.collect.ImmutableSet)1 Address (gov.ca.cwds.data.persistence.ns.Address)1 Screening (gov.ca.cwds.data.persistence.ns.Screening)1 Allegation (gov.ca.cwds.rest.api.domain.Allegation)1 CrossReport (gov.ca.cwds.rest.api.domain.CrossReport)1 Person (gov.ca.cwds.rest.api.domain.Person)1 PostedScreening (gov.ca.cwds.rest.api.domain.PostedScreening)1 PostedScreeningToReferral (gov.ca.cwds.rest.api.domain.PostedScreeningToReferral)1 ScreeningRequest (gov.ca.cwds.rest.api.domain.ScreeningRequest)1 ScreeningResponse (gov.ca.cwds.rest.api.domain.ScreeningResponse)1 ScreeningToReferral (gov.ca.cwds.rest.api.domain.ScreeningToReferral)1 ChildClient (gov.ca.cwds.rest.api.domain.cms.ChildClient)1 Client (gov.ca.cwds.rest.api.domain.cms.Client)1 PostedAllegation (gov.ca.cwds.rest.api.domain.cms.PostedAllegation)1 PostedClient (gov.ca.cwds.rest.api.domain.cms.PostedClient)1 ReferralClient (gov.ca.cwds.rest.api.domain.cms.ReferralClient)1