Search in sources :

Example 6 with CountyTrigger

use of gov.ca.cwds.data.persistence.cms.CountyTrigger in project API by ca-cwds.

the class LACountyTrigger method createClientAddressCountyTrigger.

/**
   * @param object The object creates the county Trigger for the clientAddress
   * @return the CountyTrigger created
   */
public boolean createClientAddressCountyTrigger(Object object) {
    ClientAddress clientAddress;
    if (object instanceof ClientAddress) {
        clientAddress = (ClientAddress) object;
        if (clientAddress.getFkClient() != "" && clientAddress.getFkClient() != null && clientAddress.getFkAddress() != "" && clientAddress.getFkAddress() != null) {
            CountyTrigger countyTrigger1 = new CountyTrigger(clientAddress.getFkClient(), LA_COUNTY_SPECIFIC_CODE, CLIENT_COUNTYOWNERSHIP, new Date(), ClientAddress.class.getDeclaredAnnotation(Table.class).name());
            CountyTrigger countyTrigger2 = new CountyTrigger(clientAddress.getFkAddress(), LA_COUNTY_SPECIFIC_CODE, ADDRESS_COUNTYOWNERSHIP, new Date(), ClientAddress.class.getDeclaredAnnotation(Table.class).name());
            countyTriggerDao.create(countyTrigger1);
            countyTriggerDao.create(countyTrigger2);
        }
        LOGGER.info("LA county clientAddress triggered");
    }
    return true;
}
Also used : ClientAddress(gov.ca.cwds.data.persistence.cms.ClientAddress) CountyTrigger(gov.ca.cwds.data.persistence.cms.CountyTrigger) Date(java.util.Date)

Example 7 with CountyTrigger

use of gov.ca.cwds.data.persistence.cms.CountyTrigger in project API by ca-cwds.

the class LACountyTrigger method createCountyTrigger.

/**
   * @param object The object creates the county Trigger for the Referral and referralClient
   * @return the countyTrigger created
   */
public boolean createCountyTrigger(Object object) {
    Referral referral;
    ReferralClient referralClient;
    if (object instanceof Referral) {
        referral = (Referral) object;
        if (referral.getAllegesAbuseOccurredAtAddressId() != "" && referral.getAllegesAbuseOccurredAtAddressId() != null) {
            CountyTrigger countyTrigger = new CountyTrigger(referral.getAllegesAbuseOccurredAtAddressId(), referral.getCountySpecificCode(), ADDRESS_COUNTYOWNERSHIP, null, Referral.class.getDeclaredAnnotation(Table.class).name());
            countyTriggerDao.create(countyTrigger);
            LOGGER.info("LA county referral address triggered");
        }
    }
    if (object instanceof ReferralClient) {
        referralClient = (ReferralClient) object;
        if (referralClient.getClientId() != "" && referralClient.getClientId() != null) {
            CountyTrigger countyTrigger = new CountyTrigger(referralClient.getClientId(), referralClient.getCountySpecificCode(), CLIENT_COUNTYOWNERSHIP, null, ReferralClient.class.getDeclaredAnnotation(Table.class).name());
            countyTriggerDao.create(countyTrigger);
            LOGGER.info("LA county referralClient triggered");
        }
    }
    return true;
}
Also used : Referral(gov.ca.cwds.data.persistence.cms.Referral) CountyTrigger(gov.ca.cwds.data.persistence.cms.CountyTrigger) ReferralClient(gov.ca.cwds.data.persistence.cms.ReferralClient)

Example 8 with CountyTrigger

use of gov.ca.cwds.data.persistence.cms.CountyTrigger in project API by ca-cwds.

the class CountyTriggerDaoIT method testDelete.

@Override
@Test
public void testDelete() throws Exception {
    String timestamp = "2017-05-23 19:53:50.505";
    CountyTriggerEmbeddable countyTriggerEmbeddable = new CountyTriggerEmbeddable(countyOwnershipT, null);
    DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    Date date = formatter.parse(timestamp);
    countyTriggerEmbeddable.setIntegratorTimeStamp(date);
    CountyTrigger deleted = countyTriggerDao.delete(countyTriggerEmbeddable);
    assertThat(deleted.getCountyTriggerEmbeddable().getCountyOwnershipT(), is(countyOwnershipT));
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) CountyTrigger(gov.ca.cwds.data.persistence.cms.CountyTrigger) CountyTriggerEmbeddable(gov.ca.cwds.data.persistence.cms.CountyTriggerEmbeddable) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Example 9 with CountyTrigger

use of gov.ca.cwds.data.persistence.cms.CountyTrigger in project API by ca-cwds.

the class CountyTriggerDaoIT method testFind.

@Override
@Test
public void testFind() throws Exception {
    String timestamp = "2017-05-23 19:53:50.505";
    CountyTriggerEmbeddable countyTriggerEmbeddable = new CountyTriggerEmbeddable(countyOwnershipT, null);
    DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    Date date = formatter.parse(timestamp);
    countyTriggerEmbeddable.setIntegratorTimeStamp(date);
    CountyTrigger found = countyTriggerDao.find(countyTriggerEmbeddable);
    assertThat(found.getCountyTriggerEmbeddable().getCountyOwnershipT(), is(equalTo(countyOwnershipT)));
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) CountyTrigger(gov.ca.cwds.data.persistence.cms.CountyTrigger) CountyTriggerEmbeddable(gov.ca.cwds.data.persistence.cms.CountyTriggerEmbeddable) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Example 10 with CountyTrigger

use of gov.ca.cwds.data.persistence.cms.CountyTrigger in project API by ca-cwds.

the class CountyTriggerDaoIT method testDeleteEntityNotFoundException.

@Override
@Test
public void testDeleteEntityNotFoundException() throws Exception {
    CountyTriggerEmbeddable countyTriggerEmbeddable = new CountyTriggerEmbeddable("ABC1234568", null);
    CountyTrigger deleted = countyTriggerDao.delete(countyTriggerEmbeddable);
    assertThat(deleted, is(nullValue()));
}
Also used : CountyTrigger(gov.ca.cwds.data.persistence.cms.CountyTrigger) CountyTriggerEmbeddable(gov.ca.cwds.data.persistence.cms.CountyTriggerEmbeddable) Test(org.junit.Test)

Aggregations

CountyTrigger (gov.ca.cwds.data.persistence.cms.CountyTrigger)17 Test (org.junit.Test)15 InvocationOnMock (org.mockito.invocation.InvocationOnMock)7 CountyTriggerEmbeddable (gov.ca.cwds.data.persistence.cms.CountyTriggerEmbeddable)5 Date (java.util.Date)5 ClientAddress (gov.ca.cwds.data.persistence.cms.ClientAddress)4 DateFormat (java.text.DateFormat)4 SimpleDateFormat (java.text.SimpleDateFormat)4 Referral (gov.ca.cwds.data.persistence.cms.Referral)3 ReferralClient (gov.ca.cwds.data.persistence.cms.ReferralClient)3