本文整理汇总了Java中com.hp.hpl.jena.graph.Graph.add方法的典型用法代码示例。如果您正苦于以下问题:Java Graph.add方法的具体用法?Java Graph.add怎么用?Java Graph.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.graph.Graph
的用法示例。
在下文中一共展示了Graph.add方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeRecords
import com.hp.hpl.jena.graph.Graph; //导入方法依赖的package包/类
/**
* Uses the graph that was created to add the triple and either merges or adds based on the
* availability of the graph node
* @param rdfTriple
* @param graph
*/
private void writeRecords(Triple rdfTriple, Graph graph) {
// Add triple to the graph
graph.add(rdfTriple);
if (dsg.containsGraph(graphNode))
{
logger.debug("Yes, we have this graphNode in MarkLogic");
logger.debug("Triple [" + rdfTriple.toString() + "]");
dsg.mergeGraph(graphNode, graph);
}
else
{
logger.debug("Store the graph in MarkLogic.");
dsg.addGraph(graphNode, graph);
}
}
示例2: setUp
import com.hp.hpl.jena.graph.Graph; //导入方法依赖的package包/类
@Before
public void setUp() throws FedoraException {
initMocks(this);
objectWithChildren = new FedoraObjectImpl(mockRepository, mockHelper, objectPath);
objectWithoutChildren = new FedoraObjectImpl(mockRepository, mockHelper, objectWithoutChildrenPath);
objectChild = new FedoraObjectImpl(mockRepository, mockHelper, objectChildPath);
customChild = new FedoraObjectImpl(mockRepository, mockHelper, customChildPath);
datastreamChild = new FedoraDatastreamImpl(mockRepository, mockHelper, datastreamChildPath);
final Graph graph = createDefaultGraph();
graph.add( create(objectSubj, CONTAINS.asNode(), datastreamChildSubj) );
graph.add( create(objectSubj, CONTAINS.asNode(), objectChildSubj) );
graph.add( create(objectSubj, CONTAINS.asNode(), customChildSubj) );
graph.add( create(datastreamChildSubj, HAS_MIXIN_TYPE.asNode(), createLiteral(BINARY)) );
graph.add( create(objectChildSubj, HAS_MIXIN_TYPE.asNode(), createLiteral(CONTAINER)) );
graph.add( create(customChildSubj, HAS_MIXIN_TYPE.asNode(), createLiteral(CUSTOM)) );
objectWithChildren.setGraph( graph );
objectWithoutChildren.setGraph( createDefaultGraph() );
when(mockRepository.getRepositoryUrl()).thenReturn(repositoryURL);
when(mockRepository.getObject(eq(objectPath))).thenReturn(objectWithChildren);
when(mockRepository.getObject(eq(objectChildPath))).thenReturn(objectChild);
when(mockRepository.getObject(eq(customChildPath))).thenReturn(customChild);
when(mockRepository.getDatastream(eq(datastreamChildPath))).thenReturn(datastreamChild);
}
示例3: setUp
import com.hp.hpl.jena.graph.Graph; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException {
initMocks(this);
when(mockRepository.getRepositoryUrl()).thenReturn(repositoryURL);
resource = new FedoraResourceImpl(mockRepository, mockHelper, path);
assertTrue(resource != null);
final Graph graph = createDefaultGraph();
graph.add( create(createURI(repositoryURL + "/test"), RdfLexicon.CREATED_DATE.asNode(),
ResourceFactory.createPlainLiteral(testDateValue).asNode()) );
graph.add( create(createURI(repositoryURL + "/test"), RdfLexicon.LAST_MODIFIED_DATE.asNode(),
ResourceFactory.createPlainLiteral(testDateValue).asNode()) );
graph.add( create(createURI(repositoryURL + "/test"), RdfLexicon.HAS_MIXIN_TYPE.asNode(),
createURI(testMixinType)) );
graph.add( create(createURI(repositoryURL + "/test"), RdfLexicon.WRITABLE.asNode(),
ResourceFactory.createTypedLiteral(new Boolean(isWritable)).asNode()) );
resource.setGraph( graph );
}
示例4: setUp
import com.hp.hpl.jena.graph.Graph; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException, FedoraException {
initMocks(this);
mockRepository.httpHelper = mockHelper;
when(mockRepository.getRepositoryUrl()).thenReturn(repositoryURL);
when(mockRepository.getObject(eq("/test"))).thenReturn(mockObject);
datastream = new FedoraDatastreamImpl(mockRepository, mockHelper, path);
assertTrue(datastream != null);
final Graph graph = createDefaultGraph();
graph.add( create(dsSubj, CREATED_DATE.asNode(), ResourceFactory.createPlainLiteral(testDateValue).asNode()) );
graph.add( create(dsSubj, LAST_MODIFIED_DATE.asNode(),
ResourceFactory.createPlainLiteral(testDateValue).asNode()) );
graph.add( create(dsSubj, HAS_MIXIN_TYPE.asNode(), createURI(testMixinType)) );
graph.add( create(dsSubj, WRITABLE.asNode(),
ResourceFactory.createTypedLiteral(new Boolean(isWritable)).asNode()) );
graph.add( create(dsSubj, DESCRIBES.asNode(), contentSubj) );
graph.add( create(contentSubj, HAS_SIZE.asNode(), ResourceFactory.createPlainLiteral(contentSize).asNode()) );
graph.add( create(contentSubj, HAS_MIME_TYPE.asNode(), ResourceFactory.createPlainLiteral(mimeType).asNode()) );
graph.add( create(contentSubj, HAS_ORIGINAL_NAME.asNode(),
ResourceFactory.createPlainLiteral(filename).asNode()) );
graph.add( create(contentSubj, REST_API_DIGEST.asNode(), createURI(checksum)) );
datastream.setGraph( graph );
}
示例5: load
import com.hp.hpl.jena.graph.Graph; //导入方法依赖的package包/类
@Override
public void load(
final SolrQueryRequest request,
final SolrQueryResponse response,
final ContentStream stream,
final UpdateRequestProcessor processor) throws Exception {
final PipedRDFIterator<Triple> iterator = new PipedRDFIterator<Triple>();
final StreamRDF inputStream = new PipedTriplesStream(iterator);
executor.submit(new Runnable() {
@Override
public void run() {
try {
RDFDataMgr.parse(
inputStream,
stream.getStream(),
RDFLanguages.contentTypeToLang(stream.getContentType()));
} catch (final IOException exception) {
throw new SolrException(ErrorCode.SERVER_ERROR, exception);
}
}
});
// Graph Store Protocol indicates the target graph URI separately.
// So the incoming Content-type here is one that maps "Triples Loader" but
// the indexed tuple could be a Quad.
final String graphUri = request.getParams().get(Names.GRAPH_URI_ATTRIBUTE_NAME);
final DatasetGraph dataset = new LocalDatasetGraph(request, response, null, null);
final Graph defaultGraph = graphUri == null
? dataset.getDefaultGraph()
: dataset.getGraph(NodeFactory.createURI(graphUri));
while (iterator.hasNext()) {
defaultGraph.add(iterator.next());
}
}
示例6: getSelectModel
import com.hp.hpl.jena.graph.Graph; //导入方法依赖的package包/类
/**
* Query SPARQL endpoint with a SELECT query
* @param qExec QueryExecution encapsulating the query
* @return model retrieved by querying the endpoint
*/
private Model getSelectModel(QueryExecution qExec) {
Model model = ModelFactory.createDefaultModel();
Graph graph = model.getGraph();
ResultSet results = qExec.execSelect();
while (results.hasNext()) {
QuerySolution sol = results.next();
String subject;
String predicate;
RDFNode object;
try {
subject = sol.getResource("s").toString();
predicate = sol.getResource("p").toString();
object = sol.get("o");
} catch (NoSuchElementException e) {
logger.error("SELECT query does not return a (?s ?p ?o) Triple");
continue;
}
Node objNode;
if (object.isLiteral()) {
Literal obj = object.asLiteral();
objNode = NodeFactory.createLiteral(obj.getString(), obj.getDatatype());
} else {
objNode = NodeFactory.createLiteral(object.toString());
}
graph.add(new Triple(
NodeFactory.createURI(subject),
NodeFactory.createURI(predicate),
objNode));
}
return model;
}
示例7: addTriplesToDeductionGraph
import com.hp.hpl.jena.graph.Graph; //导入方法依赖的package包/类
/**
* Transfer the triples inferred by {@link Inferray} into the deduced
* {@link FGraph}
*
* @param inferredTriples
*/
private void addTriplesToDeductionGraph(
final CacheTripleStore inferredTriples) {
final Graph fgraph = fdeductions.getGraph();
final Iterator<LongPairArrayList> verticalIterator = inferredTriples
.verticalIterator();
Node s, o;
int counter = 0;
final NodeDictionary dictionary = inferray.getDictionary();
// Iterate over properties table
while (verticalIterator.hasNext()) {
final LongPairArrayList longPairArrayList = verticalIterator.next();
final Node p = dictionary.getNode(NodeDictionary.SPLIT_INDEX
- longPairArrayList.getProperty());
// Iterate over s,o for a given p
for (int i = 0; i < longPairArrayList.size();) {
s = dictionary.getNode(longPairArrayList.getQuick(i++));
o = dictionary.getNode(longPairArrayList.getQuick(i++));
final Triple triple = new Triple(s, p, o);
if (fgraph.contains(triple)
|| fdata.getGraph().contains(triple)) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Contains " + triple);
}
} else {
counter++;
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Added " + triple);
}
fgraph.add(triple);
}
}
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Deducted triples " + fgraph.size());
LOGGER.trace("Already present " + fdata.getGraph().size());
LOGGER.trace("Counter value " + counter);
}
}