Package it.geosolutions.geostore.core.model

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


    protected Resource getSingleResource(List<Resource> list) {
        if (list == null || list.isEmpty()) {
            return null;
        } else {
            Resource r0 = list.get(0);
            if(list.size() > 1)
                LOGGER.warn("Found " + list.size() + " resources of type " + r0.getCategory().getName() + " -- sample: "+ r0 );
            return r0;
        }
    }
View Full Code Here


    public GeoStoreClient getGeoStoreClient() {
        return geoStoreClient;
    }

    public Resource getFullResource(long id) {
        Resource rest = geoStoreClient.getResource(id);
        // retrieve storedData
        String data = geoStoreClient.getData(id);
        StoredData sd = new StoredData();
        sd.setData(data);
        // reattach storedData
        rest.setData(sd);

        return rest;
    }
View Full Code Here

            if(getShortResource) {
                return srl.getList();
            } else {
                List<Resource> ret = new ArrayList<Resource>(srl.getList().size());
                for (ShortResource shortResource : srl.getList()) {
                    Resource r = geoStoreClient.getResource(shortResource.getId());
                    String data = geoStoreClient.getData(shortResource.getId());
                    StoredData sdata = new StoredData();
                    sdata.setData(data);
                    r.setData(sdata);
                    ret.add(r);
                }
                return ret;
            }
        } catch(Exception e) {
View Full Code Here

        RESTResource chartScriptRes = chartScript.createRESTResource();
        chartScriptRes.setName("testChartScript");
//        long chartScriptId = geostoreClient.insert(chartScriptRes);
        long chartScriptId = gstcu.insert(chartScriptRes);
//        Resource fullChartScript = geostoreClient.getResource(chartScriptId);
        Resource fullChartScript = gstcu.getGeoStoreClient().getResource(chartScriptId);

        // ok, some real testing now
        SearchFilter chartDataFilter = new CategoryFilter(UNREDDCategories.CHARTDATA.getName(), SearchOperator.EQUAL_TO);
//        ShortResourceList res0 = geostoreClient.searchResources(chartDataFilter);
        ShortResourceList res0 = gstcu.getGeoStoreClient().searchResources(chartDataFilter);
View Full Code Here

        final String YEAR = "1999";
        final String MONTH = "12";
        final String DAY = "07";

        Long sdId = UNREDDGeoStoreTestUtil.insertStatsDef(STATSDEFNAME, smallStat, "layerName");
        Resource statsDef = gstcu.getFullResource(sdId);

        String rasterfile = classFile.getAbsolutePath();

        Map<Tokens,String> tok = FlowUtil.fillTokens(rasterfile, null, null, null, null);

        FlowUtil flowUtil = new FlowUtil(getTempDir(), getConfigDir());

        // repeat run twice:
        // first time stats will be INSERTed
        // second time stats will be UPDATEd
        for (int i = 0; i < 2; i++) {
            String statsOut = flowUtil.processStatistics(getGeoStoreUtil(), statsDef, YEAR, MONTH, DAY, tok);
    //        LOGGER.info(statsOut);
            long outlen = statsOut.length();

            assertTrue("Empty output", outlen>0);

            Resource loadedStatsData = getGeoStoreUtil().searchStatsData(STATSDEFNAME, YEAR, MONTH, DAY);
            assertNotNull("Could not reload StatsData", loadedStatsData);
            assertEquals("Stats len mismatch", outlen, loadedStatsData.getData().getData().length());
        }
    }
View Full Code Here

        flowUtil.runStatsAndScripts(LAYERNAME, YEAR, MONTH, DAY, classFile, getGeoStoreUtil());

//---------------------
        LOGGER.info("===== Testing results");

        Resource loadedStatsData = gstcu.searchStatsData(STATSDEFNAME, YEAR, MONTH, DAY);
        assertNotNull("Could not reload StatsData", loadedStatsData);

        ShortResourceList res1 = gstcu.getGeoStoreClient().searchResources(chartDataFilter);
        assertNotNull(res1);
        assertNotNull(res1.getList());
View Full Code Here

        // some test data
        UNREDDGeoStoreTestUtil.deleteResources(UNREDDCategories.STATSDATA);

        long id = UNREDDGeoStoreTestUtil.insertStatsData("sdata1", "2010", "1", null, "data01");

        Resource res = gstcu.getFullResource(id);
        UNREDDStatsData sd = new UNREDDStatsData(res);

        assertEquals("sdata1_2010-01", res.getName());
        assertEquals("2010", sd.getAttribute(it.geosolutions.unredd.geostore.model.UNREDDStatsData.Attributes.YEAR));
        assertEquals("1", sd.getAttribute(it.geosolutions.unredd.geostore.model.UNREDDStatsData.Attributes.MONTH));

    }
View Full Code Here

        deleteAllResources(geostore);


        File geostoreDir = loadFile("georepo/resources");
        for (File resFile : geostoreDir.listFiles((FilenameFilter)new PrefixFileFilter("resource"))) {
            Resource res = JAXB.unmarshal(resFile, Resource.class);
            LOGGER.info("LOADED " + res.getCategory().getName() + " : " + res.getName());
           
            String basename = FilenameUtils.getBaseName(resFile.getName());
            String sid = basename.substring(basename.indexOf("_")+1);
            String dataFileName = "data_"+sid+".txt";
            File dataFile = new File(geostoreDir,dataFileName);
            String data = IOUtils.toString(new FileReader(dataFile));

            RESTResource restRes = FlowUtil.copyResource(res);
            restRes.setData(data);

            LOGGER.info("INSERTING " + res.getCategory().getName() + " : " + res.getName());
            geostore.insert(restRes);
        }

    }
View Full Code Here

         *  Load Layer data
         ******************/

        this.listenerForwarder.progressing(15, "Searching layer in GeoStore");

        final Resource layerRes;
        try {
            layerRes = geostore.searchLayer(layername);
        } catch(Exception e) {
            throw new ActionException(this, "Error loading Layer "+layername, e);
        }

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

        UNREDDLayer layer = new UNREDDLayer(layerRes);

        LOGGER.info("Layer resource found ");

        if( ! layer.getAttribute(Attributes.LAYERTYPE).equalsIgnoreCase(request.getFormat().getName()))
            throw new ActionException(this, "Bad Layer format "
                    + "(declared:"+ request.getFormat().getName()
                    + ", expected:"+layer.getAttribute(Attributes.LAYERTYPE) );

        // this attribute is read for moving the raster file to the destination directory, not for rasterization
        String mosaicDirPath = layer.getAttribute(UNREDDLayer.Attributes.MOSAICPATH);
        if( mosaicDirPath == null) {
            throw new ActionException(this, "Null mosaic directory for layer: '" + layername + "'... check the layer configuration on geostore");
        }

        File mosaicDir = new File(mosaicDirPath);
        if( ! mosaicDir.isDirectory() && ! mosaicDir.isAbsolute()) {
            throw new ActionException(this, "Bad mosaic directory for layer '" + layername + "': " + mosaicDir + " doesn't exist... create it or check the layer configuration on geostore");
        }

        // ******************
        // Check for LayerUpdate
        // ******************
        this.listenerForwarder.progressing(20, "Check for existing LayerUpdate in GeoStore");

        Resource existingLayerUpdate = null;
        try {
            existingLayerUpdate = geostore.searchLayerUpdate(layername, year, month, day);
        } catch (Exception e) {
            LOGGER.debug("Parameter : [layerSnapshot=" + layerUpdateName + "]");
            throw new ActionException(this, "Error searching for a LayerUpdate (layer:"+layername+" year:"+year+ " month:"+month+")", e);
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.