Search in sources :

Example 16 with PropertyType

use of org.opengis.feature.PropertyType in project geotoolkit by Geomatys.

the class ComplexTypeArrayBinding method get.

@Override
public <T> T get(FeatureType candidate, String xpath, Class<T> target) throws IllegalArgumentException {
    if (candidate == null)
        return null;
    int index = toIndex(xpath);
    int i = 1;
    for (PropertyType prop : candidate.getProperties(true)) {
        if (i == index) {
            return (T) prop;
        }
        i++;
    }
    return null;
}
Also used : PropertyType(org.opengis.feature.PropertyType)

Example 17 with PropertyType

use of org.opengis.feature.PropertyType in project geotoolkit by Geomatys.

the class JaxenFeatureNavigator method getAttributeName.

@Override
public String getAttributeName(final Object o) {
    String str = null;
    if (o instanceof Fake) {
        final Fake candidate = (Fake) o;
        str = candidate.name.tip().toString();
    } else if (o instanceof Property) {
        final Property candidate = (Property) o;
        str = candidate.getName().tip().toString();
    } else if (o instanceof PropertyType) {
        final PropertyType candidate = (PropertyType) o;
        str = candidate.getName().tip().toString();
    }
    if (str != null && str.startsWith("@")) {
        str = str.substring(1);
    }
    return str;
}
Also used : PropertyType(org.opengis.feature.PropertyType) Property(org.opengis.feature.Property)

Example 18 with PropertyType

use of org.opengis.feature.PropertyType in project geotoolkit by Geomatys.

the class ListFunction method expectedType.

@Override
public PropertyTypeBuilder expectedType(FeatureType valueType, FeatureTypeBuilder addTo) {
    PropertyTypeBuilder type;
    if (parameters.isEmpty()) {
        type = addTo.addAssociation(valueType);
    } else {
        Expression<?, ?> expression = parameters.get(0);
        if (expression instanceof FeatureExpression<?, ?>) {
            type = ((FeatureExpression<?, ?>) expression).expectedType(valueType, addTo);
        } else {
            final PropertyType pt = CollectionsExt.singletonOrNull(valueType.getProperties(true));
            if (pt == null)
                return null;
            type = addTo.addProperty(pt);
        }
    }
    return type.setMinimumOccurs(0).setMaximumOccurs(Integer.MAX_VALUE).setName(OtherFunctionFactory.LIST);
}
Also used : PropertyTypeBuilder(org.apache.sis.feature.builder.PropertyTypeBuilder) FeatureExpression(org.apache.sis.internal.feature.FeatureExpression) PropertyType(org.opengis.feature.PropertyType)

Example 19 with PropertyType

use of org.opengis.feature.PropertyType in project geotoolkit by Geomatys.

the class PostgresVersionControl method trim.

private void trim(final String schemaName, final FeatureType type, final Date date, final Set<FeatureType> visited) throws VersioningException {
    if (visited.contains(type))
        return;
    visited.add(type);
    final String tableName = type.getName().tip().toString();
    // trim complex properties versioning
    for (PropertyType desc : type.getProperties(true)) {
        if (desc instanceof FeatureAssociationRole) {
            // complex type, trim sub table history
            FeatureAssociationRole far = (FeatureAssociationRole) desc;
            trim(schemaName, far.getValueType(), date, visited);
        }
    }
    Connection cnx = null;
    Statement stmt = null;
    ResultSet rs = null;
    try {
        cnx = featureStore.getDataSource().getConnection();
        stmt = cnx.createStatement();
        final StringBuilder sb = new StringBuilder("SELECT \"HSX_TrimHistory\"(");
        sb.append('\'');
        if (schemaName != null && !schemaName.isEmpty()) {
            sb.append(schemaName).append('.');
        }
        sb.append(tableName);
        sb.append('\'');
        sb.append(", TIMESTAMP '");
        sb.append(new Timestamp(date.getTime()).toString());
        sb.append("');");
        rs = stmt.executeQuery(sb.toString());
    } catch (SQLException ex) {
        throw new VersioningException(ex.getMessage(), ex);
    } finally {
        JDBCFeatureStoreUtilities.closeSafe(featureStore.getLogger(), cnx, stmt, null);
    }
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) VersioningException(org.geotoolkit.version.VersioningException) PropertyType(org.opengis.feature.PropertyType) FeatureAssociationRole(org.opengis.feature.FeatureAssociationRole) Timestamp(java.sql.Timestamp)

Example 20 with PropertyType

use of org.opengis.feature.PropertyType in project geotoolkit by Geomatys.

the class PostgresVersionControl method revert.

private void revert(final String schemaName, final FeatureType type, final Date date, final Set<FeatureType> visited) throws VersioningException {
    if (visited.contains(type))
        return;
    visited.add(type);
    final String tableName = type.getName().tip().toString();
    // revert complex properties versioning
    for (PropertyType desc : type.getProperties(true)) {
        if (desc instanceof FeatureAssociationRole) {
            // complex type, revert sub table history
            FeatureAssociationRole far = (FeatureAssociationRole) desc;
            revert(schemaName, far.getValueType(), date, visited);
        }
    }
    Connection cnx = null;
    Statement stmt = null;
    ResultSet rs = null;
    try {
        cnx = featureStore.getDataSource().getConnection();
        stmt = cnx.createStatement();
        final StringBuilder sb = new StringBuilder("SELECT \"HSX_RevertHistory\"(");
        sb.append('\'');
        if (schemaName != null && !schemaName.isEmpty()) {
            sb.append(schemaName).append('.');
        }
        sb.append(tableName);
        sb.append('\'');
        sb.append(", TIMESTAMP '");
        sb.append(new Timestamp(date.getTime()).toString());
        sb.append("');");
        rs = stmt.executeQuery(sb.toString());
    } catch (SQLException ex) {
        throw new VersioningException(ex.getMessage(), ex);
    } finally {
        JDBCFeatureStoreUtilities.closeSafe(featureStore.getLogger(), cnx, stmt, null);
    }
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) VersioningException(org.geotoolkit.version.VersioningException) PropertyType(org.opengis.feature.PropertyType) FeatureAssociationRole(org.opengis.feature.FeatureAssociationRole) Timestamp(java.sql.Timestamp)

Aggregations

PropertyType (org.opengis.feature.PropertyType)124 AttributeType (org.opengis.feature.AttributeType)55 FeatureType (org.opengis.feature.FeatureType)48 Feature (org.opengis.feature.Feature)41 ArrayList (java.util.ArrayList)38 Geometry (org.locationtech.jts.geom.Geometry)37 FeatureAssociationRole (org.opengis.feature.FeatureAssociationRole)26 GenericName (org.opengis.util.GenericName)26 FeatureTypeBuilder (org.apache.sis.feature.builder.FeatureTypeBuilder)24 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)22 PropertyNotFoundException (org.opengis.feature.PropertyNotFoundException)20 Operation (org.opengis.feature.Operation)18 DataStoreException (org.apache.sis.storage.DataStoreException)16 Test (org.junit.Test)13 LineString (org.locationtech.jts.geom.LineString)12 HashMap (java.util.HashMap)11 Filter (org.opengis.filter.Filter)11 IOException (java.io.IOException)9 SQLException (java.sql.SQLException)9 FeatureSet (org.apache.sis.storage.FeatureSet)9