attrs.put(new StringBuilder(ipAttributeName).append(".geo.postalcode").toString(), response.getPostal().getCode()); flowFile = session.putAllAttributes(flowFile, attrs);
if (postal != null) { if (wantPostalCode) { parsable.addDissection(inputname, "STRING", "postal.code", postal.getCode()); parsable.addDissection(inputname, "NUMBER", "postal.confidence", postal.getConfidence());
AbstractCityResponse( City city, Continent continent, Country country, Location location, MaxMind maxmind, Postal postal, Country registeredCountry, RepresentedCountry representedCountry, List<Subdivision> subdivisions, Traits traits ) { super(continent, country, maxmind, registeredCountry, representedCountry, traits); this.city = city != null ? city : new City(); this.location = location != null ? location : new Location(); this.postal = postal != null ? postal : new Postal(); this.subdivisions = subdivisions != null ? subdivisions : new ArrayList<Subdivision>(); }
AbstractCityResponse( City city, Continent continent, Country country, Location location, MaxMind maxmind, Postal postal, Country registeredCountry, RepresentedCountry representedCountry, List<Subdivision> subdivisions, Traits traits ) { super(continent, country, maxmind, registeredCountry, representedCountry, traits); this.city = city != null ? city : new City(); this.location = location != null ? location : new Location(); this.postal = postal != null ? postal : new Postal(); this.subdivisions = subdivisions != null ? subdivisions : new ArrayList<Subdivision>(); }
private Record createRecord(final CityResponse city) { if (city == null) { return null; } final Map<String, Object> values = new HashMap<>(); values.put(CitySchema.CITY.getFieldName(), city.getCity().getName()); final Location location = city.getLocation(); values.put(CitySchema.ACCURACY.getFieldName(), location.getAccuracyRadius()); values.put(CitySchema.METRO_CODE.getFieldName(), location.getMetroCode()); values.put(CitySchema.TIMEZONE.getFieldName(), location.getTimeZone()); values.put(CitySchema.LATITUDE.getFieldName(), location.getLatitude()); values.put(CitySchema.LONGITUDE.getFieldName(), location.getLongitude()); values.put(CitySchema.CONTINENT.getFieldName(), city.getContinent().getName()); values.put(CitySchema.POSTALCODE.getFieldName(), city.getPostal().getCode()); values.put(CitySchema.COUNTRY.getFieldName(), createRecord(city.getCountry())); final Object[] subdivisions = new Object[city.getSubdivisions().size()]; int i = 0; for (final Subdivision subdivision : city.getSubdivisions()) { subdivisions[i++] = createRecord(subdivision); } values.put(CitySchema.SUBDIVISIONS.getFieldName(), subdivisions); return new MapRecord(CitySchema.GEO_SCHEMA, values); }
address.setPostalCode(response.getPostal().getCode()); address.setZone(response.getMostSpecificSubdivision().getIsoCode()); address.setCity(response.getCity().getName());
GeoProps.COUNTRY.set(geoInfo, MaxMindDbUtilities.convertNullToEmptyString(country.getIsoCode())); GeoProps.CITY.set(geoInfo, MaxMindDbUtilities.convertNullToEmptyString(city.getName())); GeoProps.POSTAL_CODE.set(geoInfo, MaxMindDbUtilities.convertNullToEmptyString(postal.getCode())); GeoProps.DMA_CODE.set(geoInfo, MaxMindDbUtilities.convertNullToEmptyString(location.getMetroCode()));
@Override public Object getValue(CityResponse response) { return response.getPostal().getCode(); } },
private GeoInfo _getGeoInfo(String ipAddress) { GeoInfo geoInfo = new GeoInfo(); if (ipAddress == null) { return geoInfo; } try{ InetAddress inetAddress = InetAddress.getByName(ipAddress); CityResponse response = reader.city(inetAddress); Country country = response.getCountry(); Continent continent = response.getContinent(); City city = response.getCity(); Postal postal = response.getPostal(); Location location = response.getLocation(); Subdivision subdivision = response.getMostSpecificSubdivision(); geoInfo.setRegion(subdivision.getName()); geoInfo.setCountryIsoCode(country.getIsoCode()); geoInfo.setCountry(country.getName()); geoInfo.setContinent(continent.getCode()); geoInfo.setCity(city.getName()); geoInfo.setPostalCode(postal.getCode()); geoInfo.setLatitude(location.getLatitude()); geoInfo.setLongitude(location.getLongitude()); return geoInfo; } catch(Exception ex){ return null; } }
attrs.put(new StringBuilder(ipAttributeName).append(".geo.postalcode").toString(), response.getPostal().getCode()); flowFile = session.putAllAttributes(flowFile, attrs);
attrs.put(new StringBuilder(ipAttributeName).append(".geo.postalcode").toString(), response.getPostal().getCode()); flowFile = session.putAllAttributes(flowFile, attrs);
case POSTAL: if(postal != null) { Optional.ofNullable(postal.getCode()).ifPresent(i -> informations.put("postal", i));
geo.put("postal_code", response.getPostal().getCode()); break; case LOCATION:
geo.put("postal_code", response.getPostal().getCode()); break; case LOCATION: