Package it.geosolutions.geostore.core.model

Examples of it.geosolutions.geostore.core.model.Resource


        //
        // ****************************************

        LOGGER.info("Searching source Layer " + layerName);

        Resource srcLayer = srcGeostore.searchLayer(layerName);
        if(srcLayer == null) {
            throw new ActionException(this, "Source Layer not found [" + layerName+ "]");
        }

        UNREDDLayer layerResource = new UNREDDLayer(srcLayer);
        String srcPath = layerResource.getAttribute(UNREDDLayer.Attributes.MOSAICPATH);
        String dstPath = layerResource.getAttribute(UNREDDLayer.Attributes.DISSMOSAICPATH);

        LOGGER.info(layerName + " found in the Staging Area Geostore");

        // TODO ***** add layer in destination if it does not exist
        LOGGER.error("TODO: add layer in destination if it does not exist");

        // ****************************************
        // check source layer update
        //
        // ****************************************

        LOGGER.info("Searching source LayerUpdate [" + layerName + ", " + year + "," + month + "]");

        Resource srcLayerUpdatesSA = srcGeostore.searchLayerUpdate(layerName, year, month, day);
        if (srcLayerUpdatesSA == null) {
            throw new ActionException(this, "Source LayerUpdate not found [" + layerName + ", " + year + "," + month + "]");
        }

            LOGGER.info("Source LayerUpdate found [" + layerName + ", " + year + "," + month + "]");
View Full Code Here


        //==================================================
        //=== LAYER
        //===
        //=== Insert Layer if it does not exist

        Resource srcLayer = srcGeostore.searchLayer(layerName);
        if (srcLayer == null) {
            throw new ActionException(this, "Source Layer not found [layer:" + layerName + "]");
        }

        //=== COPY LAYER

        Resource dstLayer = dstGeostore.searchLayer(layerName);
        if( dstLayer == null) {
            LOGGER.info("Copying Layer into destination: " + srcLayer);
            RESTResource layer = FlowUtil.copyResource(srcLayer);
            dstGeostore.insert(layer);
        }

        //==================================================
        //=== LAYERUPDATE
        //===
        //=== Insert LayerUpdate if it does not exist

        Resource srcLayerUpdate = srcGeostore.searchLayerUpdate(layerName, year, month, day);
        if (srcLayerUpdate == null) {
            throw new ActionException(this, "Source LayerUpdate not found [layer:" + layerName + " year:" + year + " month:" + month + "]");
        }

        //=== COPY LAYERUPDATE

        Resource dstLayerUpdate = dstGeostore.searchLayerUpdate(layerName, year, month, day);
        if ( dstLayerUpdate == null ) {
            LOGGER.info("Copying LayerUpdate " + layerName+":"+year+":"+month);

            RESTResource layerUpdate = FlowUtil.copyResource(srcLayerUpdate);
            dstGeostore.insert(layerUpdate);
        }

        //==================================================
        //=== STATS
        //===
        //=== loop on all the statistics associated with the layer

        Map<Long, Resource> srcChartScripts = new HashMap<Long, Resource>();

        List<ShortResource> statsDefList = srcGeostore.searchStatsDefByLayer(layerName, true); // may be empty, is always not null

        for (ShortResource statDef : statsDefList) {
            String statsDefName = statDef.getName();
            LOGGER.info("Found stats def :" + statsDefName);

            //=== OVERWRITE STATSDEF

            Resource dstStatsDef = dstGeostore.searchStatsDefByName(statsDefName);
            if(dstStatsDef != null) {
                LOGGER.info("Removing previous StatsDef " + statsDefName);
                dstGeostore.delete(dstStatsDef.getId());
            }

            LOGGER.info("Copying StatsDef " + statsDefName);
            Resource srcStatsDef = srcGeostore.searchStatsDefByName(statsDefName);
            RESTResource statsDef = FlowUtil.copyResource(srcStatsDef);
            dstGeostore.insert(statsDef);

            //=== OVERWRITE STATSDATA

            Resource dstStatsData = dstGeostore.searchStatsData(statsDefName, year, month, day);
            if(dstStatsData != null) {
                LOGGER.info("Removing previous StatsData [statsdef:"+statsDefName+" year:"+year+" month:"+month+"]");
                dstGeostore.delete(dstStatsData.getId());
            }

            Resource srcStatsData = srcGeostore.searchStatsData(statsDefName, year, month, day);
            if (srcStatsData == null) {
                LOGGER.warn("No StatsData found for [statsdef:"+statsDefName+" year:"+year+" month:"+month+"]");
            } else {
                LOGGER.info("Copying StatsData " + srcStatsData.getName());
                RESTResource statsData = FlowUtil.copyResource(srcStatsData);
                dstGeostore.insert(statsData);
               
                // Add attribute Published=true to srcGeostore, usefull for staging admin application
              LOGGER.info("Adding attribute published=true to resource " + srcStatsData.getName());
              RESTResource statsDataTmp = FlowUtil.copyResource(srcStatsData);
              ShortAttribute published = new ShortAttribute(UNREDDLayerUpdate.Attributes.PUBLISHED.getName(), "true", DataType.STRING);
             
              //DamianoG workaround for search in list due to ShortAttribute don't override equals method
              boolean flag = true;
              for(ShortAttribute el : statsDataTmp.getAttribute()){
                if(el.toString().equals(published.toString())){
                  flag = false;
                  break;
                }
              }
             
            //if(!statsDataTmp.getAttribute().contains(published)){
              if(flag){
                List<ShortAttribute> l = new ArrayList<ShortAttribute>();
                l.add(published);
                l.addAll(statsDataTmp.getAttribute());
                statsDataTmp.setAttribute(l);
                srcGeostore.delete(srcStatsData.getId());
                srcGeostore.insert(statsDataTmp);
              }
            }

            // Collect dependant chartscript to be copied
            List<Resource> csList = srcGeostore.searchChartScriptByStatsDef(statsDefName);
            for (Resource cs : csList) {
                LOGGER.info("Collecting ChartScript: adding " + cs.getName());
                srcChartScripts.put(cs.getId(), cs);
            }
          
           
        }

        //==================================================
        //=== CHARTS
        //===
        //=== loop on all the collected charts

        for (Resource srcChartScript : srcChartScripts.values()) {
            String chartScriptName = srcChartScript.getName();
            LOGGER.info("Removing previous charts stuff: " + chartScriptName);

            //== remove chartScript
            Resource dstChartScript = dstGeostore.searchChartScript(chartScriptName);
            if(dstChartScript != null) {
                LOGGER.info("Removing previous ChartScript :"+ chartScriptName);
                dstGeostore.delete(dstChartScript.getId());
            }

            //== remove chartData
            List<ShortResource> dstChartDataList = dstGeostore.searchChartDataByChartScript(chartScriptName);
            for (ShortResource dstChartData : dstChartDataList) {
View Full Code Here

        // Loop on all requested stats
        int cnt = 0;
        for (String statsDefName : statsDefNames) {
            float min = rescale(0, 50, cnt++/statsDefNames.size());
            float max = rescale(0, 50, cnt/statsDefNames.size());
            Resource statsDefRes = geoStoreUtil.searchStatsDefByName(statsDefName);
            if (statsDefRes == null) {
                LOGGER.warn("StatsDef not found: " + statsDefName);
                continue;
            }
            reprocessStat(statsDefRes, min, max);
View Full Code Here

        for (String layerName : layerNames) {
            float majorStep = layerCnt++ / layers;
            LOGGER.info("Starting reprocessing StatsDef:" + statsDefName + " layer:" + layerName);
            this.listenerForwarder.progressing(rescale(min, max, majorStep), "Reprocessing stats on layer " + layerName);

            Resource layerRes = geoStoreUtil.searchLayer(layerName);
            if(layerRes == null) {
                LOGGER.warn("Could not find Layer '"+layerName+"' for StatsDef '"+statsDefName+"'");
                continue;
            }
            UNREDDLayer layer = new UNREDDLayer(layerRes);
View Full Code Here

        this.listenerForwarder.setTask("Starting reprocessChart");
        List<Resource> chartScriptList = new ArrayList(request.getChartNames().size());

        for (String chartScriptName : request.getChartNames()) {
            listenerForwarder.setTask("Processing requested chart " + chartScriptName);
            Resource chartScriptResource = geoStoreUtil.searchChartScript(chartScriptName);
            if(chartScriptResource == null) {
                LOGGER.warn("Could not find chart '"+chartScriptName+"'. Will be skipped.");
                listenerForwarder.setTask("Skipping unknown chart " + chartScriptName);
                listenerForwarder.progressing();
                continue;
View Full Code Here

        // ========================================
        // Load layer info

        LOGGER.info("Searching " + layerName + " in Geostore");
        Resource layerRes = null;
        try {
            layerRes = geoStoreUtil.searchLayer(layerName);
        } catch (GeoStoreException e) {
            throw new ActionException(this, "Error while searching layer: " + layerName, e);
        }

        if (layerRes == null) {
            throw new ActionException(this, "Layer not found: " + layerName);
        }

        UNREDDLayer layer = new UNREDDLayer(layerRes);
        LOGGER.info(layerName + " found in the Staging Area Geostore");


        // ========================================
        // Load layerUpdate

        LOGGER.info("Searching layer update [" + layerName + ", " + year + "," + month + "]");

        Resource layerUpdatesRes = null;
        try {
            layerUpdatesRes = geoStoreUtil.searchLayerUpdate(layerName, year, month, day);
        } catch (GeoStoreException e) {
            throw new ActionException(this, "Error while searching LayerUpdate: " + layerName, e);
        }
View Full Code Here

    protected File doInsert(File xmlResourceFile) throws JAXBException, IOException {

        RESTResource restResource = (RESTResource) unmarshaller.unmarshal(xmlResourceFile);
        long resourceId = geostore.insert(restResource);
       
        Resource resource = geostore.getResource(resourceId);
        File outputInsertFile = File.createTempFile("gstinsert_", xmlResourceFile.getName(), getTempDir());
       
        Marshaller m = JAXBMarshallerBuilder.getJAXBMarshaller(resource.getClass());
        m.marshal(resource, outputInsertFile);
        return outputInsertFile;
    }
View Full Code Here

        RESTResource restResource = (RESTResource) unmarshaller.unmarshal(xmlResourceFile);
        long id = restResource.getId();
        String data = restResource.getStore().getData();
        geostore.setData(id, data);
        Resource resource = geostore.getResource(id);
        File outputInsertFile = File.createTempFile("gstupdate_", xmlResourceFile.getName(), getTempDir());
        Marshaller m = JAXBMarshallerBuilder.getJAXBMarshaller(resource.getClass());
        m.marshal(resource, outputInsertFile);
        return outputInsertFile;
    }
View Full Code Here

        } else {
           
            for (ShortResource shortResource: shortResourceList) {
                if(LOGGER.isDebugEnabled())
                    LOGGER.debug("ID "+shortResource.getId());
                Resource resource = geostore.getResource(shortResource.getId());
                try {
                    String data = geostore.getData(shortResource.getId());
                    if(LOGGER.isTraceEnabled())
                        LOGGER.trace("Data "+data);
                    StoredData storedData = new StoredData();
                    storedData.setData(data);
                    resource.setData(storedData);
                } catch(Exception e) {
                    LOGGER.warn("Error reading GeoStore resource" + shortResource + ": " + e.getMessage(), e);
                }
                resourceList.add(resource);
            }
View Full Code Here

    /**
     * Insert or update the storedData of a StatsData.
     */
    public void setStatsData(Resource statsDef, String statsContent, String year, String month, String day) throws GeoStoreException {
        try {
            Resource statsData = this.searchStatsData(statsDef.getName(), year, month, day);

            if (statsData == null) {
                LOGGER.info("No StatsData found for " + statsDef.getName()
                        + ", Year=" + year + ", Month=" + month
                        + ". Inserting StatsData");
                insertStatsData(statsDef.getName(), year, month, day, statsContent);

            } else {
                long id = statsData.getId();
                LOGGER.info("StatsData found for " + statsDef.getName()
                        + ", Year=" + year + ", Month=" + month
                        + ". Updating StatsData " + id);
                updateData(id, statsContent);
            }
View Full Code Here

TOP

Related Classes of it.geosolutions.geostore.core.model.Resource

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.