Package org.geoserver.catalog

Examples of org.geoserver.catalog.LayerInfo


        MapLayerInfo[] layers = new MapLayerInfo[layerNames.length];
        List styles = new ArrayList();

        for (int i = 0; i < layerNames.length; i++) {
            LayerInfo layerInfo = getCatalog().getLayerByName(layerNames[i].getLocalPart());
            try {
                styles.add(layerInfo.getDefaultStyle().getStyle());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            layers[i] = new MapLayerInfo(layerInfo);
        }
View Full Code Here


            @Override
            protected Component getComponentForProperty(String id, IModel itemModel,
                    Property<LayerSummary> property) {
                final LayerSummary layerSummary = (LayerSummary) itemModel.getObject();
                final CatalogIconFactory icons = CatalogIconFactory.get();
                LayerInfo layer = layerSummary.getLayer();
        if(property == LAYER) {
                    Fragment f = new Fragment(id, "edit", ImportSummaryPage.this);
                   
                    Link editLink = editLink(layerSummary);
                    editLink.setEnabled(layer != null);
                    f.add(editLink);
                   
                    return f;
                } else if(property == STATUS) {
                    ResourceReference icon = layerSummary.getStatus().successful() ?
                            icons.getEnabledIcon() : icons.getDisabledIcon();
                    Fragment f = new Fragment(id, "iconFragment", ImportSummaryPage.this);
                    f.add(new Image("icon", icon));
                    return f;
                } else if(property == TYPE) {
                    if(layer != null) {
                        ResourceReference icon = icons.getSpecificLayerIcon(layer);
                        Fragment f = new Fragment(id, "iconFragment", ImportSummaryPage.this);
                        Image image = new Image("icon", icon);
                        image.add(new AttributeModifier("title", true, new Model(getTypeTooltip(layer))));
            f.add(image);
                        return f;
                    } else {
                        return new Label(id, "");
                    }
                } else if(property == COMMANDS) {
                    Fragment f = new Fragment(id, "preview", ImportSummaryPage.this);

                    ExternalLink link = new ExternalLink("preview", "#");
                    if(layerSummary.getStatus().successful()) {
                        // TODO: move the preview link generation ability to some utility object
                        PreviewLayer preview = new PreviewLayer(layer);
                        String url = "window.open(\"" + preview.getWmsLink() + "&format=application/openlayers\")";
                        link.add(new AttributeAppender("onclick", new Model(url), ";"));
                    } else {
                        link.setEnabled(false);
                    }
                    f.add(link);
                   
                    return f;
                }
                return null;
            }

           
        };
        table.setOutputMarkupId(true);
        table.setFilterable(false);
        add(table);
       
        // the rollback command
        add(new ConfirmationAjaxLink("rollback", null,
                new ParamResourceModel("rollback", this),
                new ParamResourceModel("confirmRollback", this)) {
           
            @Override
            protected void onClick(AjaxRequestTarget target) {
                Catalog catalog = getCatalog();
                CascadeDeleteVisitor deleteVisitor = new CascadeDeleteVisitor(catalog);
                String project = summary.getProject();
                if(summary.isWorkspaceNew()) {
                    WorkspaceInfo ws = catalog.getWorkspaceByName(project);
                    if(ws != null)
                        ws.accept(deleteVisitor);
                } else if(summary.isStoreNew()) {
                    StoreInfo si = catalog.getStoreByName(project, project, StoreInfo.class);
                    if(si != null)
                        si.accept(deleteVisitor);
                } else {
                    // just remove the layers we created
                    for (LayerSummary layer : summary.getLayers()) {
                        catalog.remove(layer.getLayer());
                        catalog.remove(layer.getLayer().getResource());
                    }
                }
                setResponsePage(ImportPage.class, new PageParameters("afterCleanup=true"));
            }
        });
View Full Code Here

    /**
     *
     */
    public LayerInfo getLayerByName(String name) {
        Query query = buildQuery("from ", LayerInfoImplHb.class, " where name = ", param(name));
        LayerInfo layer = (LayerInfo) first(query);

        return layer;
    }
View Full Code Here

    }
   
    @Override
    protected void handleObjectPut(Object object) throws Exception {
        String l = getAttribute( "layer" );
        LayerInfo original = catalog.getLayerByName(l);
        LayerInfo layer = (LayerInfo) object;
       
        //ensure this is not a name change
        // TODO: Uncomment this when the resource/layer split is not, now by definition
        // we cannot rename a layer, it's just not possible and it's not un-marshalled either
//        if ( layer.getName() != null && !layer.getName().equals( original.getName() ) ) {
//            throw new RestletException( "Can't change name of a layer", Status.CLIENT_ERROR_FORBIDDEN );
//        }
        // force in the same resource otherwise the update will simply fail as we cannot reach the name
        layer.setResource(original.getResource());
       
        new CatalogBuilder( catalog ).updateLayer( original, layer );
        catalog.save( original );

        LOGGER.info( "PUT layer " + l);
View Full Code Here

    }
   
    @Override
    protected void handleObjectDelete() throws Exception {
        String l = getAttribute("layer");
        LayerInfo layer = (LayerInfo) catalog.getLayerByName(l);
        catalog.remove(layer);

        LOGGER.info( "DELETE layer " + l);
    }
View Full Code Here

            //add/save
            if ( add ) {
                catalog.add( cinfo );
               
                LayerInfo layerInfo = builder.buildLayer( cinfo );
                //JD: commenting this out, these sorts of edits should be handled
                // with a second PUT request on the created coverage
                /*
                String styleName = form.getFirstValue("style");
                if ( styleName != null ) {
View Full Code Here

                if ( existing == null ) {
                    //TODO: add a new style to catalog
                    throw new RestletException( "No such style: " + style.getName(), Status.CLIENT_ERROR_NOT_FOUND );
                }
               
                LayerInfo l = catalog.getLayerByName( layer );
                l.getStyles().add( existing );
               
                //check for default
                String def = getRequest().getResourceRef().getQueryAsForm().getFirstValue("default");
                if ( "true".equals( def ) ) {
                    l.setDefaultStyle( existing );
                }
                catalog.save(l);
                LOGGER.info( "POST style " + style.getName() + " to layer " + layer);
            }
            else {
View Full Code Here

            for (Name name : names) {
                // start information
                String layerName = name.getLocalPart();
                summary.newLayer(layerName);

                LayerInfo layer = null;
                try {
                    builder.setStore(storeInfo);
                    FeatureTypeInfo featureType = builder.buildFeatureType(name);
                    builder.lookupSRS(featureType, true);
                    builder.setupBounds(featureType);
                    layer = builder.buildLayer(featureType);
                    layer.setDefaultStyle(styles.getStyle(featureType));
                    ImportStatus status = SUCCESS;
                   
                    if(cancelled)
                        return;
                   
                    // if we have a default
                    if (layer.getResource().getSRS() == null && layer.getResource().getNativeCRS() != null
                            && defaultSRS != null) {
                        layer.getResource().setSRS(defaultSRS);
                        layer.getResource().setProjectionPolicy(ProjectionPolicy.REPROJECT_TO_DECLARED);
                        status = DEFAULTED_SRS;
                    }

                    // handler common error conditions
                    if (catalog.getFeatureTypeByName(namespace, layerName) != null) {
                        status = DUPLICATE;
                    } else if (layer.getResource().getSRS() == null && defaultSRS == null) {
                        status = MISSING_SRS;
                    } else if (layer.getResource().getLatLonBoundingBox() == null) {
                        status = MISSING_BBOX;
                    } else {
                        // try to save the layer
                        catalog.add(featureType);
                        try {
View Full Code Here

        // we return the group back, eventually wrapping the read only layers
        final List<LayerInfo> layers = group.getLayers();
        ArrayList<LayerInfo> wrapped = new ArrayList<LayerInfo>(layers.size());
        boolean needsWrapping = false;
        for (LayerInfo layer : layers) {
            LayerInfo checked = checkAccess(user, layer);
            if(checked == null)
                return null;
            else if(checked != null && checked != layer)
                needsWrapping = true;
            wrapped.add(checked);
View Full Code Here

     * @return
     */
    protected List<LayerInfo> filterLayers(Authentication user, List<LayerInfo> layers) {
        List<LayerInfo> result = new ArrayList<LayerInfo>();
        for (LayerInfo original : layers) {
            LayerInfo secured = checkAccess(user, original);
            if (secured != null)
                result.add(secured);
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of org.geoserver.catalog.LayerInfo

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.