use of gov.ca.cwds.data.persistence.cms.StaffPerson 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.StaffPerson in project API by ca-cwds.
the class ClientService method create.
/**
* {@inheritDoc}
*
* @see gov.ca.cwds.rest.services.CrudsService#create(gov.ca.cwds.rest.api.Request)
*/
@Override
public PostedClient create(Request request) {
assert request instanceof gov.ca.cwds.rest.api.domain.cms.Client;
gov.ca.cwds.rest.api.domain.cms.Client client = (gov.ca.cwds.rest.api.domain.cms.Client) request;
try {
String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
Client managed = new Client(CmsKeyIdGenerator.cmsIdGenertor(lastUpdatedId), client, lastUpdatedId);
managed = clientDao.create(managed);
// checking the staffPerson county code
StaffPerson staffperson = staffpersonDao.find(managed.getLastUpdatedId());
if (staffperson != null && !(triggerTablesDao.getLaCountySpecificCode().equals(staffperson.getCountyCode()))) {
nonLaCountyTriggers.createClientCountyTrigger(managed);
}
return new PostedClient(managed, false);
} catch (EntityExistsException e) {
LOGGER.info("Client already exists : {}", client);
throw new ServiceException(e);
}
}
use of gov.ca.cwds.data.persistence.cms.StaffPerson in project API by ca-cwds.
the class ClientAddressService method update.
@Override
public Response update(Serializable primaryKey, Request request) {
assert primaryKey instanceof String;
assert request instanceof gov.ca.cwds.rest.api.domain.cms.ClientAddress;
gov.ca.cwds.rest.api.domain.cms.ClientAddress clientAddress = (gov.ca.cwds.rest.api.domain.cms.ClientAddress) request;
try {
String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
ClientAddress managed = new ClientAddress((String) primaryKey, clientAddress, lastUpdatedId);
// checking the staffPerson county code
StaffPerson staffperson = staffpersonDao.find(managed.getLastUpdatedId());
if (staffperson != null && (triggerTablesDao.getLaCountySpecificCode().equals(staffperson.getCountyCode()))) {
laCountyTrigger.createClientAddressCountyTrigger(managed);
}
managed = clientAddressDao.update(managed);
return new gov.ca.cwds.rest.api.domain.cms.ClientAddress(managed, true);
} catch (EntityNotFoundException e) {
LOGGER.info("ClientAddress not found : {}", clientAddress);
throw new ServiceException(e);
}
}
use of gov.ca.cwds.data.persistence.cms.StaffPerson in project API by ca-cwds.
the class ReferralClientServiceTest method createCountyTriggerForLACounty.
/*
* Test for checking the staffperson county Code
*/
@SuppressWarnings("javadoc")
@Test
public void createCountyTriggerForLACounty() throws Exception {
ReferralClient referralClientDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/ReferralClient/valid/valid.json"), ReferralClient.class);
gov.ca.cwds.data.persistence.cms.ReferralClient toCreate = new gov.ca.cwds.data.persistence.cms.ReferralClient(referralClientDomain, "BTr");
ReferralClient request = new ReferralClient(toCreate);
when(triggerTablesDao.getLaCountySpecificCode()).thenReturn("19");
StaffPerson staffPerson = new StaffPerson("BTr", null, "External Interface", "external interface", "SCXCIN7", " ", "", BigDecimal.valueOf(9165672100L), 0, null, " ", "N", "MIZN02k00E", " ", " ", "19", "N", "3XPCP92q38", null);
when(staffpersonDao.find(any(String.class))).thenReturn(staffPerson);
when(referralClientDao.create(any(gov.ca.cwds.data.persistence.cms.ReferralClient.class))).thenReturn(toCreate);
when(laCountyTrigger.createCountyTrigger(any(gov.ca.cwds.data.persistence.cms.ReferralClient.class))).thenAnswer(new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
isLaCountyTrigger = true;
return true;
}
});
referralClientService.create(request);
assertThat(isLaCountyTrigger, is(true));
}
use of gov.ca.cwds.data.persistence.cms.StaffPerson in project API by ca-cwds.
the class ReferralServiceTest method createCountyTriggerForLACounty.
/*
* Test for checking the staffperson county Code
*/
@SuppressWarnings("javadoc")
@Test
public void createCountyTriggerForLACounty() throws Exception {
Referral referralDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/Referral/valid/valid.json"), Referral.class);
gov.ca.cwds.data.persistence.cms.Referral toCreate = new gov.ca.cwds.data.persistence.cms.Referral("1234567ABC", referralDomain, "BTr");
Referral request = new Referral(toCreate);
when(triggerTablesDao.getLaCountySpecificCode()).thenReturn("19");
StaffPerson staffPerson = new StaffPerson("BTr", null, "External Interface", "external interface", "SCXCIN7", " ", "", BigDecimal.valueOf(9165672100L), 0, null, " ", "N", "MIZN02k00E", " ", " ", "19", "N", "3XPCP92q38", null);
when(staffpersonDao.find(any(String.class))).thenReturn(staffPerson);
when(referralDao.create(any(gov.ca.cwds.data.persistence.cms.Referral.class))).thenReturn(toCreate);
when(laCountyTrigger.createCountyTrigger(any(gov.ca.cwds.data.persistence.cms.Referral.class))).thenAnswer(new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
isLaCountyTrigger = true;
return true;
}
});
referralService.create(request);
assertThat(isLaCountyTrigger, is(true));
}
Aggregations