Skip to content

Commit

Permalink
Add generics and UIDs to org.geoserver.web.data.importer
Browse files Browse the repository at this point in the history
  • Loading branch information
tbarsballe committed Jan 18, 2016
1 parent 8ee4cc5 commit 559baf7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 21 deletions.
@@ -1,4 +1,4 @@
/* (c) 2014 Open Source Geospatial Foundation - all rights reserved /* (c) 2014 - 2016 Open Source Geospatial Foundation - all rights reserved
* (c) 2001 - 2013 OpenPlans * (c) 2001 - 2013 OpenPlans
* This code is licensed under the GPL 2.0 license, available at the root * This code is licensed under the GPL 2.0 license, available at the root
* application directory. * application directory.
Expand All @@ -17,6 +17,8 @@
*/ */
public class LayerResource implements Comparable<LayerResource>, Serializable { public class LayerResource implements Comparable<LayerResource>, Serializable {


private static final long serialVersionUID = 7584589248746230483L;

enum LayerStatus {ERROR, NEWLY_PUBLISHED, UPDATED, NEW, PUBLISHED}; enum LayerStatus {ERROR, NEWLY_PUBLISHED, UPDATED, NEW, PUBLISHED};


/** /**
Expand Down
@@ -1,4 +1,4 @@
/* (c) 2014 - 2015 Open Source Geospatial Foundation - all rights reserved /* (c) 2014 - 2016 Open Source Geospatial Foundation - all rights reserved
* (c) 2001 - 2013 OpenPlans * (c) 2001 - 2013 OpenPlans
* This code is licensed under the GPL 2.0 license, available at the root * This code is licensed under the GPL 2.0 license, available at the root
* application directory. * application directory.
Expand Down Expand Up @@ -39,15 +39,15 @@


public class WMSLayerImporterPage extends GeoServerSecuredPage { public class WMSLayerImporterPage extends GeoServerSecuredPage {


private static final long serialVersionUID = -3413451886777414860L;
String storeId; String storeId;
private GeoServerTablePanel<LayerResource> layers; private GeoServerTablePanel<LayerResource> layers;
private WMSLayerProvider provider; private WMSLayerProvider provider;
int importCount; int importCount;
int errorCount; int errorCount;
int updateCount; int updateCount;
private Form form; private Form<WMSLayerImporterPage> form;


@SuppressWarnings({ "serial", "unchecked", "rawtypes" })
public WMSLayerImporterPage(PageParameters params) { public WMSLayerImporterPage(PageParameters params) {


storeId = params.get("storeId").toString(); storeId = params.get("storeId").toString();
Expand All @@ -64,13 +64,15 @@ public WMSLayerImporterPage(PageParameters params) {
} }


// build the GUI // build the GUI
form = new Form("form", new CompoundPropertyModel(this)); form = new Form<WMSLayerImporterPage>("form", new CompoundPropertyModel<WMSLayerImporterPage>(this));
form.setOutputMarkupId(true); form.setOutputMarkupId(true);
add(form); add(form);
layers = new GeoServerTablePanel<LayerResource>("layerChooser", provider, true) { layers = new GeoServerTablePanel<LayerResource>("layerChooser", provider, true) {


private static final long serialVersionUID = -5817898784100419973L;

@Override @Override
protected Component getComponentForProperty(String id, IModel itemModel, protected Component getComponentForProperty(String id, IModel<LayerResource> itemModel,
Property<LayerResource> property) { Property<LayerResource> property) {
if (property == WMSLayerProvider.NAME) { if (property == WMSLayerProvider.NAME) {
return new Label(id, property.getModel(itemModel)); return new Label(id, property.getModel(itemModel));
Expand Down Expand Up @@ -104,8 +106,10 @@ protected Component getComponentForProperty(String id, IModel itemModel,


} }


SimpleAjaxLink resourceChooserLink(String id, IModel itemModel, IModel label) { SimpleAjaxLink<LayerResource> resourceChooserLink(String id, IModel<LayerResource> itemModel, IModel<?> label) {
return new SimpleAjaxLink(id, itemModel, label) { return new SimpleAjaxLink<LayerResource>(id, itemModel, label) {

private static final long serialVersionUID = 163167608296661157L;


@Override @Override
protected void onClick(AjaxRequestTarget target) { protected void onClick(AjaxRequestTarget target) {
Expand Down Expand Up @@ -136,6 +140,8 @@ LayerInfo buildLayerInfo(LayerResource resource) {
AjaxSubmitLink submitLink() { AjaxSubmitLink submitLink() {
return new AjaxSubmitLink("import") { return new AjaxSubmitLink("import") {


private static final long serialVersionUID = -7161320029912723242L;

@Override @Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) { protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
try { try {
Expand Down Expand Up @@ -181,6 +187,8 @@ void publishLayers(List<LayerResource> selection) {
AjaxSubmitLink importAllLink() { AjaxSubmitLink importAllLink() {
return new AjaxSubmitLink("importAll") { return new AjaxSubmitLink("importAll") {


private static final long serialVersionUID = 7089389540839181808L;

@Override @Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) { protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
try { try {
Expand Down Expand Up @@ -255,22 +263,23 @@ private void createImportReport(){
} }
} }


final class StatusModel implements IModel { final class StatusModel implements IModel<String> {


IModel layerResource; private static final long serialVersionUID = 7754149365712750847L;
IModel<LayerResource> layerResource;


public StatusModel(IModel layerResource) { public StatusModel(IModel<LayerResource> layerResource) {
super(); super();
this.layerResource = layerResource; this.layerResource = layerResource;
} }


public Object getObject() { public String getObject() {
LayerResource resource = (LayerResource) layerResource.getObject(); LayerResource resource = (LayerResource) layerResource.getObject();
return new ParamResourceModel("WMSLayerImporterPage.status." + resource.getStatus(), return new ParamResourceModel("WMSLayerImporterPage.status." + resource.getStatus(),
WMSLayerImporterPage.this, resource.getError()).getString(); WMSLayerImporterPage.this, resource.getError()).getString();
} }


public void setObject(Object object) { public void setObject(String object) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }


Expand All @@ -280,15 +289,16 @@ public void detach() {


} }


final class IconModel implements IModel { final class IconModel implements IModel<PackageResourceReference> {


IModel layerResource; private static final long serialVersionUID = 5762710251083186192L;
IModel<LayerResource> layerResource;


public IconModel(IModel layerResource) { public IconModel(IModel<LayerResource> layerResource) {
this.layerResource = layerResource; this.layerResource = layerResource;
} }


public Object getObject() { public PackageResourceReference getObject() {
LayerResource resource = (LayerResource) layerResource.getObject(); LayerResource resource = (LayerResource) layerResource.getObject();
if(resource.getStatus() == LayerStatus.ERROR) { if(resource.getStatus() == LayerStatus.ERROR) {
return new PackageResourceReference( return new PackageResourceReference(
Expand All @@ -308,7 +318,7 @@ public Object getObject() {
} }
} }


public void setObject(Object object) { public void setObject(PackageResourceReference object) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }


Expand All @@ -317,7 +327,4 @@ public void detach() {
} }


} }



} }

0 comments on commit 559baf7

Please sign in to comment.