use of org.geotools.feature.NameImpl in project sldeditor by robward-scisys.
the class FunctionTableModelTest method testProcessBriefType.
/**
* Test all the methods using a ProcessBriefType.
*
* <p>Not tested because it needs to interact with GeoServer to create a receive a remote custom
* WPS function.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Disabled
@Test
void testProcessBriefType() {
FunctionTableModel model = new FunctionTableModel();
assertEquals(0, model.getRowCount());
model.addNewValue(0);
ProcessBriefType customFunction = createCustomFunction();
FunctionName name = new FunctionNameImpl(new NameImpl("vec", "PointStacker"), parameter("cellSize", Double.class), new Parameter("outputBBOX", Number.class, null, null, false, 0, 100, null, null), parameter("outputWidth", Number.class), parameter("outputHeight", Number.class));
assertFalse(name.getArguments().get(0).isRequired());
assertTrue(name.getArguments().get(1).isRequired());
model.populate(customFunction);
assertEquals(3, model.getRowCount());
assertEquals(4, model.getColumnCount());
// Get value
assertEquals("outputBBOX", model.getValueAt(0, 0));
assertEquals(Number.class.getSimpleName(), model.getValueAt(0, 1));
assertEquals(true, model.getValueAt(0, 2));
assertEquals("env([wms_bbox])", model.getValueAt(0, 3));
assertNull(model.getValueAt(0, 4));
// Is editable
assertFalse(model.isCellEditable(0, 0));
assertFalse(model.isCellEditable(0, 1));
assertTrue(model.isCellEditable(0, FunctionTableModel.getOptionalColumn()));
assertFalse(model.isCellEditable(0, 3));
assertFalse(model.isCellEditable(0, 4));
// Set value
model.setValueAt(true, 0, 2);
assertTrue((Boolean) model.getValueAt(0, FunctionTableModel.getOptionalColumn()));
model.setValueAt(false, 0, 2);
assertFalse((Boolean) model.getValueAt(0, FunctionTableModel.getOptionalColumn()));
// Get row
assertNull(model.getValue(-1));
assertNull(model.getValue(10));
// Add a new value
assertEquals(0, model.getNoOfOccurences(null));
ProcessFunctionParameterValue value = model.getValue(0);
assertEquals(1, model.getNoOfOccurences(value));
model.addNewValue(0);
assertEquals(4, model.getRowCount());
assertEquals(2, model.getNoOfOccurences(value));
// Remove value
model.removeValue(3);
assertEquals(3, model.getRowCount());
// Get expression
ProcessFunction actualFunction = model.getExpression(null);
assertNull(actualFunction);
model.setValueAt(true, 0, FunctionTableModel.getOptionalColumn());
ProcessFunctionFactory factory = new ProcessFunctionFactory();
actualFunction = model.getExpression(factory);
assertNotNull(actualFunction);
// Update expression
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
Expression expression = ff.literal(4.2);
model.update(expression, 0);
model.update(null, 1);
}
use of org.geotools.feature.NameImpl in project sldeditor by robward-scisys.
the class FunctionTableModelTest method testProcessFunction.
/**
* Test all the methods using a ProcessFunction
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
void testProcessFunction() {
FunctionTableModel model = new FunctionTableModel();
assertEquals(0, model.getRowCount());
model.addNewValue(0);
ProcessFunction processFunction = createProcessFunction();
FunctionName name = new FunctionNameImpl(new NameImpl("vec", "PointStacker"), parameter("cellSize", Double.class), new Parameter("outputBBOX", Number.class, null, null, false, 0, 100, null, null), parameter("outputWidth", Number.class), parameter("outputHeight", Number.class));
assertFalse(name.getArguments().get(0).isRequired());
assertTrue(name.getArguments().get(1).isRequired());
model.populate(name, processFunction);
assertEquals(3, model.getRowCount());
assertEquals(4, model.getColumnCount());
// Get value
assertEquals("outputBBOX", model.getValueAt(0, 0));
assertEquals(Number.class.getSimpleName(), model.getValueAt(0, 1));
assertEquals(true, model.getValueAt(0, 2));
assertEquals("env([wms_bbox])", model.getValueAt(0, 3));
assertNull(model.getValueAt(0, 4));
// Is editable
assertFalse(model.isCellEditable(0, 0));
assertFalse(model.isCellEditable(0, 1));
assertTrue(model.isCellEditable(0, FunctionTableModel.getOptionalColumn()));
assertFalse(model.isCellEditable(0, 3));
assertFalse(model.isCellEditable(0, 4));
// Set value
model.setValueAt(true, 0, 2);
assertTrue((Boolean) model.getValueAt(0, FunctionTableModel.getOptionalColumn()));
model.setValueAt(false, 0, 2);
assertFalse((Boolean) model.getValueAt(0, FunctionTableModel.getOptionalColumn()));
// Get row
assertNull(model.getValue(-1));
assertNull(model.getValue(10));
// Add a new value
assertEquals(0, model.getNoOfOccurences(null));
ProcessFunctionParameterValue value = model.getValue(0);
assertEquals(1, model.getNoOfOccurences(value));
model.addNewValue(0);
assertEquals(4, model.getRowCount());
assertEquals(2, model.getNoOfOccurences(value));
// Remove value
model.removeValue(3);
assertEquals(3, model.getRowCount());
// Get expression
ProcessFunction actualFunction = model.getExpression(null);
assertNull(actualFunction);
model.setValueAt(true, 0, FunctionTableModel.getOptionalColumn());
ProcessFunctionFactory factory = new ProcessFunctionFactory();
actualFunction = model.getExpression(factory);
assertNotNull(actualFunction);
// Update expression
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
Expression expression = ff.literal(4.2);
model.update(expression, 0);
model.update(null, 1);
}
use of org.geotools.feature.NameImpl in project sldeditor by robward-scisys.
the class DataSourceInfo method getPropertyDescriptorList.
/**
* Gets the property descriptor list.
*
* @return the property descriptor list
*/
public Collection<PropertyDescriptor> getPropertyDescriptorList() {
if (schema != null) {
return schema.getDescriptors();
} else {
if (geometryType == GeometryTypeEnum.RASTER) {
if (rasterPropertyDescriptorList == null) {
rasterPropertyDescriptorList = new ArrayList<>();
CoordinateReferenceSystem crs = null;
boolean isIdentifiable = false;
boolean isAbstract = false;
List<Filter> restrictions = null;
AttributeType superType = null;
InternationalString description = null;
GeometryType type = featureTypeFactory.createGeometryType(new NameImpl(RASTER_GEOMETRY_FIELD), GridCoverage2D.class, crs, isIdentifiable, isAbstract, restrictions, superType, description);
GeometryDescriptor descriptor = featureTypeFactory.createGeometryDescriptor(type, new NameImpl(RASTER_GEOMETRY_FIELD), 0, 1, false, null);
rasterPropertyDescriptorList.add(descriptor);
}
return rasterPropertyDescriptorList;
}
}
return null;
}
use of org.geotools.feature.NameImpl in project sldeditor by robward-scisys.
the class FieldConfigBaseTest method testPopulateExpressionExpression.
/**
* Test method for {@link
* com.sldeditor.ui.detail.config.FieldConfigBase#populate(org.opengis.filter.expression.Expression)}.
* Test method for {@link
* com.sldeditor.ui.detail.config.FieldConfigBase#populate(org.opengis.filter.expression.Expression,
* org.opengis.filter.expression.Expression)}.
*/
@Test
public void testPopulateExpressionExpression() {
FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
String expectedLabel = "test label";
TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, false, false));
AttributeSelection attributeSelectionPanel = AttributeSelection.createAttributes(String.class, field, false);
field.testAttributeSelectionPanel(attributeSelectionPanel);
TestUpdateSymbolInterface listener = new TestUpdateSymbolInterface();
field.addDataChangedListener(listener);
assertFalse(listener.hasBeenCalled());
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
// Test function
DefaultFunctionFactory functionFactory = new DefaultFunctionFactory();
FunctionName functionName = null;
for (FunctionName func : functionFactory.getFunctionNames()) {
if (func.getName() == "greaterThan") {
functionName = func;
break;
}
}
assertNotNull(functionName);
Expression testExpression = ff.function(functionName.getFunctionName(), ff.literal(1), ff.literal(2));
field.populate(testExpression);
// Updated because the attribute pulldown changed
assertTrue(listener.hasBeenCalled());
assertEquals(ExpressionTypeEnum.E_EXPRESSION, field.getExpressionType());
Expression expression = field.getExpression();
assertTrue(expression.toString().startsWith(functionName.getName()));
// Attribute expression wrapped in a literal expression
String testAttributeName = "test attribute";
NameImpl name = new NameImpl(testAttributeName);
AttributeExpressionImpl attributeExpression = new AttributeExpressionImpl(name);
Expression literalExpression = ff.literal(attributeExpression);
field.populate(literalExpression);
assertEquals(ExpressionTypeEnum.E_ATTRIBUTE, field.getExpressionType());
// Process Function
// ProcessFunctionFactory factory = new ProcessFunctionFactory();
// FunctionTableModel functionParameterTableModel = new FunctionTableModel();
// ProcessFunction processFunction = functionParameterTableModel.getExpression(factory);
// field.populate(processFunction);
// assertEquals(ExpressionTypeEnum.E_VALUE, field.getExpressionType());
}
Aggregations