本文整理汇总了Java中com.hp.hpl.jena.rdf.model.Model.size方法的典型用法代码示例。如果您正苦于以下问题:Java Model.size方法的具体用法?Java Model.size怎么用?Java Model.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.rdf.model.Model
的用法示例。
在下文中一共展示了Model.size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadMetadataTemplate
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
private Model loadMetadataTemplate(D2RServer server,
ServletContext context, Property configurationFlag,
String defaultTemplateName) {
Model metadataTemplate;
File userTemplateFile = MetadataCreator.findTemplateFile(server,
configurationFlag);
Model userResourceTemplate = MetadataCreator
.loadTemplateFile(userTemplateFile);
if (userResourceTemplate != null && userResourceTemplate.size() > 0) {
metadataTemplate = userResourceTemplate;
log.info("Using user-specified metadata template at '"
+ userTemplateFile + "'");
} else {
// load default template
InputStream drtStream = context.getResourceAsStream("/WEB-INF/"
+ defaultTemplateName);
log.info("Using default metadata template.");
metadataTemplate = MetadataCreator.loadMetadataTemplate(drtStream);
}
return metadataTemplate;
}
示例2: bulkUpdate
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
/**
* Method called to Chunk the triples into N-Sized batches and post to VIVO.
* This is designed to work around / handle errors when posting sets of triples
* over 10,000 to the API.
*
* @param namedGraph String with named graph.
* @param changeModel Jena model with set of changes to sync to store.
* @param changeType Either add or remove.
* @return Boolean true if update was successful.
* @throws IOException
*/
private Boolean bulkUpdate(String namedGraph, Model changeModel, String changeType) throws IOException {
// Temporary model to hold
Model tmpModel = ModelFactory.createDefaultModel();
Integer bSize = Integer.parseInt(batchSize);
// Use an integer to count triples rather than calling size on the model
// during each loop.
Integer size = 0;
StmtIterator iter = changeModel.listStatements();
while (iter.hasNext()) {
Statement stmt = iter.nextStatement(); // get next statement
tmpModel.add(stmt);
size++;
if (size >= bSize) {
// Submit
log.info("Submitting " + size + " triples to " + namedGraph);
submitBatch(tmpModel, namedGraph, changeType);
// Reset the tmp model.
tmpModel.removeAll();
// Reset the counter.
size = 0;
}
}
log.info("model size:" + tmpModel.size());
// Submit the remaining statements, if any.
if (tmpModel.size() > 0) {
submitBatch(tmpModel, namedGraph, changeType);
}
return true;
}
示例3: debugTrips
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
private void debugTrips(Model additions, Model subtractions) {
Long numAdd = additions.size();
Long numSub = subtractions.size();
log.info(numAdd.toString() + " triples to add:\n");
additions.write(System.out, "N-TRIPLES");
log.info(numSub.toString() + " triples to delete:\n");
subtractions.write(System.out, "N-TRIPLES");
}
示例4: MetadataCreator
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
public MetadataCreator(D2RServer server, Model template) {
// store D2R server config for template location
this.server = server;
if (template != null && template.size() > 0) {
this.enable = true;
this.tplModel = template;
}
}
示例5: doGet
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
D2RServer server = D2RServer.fromServletContext(getServletContext());
server.checkMappingFileChanged();
String relativeResourceURI = request.getRequestURI().substring(
request.getContextPath().length()
+ request.getServletPath().length());
// Some servlet containers keep the leading slash, some don't
if (!"".equals(relativeResourceURI)
&& "/".equals(relativeResourceURI.substring(0, 1))) {
relativeResourceURI = relativeResourceURI.substring(1);
}
if (request.getQueryString() != null) {
relativeResourceURI = relativeResourceURI + "?"
+ request.getQueryString();
}
/* Determine service stem, i.e. vocab/ in /[vocab/]data */
int servicePos;
if (-1 == (servicePos = request.getServletPath().indexOf(
"/" + D2RServer.getDataServiceName())))
throw new ServletException("Expected to find service path /"
+ D2RServer.getDataServiceName());
String serviceStem = request.getServletPath().substring(1,
servicePos + 1);
String resourceURI = RequestParamHandler
.removeOutputRequestParam(server.resourceBaseURI(serviceStem)
+ relativeResourceURI);
String documentURL = server.dataURL(serviceStem, relativeResourceURI);
String pageURL = server.pageURL(serviceStem, relativeResourceURI);
String sparqlQuery = "DESCRIBE <" + resourceURI + ">";
QueryExecution qe = QueryExecutionFactory.create(sparqlQuery,
server.dataset());
if (server.getConfig().getPageTimeout() > 0) {
qe.setTimeout(Math.round(server.getConfig().getPageTimeout() * 1000));
}
Model description = qe.execDescribe();
qe.close();
if (description.size() == 0) {
response.sendError(404);
}
if (description.qnameFor(FOAF.primaryTopic.getURI()) == null
&& description.getNsPrefixURI("foaf") == null) {
description.setNsPrefix("foaf", FOAF.NS);
}
Resource resource = description.getResource(resourceURI);
Resource document = description.getResource(documentURL);
document.addProperty(FOAF.primaryTopic, resource);
Statement label = resource.getProperty(RDFS.label);
if (label != null) {
document.addProperty(RDFS.label,
"RDF Description of " + label.getString());
}
server.addDocumentMetadata(description, document);
if (server.getConfig().serveMetadata()) {
// add document metadata from template
Model resourceMetadataTemplate = server.getConfig().getResourceMetadataTemplate(
server, getServletContext());
MetadataCreator resourceMetadataCreator = new MetadataCreator(
server, resourceMetadataTemplate);
description.add(resourceMetadataCreator.addMetadataFromTemplate(
resourceURI, documentURL, pageURL));
Map<String, String> descPrefixes = description.getNsPrefixMap();
descPrefixes.putAll(resourceMetadataTemplate.getNsPrefixMap());
description.setNsPrefixes(descPrefixes);
}
// TODO: Add a Content-Location header
new ModelResponse(description, request, response).serve();
}