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;
}
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;
}
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);
}
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);
}
}
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);
}
}
Aggregations