Example usage for java.util.concurrent ThreadLocalRandom current

List of usage examples for java.util.concurrent ThreadLocalRandom current

Introduction

In this page you can find the example usage for java.util.concurrent ThreadLocalRandom current.

Prototype

public static ThreadLocalRandom current() 

Source Link

Document

Returns the current thread's ThreadLocalRandom .

Usage

From source file:org.ojbc.bundles.adapters.staticmock.samplegen.CourtCaseSampleGenerator.java

Document buildCourtCaseDetailDoc(PersonElementWrapper person) throws ParserConfigurationException, IOException {

    Document rCourtCaseDetailDoc = getNewDocument();

    Element rootCourtCaseElement = rCourtCaseDetailDoc.createElementNS(
            OjbcNamespaceContext.NS_COURT_CASE_QUERY_RESULTS_EXCH_DOC, "CourtCaseQueryResults");
    rootCourtCaseElement.setPrefix(OjbcNamespaceContext.NS_PREFIX_COURT_CASE_QUERY_RESULTS_EXCH_DOC);

    rCourtCaseDetailDoc.appendChild(rootCourtCaseElement);

    Element docCreateDateElement = XmlUtils.appendElement(rootCourtCaseElement, OjbcNamespaceContext.NS_NC_30,
            "DocumentCreationDate");

    Element docCreateDateValElement = XmlUtils.appendElement(docCreateDateElement,
            OjbcNamespaceContext.NS_NC_30, "DateTime");

    String sCurrentDate = DateTime.now().toString("yyyy-MM-dd'T'HH:mm:ss");

    docCreateDateValElement.setTextContent(sCurrentDate);

    Element docIdElement = XmlUtils.appendElement(rootCourtCaseElement, OjbcNamespaceContext.NS_NC_30,
            "DocumentIdentification");
    Element docIdValElement = XmlUtils.appendElement(docIdElement, OjbcNamespaceContext.NS_NC_30,
            "IdentificationID");
    docIdValElement.setTextContent(RandomStringUtils.randomNumeric(8));

    Element sysIdElement = XmlUtils.appendElement(rootCourtCaseElement, OjbcNamespaceContext.NS_INTEL_31,
            "SystemIdentification");
    Element sysIdValElement = XmlUtils.appendElement(sysIdElement, OjbcNamespaceContext.NS_NC_30,
            "IdentificationID");
    sysIdValElement.setTextContent(RandomStringUtils.randomNumeric(8));

    Element sysNameElement = XmlUtils.appendElement(sysIdElement, OjbcNamespaceContext.NS_NC_30, "SystemName");
    sysNameElement.setTextContent(randomString("CourtCaseSystem", "CourtCaseFinder"));

    Element caseElement = XmlUtils.appendElement(rootCourtCaseElement, OjbcNamespaceContext.NS_NC_30, "Case");
    XmlUtils.addAttribute(caseElement, OjbcNamespaceContext.NS_STRUCTURES_30, "id", "Case_01");

    Element activIdElement = XmlUtils.appendElement(caseElement, OjbcNamespaceContext.NS_NC_30,
            "ActivityIdentification");
    Element activIdValElement = XmlUtils.appendElement(activIdElement, OjbcNamespaceContext.NS_NC_30,
            "IdentificationID");
    String sampleCaseId = RandomStringUtils.randomNumeric(8);
    activIdValElement.setTextContent(sampleCaseId);

    Element activStatusElement = XmlUtils.appendElement(caseElement, OjbcNamespaceContext.NS_NC_30,
            "ActivityStatus");
    Element actStatDescTxtElement = XmlUtils.appendElement(activStatusElement, OjbcNamespaceContext.NS_NC_30,
            "StatusDescriptionText");
    actStatDescTxtElement.setTextContent(randomString("Early", "Outdated", "Complete"));

    Element caseDispElement = XmlUtils.appendElement(caseElement, OjbcNamespaceContext.NS_NC_30,
            "CaseDisposition");
    Element dispDateElement = XmlUtils.appendElement(caseDispElement, OjbcNamespaceContext.NS_NC_30,
            "DispositionDate");
    Element caseDispDatValElement = XmlUtils.appendElement(dispDateElement, OjbcNamespaceContext.NS_NC_30,
            "Date");
    caseDispDatValElement.setTextContent(randomDate("yyyy-MM-dd'T'HH:mm:ss"));

    Element caseGenCatTxtElement = XmlUtils.appendElement(caseElement, OjbcNamespaceContext.NS_NC_30,
            "CaseGeneralCategoryText");
    caseGenCatTxtElement.setTextContent(randomString("Ownership", "Debate", "Arrest"));

    Element caseTrackIdElement = XmlUtils.appendElement(caseElement, OjbcNamespaceContext.NS_NC_30,
            "CaseTrackingID");
    String sampleCaseTrackId = RandomStringUtils.randomNumeric(8);
    caseTrackIdElement.setTextContent(sampleCaseTrackId);

    Element caseDocketIdElement = XmlUtils.appendElement(caseElement, OjbcNamespaceContext.NS_NC_30,
            "CaseDocketID");

    String sampleDocket = randomString("SC vs NC", "NY vs LA", "North vs South", "City vs State");
    caseDocketIdElement.setTextContent(sampleDocket);

    Element caseFilingElement = XmlUtils.appendElement(caseElement, OjbcNamespaceContext.NS_NC_30,
            "CaseFiling");
    Element caseFileDocCreateDate = XmlUtils.appendElement(caseFilingElement, OjbcNamespaceContext.NS_NC_30,
            "DocumentCreationDate");
    Element caseFileDocCreateDateValElement = XmlUtils.appendElement(caseFileDocCreateDate,
            OjbcNamespaceContext.NS_NC_30, "DateTime");
    caseFileDocCreateDateValElement.setTextContent(randomDate("yyyy-MM-dd'T'HH:mm:ss"));

    Element caseAugmentElement = XmlUtils.appendElement(caseElement, OjbcNamespaceContext.NS_JXDM_51,
            "CaseAugmentation");
    Element caseAmendChargeElement = XmlUtils.appendElement(caseAugmentElement, OjbcNamespaceContext.NS_JXDM_51,
            "CaseAmendedCharge");

    Element chargeCountElement = XmlUtils.appendElement(caseAmendChargeElement, OjbcNamespaceContext.NS_JXDM_51,
            "ChargeCountQuantity");
    String sampleChargeCount = RandomStringUtils.randomNumeric(2);
    chargeCountElement.setTextContent(sampleChargeCount);

    Element chargeDescTxtElement = XmlUtils.appendElement(caseAmendChargeElement,
            OjbcNamespaceContext.NS_JXDM_51, "ChargeDescriptionText");
    String sampleChargeDesc = randomString("Blocking Traffic", "Speeding", "Turn Signal Broken",
            "Causing Comotion");
    chargeDescTxtElement.setTextContent(sampleChargeDesc);

    Element chargeFilingDateElement = XmlUtils.appendElement(caseAmendChargeElement,
            OjbcNamespaceContext.NS_JXDM_51, "ChargeFilingDate");
    Element chargeFilingDateValElement = XmlUtils.appendElement(chargeFilingDateElement,
            OjbcNamespaceContext.NS_NC_30, "Date");
    chargeFilingDateValElement.setTextContent(randomDate("yyyy-MM-dd'T'HH:mm:ss"));

    Element chargeStatuteElement = XmlUtils.appendElement(caseAmendChargeElement,
            OjbcNamespaceContext.NS_JXDM_51, "ChargeStatute");

    Element chargeStatuteCodeIdElement = XmlUtils.appendElement(chargeStatuteElement,
            OjbcNamespaceContext.NS_JXDM_51, "StatuteCodeIdentification");

    Element statCodeIdValElement = XmlUtils.appendElement(chargeStatuteCodeIdElement,
            OjbcNamespaceContext.NS_NC_30, "IdentificationID");
    String sampleChargeStatuteId = RandomStringUtils.randomNumeric(6);
    statCodeIdValElement.setTextContent(sampleChargeStatuteId);

    Element chargeStatIdCatDescTxtElement = XmlUtils.appendElement(chargeStatuteCodeIdElement,
            OjbcNamespaceContext.NS_NC_30, "IdentificationCategoryDescriptionText");

    String sampleCatDescTxt = randomString("Driver License", "Concealed Weapon Permit", "Government ID",
            "Motorcycle License");
    chargeStatIdCatDescTxtElement.setTextContent(sampleCatDescTxt);

    int caseChargeCount = ThreadLocalRandom.current().nextInt(1, 3 + 1);

    Logger.getLogger(this.getClass()).info("\n\n CaseCharge Count: " + caseChargeCount + "\n\n");

    for (int i = 0; i < caseChargeCount; i++) {

        appendCaseChargeSampleElement(caseAugmentElement);
    }//w ww .j  av  a2  s  .c o m

    Element caseCourtElement = XmlUtils.appendElement(caseAugmentElement, OjbcNamespaceContext.NS_JXDM_51,
            "CaseCourt");

    Element caseCourtOrgAugmentElement = XmlUtils.appendElement(caseCourtElement,
            OjbcNamespaceContext.NS_JXDM_51, "OrganizationAugmentation");

    Element caseCourtOrgJurisdictElement = XmlUtils.appendElement(caseCourtOrgAugmentElement,
            OjbcNamespaceContext.NS_JXDM_51, "OrganizationJurisdiction");

    Element caseCourtOrgAutJurisdicTxtElement = XmlUtils.appendElement(caseCourtOrgJurisdictElement,
            OjbcNamespaceContext.NS_NC_30, "JurisdictionText");
    caseCourtOrgAutJurisdicTxtElement
            .setTextContent(randomString("Highway Patrol", "Sheriff", "City Police", "Mall Cop"));

    Element caseCourtNameElement = XmlUtils.appendElement(caseCourtElement, OjbcNamespaceContext.NS_JXDM_51,
            "CourtName");
    caseCourtNameElement.setTextContent(randomString("Thornton Municipal Court", "Adams County Court",
            "Adams District Court", "Aura Municipal Court"));

    Element caseCourtDivTxtElement = XmlUtils.appendElement(caseCourtElement, OjbcNamespaceContext.NS_JXDM_51,
            "CourtDivisionText");
    caseCourtDivTxtElement.setTextContent(randomString("District Court DIV A", "County Court DIV 1",
            "County Court DIV 7", "County Court DIV 2"));

    Element caseCourtEventElement = XmlUtils.appendElement(caseAugmentElement, OjbcNamespaceContext.NS_JXDM_51,
            "CaseCourtEvent");

    Element caseCourtEventActivIdElement = XmlUtils.appendElement(caseCourtEventElement,
            OjbcNamespaceContext.NS_NC_30, "ActivityIdentification");

    Element caseCourtActivIdValElement = XmlUtils.appendElement(caseCourtEventActivIdElement,
            OjbcNamespaceContext.NS_NC_30, "IdentificationID");
    caseCourtActivIdValElement.setTextContent(RandomStringUtils.randomNumeric(8));

    Element caseCourtActivDateElement = XmlUtils.appendElement(caseCourtEventElement,
            OjbcNamespaceContext.NS_NC_30, "ActivityDate");

    Element caseCourtActivityDateValElement = XmlUtils.appendElement(caseCourtActivDateElement,
            OjbcNamespaceContext.NS_NC_30, "Date");
    caseCourtActivityDateValElement.setTextContent(randomDate("yyyy-MM-dd'T'HH:mm:ss"));

    Element caseCourtActivDescTxxtElement = XmlUtils.appendElement(caseCourtEventElement,
            OjbcNamespaceContext.NS_NC_30, "ActivityDescriptionText");
    caseCourtActivDescTxxtElement.setTextContent(randomString("Speeding", "Swerving", "Stealing"));

    Element activityNameElement = XmlUtils.appendElement(caseCourtEventElement, OjbcNamespaceContext.NS_NC_30,
            "ActivityName");
    activityNameElement.setTextContent(randomString("Burglary", "Speaking Falsehood", "Telling Bad Jokes"));

    Element courtEventJudgeElement = XmlUtils.appendElement(caseCourtEventElement,
            OjbcNamespaceContext.NS_JXDM_51, "CourtEventJudge");

    Element roleOfPersonElement = XmlUtils.appendElement(courtEventJudgeElement, OjbcNamespaceContext.NS_NC_30,
            "RoleOfPerson");

    Element judgeNameElement = XmlUtils.appendElement(roleOfPersonElement, OjbcNamespaceContext.NS_NC_30,
            "PersonName");

    Element judgeFullNameElement = XmlUtils.appendElement(judgeNameElement, OjbcNamespaceContext.NS_NC_30,
            "PersonFullName");

    judgeFullNameElement.setTextContent(getRandomName());

    Element firstCourtAprncElement = XmlUtils.appendElement(caseCourtEventElement,
            OjbcNamespaceContext.NS_COURT_CASE_QUERY_RESULTS_EXT, "FirstCourtAppearance");

    Element courtAprncDatElement = XmlUtils.appendElement(firstCourtAprncElement,
            OjbcNamespaceContext.NS_JXDM_51, "CourtAppearanceDate");

    Element courtAprncDatValElement = XmlUtils.appendElement(courtAprncDatElement,
            OjbcNamespaceContext.NS_NC_30, "Date");
    courtAprncDatValElement.setTextContent(randomDate("yyyy-MM-dd'T'HH:mm:ss"));

    Element courtEventCommentsTxtElement = XmlUtils.appendElement(caseCourtEventElement,
            OjbcNamespaceContext.NS_COURT_CASE_QUERY_RESULTS_EXT, "CourtEventCommentsText");
    courtEventCommentsTxtElement.setTextContent(
            randomString("A lot of commotion", "Many reporters present", "Lawyers making up stories"));

    Element defendantSelfRepIndicElement = XmlUtils.appendElement(caseAugmentElement,
            OjbcNamespaceContext.NS_JXDM_51, "CaseDefendantSelfRepresentationIndicator");
    defendantSelfRepIndicElement.setTextContent(getRandomBooleanString());

    Element caseDefendantPartyElement = XmlUtils.appendElement(caseAugmentElement,
            OjbcNamespaceContext.NS_JXDM_51, "CaseDefendantParty");

    Element defendantEntOrgElement = XmlUtils.appendElement(caseDefendantPartyElement,
            OjbcNamespaceContext.NS_NC_30, "EntityOrganization");

    Element entOrgNameElement = XmlUtils.appendElement(defendantEntOrgElement, OjbcNamespaceContext.NS_NC_30,
            "OrganizationName");
    entOrgNameElement
            .setTextContent(randomString("123 Roofing", "DisneyLand", "Moe's Junk Yard", "Lorax Cleaning"));

    Element entPersonElement = XmlUtils.appendElement(caseDefendantPartyElement, OjbcNamespaceContext.NS_NC_30,
            "EntityPerson");

    XmlUtils.addAttribute(entPersonElement, OjbcNamespaceContext.NS_STRUCTURES_30, "ref", "Person_01");

    Element caseDefenseAtterneyElement = XmlUtils.appendElement(caseAugmentElement,
            OjbcNamespaceContext.NS_JXDM_51, "CaseDefenseAttorney");

    Element defenseAttortyPersonRoleElement = XmlUtils.appendElement(caseDefenseAtterneyElement,
            OjbcNamespaceContext.NS_NC_30, "RoleOfPerson");

    Element defenseAtrnyPersonNameElement = XmlUtils.appendElement(defenseAttortyPersonRoleElement,
            OjbcNamespaceContext.NS_NC_30, "PersonName");
    ;

    Element defenseAtrnyFullNameElement = XmlUtils.appendElement(defenseAtrnyPersonNameElement,
            OjbcNamespaceContext.NS_NC_30, "PersonFullName");
    defenseAtrnyFullNameElement.setTextContent(getRandomName());

    Element caseDomViolenceElement = XmlUtils.appendElement(caseAugmentElement, OjbcNamespaceContext.NS_JXDM_51,
            "CaseDomesticViolenceIndicator");
    caseDomViolenceElement.setTextContent(getRandomBooleanString());

    Element caseHearingElement = XmlUtils.appendElement(caseAugmentElement, OjbcNamespaceContext.NS_JXDM_51,
            "CaseHearing");

    Element caseHearingActivIdElement = XmlUtils.appendElement(caseHearingElement,
            OjbcNamespaceContext.NS_NC_30, "ActivityIdentification");

    Element caseHearActivIdValElement = XmlUtils.appendElement(caseHearingActivIdElement,
            OjbcNamespaceContext.NS_NC_30, "IdentificationID");

    caseHearActivIdValElement.setTextContent(RandomStringUtils.randomNumeric(8));

    Element activCatTxtElement = XmlUtils.appendElement(caseHearingElement, OjbcNamespaceContext.NS_NC_30,
            "ActivityCategoryText");

    activCatTxtElement.setTextContent(randomString("Prosecution", "Defense", "Evidence Presentation"));

    Element caseHearingActivDateRangeElement = XmlUtils.appendElement(caseHearingElement,
            OjbcNamespaceContext.NS_NC_30, "ActivityDateRange");

    Element caseHearingStartDateElement = XmlUtils.appendElement(caseHearingActivDateRangeElement,
            OjbcNamespaceContext.NS_NC_30, "StartDate");

    Element caseHearingStartDateValElement = XmlUtils.appendElement(caseHearingStartDateElement,
            OjbcNamespaceContext.NS_NC_30, "DateTime");
    caseHearingStartDateValElement.setTextContent(randomDate("yyyy-MM-dd'T'HH:mm:ss"));

    Element caseHearingEndDateElement = XmlUtils.appendElement(caseHearingActivDateRangeElement,
            OjbcNamespaceContext.NS_NC_30, "EndDate");

    Element caseHearingEndDateValElement = XmlUtils.appendElement(caseHearingEndDateElement,
            OjbcNamespaceContext.NS_NC_30, "DateTime");
    caseHearingEndDateValElement.setTextContent(randomDate("yyyy-MM-dd'T'HH:mm:ss"));

    Element activDescTxtElement = XmlUtils.appendElement(caseHearingElement, OjbcNamespaceContext.NS_NC_30,
            "ActivityDescriptionText");
    activDescTxtElement.setTextContent(randomString("Jury Deciding Verdict", "Jury meeting"));

    Element hearingActivNameElement = XmlUtils.appendElement(caseHearingElement, OjbcNamespaceContext.NS_NC_30,
            "ActivityName");
    hearingActivNameElement
            .setTextContent(randomString("Pre-Trial Hearing", "Plea Hearing", "Sentence Hearing"));

    Element activReasonElement = XmlUtils.appendElement(caseHearingElement, OjbcNamespaceContext.NS_NC_30,
            "ActivityReasonText");
    activReasonElement.setTextContent(
            randomString("evidence review", "hear plea agreement", "review presentence investigation report"));

    Element activDispElement = XmlUtils.appendElement(caseHearingElement, OjbcNamespaceContext.NS_NC_30,
            "ActivityDisposition");

    Element activDispDescTxtElement = XmlUtils.appendElement(activDispElement, OjbcNamespaceContext.NS_NC_30,
            "DispositionDescriptionText");
    activDispDescTxtElement.setTextContent(randomString("Guilty", "Not Guilty", "Hung"));

    Element caseHearingCourtEventJudgeElement = XmlUtils.appendElement(caseHearingElement,
            OjbcNamespaceContext.NS_JXDM_51, "CourtEventJudge");

    Element caseHearingJudgeRoleElement = XmlUtils.appendElement(caseHearingCourtEventJudgeElement,
            OjbcNamespaceContext.NS_NC_30, "RoleOfPerson");

    Element caseHearingJudgeNameElement = XmlUtils.appendElement(caseHearingJudgeRoleElement,
            OjbcNamespaceContext.NS_NC_30, "PersonName");

    Element caseJudgeFullNameElement = XmlUtils.appendElement(caseHearingJudgeNameElement,
            OjbcNamespaceContext.NS_NC_30, "PersonFullName");

    caseJudgeFullNameElement.setTextContent(getRandomName());

    Element caseHearingCommentsTxtElement = XmlUtils.appendElement(caseHearingElement,
            OjbcNamespaceContext.NS_COURT_CASE_QUERY_RESULTS_EXT, "CourtEventCommentsText");

    caseHearingCommentsTxtElement.setTextContent(randomString("Trial really long", "Hard to find entrance"));

    Element caseJudgeElement = XmlUtils.appendElement(caseAugmentElement, OjbcNamespaceContext.NS_JXDM_51,
            "CaseJudge");

    Element caseJudgeRolePersonElement = XmlUtils.appendElement(caseJudgeElement, OjbcNamespaceContext.NS_NC_30,
            "RoleOfPerson");

    Element caseJudgeNameElement = XmlUtils.appendElement(caseJudgeRolePersonElement,
            OjbcNamespaceContext.NS_NC_30, "PersonName");

    Element caseJudgePersonNameElement = XmlUtils.appendElement(caseJudgeNameElement,
            OjbcNamespaceContext.NS_NC_30, "PersonFullName");
    caseJudgePersonNameElement.setTextContent(getRandomName());

    Element judicBarMemberElement = XmlUtils.appendElement(caseJudgeElement, OjbcNamespaceContext.NS_JXDM_51,
            "JudicialOfficialBarMembership");

    Element judicBarIdElement = XmlUtils.appendElement(judicBarMemberElement, OjbcNamespaceContext.NS_JXDM_51,
            "JudicialOfficialBarIdentification");

    Element judicBarIdValElement = XmlUtils.appendElement(judicBarIdElement, OjbcNamespaceContext.NS_NC_30,
            "IdentificationID");

    judicBarIdValElement.setTextContent(RandomStringUtils.randomNumeric(8));

    Element caseLieneageElement = XmlUtils.appendElement(caseAugmentElement, OjbcNamespaceContext.NS_JXDM_51,
            "CaseLineageCase");

    Element caseTrackingIdElement = XmlUtils.appendElement(caseLieneageElement, OjbcNamespaceContext.NS_NC_30,
            "CaseTrackingID");
    caseTrackingIdElement.setTextContent(RandomStringUtils.randomNumeric(8));

    Element caseProsecAtrnyElement = XmlUtils.appendElement(caseAugmentElement, OjbcNamespaceContext.NS_JXDM_51,
            "CaseProsecutionAttorney");

    Element prosecAtrnyRoleElement = XmlUtils.appendElement(caseProsecAtrnyElement,
            OjbcNamespaceContext.NS_NC_30, "RoleOfPerson");

    Element prosecPersonElement = XmlUtils.appendElement(prosecAtrnyRoleElement, OjbcNamespaceContext.NS_NC_30,
            "PersonName");

    Element prosecAtrnyNameElement = XmlUtils.appendElement(prosecPersonElement, OjbcNamespaceContext.NS_NC_30,
            "PersonFullName");
    prosecAtrnyNameElement.setTextContent(getRandomName());

    Element prosecutorBarElement = XmlUtils.appendElement(caseProsecAtrnyElement,
            OjbcNamespaceContext.NS_JXDM_51, "JudicialOfficialBarMembership");

    Element prosecutorOfficBarIdElement = XmlUtils.appendElement(prosecutorBarElement,
            OjbcNamespaceContext.NS_JXDM_51, "JudicialOfficialBarIdentification");

    Element prosecutorOfficBarIdValElement = XmlUtils.appendElement(prosecutorOfficBarIdElement,
            OjbcNamespaceContext.NS_NC_30, "IdentificationID");
    prosecutorOfficBarIdValElement.setTextContent(RandomStringUtils.randomNumeric(8));

    Element caseAugmentExtElement = XmlUtils.appendElement(caseElement,
            OjbcNamespaceContext.NS_COURT_CASE_QUERY_RESULTS_EXT, "CaseAugmentation");

    Element caseSealedIndicatorElement = XmlUtils.appendElement(caseAugmentExtElement,
            OjbcNamespaceContext.NS_COURT_CASE_QUERY_RESULTS_EXT, "CaseSealedIndicator");
    caseSealedIndicatorElement.setTextContent(getRandomBooleanString());

    Element remandDateElement = XmlUtils.appendElement(caseAugmentExtElement,
            OjbcNamespaceContext.NS_COURT_CASE_QUERY_RESULTS_EXT, "RemandDate");

    Element remandDateValElement = XmlUtils.appendElement(remandDateElement, OjbcNamespaceContext.NS_NC_30,
            "Date");
    remandDateValElement.setTextContent(randomDate("yyyy-MM-dd'T'HH:mm:ss"));

    Element apelateCaseElement = XmlUtils.appendElement(rootCourtCaseElement, OjbcNamespaceContext.NS_JXDM_51,
            "AppellateCase");
    XmlUtils.addAttribute(apelateCaseElement, OjbcNamespaceContext.NS_STRUCTURES_30, "id", "Appel_Case_01");

    Element apelateCaseTrackIdElement = XmlUtils.appendElement(apelateCaseElement,
            OjbcNamespaceContext.NS_NC_30, "CaseTrackingID");
    apelateCaseTrackIdElement.setTextContent(RandomStringUtils.randomNumeric(8));

    Element apelateCaseFilingElement = XmlUtils.appendElement(apelateCaseElement, OjbcNamespaceContext.NS_NC_30,
            "CaseFiling");

    Element apelateCaseFileDocCreateDateElement = XmlUtils.appendElement(apelateCaseFilingElement,
            OjbcNamespaceContext.NS_NC_30, "DocumentCreationDate");

    Element apelateCaseFileDocDateVal = XmlUtils.appendElement(apelateCaseFileDocCreateDateElement,
            OjbcNamespaceContext.NS_NC_30, "Date");
    apelateCaseFileDocDateVal.setTextContent(randomDate("yyyy-MM-dd'T'HH:mm:ss"));

    Element identityElement = XmlUtils.appendElement(rootCourtCaseElement, OjbcNamespaceContext.NS_NC_30,
            "Identity");
    XmlUtils.addAttribute(identityElement, OjbcNamespaceContext.NS_STRUCTURES_30, "id", "Identity_01");

    Element idPersonRepElement = XmlUtils.appendElement(identityElement, OjbcNamespaceContext.NS_NC_30,
            "IdentityPersonRepresentation");

    Element idPersonDobElement = XmlUtils.appendElement(idPersonRepElement, OjbcNamespaceContext.NS_NC_30,
            "PersonBirthDate");

    Element idPersonDobValElement = XmlUtils.appendElement(idPersonDobElement, OjbcNamespaceContext.NS_NC_30,
            "Date");
    idPersonDobValElement.setTextContent(randomDate("yyyy-MM-dd'T'HH:mm:ss"));

    PersonElementWrapper samplePerson = getRandomIdentity(null);

    Element idPersonNameElement = XmlUtils.appendElement(idPersonRepElement, OjbcNamespaceContext.NS_NC_30,
            "PersonName");

    Element idPersonGivenName = XmlUtils.appendElement(idPersonNameElement, OjbcNamespaceContext.NS_NC_30,
            "PersonGivenName");
    idPersonGivenName.setTextContent(samplePerson.firstName);

    Element idPersonMiddleName = XmlUtils.appendElement(idPersonNameElement, OjbcNamespaceContext.NS_NC_30,
            "PersonMiddleName");
    idPersonMiddleName.setTextContent(samplePerson.middleName);

    Element idPersonSurNameElement = XmlUtils.appendElement(idPersonNameElement, OjbcNamespaceContext.NS_NC_30,
            "PersonSurName");
    idPersonSurNameElement.setTextContent(samplePerson.lastName);

    Element idPersonFullNameElement = XmlUtils.appendElement(idPersonNameElement, OjbcNamespaceContext.NS_NC_30,
            "PersonFullName");
    idPersonFullNameElement.setTextContent(
            samplePerson.firstName + " " + samplePerson.middleName + " " + samplePerson.lastName);

    Element idPersonSsnElement = XmlUtils.appendElement(idPersonRepElement, OjbcNamespaceContext.NS_NC_30,
            "PersonSSNIdentification");

    Element idPersonSsnIdElement = XmlUtils.appendElement(idPersonSsnElement, OjbcNamespaceContext.NS_NC_30,
            "IdentificationID");
    idPersonSsnIdElement.setTextContent(RandomStringUtils.randomNumeric(8));

    Element contactInfoElement = XmlUtils.appendElement(rootCourtCaseElement, OjbcNamespaceContext.NS_NC_30,
            "ContactInformation");
    XmlUtils.addAttribute(contactInfoElement, OjbcNamespaceContext.NS_STRUCTURES_30, "id", "CI_01");

    Element phoneElement = XmlUtils.appendElement(contactInfoElement, OjbcNamespaceContext.NS_NC_30,
            "ContactTelephoneNumber");

    Element fullPhoneElement = XmlUtils.appendElement(phoneElement, OjbcNamespaceContext.NS_NC_30,
            "FullTelephoneNumber");

    Element phoneValElement = XmlUtils.appendElement(fullPhoneElement, OjbcNamespaceContext.NS_NC_30,
            "TelephoneNumberFullID");

    String samplePhone = (String) getRandomIdentity(null).telephoneNumber;
    phoneValElement.setTextContent(samplePhone);

    Element elecContactIdElement = XmlUtils.appendElement(contactInfoElement,
            OjbcNamespaceContext.NS_COURT_CASE_QUERY_RESULTS_EXT, "ElectronicContactIdentification");

    Element electContactIdValElement = XmlUtils.appendElement(elecContactIdElement,
            OjbcNamespaceContext.NS_NC_30, "IdentificationID");
    electContactIdValElement.setTextContent(RandomStringUtils.randomNumeric(8));

    Element electContactIdCatDescTxtElement = XmlUtils.appendElement(elecContactIdElement,
            OjbcNamespaceContext.NS_NC_30, "IdentificationCategoryDescriptionText");
    electContactIdCatDescTxtElement.setTextContent(randomString("Email", "Facebook", "SkypeID"));

    Element citationElement = XmlUtils.appendElement(rootCourtCaseElement, OjbcNamespaceContext.NS_JXDM_51,
            "Citation");
    XmlUtils.addAttribute(citationElement, OjbcNamespaceContext.NS_STRUCTURES_30, "id", "Citation_01");

    Element citationActivIdElement = XmlUtils.appendElement(citationElement, OjbcNamespaceContext.NS_NC_30,
            "ActivityIdentification");

    Element citationAcivIdVAlElement = XmlUtils.appendElement(citationActivIdElement,
            OjbcNamespaceContext.NS_NC_30, "IdentificationID");
    citationAcivIdVAlElement.setTextContent(RandomStringUtils.randomNumeric(8));

    Element citationViolationElement = XmlUtils.appendElement(citationElement, OjbcNamespaceContext.NS_JXDM_51,
            "CitationViolation");

    Element citationActivDateElement = XmlUtils.appendElement(citationViolationElement,
            OjbcNamespaceContext.NS_NC_30, "ActivityDate");

    Element citationActivDateValElement = XmlUtils.appendElement(citationActivDateElement,
            OjbcNamespaceContext.NS_NC_30, "Date");
    citationActivDateValElement.setTextContent(randomDate("yyyy-MM-dd'T'HH:mm:ss"));

    Element incidentLocationElement = XmlUtils.appendElement(citationViolationElement,
            OjbcNamespaceContext.NS_NC_30, "IncidentLocation");

    Element incidentAddressElement = XmlUtils.appendElement(incidentLocationElement,
            OjbcNamespaceContext.NS_NC_30, "Address");

    Element incidentAddressUnitElement = XmlUtils.appendElement(incidentAddressElement,
            OjbcNamespaceContext.NS_NC_30, "AddressSecondaryUnitText");
    incidentAddressUnitElement.setTextContent(randomString("APT 123", "Suite 456", "St 789", "P.O. Box 4528"));

    Element addressPointElement = XmlUtils.appendElement(incidentAddressElement, OjbcNamespaceContext.NS_NC_30,
            "AddressDeliveryPointID");
    addressPointElement.setTextContent(randomString("doorstep", "mailbox", "PO box"));

    Element incidentLocStreetElement = XmlUtils.appendElement(incidentAddressElement,
            OjbcNamespaceContext.NS_NC_30, "LocationStreet");

    Element locStreetNameElement = XmlUtils.appendElement(incidentLocStreetElement,
            OjbcNamespaceContext.NS_NC_30, "StreetName");
    locStreetNameElement.setTextContent(samplePerson.addressStreetName);

    Element locStreetCatTxtElement = XmlUtils.appendElement(incidentLocStreetElement,
            OjbcNamespaceContext.NS_NC_30, "StreetCategoryText");
    locStreetCatTxtElement.setTextContent(randomString("Small Road", "Cul de Sac", "Highway", "Interstate"));

    Element locCountyNameElement = XmlUtils.appendElement(incidentAddressElement, OjbcNamespaceContext.NS_NC_30,
            "LocationCountyName");
    locCountyNameElement.setTextContent(randomString("Rowan", "Pickens", "Union", "Dorchester"));

    Element locDescTxtElement = XmlUtils.appendElement(incidentLocationElement, OjbcNamespaceContext.NS_NC_30,
            "LocationDescriptionText");
    locDescTxtElement.setTextContent(randomString("NY", "LA", "UT", "FL"));

    Element locNameElement = XmlUtils.appendElement(incidentLocationElement, OjbcNamespaceContext.NS_NC_30,
            "LocationName");
    locNameElement.setTextContent(randomString("40N 70W", "City", "County"));

    Element violationAugmentElement = XmlUtils.appendElement(citationViolationElement,
            OjbcNamespaceContext.NS_COURT_CASE_QUERY_RESULTS_EXT, "ViolationAugmentation");

    Element drivingPointNumTxtElement = XmlUtils.appendElement(violationAugmentElement,
            OjbcNamespaceContext.NS_COURT_CASE_QUERY_RESULTS_EXT, "DrivingPointNumberText");
    drivingPointNumTxtElement.setTextContent(RandomStringUtils.randomNumeric(2));

    Element drivingPointReducedTxtElement = XmlUtils.appendElement(violationAugmentElement,
            OjbcNamespaceContext.NS_COURT_CASE_QUERY_RESULTS_EXT, "DrivingPointNumberReducedText");
    drivingPointReducedTxtElement.setTextContent(RandomStringUtils.randomNumeric(2));

    Element bacTestRefusedElement = XmlUtils.appendElement(violationAugmentElement,
            OjbcNamespaceContext.NS_COURT_CASE_QUERY_RESULTS_EXT,
            "PersonBloodAlcoholContentTestRefusedIndicator");
    bacTestRefusedElement.setTextContent(getRandomBooleanString());

    Element citationAugElement = XmlUtils.appendElement(citationElement,
            OjbcNamespaceContext.NS_COURT_CASE_QUERY_RESULTS_EXT, "CitationAugmentation");

    Element courtAprncDateElement = XmlUtils.appendElement(citationAugElement, OjbcNamespaceContext.NS_JXDM_51,
            "CourtAppearanceDate");

    Element courtApncDateTimeElement = XmlUtils.appendElement(courtAprncDateElement,
            OjbcNamespaceContext.NS_NC_30, "DateTime");
    courtApncDateTimeElement.setTextContent(randomDate("yyyy-MM-dd'T'HH:mm:ss"));

    Element crtApncRqdElement = XmlUtils.appendElement(citationAugElement,
            OjbcNamespaceContext.NS_COURT_CASE_QUERY_RESULTS_EXT, "CourtAppearanceRequiredIndicator");
    crtApncRqdElement.setTextContent(getRandomBooleanString());

    Element licSurndrdElement = XmlUtils.appendElement(citationAugElement,
            OjbcNamespaceContext.NS_COURT_CASE_QUERY_RESULTS_EXT, "LicenseSurrenderedIndicator");
    licSurndrdElement.setTextContent(getRandomBooleanString());

    Element drivingIncElement = XmlUtils.appendElement(rootCourtCaseElement, OjbcNamespaceContext.NS_JXDM_51,
            "DrivingIncident");
    XmlUtils.addAttribute(drivingIncElement, OjbcNamespaceContext.NS_STRUCTURES_30, "id", "Incident_01");

    Element incidentDescTxtElement = XmlUtils.appendElement(drivingIncElement, OjbcNamespaceContext.NS_NC_30,
            "ActivityDescriptionText");
    incidentDescTxtElement.setTextContent(
            randomString("Speeding", "Driving too slow", "Spinning Out", "Tailgating", "Blowing horn"));

    Element driverSpeedElement = XmlUtils.appendElement(drivingIncElement, OjbcNamespaceContext.NS_JXDM_51,
            "DrivingIncidentRecordedSpeedRateMeasure");

    Element speedMeasElement = XmlUtils.appendElement(driverSpeedElement, OjbcNamespaceContext.NS_NC_30,
            "MeasureValueText");
    speedMeasElement.setTextContent(RandomStringUtils.randomNumeric(3));

    Element speedUnitElement = XmlUtils.appendElement(driverSpeedElement, OjbcNamespaceContext.NS_NC_30,
            "MeasureUnitText");
    speedUnitElement.setTextContent(randomString("kt", "mph", "kph", "mpm"));

    Element speedLimitElement = XmlUtils.appendElement(drivingIncElement, OjbcNamespaceContext.NS_JXDM_51,
            "DrivingIncidentLegalSpeedRateMeasure");

    Element speedLimitNumElement = XmlUtils.appendElement(speedLimitElement, OjbcNamespaceContext.NS_NC_30,
            "MeasureValueText");
    speedLimitNumElement.setTextContent(RandomStringUtils.randomNumeric(2));

    Element speedUnitsElement = XmlUtils.appendElement(speedLimitElement, OjbcNamespaceContext.NS_NC_30,
            "MeasureUnitText");
    speedUnitsElement.setTextContent(randomString("kt", "mph", "kph", "mpm"));

    Element arrestElement = XmlUtils.appendElement(drivingIncElement, OjbcNamespaceContext.NS_JXDM_51,
            "Arrest");
    XmlUtils.addAttribute(arrestElement, OjbcNamespaceContext.NS_STRUCTURES_30, "id", "Arrest_01");

    Element arrestActivDateElement = XmlUtils.appendElement(arrestElement, OjbcNamespaceContext.NS_NC_30,
            "ActivityDate");

    Element arrestActivDateValElement = XmlUtils.appendElement(arrestActivDateElement,
            OjbcNamespaceContext.NS_NC_30, "Date");
    arrestActivDateValElement.setTextContent(randomDate("yyyy-MM-dd'T'HH:mm:ss"));

    Element arrestAgencyRecIdElement = XmlUtils.appendElement(arrestElement, OjbcNamespaceContext.NS_JXDM_51,
            "ArrestAgencyRecordIdentification");

    Element arrestRecIdElement = XmlUtils.appendElement(arrestAgencyRecIdElement, OjbcNamespaceContext.NS_NC_30,
            "IdentificationID");
    arrestRecIdElement.setTextContent(RandomStringUtils.randomNumeric(8));

    Element arrestChargeElement = XmlUtils.appendElement(arrestElement, OjbcNamespaceContext.NS_JXDM_51,
            "ArrestCharge");

    Element arrestChargeStatuteElement = XmlUtils.appendElement(arrestChargeElement,
            OjbcNamespaceContext.NS_JXDM_51, "ChargeStatute");

    Element arrestChargeStatCodeIdElement = XmlUtils.appendElement(arrestChargeStatuteElement,
            OjbcNamespaceContext.NS_JXDM_51, "StatuteCodeIdentification");

    Element arrestChargeIdElement = XmlUtils.appendElement(arrestChargeStatCodeIdElement,
            OjbcNamespaceContext.NS_NC_30, "IdentificationID");
    arrestChargeIdElement.setTextContent(RandomStringUtils.randomNumeric(8));

    Element arrestLocElement = XmlUtils.appendElement(arrestElement, OjbcNamespaceContext.NS_JXDM_51,
            "ArrestLocation");

    Element arrestLocDescTxtElement = XmlUtils.appendElement(arrestLocElement, OjbcNamespaceContext.NS_NC_30,
            "LocationDescriptionText");
    arrestLocDescTxtElement.setTextContent(randomString("NY", "LA", "SF", "FL", "ATL"));

    Element arrestOfficialElement = XmlUtils.appendElement(arrestElement, OjbcNamespaceContext.NS_JXDM_51,
            "ArrestOfficial");
    XmlUtils.addAttribute(arrestOfficialElement, OjbcNamespaceContext.NS_STRUCTURES_30, "id", "Officer_01");

    Element officalRoleElement = XmlUtils.appendElement(arrestOfficialElement, OjbcNamespaceContext.NS_NC_30,
            "RoleOfPerson");

    Element arrestOfficNameElement = XmlUtils.appendElement(officalRoleElement, OjbcNamespaceContext.NS_NC_30,
            "PersonName");

    Element arrestFullNameElement = XmlUtils.appendElement(arrestOfficNameElement,
            OjbcNamespaceContext.NS_NC_30, "PersonFullName");
    arrestFullNameElement.setTextContent(getRandomName());

    Element leEnforcUnitElement = XmlUtils.appendElement(arrestOfficialElement, OjbcNamespaceContext.NS_JXDM_51,
            "EnforcementOfficialUnit");

    Element leEnforceUnitNameElement = XmlUtils.appendElement(leEnforcUnitElement,
            OjbcNamespaceContext.NS_JXDM_51, "EnforcementUnitName");
    leEnforceUnitNameElement.setTextContent(randomString("LAPD", "NYPD", "Walker Texas Ranger"));

    Element detentionElement = XmlUtils.appendElement(drivingIncElement, OjbcNamespaceContext.NS_JXDM_51,
            "Detention");
    XmlUtils.addAttribute(detentionElement, OjbcNamespaceContext.NS_STRUCTURES_30, "id", "Detention_01");

    Element detentionActivElement = XmlUtils.appendElement(detentionElement, OjbcNamespaceContext.NS_NC_30,
            "ActivityIdentification");

    Element detActivIdElement = XmlUtils.appendElement(detentionActivElement, OjbcNamespaceContext.NS_NC_30,
            "IdentificationID");

    detActivIdElement.setTextContent(RandomStringUtils.randomNumeric(8));

    Element detActivCatTxtElement = XmlUtils.appendElement(detentionElement, OjbcNamespaceContext.NS_NC_30,
            "ActivityCategoryText");
    detActivCatTxtElement.setTextContent(randomString("Jail", "Prison", "Community Service"));

    Element detActivDatRangeElement = XmlUtils.appendElement(detentionElement, OjbcNamespaceContext.NS_NC_30,
            "ActivityDateRange");

    Element detStartDateElement = XmlUtils.appendElement(detActivDatRangeElement, OjbcNamespaceContext.NS_NC_30,
            "StartDate");

    Element detStartDateValElement = XmlUtils.appendElement(detStartDateElement, OjbcNamespaceContext.NS_NC_30,
            "Date");
    detStartDateValElement.setTextContent(randomDate("yyyy-MM-dd'T'HH:mm:ss"));

    Element detEndDateElement = XmlUtils.appendElement(detActivDatRangeElement, OjbcNamespaceContext.NS_NC_30,
            "EndDate");

    Element endDateValElement = XmlUtils.appendElement(detEndDateElement, OjbcNamespaceContext.NS_NC_30,
            "Date");
    endDateValElement.setTextContent(randomDate("yyyy-MM-dd'T'HH:mm:ss"));

    Element superviseCustStatus = XmlUtils.appendElement(detentionElement, OjbcNamespaceContext.NS_NC_30,
            "SupervisionCustodyStatus");

    Element superviseStatDescTxtElement = XmlUtils.appendElement(superviseCustStatus,
            OjbcNamespaceContext.NS_NC_30, "StatusDescriptionText");
    superviseStatDescTxtElement
            .setTextContent(randomString("Parents Watching", "Big Brother Custody", "Homeless Shelter"));

    Element supervisFacElement = XmlUtils.appendElement(detentionElement, OjbcNamespaceContext.NS_NC_30,
            "SupervisionFacility");

    Element facIdElement = XmlUtils.appendElement(supervisFacElement, OjbcNamespaceContext.NS_NC_30,
            "FacilityIdentification");

    Element facIdValElement = XmlUtils.appendElement(facIdElement, OjbcNamespaceContext.NS_NC_30,
            "IdentificationID");
    facIdValElement.setTextContent(RandomStringUtils.randomNumeric(8));

    Element bailBondElement = XmlUtils.appendElement(drivingIncElement, OjbcNamespaceContext.NS_JXDM_51,
            "BailBond");
    XmlUtils.addAttribute(bailBondElement, OjbcNamespaceContext.NS_STRUCTURES_30, "id", "Bond_01");

    Element bailBondActivIdElement = XmlUtils.appendElement(bailBondElement, OjbcNamespaceContext.NS_NC_30,
            "ActivityIdentification");

    Element bailBondActivIdValElement = XmlUtils.appendElement(bailBondActivIdElement,
            OjbcNamespaceContext.NS_NC_30, "IdentificationID");
    bailBondActivIdValElement.setTextContent(RandomStringUtils.randomNumeric(8));

    Element bailBondActivCatTxtElement = XmlUtils.appendElement(bailBondElement, OjbcNamespaceContext.NS_NC_30,
            "ActivityCategoryText");
    bailBondActivCatTxtElement.setTextContent(randomString("Bond", "Bail", "Recognizance"));

    Element bailBondAmountElement = XmlUtils.appendElement(bailBondElement, OjbcNamespaceContext.NS_JXDM_51,
            "BailBondAmount");

    Element bailBondAmountValElement = XmlUtils.appendElement(bailBondAmountElement,
            OjbcNamespaceContext.NS_NC_30, "Amount");

    bailBondAmountValElement.setTextContent(RandomStringUtils.randomNumeric(4));

    Element bondIssuerElement = XmlUtils.appendElement(bailBondElement, OjbcNamespaceContext.NS_JXDM_51,
            "BailBondIssuerEntity");

    Element bondEntOrgElement = XmlUtils.appendElement(bondIssuerElement, OjbcNamespaceContext.NS_NC_30,
            "EntityOrganization");

    Element bondOrgNameElement = XmlUtils.appendElement(bondEntOrgElement, OjbcNamespaceContext.NS_NC_30,
            "OrganizationName");

    bondOrgNameElement
            .setTextContent(randomString("Bonds 4 Cheap", "25% Bonds", "24hr Bonding", "Bonds Advance"));

    Element vehicleElement = XmlUtils.appendElement(drivingIncElement, OjbcNamespaceContext.NS_NC_30,
            "Vehicle");
    XmlUtils.addAttribute(vehicleElement, OjbcNamespaceContext.NS_STRUCTURES_30, "id", "Vehicle_01");

    Element vehicCmvElement = XmlUtils.appendElement(vehicleElement, OjbcNamespaceContext.NS_NC_30,
            "VehicleCMVIndicator");
    vehicCmvElement.setTextContent(getRandomBooleanString());

    Element vehicleIdElement = XmlUtils.appendElement(vehicleElement, OjbcNamespaceContext.NS_NC_30,
            "VehicleIdentification");

    Element vinValueElement = XmlUtils.appendElement(vehicleIdElement, OjbcNamespaceContext.NS_NC_30,
            "IdentificationID");
    vinValueElement.setTextContent(RandomStringUtils.randomNumeric(8));

    Element vehicleMakeCode = XmlUtils.appendElement(vehicleElement, OjbcNamespaceContext.NS_JXDM_51,
            "VehicleMakeCode");
    vehicleMakeCode.setTextContent(RandomStringUtils.randomNumeric(3));

    Element vehicleModelElement = XmlUtils.appendElement(vehicleElement, OjbcNamespaceContext.NS_JXDM_51,
            "VehicleModelCode");
    vehicleModelElement.setTextContent(randomString("Chevy", "Ford", "GM", "Ferari", "Pontiac", "Kia", "VW"));

    Element personElement = XmlUtils.appendElement(drivingIncElement, OjbcNamespaceContext.NS_NC_30, "Person");
    XmlUtils.addAttribute(personElement, OjbcNamespaceContext.NS_STRUCTURES_30, "id", "Person_01");

    Element personDobElement = XmlUtils.appendElement(personElement, OjbcNamespaceContext.NS_NC_30,
            "PersonBirthDate");

    Element dobValElement = XmlUtils.appendElement(personDobElement, OjbcNamespaceContext.NS_NC_30, "Date");
    dobValElement.setTextContent(randomDate("yyyy-MM-dd'T'HH:mm:ss"));

    Element personDescElement = XmlUtils.appendElement(personElement, OjbcNamespaceContext.NS_NC_30,
            "PersonDescriptionText");
    personDescElement.setTextContent(randomString("Really Tall", "Short white female", "Tall black male",
            "Thin Asian female", "Very Large"));

    Element ethnicityElement = XmlUtils.appendElement(personElement, OjbcNamespaceContext.NS_NC_30,
            "PersonEthnicityText");
    ethnicityElement.setTextContent(randomString("W", "B", "A", "L"));

    Element eyeColorElement = XmlUtils.appendElement(personElement, OjbcNamespaceContext.NS_JXDM_51,
            "PersonEyeColorCode");
    eyeColorElement.setTextContent(randomString("BLU", "BWN", "GRN", "BLK"));

    Element hairElement = XmlUtils.appendElement(personElement, OjbcNamespaceContext.NS_JXDM_51,
            "PersonHairColorCode");
    hairElement.setTextContent(randomString("BLO", "BWN", "RED"));

    Element heightElement = XmlUtils.appendElement(personElement, OjbcNamespaceContext.NS_NC_30,
            "PersonHeightMeasure");

    Element heightValueElement = XmlUtils.appendElement(heightElement, OjbcNamespaceContext.NS_NC_30,
            "MeasureValueText");
    heightValueElement.setTextContent(RandomStringUtils.randomNumeric(2));

    Element heightUnitElement = XmlUtils.appendElement(heightElement, OjbcNamespaceContext.NS_NC_30,
            "MeasureUnitText");
    heightUnitElement.setTextContent(randomString("in", "cm", "mm", "me", "ft"));

    PersonElementWrapper samplePerson2 = getRandomIdentity(null);

    Element personNameElement = XmlUtils.appendElement(personElement, OjbcNamespaceContext.NS_NC_30,
            "PersonName");

    Element givenNameElement = XmlUtils.appendElement(personNameElement, OjbcNamespaceContext.NS_NC_30,
            "PersonGivenName");

    givenNameElement.setTextContent(samplePerson2.firstName);

    Element middleNameElement = XmlUtils.appendElement(personNameElement, OjbcNamespaceContext.NS_NC_30,
            "PersonMiddleName");

    middleNameElement.setTextContent(samplePerson2.middleName);

    Element surNameElement = XmlUtils.appendElement(personNameElement, OjbcNamespaceContext.NS_NC_30,
            "PersonSurName");

    surNameElement.setTextContent(samplePerson2.lastName);

    Element personFullNameElement = XmlUtils.appendElement(personNameElement, OjbcNamespaceContext.NS_NC_30,
            "PersonFullName");

    personFullNameElement.setTextContent(
            samplePerson2.firstName + " " + samplePerson2.middleName + " " + samplePerson2.lastName);

    Element personRaceElement = XmlUtils.appendElement(personElement, OjbcNamespaceContext.NS_NC_30,
            "PersonRaceText");

    personRaceElement.setTextContent(randomString("WHT", "BLK", "ASN", "LAT", "PAC"));

    Element personSexCodeElement = XmlUtils.appendElement(personElement, OjbcNamespaceContext.NS_NC_30,
            "PersonSexText");
    personSexCodeElement.setTextContent(samplePerson2.sex);

    Element ssnElement = XmlUtils.appendElement(personElement, OjbcNamespaceContext.NS_NC_30,
            "PersonSSNIdentification");

    Element ssnValElement = XmlUtils.appendElement(ssnElement, OjbcNamespaceContext.NS_NC_30,
            "IdentificationID");
    ssnValElement.setTextContent(RandomStringUtils.randomNumeric(9));

    Element weightElement = XmlUtils.appendElement(personElement, OjbcNamespaceContext.NS_NC_30,
            "PersonWeightMeasure");

    Element weightMeasureElement = XmlUtils.appendElement(weightElement, OjbcNamespaceContext.NS_NC_30,
            "MeasureValueText");
    weightMeasureElement.setTextContent(RandomStringUtils.randomNumeric(3));

    Element personAugmentElement = XmlUtils.appendElement(personElement, OjbcNamespaceContext.NS_JXDM_51,
            "PersonAugmentation");

    Element drivLicElement = XmlUtils.appendElement(personAugmentElement, OjbcNamespaceContext.NS_JXDM_51,
            "DriverLicense");

    Element drivLicIdElement = XmlUtils.appendElement(drivLicElement, OjbcNamespaceContext.NS_JXDM_51,
            "DriverLicenseIdentification");

    Element drivLicIdValElement = XmlUtils.appendElement(drivLicIdElement, OjbcNamespaceContext.NS_NC_30,
            "IdentificationID");
    drivLicIdValElement.setTextContent(RandomStringUtils.randomNumeric(8));

    Element drivLicIdSrcElement = XmlUtils.appendElement(drivLicIdElement, OjbcNamespaceContext.NS_NC_30,
            "IdentificationSourceText");
    drivLicIdSrcElement.setTextContent(randomString("SC", "NC", "GA", "FL", "ME", "MA", "VT", "TX"));

    Element drivLicExpDateElement = XmlUtils.appendElement(drivLicElement, OjbcNamespaceContext.NS_JXDM_51,
            "DriverLicenseExpirationDate");

    Element drivLicExpDateValElement = XmlUtils.appendElement(drivLicExpDateElement,
            OjbcNamespaceContext.NS_NC_30, "DateTime");
    drivLicExpDateValElement.setTextContent(randomDate("yyyy-MM-dd'T'HH:mm:ss"));

    Element drivLicIssDateElement = XmlUtils.appendElement(drivLicElement, OjbcNamespaceContext.NS_JXDM_51,
            "DriverLicenseIssueDate");

    Element drivLicIssDatValElement = XmlUtils.appendElement(drivLicIssDateElement,
            OjbcNamespaceContext.NS_NC_30, "DateTime");
    drivLicIssDatValElement.setTextContent(randomDate("yyyy-MM-dd'T'HH:mm:ss"));

    Element drivLicClassElement = XmlUtils.appendElement(drivLicElement, OjbcNamespaceContext.NS_JXDM_51,
            "DriverLicenseNonCommercialClassText");
    drivLicClassElement.setTextContent(randomString("C", "M", "L", "D", "S"));

    Element fbiElement = XmlUtils.appendElement(personAugmentElement, OjbcNamespaceContext.NS_JXDM_51,
            "PersonFBIIdentification");

    Element fbiIdValElement = XmlUtils.appendElement(fbiElement, OjbcNamespaceContext.NS_NC_30,
            "IdentificationID");
    fbiIdValElement.setTextContent(RandomStringUtils.randomNumeric(8));

    Element sidElement = XmlUtils.appendElement(personAugmentElement, OjbcNamespaceContext.NS_JXDM_51,
            "PersonStateFingerprintIdentification");

    Element sidValElement = XmlUtils.appendElement(sidElement, OjbcNamespaceContext.NS_NC_30,
            "IdentificationID");
    sidValElement.setTextContent(RandomStringUtils.randomNumeric(8));

    Element locElement = XmlUtils.appendElement(drivingIncElement, OjbcNamespaceContext.NS_NC_30, "Location");
    XmlUtils.addAttribute(locElement, OjbcNamespaceContext.NS_STRUCTURES_30, "id", "Location_01");

    Element locAddressElement = XmlUtils.appendElement(locElement, OjbcNamespaceContext.NS_NC_30, "Address");

    Element addressUnitElement = XmlUtils.appendElement(locAddressElement, OjbcNamespaceContext.NS_NC_30,
            "AddressSecondaryUnitText");
    addressUnitElement
            .setTextContent(randomString("APT 234", "STE 567", "PO Box 789", "2nd Floor", "Door on left"));

    Element locStreetElement = XmlUtils.appendElement(locAddressElement, OjbcNamespaceContext.NS_NC_30,
            "LocationStreet");

    Element locStreetFullElement = XmlUtils.appendElement(locStreetElement, OjbcNamespaceContext.NS_NC_30,
            "StreetFullText");

    locStreetFullElement.setTextContent(samplePerson2.addressStreetName);

    Element locCityElement = XmlUtils.appendElement(locAddressElement, OjbcNamespaceContext.NS_NC_30,
            "LocationCityName");
    locCityElement.setTextContent(samplePerson2.city);

    Element locStateElement = XmlUtils.appendElement(locAddressElement, OjbcNamespaceContext.NS_NC_30,
            "LocationStateName");
    locStateElement.setTextContent(samplePerson2.state);

    Element locZipElement = XmlUtils.appendElement(locAddressElement, OjbcNamespaceContext.NS_NC_30,
            "LocationPostalCode");
    locZipElement.setTextContent(samplePerson2.zipCode);

    Element locCatTxtElement = XmlUtils.appendElement(locElement, OjbcNamespaceContext.NS_NC_30,
            "LocationCategoryText");
    locCatTxtElement.setTextContent(randomString("around corner", "North", "East", "South", "West"));

    Element activCaseAssocElement = XmlUtils.appendElement(drivingIncElement, OjbcNamespaceContext.NS_JXDM_51,
            "ActivityCaseAssociation");

    Element citationActivElement = XmlUtils.appendElement(activCaseAssocElement, OjbcNamespaceContext.NS_NC_30,
            "Activity");
    XmlUtils.addAttribute(citationActivElement, OjbcNamespaceContext.NS_STRUCTURES_30, "ref", "Citation_01");

    Element arrestActivityElement = XmlUtils.appendElement(activCaseAssocElement, OjbcNamespaceContext.NS_NC_30,
            "Activity");
    XmlUtils.addAttribute(arrestActivityElement, OjbcNamespaceContext.NS_STRUCTURES_30, "ref", "Arrest_01");

    Element detentionActivityElement = XmlUtils.appendElement(activCaseAssocElement,
            OjbcNamespaceContext.NS_NC_30, "Activity");
    XmlUtils.addAttribute(detentionActivityElement, OjbcNamespaceContext.NS_STRUCTURES_30, "ref",
            "Detention_01");

    Element bondActivityElement = XmlUtils.appendElement(activCaseAssocElement, OjbcNamespaceContext.NS_NC_30,
            "Activity");
    XmlUtils.addAttribute(bondActivityElement, OjbcNamespaceContext.NS_STRUCTURES_30, "ref", "Bond_01");

    Element caseAssocElement = XmlUtils.appendElement(activCaseAssocElement, OjbcNamespaceContext.NS_NC_30,
            "Case");
    XmlUtils.addAttribute(caseAssocElement, OjbcNamespaceContext.NS_STRUCTURES_30, "ref", "Case_01");

    Element relatedCaseAssocElement = XmlUtils.appendElement(drivingIncElement, OjbcNamespaceContext.NS_NC_30,
            "RelatedCaseAssociation");

    Element relatedCaseActivityElement = XmlUtils.appendElement(relatedCaseAssocElement,
            OjbcNamespaceContext.NS_NC_30, "Activity");
    XmlUtils.addAttribute(relatedCaseActivityElement, OjbcNamespaceContext.NS_STRUCTURES_30, "ref", "Case_01");

    Element appelCaseActivElement = XmlUtils.appendElement(relatedCaseAssocElement,
            OjbcNamespaceContext.NS_NC_30, "Activity");
    XmlUtils.addAttribute(appelCaseActivElement, OjbcNamespaceContext.NS_STRUCTURES_30, "ref", "Appel_Case_01");

    Element activIncidentAssocElement = XmlUtils.appendElement(drivingIncElement,
            OjbcNamespaceContext.NS_JXDM_51, "ActivityIncidentAssociation");

    Element incidentCitationActivityElement = XmlUtils.appendElement(activIncidentAssocElement,
            OjbcNamespaceContext.NS_NC_30, "Activity");
    XmlUtils.addAttribute(incidentCitationActivityElement, OjbcNamespaceContext.NS_STRUCTURES_30, "ref",
            "Citation_01");

    Element activIncidentIncElement = XmlUtils.appendElement(activIncidentAssocElement,
            OjbcNamespaceContext.NS_NC_30, "Incident");
    XmlUtils.addAttribute(activIncidentIncElement, OjbcNamespaceContext.NS_STRUCTURES_30, "ref", "Incident_01");

    Element contactInfoAssocElement = XmlUtils.appendElement(drivingIncElement, OjbcNamespaceContext.NS_NC_30,
            "ContactInformationAssociation");

    Element contactEntElement = XmlUtils.appendElement(contactInfoAssocElement, OjbcNamespaceContext.NS_NC_30,
            "ContactEntity");
    XmlUtils.addAttribute(contactEntElement, OjbcNamespaceContext.NS_STRUCTURES_30, "ref", "Person_01");

    Element contactAssocInfoElement = XmlUtils.appendElement(contactInfoAssocElement,
            OjbcNamespaceContext.NS_NC_30, "ContactInformation");
    XmlUtils.addAttribute(contactAssocInfoElement, OjbcNamespaceContext.NS_STRUCTURES_30, "ref", "CI_01");

    Element personConveyAssocElement = XmlUtils.appendElement(drivingIncElement, OjbcNamespaceContext.NS_NC_30,
            "PersonConveyanceAssociation");

    Element conveyAssocPersonElement = XmlUtils.appendElement(personConveyAssocElement,
            OjbcNamespaceContext.NS_NC_30, "Person");
    XmlUtils.addAttribute(conveyAssocPersonElement, OjbcNamespaceContext.NS_STRUCTURES_30, "ref", "Person_01");

    Element conveyAssocVehicleElement = XmlUtils.appendElement(personConveyAssocElement,
            OjbcNamespaceContext.NS_NC_30, "Conveyance");
    XmlUtils.addAttribute(conveyAssocVehicleElement, OjbcNamespaceContext.NS_STRUCTURES_30, "ref",
            "Vehicle_01");

    Element personResAssocElement = XmlUtils.appendElement(drivingIncElement, OjbcNamespaceContext.NS_NC_30,
            "PersonResidenceAssociation");

    Element resAssocPersonElement = XmlUtils.appendElement(personResAssocElement, OjbcNamespaceContext.NS_NC_30,
            "Person");
    XmlUtils.addAttribute(resAssocPersonElement, OjbcNamespaceContext.NS_STRUCTURES_30, "ref", "Person_01");

    Element resLocElement = XmlUtils.appendElement(personResAssocElement, OjbcNamespaceContext.NS_NC_30,
            "Location");
    XmlUtils.addAttribute(resLocElement, OjbcNamespaceContext.NS_STRUCTURES_30, "ref", "Location_01");

    Element aliasIdentAssocElement = XmlUtils.appendElement(drivingIncElement, OjbcNamespaceContext.NS_NC_30,
            "PersonAliasIdentityAssociation");

    Element aliasPerson = XmlUtils.appendElement(aliasIdentAssocElement, OjbcNamespaceContext.NS_NC_30,
            "Person");
    XmlUtils.addAttribute(aliasPerson, OjbcNamespaceContext.NS_STRUCTURES_30, "ref", "Person_01");

    Element aliasIdentElement = XmlUtils.appendElement(aliasIdentAssocElement, OjbcNamespaceContext.NS_NC_30,
            "Identity");
    XmlUtils.addAttribute(aliasIdentElement, OjbcNamespaceContext.NS_STRUCTURES_30, "ref", "Identity_01");

    Element srcSysNamTxtElement = XmlUtils.appendElement(drivingIncElement,
            OjbcNamespaceContext.NS_COURT_CASE_QUERY_RESULTS_EXT, "SourceSystemNameText");

    //TODO correct sys name values
    srcSysNamTxtElement.setTextContent(randomString("Thornton Municipal FullCourt",
            "Adams County County Court FullCourt", "Pima County District Court Tyler Odysee"));

    Element queryResCatTxtElement = XmlUtils.appendElement(drivingIncElement,
            OjbcNamespaceContext.NS_COURT_CASE_QUERY_RESULTS_EXT, "QueryResultCategoryText");
    queryResCatTxtElement.setTextContent(randomString("Results", "Result List", "Results Returned"));

    Element infoOwnOrgElement = XmlUtils.appendElement(drivingIncElement,
            OjbcNamespaceContext.NS_COURT_CASE_QUERY_RESULTS_EXT, "InformationOwningOrganization");

    Element orgBranchNameElement = XmlUtils.appendElement(infoOwnOrgElement, OjbcNamespaceContext.NS_NC_30,
            "OrganizationBranchName");
    orgBranchNameElement.setTextContent(randomString("Large Search Company", "Acme", "Acme Search Finder",
            "Acme people lookup finder", "Cops", "Walker Texas Ranger"));

    Element orgNameElement = XmlUtils.appendElement(infoOwnOrgElement, OjbcNamespaceContext.NS_NC_30,
            "OrganizationName");
    orgNameElement.setTextContent(randomString("COPS", "Walker Texas Ranger", "Matlock"));

    Element metadataElement = XmlUtils.appendElement(drivingIncElement, OjbcNamespaceContext.NS_NC_30,
            "Metadata");

    Element lastUpdateDateElement = XmlUtils.appendElement(metadataElement, OjbcNamespaceContext.NS_NC_30,
            "LastUpdatedDate");

    Element lastUpdateDateValElement = XmlUtils.appendElement(lastUpdateDateElement,
            OjbcNamespaceContext.NS_NC_30, "Date");
    lastUpdateDateValElement.setTextContent(randomDate("yyyy-MM-dd'T'HH:mm:ss"));

    Element queryRestMetaElement = XmlUtils.appendElement(drivingIncElement, OjbcNamespaceContext.NS_QRM,
            "QueryResultsMetadata");

    Element infoAccessDenialElement = XmlUtils.appendElement(queryRestMetaElement, OjbcNamespaceContext.NS_IAD,
            "InformationAccessDenial");

    Element infoAccessDenialIndicElement = XmlUtils.appendElement(infoAccessDenialElement,
            OjbcNamespaceContext.NS_IAD, "InformationAccessDenialIndicator");
    infoAccessDenialIndicElement.setTextContent(getRandomBooleanString());

    Element infoAccessDenySysTxtElement = XmlUtils.appendElement(infoAccessDenialElement,
            OjbcNamespaceContext.NS_IAD, "InformationAccessDenyingSystemNameText");
    infoAccessDenySysTxtElement.setTextContent(
            randomString("BG Checker", "Background Checkers", "Rapback Deniers", "FBI", "Clearance Beakers"));

    Element infoAccDenySysNamElement = XmlUtils.appendElement(infoAccessDenialElement,
            OjbcNamespaceContext.NS_IAD, "InformationAccessDenialReasonText");
    infoAccDenySysNamElement.setTextContent(randomString("On deny list", "On no-fly list", "Gossips",
            "Sells info to others", "Can't keep a secret"));

    Element queryRequestErrorElement = XmlUtils.appendElement(queryRestMetaElement,
            OjbcNamespaceContext.NS_QRER, "QueryRequestError");

    Element errorTxtElement = XmlUtils.appendElement(queryRequestErrorElement, OjbcNamespaceContext.NS_QRER,
            "ErrorText");
    errorTxtElement.setTextContent(randomString("Can't do that query", "Can't find anyone", "Looked too long"));

    Element queryReqIdElement = XmlUtils.appendElement(queryRequestErrorElement, OjbcNamespaceContext.NS_QRER,
            "QueryRequestIdentification");

    Element queryReqIdValElement = XmlUtils.appendElement(queryReqIdElement, OjbcNamespaceContext.NS_NC_30,
            "IdentificationID");
    queryReqIdValElement.setTextContent(RandomStringUtils.randomNumeric(8));

    //TODO I think this is the description of the query request from the portal
    Element idCatDescElment = XmlUtils.appendElement(queryReqIdElement, OjbcNamespaceContext.NS_NC_30,
            "IdentificationCategoryDescriptionText");
    idCatDescElment
            .setTextContent(randomString("Driver License", "Gvmt Id", "Passport", "Concealed Weapons Permit"));

    Element idSrcTxtElement = XmlUtils.appendElement(queryReqIdElement, OjbcNamespaceContext.NS_NC_30,
            "IdentificationSourceText");
    idSrcTxtElement.setTextContent(samplePerson.state);

    OjbcNamespaceContext ojbcNamespaceContext = new OjbcNamespaceContext();

    ojbcNamespaceContext.populateRootNamespaceDeclarations(rootCourtCaseElement);

    return rCourtCaseDetailDoc;
}

From source file:org.apache.jmeter.util.JMeterUtils.java

/**
 * Provide random numbers// w  w  w.  j a  v a2  s  .c  o  m
 *
 * @param r -
 *            the upper bound (exclusive)
 * @return a random <code>int</code>
 */
public static int getRandomInt(int r) {
    return ThreadLocalRandom.current().nextInt(r);
}

From source file:com.pushtechnology.consulting.SessionCreator.java

/**
 * Create a finite number of sessions.//from   ww  w  .  ja va 2 s . c o  m
 */
private void doStart(int maxNumberSessions) {

    LOG.trace("SessionCreator#doStart for '{}' sessions ", maxNumberSessions);
    long delay = 0L;
    final CountDownLatch sessionsLatch = new CountDownLatch(maxNumberSessions);
    final CountDownLatch subscriptionLatch = new CountDownLatch(maxNumberSessions * topicSelectors.size());

    for (int i = 0; i < maxNumberSessions; i++) {
        addSessions.add(Benchmarker.globalThreadPool.schedule(new Runnable() {
            @Override
            public void run() {
                LOG.trace("Adding session");
                try {
                    /* ASYNC session creation */
                    sessionFactory.open(getConnectionString(),
                            new OpenCallback(sessionsLatch, subscriptionLatch));
                    LOG.trace("Done submitting session open");
                } catch (Exception e) {
                    /* ASYNC session creation */
                    connectionFailures.incrementAndGet();
                    sessionsLatch.countDown();
                    LOG.error("Exception caught trying to connect", e);
                }
            }

            private String getConnectionString() {
                final ThreadLocalRandom rnd = ThreadLocalRandom.current();
                return connectionStrings.get(rnd.nextInt(connectionStrings.size()));
            }

        }, ++delay % 500, MILLISECONDS));
    }

    try {
        final int remainingWait = 15 * 60;
        // Ensure all sessions connected
        sessionsLatch.await(remainingWait, SECONDS);

        // Countdown the subscriptions
        subscriptionLatch.await(remainingWait, SECONDS);
    } catch (InterruptedException e) {
        LOG.error("Exception caught waiting for sessions to open: '{}'", e);
    }
    // all connected/failed but not processed all the subscriptions yet.
    writeSteadyStateFlagFile();

    LOG.trace("Done SessionCreator#doStart");
}

From source file:org.apache.druid.segment.IndexMergerV9WithSpatialIndexTest.java

private static QueryableIndex makeMergedQueryableIndex(IndexSpec indexSpec, IndexMergerV9 indexMergerV9,
        IndexIO indexIO) {/*from  ww w  . j a  v  a  2s. co m*/
    try {
        IncrementalIndex first = new IncrementalIndex.Builder().setIndexSchema(
                new IncrementalIndexSchema.Builder().withMinTimestamp(DATA_INTERVAL.getStartMillis())
                        .withQueryGranularity(Granularities.DAY).withMetrics(METRIC_AGGS)
                        .withDimensionsSpec(new DimensionsSpec(null, null, Arrays.asList(
                                new SpatialDimensionSchema("dim.geo", Arrays.asList("lat", "long")),
                                new SpatialDimensionSchema("spatialIsRad", Arrays.asList("lat2", "long2"))

                        ))).build()).setReportParseExceptions(false).setMaxRowCount(1000).buildOnheap();

        IncrementalIndex second = new IncrementalIndex.Builder().setIndexSchema(
                new IncrementalIndexSchema.Builder().withMinTimestamp(DATA_INTERVAL.getStartMillis())
                        .withQueryGranularity(Granularities.DAY).withMetrics(METRIC_AGGS)
                        .withDimensionsSpec(new DimensionsSpec(null, null, Arrays.asList(
                                new SpatialDimensionSchema("dim.geo", Arrays.asList("lat", "long")),
                                new SpatialDimensionSchema("spatialIsRad", Arrays.asList("lat2", "long2"))

                        ))).build()).setReportParseExceptions(false).setMaxRowCount(1000).buildOnheap();

        IncrementalIndex third = new IncrementalIndex.Builder().setIndexSchema(
                new IncrementalIndexSchema.Builder().withMinTimestamp(DATA_INTERVAL.getStartMillis())
                        .withQueryGranularity(Granularities.DAY).withMetrics(METRIC_AGGS)
                        .withDimensionsSpec(new DimensionsSpec(null, null, Arrays.asList(
                                new SpatialDimensionSchema("dim.geo", Arrays.asList("lat", "long")),
                                new SpatialDimensionSchema("spatialIsRad", Arrays.asList("lat2", "long2"))

                        ))).build()).setReportParseExceptions(false).setMaxRowCount(NUM_POINTS).buildOnheap();

        first.add(new MapBasedInputRow(DateTimes.of("2013-01-01").getMillis(), DIMS,
                ImmutableMap.of("timestamp", DateTimes.of("2013-01-01").toString(), "dim", "foo", "lat", 0.0f,
                        "long", 0.0f, "val", 17L)));
        first.add(new MapBasedInputRow(DateTimes.of("2013-01-02").getMillis(), DIMS,
                ImmutableMap.of("timestamp", DateTimes.of("2013-01-02").toString(), "dim", "foo", "lat", 1.0f,
                        "long", 3.0f, "val", 29L)));
        first.add(new MapBasedInputRow(DateTimes.of("2013-01-03").getMillis(), DIMS,
                ImmutableMap.of("timestamp", DateTimes.of("2013-01-03").toString(), "dim", "foo", "lat", 4.0f,
                        "long", 2.0f, "val", 13L)));
        first.add(new MapBasedInputRow(DateTimes.of("2013-01-05").getMillis(), DIMS,
                ImmutableMap.of("timestamp", DateTimes.of("2013-01-05").toString(), "dim", "foo", "lat",
                        "_mmx.unknown", "long", "_mmx.unknown", "val", 101L)));
        first.add(new MapBasedInputRow(DateTimes.of("2013-01-05").getMillis(), DIMS,
                ImmutableMap.of("timestamp", DateTimes.of("2013-01-05").toString(), "dim", "foo", "dim.geo",
                        "_mmx.unknown", "val", 501L)));
        second.add(new MapBasedInputRow(DateTimes.of("2013-01-04").getMillis(), DIMS,
                ImmutableMap.of("timestamp", DateTimes.of("2013-01-04").toString(), "dim", "foo", "lat", 7.0f,
                        "long", 3.0f, "val", 91L)));
        second.add(new MapBasedInputRow(DateTimes.of("2013-01-05").getMillis(), DIMS,
                ImmutableMap.of("timestamp", DateTimes.of("2013-01-05").toString(), "dim", "foo", "lat", 8.0f,
                        "long", 6.0f, "val", 47L)));
        second.add(new MapBasedInputRow(DateTimes.of("2013-01-05").getMillis(), DIMS, ImmutableMap.of(
                "timestamp", DateTimes.of("2013-01-05").toString(), "lat2", 0.0f, "long2", 0.0f, "val", 13L)));

        // Add a bunch of random points
        Random rand = ThreadLocalRandom.current();
        for (int i = 8; i < NUM_POINTS; i++) {
            third.add(new MapBasedInputRow(DateTimes.of("2013-01-01").getMillis(), DIMS,
                    ImmutableMap.of("timestamp", DateTimes.of("2013-01-01").toString(), "dim", "boo", "lat",
                            (float) (rand.nextFloat() * 10 + 10.0), "long",
                            (float) (rand.nextFloat() * 10 + 10.0), "val", i)));
        }

        File tmpFile = File.createTempFile("yay", "who");
        tmpFile.delete();

        File firstFile = new File(tmpFile, "first");
        File secondFile = new File(tmpFile, "second");
        File thirdFile = new File(tmpFile, "third");
        File mergedFile = new File(tmpFile, "merged");

        firstFile.mkdirs();
        secondFile.mkdirs();
        thirdFile.mkdirs();
        mergedFile.mkdirs();

        indexMergerV9.persist(first, DATA_INTERVAL, firstFile, indexSpec, null);
        indexMergerV9.persist(second, DATA_INTERVAL, secondFile, indexSpec, null);
        indexMergerV9.persist(third, DATA_INTERVAL, thirdFile, indexSpec, null);

        try {
            QueryableIndex mergedRealtime = indexIO
                    .loadIndex(indexMergerV9.mergeQueryableIndex(
                            Arrays.asList(indexIO.loadIndex(firstFile), indexIO.loadIndex(secondFile),
                                    indexIO.loadIndex(thirdFile)),
                            true, METRIC_AGGS, mergedFile, indexSpec, null));
            return mergedRealtime;

        } finally {
            FileUtils.deleteDirectory(firstFile);
            FileUtils.deleteDirectory(secondFile);
            FileUtils.deleteDirectory(thirdFile);
            FileUtils.deleteDirectory(mergedFile);
        }

    } catch (IOException e) {
        throw Throwables.propagate(e);
    }
}

From source file:org.apache.hive.spark.client.rpc.TestRpc.java

@Test
public void testRpcServerMultiThread() throws Exception {
    final RpcServer server = autoClose(new RpcServer(emptyConfig));
    final String msg = "Hello World!";
    Callable<String> callable = () -> {
        Rpc[] rpcs = createRpcConnection(server, emptyConfig, UUID.randomUUID().toString());
        Rpc rpc;/* w w w . ja va  2  s.  co  m*/
        if (ThreadLocalRandom.current().nextBoolean()) {
            rpc = rpcs[0];
        } else {
            rpc = rpcs[1];
        }
        TestMessage outbound = new TestMessage("Hello World!");
        Future<TestMessage> call = rpc.call(outbound, TestMessage.class);
        TestMessage reply = call.get(10, TimeUnit.SECONDS);
        return reply.message;
    };
    final int numThreads = ThreadLocalRandom.current().nextInt(5) + 5;
    ExecutorService executor = Executors.newFixedThreadPool(numThreads);
    List<java.util.concurrent.Future<String>> futures = new ArrayList<>(numThreads);
    for (int i = 0; i < numThreads; i++) {
        futures.add(executor.submit(callable));
    }
    executor.shutdown();
    for (java.util.concurrent.Future<String> future : futures) {
        assertEquals(msg, future.get());
    }
}

From source file:ffx.algorithms.mc.RosenbluthOBMC.java

/**
 * Chooses a move, bn, from amongst the new trial set, {b}k, based on 
 * the Boltzmann-weighted orientational energy, U_or[n].
 * Also calculates Rosenbluth factors for both sets, Wn and Wo.
 * Wn = sum(i=1:k, exp(-beta * uDep[i]))
 * Wo = exp(-beta * uDep[current]) + sum(i=2:k, exp(-beta * uDep[i]))
 *//*ww  w .  ja va2  s  .c o  m*/
private MCMove calculateRosenbluthFactors( // orientational
        Residue target, Torsion chi0, ResidueState oldConf, List<MCMove> oldTrialSet, ResidueState newConf,
        List<MCMove> newTrialSet) {
    double temperature = thermostat.getCurrentTemperature();
    double beta = 1.0 / (BOLTZMANN * temperature);

    // Initialize and add up Wo.
    Wo = FastMath.exp(-beta * getTorsionEnergy(chi0));
    report.append(String.format("    TestSet (Old): %5s\t%7s\t\t%7s\n", "uDepO", "uDepOe", "Sum(Wo)"));
    report.append(String.format("       Orig %d:   %7.4f\t%7.4f\t\t%7.4f\n", 0, getTorsionEnergy(chi0),
            FastMath.exp(-beta * getTorsionEnergy(chi0)), Wo));
    for (int i = 0; i < oldTrialSet.size(); i++) {
        setState(target, oldConf);
        MCMove move = oldTrialSet.get(i);
        move.move();
        double uDepO = getTorsionEnergy(chi0);
        double uDepOe = FastMath.exp(-beta * uDepO);
        Wo += uDepOe;
        if (i < 5 || i >= oldTrialSet.size() - 5) {
            report.append(String.format("       Prop %d:   %7.4f\t%7.4f\t\t%7.4f\n", i + 1, uDepO, uDepOe, Wo));
            writeSnapshot("ots");
        } else if (i == 5) {
            report.append(String.format("        ... \n"));
        }
    }

    // Initialize and add up Wn.  Record dependent energy of each trial set member.
    Wn = 0.0;
    double uDepN[] = new double[newTrialSet.size()];
    double uDepNe[] = new double[newTrialSet.size()];
    report.append(String.format("    TestSet (New): %5s\t%7s\t\t%7s\n", "uDepN", "uDepNe", "Sum(Wn)"));
    for (int i = 0; i < newTrialSet.size(); i++) {
        setState(target, newConf);
        MCMove move = newTrialSet.get(i);
        move.move();
        uDepN[i] = getTorsionEnergy(chi0);
        uDepNe[i] = FastMath.exp(-beta * uDepN[i]);
        Wn += uDepNe[i];
        if (i < 5 || i >= newTrialSet.size() - 5) {
            report.append(
                    String.format("       Prop %d:   %7.4f\t%7.4f\t\t%7.4f\n", i, uDepN[i], uDepNe[i], Wn));
            writeSnapshot("nts");
        } else if (i == 5) {
            report.append(String.format("        ... \n"));
        }
    }
    setState(target, oldConf);

    // Choose a proposal move from the new trial set.
    MCMove proposal = null;
    double rng = ThreadLocalRandom.current().nextDouble(Wn);
    double running = 0.0;
    for (int i = 0; i < newTrialSet.size(); i++) {
        running += uDepNe[i];
        if (rng < running) {
            proposal = newTrialSet.get(i);
            double prob = uDepNe[i] / Wn * 100;
            report.append(
                    String.format("       Chose %d   %7.4f\t%7.4f\t  %4.1f%%\n", i, uDepN[i], uDepNe[i], prob));
            break;
        }
    }
    if (proposal == null) {
        logger.severe("Programming error.");
    }
    return proposal;
}

From source file:org.apache.cassandra.db.Directories.java

static DataDirectory pickWriteableDirectory(List<DataDirectoryCandidate> candidates) {
    // weighted random
    double rnd = ThreadLocalRandom.current().nextDouble();
    for (DataDirectoryCandidate candidate : candidates) {
        rnd -= candidate.perc;/*from  w ww . j  a v a 2 s  .  c om*/
        if (rnd <= 0)
            return candidate.dataDirectory;
    }

    // last resort
    return candidates.get(0).dataDirectory;
}

From source file:org.finra.herd.dao.impl.TagDaoImpl.java

@Override
public List<TagEntity> getPercentageOfAllTags(double percentage) {
    // Create the criteria builder and a tuple style criteria query.
    CriteriaBuilder builder = entityManager.getCriteriaBuilder();
    CriteriaQuery<Integer> criteria = builder.createQuery(Integer.class);

    // The criteria root is the tag.
    Root<TagEntity> tagEntityRoot = criteria.from(TagEntity.class);

    // Get the columns.
    Path<Integer> idColumn = tagEntityRoot.get(TagEntity_.id);

    criteria.select(idColumn);// w  ww.  j ava  2  s . co m

    List<Integer> allTagIdsList = entityManager.createQuery(criteria).getResultList();
    List<Integer> percentageOfTagIdsList = new ArrayList<>();

    /*
    * Gets a percentage of all tag entities.
    * The percentage is randomly selected from all the tags.
    *
    * For each tag id in the list of all tag ids, get a random double value between 0 and 1.
    * If that value is below the percentage double value, also a number between 0 and 1 (inclusive),
    * then add the tag id to the list of tag ids that will be used to return a random percentage
    * of tag entities retrieved from the database.
    */
    allTagIdsList.forEach(id -> {
        if (ThreadLocalRandom.current().nextDouble() < percentage) {
            percentageOfTagIdsList.add(id);
        }
    });

    return getTagsByIds(percentageOfTagIdsList);
}

From source file:org.neo4j.io.pagecache.impl.SingleFilePageSwapperTest.java

@Test
public void mustHandleMischiefInPositionedRead() throws Exception {
    int bytesTotal = 512;
    byte[] data = new byte[bytesTotal];
    ThreadLocalRandom.current().nextBytes(data);

    PageSwapperFactory factory = swapperFactory();
    factory.setFileSystemAbstraction(getFs());
    File file = getFile();//from   w w  w  . j  a  v a2s  .  c o m
    PageSwapper swapper = createSwapper(factory, file, bytesTotal, NO_CALLBACK, true);
    try {
        swapper.write(0, new ByteBufferPage(wrap(data)));
    } finally {
        swapper.close();
    }

    RandomAdversary adversary = new RandomAdversary(0.5, 0.0, 0.0);
    factory.setFileSystemAbstraction(new AdversarialFileSystemAbstraction(adversary, getFs()));
    swapper = createSwapper(factory, file, bytesTotal, NO_CALLBACK, false);

    ByteBufferPage page = createPage(bytesTotal);

    try {
        for (int i = 0; i < 10_000; i++) {
            clear(page);
            assertThat(swapper.read(0, page), is((long) bytesTotal));
            assertThat(array(page.buffer), is(data));
        }
    } finally {
        swapper.close();
    }
}

From source file:org.apache.sysml.utils.lite.BuildLiteExecution.java

public static void jmlcLinReg() throws Exception {

    Connection conn = getConfiguredConnection();

    String linRegDS = conn.readScript("scripts/algorithms/LinearRegDS.dml");
    PreparedScript linRegDSScript = conn.prepareScript(linRegDS, new String[] { "X", "y" },
            new String[] { "beta_out" }, false);

    double[][] trainData = new double[500][3];
    for (int i = 0; i < 500; i++) {
        double one = ThreadLocalRandom.current().nextDouble(0, 100);
        double two = ThreadLocalRandom.current().nextDouble(0, 100);
        double three = ThreadLocalRandom.current().nextDouble(0, 100);
        double[] row = new double[] { one, two, three };
        trainData[i] = row;//from w  ww  .j av  a 2s. co  m
    }
    linRegDSScript.setMatrix("X", trainData);
    log.debug(displayMatrix(trainData));

    double[][] trainLabels = new double[500][1];
    for (int i = 0; i < 500; i++) {
        double one = ThreadLocalRandom.current().nextDouble(0, 100);
        double[] row = new double[] { one };
        trainLabels[i] = row;
    }
    linRegDSScript.setMatrix("y", trainLabels);
    log.debug(displayMatrix(trainLabels));

    ResultVariables linRegDSResults = linRegDSScript.executeScript();
    double[][] dsBetas = linRegDSResults.getMatrix("beta_out");
    log.debug("DS BETAS:");
    log.debug(displayMatrix(dsBetas));

    String linRegCG = conn.readScript("scripts/algorithms/LinearRegCG.dml");
    PreparedScript linRegCGScript = conn.prepareScript(linRegCG, new String[] { "X", "y" },
            new String[] { "beta_out" }, false);
    linRegCGScript.setMatrix("X", trainData);
    linRegCGScript.setMatrix("y", trainLabels);
    ResultVariables linRegCGResults = linRegCGScript.executeScript();
    double[][] cgBetas = linRegCGResults.getMatrix("beta_out");
    log.debug("CG BETAS:");
    log.debug(displayMatrix(cgBetas));

    String glmPredict = conn.readScript("scripts/algorithms/GLM-predict.dml");
    HashMap<String, String> args = new HashMap<>();
    args.put("$M", "/tmp/dummy"); //required due to conditional write
    PreparedScript glmPredictScript = conn.prepareScript(glmPredict, args, new String[] { "X", "Y", "B_full" },
            new String[] { "means" }, false);
    double[][] testData = new double[500][3];
    for (int i = 0; i < 500; i++) {
        double one = ThreadLocalRandom.current().nextDouble(0, 100);
        double two = ThreadLocalRandom.current().nextDouble(0, 100);
        double three = ThreadLocalRandom.current().nextDouble(0, 100);
        double[] row = new double[] { one, two, three };
        testData[i] = row;
    }
    glmPredictScript.setMatrix("X", testData);
    double[][] testLabels = new double[500][1];
    for (int i = 0; i < 500; i++) {
        double one = ThreadLocalRandom.current().nextDouble(0, 100);
        double[] row = new double[] { one };
        testLabels[i] = row;
    }
    glmPredictScript.setMatrix("Y", testLabels);
    glmPredictScript.setMatrix("B_full", cgBetas);
    ResultVariables glmPredictResults = glmPredictScript.executeScript();
    double[][] means = glmPredictResults.getMatrix("means");
    log.debug("GLM PREDICT MEANS:");
    log.debug(displayMatrix(means));

    conn.close();
}