Search in sources :

Example 21 with PathResults

use of com.inova8.intelligentgraph.results.PathResults in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Local_TFL_GetPath_Tests method test_6.

/**
 * Test 6.
 */
@Test
@Order(6)
void test_6() {
    try {
        Thing _this = source.getThing("londontube:Mornington_Crescent");
        PathResults paths = _this.getPaths("(:onLine|:hasStationOnLine){1,4}/:hasStationOnLine[eq londontube:Oakleigh_Park]");
        assertEquals("Path=[[http://in4mium.com/londontube/id/Mornington_Crescent,http://in4mium.com/londontube/ref/onLine,http://in4mium.com/londontube/id/Northern,DIRECT]\r\n" + "[http://in4mium.com/londontube/id/Northern,http://in4mium.com/londontube/ref/hasStationOnLine,http://in4mium.com/londontube/id/Old_Street,DIRECT]\r\n" + "[http://in4mium.com/londontube/id/Old_Street,http://in4mium.com/londontube/ref/onLine,http://in4mium.com/londontube/id/Great_Northern,DIRECT]\r\n" + "[http://in4mium.com/londontube/id/Great_Northern,http://in4mium.com/londontube/ref/hasStationOnLine,http://in4mium.com/londontube/id/Oakleigh_Park,DIRECT]\r\n" + "]\r\n" + "Path=[[http://in4mium.com/londontube/id/Mornington_Crescent,http://in4mium.com/londontube/ref/onLine,http://in4mium.com/londontube/id/Northern,DIRECT]\r\n" + "[http://in4mium.com/londontube/id/Northern,http://in4mium.com/londontube/ref/hasStationOnLine,http://in4mium.com/londontube/id/Moorgate,DIRECT]\r\n" + "[http://in4mium.com/londontube/id/Moorgate,http://in4mium.com/londontube/ref/onLine,http://in4mium.com/londontube/id/Great_Northern,DIRECT]\r\n" + "[http://in4mium.com/londontube/id/Great_Northern,http://in4mium.com/londontube/ref/hasStationOnLine,http://in4mium.com/londontube/id/Oakleigh_Park,DIRECT]\r\n" + "]\r\n" + "", paths.toString());
    } catch (Exception e) {
        assertEquals("", e.getMessage());
        e.printStackTrace();
    }
}
Also used : PathResults(com.inova8.intelligentgraph.results.PathResults) Thing(com.inova8.intelligentgraph.model.Thing) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 22 with PathResults

use of com.inova8.intelligentgraph.results.PathResults in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Local_TFL_GetPath_Tests method test_7.

/**
 * Test 7.
 */
@Test
@Order(7)
void test_7() {
    try {
        Thing _this = source.getThing("londontube:Mornington_Crescent");
        PathResults paths = _this.getPaths(":onLine/(:hasStationOnLine/:onLine){0,4}/:hasStationOnLine[eq londontube:Oakleigh_Park]");
        for (Path path : paths) {
            assertEquals("Path=[[http://in4mium.com/londontube/id/Mornington_Crescent,http://in4mium.com/londontube/ref/onLine,http://in4mium.com/londontube/id/Northern,DIRECT]\r\n" + "[http://in4mium.com/londontube/id/Northern,http://in4mium.com/londontube/ref/hasStationOnLine,http://in4mium.com/londontube/id/Old_Street,DIRECT]\r\n" + "[http://in4mium.com/londontube/id/Old_Street,http://in4mium.com/londontube/ref/onLine,http://in4mium.com/londontube/id/Great_Northern,DIRECT]\r\n" + "[http://in4mium.com/londontube/id/Great_Northern,http://in4mium.com/londontube/ref/hasStationOnLine,http://in4mium.com/londontube/id/Oakleigh_Park,DIRECT]\r\n" + "]\r\n" + "", path.toString());
            break;
        }
    } catch (Exception e) {
        assertEquals("", e.getMessage());
        e.printStackTrace();
    }
}
Also used : Path(com.inova8.intelligentgraph.path.Path) PathResults(com.inova8.intelligentgraph.results.PathResults) Thing(com.inova8.intelligentgraph.model.Thing) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 23 with PathResults

use of com.inova8.intelligentgraph.results.PathResults in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Local_TFL_GetPath_Tests method test_2.

/**
 * Test 2.
 */
@Test
@Order(2)
void test_2() {
    try {
        Thing _this = source.getThing("londontube:Mornington_Crescent");
        PathResults paths = _this.getPaths(":connectsFrom|:connectsTo");
        assertEquals("Path=[[http://in4mium.com/londontube/id/Mornington_Crescent,http://in4mium.com/londontube/ref/connectsFrom,http://in4mium.com/londontube/id/Camden_Town,DIRECT]\r\n" + "]\r\n" + "Path=[[http://in4mium.com/londontube/id/Mornington_Crescent,http://in4mium.com/londontube/ref/connectsFrom,http://in4mium.com/londontube/id/Euston,DIRECT]\r\n" + "]\r\n" + "Path=[[http://in4mium.com/londontube/id/Mornington_Crescent,http://in4mium.com/londontube/ref/connectsTo,http://in4mium.com/londontube/id/Euston,DIRECT]\r\n" + "]\r\n" + "Path=[[http://in4mium.com/londontube/id/Mornington_Crescent,http://in4mium.com/londontube/ref/connectsTo,http://in4mium.com/londontube/id/Camden_Town,DIRECT]\r\n" + "]\r\n" + "", paths.toString());
    } catch (Exception e) {
        assertEquals("", e.getMessage());
        e.printStackTrace();
    }
}
Also used : PathResults(com.inova8.intelligentgraph.results.PathResults) Thing(com.inova8.intelligentgraph.model.Thing) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 24 with PathResults

use of com.inova8.intelligentgraph.results.PathResults in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Local_TFL_GetPath_Tests method test_4.

/**
 * Test 4.
 */
@Test
@Order(4)
void test_4() {
    try {
        Thing _this = source.getThing("londontube:Mornington_Crescent");
        PathResults paths = _this.getPaths(":connectsTo{1,2}/:connectsTo[eq londontube:Kentish_Town]");
        assertEquals("Path=[[http://in4mium.com/londontube/id/Mornington_Crescent,http://in4mium.com/londontube/ref/connectsTo,http://in4mium.com/londontube/id/Camden_Town,DIRECT]\r\n" + "[http://in4mium.com/londontube/id/Camden_Town,http://in4mium.com/londontube/ref/connectsTo,http://in4mium.com/londontube/id/Kentish_Town,DIRECT]\r\n" + "]\r\n" + "Path=[[http://in4mium.com/londontube/id/Mornington_Crescent,http://in4mium.com/londontube/ref/connectsTo,http://in4mium.com/londontube/id/Euston,DIRECT]\r\n" + "[http://in4mium.com/londontube/id/Euston,http://in4mium.com/londontube/ref/connectsTo,http://in4mium.com/londontube/id/Camden_Town,DIRECT]\r\n" + "[http://in4mium.com/londontube/id/Camden_Town,http://in4mium.com/londontube/ref/connectsTo,http://in4mium.com/londontube/id/Kentish_Town,DIRECT]\r\n" + "]\r\n" + "", paths.toString());
    } catch (Exception e) {
        assertEquals("", e.getMessage());
        e.printStackTrace();
    }
}
Also used : PathResults(com.inova8.intelligentgraph.results.PathResults) Thing(com.inova8.intelligentgraph.model.Thing) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 25 with PathResults

use of com.inova8.intelligentgraph.results.PathResults in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Thing method getPath.

/**
 * Gets the path.
 *
 * @param predicatePattern the predicate pattern
 * @return the path
 */
public Path getPath(String predicatePattern) {
    logger.debug("getPath{}\n", predicatePattern);
    PathResults pathValues = getPaths(predicatePattern, null);
    if (pathValues == null) {
        this.getEvaluationContext().getTracer().tracePathReturnNull(this, predicatePattern);
        return new NullPath();
    } else if (pathValues.hasNext()) {
        Path path = (Path) pathValues.next();
        this.getEvaluationContext().getTracer().tracePathReturn(this, predicatePattern, path);
        return path;
    } else {
        this.getEvaluationContext().getTracer().tracePathEmpty(this, predicatePattern);
        pathValues.close();
        return new NullPath();
    }
}
Also used : Path(com.inova8.intelligentgraph.path.Path) NullPath(com.inova8.intelligentgraph.path.NullPath) NullPath(com.inova8.intelligentgraph.path.NullPath) PathResults(com.inova8.intelligentgraph.results.PathResults)

Aggregations

PathResults (com.inova8.intelligentgraph.results.PathResults)37 Order (org.junit.jupiter.api.Order)33 Test (org.junit.jupiter.api.Test)33 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)33 Thing (com.inova8.intelligentgraph.model.Thing)29 Path (com.inova8.intelligentgraph.path.Path)9 Resource (com.inova8.intelligentgraph.model.Resource)4 ResourceResults (com.inova8.intelligentgraph.results.ResourceResults)3 ArrayList (java.util.ArrayList)3 Graph (com.inova8.intelligentgraph.intelligentGraphRepository.Graph)2 IntelligentGraphRepository (com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository)2 NullPath (com.inova8.intelligentgraph.path.NullPath)2 IRI (org.eclipse.rdf4j.model.IRI)2 Statement (org.eclipse.rdf4j.model.Statement)2 QueryEvaluationException (org.eclipse.rdf4j.query.QueryEvaluationException)2 SimpleDataset (org.eclipse.rdf4j.query.impl.SimpleDataset)2 Repository (org.eclipse.rdf4j.repository.Repository)2 RepositoryConnection (org.eclipse.rdf4j.repository.RepositoryConnection)2 RepositoryException (org.eclipse.rdf4j.repository.RepositoryException)2 Edge (com.inova8.intelligentgraph.path.Edge)1