use of gov.ca.cwds.data.persistence.cms.ReferralClient in project API by ca-cwds.
the class ReferralClientService method update.
@Override
public gov.ca.cwds.rest.api.domain.cms.ReferralClient update(Serializable primaryKeyObject, Request request) {
assert request instanceof gov.ca.cwds.rest.api.domain.cms.ReferralClient;
gov.ca.cwds.rest.api.domain.cms.ReferralClient referralClient = (gov.ca.cwds.rest.api.domain.cms.ReferralClient) request;
try {
ReferralClient managed = new ReferralClient(referralClient, "BTr");
// checking the staffPerson county code
StaffPerson staffperson = staffpersonDao.find(managed.getLastUpdatedId());
if (staffperson != null && (triggerTablesDao.getLaCountySpecificCode().equals(staffperson.getCountyCode()))) {
laCountyTrigger.createCountyTrigger(managed);
} else {
nonLaTriggers.createAndUpdateReferralClientCoutyOwnership(managed);
}
return new gov.ca.cwds.rest.api.domain.cms.ReferralClient(managed);
} catch (EntityNotFoundException e) {
LOGGER.info("Referral not found : {}", referralClient);
LOGGER.error(e.getMessage(), e);
throw new ServiceException(e);
}
}
use of gov.ca.cwds.data.persistence.cms.ReferralClient in project API by ca-cwds.
the class ReferralClientDaoIT method testCreateExistingEntityException.
@Override
@Test
public void testCreateExistingEntityException() throws Exception {
thrown.expect(EntityExistsException.class);
ReferralClient referralClient = new ReferralClient("LNuzMKw06s", "AazXkWY06s", "", (short) 122, (short) 681, "S", null, "N", "N", "", (short) 2, "", "", "Y", "N", "N");
referralClientDao.create(referralClient);
}
use of gov.ca.cwds.data.persistence.cms.ReferralClient in project API by ca-cwds.
the class ReferralClientDaoIT method testUpdate.
@Override
@Test
public void testUpdate() throws Exception {
ReferralClient referralClient = new ReferralClient("LNuzMKw06s", "AazXkWY06s", "", (short) 122, (short) 681, "S", null, "N", "N", "", (short) 2, "", "", "Y", "N", "N");
ReferralClient updated = referralClientDao.update(referralClient);
assertThat(updated, is(referralClient));
}
use of gov.ca.cwds.data.persistence.cms.ReferralClient in project API by ca-cwds.
the class LACountyTriggerTest method referralClientFkClientIdNullTest.
/*
* Test for checking referralClient county trigger not created as FkClient_T is null
*/
@SuppressWarnings("javadoc")
@Test
public void referralClientFkClientIdNullTest() throws JsonParseException, JsonMappingException, IOException {
when(countyTriggerDao.find(any(String.class))).thenReturn(null);
gov.ca.cwds.rest.api.domain.cms.ReferralClient validDomainReferralClient = MAPPER.readValue(fixture("fixtures/legacy/business/rules/laCountyTrigger/referralClientFkClientTIdNull.json"), gov.ca.cwds.rest.api.domain.cms.ReferralClient.class);
when(countyTriggerDao.create(any(CountyTrigger.class))).thenAnswer(new Answer<CountyTrigger>() {
@Override
public CountyTrigger answer(InvocationOnMock invocation) throws Throwable {
CountyTrigger report = (CountyTrigger) invocation.getArguments()[0];
countyTrigger = report;
return report;
}
});
ReferralClient referralClient = new ReferralClient(validDomainReferralClient, "BTr");
laCountyTrigger.createCountyTrigger(referralClient);
assertThat(countyTrigger, is(equalTo(null)));
}
use of gov.ca.cwds.data.persistence.cms.ReferralClient 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;
}
Aggregations