Search in sources :

Example 6 with FunctionName

use of org.opengis.filter.capability.FunctionName in project sldeditor by robward-scisys.

the class FunctionManager method initialise.

/**
 * Initialise.
 */
private void initialise() {
    functionNameList = functionFactory.getFunctionNames();
    List<Class<?>> classList = new ArrayList<Class<?>>();
    Logger logger = Logger.getLogger(getClass());
    for (FunctionName function : functionNameList) {
        logger.debug(function.getName());
        functionNameMap.put(function.getName(), function);
        for (int index = 0; index < function.getArgumentCount(); index++) {
            if (!classList.contains(function.getArguments().get(index).getType())) {
                classList.add(function.getArguments().get(index).getType());
            }
            logger.debug("\t" + function.getArgumentNames().get(index) + "\t" + function.getArguments().get(index).getType().getName() + "\t" + function.getArguments().get(index).getMinOccurs() + "\t" + function.getArguments().get(index).getMaxOccurs());
        }
        if (!classList.contains(function.getReturn().getType())) {
            classList.add(function.getReturn().getType());
        }
        logger.debug("\tRet : " + function.getReturn().getType().getName());
    }
    logger.debug("\nClasses");
    for (Class<?> className : classList) {
        logger.debug(className.getName());
    }
    // CHECKSTYLE:OFF
    Class<?>[] allowedNumberTypes = { Number.class, Double.class, Float.class, Integer.class, Long.class, Object.class };
    Class<?>[] allowedDoubleTypes = { Number.class, Double.class, Float.class, Integer.class, Long.class, Object.class };
    Class<?>[] allowedFloatTypes = { Number.class, Double.class, Float.class, Integer.class, Long.class, Object.class };
    Class<?>[] allowedIntegerTypes = { Number.class, Double.class, Float.class, Integer.class, Long.class, Object.class };
    Class<?>[] allowedLongTypes = { Number.class, Double.class, Float.class, Integer.class, Long.class, Object.class };
    Class<?>[] allowedBooleanTypes = { Boolean.class, Object.class };
    Class<?>[] allowedStringTypes = { String.class, Object.class };
    Class<?>[] allowedGeometryTypes = { Geometry.class, LineString.class, Point.class, MultiPoint.class, LinearRing.class, Object.class };
    Class<?>[] allowedDateTypes = { Date.class, Object.class };
    Class<?>[] allowedClassifierTypes = { RangedClassifier.class, Classifier.class, Object.class };
    Class<?>[] allowedBBoxTypes = { ReferencedEnvelope.class, Geometry.class };
    Class<?>[] allowedObjectTypes = { Number.class, Double.class, Float.class, Integer.class, Long.class, Boolean.class, String.class, Date.class, Geometry.class, LineString.class, Point.class, MultiPoint.class, LinearRing.class, RangedClassifier.class, Classifier.class, ReferencedEnvelope.class, Object.class };
    // CHECKSTYLE:ON
    populateAllowedTypes(Number.class, allowedNumberTypes);
    populateAllowedTypes(Double.class, allowedDoubleTypes);
    populateAllowedTypes(Float.class, allowedFloatTypes);
    populateAllowedTypes(Integer.class, allowedIntegerTypes);
    populateAllowedTypes(Long.class, allowedLongTypes);
    populateAllowedTypes(Boolean.class, allowedBooleanTypes);
    populateAllowedTypes(String.class, allowedStringTypes);
    populateAllowedTypes(Geometry.class, allowedGeometryTypes);
    populateAllowedTypes(Date.class, allowedDateTypes);
    populateAllowedTypes(Classifier.class, allowedClassifierTypes);
    populateAllowedTypes(ReferencedEnvelope.class, allowedBBoxTypes);
    populateAllowedTypes(Object.class, allowedObjectTypes);
}
Also used : FunctionName(org.opengis.filter.capability.FunctionName) ArrayList(java.util.ArrayList) Logger(org.apache.log4j.Logger) Point(com.vividsolutions.jts.geom.Point) MultiPoint(com.vividsolutions.jts.geom.MultiPoint)

Example 7 with FunctionName

use of org.opengis.filter.capability.FunctionName in project sldeditor by robward-scisys.

the class RenderTransformationDialogTest method testRenderTransformationDialog.

/**
 * Test method for
 * {@link com.sldeditor.rendertransformation.RenderTransformationDialog#RenderTransformationDialog(com.sldeditor.common.connection.GeoServerConnectionManagerInterface)}.
 */
@Test
public void testRenderTransformationDialog() {
    TestRenderTransformationDialog testObj = new TestRenderTransformationDialog(null);
    testObj.test_internal_showDialog(null);
    ProcessFunction actualResult = testObj.getTransformationProcessFunction();
    assertNull(actualResult);
    ProcessFunctionFactory factory = new ProcessFunctionFactory();
    FunctionName functionName = factory.getFunctionNames().get(0);
    testObj.testDisplayFunction(functionName.getName());
    actualResult = testObj.getTransformationProcessFunction();
    assertNotNull(actualResult);
    testObj.test_internal_showDialog(actualResult);
}
Also used : ProcessFunction(org.geotools.process.function.ProcessFunction) FunctionName(org.opengis.filter.capability.FunctionName) ProcessFunctionFactory(org.geotools.process.function.ProcessFunctionFactory) Test(org.junit.Test)

Example 8 with FunctionName

use of org.opengis.filter.capability.FunctionName in project sldeditor by robward-scisys.

the class SelectedProcessFunctionTest method testSetBuiltInProcessFunction.

/**
 * Test method for
 * {@link com.sldeditor.rendertransformation.SelectedProcessFunction#setBuiltInProcessFunction(org.opengis.filter.capability.FunctionName, org.geotools.process.function.ProcessFunction)}.
 */
@Test
public void testSetBuiltInProcessFunction() {
    SelectedProcessFunction obj = new SelectedProcessFunction();
    assertTrue(obj.isBuiltInSelected());
    assertTrue(obj.extractParameters().isEmpty());
    assertNull(obj.getFunctionName());
    assertEquals(0, obj.getRowCount());
    ProcessFunctionFactory processFunctionFactory = new ProcessFunctionFactory();
    List<FunctionName> functionNameList = processFunctionFactory.getFunctionNames();
    FunctionName functionName = functionNameList.get(0);
    obj.setBuiltInProcessFunction(functionName, null);
    assertTrue(obj.isBuiltInSelected());
    assertTrue(obj.getFunctionName().getLocalPart().compareTo(functionName.getName()) == 0);
    assertEquals(obj.getRowCount(), obj.extractParameters().size());
    assertFalse(obj.extractParameters().isEmpty());
}
Also used : SelectedProcessFunction(com.sldeditor.rendertransformation.SelectedProcessFunction) FunctionName(org.opengis.filter.capability.FunctionName) ProcessFunctionFactory(org.geotools.process.function.ProcessFunctionFactory) Test(org.junit.Test)

Example 9 with FunctionName

use of org.opengis.filter.capability.FunctionName in project sldeditor by robward-scisys.

the class FunctionManagerTest method testGetFunctionType.

/**
 * Test method for
 * {@link com.sldeditor.filter.v2.function.FunctionManager#getFunctionType(java.lang.String)}.
 */
@Test
public void testGetFunctionType() {
    Class<?> returnType = FunctionManager.getInstance().getFunctionType(null);
    assertNull(returnType);
    List<FunctionNameFilterInterface> functionNameFilterList = new ArrayList<FunctionNameFilterInterface>();
    FunctionNameFilterAll allFilter = new FunctionNameFilterAll();
    allFilter.accept(null);
    functionNameFilterList.add(allFilter);
    List<FunctionName> functionNameList = FunctionManager.getInstance().getFunctionNameList(null, null);
    for (FunctionName functionName : functionNameList) {
        returnType = FunctionManager.getInstance().getFunctionType(functionName.getName());
        assertEquals(functionName.getName(), functionName.getReturn().getType(), returnType);
    }
}
Also used : FunctionName(org.opengis.filter.capability.FunctionName) FunctionNameFilterAll(com.sldeditor.filter.v2.function.namefilter.FunctionNameFilterAll) FunctionNameFilterInterface(com.sldeditor.filter.v2.function.namefilter.FunctionNameFilterInterface) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 10 with FunctionName

use of org.opengis.filter.capability.FunctionName in project sldeditor by robward-scisys.

the class FunctionField method setDataType.

/**
 * Sets the field data types.
 *
 * @param fieldType the new data type
 * @param isRasterSymbol the is raster symbol
 */
public void setDataType(Class<?> fieldType, boolean isRasterSymbol) {
    functionNameMap.clear();
    List<FunctionNameFilterInterface> functionNameFilterList = new ArrayList<FunctionNameFilterInterface>();
    if (isRasterSymbol) {
        functionNameFilterList.add(new FunctionNameFilterRaster());
    } else {
        functionNameFilterList.add(new FunctionNameFilterAll());
    }
    List<FunctionName> functionNameList = functionNameMgr.getFunctionNameList(fieldType, functionNameFilterList);
    for (FunctionName functionName : functionNameList) {
        String functionNameString = functionName.getName();
        functionNameMap.put(functionNameString, functionName);
    }
    populateFunctionComboBox();
}
Also used : FunctionName(org.opengis.filter.capability.FunctionName) FunctionNameFilterAll(com.sldeditor.filter.v2.function.namefilter.FunctionNameFilterAll) FunctionNameFilterInterface(com.sldeditor.filter.v2.function.namefilter.FunctionNameFilterInterface) ArrayList(java.util.ArrayList) FunctionNameFilterRaster(com.sldeditor.filter.v2.function.namefilter.FunctionNameFilterRaster)

Aggregations

FunctionName (org.opengis.filter.capability.FunctionName)21 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)9 Expression (org.opengis.filter.expression.Expression)7 DefaultFunctionFactory (org.geotools.filter.function.DefaultFunctionFactory)6 FunctionNameFilterInterface (com.sldeditor.filter.v2.function.namefilter.FunctionNameFilterInterface)5 FunctionExpression (org.geotools.filter.FunctionExpression)5 FunctionNameFilterAll (com.sldeditor.filter.v2.function.namefilter.FunctionNameFilterAll)4 ProcessFunctionFactory (org.geotools.process.function.ProcessFunctionFactory)4 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)3 AttributeExpressionImpl (org.geotools.filter.AttributeExpressionImpl)3 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)2 FunctionNameFilterRaster (com.sldeditor.filter.v2.function.namefilter.FunctionNameFilterRaster)2 BuiltInProcessFunction (com.sldeditor.rendertransformation.BuiltInProcessFunction)2 ProcessFunctionParameterValue (com.sldeditor.rendertransformation.ProcessFunctionParameterValue)2 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)2 LineString (com.vividsolutions.jts.geom.LineString)2 Point (com.vividsolutions.jts.geom.Point)2 FunctionImpl (org.geotools.filter.FunctionImpl)2 LiteralExpressionImpl (org.geotools.filter.LiteralExpressionImpl)2