本文整理汇总了Java中org.openrdf.model.Graph类的典型用法代码示例。如果您正苦于以下问题:Java Graph类的具体用法?Java Graph怎么用?Java Graph使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Graph类属于org.openrdf.model包,在下文中一共展示了Graph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseConfig
import org.openrdf.model.Graph; //导入依赖的package包/类
protected Graph parseConfig(File file) throws SailConfigException, IOException {
RDFFormat format = Rio.getParserFormatForFileName(file.getAbsolutePath());
if (format==null)
throw new SailConfigException("Unsupported file format: " + file.getAbsolutePath());
RDFParser parser = Rio.createParser(format);
Graph model = new GraphImpl();
parser.setRDFHandler(new StatementCollector(model));
InputStream stream = new FileInputStream(file);
try {
parser.parse(stream, file.getAbsolutePath());
} catch (Exception e) {
throw new SailConfigException("Error parsing file!");
}
stream.close();
return model;
}
示例2: serializeProperties
import org.openrdf.model.Graph; //导入依赖的package包/类
private void serializeProperties( EntityState entityState,
Graph graph, Resource subject,
EntityDescriptor entityType,
boolean includeNonQueryable )
{
// Properties
entityType.state().properties().forEach(
persistentProperty ->
{
Object property = entityState.propertyValueOf( persistentProperty.qualifiedName() );
if( property != null )
{
serializeProperty( persistentProperty, property, subject, graph, includeNonQueryable );
}
} );
}
示例3: serialize
import org.openrdf.model.Graph; //导入依赖的package包/类
public Iterable<Statement> serialize( final EntityDescriptor entityDescriptor )
{
Graph graph = new GraphImpl();
ValueFactory values = graph.getValueFactory();
URI entityTypeUri = values.createURI( Classes.toURI( entityDescriptor.types().findFirst().orElse( null ) ) );
graph.add( entityTypeUri, Rdfs.TYPE, Rdfs.CLASS );
graph.add( entityTypeUri, Rdfs.TYPE, OWL.CLASS );
graph.add( entityTypeUri,
PolygeneEntityType.TYPE,
values.createLiteral( entityDescriptor.types().findFirst().get().toString() )
);
graph.add( entityTypeUri, PolygeneEntityType.QUERYABLE, values.createLiteral( entityDescriptor.queryable() ) );
serializeMixinTypes( entityDescriptor, graph, entityTypeUri );
serializePropertyTypes( entityDescriptor, graph, entityTypeUri );
serializeAssociationTypes( entityDescriptor, graph, entityTypeUri );
serializeManyAssociationTypes( entityDescriptor, graph, entityTypeUri );
return graph;
}
示例4: serializeManyAssociationTypes
import org.openrdf.model.Graph; //导入依赖的package包/类
private void serializeManyAssociationTypes( final EntityDescriptor entityDescriptor,
final Graph graph,
final URI entityTypeUri
)
{
ValueFactory values = graph.getValueFactory();
// ManyAssociations
entityDescriptor.state().manyAssociations().forEach( manyAssociationType -> {
URI associationURI = values.createURI( manyAssociationType.qualifiedName().toURI() );
graph.add( associationURI, Rdfs.DOMAIN, entityTypeUri );
graph.add( associationURI, Rdfs.TYPE, Rdfs.SEQ );
URI associatedURI = values.createURI( manyAssociationType.qualifiedName().toURI() );
graph.add( associationURI, Rdfs.RANGE, associatedURI );
graph.add( associationURI, Rdfs.RANGE, XMLSchema.ANYURI );
} );
}
示例5: serializeAssociationTypes
import org.openrdf.model.Graph; //导入依赖的package包/类
private void serializeAssociationTypes( final EntityDescriptor entityDescriptor,
final Graph graph,
final URI entityTypeUri
)
{
ValueFactory values = graph.getValueFactory();
// Associations
entityDescriptor.state().associations().forEach( associationType -> {
URI associationURI = values.createURI( associationType.qualifiedName().toURI() );
graph.add( associationURI, Rdfs.DOMAIN, entityTypeUri );
graph.add( associationURI, Rdfs.TYPE, Rdfs.PROPERTY );
URI associatedURI = values.createURI( Classes.toURI( Classes.RAW_CLASS.apply( associationType.type() ) ) );
graph.add( associationURI, Rdfs.RANGE, associatedURI );
graph.add( associationURI, Rdfs.RANGE, XMLSchema.ANYURI );
} );
}
示例6: serializePropertyTypes
import org.openrdf.model.Graph; //导入依赖的package包/类
private void serializePropertyTypes( final EntityDescriptor entityDescriptor,
final Graph graph,
final URI entityTypeUri
)
{
ValueFactory values = graph.getValueFactory();
// Properties
entityDescriptor.state().properties().forEach( persistentProperty -> {
URI propertyURI = values.createURI( persistentProperty.qualifiedName().toURI() );
graph.add( propertyURI, Rdfs.DOMAIN, entityTypeUri );
graph.add( propertyURI, Rdfs.TYPE, Rdfs.PROPERTY );
// TODO Support more types
URI type = dataTypes.get( persistentProperty.valueType().primaryType().getName() );
if( type != null )
{
graph.add( propertyURI, Rdfs.RANGE, type );
}
} );
}
示例7: export
import org.openrdf.model.Graph; //导入依赖的package包/类
@Override
public Resource export(final Graph graph) {
final Resource implNode = super.export(graph);
@SuppressWarnings("deprecation")
final
ValueFactory v = graph.getValueFactory();
graph.add(implNode, USER, v.createLiteral(user));
graph.add(implNode, PASSWORD, v.createLiteral(password));
graph.add(implNode, INSTANCE, v.createLiteral(instance));
graph.add(implNode, ZOOKEEPERS, v.createLiteral(zookeepers));
graph.add(implNode, IS_MOCK, v.createLiteral(isMock));
return implNode;
}
示例8: export
import org.openrdf.model.Graph; //导入依赖的package包/类
@Override
/**
* export graph representation of config
*
* @Note - Graph is deprecating soon (in Sesame) to be replaced by Model
*/
public Resource export(Graph graph) {
Resource implNode = super.export(graph);
ValueFactory vf = graph.getValueFactory();
if (getQueryEndpointUrl() != null) {
graph.add(implNode, QUERY_ENDPOINT, vf.createURI(getQueryEndpointUrl()));
}
if (getUpdateEndpointUrl() != null) {
graph.add(implNode, UPDATE_ENDPOINT, vf.createURI(getUpdateEndpointUrl()));
}
return implNode;
}
示例9: parse
import org.openrdf.model.Graph; //导入依赖的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);
}
}
示例10: export
import org.openrdf.model.Graph; //导入依赖的package包/类
@Override
public Resource export(Graph graph) {
Resource implNode = super.export(graph);
ValueFactory vf = graph.getValueFactory();
if (jdbcDriver != null) {
graph.add(implNode, JDBC_DRIVER, vf.createLiteral(jdbcDriver));
}
if (url != null) {
graph.add(implNode, URL, vf.createLiteral(url));
}
if (user != null) {
graph.add(implNode, USER, vf.createLiteral(user));
}
if (password != null) {
graph.add(implNode, PASSWORD, vf.createLiteral(password));
}
graph.add(implNode, MAX_TRIPLE_TABLES, vf.createLiteral(maxTripleTables));
return implNode;
}
示例11: parseFile
import org.openrdf.model.Graph; //导入依赖的package包/类
public Model parseFile(InputStream configurationFile, RDFFormat format,
String defaultNamespace) throws Exception {
final Graph graph = new GraphImpl();
RDFParser parser = Rio.createParser(format);
org.openrdf.model.Model myGraph = new org.openrdf.model.impl.LinkedHashModel();
/*
* RDFHandler handler = new RDFHandler() { public void endRDF() throws
* RDFHandlerException { }
*
* public void handleComment(String arg0) throws RDFHandlerException { }
*
* public void handleNamespace(String arg0, String arg1) throws
* RDFHandlerException { }
*
* public void handleStatement(Statement statement) throws
* RDFHandlerException { graph.add(statement); }
*
* public void startRDF() throws RDFHandlerException { } };
*/
parser.setRDFHandler(new StatementCollector(myGraph));
parser.parse(configurationFile, defaultNamespace);
return myGraph;
}
示例12: addEPCsToGraph
import org.openrdf.model.Graph; //导入依赖的package包/类
/**
* @param ns
* @param mySubject
* @param myGraph
* @param epcArray
*/
public Graph addEPCsToGraph(Namespaces ns, Graph myGraph, URI mySubject,
ArrayList<String> epcArray) {
if (epcArray.size() > 0) {
ValueFactory myFactory = ValueFactoryImpl.getInstance();
BNode bnodeEPC = myFactory.createBNode();
// link the EPCS to the event
myGraph.add(mySubject, myFactory.createURI(
ns.getIRIForPrefix("eem"), "associatedWithEPCList"),
bnodeEPC);
myGraph.add(bnodeEPC, RDF.TYPE,
myFactory.createURI(ns.getIRIForPrefix("eem"), "SetOfEPCs"));
for (String e : epcArray) {
myGraph.add(bnodeEPC,
myFactory.createURI("http://purl.org/co#element"),
myFactory.createURI(e.trim()));
// System.out.println(e);
}
}
return myGraph;
}
示例13: setLocation
import org.openrdf.model.Graph; //导入依赖的package包/类
public Graph setLocation(Namespaces ns, String prefix, Graph myGraph,
URI mySubject, Site location, String identifier) {
URI myPredicate = null;
ValueFactory myFactory = ValueFactoryImpl.getInstance();
;
// check the strings
String locationID = location.getLocationID();
URI locationIDURI = location.getLocationIDURI();
if (locationIDURI == null) {
locationIDURI = myFactory.createURI(ns.getIRIForPrefix(prefix),
locationID);
location.setLocationIDURI(locationIDURI);
}
myGraph = setLocation(ns, mySubject, myGraph, location, identifier);
return myGraph;
}
示例14: setReaderForEvent
import org.openrdf.model.Graph; //导入依赖的package包/类
/**
* @param myGraph
* @param mySubject2
* @param reader
* @return
*/
public Graph setReaderForEvent(Namespaces ns, String prefix, Graph myGraph,
URI mySubject, Reader reader) {
URI readerURI = ValueFactoryImpl.getInstance().createURI(
ns.getIRIForPrefix(prefix), reader.getPhysicalReaderID());
myGraph.add(readerURI, RDF.TYPE, ValueFactoryImpl.getInstance()
.createURI(ns.getIRIForPrefix("eem"), "Reader"));
myGraph.add(
readerURI,
ValueFactoryImpl.getInstance().createURI(
ns.getIRIForPrefix("eem"), "logicalID"),
ValueFactoryImpl.getInstance().createLiteral(
reader.getPhysicalReaderID()));
myGraph.add(
mySubject,
ValueFactoryImpl.getInstance().createURI(
ns.getIRIForPrefix("eem"), "recordedByReader"),
readerURI);
return myGraph;
}
示例15: getStringForm
import org.openrdf.model.Graph; //导入依赖的package包/类
@Nonnull
@Override
protected String getStringForm(Graph value) {
StringBuilder statementsInDotFormat = new StringBuilder();
for (Statement statement : value) {
statementsInDotFormat.append(
String.format("\t\"<%s>\" -> \"<%s>\" [label=\"%s\"];%n",
statement.getSubject().stringValue(),
statement.getObject().stringValue(),
statement.getPredicate().stringValue()
)
);
}
return String.format("digraph graphName {%n%s}%n", statementsInDotFormat);
}