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
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
Expand All @@ -17,6 +17,8 @@
*/
public class LayerResource implements Comparable<LayerResource>, Serializable {

private static final long serialVersionUID = 7584589248746230483L;

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
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
Expand Down Expand Up @@ -39,15 +39,15 @@

public class WMSLayerImporterPage extends GeoServerSecuredPage {

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

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

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

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

private static final long serialVersionUID = -5817898784100419973L;

@Override
protected Component getComponentForProperty(String id, IModel itemModel,
protected Component getComponentForProperty(String id, IModel<LayerResource> itemModel,
Property<LayerResource> property) {
if (property == WMSLayerProvider.NAME) {
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) {
return new SimpleAjaxLink(id, itemModel, label) {
SimpleAjaxLink<LayerResource> resourceChooserLink(String id, IModel<LayerResource> itemModel, IModel<?> label) {
return new SimpleAjaxLink<LayerResource>(id, itemModel, label) {

private static final long serialVersionUID = 163167608296661157L;

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

private static final long serialVersionUID = -7161320029912723242L;

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

private static final long serialVersionUID = 7089389540839181808L;

@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
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();
this.layerResource = layerResource;
}

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

public void setObject(Object object) {
public void setObject(String object) {
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;
}

public Object getObject() {
public PackageResourceReference getObject() {
LayerResource resource = (LayerResource) layerResource.getObject();
if(resource.getStatus() == LayerStatus.ERROR) {
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();
}

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

}



}

0 comments on commit 559baf7

Please sign in to comment.