Java 类com.hp.hpl.jena.rdf.model.ResIterator 实例源码

项目:mdb2rdf    文件:RdbToRdf.java   
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);
    }
}
项目:ExpertFinder    文件:OntologyIndex.java   
/**
     * 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;
    }
项目:Cetus    文件:DolceClassHierarchyLoader.java   
protected Set<Resource> getClasses(Model readModel) {
    ResIterator iterator = readModel.listSubjectsWithProperty(RDF.type, RDFS.Class);
    Resource r;
    Set<Resource> classes = new HashSet<Resource>();
    while (iterator.hasNext()) {
        r = iterator.next();
        if (!r.isAnon()) {
            classes.add(r);
        }
    }
    iterator = readModel.listSubjectsWithProperty(RDF.type, OWL.Class);
    while (iterator.hasNext()) {
        r = iterator.next();
        if (!r.isAnon()) {
            classes.add(r);
        }
    }
    return classes;
}
项目:europeana    文件:EDMAnalysis.java   
public ObjectStat analyse(File srcList, File src, File dst) throws IOException
{
    if ( dst == null ) { dst = getDestination(src); }

    Model m = loadModel(src);
    Property type = m.getProperty(RDF_TYPE);
    Resource pcho = m.getResource(EDM_PROVIDEDCHO);

    ObjectStat stat  = new ObjectStat("Europeana", true, false, true);

    stat.addPropertyValue(new LinkSetPropertyStat(m));
    ResIterator iter = m.listSubjectsWithProperty(type, pcho);
    stat.addPropertyValues(m, iter, false);

    super.analyse(m.listSubjectsWithProperty(type, pcho), dst, stat);

    return stat;
}
项目:europeana    文件:AmbiguityFetch.java   
private void fetchLabels(Model m)
{
    Map<String,String> map = new HashMap();
    Property           p   = m.getProperty(SKOS_PREF_LABEL);

    ResIterator rIter = m.listResourcesWithProperty(m.getProperty(RDF_TYPE));
    while ( rIter.hasNext() )
    {
        Resource r = rIter.next();
        fetchAlternatives(map, r);

        StmtIterator sIter = r.listProperties(p);
        while ( sIter.hasNext() )
        {
            Statement stmt = sIter.next();
            put(stmt.getSubject(), getKey(stmt.getString(), map));
        }

        map.clear();
    }
}
项目:europeana    文件:WikidataAnalysis.java   
private Model fixSubjects(Model m)
{
    Collection<String> sa = new HashSet();

    ResIterator iter = m.listSubjects();
    while ( iter.hasNext() )
    {
        String uri = iter.next().getURI();
        if ( PATTERN_WIKIDATA.matcher(uri).matches() ) { sa.add(uri); }
    }

    for ( String s : sa )
    {
        String sNew = getNew(s);
        if ( sNew == null ) { continue; }

        ResourceUtils.renameResource(m.getResource(s), sNew);
    }

    return m;
}
项目:europeana    文件:LexvoAnalysis.java   
public ObjectStat analyse(File srcList, File src, File dst) throws IOException
{
    Collection<String> c = loadDataURLs(srcList, PATTERN_LEXVO);

    Model m = ModelFactory.createDefaultModel();
    loadModel(m, src, null);

    ObjectStat  stat = new ObjectStat("Lexvo", true, false, true);
    stat.addPropertyValue(m.getProperty("http://www.w3.org/2008/05/skos-xl#literalForm"));

    ResIterator iter = m.listSubjects();
    while ( iter.hasNext() )
    {
        Resource r = iter.next();
        if ( !c.contains(r.getURI()) ) { continue; }
        stat.newObject(r);
    }

    if ( dst != null ) { stat.print(new PrintStream(dst, "UTF-8")); }

    return stat;
}
项目:europeana    文件:BabelNetAnalysis.java   
public ObjectStat analyse(File srcList, File src, File dst) throws IOException
{
    Collection<String> c = loadDataURLs(srcList, PATTERN_BABELNET);

    Model m = ModelFactory.createDefaultModel();
    loadModel(m, src, null);

    ObjectStat  stat = new ObjectStat("BabelNet", true, false, true);
    stat.addPropertyValue(m.getProperty("http://babelnet.org/model/babelnet#gloss"));

    ResIterator iter = m.listSubjects();
    while ( iter.hasNext() )
    {
        Resource r = iter.next();
        if ( !c.contains(r.getURI()) ) { continue; }
        stat.newObject(r);
    }

    if ( dst != null ) { stat.print(new PrintStream(dst, "UTF-8")); }

    return stat;
}
项目:europeana    文件:FreebaseAnalysis.java   
public ObjectStat analyse(File srcList, File src, File dst) throws IOException
{
    Collection<String> c = loadDataURLs(srcList, PATTERN_FREEBASE);

    Model m = ModelFactory.createDefaultModel();
    loadModel(m, src, null);

    ObjectStat  stat = new ObjectStat("Freebase", true, false, true);
    stat.addPropertyValue(m.getProperty("http://www.w3.org/2000/01/rdf-schema#label"));

    ResIterator iter = m.listSubjects();
    while ( iter.hasNext() )
    {
        Resource r = iter.next();
        if ( !c.contains(r.getURI()) ) { continue; }
        stat.newObject(r);
    }

    if ( dst != null ) { stat.print(new PrintStream(dst, "UTF-8")); }

    return stat;
}
项目:europeana    文件:EurovocAnalysis.java   
public ObjectStat analyse(File srcList, File src, File dst) throws IOException
{
    Collection<String> c = loadDataURLs(srcList, PATTERN_EUROVOC);

    Model m = ModelFactory.createDefaultModel();
    loadModel(m, src, null);

    ObjectStat  stat = new ObjectStat("Eurovoc", true, false, true);
    stat.addPropertyValue(m.getProperty("http://www.w3.org/2004/02/skos/core#prefLabel"));
    stat.addPropertyValue(m.getProperty("http://www.w3.org/2004/02/skos/core#altLabel"));

    ResIterator iter = m.listSubjects();
    while ( iter.hasNext() )
    {
        Resource r = iter.next();
        if ( !c.contains(r.getURI()) ) { continue; }
        stat.newObject(r);
    }

    if ( dst != null ) { stat.print(new PrintStream(dst, "UTF-8")); }

    return stat;
}
项目:europeana    文件:RunCheckLabels.java   
public static final void main(String[] args)
{
    PrintStream out = System.out;

    Model m = loadModel(FILE_AGENTS_DBPEDIA_SRC);

    Set<Resource> noLang   = new HashSet();
    Set<Resource> dupLbl   = new HashSet();
    Set<Resource> dupEnLbl = new HashSet();
    ResIterator iter = m.listSubjects();
    while ( iter.hasNext() ) { checkResource(iter.next(), noLang, dupEnLbl, dupLbl); }

    //print
    out.println("Resource with no language: " + noLang.size());
    //for ( Resource rsrc : noLang ) { out.println(rsrc.getURI()); }

    out.println("Resource with duplicate en labels: " + dupEnLbl.size());
    //for ( Resource rsrc : dupEnLbl ) { out.println(rsrc.getURI()); }

    out.println("Resource with duplicate labels in other langs: " + dupLbl.size());
    //for ( Resource rsrc : dupLbl ) { out.println(rsrc.getURI()); }
}
项目:europeana    文件:EuropeanaDatasetEnrich.java   
private void enrichImpl(ResIterator iter, CSVWriter p)
{
    while (iter.hasNext())
    {
        Resource rsrc = iter.next();
        System.out.print("Enriching resource: " + rsrc.getURI());

        List<Map> l = _api.enrich(rsrc);
        if ( l == null ) { System.out.println(); continue; }

        int count = 0;
        for ( Map m : l )
        {
            count++;
            p.print(rsrc.getURI(), m.get("field")
                  , m.get("enrichment"), "", m.get("value"));
        }

        System.out.println(" [" + count + "]");
    }
}
项目:Tapioca    文件:LabelExtractionHandler.java   
/**
 * Read required URIs and save them in a set.
 */
protected void readRequiredUris() {
    // create new set of strings
    Set<String> uris = new HashSet<String>();

    // get all resources with property "VOID.clazz"
    ResIterator iterClasses = voidModel.listResourcesWithProperty(VOID.clazz);
    while (iterClasses.hasNext()) {
        String classUri = iterClasses.nextResource().getProperty(VOID.clazz).getObject().toString();
        uris.add(classUri);
    }

    // get all resources with property "VOID.property"
    ResIterator iterPorperties = voidModel.listResourcesWithProperty(VOID.property);
    while (iterPorperties.hasNext()) {
        String propertyUri = iterPorperties.nextResource().getProperty(VOID.property).getObject().toString();
        uris.add(propertyUri);
    }

    // save the URIs
    this.uris = uris;
}
项目:gerbil    文件:ClassHierarchyLoader.java   
protected Set<Resource> getClasses(Model readModel) {
    ResIterator iterator = readModel.listSubjectsWithProperty(RDF.type, RDFS.Class);
    Resource r;
    Set<Resource> classes = new HashSet<Resource>();
    while (iterator.hasNext()) {
        r = iterator.next();
        if (!r.isAnon()) {
            classes.add(r);
        }
    }
    iterator = readModel.listSubjectsWithProperty(RDF.type, OWL.Class);
    while (iterator.hasNext()) {
        r = iterator.next();
        if (!r.isAnon()) {
            classes.add(r);
        }
    }
    return classes;
}
项目:odrlapi    文件:RDFUtils.java   
public static List<String> getObjectsOfType(Model model, String uri) {
    List<String> policies = new ArrayList();

    ResIterator it = model.listSubjectsWithProperty(RDF.type);
    while (it.hasNext()) {
        Resource res = it.next();
        Statement s = res.getProperty(RDF.type);
        String objeto = s.getObject().asResource().getURI();
        if (s.getObject().isURIResource()) {
            String sujeto = s.getSubject().getURI();
            String ouri = s.getObject().asResource().getURI();
            if (uri.equals(ouri)) {
                policies.add(sujeto);
            }
        }
    }
    return policies;
}
项目:Luzzu    文件:QualityReportTest.java   
@Test
public void generateSeqQualityProblem(){
    qr = new QualityReport();

    String qualityProblemURI = qr.createQualityProblem(metricURI, resourceProblemList);
    Model qualityProblem = qr.getProblemReportFromTBD(qualityProblemURI);

    // checks if model contains appropriate data 
    assertEquals(6, qualityProblem.size());  

    assertTrue(qualityProblem.listStatements(null, RDF.type, QPRO.QualityProblem).hasNext());
    assertTrue(qualityProblem.listStatements(null, QPRO.isDescribedBy, metricURI).hasNext());

    assertEquals(1, qualityProblem.listObjectsOfProperty(QPRO.problematicThing).toList().size());

    ResIterator seqURI = qualityProblem.listSubjectsWithProperty(RDF.type, RDF.Seq);
    assertEquals(2,qualityProblem.getSeq(seqURI.next()).size());

    qr.flush();
}
项目:adapters    文件:CallOpenSDNcore.java   
public void addCreatedTopology(Model resultModel){
  String requestedTopologyURI = null;
  String createdTopologyURI = null;

  ResIterator requestedTopologyIterator = this.createModel.listResourcesWithProperty(Omn.hasResource);
  while(requestedTopologyIterator.hasNext()){
    requestedTopologyURI = requestedTopologyIterator.nextResource().getURI();
    LOGGER.log(Level.INFO, "requested topology URI " + requestedTopologyURI);
  }
  ResIterator createdTopologyIterator = resultModel.listResourcesWithProperty(RDF.type, Omn.Topology);
  while(createdTopologyIterator.hasNext()){
    createdTopologyURI = createdTopologyIterator.nextResource().getURI();
    LOGGER.log(Level.INFO, "created topology URI " + createdTopologyURI);
  }
  toscaAdapter.setTopologies(requestedTopologyURI, createdTopologyURI);

}
项目:adapters    文件:ToscaAdapter.java   
public ToscaAdapter( Model adapterTBox, Resource adapterABox, ToscaMDBSender sender) {
  this.sender = sender;
  this.uuid = UUID.randomUUID().toString();
  this.adapterTBox = adapterTBox;
  this.adapterABox = adapterABox;
  Resource adapterType = null;
    ResIterator adapterIterator = adapterTBox.listSubjectsWithProperty(RDFS.subClassOf, MessageBusOntologyModel.classAdapter);
    if (adapterIterator.hasNext()) {
        adapterType = adapterIterator.next();
    }
  this.adapterABox.addProperty(RDF.type, adapterType);
    this.adapterABox.addProperty(RDFS.label, adapterABox.getLocalName());

    this.adapterABox.addProperty(RDFS.comment, "An adapter for TOSCA-compliant resources");
    Resource testbed = adapterABox.getModel().createResource("http://federation.av.tu-berlin.de/about#AV_Smart_Communication_Testbed");
    this.adapterABox.addProperty(Omn_federation.partOfFederation, testbed);

}
项目:adapters    文件:ToscaAdapter.java   
@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;

}
项目:adapters    文件:ToscaAdapter.java   
@Override
public Model deleteInstances(Model model) throws InvalidRequestException, ProcessingException {

  Model deletedInstancesModel = ModelFactory.createDefaultModel();

  ResIterator resourceInstanceIterator = model.listSubjectsWithProperty(RDF.type, Omn.Topology);
  while(resourceInstanceIterator.hasNext()){
    String instanceURI = resourceInstanceIterator.next().getURI();
    LOGGER.log(Level.INFO, "Deleting adapterABox: " + instanceURI);
    deleteInstance(instanceURI);
    Resource deletedInstance = deletedInstancesModel.createResource(instanceURI);
    deletedInstance.addProperty(Omn_lifecycle.hasState, Omn_lifecycle.Removing);
  }

  return deletedInstancesModel;
}
项目:adapters    文件:ToscaAdapter.java   
@Override
public Model getInstances(Model model) throws ProcessingException, InvalidRequestException, InstanceNotFoundException {
  Model instancesModel = null;
  try{
    instancesModel = super.getInstances(model);
  } catch(InstanceNotFoundException e){
    LOGGER.log(Level.INFO, "No resource instances found, looking for topologies..");
  }

  ResIterator resourceInstanceIterator = model.listSubjectsWithProperty(RDF.type, Omn.Topology);
  while(resourceInstanceIterator.hasNext()){
    String instanceURI = resourceInstanceIterator.next().getURI();
    Model createdInstance = getInstance(instanceURI);
    instancesModel.add(createdInstance);
  }

  return instancesModel;
}
项目:adapters    文件:ToscaAdapter.java   
public Model updateInstances(Model model) throws InvalidRequestException, ProcessingException {
  Model updatedInstancesModel = null;
  try{
    updatedInstancesModel = super.updateInstances(model);
  } catch(InstanceNotFoundException e){
    LOGGER.log(Level.INFO, "No resource instances found, looking for topologies..");
  }

  ResIterator resourceInstanceIterator = model.listSubjectsWithProperty(RDF.type, Omn.Topology);
  while(resourceInstanceIterator.hasNext()){
    Resource resourceInstance = resourceInstanceIterator.next();
    LOGGER.log(Level.INFO, "Updating adapterABox: " + resourceInstance);

    Model updatedModel = updateInstance(resourceInstance.getURI(), model);
    updatedInstancesModel.add(updatedModel);
  }

  return updatedInstancesModel;
}
项目:adapters    文件:NetworkingAdapter.java   
public NetworkingAdapter(Model adapterModel, Resource adapterABox) {
this.uuid = UUID.randomUUID().toString();
this.adapterTBox = adapterModel;
this.adapterABox = adapterABox;
Resource adapterType =getAdapterClass();
this.adapterABox.addProperty(RDF.type,adapterType);
this.adapterABox.addProperty(RDFS.label,  this.adapterABox.getLocalName());
this.adapterABox.addProperty(RDFS.comment, "A networking adapter that can create virtual link among resources.");

NodeIterator resourceIterator = this.adapterTBox.listObjectsOfProperty(Omn_lifecycle.implements_);
if (resourceIterator.hasNext()) {
    Resource resource = resourceIterator.next().asResource();

    this.adapterABox.addProperty(Omn_lifecycle.canImplement, resource);
    this.adapterABox.getModel().add(resource.getModel());
    ResIterator propertiesIterator = adapterTBox.listSubjectsWithProperty(RDFS.domain, resource);
    while (propertiesIterator.hasNext()) {
        Property p = adapterTBox.getProperty(propertiesIterator.next().getURI());
        networkingControlProperties.add(p);
    }
}
}
项目:CarbonDB-reasoner    文件:GroupRepo.java   
protected HashMap<String, Group> getGroups(Resource groupType) {
    HashMap<String, Group> groups = new HashMap<>();

    ResIterator i = model.listSubjectsWithProperty(RDF.type, groupType);
    while (i.hasNext()) {
        Resource resource = i.next();
        try {
            groups.put(getId(resource), getGroup(resource));
        }
        catch (NoUnitException | MalformedOntologyException
               | UnrecogniedUnitException | EmptyDimensionException | NotFoundException e
        ) {
            log.error("Unable to load group " + resource.getURI() + ": " + e.getMessage());
        }
    }

    return groups;
}
项目:Curso2014-2015    文件:ShopsDAO.java   
@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;
  }
项目:Curso2014-2015    文件:GymsDAO.java   
@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;
}
项目:Curso2014-2015    文件:LibrariesDAO.java   
@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;
}
项目:detcrc-portal    文件:NvclVocabService.java   
/**
 * Gets every Jena resource that references the specified label
 * @param label The label to lookup
 * @return
 * @throws PortalServiceException
 */
public List<Resource> getScalarsByLabel(String label) throws PortalServiceException {
    Model model = ModelFactory.createDefaultModel();
    int pageNumber = 0;
    int pageSize = this.getPageSize();

    //Request each page in turn - put the results into Model
    do {
        HttpMethodBase method = ((NvclVocabMethodMaker)sissVocMethodMaker).getScalarsByLabel(getBaseUrl(), getRepository(), label, Format.Rdf, pageSize, pageNumber);
        if (requestPageOfConcepts(method, model)) {
            pageNumber++;
        } else {
            break;
        }
    } while (true);

    Property prefLabelProperty = model.createProperty(VocabNamespaceContext.SKOS_NAMESPACE, "prefLabel");
    ResIterator it = model.listResourcesWithProperty(prefLabelProperty);

    return Lists.newArrayList(it);
}
项目:EarmarkDataStructure    文件:EARMARKDocument.java   
/**
 * This method remove all the linguistic acts having the input EARMARK item as information entity.
 * @param item the item to consider.
 * @return All the RDF statements removed from the model.
 */
protected Set<Statement> removeAllLinguisticActs(EARMARKItem item) {
    Set<Statement> result = new HashSet<Statement>();

    String base = "http://www.ontologydesignpatterns.org/cp/owl/semiotics.owl#";
    Property hasInformationEntity = rdf.createProperty(base + "hasInformationEntity");

    ResIterator linguisticActs = rdf.listSubjectsWithProperty(
            hasInformationEntity, rdf.createResource(item.hasId().toString()));

    while (linguisticActs.hasNext()) {
        result.addAll(removeLinguisticAct(item, linguisticActs.next()));
    }

    return result;
}
项目:lucene-skos-ehri    文件:SKOSEngineImpl.java   
/**
 * Creates the synonym index
 * 
 * @throws IOException
 */
private void indexSKOSModel() throws IOException {
  IndexWriterConfig cfg = new IndexWriterConfig(matchVersion, analyzer);
  IndexWriter writer = new IndexWriter(indexDir, cfg);
  writer.getConfig().setRAMBufferSizeMB(48);

  /* iterate SKOS concepts, create Lucene docs and add them to the index */
  ResIterator concept_iter = skosModel.listResourcesWithProperty(RDF.type,
      SKOS.Concept);
  while (concept_iter.hasNext()) {
    Resource skos_concept = concept_iter.next();

    Document concept_doc = createDocumentsFromConcept(skos_concept);
    if (concept_doc != null) {
      writer.addDocument(concept_doc);
    }
  }

  writer.close();
}
项目:r2rml-kit    文件:R2RMLReader.java   
public Set<Resource> listResourcesWith(Property... properties) {
    Set<Resource> result = new HashSet<Resource>();
    for (Property property: properties) {
        ResIterator it = model.listResourcesWithProperty(property);
        while (it.hasNext()) {
            result.add(it.next());
        }
    }
    return result;
}
项目:r2rml-kit    文件:R2RMLReader.java   
private void checkForSpuriousTypes() {
    // This doesn't catch spurious subclass triples, e.g., rr:SubjectMap,
    // rr:R2RMLView.
    for (ComponentType type: ComponentType.values()) {
        ResIterator it = model.listResourcesWithProperty(RDF.type, type.asResource());
        while (it.hasNext()) {
            Resource r = it.next();
            if (mapping.getMappingComponent(r, type) == null) {
                report.report(Problem.SPURIOUS_TYPE, r, RDF.type, type.asResource());
            }
        }
    }
    remainingTriples.removeAll(null, RDF.type, (RDFNode) null);
}
项目:c4a_data_repository    文件:DirectoryServlet.java   
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");
}
项目:c4a_data_repository    文件:DatasetDescriptionServlet.java   
private static Set<Resource> generatePartitions(Model m, Resource type,
        Property p) {
    Set<Resource> partitions = new HashSet<Resource>();
    ResIterator classIt = m.listResourcesWithProperty(RDF.type, type);
    while (classIt.hasNext()) {
        Resource classMap = classIt.next();
        StmtIterator pIt = classMap.listProperties(p);
        while (pIt.hasNext()) {
            partitions.add((Resource) pIt.next().getObject());
        }
    }
    return partitions;
}
项目:c4a_data_repository    文件:ConfigLoader.java   
protected Resource findServerResource() {
    ResIterator it = this.model.listSubjectsWithProperty(RDF.type,
            D2RConfig.Server);
    if (!it.hasNext()) {
        return null;
    }
    return it.nextResource();
}
项目:c4a_data_repository    文件:ConfigLoader.java   
protected Resource findDatabaseResource() {
    ResIterator it = this.model.listSubjectsWithProperty(RDF.type,
            D2RQ.Database);
    if (!it.hasNext()) {
        return null;
    }
    return it.nextResource();
}
项目:sdh-vocabulary    文件:ModuleHelper.java   
List<Resource> getResourcesOfType(final String type) {
    Preconditions.checkState(this.model!=null);
    final ResIterator iterator =
        this.model.
            listResourcesWithProperty(
                this.model.createProperty("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
                NodeFactory.createURI(type));
    try {
        return iterator.toList();
    } finally {
        iterator.close();
    }
}
项目:Cetus    文件:ClassModelCreator.java   
private static void addSubClassesOf(Resource clazz,
    Resource equivalentClass, Model classModel) {
ResIterator iterator = classModel.listSubjectsWithProperty(
    RDFS.subClassOf, clazz);
Set<Resource> subClasses = new HashSet<Resource>();
while (iterator.hasNext()) {
    subClasses.add(iterator.next());
}
for (Resource subClass : subClasses) {
    if (!classModel
        .contains(subClass, RDFS.subClassOf, equivalentClass)) {
    classModel.add(subClass, RDFS.subClassOf, equivalentClass);
    }
}
   }
项目:ontopia    文件:RDFToTopicMapConverter.java   
private void doConversion(Model model) throws JenaException {
  StatementHandler totm = new ToTMStatementHandler();
  AResourceWrapper subjw = new AResourceWrapper();
  AResourceWrapper propw = new AResourceWrapper();
  AResourceWrapper objtw = new AResourceWrapper();
  ALiteralWrapper litlw = new ALiteralWrapper();

  ResIterator it = model.listSubjects();
  while (it.hasNext()) {
    Resource subject = (Resource) it.next();

    StmtIterator it2 = subject.listProperties(); // get all statements
    while (it2.hasNext()) {
      Statement stmt = (Statement) it2.next();

      subjw.resource = stmt.getSubject();
      propw.resource = stmt.getPredicate();

      RDFNode obj = stmt.getObject();
      if (obj instanceof Resource) {
        objtw.resource = (Resource) obj;
        totm.statement(subjw, propw, objtw);
      } else {
        litlw.literal = (Literal) obj;
        totm.statement(subjw, propw, litlw);
      }
    }
  }
}
项目:europeana    文件:AgentEnrichIssuesAnalyser.java   
public void analyse(File src)
{
    Collection<String> list = new TreeSet();
    Model m = loadModel(src);

    ResIterator iter = m.listResourcesWithProperty(m.getProperty(RDF_TYPE)
                                                 , m.getResource(EDM_AGENT));
    while ( iter.hasNext() )
    {
        Resource rsrc = iter.next();
        if ( check(rsrc) ) { list.add(rsrc.getURI()); }
    }

    for ( String s : list ) { System.out.println(s); }
}