Search in sources :

Example 1 with PostalCodeLocationException

use of net.geoprism.registry.io.PostalCodeLocationException in project geoprism-registry by terraframe.

the class GeoObjectImporter method parsePostalCode.

private ServerGeoObjectIF parsePostalCode(FeatureRow feature) {
    LocationBuilder builder = PostalCodeFactory.get(this.configuration.getType());
    Location location = builder.build(this.configuration.getFunction(GeoObject.CODE));
    ShapefileFunction function = location.getFunction();
    String code = (String) function.getValue(feature);
    if (code != null) {
        // Search
        ServerGeoObjectQuery query = new ServerGeoObjectService().createQuery(location.getType(), this.configuration.getStartDate());
        query.setRestriction(new ServerCodeRestriction(code));
        // Assert.assertNull(query.getSingleResult());
        ServerGeoObjectIF result = query.getSingleResult();
        if (result != null) {
            return result;
        } else {
            PostalCodeLocationException e = new PostalCodeLocationException();
            e.setCode(code);
            e.setTypeLabel(location.getType().getLabel().getValue());
            throw e;
        }
    }
    return null;
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) LocationBuilder(net.geoprism.registry.io.LocationBuilder) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) PostalCodeLocationException(net.geoprism.registry.io.PostalCodeLocationException) ShapefileFunction(net.geoprism.data.importer.ShapefileFunction) ServerGeoObjectQuery(net.geoprism.registry.query.ServerGeoObjectQuery) ServerCodeRestriction(net.geoprism.registry.query.ServerCodeRestriction) Location(net.geoprism.registry.io.Location)

Aggregations

ShapefileFunction (net.geoprism.data.importer.ShapefileFunction)1 ServerGeoObjectService (net.geoprism.registry.geoobject.ServerGeoObjectService)1 Location (net.geoprism.registry.io.Location)1 LocationBuilder (net.geoprism.registry.io.LocationBuilder)1 PostalCodeLocationException (net.geoprism.registry.io.PostalCodeLocationException)1 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)1 ServerCodeRestriction (net.geoprism.registry.query.ServerCodeRestriction)1 ServerGeoObjectQuery (net.geoprism.registry.query.ServerGeoObjectQuery)1