@Test public void testNodes () { log.info ( "Verifying Nodes" ); Dataset ds = rdfMgr.getDataSet (); Model m = ds.getDefaultModel (); CyNode cyNode = rdfMgr.getCyNode ( m.getResource ( iri ( "ex:1" ) ), SPARQL_NODE_LABELS, SPARQL_NODE_PROPS ); assertNotNull ( "CyNode 1 not found!", cyNode ); log.info ( "Got node 1" ); assertEquals ( "CyNode 1's Label not found!", 1, cyNode.getLabels ().size () ); assertEquals ( "CyNode 1's Label not found!", "TestNode", cyNode.getLabels ().iterator ().next () ); assertEquals ( "CyNode 1's wrong properties count!", 2, cyNode.getProperties ().size () ); assertEquals ( "CyNode 1's prop1 not found!", "10.0", cyNode.getPropValue ( "attrib1" ) ); assertEquals ( "CyNode 1's prop2 not found!", "a string", cyNode.getPropValue ( "attrib2" ) ); log.info ( "End" ); }
public CyNode getCyNode ( Resource nodeRes, String labelsSparql, String propsSparql ) { ensureOpen (); QuerySolutionMap params = new QuerySolutionMap (); params.add ( "iri", nodeRes ); CyNode cyNode = new CyNode ( nodeRes.getURI () ); if ( labelsSparql != null ) { Query qry = SparqlUtils.getCachedQuery ( labelsSparql ); Function<String, String> labelIdConverter = this.getCyNodeLabelIdConverter (); boolean wasInTnx = dataSet.isInTransaction (); if ( !wasInTnx ) dataSet.begin ( ReadWrite.READ ); try { QueryExecution qx = QueryExecutionFactory.create ( qry, this.getDataSet(), params ); qx.execSelect ().forEachRemaining ( row -> cyNode.addLabel ( this.getCypherId ( row.get ( "label" ), labelIdConverter ) ) ); } finally { if ( !wasInTnx && dataSet.isInTransaction () ) dataSet.end (); } } this.addCypherProps ( cyNode, propsSparql ); return cyNode; }
RdfDataManager extends TDBEndPointHelper { public CyNode getCyNode ( Resource nodeRes, String labelsSparql, String propsSparql ) { ensureOpen (); QuerySolutionMap params = new QuerySolutionMap (); params.add ( "iri", nodeRes ); CyNode cyNode = new CyNode ( nodeRes.getURI () ); if ( labelsSparql != null ) { Query qry = SparqlUtils.getCachedQuery ( labelsSparql ); Function<String, String> labelIdConverter = this.getCyNodeLabelIdConverter (); boolean wasInTnx = dataSet.isInTransaction (); if ( !wasInTnx ) dataSet.begin ( ReadWrite.READ ); try { QueryExecution qx = QueryExecutionFactory.create ( qry, this.getDataSet(), params ); qx.execSelect ().forEachRemaining ( row -> cyNode.addLabel ( this.getCypherId ( row.get ( "label" ), labelIdConverter ) ) ); } finally { if ( !wasInTnx && dataSet.isInTransaction () ) dataSet.end (); } } this.addCypherProps ( cyNode, propsSparql ); return cyNode; } }
RdfDataManager extends TDBEndPointHelper { public CyNode getCyNode ( Resource nodeRes, String labelsSparql, String propsSparql ) { ensureOpen (); QuerySolutionMap params = new QuerySolutionMap (); params.add ( "iri", nodeRes ); CyNode cyNode = new CyNode ( nodeRes.getURI () ); if ( labelsSparql != null ) { Query qry = SparqlUtils.getCachedQuery ( labelsSparql ); Function<String, String> labelIdConverter = this.getCyNodeLabelIdConverter (); boolean wasInTnx = dataSet.isInTransaction (); if ( !wasInTnx ) dataSet.begin ( ReadWrite.READ ); try { QueryExecution qx = QueryExecutionFactory.create ( qry, this.getDataSet(), params ); qx.execSelect ().forEachRemaining ( row -> cyNode.addLabel ( this.getCypherId ( row.get ( "label" ), labelIdConverter ) ) ); } finally { if ( !wasInTnx && dataSet.isInTransaction () ) dataSet.end (); } } this.addCypherProps ( cyNode, propsSparql ); return cyNode; } RdfDataManager();  RdfDataManager( String tdbPath ); }
RdfDataManager extends TDBEndPointHelper { public CyNode getCyNode ( Resource nodeRes, String labelsSparql, String propsSparql ) { ensureOpen (); QuerySolutionMap params = new QuerySolutionMap (); params.add ( "iri", nodeRes ); CyNode cyNode = new CyNode ( nodeRes.getURI () ); if ( labelsSparql != null ) { Query qry = SparqlUtils.getCachedQuery ( labelsSparql ); Function<String, String> labelIdConverter = this.getCyNodeLabelIdConverter (); boolean wasInTnx = dataSet.isInTransaction (); if ( !wasInTnx ) dataSet.begin ( ReadWrite.READ ); try { QueryExecution qx = QueryExecutionFactory.create ( qry, this.getDataSet(), params ); qx.execSelect ().forEachRemaining ( row -> cyNode.addLabel ( this.getCypherId ( row.get ( "label" ), labelIdConverter ) ) ); } finally { if ( !wasInTnx && dataSet.isInTransaction () ) dataSet.end (); } } this.addCypherProps ( cyNode, propsSparql ); return cyNode; } RdfDataManager();  RdfDataManager( String tdbPath ); CyNode getCyNode( Resource nodeRes, String labelsSparql, String propsSparql ); CyNode getCyNode( String nodeIri, String labelsSparql, String propsSparql ); long processNodeIris( String nodeIrisSparql, Consumer<Resource> action ); CyRelation getCyRelation( QuerySolution relRow ); void setCyRelationProps( CyRelation cyRelation, String propsSparql ); long processRelationIris( String relationIrisSparql, Consumer<QuerySolution> action ); Function<String, String> getCyNodeLabelIdConverter(); @Autowired ( required = false ) @Qualifier ( "nodeLabelIdConverter" ) void setCyNodeLabelIdConverter( Function<String, String> labelIdConverter ); Function<String, String> getCyRelationTypeIdConverter(); @Autowired ( required = false ) @Qualifier ( "relationIdConverter" ) void setCyRelationTypeIdConverter( Function<String, String> relationIdConverter ); Function<String, String> getCyPropertyIdConverter(); @Autowired ( required = false ) @Qualifier ( "propertyIdConverter" ) void setCyPropertyIdConverter( Function<String, String> propertyIdConverter ); @Override long processSelect( String logPrefix, String sparql, Consumer<QuerySolution> action ); }
RdfDataManager extends TDBEndPointHelper { public CyNode getCyNode ( Resource nodeRes, String labelsSparql, String propsSparql ) { ensureOpen (); QuerySolutionMap params = new QuerySolutionMap (); params.add ( "iri", nodeRes ); CyNode cyNode = new CyNode ( nodeRes.getURI () ); if ( labelsSparql != null ) { Query qry = SparqlUtils.getCachedQuery ( labelsSparql ); Function<String, String> labelIdConverter = this.getCyNodeLabelIdConverter (); boolean wasInTnx = dataSet.isInTransaction (); if ( !wasInTnx ) dataSet.begin ( ReadWrite.READ ); try { QueryExecution qx = QueryExecutionFactory.create ( qry, this.getDataSet(), params ); qx.execSelect ().forEachRemaining ( row -> cyNode.addLabel ( this.getCypherId ( row.get ( "label" ), labelIdConverter ) ) ); } finally { if ( !wasInTnx && dataSet.isInTransaction () ) dataSet.end (); } } this.addCypherProps ( cyNode, propsSparql ); return cyNode; } RdfDataManager();  RdfDataManager( String tdbPath ); CyNode getCyNode( Resource nodeRes, String labelsSparql, String propsSparql ); CyNode getCyNode( String nodeIri, String labelsSparql, String propsSparql ); long processNodeIris( String nodeIrisSparql, Consumer<Resource> action ); CyRelation getCyRelation( QuerySolution relRow ); void setCyRelationProps( CyRelation cyRelation, String propsSparql ); long processRelationIris( String relationIrisSparql, Consumer<QuerySolution> action ); Function<String, String> getCyNodeLabelIdConverter(); @Autowired ( required = false ) @Qualifier ( "nodeLabelIdConverter" ) void setCyNodeLabelIdConverter( Function<String, String> labelIdConverter ); Function<String, String> getCyRelationTypeIdConverter(); @Autowired ( required = false ) @Qualifier ( "relationIdConverter" ) void setCyRelationTypeIdConverter( Function<String, String> relationIdConverter ); Function<String, String> getCyPropertyIdConverter(); @Autowired ( required = false ) @Qualifier ( "propertyIdConverter" ) void setCyPropertyIdConverter( Function<String, String> propertyIdConverter ); @Override long processSelect( String logPrefix, String sparql, Consumer<QuerySolution> action );  }