private void saveLayer(Layer layer, File dir, DataSource dataSource, String ext)
      throws Exception {
    String name = FileUtil.getFileNameFromLayerName(layer.getName());
    // remove extension if any (ex. for layer image.png, will remove png
    int dotPos = name.indexOf(".");
    if (dotPos > 0) name = name.substring(0, dotPos);
    File fileName = FileUtil.addExtensionIfNone(new File(name), ext);
    String path = new File(dir, fileName.getName()).getAbsolutePath();

    DriverProperties dp = new DriverProperties();
    dp.set("File", path);
    dataSource.setProperties(dp);

    DataSourceQuery dsq = new DataSourceQuery(dataSource, path, path);
    layer.setDataSourceQuery(dsq).setFeatureCollectionModified(false);

    dataSource
        .getConnection()
        .executeUpdate("", layer.getFeatureCollectionWrapper(), new DummyTaskMonitor());
  }
示例#2
0
 private static void saveJMLfile(FeatureCollection fc, String filename) throws Exception {
   JMLWriter writer = new JMLWriter();
   DriverProperties dp = new DriverProperties();
   dp.set("File", filename);
   writer.write(fc, dp);
 }
 private DriverProperties getDriverProperties() {
   DriverProperties properties = new DriverProperties();
   properties.putAll(getProperties());
   return properties;
 }