use of eu.esdihumboldt.hale.common.schema.model.constraint.type.GeometryType in project hale by halestudio.
the class GeometryCondition method accept.
/**
* @see EntityCondition#accept(Entity)
*/
@Override
public boolean accept(Type entity) {
TypeDefinition type = entity.getDefinition().getDefinition();
if (!type.getConstraint(HasValueFlag.class).isEnabled() && !type.getConstraint(AugmentedValueFlag.class).isEnabled()) {
// whether defined in the schema or augmented
return false;
}
GeometryType geometryType = entity.getDefinition().getDefinition().getConstraint(GeometryType.class);
if (!geometryType.isGeometry()) {
// is no geometry type
return false;
}
Collection<Class<? extends Geometry>> tmpBindings = bindings;
if (tmpBindings == null) {
// check only if it is a geometry
tmpBindings = new HashSet<Class<? extends Geometry>>();
tmpBindings.add(Geometry.class);
}
// otherwise check the allowed bindings
// default
boolean to = true;
switch(entity.getDefinition().getSchemaSpace()) {
case SOURCE:
to = false;
break;
case TARGET:
to = true;
break;
}
for (Class<? extends Geometry> compatibleClass : tmpBindings) {
Binding binding = type.getConstraint(Binding.class);
boolean isCollection = Collection.class.isAssignableFrom(binding.getBinding());
// check binding
if (isCompatibleClass(geometryType.getBinding(), to, compatibleClass, allowConversion) && (!isCollection || allowCollection)) {
return true;
}
}
// no check succeeded
return false;
}
Aggregations