use of gov.ca.cwds.rest.api.domain.CrossReport in project API by ca-cwds.
the class ScreeningToReferralService method processCrossReports.
/*
* CMS Cross Report
*/
private Set<gov.ca.cwds.rest.api.domain.CrossReport> processCrossReports(ScreeningToReferral scr, String referralId, Set<ErrorMessage> messages) throws ServiceException {
String crossReportId = "";
Set<gov.ca.cwds.rest.api.domain.CrossReport> resultCrossReports = new HashSet<>();
Set<CrossReport> crossReports;
crossReports = scr.getCrossReports();
if (crossReports != null) {
for (CrossReport crossReport : crossReports) {
Boolean lawEnforcementIndicator = false;
if (crossReport.getAgencyType().contains("Law Enforcement")) {
lawEnforcementIndicator = true;
}
if (crossReport.getLegacyId() == null || crossReport.getLegacyId().isEmpty()) {
// create the cross report
gov.ca.cwds.rest.api.domain.cms.CrossReport cmsCrossReport = gov.ca.cwds.rest.api.domain.cms.CrossReport.createWithDefaults(crossReportId, crossReport, referralId, DEFAULT_STAFF_PERSON_ID, DEFAULT_COUNTY_SPECIFIC_CODE, lawEnforcementIndicator);
buildErrors(messages, validator.validate(cmsCrossReport));
gov.ca.cwds.rest.api.domain.cms.CrossReport postedCrossReport = this.crossReportService.create(cmsCrossReport);
crossReport.setLegacyId(postedCrossReport.getThirdId());
crossReport.setLegacySourceTable(CROSS_REPORT_TABLE_NAME);
resultCrossReports.add(crossReport);
} else {
gov.ca.cwds.rest.api.domain.cms.CrossReport foundCrossReport = this.crossReportService.find(crossReport.getLegacyId());
if (foundCrossReport == null) {
String message = " Legacy Id on Cross Report does not correspond to an existing CMS/CWS Cross Report ";
ServiceException se = new ServiceException(message);
logError(message, se, messages);
}
}
}
}
return resultCrossReports;
}
use of gov.ca.cwds.rest.api.domain.CrossReport 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;
}
Aggregations