use of com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Thing method create.
/**
* Creates the.
*
* @param source the source
* @param graphIri the graph iri
* @param superValue the super value
* @param evaluationContext the evaluation context
* @return the thing
*/
@SuppressWarnings("deprecation")
public static Thing create(IntelligentGraphRepository source, IRI graphIri, org.eclipse.rdf4j.model.Value superValue, EvaluationContext evaluationContext) {
Thing thing;
// graphIri.stringValue()+"~"+ superValue.stringValue();
String graphThingKey = superValue.stringValue();
if (superValue != null && source != null && source.getThings().containsKey(graphThingKey)) {
thing = source.getThings().get(graphThingKey);
thing.setSource(source);
if (evaluationContext != null) {
// if(thing.evaluationContext.getPrefixes()==null || thing.evaluationContext.getPrefixes().isEmpty())thing.evaluationContext.setPrefixes(evaluationContext.getPrefixes());
if (evaluationContext.getCustomQueryOptions() != null && !evaluationContext.getCustomQueryOptions().isEmpty())
thing.evaluationContext.setCustomQueryOptions(evaluationContext.getCustomQueryOptions());
if (evaluationContext.getTracer() != null && evaluationContext.getTracer().isTracing())
thing.evaluationContext.setTracer(evaluationContext.getTracer());
if (evaluationContext.getDataset() != null)
thing.evaluationContext.setDataset(evaluationContext.getDataset());
thing.evaluationContext.setContexts(evaluationContext.getContexts());
}
// Overwrite the graphName if not null
if (graphIri != null)
thing.graphName = graphIri;
return thing;
} else {
thing = new Thing(source, superValue, evaluationContext);
if (source != null)
source.getThings().put(graphThingKey, thing);
if (graphIri == null)
graphIri = Graph.DEFAULTGRAPH;
thing.graphName = graphIri;
}
if (evaluationContext != null)
thing.evaluationContext = evaluationContext;
else if (thing.evaluationContext == null)
thing.evaluationContext = new EvaluationContext();
return thing;
}
use of com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_GetTraceFact_Tests method test_3.
/**
* Test 3.
*/
@Test
@Order(3)
void test_3() {
try {
IntelligentGraphRepository source = IntelligentGraphRepository.create(workingRep);
Thing _this = source.getThing(iri("http://inova8.com/calc2graph/id/Unit1"), null);
source.clearCache();
Trace trace = _this.traceFact(":massThroughput");
Query.assertEqualsWOSpaces(// assertEquals
"<olstyle='list-style-type:none;'><li>Gettingfacts':massThroughput'of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a></li></li><li>...withincontexts:[file://src/test/resources/calc2graph.def.ttl,file://src/test/resources/calc2graph.data.ttl]</li></li><olstyle='list-style-type:none;'><li>Evaluatingpredicate<ahref='http://inova8.com/calc2graph/def/massThroughput'target='_blank'>massThroughput</a>of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a>,byinvoking<b>groovy</b>script</li></li><li><divstyle='border:1pxsolidblack;'><pre><code>varmassThroughput=0.0;<br>for(batterylimitin_this.getFacts(":hasProductBatteryLimit")){<br> massThroughput+=batterylimit.getFact(":massFlow").doubleValue()<br>};<br>massThroughput;</code></pre></div></li><olstyle='list-style-type:none;'><li>Gettingfacts':hasProductBatteryLimit'of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a></li></li><li>Nextfact'http://inova8.com/calc2graph/def/hasProductBatteryLimit'of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a>=http://inova8.com/calc2graph/id/BatteryLimit2</li></li><li>Gettingfacts':massFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a></li></li><li>Redirectingevaluationofpredicate<ahref='http://inova8.com/calc2graph/def/massFlow'target='_blank'>massFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>,to<b><http://inova8.com/calc2graph/id/calculateMassFlow></b>script</li></li><olstyle='list-style-type:none;'><li>Evaluatingpredicate<ahref='http://inova8.com/calc2graph/def/massFlow'target='_blank'>massFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>,byinvoking<b>groovy</b>script</li></li><li><divstyle='border:1pxsolidblack;'><pre><code>varresult=_this.getFact(":volumeFlow").floatValue()*_this.getFact(":Attribute@:density").floatValue(); <br>result;</code></pre></div></li><olstyle='list-style-type:none;'><li>Gettingfacts':volumeFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a></li></li><olstyle='list-style-type:none;'><li>Evaluatingpredicate<ahref='http://inova8.com/calc2graph/def/volumeFlow'target='_blank'>volumeFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>,byinvoking<b>javascript</b>script</li></li><li><divstyle='border:1pxsolidblack;'><pre><code>40;</code></pre></div></li><olstyle='list-style-type:none;'></ol><li>Evaluated<ahref='http://inova8.com/calc2graph/def/volumeFlow'target='_blank'>volumeFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=40^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li></ol><li>Calculated<ahref='http://inova8.com/calc2graph/def/volumeFlow'target='_blank'>volumeFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=40^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li><li>Retrievedcachedvalue<ahref='http://inova8.com/calc2graph/def/volumeFlow'target='_blank'>volumeFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=40^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li><li>Nextfact'http://inova8.com/calc2graph/def/volumeFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=40</li></li><li>Returnedfact':volumeFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=40^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li><p><li>Gettingfacts':Attribute@:density'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a></li></li><li>Nextfact'http://inova8.com/calc2graph/def/density'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=.7</li></li><li>Returnedfact':Attribute@:density'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=.7^^<ahref='http://www.w3.org/2001/XMLSchema#string'target='_blank'>string</a></li></li><p></ol><li>Evaluated<ahref='http://inova8.com/calc2graph/def/massFlow'target='_blank'>massFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=27.999999523162842^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li></ol><li>Calculated<ahref='http://inova8.com/calc2graph/def/massFlow'target='_blank'>massFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=27.999999523162842^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><li>Retrievedcachedvalue<ahref='http://inova8.com/calc2graph/def/massFlow'target='_blank'>massFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=27.999999523162842^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><li>Nextfact'http://inova8.com/calc2graph/def/massFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=27.999999523162842</li></li><li>Returnedfact':massFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=27.999999523162842^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><p><li>Nextfact'http://inova8.com/calc2graph/def/hasProductBatteryLimit'of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a>=http://inova8.com/calc2graph/id/BatteryLimit3</li></li><li>Gettingfacts':massFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</a></li></li><li>Redirectingevaluationofpredicate<ahref='http://inova8.com/calc2graph/def/massFlow'target='_blank'>massFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</a>,to<b><http://inova8.com/calc2graph/id/calculateMassFlow></b>script</li></li><olstyle='list-style-type:none;'><li>Evaluatingpredicate<ahref='http://inova8.com/calc2graph/def/massFlow'target='_blank'>massFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</a>,byinvoking<b>groovy</b>script</li></li><li><divstyle='border:1pxsolidblack;'><pre><code>varresult=_this.getFact(":volumeFlow").floatValue()*_this.getFact(":Attribute@:density").floatValue(); <br>result;</code></pre></div></li><olstyle='list-style-type:none;'><li>Gettingfacts':volumeFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</a></li></li><olstyle='list-style-type:none;'><li>Evaluatingpredicate<ahref='http://inova8.com/calc2graph/def/volumeFlow'target='_blank'>volumeFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</a>,byinvoking<b>groovy</b>script</li></li><li><divstyle='border:1pxsolidblack;'><pre><code>20;</code></pre></div></li><olstyle='list-style-type:none;'></ol><li>Evaluated<ahref='http://inova8.com/calc2graph/def/volumeFlow'target='_blank'>volumeFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</a>=20^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li></ol><li>Calculated<ahref='http://inova8.com/calc2graph/def/volumeFlow'target='_blank'>volumeFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</a>=20^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li><li>Retrievedcachedvalue<ahref='http://inova8.com/calc2graph/def/volumeFlow'target='_blank'>volumeFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</a>=20^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li><li>Nextfact'http://inova8.com/calc2graph/def/volumeFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</a>=20</li></li><li>Returnedfact':volumeFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</a>=20^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li><p><li>Gettingfacts':Attribute@:density'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</a></li></li><li>Nextfact'http://inova8.com/calc2graph/def/density'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</a>=.5</li></li><li>Returnedfact':Attribute@:density'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</a>=.5^^<ahref='http://www.w3.org/2001/XMLSchema#string'target='_blank'>string</a></li></li><p></ol><li>Evaluated<ahref='http://inova8.com/calc2graph/def/massFlow'target='_blank'>massFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</a>=10.0^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li></ol><li>Calculated<ahref='http://inova8.com/calc2graph/def/massFlow'target='_blank'>massFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</a>=10.0^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><li>Retrievedcachedvalue<ahref='http://inova8.com/calc2graph/def/massFlow'target='_blank'>massFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</a>=10.0^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><li>Nextfact'http://inova8.com/calc2graph/def/massFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</a>=10.0</li></li><li>Returnedfact':massFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</a>=10.0^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><p></ol><li>Evaluated<ahref='http://inova8.com/calc2graph/def/massThroughput'target='_blank'>massThroughput</a>of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a>=37.99999952316284^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li></ol><li>Calculated<ahref='http://inova8.com/calc2graph/def/massThroughput'target='_blank'>massThroughput</a>of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a>=37.99999952316284^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><li>Retrievedcachedvalue<ahref='http://inova8.com/calc2graph/def/massThroughput'target='_blank'>massThroughput</a>of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a>=37.99999952316284^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><li>Returnedfact'http://inova8.com/calc2graph/def/massThroughput'of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a>=37.99999952316284^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><p></ol>", trace.asHTML());
trace = _this.traceFact(":massThroughput");
Query.assertEqualsWOSpaces(// assertEquals
"<olstyle='list-style-type:none;'><li>Gettingfacts':massThroughput'of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a></li></li><li>...withincontexts:[file://src/test/resources/calc2graph.def.ttl,file://src/test/resources/calc2graph.data.ttl]</li></li><li>Retrievedcachedvalue<ahref='http://inova8.com/calc2graph/def/massThroughput'target='_blank'>massThroughput</a>of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a>=37.99999952316284^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><li>Retrievedcachedvalue<ahref='http://inova8.com/calc2graph/def/massThroughput'target='_blank'>massThroughput</a>of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a>=37.99999952316284^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><li>Returnedfact'http://inova8.com/calc2graph/def/massThroughput'of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a>=37.99999952316284^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><p></ol>", trace.asHTML());
source.clearCache();
} catch (Exception e) {
assertEquals("", e.getMessage());
e.printStackTrace();
}
}
use of com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_AddGetDeleteFact_Test method ig_0.
/**
* Ig 0.
*/
@Test
@Order(0)
void ig_0() {
try {
IntelligentGraphRepository source = IntelligentGraphRepository.create(workingRep);
source.removeGraph("<http://inova8.com/calc2graph/testGraph1>");
Graph graph = source.addGraph("<http://inova8.com/calc2graph/testGraph1>");
Thing myCountry = graph.getThing(":Country1");
myCountry.addFact(":sales", "1");
myCountry.addFact(":sales", "2");
myCountry.addFact(":sales", "3");
myCountry.addFact(":sales", "4");
ResourceResults facts = myCountry.getFacts(":sales[ge '2';lt '4']");
Integer factsinrange = facts.count();
assertEquals(2, factsinrange);
// myCountry = graph.getThing(":Country1");////////////////////////////////////////////////////
myCountry.deleteFacts(":sales[eq '3']");
factsinrange = myCountry.getFacts(":sales[ge '2';lt '4']").count();
assertEquals(1, factsinrange);
// Boolean closed =source.closeGraph("<http://inova8.com/calc2graph/testGraph1>");
source.removeGraph("<http://inova8.com/calc2graph/testGraph1>");
// assertEquals(true, closed);
} catch (Exception e) {
assertEquals("", e.getMessage());
}
}
use of com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_GetTraceFact_Tests method test_1.
/**
* Test 1.
*/
@Test
@Order(1)
void test_1() {
try {
IntelligentGraphRepository source = IntelligentGraphRepository.create(workingRep);
Thing _this = source.getThing(iri("http://inova8.com/calc2graph/id/BatteryLimit2"));
@SuppressWarnings("unused") Resource result1 = _this.getFact(":volumeFlow");
Trace trace = _this.traceFact(":massFlow");
_this = source.getThing(iri("http://inova8.com/calc2graph/id/Unit1"));
Resource result2 = _this.getFact(":massThroughput");
// assertEquals("40", result1.stringValue());
Query.assertEqualsWOSpaces(// assertEquals
"<olstyle='list-style-type:none;'><li>Gettingfacts':massFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a></li></li><li>...withincontexts:[file://src/test/resources/calc2graph.def.ttl,file://src/test/resources/calc2graph.data.ttl]</li></li><li>Redirectingevaluationofpredicate<ahref='http://inova8.com/calc2graph/def/massFlow'target='_blank'>massFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>,to<b><http://inova8.com/calc2graph/id/calculateMassFlow></b>script</li></li><olstyle='list-style-type:none;'><li>Evaluatingpredicate<ahref='http://inova8.com/calc2graph/def/massFlow'target='_blank'>massFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>,byinvoking<b>groovy</b>script</li></li><li><divstyle='border:1pxsolidblack;'><pre><code>varresult=_this.getFact(":volumeFlow").floatValue()*_this.getFact(":Attribute@:density").floatValue(); <br>result;</code></pre></div></li><olstyle='list-style-type:none;'><li>Gettingfacts':volumeFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a></li></li><li>Retrievedcachedvalue<ahref='http://inova8.com/calc2graph/def/volumeFlow'target='_blank'>volumeFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=40^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li><li>Retrievedcachedvalue<ahref='http://inova8.com/calc2graph/def/volumeFlow'target='_blank'>volumeFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=40^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li><li>Nextfact'http://inova8.com/calc2graph/def/volumeFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=40</li></li><li>Returnedfact':volumeFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=40^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li><p><li>Gettingfacts':Attribute@:density'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a></li></li><li>Nextfact'http://inova8.com/calc2graph/def/density'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=.7</li></li><li>Returnedfact':Attribute@:density'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=.7^^<ahref='http://www.w3.org/2001/XMLSchema#string'target='_blank'>string</a></li></li><p></ol><li>Evaluated<ahref='http://inova8.com/calc2graph/def/massFlow'target='_blank'>massFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=27.999999523162842^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li></ol><li>Calculated<ahref='http://inova8.com/calc2graph/def/massFlow'target='_blank'>massFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=27.999999523162842^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><li>Retrievedcachedvalue<ahref='http://inova8.com/calc2graph/def/massFlow'target='_blank'>massFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=27.999999523162842^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><li>Returnedfact'http://inova8.com/calc2graph/def/massFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=27.999999523162842^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><p></ol>", trace.asHTML());
assertEquals("37.99999952316284", result2.stringValue());
} catch (Exception e) {
assertEquals("", e.getMessage());
e.printStackTrace();
}
}
use of com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_GetContextFact_Tests method test_1.
/**
* Test 1.
*/
@Test
@Order(1)
void test_1() {
try {
IntelligentGraphRepository source = IntelligentGraphRepository.create(workingRep);
// source.prefix("<http://inova8.com/calc2graph/def/>");
// source.prefix("rdfs", "<http://www.w3.org/2000/01/rdf-schema#>");
source.removeGraph("<http://inova8.com/calc2graph/contextGraph>");
// source.prefix("xsd", "<http://www.w3.org/2001/XMLSchema#>");
Graph graph = source.addGraph("<http://inova8.com/calc2graph/contextGraph>");
Thing myCountry = graph.getThing(":myCountry");
myCountry.addFact(":myOption", "_customQueryOptions.get(\"time\").integerValue() ;", SCRIPT.GROOVY);
CustomQueryOptions customQueryOptions1 = new CustomQueryOptions();
customQueryOptions1.add("time", 42);
customQueryOptions1.add("name", "Peter");
Thing myCountry1 = graph.getThing(":myCountry");
Resource result;
result = myCountry1.getFact("<http://inova8.com/calc2graph/def/myOption>", customQueryOptions1);
assertEquals("42", result.stringValue());
CustomQueryOptions customQueryOptions2 = new CustomQueryOptions();
customQueryOptions2.add("time", 43);
result = myCountry1.getFact("<http://inova8.com/calc2graph/def/myOption>", customQueryOptions2);
assertEquals("43", result.stringValue());
CustomQueryOptions customQueryOptions3 = new CustomQueryOptions();
customQueryOptions3.add("time", 2019);
result = myCountry.getFact(":myOption&time='2019'^^xsd:int", customQueryOptions3);
assertEquals("2019", result.stringValue());
ResourceResults results = myCountry.getFacts("<http://inova8.com/calc2graph/def/myOption>&time='2020'^^xsd:int");
for (Resource result1 : results) {
assertEquals("2020", result1.stringValue());
}
} catch (Exception e) {
assertEquals("", e.getMessage());
e.printStackTrace();
}
}
Aggregations