Skip to content

Commit

Permalink
Geofence-server compilable
Browse files Browse the repository at this point in the history
  • Loading branch information
NielsCharlier committed Jan 19, 2016
1 parent 63fafc4 commit 96811b1
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 65 deletions.
14 changes: 8 additions & 6 deletions src/community/geofence-server/pom.xml
Expand Up @@ -130,13 +130,15 @@
</dependency>

<dependency>
<groupId>wicket-dnd</groupId>
<groupId>com.github.svenmeier.wicket-dnd</groupId>
<artifactId>wicket-dnd</artifactId>
<version>0.4.2</version>
</dependency>
<dependency>
<groupId>org.wicketstuff</groupId>
<artifactId>prototype</artifactId>
<version>0.6.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-core</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- test dependencies -->
Expand Down
Expand Up @@ -12,7 +12,6 @@
import org.apache.wicket.model.ResourceModel;
import org.geoserver.catalog.WorkspaceInfo;
import org.geoserver.geofence.core.model.enums.AdminGrantType;
import org.geoserver.geofence.core.model.enums.GrantType;
import org.geoserver.geofence.services.dto.ShortAdminRule;
import org.geoserver.security.GeoServerRoleService;
import org.geoserver.security.GeoServerSecurityManager;
Expand All @@ -29,7 +28,8 @@

public class GeofenceAdminRulePage extends GeoServerSecuredPage {

protected DropDownChoice<String> userChoice, roleChoice, workspaceChoice;
private static final long serialVersionUID = -1652083500548496180L;
protected DropDownChoice<String> userChoice, roleChoice, workspaceChoice;
protected DropDownChoice<AdminGrantType> grantTypeChoice;

public GeofenceAdminRulePage(final ShortAdminRule rule, final GeofenceAdminRulesModel rules) {
Expand All @@ -42,7 +42,9 @@ public GeofenceAdminRulePage(final ShortAdminRule rule, final GeofenceAdminRules
form.add(roleChoice = new DropDownChoice<>("roleName", getRoleNames()));
roleChoice.add(new OnChangeAjaxBehavior() {

@Override
private static final long serialVersionUID = -8846522500239968004L;

@Override
protected void onUpdate(AjaxRequestTarget target) {
userChoice.setChoices(getUserNames(roleChoice.getConvertedInput()));
form.getModelObject().setUserName(null);
Expand All @@ -64,7 +66,9 @@ protected void onUpdate(AjaxRequestTarget target) {

form.add(new SubmitLink("save") {

@Override
private static final long serialVersionUID = -6524151967046867889L;

@Override
public void onSubmit() {
ShortAdminRule rule = (ShortAdminRule) getForm().getModelObject();
try {
Expand Down Expand Up @@ -127,9 +131,11 @@ protected List<String> getUserNames(String roleName) {
return new ArrayList<>(resultSet);
}

protected class AdminGrantTypeRenderer implements IChoiceRenderer<AdminGrantType> {
protected class AdminGrantTypeRenderer extends ChoiceRenderer<AdminGrantType> {

private static final long serialVersionUID = -7146780173551842734L;

public Object getDisplayValue(AdminGrantType object) {
public Object getDisplayValue(AdminGrantType object) {
return new ParamResourceModel(object.name(), getPage()).getObject();
}

Expand Down
Expand Up @@ -4,6 +4,7 @@
*/
package org.geoserver.geofence.web;

import org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder;
import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;
Expand All @@ -16,11 +17,14 @@

import java.util.*;

@SuppressWarnings("serial")
public class GeofenceAdminRulesModel extends GeoServerDataProvider<ShortAdminRule> {

public static class RuleBeanProperty<T> extends BeanProperty<T> {
public RuleBeanProperty(String key, String propertyPath) {
private static final long serialVersionUID = 2987962533487848796L;

public static class RuleBeanProperty<T> extends BeanProperty<T> {
private static final long serialVersionUID = 3626448043686728925L;

public RuleBeanProperty(String key, String propertyPath) {
super(key, propertyPath);
}

Expand All @@ -29,9 +33,12 @@ public Comparator<T> getComparator() {
return null;
}

public IModel getModel(IModel itemModel) {
@SuppressWarnings({ "unchecked", "rawtypes" })
public IModel getModel(IModel<T> itemModel) {
return new PropertyModel<Object>(itemModel, getPropertyPath()) {
@Override
private static final long serialVersionUID = -3213885135907358752L;

@Override
public Object getObject() {
Object o = super.getObject();
return o == null ? "*" : o;
Expand All @@ -55,16 +62,16 @@ private static AdminRuleAdminService adminService() {

public GeofenceAdminRulesModel() {
rules = adminService().getAll();
setSort("priority", true);
setSort("priority", SortOrder.ASCENDING);
}

@Override
protected Comparator<ShortAdminRule> getComparator(SortParam sort) {
protected Comparator<ShortAdminRule> getComparator(SortParam<?> sort) {
return null;
}

@Override
public void setSort(SortParam param) {
public void setSort(SortParam<Object> param) {
super.setSort(param);
Collections.sort(rules, super.getComparator(param));
}
Expand Down
Expand Up @@ -8,7 +8,6 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
Expand Down Expand Up @@ -46,7 +45,6 @@
import org.geotools.factory.CommonFactoryFinder;
import org.opengis.filter.sort.SortOrder;
import org.opengis.filter.FilterFactory2;
import org.opengis.filter.sort.SortBy;
import org.springframework.dao.DuplicateKeyException;

/**
Expand All @@ -58,9 +56,13 @@
*/
public class GeofenceRulePage extends GeoServerSecuredPage {

private class RuleFormData implements Serializable {
private static final long serialVersionUID = -3986495664060319256L;

ShortRule rule;
private class RuleFormData implements Serializable {

private static final long serialVersionUID = 3045099348340468123L;

ShortRule rule;
RuleLimits ruleLimits;
String allowedArea;
}
Expand All @@ -83,10 +85,10 @@ public GeofenceRulePage(final ShortRule rule, final GeofenceRulesModel rules) {
ruleFormData.allowedArea = getAllowedAreaAsString(ruleLimits);
}

CompoundPropertyModel ruleFormModel = new CompoundPropertyModel<RuleFormData>(ruleFormData);
CompoundPropertyModel<RuleFormData> ruleFormModel = new CompoundPropertyModel<RuleFormData>(ruleFormData);

// build the form
final Form<RuleFormData> form = new Form<>("form", ruleFormModel);
final Form<RuleFormData> form = new Form<RuleFormData>("form", ruleFormModel);
add(form);

form.add(new TextField<>("priority", ruleFormModel.bind("rule.priority")).setRequired(true));
Expand Down Expand Up @@ -153,7 +155,9 @@ protected void onUpdate(AjaxRequestTarget target) {

grantTypeChoice.add(new OnChangeAjaxBehavior() {

@Override
private static final long serialVersionUID = -4302901248019983282L;

@Override
protected void onUpdate(AjaxRequestTarget target) {
if (grantTypeChoice.getConvertedInput().equals(GrantType.LIMIT)) {
allowedAreaLabel.setVisible(true);
Expand Down Expand Up @@ -352,7 +356,7 @@ protected List<String> getUserNames(String roleName) {
/**
* Makes sure we see translated text, by the raw name is used for the model
*/
protected class GrantTypeRenderer implements IChoiceRenderer<GrantType> {
protected class GrantTypeRenderer extends ChoiceRenderer<GrantType> {
private static final long serialVersionUID = -7478943956804313995L;

public Object getDisplayValue(GrantType object) {
Expand All @@ -368,7 +372,7 @@ public String getIdValue(GrantType object, int index) {
/**
* Makes sure that while rendered in mixed case, is stored in uppercase
*/
protected class CaseConversionRenderer implements IChoiceRenderer<String> {
protected class CaseConversionRenderer extends ChoiceRenderer<String> {
private static final long serialVersionUID = 4238195087731806209L;

public Object getDisplayValue(String object) {
Expand Down
Expand Up @@ -11,6 +11,8 @@
import java.util.List;

import com.vividsolutions.jts.geom.MultiPolygon;

import org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder;
import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;
Expand All @@ -29,15 +31,18 @@
* @author Niels Charlier
*
*/
@SuppressWarnings("serial")
public class GeofenceRulesModel extends GeoServerDataProvider<ShortRule> {

/**
private static final long serialVersionUID = 478867886089304835L;

/**
* Makes columns that are unsortable and display "*" instead of empty when null
*
*/
public static class RuleBeanProperty<T> extends BeanProperty<T> {
public RuleBeanProperty(String key, String propertyPath) {
private static final long serialVersionUID = 483799722644223445L;

public RuleBeanProperty(String key, String propertyPath) {
super(key, propertyPath);
}

Expand All @@ -46,9 +51,12 @@ public Comparator<T> getComparator() { //unsortable
return null;
}

public IModel getModel(IModel itemModel) { //replace null by *
@SuppressWarnings({ "unchecked", "rawtypes" })
public IModel getModel(IModel<T> itemModel) { //replace null by *
return new PropertyModel<Object>(itemModel, getPropertyPath()) {
@Override
private static final long serialVersionUID = 1L;

@Override
public Object getObject() {
Object o = super.getObject();
return o == null ? "*" : o;
Expand Down Expand Up @@ -79,16 +87,16 @@ private static RuleAdminService adminService() {

public GeofenceRulesModel() {
rules = adminService().getAll();
setSort("priority", true);
setSort("priority", SortOrder.ASCENDING);
}

@Override
protected Comparator<ShortRule> getComparator(SortParam sort) {
protected Comparator<ShortRule> getComparator(SortParam<?> sort) {
return null; //disable on-the-fly sorting
}

@Override
public void setSort(SortParam param) {
public void setSort(SortParam<Object> param) {
super.setSort(param);
//enable in-memory sorting
Collections.sort(rules, super.getComparator(param));
Expand Down

0 comments on commit 96811b1

Please sign in to comment.