本文整理匯總了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();
}