Example usage for java.sql ResultSet getDouble

List of usage examples for java.sql ResultSet getDouble

Introduction

In this page you can find the example usage for java.sql ResultSet getDouble.

Prototype

double getDouble(String columnLabel) throws SQLException;

Source Link

Document

Retrieves the value of the designated column in the current row of this ResultSet object as a double in the Java programming language.

Usage

From source file:nl.tudelft.stocktrader.derby.DerbyCustomerDAO.java

public Holding getHolding(String userId, int holdingID) throws DAOException {
    if (logger.isDebugEnabled()) {
        logger.debug("MSSQLCustomerDAO.getHolding(String,int)\nUserID :" + userId + "\nOrder ID :" + holdingID);
    }/*from  w  w w  . ja v a  2  s  . c o m*/
    Holding holding = null;
    PreparedStatement selectHoldingNoLockStat = null;
    try {
        selectHoldingNoLockStat = sqlConnection.prepareStatement(SQL_SELECT_HOLDING_NOLOCK);
        selectHoldingNoLockStat.setInt(1, holdingID);
        selectHoldingNoLockStat.setString(2, userId);

        ResultSet rs = selectHoldingNoLockStat.executeQuery();
        if (rs.next()) {
            try {
                holding = new Holding(rs.getInt(1), holdingID, rs.getDouble(2), rs.getBigDecimal(3),
                        StockTraderUtility.convertToCalendar(rs.getDate(4)), rs.getString(5));
                return holding;
            } finally {
                try {
                    rs.close();
                } catch (SQLException e) {
                    logger.debug("", e);
                }
            }
        }
    } catch (SQLException e) {
        logger.debug("", e);
        throw new DAOException("Exception is thrown when selecting the holding entry for userID :" + userId
                + " and orderID :" + holdingID, e);

    } finally {
        if (selectHoldingNoLockStat != null) {
            try {
                selectHoldingNoLockStat.close();
            } catch (SQLException e) {
                logger.debug("", e);
            }
        }
    }
    return holding;
}

From source file:com.sfs.whichdoctor.analysis.AgedDebtorsAnalysisDAOImpl.java

/**
 * Perform a lookup for a period based on the type of financial transaction.
 *
 * @param analysis the analysis/*  ww  w  .  j a  va2s.c o m*/
 * @param period the period
 * @param type the type
 * @return the collection
 */
@SuppressWarnings("unchecked")
private Collection<AgedDebtorsRecord> performLookup(final AgedDebtorsAnalysisBean analysis,
        final AgedDebtorsPeriod period, final String type) {

    Collection<AgedDebtorsRecord> records = new ArrayList<AgedDebtorsRecord>();

    String sqlEntry = "agedDebtors/debit";
    String personField = "invoice.PersonId";
    String organisationField = "invoice.OrganisationId";

    if (StringUtils.equalsIgnoreCase(type, "credit")) {
        sqlEntry = "agedDebtors/credit";
        personField = "credit.PersonId";
        organisationField = "credit.OrganisationId";
    }
    if (StringUtils.equalsIgnoreCase(type, "refund")) {
        sqlEntry = "agedDebtors/refund";
        personField = "credit.PersonId";
        organisationField = "credit.OrganisationId";
    }
    if (StringUtils.equalsIgnoreCase(type, "receipt")) {
        sqlEntry = "agedDebtors/receipt";
        personField = "payment.PersonId";
        organisationField = "payment.OrganisationId";
    }

    StringBuffer sql = new StringBuffer();
    sql.append(this.getSQL().getValue(sqlEntry));
    sql.append(buildSqlWhere(analysis, personField, organisationField, true));
    sql.append(" GROUP BY ");
    sql.append(personField);
    sql.append(", ");
    sql.append(organisationField);

    if (dataLogger.isDebugEnabled()) {
        dataLogger.debug("SQL: " + sql.toString());
        dataLogger.debug("Start date: " + period.getStartDate());
        dataLogger.debug("End date: " + period.getEndDate());
    }

    try {
        records = this.getJdbcTemplateReader().query(sql.toString(),
                new Object[] { period.getEndDate(), period.getStartDate() }, new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        AgedDebtorsRecord record = new AgedDebtorsRecord();
                        record.setPersonGUID(rs.getInt("PersonId"));
                        record.setOrganisationGUID(rs.getInt("OrganisationId"));
                        record.setOutstandingDebitValue(rs.getDouble("Value"));

                        return record;
                    }
                });

    } catch (IncorrectResultSizeDataAccessException ie) {
        // No results found for this search
        dataLogger.debug("No results found for this search: " + ie.getMessage());
    }
    return records;
}

From source file:gov.nih.nci.cadsr.persist.de.Data_Elements_Mgr.java

/**
 * Returns DE based on the de_IDSEQ//from  w  ww  .j  a  v  a2s  . co  m
 * 
 * @param de_IDSEQ
 * @param conn
 * @return
 * @throws DBException
 */
public DeVO getDe(String de_IDSEQ, Connection conn) throws DBException {
    PreparedStatement stmt = null;
    ResultSet rs = null;
    DeVO deVO = null;
    try {
        String sql = "select * from data_elements_view where de_idseq = ?";
        stmt = conn.prepareStatement(sql);
        stmt.setString(1, de_IDSEQ);
        rs = stmt.executeQuery();
        while (rs.next()) {
            deVO = new DeVO();
            deVO.setDe_IDSEQ(rs.getString("DE_IDSEQ"));
            deVO.setVersion(rs.getDouble("VERSION"));
            deVO.setConte_IDSEQ(rs.getString("CONTE_IDSEQ"));
            deVO.setPrefferred_name(rs.getString("PREFERRED_NAME"));
            deVO.setVd_IDSEQ(rs.getString("VD_IDSEQ"));
            deVO.setDec_IDSEQ(rs.getString("DEC_IDSEQ"));
            deVO.setPrefferred_def(rs.getString("PREFERRED_DEFINITION"));
            deVO.setAsl_name(rs.getString("ASL_NAME"));
            deVO.setLong_name(rs.getString("LONG_NAME"));
            deVO.setLastest_version_ind(rs.getString("LATEST_VERSION_IND"));
            deVO.setDeleted_ind(rs.getString("DELETED_IND"));
            deVO.setDate_created(rs.getTimestamp("DATE_CREATED"));
            deVO.setBegin_date(rs.getTimestamp("BEGIN_DATE"));
            deVO.setCreated_by(rs.getString("CREATED_BY"));
            deVO.setEnd_date(rs.getTimestamp("END_DATE"));
            deVO.setDate_modified(rs.getTimestamp("DATE_MODIFIED"));
            deVO.setModified_by(rs.getString("MODIFIED_BY"));
            deVO.setChange_note(rs.getString("CHANGE_NOTE"));
        }
    } catch (SQLException e) {
        logger.error(DBException.DEFAULT_ERROR_MSG + " in getDe() method of Data_Elements_Mgr class " + e);
        throw new DBException("API_DE_000");
    } finally {
        try {
            rs = SQLHelper.closeResultSet(rs);
            stmt = SQLHelper.closePreparedStatement(stmt);
        } catch (Exception e) {
        }
    }
    return deVO;
}

From source file:com.oltpbenchmark.benchmarks.seats.SEATSProfile.java

private final void loadConfigProfile(ResultSet vt) throws SQLException {
    boolean adv = vt.next();
    assert (adv);
    int col = 1;//  w  ww  . j  a va 2  s . c  o  m
    this.scale_factor = vt.getDouble(col++);
    JSONUtil.fromJSONString(this.airport_max_customer_id, vt.getString(col++));
    this.flight_start_date.setTime(vt.getTimestamp(col++).getTime());
    this.flight_upcoming_date = vt.getTimestamp(col++);
    this.flight_past_days = vt.getLong(col++);
    this.flight_future_days = vt.getLong(col++);
    this.flight_upcoming_offset = vt.getLong(col++);
    this.reservation_upcoming_offset = vt.getLong(col++);
    this.num_reservations = vt.getLong(col++);
    if (LOG.isDebugEnabled())
        LOG.debug(String.format("Loaded %s data", SEATSConstants.TABLENAME_CONFIG_PROFILE));
}

From source file:co.nubetech.apache.hadoop.FloatSplitter.java

public List<InputSplit> split(Configuration conf, ResultSet results, String colName) throws SQLException {

    LOG.warn("Generating splits for a floating-point index column. Due to the");
    LOG.warn("imprecise representation of floating-point values in Java, this");
    LOG.warn("may result in an incomplete import.");
    LOG.warn("You are strongly encouraged to choose an integral split column.");

    List<InputSplit> splits = new ArrayList<InputSplit>();

    if (results.getString(1) == null && results.getString(2) == null) {
        // Range is null to null. Return a null split accordingly.
        splits.add(/*from  w ww.j  a  v  a 2s .c  o m*/
                new DataDrivenDBInputFormat.DataDrivenDBInputSplit(colName + " IS NULL", colName + " IS NULL"));
        return splits;
    }

    double minVal = results.getDouble(1);
    double maxVal = results.getDouble(2);

    // Use this as a hint. May need an extra task if the size doesn't
    // divide cleanly.
    int numSplits = conf.getInt(MRJobConfig.NUM_MAPS, 1);
    double splitSize = (maxVal - minVal) / (double) numSplits;

    if (splitSize < MIN_INCREMENT) {
        splitSize = MIN_INCREMENT;
    }

    String lowClausePrefix = colName + " >= ";
    String highClausePrefix = colName + " < ";

    double curLower = minVal;
    double curUpper = curLower + splitSize;

    while (curUpper < maxVal) {
        splits.add(new DataDrivenDBInputFormat.DataDrivenDBInputSplit(
                lowClausePrefix + Double.toString(curLower), highClausePrefix + Double.toString(curUpper)));

        curLower = curUpper;
        curUpper += splitSize;
    }

    // Catch any overage and create the closed interval for the last split.
    if (curLower <= maxVal || splits.size() == 1) {
        splits.add(new DataDrivenDBInputFormat.DataDrivenDBInputSplit(
                lowClausePrefix + Double.toString(curUpper), colName + " <= " + Double.toString(maxVal)));
    }

    if (results.getString(1) == null || results.getString(2) == null) {
        // At least one extrema is null; add a null split.
        splits.add(
                new DataDrivenDBInputFormat.DataDrivenDBInputSplit(colName + " IS NULL", colName + " IS NULL"));
    }

    return splits;
}

From source file:com.cloudera.sqoop.mapreduce.db.FloatSplitter.java

public List<InputSplit> split(Configuration conf, ResultSet results, String colName) throws SQLException {

    LOG.warn("Generating splits for a floating-point index column. Due to the");
    LOG.warn("imprecise representation of floating-point values in Java, this");
    LOG.warn("may result in an incomplete import.");
    LOG.warn("You are strongly encouraged to choose an integral split column.");

    List<InputSplit> splits = new ArrayList<InputSplit>();

    if (results.getString(1) == null && results.getString(2) == null) {
        // Range is null to null. Return a null split accordingly.
        splits.add(//from   w  w  w  . j a v  a  2 s. com
                new DataDrivenDBInputFormat.DataDrivenDBInputSplit(colName + " IS NULL", colName + " IS NULL"));
        return splits;
    }

    double minVal = results.getDouble(1);
    double maxVal = results.getDouble(2);

    // Use this as a hint. May need an extra task if the size doesn't
    // divide cleanly.
    int numSplits = ConfigurationHelper.getConfNumMaps(conf);
    double splitSize = (maxVal - minVal) / (double) numSplits;

    if (splitSize < MIN_INCREMENT) {
        splitSize = MIN_INCREMENT;
    }

    String lowClausePrefix = colName + " >= ";
    String highClausePrefix = colName + " < ";

    double curLower = minVal;
    double curUpper = curLower + splitSize;

    while (curUpper < maxVal) {
        splits.add(new DataDrivenDBInputFormat.DataDrivenDBInputSplit(
                lowClausePrefix + Double.toString(curLower), highClausePrefix + Double.toString(curUpper)));

        curLower = curUpper;
        curUpper += splitSize;
    }

    // Catch any overage and create the closed interval for the last split.
    if (curLower <= maxVal || splits.size() == 1) {
        splits.add(new DataDrivenDBInputFormat.DataDrivenDBInputSplit(
                lowClausePrefix + Double.toString(curUpper), colName + " <= " + Double.toString(maxVal)));
    }

    if (results.getString(1) == null || results.getString(2) == null) {
        // At least one extrema is null; add a null split.
        splits.add(
                new DataDrivenDBInputFormat.DataDrivenDBInputSplit(colName + " IS NULL", colName + " IS NULL"));
    }

    return splits;
}

From source file:com.carfinance.module.vehiclemanage.domain.VehicleInfoRowMapper.java

public VehicleInfo mapRow(ResultSet rs, int arg1) throws SQLException {
    VehicleInfo vehicleInfo = new VehicleInfo();

    vehicleInfo.setId(rs.getLong("id"));
    vehicleInfo.setBrand(rs.getString("brand"));
    vehicleInfo.setModel(rs.getString("model"));
    vehicleInfo.setColor(rs.getString("color"));
    vehicleInfo.setCarframe_no(rs.getString("carframe_no"));
    vehicleInfo.setEngine_no(rs.getString("engine_no"));
    vehicleInfo.setBuy_at(rs.getDate("buy_at"));
    vehicleInfo.setSupplier(rs.getString("supplier"));
    vehicleInfo.setLicense_plate(rs.getString("license_plate"));
    vehicleInfo.setCard_at(rs.getDate("card_at"));
    vehicleInfo.setLimited_at(rs.getDate("limited_at"));
    vehicleInfo.setGuide_price(rs.getDouble("guide_price"));
    vehicleInfo.setVehicle_price(rs.getDouble("vehicle_price"));
    vehicleInfo.setVehicle_tax(rs.getDouble("vehicle_tax"));
    vehicleInfo.setInsurance_company(rs.getString("insurance_company"));
    vehicleInfo.setStrong_insurance(rs.getDouble("strong_insurance"));
    vehicleInfo.setStrong_insurance_expire_at(rs.getDate("strong_insurance_expire_at"));
    vehicleInfo.setVehicle_vessel_tax(rs.getDouble("vehicle_vessel_tax"));
    vehicleInfo.setBusiness_insurance(rs.getDouble("business_insurance"));
    vehicleInfo.setBusiness_insurance_expire_at(rs.getDate("business_insurance_expire_at"));
    vehicleInfo.setKm(rs.getLong("km"));
    vehicleInfo.setMaintian_on_km(rs.getLong("maintian_on_km"));
    vehicleInfo.setGps(rs.getString("gps"));
    vehicleInfo.setCurrent_city(rs.getLong("current_city"));
    vehicleInfo.setCurrent_shop(rs.getLong("current_shop"));
    vehicleInfo.setLease_status(rs.getString("lease_status"));
    vehicleInfo.setPeccancy_status(rs.getString("peccancy_status"));
    vehicleInfo.setArchive_no(rs.getString("archive_no"));
    vehicleInfo.setInventory_no(rs.getString("inventory_no"));
    vehicleInfo.setRegistry_certificate(rs.getString("registry_certificate"));
    vehicleInfo.setCertificate_direction(rs.getString("certificate_direction"));
    vehicleInfo.setLoan_bank(rs.getString("loan_bank"));
    vehicleInfo.setConsistency_cer(rs.getString("consistency_cer"));
    vehicleInfo.setCheck_list(rs.getString("check_list"));
    vehicleInfo.setDuty_paid_proof(rs.getString("duty_paid_proof"));
    vehicleInfo.setRecord(rs.getString("record"));
    vehicleInfo.setRemark(rs.getString("remark"));
    vehicleInfo.setCreate_by(rs.getLong("create_by"));
    vehicleInfo.setCreate_at(rs.getDate("create_at"));
    vehicleInfo.setCreate_by(rs.getLong("update_by"));
    vehicleInfo.setCreate_at(rs.getDate("update_at"));
    vehicleInfo.setOriginal_org(rs.getLong("original_org"));
    vehicleInfo.setNext_main_km(rs.getLong("next_main_km"));

    try {/*w w w  .j  av a 2  s .co m*/
        vehicleInfo.setFinancing_rent_company(rs.getString("financing_rent_company"));
    } catch (Exception e) {
    }
    try {
        vehicleInfo.setFinancing_rent_price(rs.getDouble("financing_rent_price"));
    } catch (Exception e) {
    }
    try {
        vehicleInfo.setBail(rs.getDouble("bail"));
    } catch (Exception e) {
    }
    try {
        vehicleInfo.setMonthly_payment(rs.getDouble("monthly_payment"));
    } catch (Exception e) {
    }

    try {
        vehicleInfo.setEtc(rs.getString("etc"));
    } catch (Exception e) {
    }
    try {
        vehicleInfo.setEtc_money(rs.getDouble("etc_money"));
    } catch (Exception e) {
    }
    try {
        vehicleInfo.setOil_percent(rs.getInt("oil_percent"));
    } catch (Exception e) {
    }

    try {
        vehicleInfo.setDaily_price(rs.getDouble("daily_price"));
    } catch (Exception e) {
    }

    return vehicleInfo;
}

From source file:com.arcane.dao.Impl.PatternDaoImpl.java

@Override
public List<TrippleBottom> getTrippleBottomList() {
    //return all triple bottom patterns
    LOG.info("Returning all triple bottom patterns");
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    String sql = "SELECT * from tripplebottom";
    List<TrippleBottom> listPattern = jdbcTemplate.query(sql, new RowMapper<TrippleBottom>() {

        @Override//w w  w . ja va  2 s.co m
        public TrippleBottom mapRow(ResultSet rs, int rowNumber) throws SQLException {
            TrippleBottom pattern = new TrippleBottom();
            pattern.setId(rs.getInt("id"));
            pattern.setName(rs.getString("name"));
            pattern.setFirstMin(rs.getString("firstMin"));
            pattern.setSecondMin(rs.getString("secondMin"));
            pattern.setThirdMin(rs.getString("thirdMin"));
            pattern.setBreakPoint(rs.getString("breakPoint"));
            pattern.setFirstMinPrice(rs.getDouble("fistMinPrice"));
            pattern.setSecondMinPrice(rs.getDouble("secondMinPrice"));
            pattern.setThirdMinPrice(rs.getDouble("thirdMinPrice"));
            pattern.setBreakPointPrice(rs.getDouble("breakPointPrice"));
            pattern.setFirstMax(rs.getString("firstMax"));
            pattern.setFirstMaxPrice(rs.getDouble("firstMaxPrice"));
            pattern.setSecondMax(rs.getString("secondMax"));
            pattern.setSecondMaxPrice(rs.getDouble("secondMaxPrice"));
            return pattern;
        }

    });
    return listPattern;
}

From source file:com.concursive.connect.web.modules.productcatalog.dao.Product.java

/**
 * Description of the Method/*from   ww  w  .  j ava  2 s . com*/
 *
 * @param rs Description of the Parameter
 * @throws SQLException Description of the Exception
 */
public void buildRecord(ResultSet rs) throws SQLException {
    id = rs.getInt("product_id");
    name = rs.getString("product_name");
    priceDescription = rs.getString("price_description");
    details = rs.getString("details");
    basePrice = rs.getDouble("base_price");
    smallImage = rs.getString("small_image");
    largeImage = rs.getString("large_image");
    enabled = rs.getBoolean("enabled");
    contactInformationRequired = rs.getBoolean("contact_information_required");
    billingAddressRequired = rs.getBoolean("billing_address_required");
    shippingAddressRequired = rs.getBoolean("shipping_address_required");
    paymentRequired = rs.getBoolean("payment_required");
    orderDescription = rs.getString("order_description");
    sku = rs.getString("product_sku");
    showInCatalog = rs.getBoolean("show_in_catalog");
    cartEnabled = rs.getBoolean("cart_enabled");
    actionText = rs.getString("action_text");
}

From source file:eu.udig.tools.jgrass.geopaparazzi.ImportGeopaparazziFolderWizard.java

private void gpsLogToShapefiles(Connection connection, File outputFolderFile, IProgressMonitor pm)
        throws Exception {
    File outputLinesShapeFile = new File(outputFolderFile, "gpslines.shp");

    Statement statement = connection.createStatement();
    statement.setQueryTimeout(30); // set timeout to 30 sec.

    List<GpsLog> logsList = new ArrayList<ImportGeopaparazziFolderWizard.GpsLog>();
    // first get the logs
    ResultSet rs = statement.executeQuery("select _id, startts, endts, text from gpslogs");
    while (rs.next()) {
        long id = rs.getLong("_id");

        String startDateTimeString = rs.getString("startts");
        String endDateTimeString = rs.getString("endts");
        String text = rs.getString("text");

        GpsLog log = new GpsLog();
        log.id = id;/* www .  j a v a2  s .c  o m*/
        log.startTime = startDateTimeString;
        log.endTime = endDateTimeString;
        log.text = text;
        logsList.add(log);
    }

    statement.close();

    try {
        // then the log data
        for (GpsLog log : logsList) {
            long logId = log.id;
            String query = "select lat, lon, altim, ts from gpslog_data where logid = " + logId
                    + " order by ts";

            Statement newStatement = connection.createStatement();
            newStatement.setQueryTimeout(30);
            ResultSet result = newStatement.executeQuery(query);

            while (result.next()) {
                double lat = result.getDouble("lat");
                double lon = result.getDouble("lon");
                double altim = result.getDouble("altim");
                String dateTimeString = result.getString("ts");

                GpsPoint gPoint = new GpsPoint();
                gPoint.lon = lon;
                gPoint.lat = lat;
                gPoint.altim = altim;
                gPoint.utctime = dateTimeString;
                log.points.add(gPoint);

            }

            newStatement.close();

        }
    } catch (Exception e) {
        e.printStackTrace();
        String message = "An error occurred while reading the gps logs.";
        ExceptionDetailsDialog.openError(null, message, IStatus.ERROR, JGrassToolsPlugin.PLUGIN_ID, e);
        return;
    }

    /*
     * create the lines shapefile
     */
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("geopaparazzinotes");
    b.setCRS(mapCrs);
    b.add("the_geom", MultiLineString.class);
    b.add("STARTDATE", String.class);
    b.add("ENDDATE", String.class);
    b.add("DESCR", String.class);
    SimpleFeatureType featureType = b.buildFeatureType();

    try {
        MathTransform transform = CRS.findMathTransform(DefaultGeographicCRS.WGS84, mapCrs);
        pm.beginTask("Import gps to lines...", logsList.size());
        FeatureCollection<SimpleFeatureType, SimpleFeature> newCollection = FeatureCollections.newCollection();
        int index = 0;
        for (GpsLog log : logsList) {
            List<GpsPoint> points = log.points;

            List<Coordinate> coordList = new ArrayList<Coordinate>();
            String startDate = log.startTime;
            String endDate = log.endTime;
            for (GpsPoint gpsPoint : points) {
                Coordinate c = new Coordinate(gpsPoint.lon, gpsPoint.lat);
                coordList.add(c);
            }
            Coordinate[] coordArray = (Coordinate[]) coordList.toArray(new Coordinate[coordList.size()]);
            if (coordArray.length < 2) {
                continue;
            }
            LineString lineString = gF.createLineString(coordArray);
            LineString reprojectLineString = (LineString) JTS.transform(lineString, transform);
            MultiLineString multiLineString = gF
                    .createMultiLineString(new LineString[] { reprojectLineString });

            SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
            Object[] values = new Object[] { multiLineString, startDate, endDate, log.text };
            builder.addAll(values);
            SimpleFeature feature = builder.buildFeature(featureType.getTypeName() + "." + index++);

            newCollection.add(feature);
            pm.worked(1);
        }
        pm.done();

        ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();
        Map<String, Serializable> params = new HashMap<String, Serializable>();
        params.put("url", outputLinesShapeFile.toURI().toURL());
        params.put("create spatial index", Boolean.TRUE);
        ShapefileDataStore dStore = (ShapefileDataStore) factory.createNewDataStore(params);
        dStore.createSchema(featureType);
        dStore.forceSchemaCRS(mapCrs);

        JGrassToolsPlugin.getDefault().writeToShapefile(dStore, newCollection);

        JGrassToolsPlugin.getDefault().addServiceToCatalogAndMap(outputLinesShapeFile.getAbsolutePath(), true,
                true, new NullProgressMonitor());

    } catch (Exception e1) {
        JGrassToolsPlugin.log(e1.getLocalizedMessage(), e1);
        e1.printStackTrace();
    }
    /*
     * create the points shapefile
     */

    File outputPointsShapeFile = new File(outputFolderFile, "gpspoints.shp");

    b = new SimpleFeatureTypeBuilder();
    b.setName("geopaparazzinotes");
    b.setCRS(mapCrs);
    b.add("the_geom", Point.class);
    b.add("ALTIMETRY", String.class);
    b.add("DATE", String.class);
    featureType = b.buildFeatureType();

    try {
        MathTransform transform = CRS.findMathTransform(DefaultGeographicCRS.WGS84, mapCrs);

        pm.beginTask("Import gps to points...", logsList.size());
        FeatureCollection<SimpleFeatureType, SimpleFeature> newCollection = FeatureCollections.newCollection();
        int index = 0;
        for (GpsLog log : logsList) {
            List<GpsPoint> gpsPointList = log.points;
            for (GpsPoint gpsPoint : gpsPointList) {
                Coordinate c = new Coordinate(gpsPoint.lon, gpsPoint.lat);
                Point point = gF.createPoint(c);

                Point reprojectPoint = (Point) JTS.transform(point, transform);
                Object[] values = new Object[] { reprojectPoint, String.valueOf(gpsPoint.altim),
                        gpsPoint.utctime };

                SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
                builder.addAll(values);
                SimpleFeature feature = builder.buildFeature(featureType.getTypeName() + "." + index++);
                newCollection.add(feature);
            }
            pm.worked(1);
        }
        pm.done();

        ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();
        Map<String, Serializable> params = new HashMap<String, Serializable>();
        params.put("url", outputPointsShapeFile.toURI().toURL());
        params.put("create spatial index", Boolean.TRUE);
        ShapefileDataStore dStore = (ShapefileDataStore) factory.createNewDataStore(params);
        dStore.createSchema(featureType);
        dStore.forceSchemaCRS(mapCrs);

        JGrassToolsPlugin.getDefault().writeToShapefile(dStore, newCollection);

        JGrassToolsPlugin.getDefault().addServiceToCatalogAndMap(outputPointsShapeFile.getAbsolutePath(), true,
                true, new NullProgressMonitor());

    } catch (Exception e1) {
        JGrassToolsPlugin.log(e1.getLocalizedMessage(), e1);
        e1.printStackTrace();
    }
}