本文整理汇总了Java中com.hp.hpl.jena.rdf.model.ResIterator.nextResource方法的典型用法代码示例。如果您正苦于以下问题:Java ResIterator.nextResource方法的具体用法?Java ResIterator.nextResource怎么用?Java ResIterator.nextResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.rdf.model.ResIterator
的用法示例。
在下文中一共展示了ResIterator.nextResource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addRowToMODEL
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
private void addRowToMODEL(List<Statement> sa, String key, String puri) {
for (Statement s : sa) {
if (MODEL.contains(s)) {
continue;
}
// add to existing resource with same key if exists
if (s.getPredicate().getLocalName().equals(key)) {
ResIterator it = MODEL.listResourcesWithProperty(s.getPredicate(), s.getObject());
if (it.hasNext()) { // assume all members are equal
Resource rsc = it.nextResource(); // get parent
Property p = ResourceFactory.createProperty(genOURI(), puri);
Statement st = ResourceFactory.createStatement(rsc, p, s.getSubject());
MODEL.add(st);
continue;
}
}
MODEL.add(s);
}
}
示例2: getChildren
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
/**
* Look up <code>uri</code> in the ontology and return a list of child
* concepts (URIs). Synonyms are not considered. The list contains no
* duplicates. Never returns <code>null</code>.
*
* @param term
* term to be looked up
* @return a list of child concepts URIs
*/
// TODO add all synonyms of the children to the result
public List<String> getChildren(String uri) {
Resource resource = model.getResource(uri);
if (resource == null)
return Collections.emptyList();
List<String> result = new ArrayList<String>();
ResIterator child = model.listResourcesWithProperty(RDFS.subClassOf, resource);
while(child.hasNext()) {
Resource parent = child.nextResource();
// if (!parent.hasLiteral(Jura.invisible, true)) {
result.add(parent.getURI());
// }
}
return result;
}
示例3: createInstances
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
@Override
public Model createInstances(Model createModel) throws ProcessingException, InvalidRequestException {
try {
ManagedThreadFactory threadFactory = (ManagedThreadFactory) new InitialContext().lookup("java:jboss/ee/concurrency/factory/default");
CallOpenSDNcore callOpenSDNcore = new CallOpenSDNcore(createModel, this);
Thread callOpenSDNcoreThread = threadFactory.newThread(callOpenSDNcore);
callOpenSDNcoreThread.start();
} catch (NamingException e) {
LOGGER.log(Level.SEVERE, "REQUIRED VMs counldn't be created ", e);
}
Model returnModel = ModelFactory.createDefaultModel();
ResIterator resIterator = createModel.listSubjectsWithProperty(Omn.isResourceOf);
while(resIterator.hasNext()){
Resource resource = resIterator.nextResource();
Resource res = returnModel.createResource(resource.getURI());
Property property = returnModel.createProperty(Omn_lifecycle.hasState.getNameSpace(), Omn_lifecycle.hasState.getLocalName());
property.addProperty(RDF.type, OWL.FunctionalProperty);
res.addProperty(property, Omn_lifecycle.Uncompleted);
}
return returnModel;
}
示例4: getListByName
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
@Override
//This function returns list of local business starting by name specified
public ArrayList<PlaceDTO> getListByName(String nombre){
ArrayList<PlaceDTO> result = new ArrayList<>();
Resource schema_LocalBusiness = model.createResource(schema + "LocalBusiness");
ResIterator rIter = this.model.listSubjectsWithProperty(RDF.type,schema_LocalBusiness);
while (rIter.hasNext() && result.size() < 10){
Resource r = rIter.nextResource();
Property schema_name = this.model.createProperty(schema+"name");
Property schema_description = this.model.createProperty(schema+"description");
if (r.hasProperty(schema_name)){
String placeName = r.getRequiredProperty( schema_name ).getString();
if (placeName.toLowerCase().contains(nombre.toLowerCase())){
double[] location = this.getPlaceCoordinates(placeName.replace(" ",""));
String placeDescription = "";
if(r.hasProperty(schema_description)){
placeDescription = r.getRequiredProperty( schema_description).getString();
}
PlaceDTO place = new PlaceDTO(placeName,location[0],location[1]);
result.add(place);
}
}
}
return result;
}
示例5: getListByName
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
@Override
public ArrayList<PlaceDTO> getListByName(String nombre){
ArrayList<PlaceDTO> result = new ArrayList<>();
Resource mibarrio_SportFacility = model.createResource(mibarrio + "SportFacility");
ResIterator rIter = this.model.listSubjectsWithProperty(RDF.type,mibarrio_SportFacility);
while (rIter.hasNext() && result.size() < 10){
Resource r = rIter.nextResource();
Property schema_name = this.model.createProperty(schema+"name");
Property schema_description = this.model.createProperty(schema+"description");
if (r.hasProperty(schema_name)){
String placeName = r.getRequiredProperty( schema_name ).getString();
if (placeName.toLowerCase().contains(nombre.toLowerCase())){
double[] location = this.getPlaceCoordinates(placeName.replace(" ",""));
String placeDescription = "";
if(r.hasProperty(schema_description)){
placeDescription = r.getRequiredProperty( schema_description).getString();
}
PlaceDTO place = new PlaceDTO(placeName,location[0],location[1]);
result.add(place);
}
}
}
return result;
}
示例6: getListByName
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
@Override
public ArrayList<PlaceDTO> getListByName(String nombre) {
ArrayList<PlaceDTO> result = new ArrayList<>();
Resource mibarrio_Library = model.createResource(mibarrio + "Library");
ResIterator rIter = this.model.listSubjectsWithProperty(RDF.type,mibarrio_Library);
while (rIter.hasNext() && result.size() < 10){
Resource r = rIter.nextResource();
Property schema_name = this.model.createProperty(schema+"name");
Property schema_description = this.model.createProperty(schema+"description");
if (r.hasProperty(schema_name)){
String placeName = r.getRequiredProperty( schema_name ).getString();
if (placeName.toLowerCase().contains(nombre.toLowerCase())){
double[] location = this.getPlaceCoordinates(placeName.replace(" ",""));
String placeDescription = "";
if(r.hasProperty(schema_description)){
placeDescription = r.getRequiredProperty( schema_description).getString();
}
PlaceDTO place = new PlaceDTO(placeName,location[0],location[1]);
result.add(place);
}
}
}
return result;
}
示例7: doGet
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
D2RServer server = D2RServer.fromServletContext(getServletContext());
server.checkMappingFileChanged();
if (request.getPathInfo() == null) {
response.sendError(404);
return;
}
String classMapName = request.getPathInfo().substring(1);
Model resourceList = getClassMapLister().classMapInventory(
classMapName, server.getConfig().getLimitPerClassMap());
if (resourceList == null) {
response.sendError(404, "Sorry, class map '" + classMapName + "' not found.");
return;
}
Map<String,String> resources = new TreeMap<String,String>();
ResIterator subjects = resourceList.listSubjects();
while (subjects.hasNext()) {
Resource resource = subjects.nextResource();
if (!resource.isURIResource()) {
continue;
}
String uri = resource.getURI();
Statement labelStmt = PageServlet.getBestLabel(resource);
String label = (labelStmt == null) ? resource.getURI() : labelStmt.getString();
resources.put(uri, label);
}
Map<String,String> classMapLinks = new TreeMap<String,String>();
for (String name: getClassMapLister().classMapNames()) {
classMapLinks.put(name, server.baseURI() + "directory/" + name);
}
VelocityWrapper velocity = new VelocityWrapper(this, request, response);
Context context = velocity.getContext();
context.put("rdf_link", server.baseURI() + "all/" + classMapName);
context.put("classmap", classMapName);
context.put("classmap_links", classMapLinks);
context.put("resources", resources);
context.put("limit_per_class_map", server.getConfig().getLimitPerClassMap());
velocity.mergeTemplateXHTML("directory_page.vm");
}
示例8: findServerResource
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
protected Resource findServerResource() {
ResIterator it = this.model.listSubjectsWithProperty(RDF.type,
D2RConfig.Server);
if (!it.hasNext()) {
return null;
}
return it.nextResource();
}
示例9: findDatabaseResource
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
protected Resource findDatabaseResource() {
ResIterator it = this.model.listSubjectsWithProperty(RDF.type,
D2RQ.Database);
if (!it.hasNext()) {
return null;
}
return it.nextResource();
}
示例10: startTopology
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
public void startTopology(Model returnModel){
ResIterator resIterator = this.createModel.listResourcesWithProperty(Omn.hasResource);
while(resIterator.hasNext()){
Resource resource = resIterator.nextResource();
Property property = returnModel.createProperty(Omn_lifecycle.hasState.getNameSpace(),Omn_lifecycle.hasState.getLocalName());
property.addProperty(RDF.type, OWL.FunctionalProperty);
Statement statement = new StatementImpl(resource, property, Omn_lifecycle.Started);
returnModel.add(statement);
}
}
示例11: handleInform
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
public void handleInform(Model model){
LOGGER.log(Level.SEVERE, "Starting Monitoring Service");
readConfig("MonitoringService");
os_client = new OpenstackClient() ;
os_client.setConfig(config) ;
sqlite = new SQLite() ;
sqlite.setConfig(config) ;
ResIterator resIterator = model.listSubjects();
while(resIterator.hasNext()){
boolean createOk = false, deleteOk = false ;
Resource r = resIterator.nextResource();
if(r.hasProperty(RDF.type, Omn_domain_pc.VM) && r.hasProperty(Omn_domain_pc.hasVMID)){ // if resource is vm
vm_uri = r.toString() ;
if(r.hasProperty(Omn_lifecycle.hasState, Omn_lifecycle.Started)){
createOk = handleCreate(model, r) ;
}
else if(r.hasProperty(Omn_lifecycle.hasState, Omn_lifecycle.Stopped)){
deleteOk = handleDelete(model, r) ;
}
else{
LOGGER.log(Level.INFO, "Not monitoring-related resource: State of VM is not created/deleted. Ignoring...") ;
}
}else{
LOGGER.log(Level.INFO, "Not monitoring-related resource: Resource type is not VM. Ignoring...") ;
}
if(createOk && !deleteOk ){
if(sqlite.insert(vm_id, host, oml_uri,vm_uri)) System.out.println("Data successfully added to database.") ;
}else if(!createOk && deleteOk){
if(sqlite.delete(vm_id)) System.out.println("Data successfully deleted to database.") ;
}
}
}
示例12: getMonitoringService
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
private Resource getMonitoringService(Model newInstanceModel) {
ResIterator resIterator = newInstanceModel.listSubjectsWithProperty(RDF.type, Omn_monitoring.MonitoringService);
Resource omsp_service = null;
while (resIterator.hasNext()){
omsp_service = resIterator.nextResource();
}
return omsp_service;
}
示例13: withPropertyValue
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
public RDFMetadataContentSelector withPropertyValue(String propertyName, String propertyValue)
{
if (_model != null)
{
Property property = _model.getProperty(propertyName);
ResIterator resourceIterator = _model.listResourcesWithProperty(property, propertyValue);
return new RDFMetadataContentSelector(resourceIterator.nextResource());
}
else
return new RDFMetadataContentSelector(null);
}
示例14: mutableWithPropertyValue
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
public RDFMutableMetadataContentSelector mutableWithPropertyValue(String propertyName, String propertyValue)
{
if (_model != null)
{
Property property = _model.getProperty(propertyName);
ResIterator resourceIterator = _model.listResourcesWithProperty(property, propertyValue);
return new RDFMutableMetadataContentSelector(resourceIterator.nextResource());
}
else
return new RDFMutableMetadataContentSelector(null);
}
示例15: test_generateRdfs_clinical_trials
import com.hp.hpl.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
/**
* Run the RDF generator pipeline for clinical trial data Before running
* this, run the Mapping Discovery Test first to generate the mapping file
* for clinical trials.
*
* @throws SAXException
* @throws IOException
* @throws ParserConfigurationException
*/
@Test
public void test_generateRdfs_clinical_trials() throws SAXException, IOException, ParserConfigurationException {
// Setup deserializer
mappingDeserialization = new XmlBasedMappingDeserialization(
new FileInputStream("output/clinicaltrials-mapping.xml"), parser);
Document dataDocument = parser.parse(RdfGeneratorTest2.class.getResourceAsStream(
"/clinicaltrials/data/content.xml"), 10);
rdfGenerator = new RdfGenerator(new DataDocument(dataDocument), new XmlBasedMapping());
// Add steps
rdfGenerator.addStep(mappingDeserialization);
rdfGenerator.addStep(rdfGeneration);
// Generate
rdfGenerator.generateRdfs();
// Verify
Model model = TDBFactory.createModel(testTdbDir);
Assert.assertFalse("No RDF was generated. TDB directory: " + testTdbDir, model.isEmpty());
ResIterator iter = model.listResourcesWithProperty(RDF.type);
while (iter.hasNext()) {
Resource resource = iter.nextResource();
System.out.println(resource.getLocalName());
StmtIterator iterStm = resource.listProperties();
while (iterStm.hasNext()) {
System.out.println(iterStm.nextStatement().toString());
}
}
}