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