Package it.geosolutions.filesystemmonitor.monitor

Examples of it.geosolutions.filesystemmonitor.monitor.FileSystemEvent


    public static File execute(Action a, File file) throws ActionException {

    Queue<FileSystemEvent> inQueue = new LinkedList<FileSystemEvent>();
        if(file != null)
            inQueue.add(new FileSystemEvent(file, FileSystemEventType.FILE_ADDED));

        Queue<FileSystemEvent> outQueue = a.execute(inQueue);
        switch(outQueue.size()) {
            case 0:
                return null;
View Full Code Here


    public static Collection<File> executeMultiReturn(Action a, File file) throws ActionException {

    Queue<FileSystemEvent> inQueue = new LinkedList<FileSystemEvent>();
        if(file != null)
            inQueue.add(new FileSystemEvent(file, FileSystemEventType.FILE_ADDED));

        List<File> ret = new ArrayList<File>();

        Queue<FileSystemEvent> outQueue = a.execute(inQueue);
        for (FileSystemEvent ev : outQueue) {
View Full Code Here



        final Queue<FileSystemEvent> ret = new LinkedList<FileSystemEvent>();
        while (!events.isEmpty()) {
            final FileSystemEvent ev = events.remove();

            try {
                if (ev != null) {
                    if (LOGGER.isTraceEnabled()) {
                        LOGGER.trace("PublishingAction.execute(): working on incoming event: " + ev.getSource());
                    }

                    File xmlFile = ev.getSource(); // this is the input xml file
                    executeInternal(xmlFile);
                    ret.add(new FileSystemEvent(xmlFile, FileSystemEventType.FILE_ADDED));

                } else {
                    LOGGER.error("PublishingAction.execute(): Encountered a NULL event: SKIPPING...");
                    continue;
                }
View Full Code Here

//        initComponents(properties);

        final Queue<FileSystemEvent> ret = new LinkedList<FileSystemEvent>();

        while (!events.isEmpty()) {
            final FileSystemEvent ev = events.remove();

            try {
                if (ev != null) {
                    if (LOGGER.isTraceEnabled()) {
                        LOGGER.trace("Processing incoming event: " + ev.getSource());
                    }
                    File xmlFile = ev.getSource(); // this is the input xml file

                    /**
                     * *************************
                     * The reprocessing flow will recompute statistics and charts. it is needed when data in the staging area are
                     * changed; i.e.: - vector data are edited; - chart scripts are modified or inserted; - new statistics are
                     * added. Each doXXX methos manages one of this case
                     */
                    ReprocessRequest request = RequestReader.load(xmlFile);
                    if (request == null) {
                        throw new ActionException(this, "Could not parse input file:" + xmlFile.getName());
                    }

                    if (request instanceof ReprocessLayerRequest) {
                        reprocessLayer((ReprocessLayerRequest) request);

                    } else if (request instanceof ReprocessChartRequest) {
                        reprocessChart((ReprocessChartRequest) request);

                    } else if (request instanceof ReprocessStatsRequest) {
                        reprocessStats((ReprocessStatsRequest) request);

                    }

                    ret.add(new FileSystemEvent(xmlFile, FileSystemEventType.FILE_ADDED));

                } else {
                    LOGGER.error("Encountered a null event: skipping event");
                    continue;
                }
View Full Code Here

    rc.setRastery1(51);
    rc.setWorkingDirectory("src/test/resources");

    Queue<EventObject> queue = new LinkedBlockingQueue<EventObject>();
    File inputFile = new File("src/test/resources/cell_pol_roi2.shp");
    queue.add(new FileSystemEvent(inputFile, FileSystemEventType.FILE_ADDED));

    RasterizeAction action = new RasterizeAction(rc);
    action.execute(queue);
  }
View Full Code Here

    GDALRasterizeAction action = new GDALRasterizeAction(rc);
        action.setTempDir(getTempDir());

    Queue<EventObject> queue = new LinkedBlockingQueue<EventObject>();
    queue.add(new FileSystemEvent(inputFile, FileSystemEventType.FILE_ADDED));
    action.execute(queue);
  }
View Full Code Here

          String layername = conf.getLayername();
         
          if (layername==null) throw new ActionException(this, "the layer name cannot be empty");
          if (rasterpixelheight==0.0d || rasterpixelwidth==0.0d) throw new ActionException(this, "the raster pixel size is wrong");
         
          FileSystemEvent fileEvent=(FileSystemEvent)ev;
          File file = fileEvent.getSource();
          FileDataStore store = null;
          // this action can be used also getting a simpleFeatureCollection from another resource than a file
          // in this case the features field is not null but it is filled externally
                    if (features==null) {
                       
              store = FileDataStoreFinder.getDataStore(file);
              if (store==null) throw new ActionException(this, "the layer "+file.getCanonicalPath()+" cannot be found. Skip execution.");
                        FeatureSource featureSource = store.getFeatureSource();
                        SimpleFeatureType schema = (SimpleFeatureType) featureSource.getSchema();
                        Query query = new Query( schema.getTypeName(), Filter.INCLUDE );
                        query.setCoordinateSystem(CRS.decode("EPSG:4326", true));
                        features = (SimpleFeatureCollection) featureSource.getFeatures( query );
                       
          //    features = (SimpleFeatureCollection) featureSource.getFeatures();
                    }
                   
          //CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84;
          CoordinateReferenceSystem crs = features.getSchema().getCoordinateReferenceSystem();
          ReferencedEnvelope bounds = new ReferencedEnvelope(rasterx0, rasterx1, rastery0, rastery1,crs);

              Dimension gridDim = new Dimension(rasterpixelwidth, rasterpixelheight);

              String covName = layername;
              ProgressListener monitor = null;

              GridCoverage2D cov = VectorToRasterProcess.process(features, rasterAttribName, gridDim, bounds, covName, monitor);
              LOGGER.debug("CRS :"+cov.getCoordinateReferenceSystem().toWKT());
//              System.out.println(cov.toString());

//          Map<String, Object> attribute = new HashMap<String, Object>();
//          attribute.put("rasterAttribName", rasterAttribName);
//          if (rasterCqlFilter!=null) attribute.put("rasterCqlFilter", rasterCqlFilter);
          File tmpTiff = null;
          if (conf.getFilename()!=null)
              tmpTiff = new File(conf.getWorkingDirectory(),conf.getFilename());
          else 
              tmpTiff =   new File(conf.getWorkingDirectory(),"testcov.tif");
          GeoTiffWriter writer = null;
          try {
                        writer = new GeoTiffWriter(tmpTiff);
                       
            if (height>0 && width>0) {
              GeoTiffWriteParams params = new GeoTiffWriteParams();
             
                            params.setTilingMode(TIFFImageWriteParam.MODE_EXPLICIT);
                            params.setTiling(conf.getRetileH(), conf.getRetileW());
                            ParameterValue<GeoToolsWriteParams> value = GeoTiffFormat.GEOTOOLS_WRITE_PARAMS.createValue();
                            value.setValue(params);
                            writer.write(cov, new GeneralParameterValue[]{value});
                        }
                        else
                          writer.write(cov, null );
          } catch (IOException e) {
            // TODO Auto-generated catch block
            LOGGER.error("An exception was raised executing the RasterizeAction",e);
            throw new ActionException(this,"An exception was raised executing the RasterizeAction");
                    }
                    finally {
                    //  if (writer!=null) writer.dispose();
                  FileSystemEvent fileSystemInsertEvent = new FileSystemEvent(tmpTiff, FileSystemEventType.FILE_ADDED);
              ret.add(fileSystemInsertEvent);
              if (store!=null) store.dispose();
                    }
         
          // add the event to the return
View Full Code Here

        if ((ev = events.remove()) != null) {
          if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("GeostoreAction.execute(): working on incoming event: "
                + ev.getSource());
          }
          FileSystemEvent fileEvent=(FileSystemEvent)ev;
          File inputFile = fileEvent.getSource();

                    File outFile = null;
          LOGGER.debug("Running "+operation.name());
          switch(operation) {
            case SEARCH:
              outFile = doSearch(inputFile);
              break;
            case INSERT:
              outFile = doInsert(inputFile);
              break;
                        case UPDATEDATA:
                            outFile = this.doUpdateData(inputFile);
                            break;
                        case DELETE:
                            this.doDelete(inputFile);
                            break;
            default:
                            throw new ActionException(this, "GeostoreAction.execute(): unknown operation " + operation);
            }

                    if(outFile != null) {
                        FileSystemEvent fileSystemInsertEvent = new FileSystemEvent(outFile, FileSystemEventType.FILE_ADDED);
                        ret.add(fileSystemInsertEvent);
                    }

        } else {
            LOGGER.error("GeostoreAction.execute(): Encountered a NULL event: SKIPPING...");
View Full Code Here

          String layername = conf.getLayername();
         
          if (layername==null) throw new ActionException(this, "the layer name cannot be empty");
          if (rasterpixelheight==0.0d || rasterpixelwidth==0.0d) throw new ActionException(this, "the raster pixel size is wrong");
         
          FileSystemEvent fileEvent=(FileSystemEvent)ev;
          File file = fileEvent.getSource();
          FileDataStore store = null;
          // this action can be used also getting a simpleFeatureCollection from another resource than a file
          // in this case the features field is not null but it is filled externally
                    if (features==null) {
                       
              store = FileDataStoreFinder.getDataStore(file);
              if (store==null) throw new ActionException(this, "the layer "+file.getCanonicalPath()+" cannot be found. Skip execution.");
                        FeatureSource featureSource = store.getFeatureSource();
                        SimpleFeatureType schema = (SimpleFeatureType) featureSource.getSchema();
                        Query query = new Query( schema.getTypeName(), Filter.INCLUDE );
                        query.setCoordinateSystem(CRS.decode("EPSG:4326", true));
                        features = (SimpleFeatureCollection) featureSource.getFeatures( query );
                       
          //    features = (SimpleFeatureCollection) featureSource.getFeatures();
                    }
                   
          //CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84;
          CoordinateReferenceSystem crs = features.getSchema().getCoordinateReferenceSystem();
          ReferencedEnvelope bounds = new ReferencedEnvelope(rasterx0, rasterx1, rastery0, rastery1,crs);

              Dimension gridDim = new Dimension(rasterpixelwidth, rasterpixelheight);

              String covName = layername;
              ProgressListener monitor = null;

              GridCoverage2D cov = VectorToRasterProcess.process(features, rasterAttribName, gridDim, bounds, covName, monitor);
              LOGGER.debug("CRS :"+cov.getCoordinateReferenceSystem().toWKT());
//              System.out.println(cov.toString());

//          Map<String, Object> attribute = new HashMap<String, Object>();
//          attribute.put("rasterAttribName", rasterAttribName);
//          if (rasterCqlFilter!=null) attribute.put("rasterCqlFilter", rasterCqlFilter);
          File tmpTiff = null;
          if (conf.getFilename()!=null)
              tmpTiff = new File(conf.getWorkingDirectory(),conf.getFilename());
          else 
              tmpTiff =   new File(conf.getWorkingDirectory(),"testcov.tif");
          GeoTiffWriter writer = null;
          try {
                        writer = new GeoTiffWriter(tmpTiff);
                       
            if (height>0 && width>0) {
              GeoTiffWriteParams params = new GeoTiffWriteParams();
             
                            params.setTilingMode(TIFFImageWriteParam.MODE_EXPLICIT);
                            params.setTiling(conf.getRetileH(), conf.getRetileW());
                            ParameterValue<GeoToolsWriteParams> value = GeoTiffFormat.GEOTOOLS_WRITE_PARAMS.createValue();
                            value.setValue(params);
                            writer.write(cov, new GeneralParameterValue[]{value});
                        }
                        else
                          writer.write(cov, null );
          } catch (IOException e) {
            // TODO Auto-generated catch block
            LOGGER.error("An exception was raised executing the RasterizeAction",e);
            throw new ActionException(this,"An exception was raised executing the RasterizeAction");
                    }
                    finally {
                    //  if (writer!=null) writer.dispose();
                  FileSystemEvent fileSystemInsertEvent = new FileSystemEvent(tmpTiff, FileSystemEventType.FILE_ADDED);
              ret.add(fileSystemInsertEvent);
              if (store!=null) store.dispose();
                    }
         
          // add the event to the return
View Full Code Here

        // control if directories and PostGISUtils exist
        basicChecks();


        while (!events.isEmpty()) {
            final FileSystemEvent ev = events.remove();

            try {
                if (ev != null) {
                    if (LOGGER.isTraceEnabled()) {
                        LOGGER.trace("Processing incoming event: " + ev.getSource());
                    }

                    File inputZipFile = ev.getSource(); // this is the input zip file
                    File out = execute(inputZipFile);
                    ret.add(new FileSystemEvent(out, FileSystemEventType.FILE_ADDED));

                } else {
                    LOGGER.error("NULL event: skipping...");
                    continue;
                }
View Full Code Here

TOP

Related Classes of it.geosolutions.filesystemmonitor.monitor.FileSystemEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.