• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java GraphUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.openrdf.model.util.GraphUtil的典型用法代码示例。如果您正苦于以下问题:Java GraphUtil类的具体用法?Java GraphUtil怎么用?Java GraphUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GraphUtil类属于org.openrdf.model.util包,在下文中一共展示了GraphUtil类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: enrich

import org.openrdf.model.util.GraphUtil; //导入依赖的package包/类
@Override
	public List<Statement> enrich(EnricherConfig config, NamedGraph graph) {
		List<Statement> statements = new ArrayList<Statement>();
		ValueFactory vf = graph.getValueFactory();
		
		try {
			double latitude = GraphUtil.getUniqueObjectLiteral(graph, null, vf.createURI("http://www.w3.org/2003/01/geo/wgs84_pos#lat")).doubleValue();
			double longitude = GraphUtil.getUniqueObjectLiteral(graph, null, vf.createURI("http://www.w3.org/2003/01/geo/wgs84_pos#long")).doubleValue();

			List<Toponym> searchResult = WebService.findNearby(latitude, longitude, FeatureClass.A, new String[]{"ADM2"});
//			List<Toponym> searchResult = WebService.findNearbyPlaceName(latitude, longitude, 50, 10);
			
			for (Toponym toponym : searchResult) {
//				System.out.println(toponym.toString());
				statements.add(
						vf.createStatement(graph.getGraphUri(), 
						vf.createURI("http://www.geonames.org/ontology#Feature"), 
						vf.createURI("http://sws.geonames.org/"+toponym.getGeoNameId())));
			}			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return statements;
	}
 
开发者ID:erfgoed-en-locatie,项目名称:artsholland-platform,代码行数:26,代码来源:GeoNamesEnricher.java


示例2: parse

import org.openrdf.model.util.GraphUtil; //导入依赖的package包/类
@Override
/**
 * parse graph representation of config
 *
    * @Note - Graph is deprecating soon (in Sesame) to be replaced by Model
 */
public void parse(Graph graph, Resource implNode)
		throws RepositoryConfigException {
	super.parse(graph, implNode);

	try {
		URI uri = GraphUtil.getOptionalObjectURI(graph, implNode, QUERY_ENDPOINT);
		if (uri != null) {
			setQueryEndpointUrl(uri.stringValue());
		}

		uri = GraphUtil.getOptionalObjectURI(graph, implNode, UPDATE_ENDPOINT);
		if (uri != null) {
			setUpdateEndpointUrl(uri.stringValue());
		}
	} catch (GraphUtilException e) {
		throw new RepositoryConfigException(e.getMessage(), e);
	}
}
 
开发者ID:marklogic,项目名称:marklogic-sesame,代码行数:25,代码来源:MarkLogicRepositoryConfig.java


示例3: getOptionalObjectLiteral

import org.openrdf.model.util.GraphUtil; //导入依赖的package包/类
private Literal getOptionalObjectLiteral(Model model, Resource subject,
                                         URI predicate, String lang) {
    Set<Value> objects = GraphUtil.getObjects(model, subject, predicate);

    Literal result = null;

    for (Value nextValue : objects) {
        if (nextValue instanceof Literal) {
            final Literal literal = (Literal) nextValue;
            if (result == null || (lang != null && lang.equals(literal.getLanguage()))) {
                result = literal;
            }
        }
    }
    return result;
}
 
开发者ID:tkurz,项目名称:sesame-vocab-builder,代码行数:17,代码来源:VocabBuilder.java


示例4: updateMetadataGraph

import org.openrdf.model.util.GraphUtil; //导入依赖的package包/类
private void updateMetadataGraph(INamedGraphWithMetaData graph, File metaGraphFile) throws AnzoIoException {
    INamedGraph metaGraph = null ;
    try {
        metaGraph = graph.getMetaDataGraph() ;
        Graph metaFile = loadGraph(metaGraphFile) ;
        URI newAcl = GraphUtil.getUniqueObjectURI(metaFile, graph.getNamedGraphUri(), uri(AnzoPredicates.USES_ACL)) ;
        AnzoFactory.createACL(newAcl, metaGraph) ;
        Iterator<Statement> acl = metaFile.match(newAcl, null, null) ;
        while (acl.hasNext()) {
            metaGraph.add(acl.next()) ;
        }
        metaGraph.add(graph.getNamedGraphUri(), uri(AnzoPredicates.USES_ACL), newAcl) ;
    } catch (GraphUtilException e) {
        throw new AnzoIoException("Unable to retrieve new ACL from meta graph file: " + metaGraphFile.getPath() + ".", e) ;
    } finally {
        if (metaGraph == null) {
            metaGraph.close() ;
        }
    }
}
 
开发者ID:NCIP,项目名称:digital-model-repository,代码行数:21,代码来源:AnzoIo.java


示例5: parse

import org.openrdf.model.util.GraphUtil; //导入依赖的package包/类
@Override
public void parse(final Graph graph, final Resource implNode) throws SailConfigException {
    super.parse(graph, implNode);
    System.out.println("parsing");

    try {
        final Literal userLit = GraphUtil.getOptionalObjectLiteral(graph, implNode, USER);
        if (userLit != null) {
            setUser(userLit.getLabel());
        }
        final Literal pwdLit = GraphUtil.getOptionalObjectLiteral(graph, implNode, PASSWORD);
        if (pwdLit != null) {
            setPassword(pwdLit.getLabel());
        }
        final Literal instLit = GraphUtil.getOptionalObjectLiteral(graph, implNode, INSTANCE);
        if (instLit != null) {
            setInstance(instLit.getLabel());
        }
        final Literal zooLit = GraphUtil.getOptionalObjectLiteral(graph, implNode, ZOOKEEPERS);
        if (zooLit != null) {
            setZookeepers(zooLit.getLabel());
        }
        final Literal mockLit = GraphUtil.getOptionalObjectLiteral(graph, implNode, IS_MOCK);
        if (mockLit != null) {
            setMock(Boolean.parseBoolean(mockLit.getLabel()));
        }
    } catch (final GraphUtilException e) {
        throw new SailConfigException(e.getMessage(), e);
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:31,代码来源:RyaAccumuloSailConfig.java


示例6: enrich

import org.openrdf.model.util.GraphUtil; //导入依赖的package包/类
@Override
public List<Statement> enrich(EnricherConfig config, NamedGraph graph) {
	List<Statement> statements = new ArrayList<Statement>();
	ValueFactory vf = graph.getValueFactory();

	RepositoryConnection connection = config.getConnection();

	for (String p : PREDICATES) {
		URI predicate = vf.createURI(p);
		Value subject = graph.getGraphUri();

		List<Value> objects = new ArrayList<Value>();
		objects.addAll((Collection<Value>) GraphUtil.getObjects(graph, null,
				predicate));
		if (objects.size() > 0) {
			String message = "Keeping \"";

			int i = getBestTriple(p, objects);
			Value objectKept = objects.get(i);
			message += objectKept.toString() + "\", removing ";
			objects.remove(objectKept);

			for (Value object : objects) {
				try {
					message += "\"" + object.toString() + "\", ";
					connection.remove((Resource) subject, predicate, object);
				} catch (Exception e) {
					logger.error(e.getMessage(), e);
				}
			}
			logger.debug(message);
		}
	}
	return statements;
}
 
开发者ID:erfgoed-en-locatie,项目名称:artsholland-platform,代码行数:36,代码来源:AddressCleanup.java


示例7: parse

import org.openrdf.model.util.GraphUtil; //导入依赖的package包/类
@Override
public void parse(Graph graph, Resource implNode) throws RepositoryConfigException
{
   super.parse(graph, implNode);
   try {
      Literal configPath = GraphUtil.getOptionalObjectLiteral(graph, implNode, SEMANTIKA_CONFIG_PATH);
      if (configPath != null) {
         setConfigurationPath(configPath.getLabel());
      }
   }
   catch (GraphUtilException e) {
      throw new RepositoryConfigException(e);
   }
}
 
开发者ID:obidea,项目名称:semantika-endpoint,代码行数:15,代码来源:SemantikaRepositoryConfig.java


示例8: testGetRepositoryConfig

import org.openrdf.model.util.GraphUtil; //导入依赖的package包/类
/**
 * Test method for
 * {@link org.openrdf.repository.manager.RepositoryManager#getRepositoryConfig(java.lang.String)}
 * .
 * 
 * @throws Exception
 */
@Test
public void testGetRepositoryConfig() throws Exception
{
    RepositoryConfig repositoryConfig = testRepositoryManager.getRepositoryConfig("SYSTEM");
    
    assertNotNull(repositoryConfig);
    
    Model exportGraph = new LinkedHashModel();
    repositoryConfig.export(exportGraph);
    
    assertEquals(23, exportGraph.size());
    Rio.write(exportGraph, System.out, RDFFormat.NQUADS);
    
    assertEquals(5, exportGraph.filter(null, StardogRepositoryConfig.NAMESPACE_NAME_URI, null).size());
    assertEquals(5, exportGraph.filter(null, StardogRepositoryConfig.NAMESPACE_PREFIX_URI, null).size());
    
    Resource topNode = GraphUtil.getUniqueSubject(exportGraph, RDF.TYPE, RepositoryConfigSchema.REPOSITORY);
    
    System.out.println(topNode);
    
    RepositoryConfig imported = new RepositoryConfig();
    imported.parse(exportGraph, topNode);
    
    // StardogRepositoryConfig test = new StardogRepositoryConfig();
    // test.parse(exportGraph, topNode);
    
    Model secondExport = new LinkedHashModel();
    imported.export(secondExport);
    
    assertEquals(23, secondExport.size());
    System.out.println("Round-tripped configuration...");
    Rio.write(secondExport, System.out, RDFFormat.NQUADS);
    
    // Test round-tripping of the configuration
    assertTrue(ModelUtil.equals(exportGraph, secondExport));
}
 
开发者ID:ansell,项目名称:sesame-stardog-manager,代码行数:44,代码来源:StardogRepositoryManagerTest.java


示例9: loadGraphsFromManifest

import org.openrdf.model.util.GraphUtil; //导入依赖的package包/类
public void loadGraphsFromManifest(DatasetService anzo, File manifestFile) throws AnzoIoException {
    String baseUrl ;
    try {
        String manifestPath = manifestFile.getParentFile().getCanonicalPath() ;
        baseUrl = "file://" + manifestPath + File.separator ;
    } catch (IOException e) {
        throw new AnzoIoException("Error generating base url for manifest file: " + manifestFile.getPath() + ".", e) ;
    }
    Graph manifest = loadGraph(manifestFile, baseUrl) ;
    Iterator<Resource> namedGraphs = GraphUtil.getSubjectIterator(manifest, uri(Rdf.TYPE), uri(NAMED_GRAPH)) ;
    while (namedGraphs.hasNext()) {
        Resource namedGraph = namedGraphs.next() ;
        loadNamedGraph(anzo, manifest.match(namedGraph, null, null)) ;
    }
}
 
开发者ID:NCIP,项目名称:digital-model-repository,代码行数:16,代码来源:AnzoIo.java


示例10: testCreateFromTemplateName

import org.openrdf.model.util.GraphUtil; //导入依赖的package包/类
@Test
    public void testCreateFromTemplateName() throws Exception {
        LocalRepositoryManager repoman = new LocalRepositoryManager(Files.createTempDir());
        repoman.initialize();
        
        
        
        try(InputStream templateStream = RepositoryConfig.class.getResourceAsStream("RyaAccumuloSail.ttl")) {
            String template = IOUtils.toString(templateStream);
            
            final ConfigTemplate configTemplate = new ConfigTemplate(template);
            final Map<String, String> valueMap = ImmutableMap.<String, String> builder()
                    .put("Repository ID", "RyaAccumuloSail")
                    .put("Repository title", "RyaAccumuloSail Store")
                    .put("Rya Accumulo user", "root")
                    .put("Rya Accumulo password", "")
                    .put("Rya Accumulo instance", "dev")
                    .put("Rya Accumulo zookeepers", "zoo1,zoo2,zoo3")
                    .put("Rya Accumulo is mock", "true")
                    .build();
            
            final String configString = configTemplate.render(valueMap);
            
//            final Repository systemRepo = this.state.getManager().getSystemRepository();
            final Graph graph = new LinkedHashModel();
            final RDFParser rdfParser = Rio.createParser(RDFFormat.TURTLE);
            rdfParser.setRDFHandler(new StatementCollector(graph));
            rdfParser.parse(new StringReader(configString), RepositoryConfigSchema.NAMESPACE);
            final Resource repositoryNode = GraphUtil.getUniqueSubject(graph, RDF.TYPE,
                    RepositoryConfigSchema.REPOSITORY);
            final RepositoryConfig repConfig = RepositoryConfig.create(graph, repositoryNode);
            repConfig.validate();

            
            repoman.addRepositoryConfig(repConfig);
            
            Repository r = repoman.getRepository("RyaAccumuloSail");
            r.initialize();
            
        }

    }
 
开发者ID:apache,项目名称:incubator-rya,代码行数:43,代码来源:RyaAccumuloSailFactoryTest.java


示例11: enrich

import org.openrdf.model.util.GraphUtil; //导入依赖的package包/类
@Override
public List<Statement> enrich(EnricherConfig config, NamedGraph graph) {
	List<Statement> statements = new ArrayList<Statement>();
	ValueFactory vf = graph.getValueFactory();
	RepositoryConnection conn = config.getConnection();
	try {
		
		String classUri = platformConfig.getString("platform.classUri");						
		String homepageStr = GraphUtil.getOptionalObjectResource(graph, null, vf.createURI("http://xmlns.com/foaf/0.1/homepage")).toString();
		
		String sparql = 
				"SELECT ?dbpedia WHERE { " +
				"		SERVICE <http://dbpedia.org/sparql> { " +
				"			?dbpedia <http://xmlns.com/foaf/0.1/homepage> ?homepage . " +
				"		}" +
				"}";

		List<URI> homepages = new ArrayList<URI>();  
	  Collections.addAll(homepages, vf.createURI(homepageStr), vf.createURI(homepageStr + "/")); 
		
	  for (URI homepage : homepages) {
	  	TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, sparql);
			query.setBinding("homepage", homepage);
			
			TupleQueryResult queryResult = query.evaluate();
			
			while (queryResult.hasNext()) {
				BindingSet bindingSet = queryResult.next();
				Binding dbpedia = bindingSet.getBinding("dbpedia");
				
				statements.add(
					vf.createStatement(graph.getGraphUri(), 
					vf.createURI(classUri + "dbpedia"), 
					vf.createURI(dbpedia.getValue().stringValue())));				
			}
	  }						
	} catch (Exception e) {
		e.printStackTrace();
	}
	
	return statements;
}
 
开发者ID:erfgoed-en-locatie,项目名称:artsholland-platform,代码行数:43,代码来源:DBpediaEnricher.java


示例12: getPotUri

import org.openrdf.model.util.GraphUtil; //导入依赖的package包/类
/**
 * @param potUriMap
 * @param plantId
 * @param nextProjectID
 * @param nextTrayURI
 * @return
 * @throws PoddClientException
 * @throws GraphUtilException
 */
private URI getPotUri(final ConcurrentMap<String, ConcurrentMap<URI, URI>> potUriMap, final String plantId,
        final InferredOWLOntologyID nextProjectID, final URI nextTrayURI) throws PoddClientException,
    GraphUtilException
{
    URI nextPotURI;
    if(potUriMap.containsKey(plantId))
    {
        nextPotURI = potUriMap.get(plantId).keySet().iterator().next();
    }
    else
    {
        final Model plantIdSparqlResults =
                this.doSPARQL(String.format(ExampleSpreadsheetConstants.TEMPLATE_SPARQL_BY_TYPE_LABEL_STRSTARTS,
                        RenderUtils.escape(plantId), RenderUtils.getSPARQLQueryString(PODD.PODD_SCIENCE_POT)),
                        Arrays.asList(nextProjectID));
        
        if(plantIdSparqlResults.isEmpty())
        {
            this.log.debug(
                    "Could not find an existing container for pot barcode, assigning a temporary URI: {} {}",
                    plantId, nextProjectID);
            
            nextPotURI =
                    RestletPoddClientImpl.vf.createURI(RestletPoddClientImpl.TEMP_UUID_PREFIX + "pot:"
                            + UUID.randomUUID().toString());
        }
        else
        {
            nextPotURI = GraphUtil.getUniqueSubjectURI(plantIdSparqlResults, RDF.TYPE, PODD.PODD_SCIENCE_POT);
        }
        
        ConcurrentMap<URI, URI> nextPotUriMap = new ConcurrentHashMap<>();
        final ConcurrentMap<URI, URI> putIfAbsent2 = potUriMap.putIfAbsent(plantId, nextPotUriMap);
        if(putIfAbsent2 != null)
        {
            nextPotUriMap = putIfAbsent2;
        }
        nextPotUriMap.put(nextPotURI, nextTrayURI);
    }
    return nextPotURI;
}
 
开发者ID:podd,项目名称:podd-examples,代码行数:51,代码来源:ExamplePoddClient.java


示例13: getTrayUri

import org.openrdf.model.util.GraphUtil; //导入依赖的package包/类
/**
 * @param trayUriMap
 * @param trayId
 * @param nextProjectID
 * @param nextExperimentUri
 * @return
 * @throws PoddClientException
 * @throws GraphUtilException
 */
private URI getTrayUri(final ConcurrentMap<String, ConcurrentMap<URI, URI>> trayUriMap, final String trayId,
        final InferredOWLOntologyID nextProjectID, final URI nextExperimentUri) throws PoddClientException,
    GraphUtilException
{
    // Check whether trayId already has an assigned URI
    URI nextTrayURI;
    if(trayUriMap.containsKey(trayId))
    {
        nextTrayURI = trayUriMap.get(trayId).keySet().iterator().next();
    }
    else
    {
        final Model trayIdSparqlResults =
                this.doSPARQL(String.format(ExampleSpreadsheetConstants.TEMPLATE_SPARQL_BY_TYPE_LABEL_STRSTARTS,
                        RenderUtils.escape(trayId), RenderUtils.getSPARQLQueryString(PODD.PODD_SCIENCE_TRAY)),
                        Arrays.asList(nextProjectID));
        
        if(trayIdSparqlResults.isEmpty())
        {
            this.log.debug(
                    "Could not find an existing container for tray barcode, assigning a temporary URI: {} {}",
                    trayId, nextProjectID);
            
            nextTrayURI =
                    RestletPoddClientImpl.vf.createURI(RestletPoddClientImpl.TEMP_UUID_PREFIX + "tray:"
                            + UUID.randomUUID().toString());
        }
        else
        {
            nextTrayURI = GraphUtil.getUniqueSubjectURI(trayIdSparqlResults, RDF.TYPE, PODD.PODD_SCIENCE_TRAY);
        }
        
        ConcurrentMap<URI, URI> nextTrayUriMap = new ConcurrentHashMap<>();
        final ConcurrentMap<URI, URI> putIfAbsent2 = trayUriMap.putIfAbsent(trayId, nextTrayUriMap);
        if(putIfAbsent2 != null)
        {
            nextTrayUriMap = putIfAbsent2;
        }
        nextTrayUriMap.put(nextTrayURI, nextExperimentUri);
    }
    return nextTrayURI;
}
 
开发者ID:podd,项目名称:podd-examples,代码行数:52,代码来源:ExamplePoddClient.java



注:本文中的org.openrdf.model.util.GraphUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Reference类代码示例发布时间:2022-05-22
下一篇:
Java MissingTokenException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap