Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
56601cd
Test: give Latitude and Longitude rounded to 3 decimal places
jwrosewell Nov 15, 2026
38fd7ff
Fix: build against the cxx release candidate that rounds angles
jwrosewell Nov 15, 2026
3172f39
Test: give IP Intelligence results as Aspect Data, on-premise and cloud
jwrosewell Nov 15, 2026
a21ace6
Test: read the accepted Evidence keys at start-up and on every refresh
jwrosewell Nov 15, 2026
bb32a44
Test: read no IP Intelligence value while processing, only when asked
jwrosewell Nov 15, 2026
5216036
Test: create the native IP Intelligence engine with no names when non…
jwrosewell Nov 15, 2026
9460d88
Test: make the property index table once, never from a later data set
jwrosewell Nov 15, 2026
4223be9
Test: let one thread at a time read an Element Data's native results
jwrosewell Nov 15, 2026
4ead739
Fix: hold one lock for every read of an Element Data's native results
jwrosewell Nov 15, 2026
c0b6f47
Test: use the query client IP ahead of the server one
jwrosewell Nov 15, 2026
b8a08ac
Test: create the native IP Intelligence engine with only the names set
jwrosewell Nov 15, 2026
a3a96c6
Test: pass native code only the accepted Evidence, and read keys once
jwrosewell Nov 15, 2026
12b7650
Test: leave cloud IP Intelligence processing to the shared engine logic
jwrosewell Nov 15, 2026
f186d34
Fix: let the shared Cloud Aspect Engine logic process cloud IP Intell…
jwrosewell Nov 15, 2026
b687740
Test: read weighted Latitude and Longitude as Float, as the engine ty…
jwrosewell Nov 16, 2026
595e3cc
Test: give Latitude and Longitude read by name as weighted Float values
jwrosewell Nov 16, 2026
624c811
Fix: type a native single property as Float in the property meta data
jwrosewell Nov 16, 2026
b8bb7e1
Merge rc into the section 9 conformance work
jwrosewell Nov 16, 2026
b8dda8b
Fix: process through the engine in the cloud request failed test, now…
jwrosewell Nov 16, 2026
004c20d
Merge rc into the IP Intelligence engine work
jwrosewell Nov 16, 2026
07bb0e9
Keep the C library at the 4.5.106 release, and the rounding test with…
jwrosewell Nov 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
package fiftyone.ipintelligence.cloud.flowelements;

import fiftyone.ipintelligence.cloud.data.IPIntelligenceDataCloud;
import fiftyone.pipeline.cloudrequestengine.data.CloudRequestData;
import fiftyone.pipeline.cloudrequestengine.flowelements.CloudAspectEngineBase;
import fiftyone.pipeline.cloudrequestengine.flowelements.CloudRequestEngine;
import fiftyone.pipeline.core.data.AccessiblePropertyMetaData;
Expand All @@ -32,7 +31,6 @@
import fiftyone.pipeline.core.data.FlowData;
import fiftyone.pipeline.core.data.factories.ElementDataFactory;
import fiftyone.pipeline.core.data.types.JavaScript;
import fiftyone.pipeline.core.exceptions.PipelineConfigurationException;
import fiftyone.pipeline.core.flowelements.Pipeline;
import fiftyone.pipeline.engines.data.AspectPropertyMetaData;
import fiftyone.pipeline.engines.data.AspectPropertyMetaDataDefault;
Expand Down Expand Up @@ -68,7 +66,7 @@ public class IPIntelligenceCloudEngine
private String dataSourceTier;
private final Object metadataLock = new Object();
// Lower-cased names of properties the cloud returns as weighted lists
// (cloud type "Weighted..."), so processEngine can read their value/weight
// (cloud type "Weighted..."), so processCloudEngine can read their value/weight
// pairs rather than treating them as a plain list.
private final Set<String> weightedPropertyNames = new HashSet<>();
CloudRequestEngine cloudRequestEngine;
Expand Down Expand Up @@ -136,128 +134,114 @@ public EvidenceKeyFilter getEvidenceKeyFilter() {
return new EvidenceKeyFilterWhitelist(new ArrayList<String>());
}

/**
* Populate the Element Data from this engine's part of the cloud
* response. The shared Cloud Aspect Engine processing finds the Cloud
* Request Engine's data, checks the request ran, and calls this only when
* there is a response.
* @param data the Flow Data being processed
* @param aspectData the Element Data to populate
* @param json the JSON response from the {@link CloudRequestEngine}
*/
@Override
protected void processEngine(FlowData data, IPIntelligenceDataCloud aspectData) {
if (cloudRequestEngine == null) {
throw new PipelineConfigurationException(
"The '" + getClass().getName() + "' requires a " +
"'CloudRequestEngine' before it in the Pipeline. This " +
"engine will be unable to produce results until this is " +
"corrected.");
}
else {
CloudRequestData requestData =
data.getFromElement(cloudRequestEngine);
setCloudRequestFailed(data, aspectData, cloudRequestEngine);
String json = requestData.getJsonResponse();

// A failed request can leave no response, which the Cloud
// Request Engine has reported.
if (json == null || json.isEmpty()) {
logger.warn("The " + getClass().getSimpleName() + " did " +
"not process as the JSON response from the " +
"CloudRequestEngine was null or empty. Please refer to " +
"errors generated by the CloudRequestEngine in the logs " +
"as this indicates an error occurred there.");
return;
protected void processCloudEngine(
FlowData data,
IPIntelligenceDataCloud aspectData,
String json) {
JSONObject jsonObj = new JSONObject(json);
JSONObject ipiObj = getElementJson(jsonObj);

Map<String, Object> propertyMap =
new TreeMap<>(String.CASE_INSENSITIVE_ORDER);

for (AspectPropertyMetaData property : getProperties()) {
// A property the response leaves out has no entry, so
// reading it throws a PropertyMissingException.
if (ipiObj.has(
property.getName().toLowerCase(Locale.ROOT)) == false) {
continue;
}

// Extract data from json to the aspectData instance.
JSONObject jsonObj = new JSONObject(json);
JSONObject ipiObj = getElementJson(jsonObj);

Map<String, Object> propertyMap =
new TreeMap<>(String.CASE_INSENSITIVE_ORDER);

for (AspectPropertyMetaData property : getProperties()) {
// A property the response leaves out has no entry, so
// reading it throws a PropertyMissingException.
if (ipiObj.has(
property.getName().toLowerCase(Locale.ROOT)) == false) {
continue;
}
if (weightedPropertyNames.contains(
property.getName().toLowerCase())) {
if (weightedPropertyNames.contains(
property.getName().toLowerCase())) {
propertyMap.put(
property.getName(),
getWeightedListAspectPropertyValue(ipiObj, property));
continue;
}
String type = property.getType().getSimpleName();
switch(type) {
case ("List"):
propertyMap.put(
property.getName(),
getWeightedListAspectPropertyValue(ipiObj, property));
continue;
}
String type = property.getType().getSimpleName();
switch(type) {
case ("List"):
propertyMap.put(
property.getName(),
getListAspectPropertyValue(ipiObj, property));
break;
case ("JavaScript"):
propertyMap.put(
property.getName(),
getJavaScriptAspectPropertyValue(ipiObj, property));
break;
case ("String"):
propertyMap.put(
property.getName(),
getStringAspectPropertyValue(ipiObj, property));
break;
case ("InetAddress"):
propertyMap.put(
property.getName(),
getInetAddressAspectPropertyValue(ipiObj, property));
break;
case ("WktString"):
propertyMap.put(
property.getName(),
getWktStringAspectPropertyValue(ipiObj, property));
break;
case ("boolean"):
propertyMap.put(
property.getName(),
getBooleanAspectPropertyValue(ipiObj, property));
break;
case ("int"):
propertyMap.put(
property.getName(),
getIntegerAspectPropertyValue(ipiObj, property));
break;
case ("double"):
propertyMap.put(
property.getName(),
getDoubleAspectPropertyValue(ipiObj, property));
getListAspectPropertyValue(ipiObj, property));
break;
case ("JavaScript"):
propertyMap.put(
property.getName(),
getJavaScriptAspectPropertyValue(ipiObj, property));
break;
case ("String"):
propertyMap.put(
property.getName(),
getStringAspectPropertyValue(ipiObj, property));
break;
case ("Float"):
propertyMap.put(
property.getName(),
getFloatAspectPropertyValue(ipiObj, property));
case ("InetAddress"):
propertyMap.put(
property.getName(),
getInetAddressAspectPropertyValue(ipiObj, property));
break;
case ("WktString"):
propertyMap.put(
property.getName(),
getWktStringAspectPropertyValue(ipiObj, property));
break;
case ("boolean"):
propertyMap.put(
property.getName(),
getBooleanAspectPropertyValue(ipiObj, property));
break;
case ("int"):
propertyMap.put(
property.getName(),
getIntegerAspectPropertyValue(ipiObj, property));
break;
case ("double"):
propertyMap.put(
property.getName(),
getDoubleAspectPropertyValue(ipiObj, property));
break;
case ("Float"):
propertyMap.put(
property.getName(),
getFloatAspectPropertyValue(ipiObj, property));
break;
default:
propertyMap.put(
property.getName(),
getStringAspectPropertyValue(ipiObj, property));
break;
default:
propertyMap.put(
property.getName(),
getStringAspectPropertyValue(ipiObj, property));
break;
}
}
}

// Add no value messages for any properties which have not yet been
// populated.
for (String key : ipiObj.keySet()) {
if (key.endsWith("nullreason")) {
String actualKey = key
.replace("nullreason", "");
if (propertyMap.containsKey(actualKey) == false) {
AspectPropertyValue<?> nullValue =
new AspectPropertyValueDefault<Object>();
nullValue.setNoValueMessage(
ipiObj.optString(key, "Unknown"));
propertyMap.put(
actualKey,
nullValue);
}
// Add no value messages for any properties which have not yet been
// populated.
for (String key : ipiObj.keySet()) {
if (key.endsWith("nullreason")) {
String actualKey = key
.replace("nullreason", "");
if (propertyMap.containsKey(actualKey) == false) {
AspectPropertyValue<?> nullValue =
new AspectPropertyValueDefault<Object>();
nullValue.setNoValueMessage(
ipiObj.optString(key, "Unknown"));
propertyMap.put(
actualKey,
nullValue);
}
}

aspectData.populateFromMap(propertyMap);
}

aspectData.populateFromMap(propertyMap);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@
import fiftyone.pipeline.core.data.AccessiblePropertyMetaData.PropertyMetaData;
import fiftyone.pipeline.core.data.FlowData;
import fiftyone.pipeline.core.data.FlowError;
import fiftyone.pipeline.core.flowelements.FlowElement;
import fiftyone.pipeline.core.flowelements.Pipeline;
import fiftyone.pipeline.core.typed.TypedKey;
import fiftyone.pipeline.engines.exceptions.PropertyMissingException;
import fiftyone.pipeline.engines.services.MissingPropertyServiceDefault;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentMatchers;
import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;

Expand Down Expand Up @@ -149,9 +152,13 @@ private IPIntelligenceDataCloud process(
flowData,
engine,
MissingPropertyServiceDefault.getInstance());
when(flowData.getOrAdd(
ArgumentMatchers.<TypedKey<IPIntelligenceDataCloud>>any(),
ArgumentMatchers.<FlowElement.DataFactory<IPIntelligenceDataCloud>>any()))
.thenReturn(data);
try {
engine.processEngine(flowData, data);
} catch (RuntimeException e) {
engine.process(flowData);
} catch (Exception e) {
// A failed request's response may not be readable. The
// property is read afterwards either way, as it is through a
// Pipeline that suppresses process exceptions.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/* *********************************************************************
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
* Copyright 2026 51 Degrees Mobile Experts Limited, Davidson House,
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
*
* This Original Work is licensed under the European Union Public Licence
* (EUPL) v.1.2 and is subject to its terms as set out below.
*
* If a copy of the EUPL was not distributed with this file, You can obtain
* one at https://opensource.org/licenses/EUPL-1.2.
*
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
* amended by the European Commission) shall be deemed incompatible for
* the purposes of the Work and the provisions of the compatibility
* clause in Article 5 of the EUPL shall not apply.
*
* If using the Work as, or as part of, a network application, by
* including the attribution notice(s) required under Article 5 of the EUPL
* in the end user terms of the application under an appropriate heading,
* such notice(s) shall fulfill the requirements of that article.
* ********************************************************************* */

package fiftyone.ipintelligence.cloud.flowelements;

import fiftyone.ipintelligence.cloud.data.IPIntelligenceDataCloud;
import fiftyone.ipintelligence.shared.IPIntelligenceData;
import fiftyone.pipeline.cloudrequestengine.data.CloudRequestData;
import fiftyone.pipeline.cloudrequestengine.flowelements.CloudRequestEngine;
import fiftyone.pipeline.core.data.AccessiblePropertyMetaData.ProductMetaData;
import fiftyone.pipeline.core.data.AccessiblePropertyMetaData.PropertyMetaData;
import fiftyone.pipeline.core.data.FlowData;
import fiftyone.pipeline.core.flowelements.Pipeline;
import fiftyone.pipeline.core.typed.TypedKey;
import fiftyone.pipeline.engines.data.AspectData;
import fiftyone.pipeline.engines.services.MissingPropertyServiceDefault;
import org.junit.Test;
import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

/**
* The cloud IP Intelligence engine populates Aspect Data, which is the IP
* Intelligence Element Data type. The engine processes a fixed response,
* so the test needs no resource key.
*/
public class DataModelTests {

@Test
@SuppressWarnings("unchecked")
public void Engine_PopulatesAspectData() throws Exception {
Logger logger = mock(Logger.class);
ILoggerFactory loggerFactory = mock(ILoggerFactory.class);
when(loggerFactory.getLogger(anyString())).thenReturn(logger);

try (IPIntelligenceCloudEngine engine =
new IPIntelligenceCloudEngineBuilder(loggerFactory).build()) {
ProductMetaData product = new ProductMetaData();
product.dataTier = "test";
product.properties = Arrays.asList(
new PropertyMetaData("registeredname", "String", "cat", null));
Map<String, ProductMetaData> products = new HashMap<>();
products.put(engine.getElementDataKey(), product);
CloudRequestEngine requestEngine = mock(CloudRequestEngine.class);
when(requestEngine.getPublicProperties()).thenReturn(products);
Pipeline pipeline = mock(Pipeline.class);
when(pipeline.getElement(CloudRequestEngine.class))
.thenReturn(requestEngine);
engine.addPipeline(pipeline);

CloudRequestData cloudData = mock(CloudRequestData.class);
when(cloudData.getJsonResponse()).thenReturn(
"{ \"ip\": { \"registeredname\": \"Example\" } }");
when(cloudData.getProcessStarted()).thenReturn(true);
FlowData flowData = mock(FlowData.class);
when(flowData.getFromElement(any(CloudRequestEngine.class)))
.thenReturn(cloudData);

IPIntelligenceDataCloud data = new IPIntelligenceDataCloudInternal(
logger,
flowData,
engine,
MissingPropertyServiceDefault.getInstance());
when(flowData.getOrAdd(any(TypedKey.class), any()))
.thenReturn(data);
engine.process(flowData);

assertTrue(data instanceof AspectData);
assertTrue(data instanceof IPIntelligenceData);
}
}
}
Loading
Loading