Search in sources :

Example 31 with AttributeExpressionImpl

use of org.geotools.filter.AttributeExpressionImpl in project ddf by codice.

the class TestCswRecordMapperFilterVisitor method testVisitWithBoundingBoxProperty.

@Test
public void testVisitWithBoundingBoxProperty() {
    AttributeExpressionImpl propName = new AttributeExpressionImpl(new NameImpl(new QName(CswConstants.DUBLIN_CORE_SCHEMA, CswConstants.OWS_BOUNDING_BOX, CswConstants.DUBLIN_CORE_NAMESPACE_PREFIX)));
    CswRecordMapperFilterVisitor visitor = new CswRecordMapperFilterVisitor(metacardType, mockMetacardTypeList);
    PropertyName propertyName = (PropertyName) visitor.visit(propName, null);
    assertThat(propertyName.getPropertyName(), is(Metacard.ANY_GEO));
}
Also used : NameImpl(org.geotools.feature.NameImpl) PropertyName(org.opengis.filter.expression.PropertyName) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) QName(javax.xml.namespace.QName) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Example 32 with AttributeExpressionImpl

use of org.geotools.filter.AttributeExpressionImpl in project sldeditor by robward-scisys.

the class FilterPanelv2 method addExpression.

/**
 * Adds the expression.
 *
 * @param node the node
 * @return the expression
 */
private Expression addExpression(ExpressionNode node) {
    Expression expression = node.getExpression();
    if (expression instanceof LiteralExpressionImpl) {
        return expression;
    } else if (expression instanceof AttributeExpressionImpl) {
        return expression;
    } else if (expression instanceof FunctionExpressionImpl) {
        FunctionExpressionImpl functionExpression = (FunctionExpressionImpl) expression;
        List<Expression> parameterlist = new ArrayList<Expression>();
        for (int childIndex = 0; childIndex < node.getChildCount(); childIndex++) {
            ExpressionNode childNode = (ExpressionNode) node.getChildAt(childIndex);
            parameterlist.add(addExpression(childNode));
        }
        functionExpression.setParameters(parameterlist);
        return functionExpression;
    } else if (expression instanceof MathExpressionImpl) {
        MathExpressionImpl mathExpression = (MathExpressionImpl) expression;
        ExpressionNode leftChildNode = (ExpressionNode) node.getChildAt(0);
        mathExpression.setExpression1(addExpression(leftChildNode));
        ExpressionNode rightChildNode = (ExpressionNode) node.getChildAt(1);
        mathExpression.setExpression2(addExpression(rightChildNode));
        return mathExpression;
    }
    return null;
}
Also used : MathExpressionImpl(org.geotools.filter.MathExpressionImpl) Expression(org.opengis.filter.expression.Expression) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) ArrayList(java.util.ArrayList) FunctionExpressionImpl(org.geotools.filter.FunctionExpressionImpl)

Example 33 with AttributeExpressionImpl

use of org.geotools.filter.AttributeExpressionImpl in project sldeditor by robward-scisys.

the class FieldConfigBase method populate.

/**
 * Populate.
 *
 * @param expression the expression
 */
public void populate(Expression expression) {
    if (attributeSelectionPanel != null) {
        attributeSelectionPanel.populateAttributeComboxBox(expression);
    }
    if (expression == null) {
        expressionType = ExpressionTypeEnum.E_VALUE;
        revertToDefaultValue();
        valueUpdated();
    } else {
        if (expression instanceof LiteralExpressionImpl) {
            LiteralExpressionImpl lExpression = (LiteralExpressionImpl) expression;
            Object objValue = lExpression.getValue();
            if (objValue instanceof AttributeExpressionImpl) {
                expressionType = ExpressionTypeEnum.E_ATTRIBUTE;
                if (attributeSelectionPanel != null) {
                    attributeSelectionPanel.setAttribute((AttributeExpressionImpl) objValue);
                }
                setCachedExpression((AttributeExpressionImpl) objValue);
            } else {
                expressionType = ExpressionTypeEnum.E_VALUE;
                populateExpression(objValue);
                valueUpdated();
            }
        } else if (expression instanceof ConstantExpression) {
            ConstantExpression cExpression = (ConstantExpression) expression;
            Object objValue = cExpression.getValue();
            expressionType = ExpressionTypeEnum.E_VALUE;
            populateExpression(objValue);
            valueUpdated();
        } else if (expression instanceof NilExpression) {
            Object objValue = null;
            expressionType = ExpressionTypeEnum.E_VALUE;
            populateExpression(objValue);
            valueUpdated();
        } else if (expression instanceof ProcessFunction) {
            ProcessFunction processExpression = (ProcessFunction) expression;
            Object objValue = processExpression;
            expressionType = ExpressionTypeEnum.E_VALUE;
            populateExpression(objValue);
            valueUpdated();
        } else if (expression instanceof AttributeExpressionImpl) {
            expressionType = ExpressionTypeEnum.E_ATTRIBUTE;
            if (attributeSelectionPanel != null) {
                attributeSelectionPanel.setAttribute(expression);
            } else {
                populateExpression(expression);
            }
            setCachedExpression(expression);
        } else if (expression instanceof FunctionExpressionImpl) {
            expressionType = ExpressionTypeEnum.E_EXPRESSION;
            if (attributeSelectionPanel != null) {
                attributeSelectionPanel.populate(expression);
            }
            setCachedExpression(expression);
        } else if (expression instanceof BinaryExpression) {
            expressionType = ExpressionTypeEnum.E_EXPRESSION;
            if (attributeSelectionPanel != null) {
                attributeSelectionPanel.populate(expression);
            }
            setCachedExpression(expression);
        } else {
            expressionType = ExpressionTypeEnum.E_EXPRESSION;
        }
    }
    setValueFieldState();
}
Also used : ProcessFunction(org.geotools.process.function.ProcessFunction) BinaryExpression(org.opengis.filter.expression.BinaryExpression) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) ConstantExpression(org.geotools.filter.ConstantExpression) NilExpression(org.opengis.filter.expression.NilExpression) FunctionExpressionImpl(org.geotools.filter.FunctionExpressionImpl)

Example 34 with AttributeExpressionImpl

use of org.geotools.filter.AttributeExpressionImpl in project ddf by codice.

the class CswRecordMapperFilterVisitorTest method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    factory = new FilterFactoryImpl();
    attrExpr = factory.property(new NameImpl(new QName(CswConstants.DUBLIN_CORE_SCHEMA, UNMAPPED_PROPERTY, CswConstants.DUBLIN_CORE_NAMESPACE_PREFIX)));
    created = new AttributeExpressionImpl(new NameImpl(new QName(CswConstants.DUBLIN_CORE_SCHEMA, Core.CREATED, CswConstants.DUBLIN_CORE_NAMESPACE_PREFIX)));
    attributeRegistry = new AttributeRegistryImpl();
    attributeRegistry.registerMetacardType(CswQueryFactoryTest.getCswMetacardType());
    visitor = new CswRecordMapperFilterVisitor(DEFAULT_CSW_RECORD_MAP, attributeRegistry);
}
Also used : NameImpl(org.geotools.feature.NameImpl) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) QName(javax.xml.namespace.QName) AttributeRegistryImpl(ddf.catalog.data.impl.AttributeRegistryImpl) FilterFactoryImpl(org.geotools.filter.FilterFactoryImpl) BeforeClass(org.junit.BeforeClass)

Example 35 with AttributeExpressionImpl

use of org.geotools.filter.AttributeExpressionImpl in project ddf by codice.

the class CswRecordMapperFilterVisitorTest method testVisitWithMappedName.

@Test
public void testVisitWithMappedName() {
    AttributeExpressionImpl propName = new AttributeExpressionImpl(new NameImpl(new QName(CswConstants.DUBLIN_CORE_SCHEMA, CswConstants.CSW_ALTERNATIVE, CswConstants.DUBLIN_CORE_NAMESPACE_PREFIX)));
    CswRecordMapperFilterVisitor visitor = new CswRecordMapperFilterVisitor(DEFAULT_CSW_RECORD_MAP, attributeRegistry);
    PropertyName propertyName = (PropertyName) visitor.visit(propName, null);
    assertThat(propertyName.getPropertyName(), is(Core.TITLE));
    assertThat(propertyName.getPropertyName(), not(is(CswConstants.CSW_ALTERNATIVE)));
}
Also used : NameImpl(org.geotools.feature.NameImpl) PropertyName(org.opengis.filter.expression.PropertyName) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) QName(javax.xml.namespace.QName) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Aggregations

AttributeExpressionImpl (org.geotools.filter.AttributeExpressionImpl)50 LiteralExpressionImpl (org.geotools.filter.LiteralExpressionImpl)20 Expression (org.opengis.filter.expression.Expression)19 NameImpl (org.geotools.feature.NameImpl)13 Test (org.junit.Test)10 PropertyName (org.opengis.filter.expression.PropertyName)10 LikeFilterImpl (org.geotools.filter.LikeFilterImpl)9 ArrayList (java.util.ArrayList)8 QName (javax.xml.namespace.QName)8 FunctionExpressionImpl (org.geotools.filter.FunctionExpressionImpl)7 MathExpressionImpl (org.geotools.filter.MathExpressionImpl)7 CswQueryFactoryTest (org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest)6 FilterFactoryImpl (org.geotools.filter.FilterFactoryImpl)5 HashMap (java.util.HashMap)4 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)3 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)3 ContentTypePredicate (ddf.catalog.pubsub.predicate.ContentTypePredicate)3 ContextualPredicate (ddf.catalog.pubsub.predicate.ContextualPredicate)3 Date (java.util.Date)3 FunctionExpression (org.geotools.filter.FunctionExpression)3