本文整理匯總了Java中org.apache.jena.rdf.model.Resource.listProperties方法的典型用法代碼示例。如果您正苦於以下問題:Java Resource.listProperties方法的具體用法?Java Resource.listProperties怎麽用?Java Resource.listProperties使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.jena.rdf.model.Resource
的用法示例。
在下文中一共展示了Resource.listProperties方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: listNotifications
import org.apache.jena.rdf.model.Resource; //導入方法依賴的package包/類
public List<String> listNotifications(String inboxUrl) throws InterruptedException, IOException{
List<String> notifications=new ArrayList<String>();
UrlRequest urlReq=new UrlRequest(inboxUrl, "Accept", "application/ld+json");
FetchRequest fetched = httpFetcher.fetch(urlReq);
if (fetched.getResponseStatusCode()==200) {
if(fetched.getContent().getType().getMimeType().equals("application/ld+json")) {
Model dcModelRdf = ModelFactory.createDefaultModel();
ByteArrayInputStream bytesIs = new ByteArrayInputStream(fetched.getContent().asBytes());
RDFDataMgr.read(dcModelRdf, bytesIs, inboxUrl, Lang.JSONLD);
try {
bytesIs.close();
} catch (IOException e) {
throw new RuntimeException(e.getMessage(), e);
}
Resource resource = dcModelRdf.getResource(inboxUrl);
StmtIterator seeAlsoStms = resource.listProperties(RdfReg.LDN_CONTAINS);
while (seeAlsoStms.hasNext()) {
Statement st = seeAlsoStms.next();
// System.out.println(st);
notifications.add(st.getObject().toString());
}
}
}
return notifications;
}
示例2: exportVersions
import org.apache.jena.rdf.model.Resource; //導入方法依賴的package包/類
/**
* Initiates export of versions for the given resource if it is a versioned resourced
*
* @param uri resource uri
* @throws FcrepoOperationFailedException
* @throws IOException
*/
private void exportVersions(final URI uri) throws FcrepoOperationFailedException, IOException {
// Do not check for versions if disabled, already exporting a version, or the repo root
if (!config.includeVersions() || uri.toString().contains(FCR_VERSIONS_PATH)
|| uri.equals(repositoryRoot)) {
return;
}
// Create URI for location of the versions endpoint for this resource
final URI versionsUri = addRelativePath(uri, FCR_VERSIONS_PATH);
try (FcrepoResponse response = client().get(versionsUri).accept(config.getRdfLanguage()).perform()) {
// Verify that fcr:versions can be accessed, which will fail if the resource is not versioned
checkValidResponse(response, versionsUri, config.getUsername());
// Persist versions response
final File file = TransferProcess.fileForURI(versionsUri, null, null, config.getBaseDirectory(),
config.getRdfExtension());
writeResponse(uri, response.getBody(), null, file);
// Extract uris of previous versions for export
final Model model = createDefaultModel().read(new FileInputStream(file), null, config.getRdfLanguage());
final Resource resc = model.getResource(uri.toString());
final StmtIterator versionsIt = resc.listProperties(HAS_VERSION);
while (versionsIt.hasNext()) {
final Statement versionSt = versionsIt.next();
final Resource versionResc = versionSt.getResource();
exportLogger.info("Exporting version: {}", versionResc.getURI());
logger.info("Exporting version {} for {}", versionResc.getURI(), uri);
export(URI.create(versionResc.getURI()));
}
} catch (ResourceNotFoundRuntimeException e) {
// Expected case for when the resource is not versioned
logger.trace("Resource {} is not versioned", uri);
}
}
示例3: addPropertiesToResource
import org.apache.jena.rdf.model.Resource; //導入方法依賴的package包/類
private void addPropertiesToResource(Resource to, Resource from) {
StmtIterator iterator = from.listProperties();
while (iterator.hasNext()) {
Statement statement = iterator.next();
to.addProperty(statement.getPredicate(), statement.getObject());
}
}