Example usage for java.time LocalDate parse

List of usage examples for java.time LocalDate parse

Introduction

In this page you can find the example usage for java.time LocalDate parse.

Prototype

public static LocalDate parse(CharSequence text) 

Source Link

Document

Obtains an instance of LocalDate from a text string such as 2007-12-03 .

Usage

From source file:org.silverpeas.core.webapi.calendar.CalendarEventEntity.java

/**
 * Gets the period of the event.//w  w w .ja v  a  2 s .c o m
 * @return a period instance.
 */
@XmlTransient
Period getPeriod() {
    final Period eventPeriod;
    if (isOnAllDay()) {
        eventPeriod = Period.between(LocalDate.parse(startDate), LocalDate.parse(endDate));
    } else {
        eventPeriod = Period.between(OffsetDateTime.parse(startDate), OffsetDateTime.parse(endDate));
    }
    return eventPeriod;
}

From source file:org.ojbc.adapters.analyticsstaging.custody.processor.AbstractReportRepositoryProcessor.java

private void processPrescribedMedications(BehavioralHealthAssessment assessment, Node behavioralHealthInfoNode,
        String extPrefix) throws Exception {
    NodeList prescribedMedicationNodes = XmlUtils.xPathNodeListSearch(behavioralHealthInfoNode,
            extPrefix + ":PrescribedMedication");

    if (prescribedMedicationNodes.getLength() > 0) {

        List<PrescribedMedication> prescribedMedications = new ArrayList<PrescribedMedication>();

        for (int i = 0; i < prescribedMedicationNodes.getLength(); i++) {
            Node prescribedMedicationNode = prescribedMedicationNodes.item(i);

            PrescribedMedication prescribedMedication = new PrescribedMedication();
            prescribedMedication.setBehavioralHealthAssessmentID(assessment.getBehavioralHealthAssessmentId());
            String medicationItemName = XmlUtils.xPathStringSearch(prescribedMedicationNode,
                    "cyfs31:Medication/nc30:ItemName");
            prescribedMedication.setMedicationDescription(medicationItemName);

            String medicationDispensingDate = XmlUtils.xPathStringSearch(prescribedMedicationNode,
                    "cyfs31:MedicationDispensingDate/nc30:Date");
            if (StringUtils.isNotBlank(medicationDispensingDate)) {
                prescribedMedication.setMedicationDispensingDate(LocalDate.parse(medicationDispensingDate));
            }//from w w w  .j a v a 2s.co  m

            String medicationDoseMeasure = XmlUtils.xPathStringSearch(prescribedMedicationNode,
                    "cyfs31:MedicationDoseMeasure/nc30:MeasureValueText");
            prescribedMedication.setMedicationDoseMeasure(medicationDoseMeasure);

            prescribedMedications.add(prescribedMedication);
        }

        analyticalDatastoreDAO.savePrescribedMedications(prescribedMedications);
        assessment.setPrescribedMedications(prescribedMedications);
    }

}

From source file:org.ojbc.adapters.analyticsstaging.custody.processor.AbstractReportRepositoryProcessor.java

private void processTreatmentNodes(BehavioralHealthAssessment assessment, Node behavioralHealthInfoNode,
        String extPrefix) throws Exception {
    NodeList treatmentNodes = XmlUtils.xPathNodeListSearch(behavioralHealthInfoNode, "nc30:Treatment");

    if (treatmentNodes.getLength() > 0) {

        List<Treatment> treatments = new ArrayList<Treatment>();

        for (int i = 0; i < treatmentNodes.getLength(); i++) {
            Node treatmentNode = treatmentNodes.item(i);

            Treatment treatment = new Treatment();
            treatment.setBehavioralHealthAssessmentID(assessment.getBehavioralHealthAssessmentId());

            String startDateString = XmlUtils.xPathStringSearch(treatmentNode,
                    "nc30:ActivityDateRange/nc30:StartDate/nc30:Date");
            if (StringUtils.isNotBlank(startDateString)) {
                treatment.setTreatmentStartDate(LocalDate.parse(startDateString));
            }/* ww w. ja va 2  s  .  co m*/

            String treatmentProvider = XmlUtils.xPathStringSearch(treatmentNode,
                    "nc30:TreatmentProvider/nc30:EntityOrganization/nc30:OrganizationName");
            treatment.setTreatmentProviderName(treatmentProvider);

            Boolean treatmentCourtOrdered = BooleanUtils.toBooleanObject(
                    XmlUtils.xPathStringSearch(treatmentNode, extPrefix + ":TreatmentCourtOrderedIndicator"));
            String treatmentAdmissionReason = BooleanUtils.toString(treatmentCourtOrdered, "court ordered",
                    "voluntary", null);
            treatment.setTreatmentAdmissionReasonTypeId(descriptionCodeLookupService
                    .retrieveCode(CodeTable.TreatmentAdmissionReasonType, treatmentAdmissionReason));

            Boolean treatmentActive = BooleanUtils.toBooleanObject(
                    XmlUtils.xPathStringSearch(treatmentNode, extPrefix + ":TreatmentActiveIndicator"));
            String treamentStatusType = BooleanUtils.toString(treatmentActive, "active", "inactive", null);
            treatment.setTreatmentStatusTypeId(descriptionCodeLookupService
                    .retrieveCode(CodeTable.TreatmentStatusType, treamentStatusType));

            treatments.add(treatment);
        }

        analyticalDatastoreDAO.saveTreatments(treatments);
        assessment.setTreatments(treatments);
    }

}

From source file:org.ojbc.adapters.analyticsstaging.custody.CamelContextAdamsWrongOrderTest.java

public void testBookingReportServiceRoute() throws Exception, IOException {
    Exchange senderExchange = createSenderExchange(
            "src/test/resources/xmlInstances/bookingReport/BookingReport-Adams.xml");

    Person person = analyticalDatastoreDAO.getPerson(1);
    Assert.assertNotNull(person);/*from   w w w. j a v  a 2  s  . c o m*/

    Booking booking = analyticalDatastoreDAO.getBookingByBookingNumber("Booking Number");
    assertNull(booking);

    List<BookingCharge> bookingCharges = analyticalDatastoreDAO.getBookingCharges(1);
    assertTrue(bookingCharges.isEmpty());

    List<BookingArrest> bookingArrests = analyticalDatastoreDAO.getBookingArrests(1);
    assertTrue(bookingArrests.isEmpty());

    //Send the one-way exchange.  Using template.send will send an one way message
    Exchange returnExchange = template.send("direct:bookingReportServiceEndpoint", senderExchange);

    //Use getException to see if we received an exception
    if (returnExchange.getException() != null) {
        throw new Exception(returnExchange.getException());
    }

    assertThat(jdbcTemplate.queryForObject("select count(*) from Booking", Integer.class), is(1));

    person = analyticalDatastoreDAO.getPerson(2);
    Assert.assertNotNull(person);

    assertThat(person.getPersonId(), is(2));
    assertThat(person.getPersonSexId(), is(2));
    assertThat(person.getPersonRaceId(), is(6));
    assertThat(person.getPersonSexDescription(), is("Female"));
    assertThat(person.getPersonRaceDescription(), is("White"));
    assertThat(person.getLanguage(), is("English"));
    assertThat(person.getPersonBirthDate(), is(LocalDate.parse("1968-12-17")));
    assertThat(person.getPersonUniqueIdentifier(), is("e807f1fcf82d132f9bb018ca6738a19f"));
    assertThat(person.getPersonUniqueIdentifier2(), is("Booking Subject Number"));
    assertThat(person.getLanguageId(), is(1));
    assertThat(person.getSexOffenderStatusTypeId(), is(1));
    assertThat(person.getMilitaryServiceStatusType().getValue(), is("Honorable Discharge"));

    assertThat(person.getEducationLevel(), is("High School Graduate"));
    assertThat(person.getOccupation(), is("Truck Driver"));

    List<BehavioralHealthAssessment> behavioralHealthAssessments = analyticalDatastoreDAO
            .getBehavioralHealthAssessments(person.getPersonId());
    assertFalse(behavioralHealthAssessments.isEmpty());

    BehavioralHealthAssessment behavioralHealthAssessment = behavioralHealthAssessments.get(0);

    assertTrue(behavioralHealthAssessment.getBehavioralHealthDiagnoses().size() == 1);
    assertThat(behavioralHealthAssessment.getBehavioralHealthDiagnoses().get(0), is("Schizophrenia 295.10"));
    assertThat(behavioralHealthAssessment.getPersonId(), is(2));
    assertThat(behavioralHealthAssessment.getBehavioralHealthAssessmentId(), is(2));
    assertThat(behavioralHealthAssessment.getSeriousMentalIllness(), is(true));
    assertThat(behavioralHealthAssessment.getCareEpisodeStartDate(), is(LocalDate.parse("2016-01-01")));
    assertThat(behavioralHealthAssessment.getCareEpisodeEndDate(), is(LocalDate.parse("2016-04-01")));
    assertThat(behavioralHealthAssessment.getEnrolledProviderName(), is("79"));
    assertThat(behavioralHealthAssessment.getMedicaidStatusTypeId(), nullValue());

    List<Treatment> treatments = analyticalDatastoreDAO.getTreatments(2);
    assertThat(treatments.size(), is(1));

    Treatment treatment = treatments.get(0);
    assertThat(treatment.getBehavioralHealthAssessmentID(), is(2));
    assertThat(treatment.getTreatmentStartDate(), is(LocalDate.parse("2016-01-01")));
    assertThat(treatment.getTreatmentAdmissionReasonTypeId(), nullValue());
    assertThat(treatment.getTreatmentStatusTypeId(), nullValue());
    assertThat(treatment.getTreatmentProviderName(), is("Treatment Providing Organization Name"));

    List<PrescribedMedication> prescribedMedications = analyticalDatastoreDAO.getPrescribedMedication(2);
    assertThat(prescribedMedications.size(), is(1));

    PrescribedMedication prescribedMedication = prescribedMedications.get(0);
    assertThat(prescribedMedication.getBehavioralHealthAssessmentID(), is(2));
    assertThat(prescribedMedication.getMedicationDescription(), is("Zyprexa"));
    assertThat(prescribedMedication.getMedicationDispensingDate(), is(LocalDate.parse("2016-01-01")));
    assertThat(prescribedMedication.getMedicationDoseMeasure(), is("3mg"));

    booking = analyticalDatastoreDAO.getBookingByBookingNumber("Booking Number");
    assertNotNull(booking);

    assertEquals(LocalDate.parse("2013-12-17"), booking.getBookingDate());
    assertEquals(LocalTime.parse("09:30"), booking.getBookingTime());
    assertThat(booking.getFacilityId(), is(1));
    assertThat(booking.getSupervisionUnitTypeId(), nullValue());
    assertEquals("Booking Number", booking.getBookingNumber());
    assertEquals(LocalDate.parse("2014-12-17"), booking.getScheduledReleaseDate());
    assertThat(booking.getInmateJailResidentIndicator(), is(false));

    bookingArrests = analyticalDatastoreDAO.getBookingArrests(1);
    assertFalse(bookingArrests.isEmpty());
    BookingArrest bookingArrest = bookingArrests.get(0);

    assertTrue(bookingArrest.getBookingId() == 1);
    assertTrue(bookingArrest.getBookingArrestId() == 1);
    assertEquals("392", bookingArrest.getAddress().getStreetNumber());
    assertEquals("Woodlawn Ave", bookingArrest.getAddress().getStreetName());
    assertEquals("Burlington", bookingArrest.getAddress().getCity());
    assertEquals("NY", bookingArrest.getAddress().getState());
    assertEquals("05408", bookingArrest.getAddress().getPostalcode());
    assertTrue(bookingArrest.getAddress().getLocationLatitude().doubleValue() == 56.1111);
    assertTrue(bookingArrest.getAddress().getLocationLongitude().doubleValue() == 32.1111);
    assertThat(bookingArrest.getArrestAgencyId(), is(29));

    bookingCharges = analyticalDatastoreDAO.getBookingCharges(1);
    assertThat(bookingCharges.size(), is(2));

    BookingCharge bookingCharge = bookingCharges.get(0);
    assertThat(bookingCharge.getChargeCode(), is("Charge Code ID"));
    assertTrue(bookingCharge.getBookingArrestId() == 1);
    assertTrue(bookingCharge.getBondAmount().doubleValue() == 500.00);
    assertThat(bookingCharge.getBondType().getValue(), is("CASH/SURETY/PROPERTY"));
    assertThat(bookingCharge.getAgencyId(), is(21));
    assertThat(bookingCharge.getChargeClassTypeId(), is(1));
    assertThat(bookingCharge.getBondStatusTypeId(), is(17));
    assertThat(bookingCharge.getChargeJurisdictionTypeId(), is(1));
    assertThat(bookingCharge.getChargeDisposition(), is("Disposition"));

    CustodyRelease custodyRelease = analyticalDatastoreDAO.getCustodyReleaseByBookingId(1);
    log.info(custodyRelease.toString());
    assertEquals(LocalDate.parse("2014-12-17"), custodyRelease.getReleaseDate());
    assertEquals(LocalTime.parse("10:30"), custodyRelease.getReleaseTime());
    assertThat(custodyRelease.getBookingNumber(), is("Booking Number"));

    assertThat(jdbcTemplate.queryForObject(
            "select count(*) from CustodyRelease WHERE bookingId = 1 AND bookingNumber = 'Booking Number' ",
            Integer.class), is(2));
    assertThat(jdbcTemplate.queryForObject("select count(*) from CustodyRelease", Integer.class), is(2));
    assertThat(jdbcTemplate.queryForObject(
            "select count(*) from CustodyStatusChange WHERE bookingId = 1 AND bookingNumber = 'Booking Number' ",
            Integer.class), is(1));
    assertThat(jdbcTemplate.queryForObject("select count(*) from CustodyStatusChange", Integer.class), is(1));
}

From source file:org.ojbc.adapters.analyticsstaging.custody.CamelContextAdamsTest.java

public void testBookingReportServiceRoute() throws Exception, IOException {
    Exchange senderExchange = createSenderExchange(
            "src/test/resources/xmlInstances/bookingReport/BookingReport-Adams.xml");

    Person person = analyticalDatastoreDAO.getPerson(1);
    Assert.assertNull(person);//from ww w .  j  a  v a2  s  .  c  o m

    Booking booking = analyticalDatastoreDAO.getBookingByBookingNumber("Booking Number");
    assertNull(booking);

    List<BookingCharge> bookingCharges = analyticalDatastoreDAO.getBookingCharges(1);
    assertTrue(bookingCharges.isEmpty());

    List<BookingArrest> bookingArrests = analyticalDatastoreDAO.getBookingArrests(1);
    assertTrue(bookingArrests.isEmpty());

    //Send the one-way exchange.  Using template.send will send an one way message
    Exchange returnExchange = template.send("direct:bookingReportServiceEndpoint", senderExchange);

    //Use getException to see if we received an exception
    if (returnExchange.getException() != null) {
        throw new Exception(returnExchange.getException());
    }

    assertThat(jdbcTemplate.queryForObject("select count(*) from Booking", Integer.class), is(1));

    person = analyticalDatastoreDAO.getPerson(1);
    Assert.assertNotNull(person);

    Assert.assertEquals(Integer.valueOf(1), person.getPersonId());
    assertThat(person.getPersonSexId(), is(2));
    assertThat(person.getPersonRaceId(), is(6));
    assertThat(person.getPersonEthnicityTypeId(), is(1));
    assertThat(person.getPersonSexDescription(), is("Female"));
    assertThat(person.getPersonRaceDescription(), is("White"));
    assertThat(person.getLanguage(), is("English"));
    assertThat(person.getPersonBirthDate(), is(LocalDate.parse("1968-12-17")));
    assertThat(person.getPersonUniqueIdentifier(), is("e807f1fcf82d132f9bb018ca6738a19f"));
    assertThat(person.getPersonUniqueIdentifier2(), is("Booking Subject Number"));
    assertThat(person.getLanguageId(), is(1));
    assertThat(person.getSexOffenderStatusTypeId(), is(1));
    assertThat(person.getMilitaryServiceStatusType().getValue(), is("Honorable Discharge"));

    assertThat(person.getEducationLevel(), is("High School Graduate"));
    assertThat(person.getOccupation(), is("Truck Driver"));

    List<BehavioralHealthAssessment> behavioralHealthAssessments = analyticalDatastoreDAO
            .getBehavioralHealthAssessments(1);
    assertFalse(behavioralHealthAssessments.isEmpty());

    BehavioralHealthAssessment behavioralHealthAssessment = behavioralHealthAssessments.get(0);

    assertTrue(behavioralHealthAssessment.getBehavioralHealthDiagnoses().size() == 1);
    assertThat(behavioralHealthAssessment.getBehavioralHealthDiagnoses().get(0), is("Schizophrenia 295.10"));
    assertThat(behavioralHealthAssessment.getPersonId(), is(1));
    assertThat(behavioralHealthAssessment.getBehavioralHealthAssessmentId(), is(1));
    assertThat(behavioralHealthAssessment.getSeriousMentalIllness(), is(true));
    assertThat(behavioralHealthAssessment.getCareEpisodeStartDate(), is(LocalDate.parse("2016-01-01")));
    assertThat(behavioralHealthAssessment.getCareEpisodeEndDate(), is(LocalDate.parse("2016-04-01")));
    assertThat(behavioralHealthAssessment.getEnrolledProviderName(), is("79"));
    assertThat(behavioralHealthAssessment.getMedicaidStatusTypeId(), nullValue());

    List<Treatment> treatments = analyticalDatastoreDAO.getTreatments(1);
    assertThat(treatments.size(), is(1));

    Treatment treatment = treatments.get(0);
    assertThat(treatment.getBehavioralHealthAssessmentID(), is(1));
    assertThat(treatment.getTreatmentStartDate(), is(LocalDate.parse("2016-01-01")));
    assertThat(treatment.getTreatmentAdmissionReasonTypeId(), nullValue());
    assertThat(treatment.getTreatmentStatusTypeId(), nullValue());
    assertThat(treatment.getTreatmentProviderName(), is("Treatment Providing Organization Name"));

    List<PrescribedMedication> prescribedMedications = analyticalDatastoreDAO.getPrescribedMedication(1);
    assertThat(prescribedMedications.size(), is(1));

    PrescribedMedication prescribedMedication = prescribedMedications.get(0);
    assertThat(prescribedMedication.getBehavioralHealthAssessmentID(), is(1));
    assertThat(prescribedMedication.getMedicationDescription(), is("Zyprexa"));
    assertThat(prescribedMedication.getMedicationDispensingDate(), is(LocalDate.parse("2016-01-01")));
    assertThat(prescribedMedication.getMedicationDoseMeasure(), is("3mg"));

    booking = analyticalDatastoreDAO.getBookingByBookingNumber("Booking Number");
    assertNotNull(booking);

    assertEquals(LocalDate.parse("2013-12-17"), booking.getBookingDate());
    assertEquals(LocalTime.parse("09:30"), booking.getBookingTime());
    assertThat(booking.getFacilityId(), is(1));
    assertThat(booking.getSupervisionUnitTypeId(), nullValue());
    assertEquals("Booking Number", booking.getBookingNumber());
    assertEquals(LocalDate.parse("2014-12-17"), booking.getScheduledReleaseDate());
    assertThat(booking.getInmateJailResidentIndicator(), is(false));

    bookingArrests = analyticalDatastoreDAO.getBookingArrests(1);
    assertFalse(bookingArrests.isEmpty());
    BookingArrest bookingArrest = bookingArrests.get(0);

    assertTrue(bookingArrest.getBookingId() == 1);
    assertTrue(bookingArrest.getBookingArrestId() == 1);
    assertEquals("392", bookingArrest.getAddress().getStreetNumber());
    assertEquals("Woodlawn Ave", bookingArrest.getAddress().getStreetName());
    assertEquals("Burlington", bookingArrest.getAddress().getCity());
    assertEquals("NY", bookingArrest.getAddress().getState());
    assertEquals("05408", bookingArrest.getAddress().getPostalcode());
    assertTrue(bookingArrest.getAddress().getLocationLatitude().doubleValue() == 56.1111);
    assertTrue(bookingArrest.getAddress().getLocationLongitude().doubleValue() == 32.1111);
    assertThat(bookingArrest.getArrestAgencyId(), is(29));

    bookingCharges = analyticalDatastoreDAO.getBookingCharges(1);
    assertThat(bookingCharges.size(), is(2));

    BookingCharge bookingCharge = bookingCharges.get(0);
    assertThat(bookingCharge.getChargeCode(), is("Charge Code ID"));
    assertTrue(bookingCharge.getBookingArrestId() == 1);
    assertTrue(bookingCharge.getBondAmount().doubleValue() == 500.00);
    assertThat(bookingCharge.getBondType().getValue(), is("CASH/SURETY/PROPERTY"));
    assertThat(bookingCharge.getAgencyId(), is(21));
    assertThat(bookingCharge.getChargeClassTypeId(), is(1));
    assertThat(bookingCharge.getBondStatusTypeId(), is(17));
    assertThat(bookingCharge.getChargeJurisdictionTypeId(), is(1));
    assertThat(bookingCharge.getChargeDisposition(), is("Disposition"));

    CustodyRelease custodyRelease = analyticalDatastoreDAO.getCustodyReleaseByBookingId(1);
    log.info(custodyRelease.toString());
    assertEquals(LocalDate.parse("2014-12-17"), custodyRelease.getReleaseDate());
    assertEquals(LocalTime.parse("10:30"), custodyRelease.getReleaseTime());
    assertThat(custodyRelease.getBookingNumber(), is("Booking Number"));

}

From source file:investiagenofx2.view.InvestiaGenOFXController.java

private void getTransactionsFromWeb() {
    try {//  w ww. ja va2 s .co  m
        if (!htmlPage.getUrl().toString().contains("/TransactionReports/Select")) {
            if (InvestiaGenOFX.debug) {
                htmlPage = InvestiaGenOFX.getWebClient()
                        .getPage(InvestiaGenOFX.debugFullPath + "-Transactions.htm");
            } else {
                htmlPage = InvestiaGenOFX.getWebClient()
                        .getPage(txt_investiaURL.getText() + "/TransactionReports/Select" + "?wcag=true");
                waitForGeneratedTransactions();
            }
        }
        @SuppressWarnings(("unchecked"))
        List<HtmlHeading4> h4from = (List<HtmlHeading4>) htmlPage
                .getByXPath("//h4[contains(text(),'Priode: de ')]");
        String from = h4from.get(0).asText();
        int index = from.indexOf("Priode: de ");
        LocalDate selFromDate = LocalDate.parse(from.substring(index + 12, index + 12 + 10));

        if (dtp_lastDate.getValue().isBefore(selFromDate)) {
            @SuppressWarnings(("unchecked"))
            List<HtmlForm> forms = (List<HtmlForm>) htmlPage.getByXPath("//form");
            HtmlForm form = forms.get(1);
            HtmlTextInput selPerFrom = form.getInputByName("selPerFrom");
            selPerFrom.setValueAttribute(dtp_lastDate.getValue().toString());

            HtmlAnchor generate = (HtmlAnchor) form.getByXPath("//a[contains(@class, 'btn-investia-blue')]")
                    .get(0);
            if (InvestiaGenOFX.debug) {
                htmlPage = InvestiaGenOFX.getWebClient()
                        .getPage(InvestiaGenOFX.debugFullPath + "-Transactions.htm");
            } else {
                htmlPage = generate.click();
                waitForGeneratedTransactions();
            }
        }

        HtmlTable htmlTable = (HtmlTable) htmlPage.getElementById("tblTransactionReports");
        if (htmlTable == null) {
            return;
        }
        for (int i = 0; i < htmlTable.getRowCount(); i++) {
            LocalDate transacDate = LocalDate.parse(htmlTable.getCellAt(i, 0).getTextContent(),
                    DateTimeFormatter.ofPattern("dd MMM yyyy", Locale.CANADA_FRENCH));
            if (transacDate.isBefore(dtp_lastDate.getValue())) {
                break;
            }
            String transacType = htmlTable.getCellAt(i, 2).getTextContent();
            String[] token = transacType.split("[\\-/(]");
            switch (token[0].replace(" ", "")) {
            case "Dividendes":
                transacType = "Distribution";
                break;
            case "Achat":
            case "changeentrant":
            case "Prlvementautomatique":
            case "Transfertentrantdecourtier":
            case "Transfertexterneentrant":
            case "Transfertinterneentrant":
                transacType = "Purchase";
                break;
            case "changesortant":
            case "Rachat":
            case "Transfertexternesortant":
            case "Transf.int.sort.":
            case "Transf.Int.sortant":
            case "Transfertinternesortant":
                transacType = "Switch Out";
                break;
            case "Dpt":
                transacType = "Credit";
                break;
            case "Retrait":
            case "Retenue":
                transacType = "Debit";
                break;
            case "Crditenespces":
            case "Entred'espces":
            case "Fraisd'administration":
            case "Sortied'espces":
            case "Transfertd'espcesentrant":
            case "Transfertd'espcessortant":
                continue;
            default:
                try {
                    throw new MyOwnException("Type de transaction non prise en charge: " + transacType.trim());
                } catch (MyOwnException ex) {
                    Logger.getLogger(OFXUtilites.class.getName()).log(Level.SEVERE, null, ex);
                    continue;
                }
            }

            String transacAccount = accountOwnerName.split(" ")[0] + "\\"
                    + htmlTable.getCellAt(i, 1).getTextContent();
            String symbol = htmlTable.getCellAt(i, 3).getTextContent();
            String unit = htmlTable.getCellAt(i, 5).getTextContent().replaceAll("[^0-9,]", "").replace(",",
                    ".");
            String fitid = "";
            String price = "0.00";
            String amount;
            if ("Credit".equals(transacType) || "Debit".equals(transacType)) {
                amount = htmlTable.getCellAt(i, 9).getTextContent().replaceAll("[^0-9,]", "").replace(",", ".");
                fitid = StringUtils.stripAccents(htmlTable.getCellAt(i, 2).getTextContent());
            } else {
                amount = htmlTable.getCellAt(i, 10).getTextContent().replaceAll("[^0-9,]", "").replace(",",
                        ".");
                price = Float.toString(Float.parseFloat(amount) / Float.parseFloat(unit));
            }
            if (PropertiesInit.getLinkAccountsTransac().indexOf(transacAccount) < 0) {
                linkAccountTransac(transacAccount);
            }
            int idxAccount = linkAccountToLocalAccountIndex[PropertiesInit.getLinkAccountsTransac()
                    .indexOf(transacAccount)];
            accounts.get(idxAccount)
                    .add(new Transaction(transacDate, transacType, amount, fitid, symbol, unit, price, ""));
        }
    } catch (Exception ex) {
        Logger.getLogger(InvestiaGenOFXController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:org.apache.nifi.processors.solr.SolrUtils.java

private static void writeValue(final SolrInputDocument inputDocument, final Object value,
        final String fieldName, final DataType dataType, final List<String> fieldsToIndex) throws IOException {
    final DataType chosenDataType = dataType.getFieldType() == RecordFieldType.CHOICE
            ? DataTypeUtils.chooseDataType(value, (ChoiceDataType) dataType)
            : dataType;/*from   w ww. j  a v a2s  .  c o m*/
    final Object coercedValue = DataTypeUtils.convertType(value, chosenDataType, fieldName);
    if (coercedValue == null) {
        return;
    }

    switch (chosenDataType.getFieldType()) {
    case DATE: {
        final String stringValue = DataTypeUtils.toString(coercedValue,
                () -> DataTypeUtils.getDateFormat(RecordFieldType.DATE.getDefaultFormat()));
        if (DataTypeUtils.isLongTypeCompatible(stringValue)) {
            LocalDate localDate = getLocalDateFromEpochTime(fieldName, coercedValue);
            addFieldToSolrDocument(inputDocument, fieldName,
                    localDate.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME) + 'Z', fieldsToIndex);
        } else {
            addFieldToSolrDocument(inputDocument, fieldName,
                    LocalDate.parse(stringValue).format(DateTimeFormatter.ISO_LOCAL_DATE_TIME) + 'Z',
                    fieldsToIndex);
        }
        break;
    }
    case TIMESTAMP: {
        final String stringValue = DataTypeUtils.toString(coercedValue,
                () -> DataTypeUtils.getDateFormat(RecordFieldType.TIMESTAMP.getDefaultFormat()));
        if (DataTypeUtils.isLongTypeCompatible(stringValue)) {
            LocalDateTime localDateTime = getLocalDateTimeFromEpochTime(fieldName, coercedValue);
            addFieldToSolrDocument(inputDocument, fieldName,
                    localDateTime.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME) + 'Z', fieldsToIndex);
        } else {
            addFieldToSolrDocument(inputDocument, fieldName,
                    LocalDateTime.parse(stringValue).format(DateTimeFormatter.ISO_LOCAL_DATE_TIME) + 'Z',
                    fieldsToIndex);
        }
        break;
    }
    case DOUBLE:
        addFieldToSolrDocument(inputDocument, fieldName, DataTypeUtils.toDouble(coercedValue, fieldName),
                fieldsToIndex);
        break;
    case FLOAT:
        addFieldToSolrDocument(inputDocument, fieldName, DataTypeUtils.toFloat(coercedValue, fieldName),
                fieldsToIndex);
        break;
    case LONG:
        addFieldToSolrDocument(inputDocument, fieldName, DataTypeUtils.toLong(coercedValue, fieldName),
                fieldsToIndex);
        break;
    case INT:
    case BYTE:
    case SHORT:
        addFieldToSolrDocument(inputDocument, fieldName, DataTypeUtils.toInteger(coercedValue, fieldName),
                fieldsToIndex);
        break;
    case CHAR:
    case STRING:
        addFieldToSolrDocument(inputDocument, fieldName, coercedValue.toString(), fieldsToIndex);
        break;
    case BIGINT:
        if (coercedValue instanceof Long) {
            addFieldToSolrDocument(inputDocument, fieldName, (Long) coercedValue, fieldsToIndex);
        } else {
            addFieldToSolrDocument(inputDocument, fieldName, (BigInteger) coercedValue, fieldsToIndex);
        }
        break;
    case BOOLEAN:
        final String stringValue = coercedValue.toString();
        if ("true".equalsIgnoreCase(stringValue)) {
            addFieldToSolrDocument(inputDocument, fieldName, true, fieldsToIndex);
        } else if ("false".equalsIgnoreCase(stringValue)) {
            addFieldToSolrDocument(inputDocument, fieldName, false, fieldsToIndex);
        } else {
            addFieldToSolrDocument(inputDocument, fieldName, stringValue, fieldsToIndex);
        }
        break;
    case RECORD: {
        final Record record = (Record) coercedValue;
        writeRecord(record, inputDocument, fieldsToIndex, fieldName);
        break;
    }
    case ARRAY:
    default:
        if (coercedValue instanceof Object[]) {
            final Object[] values = (Object[]) coercedValue;
            for (Object element : values) {
                if (element instanceof Record) {
                    writeRecord((Record) element, inputDocument, fieldsToIndex, fieldName);
                } else {
                    addFieldToSolrDocument(inputDocument, fieldName, coercedValue.toString(), fieldsToIndex);
                }
            }
        } else {
            addFieldToSolrDocument(inputDocument, fieldName, coercedValue.toString(), fieldsToIndex);
        }
        break;
    }
}

From source file:serposcope.controllers.google.GoogleTargetController.java

public Result jsonRanks(Context context, @PathParam("targetId") Integer targetId,
        @Param("startDate") String startDateStr, @Param("endDate") String endDateStr) {
    final GoogleTarget target = getTarget(context, targetId);
    final List<GoogleSearch> searches = context.getAttribute("searches", List.class);
    final Group group = context.getAttribute("group", Group.class);
    final LocalDate startDate, endDate;
    try {/*from  w  w w .j ava2s.  co  m*/
        startDate = LocalDate.parse(startDateStr);
        endDate = LocalDate.parse(endDateStr);
    } catch (Exception ex) {
        return Results.json().renderRaw("[]");
    }

    final Run firstRun = baseDB.run.findFirst(group.getModule(), RunDB.STATUSES_DONE, startDate);
    final Run lastRun = baseDB.run.findLast(group.getModule(), RunDB.STATUSES_DONE, endDate);
    final List<Run> runs = baseDB.run.listDone(firstRun.getId(), lastRun.getId());

    return Results.ok().json().render((Context context0, Result result) -> {
        PrintWriter writer = null;
        OutputStream os = null;
        try {

            String acceptEncoding = context0.getHeader("Accept-Encoding");
            if (acceptEncoding != null && acceptEncoding.contains("gzip")) {
                result.addHeader("Content-Encoding", "gzip");
            }

            ResponseStreams response = context0.finalizeHeaders(result);
            os = response.getOutputStream();
            if (acceptEncoding != null && acceptEncoding.contains("gzip")) {
                os = new GZIPOutputStream(os);
            }

            writer = new PrintWriter(os);
            getTableJson(group, target, searches, runs, startDate, endDate, writer);

        } catch (Exception ex) {
            LOG.warn("HTTP error", ex);
        } finally {
            if (os != null) {
                try {
                    writer.close();
                    os.close();
                } catch (Exception ex) {
                }
            }
        }
    });
}

From source file:org.ojbc.adapters.analyticsstaging.custody.processor.AbstractReportRepositoryProcessor.java

/**
 * @param dateString//from  ww w .  j  av a  2 s.  c om
 * @return the parsed LocalDate or null if the dateString is not valid or parsing failure. 
 */
protected LocalDate parseLocalDate(String dateString) {

    try {
        if (StringUtils.isNotBlank(dateString)) {
            return LocalDate.parse(dateString);
        } else {
            log.error("The dateString can not be blank");
        }
    } catch (DateTimeParseException e) {
        log.error("Failed to parse dateTimeString " + dateString, e);
    }

    return null;
}

From source file:serposcope.controllers.google.GoogleGroupController.java

@FilterWith({ XSRFFilter.class, AdminFilter.class })
public Result addEvent(Context context, @Param("day") String day, @Param("title") String title,
        @Param("description") String description, @Param("redir-search") Integer redirSearchId,
        @Param("redir-target") Integer redirTargetId) {
    FlashScope flash = context.getFlashScope();
    Group group = context.getAttribute("group", Group.class);

    Event event = new Event();
    event.setGroupId(group.getId());//from   w ww  .  j  a v a 2  s  .  c o  m
    try {
        event.setDay(LocalDate.parse(day));
    } catch (Exception ex) {
    }

    if (event.getDay() == null) {
        flash.error("error.invalidDate");
        return Results.redirect(
                router.getReverseRoute(GoogleGroupController.class, "view", "groupId", group.getId()));
    }

    if (Validator.isEmpty(title)) {
        flash.error("error.invalidTitle");
        return Results.redirect(
                router.getReverseRoute(GoogleGroupController.class, "view", "groupId", group.getId()));
    }

    if (baseDB.event.find(group, event.getDay()) != null) {
        flash.error("google.group.alreadyEventForThisDate");
        return Results.redirect(
                router.getReverseRoute(GoogleGroupController.class, "view", "groupId", group.getId()));
    }

    event.setTitle(title);
    event.setDescription(Jsoup.clean(description == null ? "" : description, Whitelist.basic()));

    if (!baseDB.event.insert(event)) {
        flash.error("error.internalError");
        return Results.redirect(
                router.getReverseRoute(GoogleGroupController.class, "view", "groupId", group.getId()));
    }

    flash.success("google.group.eventInserted");
    if (redirSearchId != null) {
        return Results.redirect(router.getReverseRoute(GoogleSearchController.class, "search", "groupId",
                group.getId(), "searchId", redirSearchId));
    }
    if (redirTargetId != null) {
        return Results.redirect(router.getReverseRoute(GoogleTargetController.class, "target", "groupId",
                group.getId(), "targetId", redirTargetId));
    }

    return Results
            .redirect(router.getReverseRoute(GoogleGroupController.class, "view", "groupId", group.getId()));
}