@Test public void subscribeMessageTest() throws Exception { Subscription subscription = getSampleSubscriptionPojo(); Document generatedSubscriptinDoc = RequestMessageBuilderUtilities.createSubscriptionRequest(subscription); String subQualId = XmlUtils.xPathStringSearch( generatedSubscriptinDoc, "//submsg-ext:SubscriptionQualifierIdentification/nc:IdentificationID"); String sGeneratedSubscriptionDoc = XmlUtils.getStringFromNode(generatedSubscriptinDoc); String sExpectedXmlSubDoc = XmlUtils.getRootNodeAsString( "src/test/resources/xml/subscriptionRequest/Arrest_Subscription_Document.xml"); sExpectedXmlSubDoc = sExpectedXmlSubDoc.replace("@SUB_QUAL_ID@", subQualId); Diff diff = new Diff(sExpectedXmlSubDoc, sGeneratedSubscriptionDoc); DetailedDiff detailDiff = new DetailedDiff(diff); List<Difference> diffList = detailDiff.getAllDifferences(); int diffCount = diffList.size(); Assert.assertEquals(detailDiff.toString(), 0, diffCount); }
private void updateSubject(Node rootNode, String transactionNumber) throws Exception { IdentificationTransaction identificationTransaction = rapbackDAO.getIdentificationTransaction(transactionNumber); Subject subject = identificationTransaction.getSubject(); String fbiId = XmlUtils.xPathStringSearch( rootNode, "jxdm50:Subject/nc30:RoleOfPerson/jxdm50:PersonAugmentation/jxdm50:PersonFBIIdentification/nc30:IdentificationID"); if (StringUtils.isNotBlank(fbiId)) { subject.setUcn(fbiId); } String civilSid = XmlUtils.xPathStringSearch( rootNode, "jxdm50:Subject/nc30:RoleOfPerson/jxdm50:PersonAugmentation/jxdm50:PersonStateFingerprintIdentification[ident-ext:FingerprintIdentificationIssuedForCivilPurposeIndicator='true']/nc30:IdentificationID"); if (StringUtils.isNotBlank(civilSid)) { subject.setCivilSid(civilSid); } String criminalSid = XmlUtils.xPathStringSearch( rootNode, "jxdm50:Subject/nc30:RoleOfPerson/jxdm50:PersonAugmentation/jxdm50:PersonStateFingerprintIdentification[ident-ext:FingerprintIdentificationIssuedForCriminalPurposeIndicator='true']/nc30:IdentificationID"); if (StringUtils.isNotBlank(criminalSid)) { subject.setCriminalSid(criminalSid); } rapbackDAO.updateSubject(subject); }
private void addResidenceLocationElement( Document parentDocument, PersonElementWrapper person, Element rapSheetElement, String locationId) { Element e; e = appendElement(rapSheetElement, OjbcNamespaceContext.NS_NC, "ResidenceAssociation"); Element ra = e; e = appendElement(ra, OjbcNamespaceContext.NS_NC, "PersonReference"); XmlUtils.addAttribute(e, OjbcNamespaceContext.NS_STRUCTURES, "ref", person.personId); e = appendElement(ra, OjbcNamespaceContext.NS_NC, "LocationReference"); XmlUtils.addAttribute(e, OjbcNamespaceContext.NS_STRUCTURES, "ref", locationId); }
private void addArrestAgencyAssociations( Document parentDocument, Element rapSheetElement, List<Arrest> arrests) { for (Arrest arrest : arrests) { Element e = appendElement( rapSheetElement, OjbcNamespaceContext.NS_RAPSHEET_41, "ArrestAgencyAssociation"); Element aaa = e; e = appendElement(aaa, OjbcNamespaceContext.NS_NC, "ActivityReference"); XmlUtils.addAttribute(e, OjbcNamespaceContext.NS_STRUCTURES, "ref", arrest.id); e = appendElement(aaa, OjbcNamespaceContext.NS_NC, "OrganizationReference"); XmlUtils.addAttribute( e, OjbcNamespaceContext.NS_STRUCTURES, "ref", arrest.arrestingAgency.getXmlId()); } }
private void addAgencyElements( Document parentDocument, Element rapSheetElement, Set<Agency> agencies) { Element e; for (Agency agency : agencies) { e = appendElement(rapSheetElement, OjbcNamespaceContext.NS_RAPSHEET_41, "Agency"); XmlUtils.addAttribute(e, OjbcNamespaceContext.NS_STRUCTURES, "id", agency.getXmlId()); e = appendElement(e, OjbcNamespaceContext.NS_NC, "OrganizationName"); e.setTextContent(agency.name); } }
private void addSupervisionAgencyAssociations( Document parentDocument, Element rapSheetElement, List<Arrest> arrests) { for (Arrest arrest : arrests) { if (arrest.custodySupervisionId != null) { Element saa = appendElement( rapSheetElement, OjbcNamespaceContext.NS_RAPSHEET_41, "SupervisionAgencyAssociation"); Element e = appendElement(saa, OjbcNamespaceContext.NS_RAPSHEET_41, "SupervisionReference"); XmlUtils.addAttribute( e, OjbcNamespaceContext.NS_STRUCTURES, "ref", arrest.custodySupervisionId); e = appendElement(saa, OjbcNamespaceContext.NS_NC, "OrganizationReference"); XmlUtils.addAttribute( e, OjbcNamespaceContext.NS_STRUCTURES, "ref", arrest.custodySupervisionAgency.getXmlId()); } if (arrest.probationSupervisionId != null) { Element saa = appendElement( rapSheetElement, OjbcNamespaceContext.NS_RAPSHEET_41, "SupervisionAgencyAssociation"); Element e = appendElement(saa, OjbcNamespaceContext.NS_RAPSHEET_41, "SupervisionReference"); XmlUtils.addAttribute( e, OjbcNamespaceContext.NS_STRUCTURES, "ref", arrest.probationSupervisionId); e = appendElement(saa, OjbcNamespaceContext.NS_NC, "OrganizationReference"); XmlUtils.addAttribute( e, OjbcNamespaceContext.NS_STRUCTURES, "ref", arrest.probationSupervisionAgency.getXmlId()); } } }
@Transactional public void processReport(@Body Document report, Exchange exchange) throws Exception { log.info("Processing Identification Results Report."); Node rootNode = XmlUtils.xPathNodeSearch( report, "/pidresults:PersonFederalIdentificationResults[ident-ext:CivilIdentificationReasonCode]|" + "/pidresults:PersonStateIdentificationResults[ident-ext:CivilIdentificationReasonCode]"); if (rootNode != null) { processCivilInitialResultsReport(rootNode, exchange); } else { rootNode = XmlUtils.xPathNodeSearch( report, "/pidresults:PersonFederalIdentificationResults[ident-ext:CriminalIdentificationReasonCode]|" + "/pidresults:PersonStateIdentificationResults[ident-ext:CriminalIdentificationReasonCode]"); processCriminalInitialResultsReport(rootNode, exchange); } }
@Test public void testCreatePersonSearchError() throws Exception { Document doc = PersonQueryResponseErrorBuilderUtils.createPersonQueryCriminalHistoryError( "Error Text", "ID12345"); // XmlUtils.printNode(doc); // ensure the document we generated is valid by using the xsd to validate it XmlUtils.validateInstance( "ssp/Criminal_History_Query_Results/artifacts/service_model/information_model/IEPD/xsd", "NIEM_2.1", "Criminal_History.xsd", doc); }
private void addBiometricElement( Document parentDocument, PersonElementWrapper person, Element rapSheetElement) { Element bior = appendElement( rapSheetElement, OjbcNamespaceContext.NS_RAPSHEET_41, "PersonBiometricsAssociation"); Element e = appendElement(bior, OjbcNamespaceContext.NS_NC, "PersonReference"); XmlUtils.addAttribute(e, OjbcNamespaceContext.NS_STRUCTURES, "ref", person.personId); Element bio = appendElement(bior, OjbcNamespaceContext.NS_NC, "Biometric"); e = appendElement(bio, OjbcNamespaceContext.NS_NC, "BiometricValueText"); e.setTextContent("W W \\ \\ \\ ,W A / / /"); e = appendElement(bio, OjbcNamespaceContext.NS_NC, "BiometricDescriptionText"); e.setTextContent("Fingerprint Class"); e = appendElement(bior, OjbcNamespaceContext.NS_RAPSHEET_41, "PersonBiometrics"); }
private String addLocationElement( Document parentDocument, PersonElementWrapper person, Element rapSheet) { StringBuffer fullAddress = new StringBuffer(1024); fullAddress .append(person.streetAddress) .append(" ") .append(person.city) .append(", ") .append(person.state) .append(" ") .append(person.zipCode); String id = "L" + String.valueOf(fullAddress.hashCode()); Element location = appendElement(rapSheet, OjbcNamespaceContext.NS_NC, "Location"); XmlUtils.addAttribute(location, OjbcNamespaceContext.NS_STRUCTURES, "id", id); Element e = appendElement(location, OjbcNamespaceContext.NS_NC, "LocationAddress"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "AddressFullText"); e.setTextContent(fullAddress.toString()); return id; }
private String getTransactionNumber(Node rootNode) throws Exception { String transactionNumber = XmlUtils.xPathStringSearch( rootNode, "ident-ext:TransactionIdentification/nc30:IdentificationID"); return transactionNumber; }
private String getPersonRace(Node personNode, String jxdmPrefix) throws Exception { String personRace = XmlUtils.xPathStringSearch(personNode, jxdmPrefix + ":PersonRaceCode"); return StringUtils.trimToNull(personRace); }
@Test public void testNotificationBroker() throws Exception { notificationBrokerMockEndpoint.expectedMessageCount(1); loggingEndpoint.expectedMessageCount(1); // Create a new exchange Exchange senderExchange = new DefaultExchange(context); // Set the WS-Address Message ID Map<String, Object> requestContext = OJBUtils.setWSAddressingMessageID("123456789"); // Set the operation name and operation namespace for the CXF exchange senderExchange.getIn().setHeader(Client.REQUEST_CONTEXT, requestContext); Document doc = createDocument(); List<SoapHeader> soapHeaders = new ArrayList<SoapHeader>(); soapHeaders.add( makeSoapHeader(doc, "http://www.w3.org/2005/08/addressing", "MessageID", "12345")); senderExchange.getIn().setHeader(Header.HEADER_LIST, soapHeaders); org.apache.cxf.message.Message message = new MessageImpl(); senderExchange.getIn().setHeader(CxfConstants.CAMEL_CXF_MESSAGE, message); senderExchange .getIn() .setHeader(CxfConstants.OPERATION_NAME, CXF_OPERATION_NAME_CRIMINAL_HISTORY); senderExchange .getIn() .setHeader(CxfConstants.OPERATION_NAMESPACE, CXF_OPERATION_NAMESPACE_CRIMINAL_HISTORY); // Read the firearm search request file from the file system File inputFile = new File( "src/test/resources/xmlInstances/cycleTrackingIdentifierAssignmentReport/Cycle-Tracking-Identifier-Assignment-Report.xml"); String inputStr = FileUtils.readFileToString(inputFile); assertNotNull(inputStr); log.debug(inputStr); // Set it as the message message body senderExchange.getIn().setBody(inputStr); // Send the one-way exchange. Using template.send will send an one way message Exchange returnExchange = template.send("direct:criminalHistoryUpdatedReportingService", senderExchange); // Use getException to see if we received an exception if (returnExchange.getException() != null) { throw new Exception(returnExchange.getException()); } // Sleep while a response is generated Thread.sleep(3000); // Assert that the mock endpoint expectations are satisfied notificationBrokerMockEndpoint.assertIsSatisfied(); loggingEndpoint.assertIsSatisfied(); // Get the first exchange (the only one) Exchange ex = notificationBrokerMockEndpoint.getExchanges().get(0); String opName = (String) ex.getIn().getHeader("operationName"); assertEquals("Notify", opName); String opNamespace = (String) ex.getIn().getHeader("operationNamespace"); assertEquals("http://docs.oasis-open.org/wsn/brw-2", opNamespace); Document returnDocumentNotificationBroker = ex.getIn().getBody(Document.class); // Do some very basic assertions to assure the message is transformed. // The XSLT test does a more complete examination of the transformation. Node notifyNode = XmlUtils.xPathNodeSearch(returnDocumentNotificationBroker, "/b-2:Notify"); Node notifyMesssageNode = XmlUtils.xPathNodeSearch(notifyNode, "b-2:NotificationMessage"); Node messageNode = XmlUtils.xPathNodeSearch(notifyMesssageNode, "b-2:Message"); assertNotNull(messageNode); // Get the first exchange (the only one) to the logger // This is what would be sent to the implementation specific route Exchange exImplementationSpecific = loggingEndpoint.getExchanges().get(0); Document returnDocumentImplementationSpecific = exImplementationSpecific.getIn().getBody(Document.class); // Make sure the root node here is the message to the original exchange Node rootNode = XmlUtils.xPathNodeSearch( returnDocumentImplementationSpecific, "/crimhistory-update-exch:CycleTrackingIdentifierAssignmentReport"); assertNotNull(rootNode); // XmlUtils.printNode(returnDocumentImplementationSpecific); }
private void addPersonElement( Document parentDocument, PersonElementWrapper person, Element rapSheetElement) { Element rsp = appendElement(rapSheetElement, OjbcNamespaceContext.NS_RAPSHEET_41, "RapSheetPerson"); Element e; XmlUtils.addAttribute(rsp, OjbcNamespaceContext.NS_STRUCTURES, "id", person.personId); if (coinFlip(.7)) { e = appendElement(rsp, OjbcNamespaceContext.NS_NC, "PersonAlternateName"); Element alternateName = e; e = appendElement(alternateName, OjbcNamespaceContext.NS_NC, "PersonGivenName"); e.setTextContent(person.firstName + " " + generateRandomLetter()); e = appendElement(alternateName, OjbcNamespaceContext.NS_NC, "PersonSurName"); e.setTextContent(person.lastName); } if (coinFlip(.1)) { e = appendElement(rsp, OjbcNamespaceContext.NS_NC, "PersonAlternateName"); Element alternateName = e; e = appendElement(alternateName, OjbcNamespaceContext.NS_NC, "PersonGivenName"); e.setTextContent(person.firstName); e = appendElement(alternateName, OjbcNamespaceContext.NS_NC, "PersonSurName"); e.setTextContent( person.lastName + "-" + generateRandomCodeFromList( "Washington", "Adams", "Jefferson", "Madison", "Monroe")); } e = appendElement(rsp, OjbcNamespaceContext.NS_NC, "PersonBirthDate"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "Date"); e.setTextContent(DATE_FORMATTER_YYYY_MM_DD.print(person.birthdate)); e = appendElement(rsp, OjbcNamespaceContext.NS_RAPSHEET_41, "PersonEyeColorText"); e.setTextContent(generateRandomCodeFromList("Brown", "Black", "Blue", "Hazel")); e = appendElement(rsp, OjbcNamespaceContext.NS_RAPSHEET_41, "PersonHairColorText"); e.setTextContent( generateRandomCodeFromList("Brown", "Black", "Red Or Auburn", "Blonde Or Strawberry")); if (coinFlip(.4)) { e = appendElement(rsp, OjbcNamespaceContext.NS_NC, "PersonHeightMeasure"); Element phm = e; e = appendElement(e, OjbcNamespaceContext.NS_NC, "MeasurePointValue"); e.setTextContent(String.valueOf(Math.round(Integer.parseInt(person.centimeters) * .39))); e = appendElement(phm, OjbcNamespaceContext.NS_NC, "LengthUnitCode"); e.setTextContent("INH"); } e = appendElement(rsp, OjbcNamespaceContext.NS_NC, "PersonName"); Element pn = e; e = appendElement(pn, OjbcNamespaceContext.NS_NC, "PersonGivenName"); e.setTextContent(person.firstName); e = appendElement(pn, OjbcNamespaceContext.NS_NC, "PersonMiddleName"); e.setTextContent(person.middleName); e = appendElement(pn, OjbcNamespaceContext.NS_NC, "PersonSurName"); e.setTextContent(person.lastName); e = appendElement(rsp, OjbcNamespaceContext.NS_NC, "PersonRaceCode"); e.setTextContent(generateRandomCodeFromList("B", "A", "W", "U", "I")); e = appendElement(rsp, OjbcNamespaceContext.NS_NC, "PersonSexCode"); e.setTextContent(person.sex.substring(0, 1).toUpperCase()); if (coinFlip(.8)) { e = appendElement(rsp, OjbcNamespaceContext.NS_NC, "PersonSSNIdentification"); Element ssn = e; e = appendElement(ssn, OjbcNamespaceContext.NS_NC, "IdentificationID"); e.setTextContent(person.nationalID); e = appendElement(ssn, OjbcNamespaceContext.NS_NC, "IdentificationJurisdictionText"); e.setTextContent("SSA"); } if (coinFlip(.4)) { e = appendElement(rsp, OjbcNamespaceContext.NS_NC, "PersonWeightMeasure"); Element pwm = e; e = appendElement(pwm, OjbcNamespaceContext.NS_NC, "MeasurePointValue"); e.setTextContent(person.pounds); e = appendElement(pwm, OjbcNamespaceContext.NS_NC, "WeightUnitCode"); e.setTextContent("LBR"); } e = appendElement(rsp, OjbcNamespaceContext.NS_JXDM_41, "PersonAugmentation"); Element pa = e; if (coinFlip(.7)) { e = appendElement(pa, OjbcNamespaceContext.NS_JXDM_41, "PersonFBIIdentification"); Element fbi = e; e = appendElement(fbi, OjbcNamespaceContext.NS_NC, "IdentificationID"); e.setTextContent( generateRandomID("", 6) + generateRandomLetter() + generateRandomLetter() + generateRandomID("", 1)); e = appendElement(fbi, OjbcNamespaceContext.NS_NC, "IdentificationJurisdictionText"); } e = appendElement(pa, OjbcNamespaceContext.NS_JXDM_41, "PersonStateFingerprintIdentification"); Element sid = e; e = appendElement(sid, OjbcNamespaceContext.NS_NC, "IdentificationID"); e.setTextContent(generateRandomID("A", 7)); e = appendElement(sid, OjbcNamespaceContext.NS_NC, "IdentificationJurisdictionText"); }
private void addSupervisionCycleElements( Document parentDocument, Element rapSheetElement, List<Arrest> arrests) { Element e; for (Arrest arrest : arrests) { if (arrest.custodyEndDate != null) { Element rapSheetCycle = appendElement(rapSheetElement, OjbcNamespaceContext.NS_CH_EXT, "RapSheetCycle"); e = appendElement(rapSheetCycle, OjbcNamespaceContext.NS_RAPSHEET_41, "CycleEarliestDate"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "Date"); e.setTextContent(DATE_FORMATTER_YYYY_MM_DD.print(arrest.dispoDate)); Element supervisionElement = appendElement(rapSheetCycle, OjbcNamespaceContext.NS_RAPSHEET_41, "Supervision"); XmlUtils.addAttribute( supervisionElement, OjbcNamespaceContext.NS_STRUCTURES, "id", arrest.custodySupervisionId); e = appendElement(supervisionElement, OjbcNamespaceContext.NS_NC, "ActivityCategoryText"); e.setTextContent("CUSTODY"); e = appendElement(supervisionElement, OjbcNamespaceContext.NS_NC, "ActivityDate"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "Date"); e.setTextContent(DATE_FORMATTER_YYYY_MM_DD.print(arrest.dispoDate)); e = appendElement( supervisionElement, OjbcNamespaceContext.NS_NC, "SupervisionCustodyStatus"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "StatusDescriptionText"); e.setTextContent(arrest.felonyConviction ? "SENT FELON" : "SENT MISD"); e = appendElement(supervisionElement, OjbcNamespaceContext.NS_NC, "SupervisionRelease"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "ActivityDate"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "Date"); e.setTextContent(DATE_FORMATTER_YYYY_MM_DD.print(arrest.custodyEndDate)); } if (arrest.probationEndDate != null) { Element rapSheetCycle = appendElement(rapSheetElement, OjbcNamespaceContext.NS_CH_EXT, "RapSheetCycle"); e = appendElement(rapSheetCycle, OjbcNamespaceContext.NS_RAPSHEET_41, "CycleEarliestDate"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "Date"); e.setTextContent(DATE_FORMATTER_YYYY_MM_DD.print(arrest.dispoDate)); Element supervisionElement = appendElement(rapSheetCycle, OjbcNamespaceContext.NS_RAPSHEET_41, "Supervision"); XmlUtils.addAttribute( supervisionElement, OjbcNamespaceContext.NS_STRUCTURES, "id", arrest.probationSupervisionId); e = appendElement(supervisionElement, OjbcNamespaceContext.NS_NC, "ActivityCategoryText"); e.setTextContent("PROBATION"); e = appendElement(supervisionElement, OjbcNamespaceContext.NS_NC, "ActivityDate"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "Date"); e.setTextContent(DATE_FORMATTER_YYYY_MM_DD.print(arrest.dispoDate)); e = appendElement( supervisionElement, OjbcNamespaceContext.NS_NC, "SupervisionCustodyStatus"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "StatusDescriptionText"); e.setTextContent(arrest.felonyConviction ? "SENT FELON" : "SENT MISD"); e = appendElement(supervisionElement, OjbcNamespaceContext.NS_NC, "SupervisionRelease"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "ActivityDate"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "Date"); e.setTextContent(DATE_FORMATTER_YYYY_MM_DD.print(arrest.probationEndDate)); } } }
private void addMainCycleElements( Document parentDocument, Element rapSheetElement, List<Arrest> arrests) { Element e; for (Arrest arrest : arrests) { boolean courtAction = false; Element rapSheetCycle = appendElement(rapSheetElement, OjbcNamespaceContext.NS_CH_EXT, "RapSheetCycle"); e = appendElement(rapSheetCycle, OjbcNamespaceContext.NS_RAPSHEET_41, "CycleEarliestDate"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "Date"); e.setTextContent(DATE_FORMATTER_YYYY_MM_DD.print(arrest.date)); Element arrestElement = appendElement(rapSheetCycle, OjbcNamespaceContext.NS_RAPSHEET_41, "Arrest"); XmlUtils.addAttribute(arrestElement, OjbcNamespaceContext.NS_STRUCTURES, "id", arrest.id); e = appendElement(arrestElement, OjbcNamespaceContext.NS_NC, "ActivityDate"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "Date"); e.setTextContent(DATE_FORMATTER_YYYY_MM_DD.print(arrest.date)); e = appendElement( arrestElement, OjbcNamespaceContext.NS_JXDM_41, "ArrestAgencyRecordIdentification"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "IdentificationID"); e.setTextContent(arrest.recordId); for (ArrestCharge arrestCharge : arrest.charges) { Element arrestChargeElement = appendElement(arrestElement, OjbcNamespaceContext.NS_RAPSHEET_41, "ArrestCharge"); e = appendElement( arrestChargeElement, OjbcNamespaceContext.NS_JXDM_41, "ChargeDescriptionText"); e.setTextContent(arrestCharge.description); if (!arrestCharge.prosecuted) { e = appendElement( arrestChargeElement, OjbcNamespaceContext.NS_JXDM_41, "ChargeDisposition"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "DispositionDescriptionText"); e.setTextContent("LACK OF PROS"); } else { courtAction = true; } e = appendElement( arrestChargeElement, OjbcNamespaceContext.NS_JXDM_41, "ChargeIdentification"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "IdentificationID"); e.setTextContent(arrestCharge.id); e = appendElement( arrestChargeElement, OjbcNamespaceContext.NS_JXDM_41, "ChargeSeverityText"); e.setTextContent(arrestCharge.severity); e = appendElement( arrestChargeElement, OjbcNamespaceContext.NS_JXDM_41, "ChargeTrackingIdentification"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "IdentificationID"); e.setTextContent(arrestCharge.trackingId); } boolean sentenced = false; if (courtAction && arrest.dispoDate != null) { Element courtActionElement = appendElement(rapSheetCycle, OjbcNamespaceContext.NS_RAPSHEET_41, "CourtAction"); for (ArrestCharge arrestCharge : arrest.charges) { if (arrestCharge.prosecuted) { Element courtChargeElement = appendElement( courtActionElement, OjbcNamespaceContext.NS_RAPSHEET_41, "CourtCharge"); e = appendElement( courtChargeElement, OjbcNamespaceContext.NS_JXDM_41, "ChargeDescriptionText"); e.setTextContent(arrestCharge.description); e = appendElement( courtChargeElement, OjbcNamespaceContext.NS_JXDM_41, "ChargeDisposition"); Element dispoElement = e; e = appendElement(dispoElement, OjbcNamespaceContext.NS_NC, "DispositionDate"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "Date"); e.setTextContent(DATE_FORMATTER_YYYY_MM_DD.print(arrest.dispoDate)); e = appendElement( dispoElement, OjbcNamespaceContext.NS_NC, "DispositionDescriptionText"); if (arrestCharge.guilty) { e.setTextContent("GUILTY"); sentenced = true; } else { e.setTextContent("NOT GUILTY"); } e = appendElement( courtChargeElement, OjbcNamespaceContext.NS_JXDM_41, "ChargeIdentification"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "IdentificationID"); e.setTextContent(arrestCharge.id); e = appendElement( courtChargeElement, OjbcNamespaceContext.NS_JXDM_41, "ChargeSeverityText"); e.setTextContent(arrestCharge.severity); e = appendElement( courtChargeElement, OjbcNamespaceContext.NS_JXDM_41, "ChargeTrackingIdentification"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "IdentificationID"); e.setTextContent(arrestCharge.trackingId); } } } if (sentenced) { Element sentencingElement = appendElement(rapSheetCycle, OjbcNamespaceContext.NS_CH_EXT, "Sentencing"); for (ArrestCharge arrestCharge : arrest.charges) { if (arrestCharge.guilty) { Element sentenceElement = appendElement(sentencingElement, OjbcNamespaceContext.NS_CH_EXT, "Sentence"); e = appendElement( sentenceElement, OjbcNamespaceContext.NS_JXDM_41, "SentenceDescriptionText"); String termPeriod = " DAYS"; String sentenceType = " CONFINEMENT "; int termLength = arrestCharge.offense.daysInJail; if (termLength > 365 * 2) { termLength = (int) Math.round(termLength / 365.0); termPeriod = " YEARS"; } else if (termLength == 0) { termLength = (int) Math.round(arrestCharge.offense.daysOfProbation / 30.0); termPeriod = " MONTHS"; sentenceType = " PROBATION "; } e.setTextContent( "ON " + DATE_FORMATTER_MM_DD_YYYY.print(arrest.dispoDate) + " SUBJECT SENTENCED TO " + termLength + termPeriod + sentenceType + "AND " + "A FINE OF " + NumberFormat.getCurrencyInstance().format(arrestCharge.offense.fine)); e = appendElement( sentenceElement, OjbcNamespaceContext.NS_RAPSHEET_41, "SentenceCharge"); e = appendElement(e, OjbcNamespaceContext.NS_JXDM_41, "ChargeTrackingIdentification"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "IdentificationID"); e.setTextContent(arrestCharge.trackingId); } } } } }