Search in sources :

Example 41 with AttributeExpressionImpl

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

the class CswQueryFactory method buildSort.

private SortBy[] buildSort(SortByType sort) throws CswException {
    if (sort == null || sort.getSortProperty() == null) {
        return null;
    }
    SortBy[] sortByArr = parseSortBy(sort);
    if (sortByArr == null || sortByArr.length == 0) {
        return null;
    }
    List<SortBy> sortBys = new ArrayList<>(sortByArr.length);
    for (SortBy cswSortBy : sortByArr) {
        if (cswSortBy.getPropertyName() == null) {
            LOGGER.debug("No property name in primary sort criteria");
            return null;
        }
        String name = cswSortBy.getPropertyName().getPropertyName();
        PropertyName propName = new AttributeExpressionImpl(new NameImpl(name));
        SortBy sortBy = new SortByImpl(propName, cswSortBy.getSortOrder());
        sortBys.add(sortBy);
    }
    if (sortBys.isEmpty()) {
        return null;
    }
    return sortBys.toArray(new SortBy[0]);
}
Also used : PropertyName(org.opengis.filter.expression.PropertyName) NameImpl(org.geotools.feature.NameImpl) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) SortByImpl(ddf.catalog.filter.impl.SortByImpl) SortBy(org.opengis.filter.sort.SortBy) ArrayList(java.util.ArrayList)

Example 42 with AttributeExpressionImpl

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

the class CoordinateReferenceSystemValues method setValue.

/*
     * (non-Javadoc)
     *
     * @see
     * com.sldeditor.rendertransformation.types.RenderTransformValueInterface#setValue(java.lang.
     * Object)
     */
@Override
public void setValue(Object aValue) {
    this.value = null;
    this.expression = null;
    if (aValue instanceof LiteralExpressionImpl) {
        LiteralExpressionImpl literal = (LiteralExpressionImpl) aValue;
        if (literal.getValue() != null) {
            value = literal.toString();
        }
    } else if ((aValue instanceof AttributeExpressionImpl) || (aValue instanceof FunctionExpressionImpl) || (aValue instanceof MathExpressionImpl)) {
        this.expression = (Expression) aValue;
    } else {
        if (aValue instanceof String) {
            value = ((String) aValue);
        }
    }
}
Also used : MathExpressionImpl(org.geotools.filter.MathExpressionImpl) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) Expression(org.opengis.filter.expression.Expression) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) FunctionExpressionImpl(org.geotools.filter.FunctionExpressionImpl)

Example 43 with AttributeExpressionImpl

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

the class FieldConfigGeometryField method populateExpression.

/**
 * Populate expression.
 *
 * @param objValue the obj value
 */
/*
     * (non-Javadoc)
     *
     * @see com.sldeditor.ui.detail.config.FieldConfigBase#populateExpression(java.lang.Object)
     */
@Override
public void populateExpression(Object objValue) {
    String propertyName = null;
    if (objValue instanceof PropertyExistsFunction) {
        Expression e = ((PropertyExistsFunction) objValue).getParameters().get(0);
        propertyName = e.toString();
    } else if (objValue instanceof AttributeExpressionImpl) {
        propertyName = ((AttributeExpressionImpl) objValue).getPropertyName();
    } else if (objValue instanceof LiteralExpressionImpl) {
        propertyName = AttributeUtils.extract((String) ((LiteralExpressionImpl) objValue).getValue());
    }
    populateField(propertyName);
}
Also used : PropertyExistsFunction(org.geotools.filter.function.PropertyExistsFunction) Expression(org.opengis.filter.expression.Expression) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl)

Example 44 with AttributeExpressionImpl

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

the class FieldConfigBase method attributeUpdated.

/**
 * Attribute updated.
 *
 * @param attributeName the attribute name
 */
@Override
public void attributeUpdated(String attributeName) {
    expressionType = ExpressionTypeEnum.E_ATTRIBUTE;
    NameImpl name = new NameImpl(attributeName);
    setCachedExpression(new AttributeExpressionImpl(name));
    setValueFieldState();
    fireDataChanged();
}
Also used : NameImpl(org.geotools.feature.NameImpl) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl)

Example 45 with AttributeExpressionImpl

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

the class WindBarbDetails method updateSymbol.

/**
 * Update symbol.
 */
private void updateSymbol() {
    if (!Controller.getInstance().isPopulating()) {
        ValueComboBoxData windSpeedUnits = fieldConfigVisitor.getComboBox(FieldIdEnum.WINDBARB_WINDSPEED_UNITS);
        Expression windSpeedExpression = fieldConfigVisitor.getExpression(FieldIdEnum.WINDBARB_WINDSPEED);
        boolean inNorthernHemisphere = fieldConfigVisitor.getBoolean(FieldIdEnum.WINDBARB_NORTHERN_HEMISPHERE);
        Object windSpeed = null;
        if (windSpeedExpression == null) {
            windSpeed = Integer.valueOf(0);
        } else if (windSpeedExpression instanceof LiteralExpressionImpl) {
            LiteralExpressionImpl literalExpression = (LiteralExpressionImpl) windSpeedExpression;
            windSpeed = literalExpression.getValue();
        } else if (windSpeedExpression instanceof ConstantExpression) {
            ConstantExpression constantExpression = (ConstantExpression) windSpeedExpression;
            windSpeed = constantExpression.getValue();
        } else if (windSpeedExpression instanceof AttributeExpressionImpl) {
            AttributeExpressionImpl attributeExpression = (AttributeExpressionImpl) windSpeedExpression;
            windSpeed = String.format("<ogc:PropertyName>%s</ogc:PropertyName>", attributeExpression.getPropertyName());
        } else {
            ConsoleManager.getInstance().error(this, Localisation.getField(WindBarbDetails.class, "WindBarb.windspeedError1") + windSpeedExpression.getClass().getName());
        }
        String url = String.format("windbarbs://default(%s)[%s]", windSpeed, windSpeedUnits.getKey());
        if (!inNorthernHemisphere) {
            url = url + HEMISPHERE_S;
        }
        windBarbsExpression = getFilterFactory().literal(url);
        if (parentObj != null) {
            parentObj.windBarbValueUpdated();
        }
    }
}
Also used : ConstantExpression(org.geotools.filter.ConstantExpression) Expression(org.opengis.filter.expression.Expression) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) ConstantExpression(org.geotools.filter.ConstantExpression) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

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